Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nxhjl-0001V2-NG for qemu-devel@nongnu.org; Fri, 02 Apr 2010 10:20:41 -0400 Received: from [140.186.70.92] (port=48465 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nxhjk-0001U4-JD for qemu-devel@nongnu.org; Fri, 02 Apr 2010 10:20:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Nxhjj-0008KI-6o for qemu-devel@nongnu.org; Fri, 02 Apr 2010 10:20:40 -0400 Received: from mail-pw0-f45.google.com ([209.85.160.45]:42858) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Nxhjj-0008KB-25 for qemu-devel@nongnu.org; Fri, 02 Apr 2010 10:20:39 -0400 Received: by pwi6 with SMTP id 6so1683754pwi.4 for ; Fri, 02 Apr 2010 07:20:38 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <4BB500C1.1020600@redhat.com> References: <4BB500C1.1020600@redhat.com> Date: Fri, 2 Apr 2010 17:20:38 +0300 Message-ID: From: Blue Swirl Content-Type: text/plain; charset=UTF-8 Subject: [Qemu-devel] Re: [PATCH 1/2] Move KVM init to arch_init.c, compile vl.c once List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel On 4/1/10, Paolo Bonzini wrote: > On 04/01/2010 10:07 PM, Blue Swirl wrote: > > > Remove dependency of vl.c to KVM, then we can partially revert > > b33612d03540fda7fa67485f1c20395beb7a2bf0. > > > > This is ugly... > > Michael Tsirkin said in commit ca821806: > > Comment on kvm usage: rather than require users to do if(kvm_enabled()) > and/or ifdefs, this patch adds an API that, internally, is defined to > stub function on non-kvm build, and checks kvm_enabled for non-kvm > run. > > While rest of qemu code still uses if (kvm_enabled()), I think this > approach is cleaner, and we should convert rest of code to it > long term. > > Maybe we can start doing this for kvm_init? I see now. Yes, this would be better approach, I think this is also what Anthony proposed. > > +void enable_kvm(void) > > +{ > > + kvm_allowed = 1; > > +} > > > > If you're adding this, this conditional from vl.c > > if (!(kvm_available())) { > printf("Option %s not supported for this target\n", popt->name); > exit(1); > } > > belongs in arch_init.c too, like in do_smbios_option and > do_acpitable_option. > > Alternatively, with the approach I gave above, you can test in > kvm_maybe_init if kvm_init returns -ENOSYS, and print the error above > instead of "failed to initialize KVM". Also kvm_allowed could be set in kvm-all.c.