Move KVM init to arch_init.c, compile vl.c once
PATCH 1/2 Move KVM init to arch_init.c, compile vl.c once
Remove dependency of vl.c to KVM, then we can partially revert b33612d03540fda7fa67485f1c20395beb7a2bf0.
--- Makefile.objs | 2 +- Makefile.target | 2 +- arch_init.c | 20 ++++++++++++++++++++ arch_init.h | 2 ++ vl.c | 14 ++------------ 5 files changed, 26 insertions(+), 14 deletions(-)
Makefile.objs +1 -1
@@ -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
Makefile.target +1 -1
@@ -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
arch_init.c +20 -0
@@ -41,6 +41,8 @@#include "gdbstub.h" #include "hw/smbios.h" +int kvm_allowed =0 ; +#ifdef TARGET_SPARC int graphic_width =1024 ;int graphic_height =768 ;
@@ -508,3 +510,21 @@ int xen_available(void)return 0 ;#endif } + +void enable_kvm (void ) +{ + kvm_allowed =1 ; +} + +void kvm_maybe_init (int smp_cpus) +{ +if (kvm_enabled ()) { +int ret; + + ret =kvm_init (smp_cpus); +if (ret <0 ) { +fprintf (stderr,"failed to initialize KVM\n" ); +exit (1 ); + } + } +}
arch_init.h +2 -0
@@ -29,5 +29,7 @@ void cpudef_init(void);int audio_available (void );int kvm_available (void );int xen_available (void ); +void enable_kvm (void ); +void kvm_maybe_init (int smp_cpus);#endif
vl.c +0 -2
@@ -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 ;
@@ -3228,7 +3226,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();
break;
case QEMU_OPTION_usb:
usb_enabled = 1;
@@ -3574,15 +3572,7 @@ 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);
- }
- }
+ kvm_maybe_init(smp_cpus);
if (qemu_init_main_loop()) {
fprintf(stderr, "qemu_init_main_loop failed\n");Signature · 1 line
1.6.2.4
Quoted 54 lines · Blue Swirl
Remove dependency of
vl.cto KVM, then we can partially revertb33612d03540fda7fa67485f1c20395beb7a2bf0.Signed-off-by Blue Swirl<[email protected]>--- Makefile.objs | 2 +- Makefile.target | 2 +- arch_init.c | 20 ++++++++++++++++++++ arch_init.h | 2 ++ vl.c | 14 ++------------ 5 files changed, 26 insertions(+), 14 deletions(-)Makefile.objs +1
-1@@ -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.oMakefile.target +1
-1@@ -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.ovirtio-serial-bus.o
arch_init.c +2
-0@@ -41,6 +41,8 @@#include "gdbstub.h" #include "hw/smbios.h" +int kvm_allowed =0 ; +#ifdef TARGET_SPARC int graphic_width =1024 ;int graphic_height =768 ;
arch_init.c int xen_available(void) · line 517
Quoted 8 lines
arch_init.c +5
-0@@ -508,3 +510,21 @@ int xen_available(void)return 0 ;#endif } + +void enable_kvm (void ) +{ + kvm_allowed =1 ; +}
Can we get away with keeping a local to vl.c use_kvm flag and then call kvm_init() if use_kvm in vl.c?
We can stick a stub kvm_init() in arch_init.c if !CONFIG_KVM.
Regards,
Anthony LIguori
Quoted 72 lines
arch_init.c +12
-0+void kvm_maybe_init (int smp_cpus) +{ +if (kvm_enabled ()) { +int ret; + + ret =kvm_init (smp_cpus); +if (ret<0 ) { +fprintf (stderr,"failed to initialize KVM\n" ); +exit (1 ); + } + } +}arch_init.h +2
-0@@ -29,5 +29,7 @@ void cpudef_init(void);int audio_available (void );int kvm_available (void );int xen_available (void ); +void enable_kvm (void ); +void kvm_maybe_init (int smp_cpus);#endif vl.c +1
-3@@ -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 ;@@ -3228,7 +3226,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 ();break ;case QEMU_OPTION_usb:usb_enabled = 1;vl.c +1
-9@@ -3574,15 +3572,7 @@ 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 ); - } - } +kvm_maybe_init (smp_cpus);if (qemu_init_main_loop ()) {fprintf (stderr,"qemu_init_main_loop failed\n" );
Quoted 61 lines · Anthony Liguori
Quoted 30 lines · Blue Swirl
Remove dependency of
vl.cto KVM, then we can partially revertb33612d03540fda7fa67485f1c20395beb7a2bf0.Signed-off-by Blue Swirl<[email protected]>--- Makefile.objs | 2 +- Makefile.target | 2 +- arch_init.c | 20 ++++++++++++++++++++ arch_init.h | 2 ++ vl.c | 14 ++------------ 5 files changed, 26 insertions(+), 14 deletions(-)Makefile.objs +1
-1@@ -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.oMakefile.target +0
-0Makefile.target endif #CONFIG_BSD_USER · line 165
Quoted 6 lines
Makefile.target +1
-1@@ -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 andvirtio-net.
Quoted 22 lines
Makefile.target +0
-0# need to fix this properly obj-y += virtio-blk.o virtio-balloon.o virtio-net.o virtio-pci.ovirtio-serial-bus.o
arch_init.c +4
-0@@ -41,6 +41,8 @@#include "gdbstub.h" #include "hw/smbios.h" +int kvm_allowed =0 ; +#ifdef TARGET_SPARC int graphic_width =1024 ;int graphic_height =768 ;@@ -508,3 +510,21 @@ int xen_available(void)return 0 ;#endif } + +void enable_kvm (void )
Quoted 8 lines
arch_init.c int xen_available(void) · line 517
Quoted 5 lines
arch_init.c +3
-0+{ + kvm_allowed =1 ; +}Can we get away with keeping a local to
vl.cuse_kvmflag and then callkvm_init()ifuse_kvminvl.c?
It will not be safe to use kvm_enabled() in vl.c, so there needs to be a target dependent helper. The call to kvm_init could remain in vl.c, likewise it's not strictly needed to move kvm_allowed to arch_init.c. They just caused problems with the poisoning check in patch 2/2. But with this approach, because kvm.h is no longer included, there will not be any problems.
Quoted 84 lines
We can stick a stub
kvm_init()inarch_init.cif !CONFIG_KVM.Regards,
Anthony LIguori
Quoted 73 lines
arch_init.c +12
-0+void kvm_maybe_init (int smp_cpus) +{ +if (kvm_enabled ()) { +int ret; + + ret =kvm_init (smp_cpus); +if (ret<0 ) { +fprintf (stderr,"failed to initialize KVM\n" ); +exit (1 ); + } + } +}arch_init.h +2
-0@@ -29,5 +29,7 @@ void cpudef_init(void);int audio_available (void );int kvm_available (void );int xen_available (void ); +void enable_kvm (void ); +void kvm_maybe_init (int smp_cpus);#endif vl.c +1
-3@@ -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 ;@@ -3228,7 +3226,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 ();break ;case QEMU_OPTION_usb:usb_enabled = 1;vl.c +1
-9@@ -3574,15 +3572,7 @@ 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 ); - } - } +kvm_maybe_init (smp_cpus);if (qemu_init_main_loop ()) {fprintf (stderr,"qemu_init_main_loop failed\n" );
Quoted 3 lines · Blue Swirl
It will not be safe to use
kvm_enabled()invl.c, so there needs to be a target dependent helper. The call tokvm_initcould remain invl.c, likewise it's not strictly needed to movekvm_allowedtoarch_init.c.
Not really, because kvm_allowed _can_ be used from once-compiled files.
The attached patch makes kvm-all.c be compiled always, even if
!CONFIG_KVM; functions that require kvm are almost always omitted for now (so checking kvm_enabled() is required to call them). However, kvm_init is stubbed so that vl.c can call it.
In the future we could add more stubbing and ultimately do this unconditionally:
#define kvm_enabled() kvm_allowed
With this patch vl.c can already be compiled once, but I did not include it because it would conflict with my balloon.c series; I'm doing enough rebasing these days. Also, qemu-kvm is a bit behind qemu and all these patches are nightmares for the merges, so it's better IMO if things are left to calm down a bit.
Quoted 1 line
They just caused problems with the poisoning check in patch 2/2.
Poisoning kvm_enabled is right, but poisoning kvm_allowed is overkill.
Paolo
From e9bd21893633365567b7c0d468a9971ab02e46f0 Mon Sep 17 00:00:00 2001
From: Paolo Bonzini <[email protected]>
Date: Fri, 2 Apr 2010 09:29:54 +0200
Subject: [PATCH] provide a stub version of kvm-all.c if !CONFIG_KVM
This allows limited use of kvm functions (which will return ENOSYS) even in once-compiled modules. The patch also improves a bit the error messages for KVM initialization.
--- Makefile.target | 4 ++-- kvm-all.c | 16 ++++++++++++++-- kvm.h | 4 +++- vl.c | 16 +++++++--------- 4 files changed, 26 insertions(+), 14 deletions(-)
Makefile.target +2 -2
@@ -168,8 +168,8 @@ obj-y += virtio-blk.o virtio-balloon.o virtio-net.o virtio-pci.o virtio-serial-b obj-y += event_notifier.o obj-y += vhost_net.o obj-$(CONFIG_VHOST_NET) += vhost.o -obj-y += rwhandler.o -obj-$(CONFIG_KVM) += kvm.o kvm-all.o +obj-y += rwhandler.o kvm-all.o +obj-$(CONFIG_KVM) += kvm.o LIBS+=-lz QEMU_CFLAGS += $(VNC_TLS_CFLAGS)
kvm-all.c +14 -2
@@ -13,14 +13,16 @@* */ +#include "qemu-common.h" #include <sys/types.h> #include <sys/ioctl.h> #include <sys/mman.h> #include <stdarg.h> +#ifdef CONFIG_KVM #include <linux/kvm.h> +#endif -#include "qemu-common.h" #include "qemu-barrier.h" #include "sysemu.h" #include "hw/hw.h"
@@ -73,6 +75,7 @@ struct KVMStatestatic KVMState *kvm_state; +#ifdef CONFIG_KVM static KVMSlot *kvm_alloc_slot (KVMState *s) {int i;
@@ -282,7 +285,7 @@ static int kvm_set_migration_log(int enable)return 0 ; } -static int test_le_bit (unsigned long nr,unsigned char *addr) +static inline int test_le_bit (unsigned long nr,unsigned char *addr) {return (addr[nr >>3 ] >> (nr &7 )) &1 ; }
@@ -561,9 +564,11 @@ static CPUPhysMemoryClient kvm_cpu_phys_memory_client = { .sync_dirty_bitmap = kvm_client_sync_dirty_bitmap, .migration_log = kvm_client_migration_log, }; +#endif int kvm_init (int smp_cpus) { +#ifdef CONFIG_KVM static const char upgrade_note[] ="Please upgrade to at least kernel 2.6.29 or recent kvm-kmod\n" "(see http://sourceforge.net/projects/kvm).\n" ;
@@ -683,8 +688,12 @@ err:qemu_free (s);return ret; +#else +return -ENOSYS ; +#endif } +#ifdef CONFIG_KVM static int kvm_handle_io (uint16_t port,void *data,int direction,int size,uint32_t count) {
@@ -866,6 +875,7 @@ int kvm_cpu_exec(CPUState *env) return ret; } +#endif int kvm_ioctl (KVMState *s,int type, ...) {
@@ -1139,6 +1149,7 @@ void kvm_remove_all_breakpoints(CPUState *current_env) }#endif /* !KVM_CAP_SET_GUEST_DEBUG */ +#ifdef CONFIG_KVM int kvm_set_signal_mask (CPUState *env,const sigset_t *sigset) {struct kvm_signal_mask *sigmask;
@@ -1156,6 +1167,7 @@ int kvm_set_signal_mask(CPUState *env, const sigset_t *sigset) return r; } +#endif #ifdef KVM_IOEVENTFD int kvm_set_ioeventfd_pio_word (int fd,uint16_t addr,uint16_t val,bool assign)
kvm.h +3 -1
@@ -18,13 +18,15 @@#include <errno.h> #include "config-host.h" #include "qemu-queue.h" +#include "cpu-common.h" #ifdef CONFIG_KVM #include <linux/kvm.h> #endif -#ifdef CONFIG_KVM extern int kvm_allowed; + +#ifdef CONFIG_KVM #define kvm_enabled () (kvm_allowed)#else #define kvm_enabled () (0)
vl.c +7 -9
@@ -3235,10 +3235,6 @@ int main(int argc, char **argv, char **envp)do_smbios_option (optarg);break ;case QEMU_OPTION_enable_kvm: -if (!(kvm_available ())) { -printf ("Option %s not supported for this target\n" , popt->name); -exit (1 ); - } kvm_allowed =1 ;break ;case QEMU_OPTION_usb:
@@ -3585,12 +3581,14 @@ int main(int argc, char **argv, char **envp)exit (1 ); } -if (kvm_enabled ()) { -int ret; - - ret =kvm_init (smp_cpus); +if (kvm_allowed) { +int ret =kvm_init (smp_cpus);if (ret <0 ) { -fprintf (stderr,"failed to initialize KVM\n" ); +if (!kvm_available ()) { +printf ("KVM not supported for this target\n" ); + }else { +fprintf (stderr,"failed to initialize KVM: %s\n" ,strerror (-ret)); + }exit (1 ); } }
Signature · 1 line
1.6.6.1
Quoted 5 lines · Paolo Bonzini
Quoted 3 lines · Blue Swirl
It will not be safe to use
kvm_enabled()invl.c, so there needs to be a target dependent helper. The call tokvm_initcould remain invl.c, likewise it's not strictly needed to movekvm_allowedtoarch_init.c.
Quoted 7 lines
Not really, because
kvm_allowed_can_ be used from once-compiled files. The attached patch makeskvm-all.cbe compiled always, even if !CONFIG_KVM; functions that require kvm are almost always omitted for now (so checkingkvm_enabled()is required to call them). However,kvm_initis stubbed so thatvl.ccan call it.In the future we could add more stubbing and ultimately do this unconditionally:
#define kvm_enabled() kvm_allowedWith this patch
vl.ccan already be compiled once, but I did not include it because it would conflict with myballoon.cseries; I'm doing enough rebasing these days. Also, qemu-kvm is a bit behind qemu and all these patches are nightmares for the merges, so it's better IMO if things are left to calm down a bit.
Having kvm-all.c compile with and without CONFIG_KVM is pretty ugly IMHO.
Is compiling vl.c once really that important of a goal? Wouldn't it be better to split bits out of vl.c and have those compile once? Ideally, vl.c should be so small that compiling per-target shouldn't matter.
Regards,
Anthony Liguori
Quoted 5 lines
Quoted 1 line
They just caused problems with the poisoning check in patch 2/2.
Poisoning
kvm_enabledis right, but poisoningkvm_allowedis overkill.Paolo
Quoted 3 lines · Anthony Liguori
Having
kvm-all.ccompile with and withoutCONFIG_KVMis pretty ugly IMHO.Is compiling
vl.conce really that important of a goal?
I didn't do this to compile vl.c once. I don't care about that.
I did this as an initial step towards having kvm functions stubbed out for !CONFIG_KVM, instead of relying on GCC performing dead-code-elimination on kvm_enabled().
Paolo
Quoted 8 lines · Paolo Bonzini
Quoted 3 lines · Anthony Liguori
Having
kvm-all.ccompile with and withoutCONFIG_KVMis pretty ugly IMHO.Is compiling
vl.conce really that important of a goal?I didn't do this to compile
vl.conce. I don't care about that.I did this as an initial step towards having kvm functions stubbed out for !CONFIG_KVM, instead of relying on GCC performing dead-code-elimination on
kvm_enabled().
I'd prefer a kvm-stub.c implementation as opposed to mixing in CONFIG_KVM in kvm-all.c
Regards,
Anthony Liguori
Quoted 1 line
Paolo
Quoted 9 lines · Anthony Liguori
Quoted 6 lines
I didn't do this to compile
vl.conce. I don't care about that.I did this as an initial step towards having kvm functions stubbed out for !CONFIG_KVM, instead of relying on GCC performing dead-code-elimination on
kvm_enabled().I'd prefer a
kvm-stub.cimplementation as opposed to mixing inCONFIG_KVMinkvm-all.c
I tried it, but our build system makes it a mess because compile-once-only can only be done using what once were static libraries. All files from there are added blindly:
obj-y += $(addprefix ../, $(common-obj-y)) obj-y += $(addprefix ../libdis/, $(libdis-y)) obj-y += $(libobj-y) obj-y += $(addprefix $(HWDIR)/, $(hw-obj-y))
I'll try something.
Paolo
Quoted 27 lines · Anthony Liguori
Quoted 8 lines · Paolo Bonzini
Quoted 4 lines · Blue Swirl
It will not be safe to use
kvm_enabled()invl.c, so there needs to be a target dependent helper. The call tokvm_initcould remain invl.c, likewise it's not strictly needed to movekvm_allowedtoarch_init.c.Not really, because
kvm_allowed_can_ be used from once-compiled files.The attached patch makes
kvm-all.cbe compiled always, even if !CONFIG_KVM; functions that require kvm are almost always omitted for now (so checkingkvm_enabled()is required to call them). However,kvm_initis stubbed so thatvl.ccan call it.Quoted 2 lines
In the future we could add more stubbing and ultimately do this
unconditionally:
Quoted 4 lines
#define kvm_enabled() kvm_allowedWith this patch
vl.ccan already be compiled once, but I did not includeit because it would conflict with my
balloon.cseries; I'm doing enough rebasing these days. Also, qemu-kvm is a bit behind qemu and all these patches are nightmares for the merges, so it's better IMO if things are left to calm down a bit.Quoted 1 line
Quoted 5 lines
Having
kvm-all.ccompile with and withoutCONFIG_KVMis pretty ugly IMHO.Is compiling
vl.conce really that important of a goal? Wouldn't it be
better to split bits out ofvl.cand have those compile once? Ideally,vl.cshould be so small that compiling per-target shouldn't matter.
But the only thing preventing compiling whole vl.c once is just KVM init. I'll send a new patch, hopefully it's better.
Quoted 2 lines · Blue Swirl
Remove dependency of
vl.cto KVM, then we can partially revertb33612d03540fda7fa67485f1c20395beb7a2bf0.
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?
arch_init.c int xen_available(void) · line 517
Quoted 4 lines
arch_init.c +4
-0+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".
Paolo
Quoted 15 lines · Paolo Bonzini
Quoted 3 lines · Blue Swirl
Remove dependency of
vl.cto KVM, then we can partially revertb33612d03540fda7fa67485f1c20395beb7a2bf0.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_enabledfor non-kvm run.
Quoted 5 lines
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.
Quoted 13 lines
arch_init.c int xen_available(void) · line 517
Quoted 5 lines
arch_init.c +4
-0+void enable_kvm (void ) +{ + kvm_allowed =1 ; +}If you're adding this, this conditional from
vl.cif (!(kvm_available())) { printf("Option %s not supported for this target\n", popt->name); exit(1); }
Quoted 6 lines
belongs in
arch_init.ctoo, like indo_smbios_optionanddo_acpitable_option.Alternatively, with the approach I gave above, you can test in
kvm_maybe_initifkvm_initreturns-ENOSYS, and print the error above instead of "failed to initialize KVM".
Also kvm_allowed could be set in kvm-all.c.