summaryrefslogtreecommitdiff
path: root/target/i386/kvm.c
diff options
context:
space:
mode:
authorRoman Kagan <rkagan@virtuozzo.com>2018-09-21 11:22:08 +0300
committerPaolo Bonzini <pbonzini@redhat.com>2018-10-19 13:44:14 +0200
commit729ce7e1b6b6e035012544f51878d1ef5864bf39 (patch)
tree91970025907d1255f7d9044d872c75625adbe71e /target/i386/kvm.c
parent8417442a34f78f1e1dda87aff27c8a42124f4d42 (diff)
downloadqemu-729ce7e1b6b6e035012544f51878d1ef5864bf39.zip
hyperv:synic: split capability testing and setting
Put a bit more consistency into handling KVM_CAP_HYPERV_SYNIC capability, by checking its availability and determining the feasibility of hv-synic property first, and enabling it later. Signed-off-by: Roman Kagan <rkagan@virtuozzo.com> Message-Id: <20180921082217.29481-2-rkagan@virtuozzo.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'target/i386/kvm.c')
-rw-r--r--target/i386/kvm.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index b0b42d2991..2e5b9f63eb 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -735,8 +735,9 @@ static int hyperv_handle_properties(CPUState *cs)
}
if (cpu->hyperv_synic) {
if (!has_msr_hv_synic ||
- kvm_vcpu_enable_cap(cs, KVM_CAP_HYPERV_SYNIC, 0)) {
- fprintf(stderr, "Hyper-V SynIC is not supported by kernel\n");
+ !kvm_check_extension(cs->kvm_state, KVM_CAP_HYPERV_SYNIC)) {
+ fprintf(stderr, "Hyper-V SynIC (requested by 'hv-synic' cpu flag) "
+ "is not supported by kernel\n");
return -ENOSYS;
}
@@ -754,12 +755,14 @@ static int hyperv_handle_properties(CPUState *cs)
static int hyperv_init_vcpu(X86CPU *cpu)
{
+ CPUState *cs = CPU(cpu);
+ int ret;
+
if (cpu->hyperv_vpindex && !hv_vpindex_settable) {
/*
* the kernel doesn't support setting vp_index; assert that its value
* is in sync
*/
- int ret;
struct {
struct kvm_msrs info;
struct kvm_msr_entry entries[1];
@@ -768,7 +771,7 @@ static int hyperv_init_vcpu(X86CPU *cpu)
.entries[0].index = HV_X64_MSR_VP_INDEX,
};
- ret = kvm_vcpu_ioctl(CPU(cpu), KVM_GET_MSRS, &msr_data);
+ ret = kvm_vcpu_ioctl(cs, KVM_GET_MSRS, &msr_data);
if (ret < 0) {
return ret;
}
@@ -780,6 +783,15 @@ static int hyperv_init_vcpu(X86CPU *cpu)
}
}
+ if (cpu->hyperv_synic) {
+ ret = kvm_vcpu_enable_cap(cs, KVM_CAP_HYPERV_SYNIC, 0);
+ if (ret < 0) {
+ error_report("failed to turn on HyperV SynIC in KVM: %s",
+ strerror(-ret));
+ return ret;
+ }
+ }
+
return 0;
}