mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemu: command: Support new cpu feature argument syntax
Qemu has abandoned the +/-feature syntax in favor of key=value. Some architectures (s390) do not support +/-feature. So we update libvirt to handle both formats. If we detect a sufficiently new Qemu (indicated by support for qmp query-cpu-model-expansion) we use key=value else we fall back to +/-feature. Signed-off-by: Collin L. Walling <walling@linux.vnet.ibm.com> Signed-off-by: Jason J. Herne <jjherne@linux.vnet.ibm.com>
This commit is contained in:
parent
27e411fa83
commit
d47db7b16d
@ -6664,6 +6664,14 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
|
||||
break;
|
||||
}
|
||||
|
||||
if (ARCH_IS_S390(def->os.arch) && cpu->features &&
|
||||
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION)) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("CPU features not supported by hypervisor for %s "
|
||||
"architecture"), virArchToString(def->os.arch));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (cpu->vendor_id)
|
||||
virBufferAsprintf(buf, ",vendor=%s", cpu->vendor_id);
|
||||
|
||||
@ -6671,12 +6679,18 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
|
||||
switch ((virCPUFeaturePolicy) cpu->features[i].policy) {
|
||||
case VIR_CPU_FEATURE_FORCE:
|
||||
case VIR_CPU_FEATURE_REQUIRE:
|
||||
virBufferAsprintf(buf, ",+%s", cpu->features[i].name);
|
||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION))
|
||||
virBufferAsprintf(buf, ",%s=on", cpu->features[i].name);
|
||||
else
|
||||
virBufferAsprintf(buf, ",+%s", cpu->features[i].name);
|
||||
break;
|
||||
|
||||
case VIR_CPU_FEATURE_DISABLE:
|
||||
case VIR_CPU_FEATURE_FORBID:
|
||||
virBufferAsprintf(buf, ",-%s", cpu->features[i].name);
|
||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION))
|
||||
virBufferAsprintf(buf, ",%s=off", cpu->features[i].name);
|
||||
else
|
||||
virBufferAsprintf(buf, ",-%s", cpu->features[i].name);
|
||||
break;
|
||||
|
||||
case VIR_CPU_FEATURE_OPTIONAL:
|
||||
|
19
tests/qemuxml2argvdata/qemuxml2argv-cpu-s390-features.args
Normal file
19
tests/qemuxml2argvdata/qemuxml2argv-cpu-s390-features.args
Normal file
@ -0,0 +1,19 @@
|
||||
LC_ALL=C \
|
||||
PATH=/bin \
|
||||
HOME=/home/test \
|
||||
USER=test \
|
||||
LOGNAME=test \
|
||||
QEMU_AUDIO_DRV=none \
|
||||
/usr/bin/qemu-kvm \
|
||||
-name guest1 \
|
||||
-S \
|
||||
-M s390-ccw-virtio \
|
||||
-cpu zEC12,dfppc=on,stckf=off \
|
||||
-m 214 \
|
||||
-smp 1,sockets=1,cores=1,threads=1 \
|
||||
-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
|
||||
-nographic \
|
||||
-nodefaults \
|
||||
-monitor unix:/tmp/lib/domain--1-guest1/monitor.sock,server,nowait \
|
||||
-no-acpi \
|
||||
-boot c
|
23
tests/qemuxml2argvdata/qemuxml2argv-cpu-s390-features.xml
Normal file
23
tests/qemuxml2argvdata/qemuxml2argv-cpu-s390-features.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<domain type='kvm'>
|
||||
<name>guest1</name>
|
||||
<uuid>c7a5fdbd-edaf-9455-926a-d65c16db1809</uuid>
|
||||
<memory unit='KiB'>219100</memory>
|
||||
<currentMemory unit='KiB'>219100</currentMemory>
|
||||
<vcpu placement='static'>1</vcpu>
|
||||
<os>
|
||||
<type arch='s390x' machine='s390-ccw-virtio'>hvm</type>
|
||||
</os>
|
||||
<clock offset='utc'/>
|
||||
<on_poweroff>destroy</on_poweroff>
|
||||
<on_reboot>restart</on_reboot>
|
||||
<on_crash>destroy</on_crash>
|
||||
<cpu mode='custom' match='exact'>
|
||||
<model fallback='forbid'>zEC12</model>
|
||||
<feature policy='require' name='dfppc'/>
|
||||
<feature policy='disable' name='stckf'/>
|
||||
</cpu>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu-kvm</emulator>
|
||||
<memballoon model='none'/>
|
||||
</devices>
|
||||
</domain>
|
@ -1530,6 +1530,8 @@ mymain(void)
|
||||
|
||||
qemuTestSetHostArch(driver.caps, VIR_ARCH_S390X);
|
||||
DO_TEST("cpu-s390-zEC12", QEMU_CAPS_KVM, QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390);
|
||||
DO_TEST("cpu-s390-features", QEMU_CAPS_KVM, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION);
|
||||
DO_TEST_FAILURE("cpu-s390-features", QEMU_CAPS_KVM);
|
||||
qemuTestSetHostArch(driver.caps, VIR_ARCH_NONE);
|
||||
|
||||
qemuTestSetHostCPU(driver.caps, cpuHaswell);
|
||||
|
Loading…
x
Reference in New Issue
Block a user