From patchwork Mon Jul 20 23:10:09 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glauber Costa X-Patchwork-Id: 36420 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n6KNARA4021865 for ; Mon, 20 Jul 2009 23:10:27 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753240AbZGTXKY (ORCPT ); Mon, 20 Jul 2009 19:10:24 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754323AbZGTXKW (ORCPT ); Mon, 20 Jul 2009 19:10:22 -0400 Received: from mx2.redhat.com ([66.187.237.31]:53378 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753240AbZGTXKS (ORCPT ); Mon, 20 Jul 2009 19:10:18 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n6KNAIIG029391 for ; Mon, 20 Jul 2009 19:10:18 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n6KNAHMf002965; Mon, 20 Jul 2009 19:10:18 -0400 Received: from localhost.localdomain (virtlab1.virt.bos.redhat.com [10.16.72.21]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n6KNAGkf028980; Mon, 20 Jul 2009 19:10:17 -0400 From: Glauber Costa To: kvm@vger.kernel.org Cc: avi@redhat.com Subject: [PATCH 2/9] embed kvm_create_context into kvm_init Date: Mon, 20 Jul 2009 19:10:09 -0400 Message-Id: <1248131416-11272-3-git-send-email-glommer@redhat.com> In-Reply-To: <1248131416-11272-2-git-send-email-glommer@redhat.com> References: <1248131416-11272-1-git-send-email-glommer@redhat.com> <1248131416-11272-2-git-send-email-glommer@redhat.com> X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org There is no reason why kvm_create_context is placed outside kvm_init(). After we call kvm_init(), no extra initialization step should be necessary. This patch folds kvm_create_context into it, simplifying vl.c code. Signed-off-by: Glauber Costa --- qemu-kvm.c | 6 ++++-- qemu-kvm.h | 1 - vl.c | 7 ------- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/qemu-kvm.c b/qemu-kvm.c index db28126..c3af59c 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -419,6 +419,8 @@ int kvm_dirty_pages_log_reset(kvm_context_t kvm) } +static int kvm_create_context(void); + int kvm_init(int smp_cpus) { int fd; @@ -478,7 +480,7 @@ int kvm_init(int smp_cpus) } pthread_mutex_lock(&qemu_mutex); - return 0; + return kvm_create_context(); out_close: close(fd); @@ -2249,7 +2251,7 @@ int kvm_arch_init_irq_routing(void) } #endif -int kvm_qemu_create_context(void) +static int kvm_create_context() { int r; diff --git a/qemu-kvm.h b/qemu-kvm.h index d5291a3..4fc2847 100644 --- a/qemu-kvm.h +++ b/qemu-kvm.h @@ -930,7 +930,6 @@ struct kvm_pit_state { }; int kvm_main_loop(void); int kvm_qemu_init(void); -int kvm_qemu_create_context(void); int kvm_init_ap(void); int kvm_vcpu_inited(CPUState *env); void kvm_load_registers(CPUState *env); diff --git a/vl.c b/vl.c index 7701488..f4e4d0f 100644 --- a/vl.c +++ b/vl.c @@ -5838,13 +5838,6 @@ int main(int argc, char **argv, char **envp) if (ram_size == 0) ram_size = DEFAULT_RAM_SIZE * 1024 * 1024; - if (kvm_enabled()) { - if (kvm_qemu_create_context() < 0) { - fprintf(stderr, "Could not create KVM context\n"); - exit(1); - } - } - #ifdef CONFIG_KQEMU /* FIXME: This is a nasty hack because kqemu can't cope with dynamic guest ram allocation. It needs to go away. */