[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 01/10] hyperv:synic: split capability testing and se
From: |
Roman Kagan |
Subject: |
[Qemu-devel] [PATCH 01/10] hyperv:synic: split capability testing and setting |
Date: |
Fri, 21 Sep 2018 11:22:08 +0300 |
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 <address@hidden>
---
target/i386/kvm.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index 892d4f46c1..8d956da5d1 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -734,8 +734,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;
}
@@ -753,12 +754,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];
@@ -767,7 +770,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;
}
@@ -779,6 +782,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;
}
--
2.17.1
- [Qemu-devel] [PATCH 00/10] hyperv: add connection infrastructure, Roman Kagan, 2018/09/21
- [Qemu-devel] [PATCH 01/10] hyperv:synic: split capability testing and setting,
Roman Kagan <=
- [Qemu-devel] [PATCH 03/10] hyperv: only add SynIC in compatible configurations, Roman Kagan, 2018/09/21
- [Qemu-devel] [PATCH 04/10] hyperv: make overlay pages for SynIC, Roman Kagan, 2018/09/21
- [Qemu-devel] [PATCH 06/10] hyperv: add synic event flag signaling, Roman Kagan, 2018/09/21
- [Qemu-devel] [PATCH 05/10] hyperv: add synic message delivery, Roman Kagan, 2018/09/21
- [Qemu-devel] [PATCH 08/10] hyperv: add support for KVM_HYPERV_EVENTFD, Roman Kagan, 2018/09/21
- [Qemu-devel] [PATCH 07/10] hyperv: process SIGNAL_EVENT hypercall, Roman Kagan, 2018/09/21
- [Qemu-devel] [PATCH 09/10] hyperv: process POST_MESSAGE hypercall, Roman Kagan, 2018/09/21
- [Qemu-devel] [PATCH 10/10] hyperv_testdev: add SynIC message and event testmodes, Roman Kagan, 2018/09/21