KVM_CAP_HYPERV is a VM ioctl and can be cached at kvm_arch_init() instead of performing an ioctl each time in hyperv_enabled() which is called foreach vCPU. Apart from that, this variable will come in handy in a subsequent patch. Signed-off-by: Siddharth Chandrasekaran <sidcha@xxxxxxxxx> --- target/i386/kvm/kvm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index 03202bd06b..bcf1b4f2d0 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -93,6 +93,7 @@ static bool has_msr_misc_enable; static bool has_msr_smbase; static bool has_msr_bndcfgs; static int lm_capable_kernel; +static bool has_hyperv; static bool has_msr_hv_hypercall; static bool has_msr_hv_crash; static bool has_msr_hv_reset; @@ -716,7 +717,7 @@ unsigned long kvm_arch_vcpu_id(CPUState *cs) static bool hyperv_enabled(X86CPU *cpu) { - return kvm_check_extension(kvm_state, KVM_CAP_HYPERV) > 0 && + return has_hyperv && ((cpu->hyperv_spinlock_attempts != HYPERV_SPINLOCK_NEVER_NOTIFY) || cpu->hyperv_features || cpu->hyperv_passthrough); } @@ -2216,6 +2217,7 @@ int kvm_arch_init(MachineState *ms, KVMState *s) has_xsave = kvm_check_extension(s, KVM_CAP_XSAVE); has_xcrs = kvm_check_extension(s, KVM_CAP_XCRS); has_pit_state2 = kvm_check_extension(s, KVM_CAP_PIT_STATE2); + has_hyperv = kvm_check_extension(s, KVM_CAP_HYPERV); hv_vpindex_settable = kvm_check_extension(s, KVM_CAP_HYPERV_VP_INDEX); -- 2.17.1 Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879