From patchwork Sat Apr 9 10:51:07 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pekka Enberg X-Patchwork-Id: 695821 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p39ApOIc002447 for ; Sat, 9 Apr 2011 10:51:25 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754161Ab1DIKvW (ORCPT ); Sat, 9 Apr 2011 06:51:22 -0400 Received: from filtteri5.pp.htv.fi ([213.243.153.188]:33204 "EHLO filtteri5.pp.htv.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754030Ab1DIKvU (ORCPT ); Sat, 9 Apr 2011 06:51:20 -0400 Received: from localhost (localhost [127.0.0.1]) by filtteri5.pp.htv.fi (Postfix) with ESMTP id D96BE5A6216; Sat, 9 Apr 2011 13:51:13 +0300 (EEST) X-Virus-Scanned: Debian amavisd-new at pp.htv.fi Received: from smtp5.welho.com ([213.243.153.39]) by localhost (filtteri5.pp.htv.fi [213.243.153.188]) (amavisd-new, port 10024) with ESMTP id 6amI3GWWN7bK; Sat, 9 Apr 2011 13:51:08 +0300 (EEST) Received: from localhost.localdomain (cs181148025.pp.htv.fi [82.181.148.25]) by smtp5.welho.com (Postfix) with ESMTP id 970665BC005; Sat, 9 Apr 2011 13:51:08 +0300 (EEST) From: Pekka Enberg To: kvm@vger.kernel.org Cc: Pekka Enberg , Asias He , Cyrill Gorcunov , Ingo Molnar Subject: [PATCH 2/2] kvm tools: Move CPU initialization to kvm_cpu__start() Date: Sat, 9 Apr 2011 13:51:07 +0300 Message-Id: <1302346267-457-2-git-send-email-penberg@kernel.org> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1302346267-457-1-git-send-email-penberg@kernel.org> References: <1302346267-457-1-git-send-email-penberg@kernel.org> 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.6 (demeter1.kernel.org [140.211.167.41]); Sat, 09 Apr 2011 10:51:25 +0000 (UTC) Move CPUID setup and CPU reset code to kvm_cpu__start() so that CPU state is setup in one place. Cc: Asias He Cc: Cyrill Gorcunov Cc: Ingo Molnar Signed-off-by: Pekka Enberg --- tools/kvm/kvm-cpu.c | 3 +++ tools/kvm/kvm-run.c | 10 +++------- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/tools/kvm/kvm-cpu.c b/tools/kvm/kvm-cpu.c index 392fad3..4cbe597 100644 --- a/tools/kvm/kvm-cpu.c +++ b/tools/kvm/kvm-cpu.c @@ -373,6 +373,9 @@ void kvm_cpu__run(struct kvm_cpu *self) int kvm_cpu__start(struct kvm_cpu *cpu) { + kvm_cpu__setup_cpuid(cpu); + kvm_cpu__reset_vcpu(cpu); + for (;;) { kvm_cpu__run(cpu); diff --git a/tools/kvm/kvm-run.c b/tools/kvm/kvm-run.c index 9a0400b..8a9747b 100644 --- a/tools/kvm/kvm-run.c +++ b/tools/kvm/kvm-run.c @@ -143,8 +143,6 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix) die("unable to load disk image %s", image_filename); } - kvm_cpu__setup_cpuid(cpu); - strcpy(real_cmdline, "notsc nolapic noacpi pci=conf1 console=ttyS0 "); if (!kernel_cmdline || !strstr(kernel_cmdline, "root=")) { strlcat(real_cmdline, "root=/dev/vda rw ", @@ -160,13 +158,8 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix) real_cmdline)) die("unable to load kernel %s", kernel_filename); - kvm_cpu__reset_vcpu(cpu); - kvm__setup_bios(kvm); - if (single_step) - kvm_cpu__enable_singlestep(cpu); - serial8250__init(kvm); pci__init(); @@ -177,6 +170,9 @@ int kvm_cmd_run(int argc, const char **argv, const char *prefix) kvm__start_timer(kvm); + if (single_step) + kvm_cpu__enable_singlestep(cpu); + if (kvm_cpu__start(cpu)) goto panic_kvm;