From: "Collin L. Walling" <walling@xxxxxxxxxxxxxxxxxx> 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@xxxxxxxxxxxxxxxxxx> Signed-off-by: Jason J. Herne <jjherne@xxxxxxxxxxxxxxxxxx> --- src/qemu/qemu_command.c | 18 +++++++++++++++-- .../qemuxml2argv-cpu-s390-features.args | 19 ++++++++++++++++++ .../qemuxml2argv-cpu-s390-features.xml | 23 ++++++++++++++++++++++ tests/qemuxml2argvtest.c | 2 ++ 4 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-s390-features.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-s390-features.xml diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index f8e48d2..89226a6 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6665,6 +6665,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); @@ -6672,12 +6680,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: diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-s390-features.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-s390-features.args new file mode 100644 index 0000000..07abc93 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-s390-features.args @@ -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 diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-s390-features.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-s390-features.xml new file mode 100644 index 0000000..47279c4 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-s390-features.xml @@ -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> diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index bd2cdcb..7579c6d 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1522,6 +1522,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); -- 2.7.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list