From patchwork Fri Apr 2 15:46:29 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Blue Swirl X-Patchwork-Id: 49297 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2A08AB7CF3 for ; Sat, 3 Apr 2010 02:55:09 +1100 (EST) Received: from localhost ([127.0.0.1]:59370 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nxj88-0007vc-PV for incoming@patchwork.ozlabs.org; Fri, 02 Apr 2010 11:49:56 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nxj4s-0007GP-1E for qemu-devel@nongnu.org; Fri, 02 Apr 2010 11:46:34 -0400 Received: from [140.186.70.92] (port=40800 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nxj4q-0007Fh-Fd for qemu-devel@nongnu.org; Fri, 02 Apr 2010 11:46:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Nxj4o-000279-OU for qemu-devel@nongnu.org; Fri, 02 Apr 2010 11:46:32 -0400 Received: from mail-pz0-f202.google.com ([209.85.222.202]:33377) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Nxj4o-000274-Jz for qemu-devel@nongnu.org; Fri, 02 Apr 2010 11:46:30 -0400 Received: by pzk40 with SMTP id 40so1606235pzk.23 for ; Fri, 02 Apr 2010 08:46:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:received:message-id :subject:from:to:content-type; bh=9J6EBcjiadZrJsbGPxAoHI7BFFwj3w3xCxBCq2odGQc=; b=u7Vr/C6AxXVSxUlNXs3nC2tZRuGHdwe2uBr0wamBLczqFrvti8qNtdJIkIaf68s65e HX30oLh2pp+Peuf/8qYD6Nrb39CaChUKV0apMEsoFiTb1PITjI7jqUdcGE8L8MIfEzis 1HSpFDAfycduke/ur6BBhxV8qHDph6mwnBhmE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=UP84bp8XEkgo1/tDT+orJje5XVnbqlYVC85vg2wCQeMn8171JALaCp4YRkUgdsVpGX Wfc894KW7tUtOm18BPkqG9XW29lQDijDIR6Xbj8Uj4fGk6O8UdZzXX5u0HAhQpnYZ6MQ 8+BV1fQikHAO6QfEUf3QshcdTv0/CDBM9phdQ= MIME-Version: 1.0 Received: by 10.140.178.12 with HTTP; Fri, 2 Apr 2010 08:46:29 -0700 (PDT) Date: Fri, 2 Apr 2010 18:46:29 +0300 Received: by 10.140.255.17 with SMTP id c17mr1667405rvi.75.1270223189402; Fri, 02 Apr 2010 08:46:29 -0700 (PDT) Message-ID: From: Blue Swirl To: qemu-devel X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [Qemu-devel] [PATCH 1/2] Move KVM init to arch_init.c, compile vl.c once X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Remove dependency of vl.c to KVM, then we can partially revert b33612d03540fda7fa67485f1c20395beb7a2bf0. Signed-off-by: Blue Swirl --- Makefile.objs | 2 +- Makefile.target | 2 +- arch_init.c | 5 +++++ arch_init.h | 1 + kvm-all.c | 3 +++ kvm.h | 8 ++++++++ vl.c | 16 +++++----------- 7 files changed, 24 insertions(+), 13 deletions(-) usb_enabled = 1; @@ -3585,14 +3584,9 @@ int main(int argc, char **argv, char **envp) exit(1); } - if (kvm_enabled()) { - int ret; - - ret = kvm_init(smp_cpus); - if (ret < 0) { - fprintf(stderr, "failed to initialize KVM\n"); - exit(1); - } + if (enable_kvm && kvm_maybe_init(smp_cpus) < 0) { + fprintf(stderr, "failed to initialize KVM\n"); + exit(1); } if (qemu_init_main_loop()) { diff --git a/Makefile.objs b/Makefile.objs index 11e44a0..cb2ec2c 100644 --- a/Makefile.objs +++ b/Makefile.objs @@ -128,7 +128,7 @@ user-obj-y += cutils.o cache-utils.o # libhw hw-obj-y = -hw-obj-y += loader.o +hw-obj-y += vl.o loader.o hw-obj-y += virtio.o virtio-console.o hw-obj-y += fw_cfg.o pci.o pci_host.o pcie_host.o hw-obj-y += watchdog.o diff --git a/Makefile.target b/Makefile.target index 167fc8d..2aa02f5 100644 --- a/Makefile.target +++ b/Makefile.target @@ -161,7 +161,7 @@ endif #CONFIG_BSD_USER # System emulator target ifdef CONFIG_SOFTMMU -obj-y = arch_init.o cpus.o monitor.o machine.o gdbstub.o vl.o +obj-y = arch_init.o cpus.o monitor.o machine.o gdbstub.o # virtio has to be here due to weird dependency between PCI and virtio-net. # need to fix this properly obj-y += virtio-blk.o virtio-balloon.o virtio-net.o virtio-pci.o virtio-serial-bus.o diff --git a/arch_init.c b/arch_init.c index cfc03ea..055e65d 100644 --- a/arch_init.c +++ b/arch_init.c @@ -508,3 +508,8 @@ int xen_available(void) return 0; #endif } + +int kvm_maybe_init(int smp_cpus) +{ + return kvm_init(smp_cpus); +} diff --git a/arch_init.h b/arch_init.h index 682890c..52dd327 100644 --- a/arch_init.h +++ b/arch_init.h @@ -29,5 +29,6 @@ void cpudef_init(void); int audio_available(void); int kvm_available(void); int xen_available(void); +int kvm_maybe_init(int smp_cpus); #endif diff --git a/kvm-all.c b/kvm-all.c index 7aa5e57..dc99aae 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -51,6 +51,8 @@ typedef struct KVMSlot typedef struct kvm_dirty_log KVMDirtyLog; +int kvm_allowed = 0; + struct KVMState { KVMSlot slots[32]; @@ -670,6 +672,7 @@ int kvm_init(int smp_cpus) kvm_state = s; cpu_register_phys_memory_client(&kvm_cpu_phys_memory_client); + kvm_allowed = 1; return 0; diff --git a/kvm.h b/kvm.h index 1e5be27..979f640 100644 --- a/kvm.h +++ b/kvm.h @@ -34,7 +34,15 @@ struct kvm_run; /* external API */ +#ifdef CONFIG_KVM int kvm_init(int smp_cpus); +#else +static inline +int kvm_init(int smp_cpus) +{ + return -ENOSYS; +} +#endif #ifdef NEED_CPU_H int kvm_init_vcpu(CPUState *env); diff --git a/vl.c b/vl.c index 6768cf1..6958b2c 100644 --- a/vl.c +++ b/vl.c @@ -145,7 +145,6 @@ int main(int argc, char **argv) #include "dma.h" #include "audio/audio.h" #include "migration.h" -#include "kvm.h" #include "balloon.h" #include "qemu-option.h" #include "qemu-config.h" @@ -241,7 +240,6 @@ uint8_t qemu_uuid[16]; static QEMUBootSetHandler *boot_set_handler; static void *boot_set_opaque; -int kvm_allowed = 0; uint32_t xen_domid; enum xen_mode xen_mode = XEN_EMULATE; @@ -2649,6 +2647,7 @@ int main(int argc, char **argv, char **envp) #endif int show_vnc_port = 0; int defconfig = 1; + int enable_kvm = 0; error_set_progname(argv[0]); @@ -3239,7 +3238,7 @@ int main(int argc, char **argv, char **envp) printf("Option %s not supported for this target\n", popt->name); exit(1); } - kvm_allowed = 1; + enable_kvm = 1; break; case QEMU_OPTION_usb: