OSDN Git Service

i386: use global kvm_state in hyperv_enabled() check
authorVitaly Kuznetsov <vkuznets@redhat.com>
Thu, 22 Apr 2021 16:11:25 +0000 (18:11 +0200)
committerEduardo Habkost <ehabkost@redhat.com>
Mon, 31 May 2021 19:53:03 +0000 (15:53 -0400)
There is no need to use vCPU-specific kvm state in hyperv_enabled() check
and we need to do that when feature expansion happens early, before vCPU
specific KVM state is created.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>
Message-Id: <20210422161130.652779-15-vkuznets@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
target/i386/kvm/kvm.c

index 6bcb74b..c676ee8 100644 (file)
@@ -716,8 +716,7 @@ unsigned long kvm_arch_vcpu_id(CPUState *cs)
 
 static bool hyperv_enabled(X86CPU *cpu)
 {
-    CPUState *cs = CPU(cpu);
-    return kvm_check_extension(cs->kvm_state, KVM_CAP_HYPERV) > 0 &&
+    return kvm_check_extension(kvm_state, KVM_CAP_HYPERV) > 0 &&
         ((cpu->hyperv_spinlock_attempts != HYPERV_SPINLOCK_NEVER_NOTIFY) ||
          cpu->hyperv_features || cpu->hyperv_passthrough);
 }