From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: [PATCH] qemu-kvm initialize vcpu state after machine initialization Date: Mon, 14 Dec 2009 18:36:37 -0200 Message-ID: <20091214203637.GA7120@amt.cnet> References: <20091209174654.GA28056@amt.cnet> <4B20C058.5080307@redhat.com> <4B20C32B.7070005@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Glauber de Oliveira Costa , kvm , Gleb Natapov To: Avi Kivity Return-path: Received: from mx1.redhat.com ([209.132.183.28]:5163 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751791AbZLNUgv (ORCPT ); Mon, 14 Dec 2009 15:36:51 -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 nBEKapXD014269 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 14 Dec 2009 15:36:51 -0500 Content-Disposition: inline In-Reply-To: <4B20C32B.7070005@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: So that the vcpu state is initialized, from vcpu thread context, after machine initialization is settled. This allows to revert apic_init's apic_reset call. apic_reset now happens through system_reset, similarly to qemu upstream. Signed-off-by: Marcelo Tosatti diff --git a/hw/apic.c b/hw/apic.c index ae805dc..627ff98 100644 --- a/hw/apic.c +++ b/hw/apic.c @@ -1131,11 +1131,6 @@ int apic_init(CPUState *env) vmstate_register(s->idx, &vmstate_apic, s); qemu_register_reset(apic_reset, s); - /* apic_reset must be called before the vcpu threads are initialized and load - * registers, in qemu-kvm. - */ - apic_reset(s); - local_apics[s->idx] = s; return 0; } diff --git a/qemu-kvm.c b/qemu-kvm.c index 44e8b75..ef8c288 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -1918,11 +1918,6 @@ static void *ap_main_loop(void *_env) setup_kernel_sigmask(env); pthread_mutex_lock(&qemu_mutex); - cpu_single_env = env; - - kvm_arch_init_vcpu(env); - - kvm_arch_load_regs(env); /* signal VCPU creation */ current_env->created = 1; @@ -1934,6 +1929,8 @@ static void *ap_main_loop(void *_env) /* re-initialize cpu_single_env after re-acquiring qemu_mutex */ cpu_single_env = env; + kvm_arch_init_vcpu(env); + kvm_arch_load_regs(env); kvm_main_loop_cpu(env); return NULL;