[libvirt] [PATCH 0/5] Fix hyperv and kvm features with QEMU 4.1

Originally the names of the hyperv and kvm CPU features were only used internally for looking up their CPUID bits. But with QEMU 4.1 we check which features were enabled or disabled by a freshly started QEMU process using their names rather than their CPUID bits (mostly because of MSR features). Thus we need to change our made up internal names into the actual names used by QEMU. Otherwise libvirt would mistakenly report the features as unavailable and refuse to start any domain using them with QEMU 4.1. Reported-by: Vitaly Kuznetsov <vkuznets@redhat.com> Jiri Denemark (5): qemu: Fix hyperv features with QEMU 4.1 qemu: Prefer dashes for hyperv features cpu: Drop KVM_ from hyperv feature macros cpu: Drop unused KVM features qemu: Fix KVM features with QEMU 4.1 src/cpu/cpu_x86.c | 77 +++++++------------ src/cpu/cpu_x86_data.h | 38 ++++----- src/qemu/qemu_command.c | 19 +++-- src/qemu/qemu_process.c | 2 +- .../clock-timer-hyperv-rtc.args | 2 +- tests/qemuxml2argvdata/hyperv-panic.args | 2 +- tests/qemuxml2argvdata/hyperv.args | 4 +- tests/qemuxml2argvdata/panic-double.args | 2 +- 8 files changed, 61 insertions(+), 85 deletions(-) -- 2.22.0

Originally the names of the hyperv CPU features were only used internally for looking up their CPUID bits. So we used "__kvm_hv_" prefix for them to make sure the names do not collide with normal CPU features stored in our CPU map. But with QEMU 4.1 we check which features were enabled or disabled by a freshly started QEMU process using their names rather than their CPUID bits (mostly because of MSR features). Thus we need to change our made up internal names into the actual names used by QEMU. Most of the names are only used with QEMU 4.1 and newer and the reset was introduced with QEMU recently enough to already support spelling with "-". Thus we don't need to define them as "hv_*" with a translation to "hv-*" for new QEMU. Without this patch libvirt would mistakenly report all hyperv features as unavailable and refuse to start any domain using them with QEMU 4.1. Reported-by: Vitaly Kuznetsov <vkuznets@redhat.com> Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- src/cpu/cpu_x86_data.h | 28 ++++++++++++++-------------- src/qemu/qemu_process.c | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/cpu/cpu_x86_data.h b/src/cpu/cpu_x86_data.h index f3f4d7ab9c..bb781707aa 100644 --- a/src/cpu/cpu_x86_data.h +++ b/src/cpu/cpu_x86_data.h @@ -56,21 +56,21 @@ struct _virCPUx86MSR { /* * The following HyperV feature names suffixes must exactly match corresponding * ones defined for virDomainHyperv in domain_conf.c. - * E.g "__kvm_runtime" -> "runtime", "__kvm_hv_spinlocks" -> "spinlocks" etc. + * E.g "hv-runtime" -> "runtime", "hv-spinlocks" -> "spinlocks" etc. */ -#define VIR_CPU_x86_KVM_HV_RUNTIME "__kvm_hv_runtime" -#define VIR_CPU_x86_KVM_HV_SYNIC "__kvm_hv_synic" -#define VIR_CPU_x86_KVM_HV_STIMER "__kvm_hv_stimer" -#define VIR_CPU_x86_KVM_HV_RELAXED "__kvm_hv_relaxed" -#define VIR_CPU_x86_KVM_HV_SPINLOCKS "__kvm_hv_spinlocks" -#define VIR_CPU_x86_KVM_HV_VAPIC "__kvm_hv_vapic" -#define VIR_CPU_x86_KVM_HV_VPINDEX "__kvm_hv_vpindex" -#define VIR_CPU_x86_KVM_HV_RESET "__kvm_hv_reset" -#define VIR_CPU_x86_KVM_HV_FREQUENCIES "__kvm_hv_frequencies" -#define VIR_CPU_x86_KVM_HV_REENLIGHTENMENT "__kvm_hv_reenlightenment" -#define VIR_CPU_x86_KVM_HV_TLBFLUSH "__kvm_hv_tlbflush" -#define VIR_CPU_x86_KVM_HV_IPI "__kvm_hv_ipi" -#define VIR_CPU_x86_KVM_HV_EVMCS "__kvm_hv_evmcs" +#define VIR_CPU_x86_KVM_HV_RUNTIME "hv-runtime" +#define VIR_CPU_x86_KVM_HV_SYNIC "hv-synic" +#define VIR_CPU_x86_KVM_HV_STIMER "hv-stimer" +#define VIR_CPU_x86_KVM_HV_RELAXED "hv-relaxed" +#define VIR_CPU_x86_KVM_HV_SPINLOCKS "hv-spinlocks" +#define VIR_CPU_x86_KVM_HV_VAPIC "hv-vapic" +#define VIR_CPU_x86_KVM_HV_VPINDEX "hv-vpindex" +#define VIR_CPU_x86_KVM_HV_RESET "hv-reset" +#define VIR_CPU_x86_KVM_HV_FREQUENCIES "hv-frequencies" +#define VIR_CPU_x86_KVM_HV_REENLIGHTENMENT "hv-reenlightenment" +#define VIR_CPU_x86_KVM_HV_TLBFLUSH "hv-tlbflush" +#define VIR_CPU_x86_KVM_HV_IPI "hv-ipi" +#define VIR_CPU_x86_KVM_HV_EVMCS "hv-evmcs" #define VIR_CPU_X86_DATA_INIT { 0 } diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 75205bc121..7561781848 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4104,7 +4104,7 @@ qemuProcessVerifyHypervFeatures(virDomainDefPtr def, if (def->hyperv_features[i] != VIR_TRISTATE_SWITCH_ON) continue; - if (virAsprintf(&cpuFeature, "__kvm_hv_%s", + if (virAsprintf(&cpuFeature, "hv-%s", virDomainHypervTypeToString(i)) < 0) return -1; -- 2.22.0

Starting with QEMU 4.1, we're using the canonical feature names on the command line and avoid aliases to prepare for possible deprecation of all aliases in QEMU. But we do so only for features from our CPU map, hyperv features defined in the code were unchanged and this patch fixes it. Some features use "hv-" prefix unconditionally because they were introduced recently enough to always support spelling with a dash. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- src/qemu/qemu_command.c | 17 ++++++++++++----- .../clock-timer-hyperv-rtc.args | 2 +- tests/qemuxml2argvdata/hyperv-panic.args | 2 +- tests/qemuxml2argvdata/hyperv.args | 4 ++-- tests/qemuxml2argvdata/panic-double.args | 2 +- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 476e710257..c2f99034c8 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7133,7 +7133,7 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, !!timer->present); } else if (timer->name == VIR_DOMAIN_TIMER_NAME_HYPERVCLOCK && timer->present == 1) { - virBufferAddLit(&buf, ",hv_time"); + virBufferAddLit(&buf, ",hv-time"); } else if (timer->name == VIR_DOMAIN_TIMER_NAME_TSC && timer->frequency > 0) { virBufferAsprintf(&buf, ",tsc-frequency=%lu", timer->frequency); @@ -7151,6 +7151,11 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, } if (def->features[VIR_DOMAIN_FEATURE_HYPERV] == VIR_TRISTATE_SWITCH_ON) { + const char *hvPrefix = "hv-"; + + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CANONICAL_CPU_FEATURES)) + hvPrefix = "hv_"; + for (i = 0; i < VIR_DOMAIN_HYPERV_LAST; i++) { switch ((virDomainHyperv) i) { case VIR_DOMAIN_HYPERV_RELAXED: @@ -7166,19 +7171,21 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, case VIR_DOMAIN_HYPERV_IPI: case VIR_DOMAIN_HYPERV_EVMCS: if (def->hyperv_features[i] == VIR_TRISTATE_SWITCH_ON) - virBufferAsprintf(&buf, ",hv_%s", + virBufferAsprintf(&buf, ",%s%s", + hvPrefix, virDomainHypervTypeToString(i)); break; case VIR_DOMAIN_HYPERV_SPINLOCKS: if (def->hyperv_features[i] == VIR_TRISTATE_SWITCH_ON) - virBufferAsprintf(&buf, ",hv_spinlocks=0x%x", + virBufferAsprintf(&buf, ",%s=0x%x", + VIR_CPU_x86_KVM_HV_SPINLOCKS, def->hyperv_spinlocks); break; case VIR_DOMAIN_HYPERV_VENDOR_ID: if (def->hyperv_features[i] == VIR_TRISTATE_SWITCH_ON) - virBufferAsprintf(&buf, ",hv_vendor_id=%s", + virBufferAsprintf(&buf, ",hv-vendor-id=%s", def->hyperv_vendor_id); break; @@ -7191,7 +7198,7 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, for (i = 0; i < def->npanics; i++) { if (def->panics[i]->model == VIR_DOMAIN_PANIC_MODEL_HYPERV) { - virBufferAddLit(&buf, ",hv_crash"); + virBufferAddLit(&buf, ",hv-crash"); break; } } diff --git a/tests/qemuxml2argvdata/clock-timer-hyperv-rtc.args b/tests/qemuxml2argvdata/clock-timer-hyperv-rtc.args index 98b7dcae1b..d75585bf0f 100644 --- a/tests/qemuxml2argvdata/clock-timer-hyperv-rtc.args +++ b/tests/qemuxml2argvdata/clock-timer-hyperv-rtc.args @@ -11,7 +11,7 @@ QEMU_AUDIO_DRV=none \ -name QEMUGuest1 \ -S \ -machine pc,accel=kvm,usb=off,dump-guest-core=off \ --cpu qemu32,hv_time \ +-cpu qemu32,hv-time \ -m 214 \ -realtime mlock=off \ -smp 6,sockets=6,cores=1,threads=1 \ diff --git a/tests/qemuxml2argvdata/hyperv-panic.args b/tests/qemuxml2argvdata/hyperv-panic.args index 3226837fbd..1ef5068aca 100644 --- a/tests/qemuxml2argvdata/hyperv-panic.args +++ b/tests/qemuxml2argvdata/hyperv-panic.args @@ -11,7 +11,7 @@ QEMU_AUDIO_DRV=none \ -name QEMUGuest1 \ -S \ -machine pc,accel=tcg,usb=off,dump-guest-core=off \ --cpu qemu32,hv_crash \ +-cpu qemu32,hv-crash \ -m 214 \ -realtime mlock=off \ -smp 6,sockets=6,cores=1,threads=1 \ diff --git a/tests/qemuxml2argvdata/hyperv.args b/tests/qemuxml2argvdata/hyperv.args index c557b6d8fe..086adaa349 100644 --- a/tests/qemuxml2argvdata/hyperv.args +++ b/tests/qemuxml2argvdata/hyperv.args @@ -11,8 +11,8 @@ QEMU_AUDIO_DRV=none \ -name QEMUGuest1 \ -S \ -machine pc,accel=tcg,usb=off,dump-guest-core=off \ --cpu 'qemu32,hv_relaxed,hv_vapic,hv_spinlocks=0x2fff,hv_vpindex,hv_runtime,\ -hv_synic,hv_stimer,hv_reset,hv_vendor_id=KVM Hv,hv_frequencies,\ +-cpu 'qemu32,hv_relaxed,hv_vapic,hv-spinlocks=0x2fff,hv_vpindex,hv_runtime,\ +hv_synic,hv_stimer,hv_reset,hv-vendor-id=KVM Hv,hv_frequencies,\ hv_reenlightenment,hv_tlbflush,hv_ipi,hv_evmcs' \ -m 214 \ -realtime mlock=off \ diff --git a/tests/qemuxml2argvdata/panic-double.args b/tests/qemuxml2argvdata/panic-double.args index 8e75816e56..7f49d3482e 100644 --- a/tests/qemuxml2argvdata/panic-double.args +++ b/tests/qemuxml2argvdata/panic-double.args @@ -11,7 +11,7 @@ QEMU_AUDIO_DRV=none \ -name QEMUGuest1 \ -S \ -machine pc,accel=tcg,usb=off,dump-guest-core=off \ --cpu qemu32,hv_crash \ +-cpu qemu32,hv-crash \ -m 214 \ -realtime mlock=off \ -smp 6,sockets=6,cores=1,threads=1 \ -- 2.22.0

All the features are hyperv features even though they are provided by KVM with QEMU. The "KVM" part in the macro names does not make a lot of sense. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- src/cpu/cpu_x86.c | 53 +++++++++++++++++++++-------------------- src/cpu/cpu_x86_data.h | 26 ++++++++++---------- src/qemu/qemu_command.c | 2 +- 3 files changed, 41 insertions(+), 40 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 55b55da784..f8a51dedf6 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -91,31 +91,32 @@ KVM_FEATURE_DEF(VIR_CPU_x86_KVM_PV_UNHALT, 0x40000001, 0x00000080); KVM_FEATURE_DEF(VIR_CPU_x86_KVM_CLOCKSOURCE_STABLE_BIT, 0x40000001, 0x01000000); -KVM_FEATURE_DEF(VIR_CPU_x86_KVM_HV_RUNTIME, + +KVM_FEATURE_DEF(VIR_CPU_x86_HV_RUNTIME, 0x40000003, 0x00000001); -KVM_FEATURE_DEF(VIR_CPU_x86_KVM_HV_SYNIC, +KVM_FEATURE_DEF(VIR_CPU_x86_HV_SYNIC, 0x40000003, 0x00000004); -KVM_FEATURE_DEF(VIR_CPU_x86_KVM_HV_STIMER, +KVM_FEATURE_DEF(VIR_CPU_x86_HV_STIMER, 0x40000003, 0x00000008); -KVM_FEATURE_DEF(VIR_CPU_x86_KVM_HV_RELAXED, +KVM_FEATURE_DEF(VIR_CPU_x86_HV_RELAXED, 0x40000003, 0x00000020); -KVM_FEATURE_DEF(VIR_CPU_x86_KVM_HV_SPINLOCKS, +KVM_FEATURE_DEF(VIR_CPU_x86_HV_SPINLOCKS, 0x40000003, 0x00000022); -KVM_FEATURE_DEF(VIR_CPU_x86_KVM_HV_VAPIC, +KVM_FEATURE_DEF(VIR_CPU_x86_HV_VAPIC, 0x40000003, 0x00000030); -KVM_FEATURE_DEF(VIR_CPU_x86_KVM_HV_VPINDEX, +KVM_FEATURE_DEF(VIR_CPU_x86_HV_VPINDEX, 0x40000003, 0x00000040); -KVM_FEATURE_DEF(VIR_CPU_x86_KVM_HV_RESET, +KVM_FEATURE_DEF(VIR_CPU_x86_HV_RESET, 0x40000003, 0x00000080); -KVM_FEATURE_DEF(VIR_CPU_x86_KVM_HV_FREQUENCIES, +KVM_FEATURE_DEF(VIR_CPU_x86_HV_FREQUENCIES, 0x40000003, 0x00000800); -KVM_FEATURE_DEF(VIR_CPU_x86_KVM_HV_REENLIGHTENMENT, +KVM_FEATURE_DEF(VIR_CPU_x86_HV_REENLIGHTENMENT, 0x40000003, 0x00002000); -KVM_FEATURE_DEF(VIR_CPU_x86_KVM_HV_TLBFLUSH, +KVM_FEATURE_DEF(VIR_CPU_x86_HV_TLBFLUSH, 0x40000004, 0x00000004); -KVM_FEATURE_DEF(VIR_CPU_x86_KVM_HV_IPI, +KVM_FEATURE_DEF(VIR_CPU_x86_HV_IPI, 0x40000004, 0x00000400); -KVM_FEATURE_DEF(VIR_CPU_x86_KVM_HV_EVMCS, +KVM_FEATURE_DEF(VIR_CPU_x86_HV_EVMCS, 0x40000004, 0x00004000); static virCPUx86Feature x86_kvm_features[] = @@ -129,19 +130,19 @@ static virCPUx86Feature x86_kvm_features[] = KVM_FEATURE(VIR_CPU_x86_KVM_PV_EOI), KVM_FEATURE(VIR_CPU_x86_KVM_PV_UNHALT), KVM_FEATURE(VIR_CPU_x86_KVM_CLOCKSOURCE_STABLE_BIT), - KVM_FEATURE(VIR_CPU_x86_KVM_HV_RUNTIME), - KVM_FEATURE(VIR_CPU_x86_KVM_HV_SYNIC), - KVM_FEATURE(VIR_CPU_x86_KVM_HV_STIMER), - KVM_FEATURE(VIR_CPU_x86_KVM_HV_RELAXED), - KVM_FEATURE(VIR_CPU_x86_KVM_HV_SPINLOCKS), - KVM_FEATURE(VIR_CPU_x86_KVM_HV_VAPIC), - KVM_FEATURE(VIR_CPU_x86_KVM_HV_VPINDEX), - KVM_FEATURE(VIR_CPU_x86_KVM_HV_RESET), - KVM_FEATURE(VIR_CPU_x86_KVM_HV_FREQUENCIES), - KVM_FEATURE(VIR_CPU_x86_KVM_HV_REENLIGHTENMENT), - KVM_FEATURE(VIR_CPU_x86_KVM_HV_TLBFLUSH), - KVM_FEATURE(VIR_CPU_x86_KVM_HV_IPI), - KVM_FEATURE(VIR_CPU_x86_KVM_HV_EVMCS), + KVM_FEATURE(VIR_CPU_x86_HV_RUNTIME), + KVM_FEATURE(VIR_CPU_x86_HV_SYNIC), + KVM_FEATURE(VIR_CPU_x86_HV_STIMER), + KVM_FEATURE(VIR_CPU_x86_HV_RELAXED), + KVM_FEATURE(VIR_CPU_x86_HV_SPINLOCKS), + KVM_FEATURE(VIR_CPU_x86_HV_VAPIC), + KVM_FEATURE(VIR_CPU_x86_HV_VPINDEX), + KVM_FEATURE(VIR_CPU_x86_HV_RESET), + KVM_FEATURE(VIR_CPU_x86_HV_FREQUENCIES), + KVM_FEATURE(VIR_CPU_x86_HV_REENLIGHTENMENT), + KVM_FEATURE(VIR_CPU_x86_HV_TLBFLUSH), + KVM_FEATURE(VIR_CPU_x86_HV_IPI), + KVM_FEATURE(VIR_CPU_x86_HV_EVMCS), }; typedef struct _virCPUx86Model virCPUx86Model; diff --git a/src/cpu/cpu_x86_data.h b/src/cpu/cpu_x86_data.h index bb781707aa..85aaab709c 100644 --- a/src/cpu/cpu_x86_data.h +++ b/src/cpu/cpu_x86_data.h @@ -58,19 +58,19 @@ struct _virCPUx86MSR { * ones defined for virDomainHyperv in domain_conf.c. * E.g "hv-runtime" -> "runtime", "hv-spinlocks" -> "spinlocks" etc. */ -#define VIR_CPU_x86_KVM_HV_RUNTIME "hv-runtime" -#define VIR_CPU_x86_KVM_HV_SYNIC "hv-synic" -#define VIR_CPU_x86_KVM_HV_STIMER "hv-stimer" -#define VIR_CPU_x86_KVM_HV_RELAXED "hv-relaxed" -#define VIR_CPU_x86_KVM_HV_SPINLOCKS "hv-spinlocks" -#define VIR_CPU_x86_KVM_HV_VAPIC "hv-vapic" -#define VIR_CPU_x86_KVM_HV_VPINDEX "hv-vpindex" -#define VIR_CPU_x86_KVM_HV_RESET "hv-reset" -#define VIR_CPU_x86_KVM_HV_FREQUENCIES "hv-frequencies" -#define VIR_CPU_x86_KVM_HV_REENLIGHTENMENT "hv-reenlightenment" -#define VIR_CPU_x86_KVM_HV_TLBFLUSH "hv-tlbflush" -#define VIR_CPU_x86_KVM_HV_IPI "hv-ipi" -#define VIR_CPU_x86_KVM_HV_EVMCS "hv-evmcs" +#define VIR_CPU_x86_HV_RUNTIME "hv-runtime" +#define VIR_CPU_x86_HV_SYNIC "hv-synic" +#define VIR_CPU_x86_HV_STIMER "hv-stimer" +#define VIR_CPU_x86_HV_RELAXED "hv-relaxed" +#define VIR_CPU_x86_HV_SPINLOCKS "hv-spinlocks" +#define VIR_CPU_x86_HV_VAPIC "hv-vapic" +#define VIR_CPU_x86_HV_VPINDEX "hv-vpindex" +#define VIR_CPU_x86_HV_RESET "hv-reset" +#define VIR_CPU_x86_HV_FREQUENCIES "hv-frequencies" +#define VIR_CPU_x86_HV_REENLIGHTENMENT "hv-reenlightenment" +#define VIR_CPU_x86_HV_TLBFLUSH "hv-tlbflush" +#define VIR_CPU_x86_HV_IPI "hv-ipi" +#define VIR_CPU_x86_HV_EVMCS "hv-evmcs" #define VIR_CPU_X86_DATA_INIT { 0 } diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index c2f99034c8..7b2cfa0683 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7179,7 +7179,7 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, case VIR_DOMAIN_HYPERV_SPINLOCKS: if (def->hyperv_features[i] == VIR_TRISTATE_SWITCH_ON) virBufferAsprintf(&buf, ",%s=0x%x", - VIR_CPU_x86_KVM_HV_SPINLOCKS, + VIR_CPU_x86_HV_SPINLOCKS, def->hyperv_spinlocks); break; -- 2.22.0

Most of the internally defined KVM CPUID features are not actually used by libvirt. The QEMU driver may enable or disable them on the command line, but we don't check for the associated CPU properties or CPUID bits. They would be useless with QEMU 4.1 anyway since their names were only remotely similar to the actual feature names. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- src/cpu/cpu_x86.c | 24 ------------------------ src/cpu/cpu_x86_data.h | 8 -------- 2 files changed, 32 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index f8a51dedf6..387c365512 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -73,24 +73,8 @@ struct _virCPUx86Feature { } \ } -KVM_FEATURE_DEF(VIR_CPU_x86_KVM_CLOCKSOURCE, - 0x40000001, 0x00000001); -KVM_FEATURE_DEF(VIR_CPU_x86_KVM_NOP_IO_DELAY, - 0x40000001, 0x00000002); -KVM_FEATURE_DEF(VIR_CPU_x86_KVM_MMU_OP, - 0x40000001, 0x00000004); -KVM_FEATURE_DEF(VIR_CPU_x86_KVM_CLOCKSOURCE2, - 0x40000001, 0x00000008); -KVM_FEATURE_DEF(VIR_CPU_x86_KVM_ASYNC_PF, - 0x40000001, 0x00000010); -KVM_FEATURE_DEF(VIR_CPU_x86_KVM_STEAL_TIME, - 0x40000001, 0x00000020); -KVM_FEATURE_DEF(VIR_CPU_x86_KVM_PV_EOI, - 0x40000001, 0x00000040); KVM_FEATURE_DEF(VIR_CPU_x86_KVM_PV_UNHALT, 0x40000001, 0x00000080); -KVM_FEATURE_DEF(VIR_CPU_x86_KVM_CLOCKSOURCE_STABLE_BIT, - 0x40000001, 0x01000000); KVM_FEATURE_DEF(VIR_CPU_x86_HV_RUNTIME, 0x40000003, 0x00000001); @@ -121,15 +105,7 @@ KVM_FEATURE_DEF(VIR_CPU_x86_HV_EVMCS, static virCPUx86Feature x86_kvm_features[] = { - KVM_FEATURE(VIR_CPU_x86_KVM_CLOCKSOURCE), - KVM_FEATURE(VIR_CPU_x86_KVM_NOP_IO_DELAY), - KVM_FEATURE(VIR_CPU_x86_KVM_MMU_OP), - KVM_FEATURE(VIR_CPU_x86_KVM_CLOCKSOURCE2), - KVM_FEATURE(VIR_CPU_x86_KVM_ASYNC_PF), - KVM_FEATURE(VIR_CPU_x86_KVM_STEAL_TIME), - KVM_FEATURE(VIR_CPU_x86_KVM_PV_EOI), KVM_FEATURE(VIR_CPU_x86_KVM_PV_UNHALT), - KVM_FEATURE(VIR_CPU_x86_KVM_CLOCKSOURCE_STABLE_BIT), KVM_FEATURE(VIR_CPU_x86_HV_RUNTIME), KVM_FEATURE(VIR_CPU_x86_HV_SYNIC), KVM_FEATURE(VIR_CPU_x86_HV_STIMER), diff --git a/src/cpu/cpu_x86_data.h b/src/cpu/cpu_x86_data.h index 85aaab709c..2607dd96b1 100644 --- a/src/cpu/cpu_x86_data.h +++ b/src/cpu/cpu_x86_data.h @@ -43,15 +43,7 @@ struct _virCPUx86MSR { #define CPUX86_KVM 0x40000000 #define CPUX86_EXTENDED 0x80000000 -#define VIR_CPU_x86_KVM_CLOCKSOURCE "__kvm_clocksource" -#define VIR_CPU_x86_KVM_NOP_IO_DELAY "__kvm_no_io_delay" -#define VIR_CPU_x86_KVM_MMU_OP "__kvm_mmu_op" -#define VIR_CPU_x86_KVM_CLOCKSOURCE2 "__kvm_clocksource2" -#define VIR_CPU_x86_KVM_ASYNC_PF "__kvm_async_pf" -#define VIR_CPU_x86_KVM_STEAL_TIME "__kvm_steal_time" -#define VIR_CPU_x86_KVM_PV_EOI "__kvm_pv_eoi" #define VIR_CPU_x86_KVM_PV_UNHALT "__kvm_pv_unhalt" -#define VIR_CPU_x86_KVM_CLOCKSOURCE_STABLE_BIT "__kvm_clocksource_stable" /* * The following HyperV feature names suffixes must exactly match corresponding -- 2.22.0

Originally the names of the KVM CPU features were only used internally for looking up their CPUID bits. So we used "__kvm_" prefix for them to make sure the names do not collide with normal CPU features stored in our CPU map. But with QEMU 4.1 we check which features were enabled or disabled by a freshly started QEMU process using their names rather than their CPUID bits (mostly because of MSR features). Thus we need to change our made up internal names into the actual names used by QEMU. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> --- src/cpu/cpu_x86_data.h | 2 +- src/qemu/qemu_command.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cpu/cpu_x86_data.h b/src/cpu/cpu_x86_data.h index 2607dd96b1..cc0c93dff0 100644 --- a/src/cpu/cpu_x86_data.h +++ b/src/cpu/cpu_x86_data.h @@ -43,7 +43,7 @@ struct _virCPUx86MSR { #define CPUX86_KVM 0x40000000 #define CPUX86_EXTENDED 0x80000000 -#define VIR_CPU_x86_KVM_PV_UNHALT "__kvm_pv_unhalt" +#define VIR_CPU_x86_KVM_PV_UNHALT "kvm_pv_unhalt" /* * The following HyperV feature names suffixes must exactly match corresponding diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 7b2cfa0683..fee51158a9 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7146,7 +7146,7 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, } if (def->features[VIR_DOMAIN_FEATURE_PVSPINLOCK]) { - qemuBuildCpuFeature(qemuCaps, &buf, "kvm_pv_unhalt", + qemuBuildCpuFeature(qemuCaps, &buf, VIR_CPU_x86_KVM_PV_UNHALT, def->features[VIR_DOMAIN_FEATURE_PVSPINLOCK] == VIR_TRISTATE_SWITCH_ON); } -- 2.22.0

On Fri, Jul 26, 2019 at 05:30:51PM +0200, Jiri Denemark wrote:
Originally the names of the hyperv and kvm CPU features were only used internally for looking up their CPUID bits. But with QEMU 4.1 we check which features were enabled or disabled by a freshly started QEMU process using their names rather than their CPUID bits (mostly because of MSR features). Thus we need to change our made up internal names into the actual names used by QEMU.
Otherwise libvirt would mistakenly report the features as unavailable and refuse to start any domain using them with QEMU 4.1.
Reported-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Jiri Denemark (5): qemu: Fix hyperv features with QEMU 4.1 qemu: Prefer dashes for hyperv features cpu: Drop KVM_ from hyperv feature macros cpu: Drop unused KVM features qemu: Fix KVM features with QEMU 4.1
Reviewed-by: Ján Tomko <jtomko@redhat.com> Jano

Jiri Denemark <jdenemar@redhat.com> writes:
Originally the names of the hyperv and kvm CPU features were only used internally for looking up their CPUID bits. But with QEMU 4.1 we check which features were enabled or disabled by a freshly started QEMU process using their names rather than their CPUID bits (mostly because of MSR features). Thus we need to change our made up internal names into the actual names used by QEMU.
Otherwise libvirt would mistakenly report the features as unavailable and refuse to start any domain using them with QEMU 4.1.
Reported-by: Vitaly Kuznetsov <vkuznets@redhat.com>
It seems to resolve my issue, so Tested-by: Vitaly Kuznetsov <vkuznets@redhat.com> I'll rebase my 'direct stimer' on top of this, thanks! -- Vitaly
participants (3)
-
Jiri Denemark
-
Ján Tomko
-
Vitaly Kuznetsov