From: Joao Martins <joao.m.mart...@oracle.com> When enabling reporting to the guest that the hypervisor is KVM via "+kvm", we also enable all of the known KVM features that are supported by the host kernel. A new "kvm-no-defaults" option for -cpu defeats this, enabling KVM reporting but *not* enabling any specific KVM features. Those features can be enabled one-by-one using existing feature flags, such as kvmclock, kvm-pv-eoi, etc.
Signed-off-by: Joao Martins <joao.m.mart...@oracle.com> Signed-off-by: David Edmondson <david.edmond...@oracle.com> --- target/i386/cpu.c | 5 +++++ target/i386/cpu.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 13f58ef183..4f1e807815 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6398,6 +6398,10 @@ static void x86_cpu_expand_features(X86CPU *cpu, Error **errp) int i; GList *l; + if (kvm_enabled() && cpu->kvm_no_defaults) { + env->features[FEAT_KVM] = 0; + } + for (l = plus_features; l; l = l->next) { const char *prop = l->data; if (!object_property_set_bool(OBJECT(cpu), prop, true, errp)) { @@ -7269,6 +7273,7 @@ static Property x86_cpu_properties[] = { DEFINE_PROP_BOOL("cpuid-0xb", X86CPU, enable_cpuid_0xb, true), DEFINE_PROP_BOOL("lmce", X86CPU, enable_lmce, false), DEFINE_PROP_BOOL("l3-cache", X86CPU, enable_l3_cache, true), + DEFINE_PROP_BOOL("kvm-no-defaults", X86CPU, kvm_no_defaults, false), DEFINE_PROP_BOOL("kvm-no-smi-migration", X86CPU, kvm_no_smi_migration, false), DEFINE_PROP_BOOL("vmware-cpuid-freq", X86CPU, vmware_cpuid_freq, true), diff --git a/target/i386/cpu.h b/target/i386/cpu.h index d23a5b340a..f76af4a771 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1744,6 +1744,9 @@ struct X86CPU { /* if set, limit maximum value for phys_bits when host_phys_bits is true */ uint8_t host_phys_bits_limit; + /* Don't automatically enable all of the discovered KVM features. */ + bool kvm_no_defaults; + /* Stop SMI delivery for migration compatibility with old machines */ bool kvm_no_smi_migration; -- 2.29.2