From patchwork Wed Jan 27 22:44:01 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 75549 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.2) with ESMTP id o0RMisEV024588 for ; Wed, 27 Jan 2010 22:44:54 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756388Ab0A0Wo1 (ORCPT ); Wed, 27 Jan 2010 17:44:27 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756386Ab0A0Wo0 (ORCPT ); Wed, 27 Jan 2010 17:44:26 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40952 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756379Ab0A0WoW (ORCPT ); Wed, 27 Jan 2010 17:44:22 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o0RMiK9W021519 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 27 Jan 2010 17:44:20 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o0RMiJ0C021225; Wed, 27 Jan 2010 17:44:20 -0500 Received: from amt.cnet (vpn-11-221.rdu.redhat.com [10.11.11.221]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o0RMiH45001581; Wed, 27 Jan 2010 17:44:18 -0500 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id E88DC65600F; Wed, 27 Jan 2010 20:44:03 -0200 (BRST) Received: (from marcelo@localhost) by amt.cnet (8.14.3/8.14.3/Submit) id o0RMi1rU023372; Wed, 27 Jan 2010 20:44:01 -0200 Date: Wed, 27 Jan 2010 20:44:01 -0200 From: Marcelo Tosatti To: Jan Kiszka Cc: Gleb Natapov , kvm , Glauber de Oliveira Costa Subject: qemu-kvm: enable get/set vcpu events on reset and migration Message-ID: <20100127224401.GA23292@amt.cnet> References: <20100127002622.GB8811@amt.cnet> <4B5FFB07.9030601@siemens.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <4B5FFB07.9030601@siemens.com> User-Agent: Mutt/1.5.20 (2009-08-17) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org diff --git a/kvm.h b/kvm.h index e2a945b..9fa4e25 100644 --- a/kvm.h +++ b/kvm.h @@ -52,6 +52,9 @@ int kvm_set_migration_log(int enable); int kvm_has_sync_mmu(void); #endif /* KVM_UPSTREAM */ int kvm_has_vcpu_events(void); +int kvm_put_vcpu_events(CPUState *env); +int kvm_get_vcpu_events(CPUState *env); + #ifdef KVM_UPSTREAM void kvm_setup_guest_memory(void *start, size_t size); @@ -96,7 +99,9 @@ int kvm_arch_init(KVMState *s, int smp_cpus); int kvm_arch_init_vcpu(CPUState *env); +#endif void kvm_arch_reset_vcpu(CPUState *env); +#ifdef KVM_UPSTREAM struct kvm_guest_debug; struct kvm_debug_exit_arch; diff --git a/qemu-kvm-x86.c b/qemu-kvm-x86.c index 82e362c..7f820a4 100644 --- a/qemu-kvm-x86.c +++ b/qemu-kvm-x86.c @@ -1457,8 +1457,9 @@ void kvm_arch_push_nmi(void *opaque) void kvm_arch_cpu_reset(CPUState *env) { - env->interrupt_injected = -1; + kvm_arch_reset_vcpu(env); kvm_arch_load_regs(env); + kvm_put_vcpu_events(env); if (!cpu_is_bsp(env)) { if (kvm_irqchip_in_kernel()) { #ifdef KVM_CAP_MP_STATE diff --git a/qemu-kvm.c b/qemu-kvm.c index 1c34846..f891a3e 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -2187,6 +2187,11 @@ static int kvm_create_context(void) return r; } + kvm_state->vcpu_events = 0; +#ifdef KVM_CAP_VCPU_EVENTS + kvm_state->vcpu_events = kvm_check_extension(kvm_state, KVM_CAP_VCPU_EVENTS); +#endif + kvm_init_ap(); if (kvm_irqchip) { if (!qemu_kvm_has_gsi_routing()) { diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 9af1e48..79be2d5 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -285,6 +285,7 @@ int kvm_arch_init_vcpu(CPUState *env) return kvm_vcpu_ioctl(env, KVM_SET_CPUID2, &cpuid_data); } +#endif void kvm_arch_reset_vcpu(CPUState *env) { env->exception_injected = -1; @@ -292,6 +293,7 @@ void kvm_arch_reset_vcpu(CPUState *env) env->nmi_injected = 0; env->nmi_pending = 0; } +#ifdef KVM_UPSTREAM static int kvm_has_msr_star(CPUState *env) { @@ -776,8 +778,9 @@ static int kvm_get_mp_state(CPUState *env) env->mp_state = mp_state.mp_state; return 0; } +#endif -static int kvm_put_vcpu_events(CPUState *env) +int kvm_put_vcpu_events(CPUState *env) { #ifdef KVM_CAP_VCPU_EVENTS struct kvm_vcpu_events events; @@ -807,7 +810,7 @@ static int kvm_put_vcpu_events(CPUState *env) #endif } -static int kvm_get_vcpu_events(CPUState *env) +int kvm_get_vcpu_events(CPUState *env) { #ifdef KVM_CAP_VCPU_EVENTS struct kvm_vcpu_events events; @@ -844,6 +847,7 @@ static int kvm_get_vcpu_events(CPUState *env) return 0; } +#ifdef KVM_UPSTREAM int kvm_arch_put_registers(CPUState *env) { int ret; diff --git a/target-i386/machine.c b/target-i386/machine.c index 47ca6e8..0b8a33a 100644 --- a/target-i386/machine.c +++ b/target-i386/machine.c @@ -323,7 +323,10 @@ static void cpu_pre_save(void *opaque) int i; cpu_synchronize_state(env); - kvm_save_mpstate(env); + if (kvm_enabled()) { + kvm_save_mpstate(env); + kvm_get_vcpu_events(env); + } /* FPU */ env->fpus_vmstate = (env->fpus & ~0x3800) | (env->fpstt & 0x7) << 11; @@ -374,6 +377,7 @@ static int cpu_post_load(void *opaque, int version_id) kvm_load_tsc(env); kvm_load_mpstate(env); + kvm_put_vcpu_events(env); } return 0;