From nobody Wed May 14 10:23:43 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1527613067681116.14682769235503; Tue, 29 May 2018 09:57:47 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 931417C0BE; Tue, 29 May 2018 16:57:45 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1DF093083325; Tue, 29 May 2018 16:57:45 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id F096F4CA82; Tue, 29 May 2018 16:57:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w4TGvf0f021911 for ; Tue, 29 May 2018 12:57:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9FDC8300165E; Tue, 29 May 2018 16:57:41 +0000 (UTC) Received: from mx1.redhat.com (ext-mx20.extmail.prod.ext.phx2.redhat.com [10.5.110.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 961593001662 for ; Tue, 29 May 2018 16:57:38 +0000 (UTC) Received: from mail-wm0-f44.google.com (mail-wm0-f44.google.com [74.125.82.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D8D603086272 for ; Tue, 29 May 2018 16:57:26 +0000 (UTC) Received: by mail-wm0-f44.google.com with SMTP id f8-v6so42641017wmc.4 for ; Tue, 29 May 2018 09:57:26 -0700 (PDT) Received: from kloomba.my.domain ([213.147.223.87]) by smtp.gmail.com with ESMTPSA id t133-v6sm7440169lfe.60.2018.05.29.09.57.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 09:57:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XOY8rAzJ/NrO5jQETBfZOJ+u8dc6r9INLcSDxjRHQTo=; b=mtfnJwJh1lpdh/Rr3h/uwahSZbA44S/VQLnXfB3e2YGvooUbHneoH4sun26e9in0pC +o3RlRttrUQM85MAGBn/ufcZ7ObNj2Ztppjvn049/8pqMYa3cGn6fyCL6LXD/3VwcMxs FrJSb7g/XVbYEebC5uPjDhfGJrKbXKGsYW/v6AYrsi0GQwj3tA0zoQotb2e5DUELQIq/ dZZTJBmP8Y22DUPN0un4A6o4NU/1wBF3muxeuG7YKD2on6WsbF0zX2OkHMkQPln7ad18 i7xCFgoXeCzS5TtsLSfodBsNhmAjB7IGi6ZvkY4Pju4X183e44k1aExW3TFJ/DsrEJns hwKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XOY8rAzJ/NrO5jQETBfZOJ+u8dc6r9INLcSDxjRHQTo=; b=rZohqm9j9oKLvgYxeNqvr3fM2nRoU4JNZmOEEsWgAdPyysUMaVmFVvqQ51+crqD7xL eyyg2aP2ICjfhn74WyxYvVIc9F90v5k9t5mUx9NUa+LfsGXqrzc9BI5sI9Qxlo0kQbYZ K3RBNi5UhCyRramtBwPAFxfuD3tGb4ahcWPVmuMpgSUmMkxV0DxIKMpikymrkpebNXnu t4zmCTu3KJ2wG+faRmQ5dS//JA5j17KhniNCd0ybfmy4jS6stIsCcjtBvoK0U/ehojDm x3J/eT0LNTi48jZyPIpDqsa1Q70DTOx8sXED8JQYCSrKIPXAgRrrK48efQzZ7VNkSEj1 c5Zg== X-Gm-Message-State: ALKqPwcMgo3Y74wVU5rQxRYXFI1kU3wSxTObvmRshPuxlTHZV3D4oNyu NdUL2ouTdACHZmUw2OAwm6pPiQ== X-Google-Smtp-Source: ADUXVKL0TgmC8guSLFD//y551mWPF8vfU3qeUntrkFG4CtKHI3cRwGwAG6TzzB6L7BtOumz64OC5Qw== X-Received: by 2002:a2e:8948:: with SMTP id b8-v6mr11952688ljk.31.1527613045100; Tue, 29 May 2018 09:57:25 -0700 (PDT) From: Roman Bogorodskiy To: libvir-list@redhat.com Date: Tue, 29 May 2018 20:57:12 +0400 Message-Id: <20180529165713.47282-2-bogorodskiy@gmail.com> In-Reply-To: <20180529165713.47282-1-bogorodskiy@gmail.com> References: <20180529165713.47282-1-bogorodskiy@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Tue, 29 May 2018 16:57:27 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Tue, 29 May 2018 16:57:27 +0000 (UTC) for IP:'74.125.82.44' DOMAIN:'mail-wm0-f44.google.com' HELO:'mail-wm0-f44.google.com' FROM:'bogorodskiy@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.281 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS, T_DKIM_INVALID) 74.125.82.44 mail-wm0-f44.google.com 74.125.82.44 mail-wm0-f44.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.49 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-loop: libvir-list@redhat.com Cc: Roman Bogorodskiy Subject: [libvirt] [PATCH v2 1/2] bhyve: add CPU topology support X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 29 May 2018 16:57:46 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Recently, bhyve started supporting specifying guest CPU topology. It looks this way: bhyve -c cpus=3DC,sockets=3DS,cores=3DC,threads=3DT ... The old behaviour with bhyve -c C, where C is a number of vCPUs, is still supported. So if we have CPU topology in the domain XML, use the new syntax, otherwise keeps the old behaviour. Signed-off-by: Roman Bogorodskiy Reviewed-by: John Ferlan --- src/bhyve/bhyve_capabilities.c | 7 +++-- src/bhyve/bhyve_capabilities.h | 1 + src/bhyve/bhyve_command.c | 26 ++++++++++++++++++- ...yvexml2argv-cputopology-nvcpu-mismatch.xml | 26 +++++++++++++++++++ .../bhyvexml2argv-cputopology.args | 9 +++++++ .../bhyvexml2argv-cputopology.ldargs | 3 +++ .../bhyvexml2argv-cputopology.xml | 26 +++++++++++++++++++ tests/bhyvexml2argvtest.c | 8 +++++- 8 files changed, 102 insertions(+), 4 deletions(-) create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-cputopology-nvcpu= -mismatch.xml create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-cputopology.args create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-cputopology.ldargs create mode 100644 tests/bhyvexml2argvdata/bhyvexml2argv-cputopology.xml diff --git a/src/bhyve/bhyve_capabilities.c b/src/bhyve/bhyve_capabilities.c index e13085b1d5..a3229cea75 100644 --- a/src/bhyve/bhyve_capabilities.c +++ b/src/bhyve/bhyve_capabilities.c @@ -227,7 +227,7 @@ bhyveProbeCapsDeviceHelper(unsigned int *caps, } =20 static int -bhyveProbeCapsRTC_UTC(unsigned int *caps, char *binary) +bhyveProbeCapsFromHelp(unsigned int *caps, char *binary) { char *help; virCommandPtr cmd =3D NULL; @@ -244,6 +244,9 @@ bhyveProbeCapsRTC_UTC(unsigned int *caps, char *binary) if (strstr(help, "-u:") !=3D NULL) *caps |=3D BHYVE_CAP_RTC_UTC; =20 + if (strstr(help, "sockets=3Dn][,cores=3Dn][,threads=3Dn") !=3D NULL) + *caps |=3D BHYVE_CAP_CPUTOPOLOGY; + out: VIR_FREE(help); virCommandFree(cmd); @@ -314,7 +317,7 @@ virBhyveProbeCaps(unsigned int *caps) if (binary =3D=3D NULL) goto out; =20 - if ((ret =3D bhyveProbeCapsRTC_UTC(caps, binary))) + if ((ret =3D bhyveProbeCapsFromHelp(caps, binary))) goto out; =20 if ((ret =3D bhyveProbeCapsAHCI32Slot(caps, binary))) diff --git a/src/bhyve/bhyve_capabilities.h b/src/bhyve/bhyve_capabilities.h index 0e310e6eda..873bc9c12d 100644 --- a/src/bhyve/bhyve_capabilities.h +++ b/src/bhyve/bhyve_capabilities.h @@ -49,6 +49,7 @@ typedef enum { BHYVE_CAP_LPC_BOOTROM =3D 1 << 3, BHYVE_CAP_FBUF =3D 1 << 4, BHYVE_CAP_XHCI =3D 1 << 5, + BHYVE_CAP_CPUTOPOLOGY =3D 1 << 6, } virBhyveCapsFlags; =20 int virBhyveProbeGrubCaps(virBhyveGrubCapsFlags *caps); diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c index e3f7ded7db..802997bd2d 100644 --- a/src/bhyve/bhyve_command.c +++ b/src/bhyve/bhyve_command.c @@ -462,12 +462,36 @@ virBhyveProcessBuildBhyveCmd(virConnectPtr conn, size_t i; bool add_lpc =3D false; int nusbcontrollers =3D 0; + unsigned int nvcpus =3D virDomainDefGetVcpus(def); =20 virCommandPtr cmd =3D virCommandNew(BHYVE); =20 /* CPUs */ virCommandAddArg(cmd, "-c"); - virCommandAddArgFormat(cmd, "%d", virDomainDefGetVcpus(def)); + if (def->cpu && def->cpu->sockets) { + if (nvcpus !=3D def->cpu->sockets * def->cpu->cores * def->cpu->th= reads) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Invalid CPU topology: total number of vCPUs " + "must equal the product of sockets, cores, " + "and threads")); + goto error; + } + + if ((bhyveDriverGetCaps(conn) & BHYVE_CAP_CPUTOPOLOGY) !=3D 0) { + virCommandAddArgFormat(cmd, "cpus=3D%d,sockets=3D%d,cores=3D%d= ,threads=3D%d", + nvcpus, + def->cpu->sockets, + def->cpu->cores, + def->cpu->threads); + } else { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Installed bhyve binary does not support " + "defining CPU topology")); + goto error; + } + } else { + virCommandAddArgFormat(cmd, "%d", nvcpus); + } =20 /* Memory */ virCommandAddArg(cmd, "-m"); diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-cputopology-nvcpu-mismat= ch.xml b/tests/bhyvexml2argvdata/bhyvexml2argv-cputopology-nvcpu-mismatch.x= ml new file mode 100644 index 0000000000..5bd05fb7da --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-cputopology-nvcpu-mismatch.xml @@ -0,0 +1,26 @@ + + bhyve + df3be7e7-a104-11e3-aeb0-50e5492bd3dc + 219136 + 4 + + + + + hvm + + + + + + +
+ + + + + +
+ + + diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-cputopology.args b/tests= /bhyvexml2argvdata/bhyvexml2argv-cputopology.args new file mode 100644 index 0000000000..2d175a4178 --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-cputopology.args @@ -0,0 +1,9 @@ +/usr/sbin/bhyve \ +-c cpus=3D2,sockets=3D1,cores=3D2,threads=3D1 \ +-m 214 \ +-u \ +-H \ +-P \ +-s 0:0,hostbridge \ +-s 2:0,ahci,hd:/tmp/freebsd.img \ +-s 3:0,virtio-net,faketapdev,mac=3D52:54:00:b9:94:02 bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-cputopology.ldargs b/tes= ts/bhyvexml2argvdata/bhyvexml2argv-cputopology.ldargs new file mode 100644 index 0000000000..32538b558e --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-cputopology.ldargs @@ -0,0 +1,3 @@ +/usr/sbin/bhyveload \ +-m 214 \ +-d /tmp/freebsd.img bhyve diff --git a/tests/bhyvexml2argvdata/bhyvexml2argv-cputopology.xml b/tests/= bhyvexml2argvdata/bhyvexml2argv-cputopology.xml new file mode 100644 index 0000000000..83c7d423c4 --- /dev/null +++ b/tests/bhyvexml2argvdata/bhyvexml2argv-cputopology.xml @@ -0,0 +1,26 @@ + + bhyve + df3be7e7-a104-11e3-aeb0-50e5492bd3dc + 219136 + 2 + + + + + hvm + + + + + + +
+ + + + + +
+ + + diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c index b08b1675f3..6d5f19e2c6 100644 --- a/tests/bhyvexml2argvtest.c +++ b/tests/bhyvexml2argvtest.c @@ -176,7 +176,8 @@ mymain(void) driver.grubcaps =3D BHYVE_GRUB_CAP_CONSDEV; driver.bhyvecaps =3D BHYVE_CAP_RTC_UTC | BHYVE_CAP_AHCI32SLOT | \ BHYVE_CAP_NET_E1000 | BHYVE_CAP_LPC_BOOTROM | \ - BHYVE_CAP_FBUF | BHYVE_CAP_XHCI; + BHYVE_CAP_FBUF | BHYVE_CAP_XHCI | \ + BHYVE_CAP_CPUTOPOLOGY; =20 DO_TEST("base"); DO_TEST("wired"); @@ -207,6 +208,8 @@ mymain(void) DO_TEST("vnc-vgaconf-off"); DO_TEST("vnc-vgaconf-io"); DO_TEST("vnc-autoport"); + DO_TEST("cputopology"); + DO_TEST_FAILURE("cputopology-nvcpu-mismatch"); =20 /* Address allocation tests */ DO_TEST("addr-single-sata-disk"); @@ -243,6 +246,9 @@ mymain(void) driver.bhyvecaps &=3D ~BHYVE_CAP_FBUF; DO_TEST_FAILURE("vnc"); =20 + driver.bhyvecaps &=3D ~BHYVE_CAP_CPUTOPOLOGY; + DO_TEST_FAILURE("cputopology"); + virObjectUnref(driver.caps); virObjectUnref(driver.xmlopt); virPortAllocatorRangeFree(driver.remotePorts); --=20 2.17.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list