[PATCH 1/2] vmx: convert cpuid.coresPerSocket for CPU topology

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Convert the cpuid.coresPerSocket key as both number of CPU sockets, and
cores per socket.

Add the VMX file attached to RHBZ#1568148 as testcase esx-in-the-wild-9;
adapt the resulting XML of testcase esx-in-the-wild-8 to the CPU
topology present in that VMX.

https://bugzilla.redhat.com/show_bug.cgi?id=1568148

Signed-off-by: Pino Toscano <ptoscano@xxxxxxxxxx>
---
 src/vmx/vmx.c                                   | 28 ++++++++++
 tests/vmx2xmldata/vmx2xml-esx-in-the-wild-8.xml |  3 ++
 tests/vmx2xmldata/vmx2xml-esx-in-the-wild-9.vmx | 72 +++++++++++++++++++++++++
 tests/vmx2xmldata/vmx2xml-esx-in-the-wild-9.xml | 37 +++++++++++++
 tests/vmx2xmltest.c                             |  1 +
 5 files changed, 141 insertions(+)
 create mode 100644 tests/vmx2xmldata/vmx2xml-esx-in-the-wild-9.vmx
 create mode 100644 tests/vmx2xmldata/vmx2xml-esx-in-the-wild-9.xml

diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index cd43d9c49b..939fa840ab 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -1353,6 +1353,8 @@ virVMXParseConfig(virVMXContext *ctx,
     long long sharedFolder_maxNum = 0;
     int cpumasklen;
     struct virVMXConfigScanResults results = { -1 };
+    long long coresPerSocket = 0;
+    virCPUDefPtr cpu = NULL;
 
     if (ctx->parseFileName == NULL) {
         virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
@@ -1516,6 +1518,31 @@ virVMXParseConfig(virVMXContext *ctx,
     if (virDomainDefSetVcpus(def, numvcpus) < 0)
         goto cleanup;
 
+    /* vmx:cpuid.coresPerSocket -> def:cpu */
+    if (virVMXGetConfigLong(conf, "cpuid.coresPerSocket", &coresPerSocket, 1,
+                            true) < 0)
+        goto cleanup;
+
+    if (coresPerSocket > 1) {
+        if (VIR_ALLOC(cpu) < 0)
+            goto cleanup;
+
+        cpu->type = VIR_CPU_TYPE_GUEST;
+        cpu->mode = VIR_CPU_MODE_CUSTOM;
+
+        cpu->sockets = numvcpus / coresPerSocket;
+        if (cpu->sockets <= 0) {
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                           _("VMX entry 'cpuid.coresPerSocket' smaller than "
+                             "'numvcpus'"));
+            goto cleanup;
+        }
+        cpu->cores = coresPerSocket;
+        cpu->threads = 1;
+
+        VIR_STEAL_PTR(def->cpu, cpu);
+    }
+
     /* vmx:sched.cpu.affinity -> def:cpumask */
     /* NOTE: maps to VirtualMachine:config.cpuAffinity.affinitySet */
     if (virVMXGetConfigString(conf, "sched.cpu.affinity", &sched_cpu_affinity,
@@ -1881,6 +1908,7 @@ virVMXParseConfig(virVMXContext *ctx,
     VIR_FREE(sched_cpu_affinity);
     VIR_FREE(sched_cpu_shares);
     VIR_FREE(guestOS);
+    virCPUDefFree(cpu);
 
     return def;
 }
diff --git a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-8.xml b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-8.xml
index c85ccf3649..eba5f4734a 100644
--- a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-8.xml
+++ b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-8.xml
@@ -10,6 +10,9 @@
   <os>
     <type arch='x86_64'>hvm</type>
   </os>
+  <cpu>
+    <topology sockets='4' cores='2' threads='1'/>
+  </cpu>
   <clock offset='utc'/>
   <on_poweroff>destroy</on_poweroff>
   <on_reboot>restart</on_reboot>
diff --git a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-9.vmx b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-9.vmx
new file mode 100644
index 0000000000..8c3f5b4ba8
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-9.vmx
@@ -0,0 +1,72 @@
+.encoding = "UTF-8"
+config.version = "8"
+virtualHW.version = "10"
+vmci0.present = "TRUE"
+svga.vramSize = "8388608"
+numvcpus = "16"
+memSize = "16384"
+sched.cpu.units = "mhz"
+sched.cpu.latencySensitivity = "normal"
+tools.upgrade.policy = "manual"
+scsi0.virtualDev = "lsisas1068"
+scsi0.present = "TRUE"
+sata0.present = "TRUE"
+scsi0:0.deviceType = "scsi-hardDisk"
+scsi0:0.fileName = "v2v-windows-kkulkarn.vmdk"
+sched.scsi0:0.shares = "normal"
+sched.scsi0:0.throughputCap = "off"
+scsi0:0.present = "TRUE"
+ethernet0.virtualDev = "vmxnet3"
+ethernet0.networkName = "VM Network"
+ethernet0.addressType = "vpx"
+ethernet0.generatedAddress = "00:50:56:80:b3:81"
+ethernet0.uptCompatibility = "TRUE"
+ethernet0.present = "TRUE"
+floppy0.startConnected = "FALSE"
+floppy0.clientDevice = "TRUE"
+floppy0.fileName = "Floppy 0"
+sata0:0.startConnected = "FALSE"
+sata0:0.deviceType = "atapi-cdrom"
+sata0:0.clientDevice = "TRUE"
+sata0:0.fileName = "CD/DVD drive 0"
+sata0:0.present = "TRUE"
+displayName = "v2v-windows-kkulkarn"
+guestOS = "windows8srv-64"
+toolScripts.afterPowerOn = "TRUE"
+toolScripts.afterResume = "TRUE"
+toolScripts.beforeSuspend = "TRUE"
+toolScripts.beforePowerOff = "TRUE"
+tools.syncTime = "FALSE"
+tools.guest.desktop.autolock = "FALSE"
+uuid.bios = "42 00 93 72 17 da be 73-77 9d 00 7c cf 1b d2 28"
+vc.uuid = "50 00 d2 b0 61 6e 61 29-8c 06 82 b0 74 40 a8 71"
+nvram = "v2v-windows-kkulkarn.nvram"
+pciBridge0.present = "TRUE"
+svga.present = "TRUE"
+pciBridge4.present = "TRUE"
+pciBridge4.virtualDev = "pcieRootPort"
+pciBridge4.functions = "8"
+pciBridge5.present = "TRUE"
+pciBridge5.virtualDev = "pcieRootPort"
+pciBridge5.functions = "8"
+pciBridge6.present = "TRUE"
+pciBridge6.virtualDev = "pcieRootPort"
+pciBridge6.functions = "8"
+pciBridge7.present = "TRUE"
+pciBridge7.virtualDev = "pcieRootPort"
+pciBridge7.functions = "8"
+hpet0.present = "TRUE"
+scsi0.pciSlotNumber = "160"
+sata0.pciSlotNumber = "33"
+vmci0.pciSlotNumber = "32"
+ethernet0.pciSlotNumber = "192"
+disk.EnableUUID = "TRUE"
+migrate.hostLog = "v2v-windows-kkulkarn-1017c46c.hlog"
+sched.cpu.min = "0"
+sched.cpu.shares = "normal"
+sched.mem.min = "0"
+sched.mem.minSize = "0"
+sched.mem.shares = "normal"
+migrate.encryptionMode = "opportunistic"
+annotation = "MIQ GUID=b55c806d-99b9-4fa5-bbcc-a4de04f822e5"
+cpuid.coresPerSocket = "4"
diff --git a/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-9.xml b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-9.xml
new file mode 100644
index 0000000000..f1fe6dd4c9
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-esx-in-the-wild-9.xml
@@ -0,0 +1,37 @@
+<domain type='vmware'>
+  <name>v2v-windows-kkulkarn</name>
+  <uuid>42009372-17da-be73-779d-007ccf1bd228</uuid>
+  <description>MIQ GUID=b55c806d-99b9-4fa5-bbcc-a4de04f822e5</description>
+  <memory unit='KiB'>16777216</memory>
+  <currentMemory unit='KiB'>16777216</currentMemory>
+  <vcpu placement='static'>16</vcpu>
+  <cputune>
+    <shares>16000</shares>
+  </cputune>
+  <os>
+    <type arch='x86_64'>hvm</type>
+  </os>
+  <cpu>
+    <topology sockets='4' cores='4' threads='1'/>
+  </cpu>
+  <clock offset='utc'/>
+  <on_poweroff>destroy</on_poweroff>
+  <on_reboot>restart</on_reboot>
+  <on_crash>destroy</on_crash>
+  <devices>
+    <disk type='file' device='disk'>
+      <source file='[datastore] directory/v2v-windows-kkulkarn.vmdk'/>
+      <target dev='sda' bus='scsi'/>
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
+    </disk>
+    <controller type='scsi' index='0' model='lsisas1068'/>
+    <interface type='bridge'>
+      <mac address='00:50:56:80:b3:81'/>
+      <source bridge='VM Network'/>
+      <model type='vmxnet3'/>
+    </interface>
+    <video>
+      <model type='vmvga' vram='8192' primary='yes'/>
+    </video>
+  </devices>
+</domain>
diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c
index 319bf345a3..60913b6b11 100644
--- a/tests/vmx2xmltest.c
+++ b/tests/vmx2xmltest.c
@@ -269,6 +269,7 @@ mymain(void)
     DO_TEST("esx-in-the-wild-6", "esx-in-the-wild-6");
     DO_TEST("esx-in-the-wild-7", "esx-in-the-wild-7");
     DO_TEST("esx-in-the-wild-8", "esx-in-the-wild-8");
+    DO_TEST("esx-in-the-wild-9", "esx-in-the-wild-9");
 
     DO_TEST("gsx-in-the-wild-1", "gsx-in-the-wild-1");
     DO_TEST("gsx-in-the-wild-2", "gsx-in-the-wild-2");
-- 
2.14.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux