From nobody Wed May 14 11:55:26 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1524143029066435.7778182816602; Thu, 19 Apr 2018 06:03:49 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7D6DC3130674; Thu, 19 Apr 2018 13:03:47 +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 186FB82F62; Thu, 19 Apr 2018 13:03:47 +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 A049B4CA9E; Thu, 19 Apr 2018 13:03:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w3JD3ihS020135 for ; Thu, 19 Apr 2018 09:03:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id EEAF7202660D; Thu, 19 Apr 2018 13:03:43 +0000 (UTC) Received: from thyrus.usersys.redhat.com (unknown [10.43.2.1]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 92EB62026985 for ; Thu, 19 Apr 2018 13:03:43 +0000 (UTC) From: Pino Toscano To: libvir-list@redhat.com Date: Thu, 19 Apr 2018 15:03:38 +0200 Message-Id: <20180419130338.10314-3-ptoscano@redhat.com> In-Reply-To: <20180419130338.10314-1-ptoscano@redhat.com> References: <20180419130338.10314-1-ptoscano@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/2] vmx: write cpuid.coresPerSocket back from CPU topology 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.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Thu, 19 Apr 2018 13:03:48 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" When writing the VMX file from the domain XML, write cpuid.coresPerSocket if there is a specified CPU topology in the guest. Use the domain XML of esx-in-the-wild-9 in vmx2xml as testcase for xml2vmxtest. Signed-off-by: Pino Toscano --- src/vmx/vmx.c | 29 ++++++++++++++++++ tests/xml2vmxdata/xml2vmx-esx-in-the-wild-9.vmx | 39 +++++++++++++++++++++= ++++ tests/xml2vmxdata/xml2vmx-esx-in-the-wild-9.xml | 37 +++++++++++++++++++++= ++ tests/xml2vmxtest.c | 1 + 4 files changed, 106 insertions(+) create mode 100644 tests/xml2vmxdata/xml2vmx-esx-in-the-wild-9.vmx create mode 100644 tests/xml2vmxdata/xml2vmx-esx-in-the-wild-9.xml diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 939fa840ab..8027a7bba6 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -3246,6 +3246,35 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLO= ptionPtr xmlopt, virDomainDe =20 virBufferAsprintf(&buffer, "numvcpus =3D \"%d\"\n", maxvcpus); =20 + if (def->cpu) { + unsigned int calculated_vcpus; + + if (def->cpu->mode !=3D VIR_CPU_MODE_CUSTOM) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Expecting domain XML CPU mode 'custom' but " + "found '%s'"), + virCPUModeTypeToString(def->cpu->mode)); + goto cleanup; + } + + if (def->cpu->threads !=3D 1) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Only 1 thread per core is supported")); + goto cleanup; + } + + calculated_vcpus =3D def->cpu->sockets * def->cpu->cores; + if (calculated_vcpus !=3D maxvcpus) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Expecting domain XML CPU sockets per core as= %d " + "but found %d"), + maxvcpus, calculated_vcpus); + goto cleanup; + } + + virBufferAsprintf(&buffer, "cpuid.coresPerSocket =3D \"%d\"\n", de= f->cpu->cores); + } + /* def:cpumask -> vmx:sched.cpu.affinity */ if (def->cpumask && virBitmapSize(def->cpumask) > 0) { int bit; diff --git a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-9.vmx b/tests/xml2vm= xdata/xml2vmx-esx-in-the-wild-9.vmx new file mode 100644 index 0000000000..f92650f7ea --- /dev/null +++ b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-9.vmx @@ -0,0 +1,39 @@ +.encoding =3D "UTF-8" +config.version =3D "8" +virtualHW.version =3D "10" +guestOS =3D "other-64" +uuid.bios =3D "42 00 93 72 17 da be 73-77 9d 00 7c cf 1b d2 28" +displayName =3D "v2v-windows-kkulkarn" +annotation =3D "MIQ GUID=3Db55c806d-99b9-4fa5-bbcc-a4de04f822e5" +memsize =3D "16384" +numvcpus =3D "16" +cpuid.coresPerSocket =3D "4" +sched.cpu.shares =3D "normal" +scsi0.present =3D "true" +scsi0.virtualDev =3D "lsisas1068" +scsi0:0.present =3D "true" +scsi0:0.deviceType =3D "scsi-hardDisk" +scsi0:0.fileName =3D "/vmfs/volumes/datastore/directory/v2v-windows-kkulka= rn.vmdk" +floppy0.present =3D "false" +floppy1.present =3D "false" +ethernet0.present =3D "true" +ethernet0.virtualDev =3D "vmxnet3" +ethernet0.networkName =3D "VM Network" +ethernet0.connectionType =3D "bridged" +ethernet0.addressType =3D "vpx" +ethernet0.generatedAddress =3D "00:50:56:80:b3:81" +svga.vramSize =3D "8388608" +pciBridge0.present =3D "true" +pciBridge4.present =3D "true" +pciBridge4.virtualDev =3D "pcieRootPort" +pciBridge4.functions =3D "8" +pciBridge5.present =3D "true" +pciBridge5.virtualDev =3D "pcieRootPort" +pciBridge5.functions =3D "8" +pciBridge6.present =3D "true" +pciBridge6.virtualDev =3D "pcieRootPort" +pciBridge6.functions =3D "8" +pciBridge7.present =3D "true" +pciBridge7.virtualDev =3D "pcieRootPort" +pciBridge7.functions =3D "8" +vmci0.present =3D "true" diff --git a/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-9.xml b/tests/xml2vm= xdata/xml2vmx-esx-in-the-wild-9.xml new file mode 100644 index 0000000000..f1fe6dd4c9 --- /dev/null +++ b/tests/xml2vmxdata/xml2vmx-esx-in-the-wild-9.xml @@ -0,0 +1,37 @@ + + v2v-windows-kkulkarn + 42009372-17da-be73-779d-007ccf1bd228 + MIQ GUID=3Db55c806d-99b9-4fa5-bbcc-a4de04f822e5 + 16777216 + 16777216 + 16 + + 16000 + + + hvm + + + + + + destroy + restart + destroy + + + + +
+ + + + + + + + + + diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c index 7b01151974..f6bcd7b012 100644 --- a/tests/xml2vmxtest.c +++ b/tests/xml2vmxtest.c @@ -279,6 +279,7 @@ mymain(void) DO_TEST("esx-in-the-wild-5", "esx-in-the-wild-5", 4); DO_TEST("esx-in-the-wild-6", "esx-in-the-wild-6", 4); DO_TEST("esx-in-the-wild-7", "esx-in-the-wild-7", 4); + DO_TEST("esx-in-the-wild-9", "esx-in-the-wild-9", 10); =20 DO_TEST("gsx-in-the-wild-1", "gsx-in-the-wild-1", 4); DO_TEST("gsx-in-the-wild-2", "gsx-in-the-wild-2", 4); --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list