From: Chris Wright Subject: [PATCH] kvm-userspace: fix compilation w/out KVM_CAP_MP_STATE Date: Tue, 20 May 2008 18:24:24 -0700 Message-ID: <20080521012423.GT30402@sequoia.sous-sol.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii To: kvm@vger.kernel.org Return-path: Received: from sous-sol.org ([216.99.217.87]:40763 "EHLO sous-sol.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755213AbYEUBYZ (ORCPT ); Tue, 20 May 2008 21:24:25 -0400 Content-Disposition: inline Sender: kvm-owner@vger.kernel.org List-ID: 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 --- 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(-) diff --git a/libkvm/libkvm.h b/libkvm/libkvm.h index 31c0d59..63183b8 100644 --- a/libkvm/libkvm.h +++ b/libkvm/libkvm.h @@ -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 /*! diff --git a/qemu/qemu-kvm-x86.c b/qemu/qemu-kvm-x86.c index 6cc08fc..197d761 100644 --- a/qemu/qemu-kvm-x86.c +++ b/qemu/qemu-kvm-x86.c @@ -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;