From patchwork Tue Mar 23 16:53:39 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 87700 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2NGtLTt012919 for ; Tue, 23 Mar 2010 16:55:21 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752625Ab0CWQzP (ORCPT ); Tue, 23 Mar 2010 12:55:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39898 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752045Ab0CWQzG (ORCPT ); Tue, 23 Mar 2010 12:55:06 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2NGt6u6024661 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 23 Mar 2010 12:55:06 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2NGt5P8019366; Tue, 23 Mar 2010 12:55:05 -0400 Received: from amt.cnet (vpn-10-84.rdu.redhat.com [10.11.10.84]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o2NGt3b0032025; Tue, 23 Mar 2010 12:55:04 -0400 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id E54BE6520A6; Tue, 23 Mar 2010 13:54:08 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.3/8.14.3/Submit) id o2NGs7bc019926; Tue, 23 Mar 2010 13:54:07 -0300 Message-Id: <20100323165347.689886209@amt.cnet> User-Agent: quilt/0.47-1 Date: Tue, 23 Mar 2010 13:53:39 -0300 From: Marcelo Tosatti To: kvm@vger.kernel.org Cc: Marcelo Tosatti Subject: [patch 6/6] qemu-kvm: use reset handler for vcpus References: <20100323165333.062022913@amt.cnet> Content-Disposition: inline; filename=register-reset-vcpu X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 23 Mar 2010 16:55:22 +0000 (UTC) Index: qemu-kvm-cleanups/qemu-kvm.c =================================================================== --- qemu-kvm-cleanups.orig/qemu-kvm.c +++ qemu-kvm-cleanups/qemu-kvm.c @@ -439,6 +439,13 @@ void kvm_disable_pit_creation(kvm_contex kvm->no_pit_creation = 1; } +static void kvm_reset_vcpu(void *opaque) +{ + CPUState *env = opaque; + + kvm_arch_cpu_reset(env); +} + static void kvm_create_vcpu(CPUState *env, int id) { long mmap_size; @@ -473,6 +480,11 @@ static void kvm_create_vcpu(CPUState *en s->coalesced_mmio * PAGE_SIZE; #endif + r = kvm_arch_init_vcpu(env); + if (r == 0) { + qemu_register_reset(kvm_reset_vcpu, env); + } + return; err_fd: close(env->kvm_fd); @@ -1777,17 +1789,10 @@ static void setup_kernel_sigmask(CPUStat static void qemu_kvm_system_reset(void) { - CPUState *penv = first_cpu; - pause_all_threads(); qemu_system_reset(); - while (penv) { - kvm_arch_cpu_reset(penv); - penv = (CPUState *) penv->next_cpu; - } - resume_all_threads(); } @@ -1829,7 +1834,6 @@ static void *ap_main_loop(void *_env) env->thread_id = kvm_get_thread_id(); sigfillset(&signals); sigprocmask(SIG_BLOCK, &signals, NULL); - kvm_create_vcpu(env, env->cpu_index); #ifdef CONFIG_KVM_DEVICE_ASSIGNMENT /* do ioperm for io ports of assigned devices */ @@ -1837,12 +1841,11 @@ static void *ap_main_loop(void *_env) on_vcpu(env, kvm_arch_do_ioperm, data); #endif - setup_kernel_sigmask(env); - pthread_mutex_lock(&qemu_mutex); cpu_single_env = env; - kvm_arch_init_vcpu(env); + kvm_create_vcpu(env, env->cpu_index); + setup_kernel_sigmask(env); /* signal VCPU creation */ current_env->created = 1;