kvm-userspace: fix compilation w/out KVM_CAP_MP_STATE
PATCH 1/1 kvm-userspace: fix compilation w/out KVM_CAP_MP_STATE
Add kvm_reset_mpstate inline function and only call it when KVM_CAP_MP_STATE is defined.
qemu/qemu-kvm-x86.c:677: error: unknown field mp_state' specified in initializer qemu/qemu-kvm-x86.c:677: error: KVM_MP_STATE_UNINITIALIZED' undeclared (first use in this function)
...
Signed-off-by Chris Wright <[email protected]>
---
Note: could easily extend this to have an #else clause in libkvm.h to simplify some of the ifdef-ery in qemu-kvm-x86.c.
libkvm/libkvm.h | 9 +++++++++ qemu/qemu-kvm-x86.c | 10 +++++----- 2 files changed, 14 insertions(+), 5 deletions(-)
libkvm/libkvm.h +9 -0
@@ -314,6 +314,15 @@ int kvm_get_mpstate(kvm_context_t kvm, int vcpu,*/ int kvm_set_mpstate (kvm_context_t kvm,int vcpu,struct kvm_mp_state *mp_state); +/*! +* * \brief Reset VCPU MP state +* +*/ +static inline int kvm_reset_mpstate (kvm_context_t kvm,int vcpu) +{ +struct kvm_mp_state mp_state = {.mp_state =KVM_MP_STATE_UNINITIALIZED }; +return kvm_set_mpstate (kvm, vcpu, &mp_state); +}#endif /*!
qemu/qemu-kvm-x86.c +5 -5
@@ -674,13 +674,13 @@ int handle_tpr_access(void *opaque, int vcpu,void kvm_arch_cpu_reset (CPUState *env) { -struct kvm_mp_state mp_state = { .mp_state =KVM_MP_STATE_UNINITIALIZED }; -kvm_arch_load_regs (env);if (env->cpu_index !=0 ) { -if (kvm_irqchip_in_kernel (kvm_context)) -kvm_set_mpstate (kvm_context, env->cpu_index, &mp_state); -else { +if (kvm_irqchip_in_kernel (kvm_context)) { +#ifdef KVM_CAP_MP_STATE +kvm_reset_mpstate (kvm_context, env->cpu_index); +#endif + }else { env->interrupt_request &= ~CPU_INTERRUPT_HARD ; env->hflags |=HF_HALTED_MASK ; env->exception_index =EXCP_HLT ;
Avi Kivity
AppliedQuoted 8 lines · Chris Wright
Add
kvm_reset_mpstateinline function and only call it whenKVM_CAP_MP_STATEis defined.
qemu/qemu-kvm-x86.c:677: error: unknown fieldmp_state' specified in initializer qemu/qemu-kvm-x86.c:677: error:KVM_MP_STATE_UNINITIALIZED' undeclared (first use in this function)
...
Applied, thanks.
Signature · 1 line
error compiling committee.c: too many arguments to function