Skip to contentSkip to conversation

kvm-userspace: fix compilation w/out KVM_CAP_MP_STATE

PATCH Applied Chris Wright 2 participants 2 messages May 21, 2008 KVM

lore
Share & tools
lore
#0 lore raw

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)
...

---
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
index 31c0d59..63183b8 100644
@@ -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
index 6cc08fc..197d761 100644
@@ -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;
Applied
#1 lore raw
Quoted 8 lines · Chris Wright

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)
...

Applied, thanks.

Signature · 1 line
error compiling committee.c: too many arguments to function