]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Add support for pseries machine's max-cpu-compat= parameter
authorShivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
Fri, 5 Jan 2018 13:48:00 +0000 (19:18 +0530)
committerAndrea Bolognani <abologna@redhat.com>
Fri, 5 Jan 2018 16:12:14 +0000 (17:12 +0100)
When the -machine pseries,max-cpu-compat=X is supported use
machine parameter instead of -cpu host,compat=X parameter as
that is deprecated now with qemu >= v2.10.

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

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
src/qemu/qemu_command.c
tests/qemuxml2argvdata/pseries-machine-max-cpu-compat.args [new file with mode: 0644]
tests/qemuxml2argvdata/pseries-machine-max-cpu-compat.xml [new file with mode: 0644]
tests/qemuxml2argvtest.c

index 4d0c141e557525d0801dc10730ba838cc2ee7c21..b8aede32d298ce38483c55b9d1fb49e6154a58c7 100644 (file)
@@ -6923,8 +6923,11 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
     case VIR_CPU_MODE_HOST_MODEL:
         if (ARCH_IS_PPC64(def->os.arch)) {
             virBufferAddLit(buf, "host");
-            if (cpu->model)
+            if (cpu->model &&
+                !(qemuDomainIsPSeries(def) &&
+                  virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_PSERIES_MAX_CPU_COMPAT))) {
                 virBufferAsprintf(buf, ",compat=%s", cpu->model);
+            }
         } else {
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("unexpected host-model CPU for %s architecture"),
@@ -7414,6 +7417,7 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
     } else {
         virTristateSwitch vmport = def->features[VIR_DOMAIN_FEATURE_VMPORT];
         virTristateSwitch smm = def->features[VIR_DOMAIN_FEATURE_SMM];
+        virCPUDefPtr cpu = def->cpu;
 
         virCommandAddArg(cmd, "-machine");
         virBufferAdd(&buf, def->os.machine, -1);
@@ -7588,6 +7592,13 @@ qemuBuildMachineCommandLine(virCommandPtr cmd,
             virBufferAsprintf(&buf, ",resize-hpt=%s", str);
         }
 
+        if (cpu && cpu->model &&
+            cpu->mode == VIR_CPU_MODE_HOST_MODEL &&
+            qemuDomainIsPSeries(def) &&
+            virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_PSERIES_MAX_CPU_COMPAT)) {
+            virBufferAsprintf(&buf, ",max-cpu-compat=%s", cpu->model);
+        }
+
         if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX) &&
             virQEMUCapsGet(qemuCaps, QEMU_CAPS_LOADPARM))
             qemuAppendLoadparmMachineParm(&buf, def);
diff --git a/tests/qemuxml2argvdata/pseries-machine-max-cpu-compat.args b/tests/qemuxml2argvdata/pseries-machine-max-cpu-compat.args
new file mode 100644 (file)
index 0000000..2796d23
--- /dev/null
@@ -0,0 +1,21 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/home/test \
+USER=test \
+LOGNAME=test \
+QEMU_AUDIO_DRV=none \
+/usr/bin/qemu-system-ppc64 \
+-name QEMUGuest1 \
+-S \
+-machine pseries,accel=kvm,max-cpu-compat=power7 \
+-cpu host \
+-m 256 \
+-smp 4,sockets=4,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-nographic \
+-nodefconfig \
+-nodefaults \
+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\
+server,nowait \
+-mon chardev=charmonitor,id=monitor,mode=readline \
+-boot c
diff --git a/tests/qemuxml2argvdata/pseries-machine-max-cpu-compat.xml b/tests/qemuxml2argvdata/pseries-machine-max-cpu-compat.xml
new file mode 100644 (file)
index 0000000..ad26473
--- /dev/null
@@ -0,0 +1,17 @@
+<domain type='kvm'>
+  <name>QEMUGuest1</name>
+  <uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
+  <memory unit='KiB'>219100</memory>
+  <vcpu placement='static'>4</vcpu>
+  <os>
+    <type arch='ppc64' machine='pseries'>hvm</type>
+  </os>
+  <cpu mode='host-model'>
+    <model>power7</model>
+  </cpu>
+  <devices>
+    <emulator>/usr/bin/qemu-system-ppc64</emulator>
+    <controller type='usb' model='none'/>
+    <memballoon model="none"/>
+  </devices>
+</domain>
index fe15072dc1dc55350adf12418de0357d799306bc..be32d891e14c496d434a5fdedaf3537872dcb0f8 100644 (file)
@@ -1816,6 +1816,11 @@ mymain(void)
     DO_TEST("pseries-cpu-compat", QEMU_CAPS_KVM,
             QEMU_CAPS_DEVICE_SPAPR_VTY,
             QEMU_CAPS_NODEFCONFIG);
+    DO_TEST("pseries-machine-max-cpu-compat",
+            QEMU_CAPS_KVM,
+            QEMU_CAPS_MACHINE_OPT,
+            QEMU_CAPS_MACHINE_PSERIES_MAX_CPU_COMPAT,
+            QEMU_CAPS_NODEFCONFIG);
     DO_TEST("pseries-cpu-le", QEMU_CAPS_KVM,
             QEMU_CAPS_DEVICE_SPAPR_VTY,
             QEMU_CAPS_NODEFCONFIG);