Signed-off-by: Sheng Yang <sheng@xxxxxxxxxxxxxxx> --- qemu-kvm.c | 16 ++++++++++++++++ qemu-kvm.h | 8 ++++++++ 2 files changed, 24 insertions(+), 0 deletions(-) diff --git a/qemu-kvm.c b/qemu-kvm.c index 733d0a9..fbb68f6 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -540,6 +540,22 @@ int kvm_set_xcrs(CPUState *env, struct kvm_xcrs *xcrs) } #endif +#ifdef KVM_CAP_ENABLE_CAP +int kvm_enable_cap(CPUState *env, uint32_t cap) +{ + int r = 0; + struct kvm_enable_cap enable_cap = { + .cap = cap, + .flags = 0, + }; + + r = kvm_ioctl(kvm_state, KVM_CHECK_EXTENSION, KVM_CAP_ENABLE_CAP); + if (r > 0) + r = kvm_vcpu_ioctl(env, KVM_ENABLE_CAP, &enable_cap); + return r; +} +#endif + static int handle_mmio(CPUState *env) { unsigned long addr = env->kvm_run->mmio.phys_addr; diff --git a/qemu-kvm.h b/qemu-kvm.h index 9c08ab4..5cac0c2 100644 --- a/qemu-kvm.h +++ b/qemu-kvm.h @@ -316,6 +316,14 @@ int kvm_get_xcrs(CPUState *env, struct kvm_xcrs *xcrs); int kvm_set_xcrs(CPUState *env, struct kvm_xcrs *xcrs); #endif +#ifdef KVM_ENABLE_CAP +/*! + * * \brief Enable specific capability of KVM + * + */ +int kvm_enable_cap(CPUState *env, uint32_t cap); +#endif + /*! * \brief Simulate an external vectored interrupt * -- 1.7.0.1 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html