Normal CPU features use modern -cpu ...,feature=on|off syntax when
available, but kvm features kept using the old +feature or -feature.
Signed-off-by: Jiri Denemark <jdenemar(a)redhat.com>
---
src/qemu/qemu_command.c | 46 +++++++++----------
.../eoi-disabled.x86_64-latest.args | 2 +-
.../eoi-enabled.x86_64-latest.args | 2 +-
.../kvmclock+eoi-disabled.x86_64-latest.args | 2 +-
.../pv-spinlock-disabled.x86_64-latest.args | 2 +-
.../pv-spinlock-enabled.x86_64-latest.args | 2 +-
6 files changed, 26 insertions(+), 30 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index a23e428322..08da30d10c 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -7039,6 +7039,19 @@ qemuBuildGlobalControllerCommandLine(virCommandPtr cmd,
}
+static void
+qemuBuildCpuFeature(virQEMUCapsPtr qemuCaps,
+ virBufferPtr buf,
+ const char *name,
+ bool state)
+{
+ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION))
+ virBufferAsprintf(buf, ",%s=%s", name, state ? "on" :
"off");
+ else
+ virBufferAsprintf(buf, ",%c%s", state ? '+' : '-',
name);
+}
+
+
static int
qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
const virDomainDef *def,
@@ -7109,18 +7122,12 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver,
switch ((virCPUFeaturePolicy) cpu->features[i].policy) {
case VIR_CPU_FEATURE_FORCE:
case VIR_CPU_FEATURE_REQUIRE:
- 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);
+ qemuBuildCpuFeature(qemuCaps, buf, cpu->features[i].name, true);
break;
case VIR_CPU_FEATURE_DISABLE:
case VIR_CPU_FEATURE_FORBID:
- 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);
+ qemuBuildCpuFeature(qemuCaps, buf, cpu->features[i].name, false);
break;
case VIR_CPU_FEATURE_OPTIONAL:
@@ -7179,8 +7186,8 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
if (timer->name == VIR_DOMAIN_TIMER_NAME_KVMCLOCK &&
timer->present != -1) {
- virBufferAsprintf(&buf, ",%ckvmclock",
- timer->present ? '+' : '-');
+ qemuBuildCpuFeature(qemuCaps, &buf, "kvmclock",
+ !!timer->present);
} else if (timer->name == VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK &&
timer->present == 1) {
virBufferAddLit(&buf, ",hv_time");
@@ -7191,24 +7198,13 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
}
if (def->apic_eoi) {
- char sign;
- if (def->apic_eoi == VIR_TRISTATE_SWITCH_ON)
- sign = '+';
- else
- sign = '-';
-
- virBufferAsprintf(&buf, ",%ckvm_pv_eoi", sign);
+ qemuBuildCpuFeature(qemuCaps, &buf, "kvm_pv_eoi",
+ def->apic_eoi == VIR_TRISTATE_SWITCH_ON);
}
if (def->features[VIR_DOMAIN_FEATURE_PVSPINLOCK]) {
- char sign;
- if (def->features[VIR_DOMAIN_FEATURE_PVSPINLOCK] ==
- VIR_TRISTATE_SWITCH_ON)
- sign = '+';
- else
- sign = '-';
-
- virBufferAsprintf(&buf, ",%ckvm_pv_unhalt", sign);
+ qemuBuildCpuFeature(qemuCaps, &buf, "kvm_pv_unhalt",
+ def->features[VIR_DOMAIN_FEATURE_PVSPINLOCK] ==
VIR_TRISTATE_SWITCH_ON);
}
if (def->features[VIR_DOMAIN_FEATURE_HYPERV] == VIR_TRISTATE_SWITCH_ON) {
diff --git a/tests/qemuxml2argvdata/eoi-disabled.x86_64-latest.args
b/tests/qemuxml2argvdata/eoi-disabled.x86_64-latest.args
index e59d0ab29b..caae868abf 100644
--- a/tests/qemuxml2argvdata/eoi-disabled.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/eoi-disabled.x86_64-latest.args
@@ -13,7 +13,7 @@ QEMU_AUDIO_DRV=none \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
-machine pc,accel=tcg,usb=off,dump-guest-core=off \
--cpu qemu32,-kvm_pv_eoi \
+-cpu qemu32,kvm_pv_eoi=off \
-m 214 \
-overcommit mem-lock=off \
-smp 6,sockets=6,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/eoi-enabled.x86_64-latest.args
b/tests/qemuxml2argvdata/eoi-enabled.x86_64-latest.args
index fed8deb688..abafafa411 100644
--- a/tests/qemuxml2argvdata/eoi-enabled.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/eoi-enabled.x86_64-latest.args
@@ -13,7 +13,7 @@ QEMU_AUDIO_DRV=none \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
-machine pc,accel=tcg,usb=off,dump-guest-core=off \
--cpu qemu32,+kvm_pv_eoi \
+-cpu qemu32,kvm_pv_eoi=on \
-m 214 \
-overcommit mem-lock=off \
-smp 6,sockets=6,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/kvmclock+eoi-disabled.x86_64-latest.args
b/tests/qemuxml2argvdata/kvmclock+eoi-disabled.x86_64-latest.args
index c1c6e2b621..23d2bcb87e 100644
--- a/tests/qemuxml2argvdata/kvmclock+eoi-disabled.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/kvmclock+eoi-disabled.x86_64-latest.args
@@ -13,7 +13,7 @@ QEMU_AUDIO_DRV=none \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
-machine pc,accel=tcg,usb=off,dump-guest-core=off \
--cpu qemu32,-kvmclock,-kvm_pv_eoi \
+-cpu qemu32,kvmclock=off,kvm_pv_eoi=off \
-m 214 \
-overcommit mem-lock=off \
-smp 6,sockets=6,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/pv-spinlock-disabled.x86_64-latest.args
b/tests/qemuxml2argvdata/pv-spinlock-disabled.x86_64-latest.args
index 52a36ca075..b78533cf39 100644
--- a/tests/qemuxml2argvdata/pv-spinlock-disabled.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/pv-spinlock-disabled.x86_64-latest.args
@@ -13,7 +13,7 @@ QEMU_AUDIO_DRV=none \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
-machine pc,accel=tcg,usb=off,dump-guest-core=off \
--cpu qemu32,-kvm_pv_unhalt \
+-cpu qemu32,kvm_pv_unhalt=off \
-m 214 \
-overcommit mem-lock=off \
-smp 6,sockets=6,cores=1,threads=1 \
diff --git a/tests/qemuxml2argvdata/pv-spinlock-enabled.x86_64-latest.args
b/tests/qemuxml2argvdata/pv-spinlock-enabled.x86_64-latest.args
index 4f1ab219af..a016e80016 100644
--- a/tests/qemuxml2argvdata/pv-spinlock-enabled.x86_64-latest.args
+++ b/tests/qemuxml2argvdata/pv-spinlock-enabled.x86_64-latest.args
@@ -13,7 +13,7 @@ QEMU_AUDIO_DRV=none \
-object secret,id=masterKey0,format=raw,\
file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \
-machine pc,accel=tcg,usb=off,dump-guest-core=off \
--cpu qemu32,+kvm_pv_unhalt \
+-cpu qemu32,kvm_pv_unhalt=on \
-m 214 \
-overcommit mem-lock=off \
-smp 6,sockets=6,cores=1,threads=1 \
--
2.22.0