diff options
author | 2009-11-20 15:41:05 +0100 | |
---|---|---|
committer | 2009-11-20 15:41:05 +0100 | |
commit | b827338a7219106bc6d17cebb5d0c7f5d4bc7d6d (patch) | |
tree | e7fd04b4f4ccc79563f4cc56dde46bd170d9bc71 | |
parent | fix deprecated iptables command syntax (diff) | |
download | libvirt-b827338a7219106bc6d17cebb5d0c7f5d4bc7d6d.tar.gz libvirt-b827338a7219106bc6d17cebb5d0c7f5d4bc7d6d.tar.bz2 libvirt-b827338a7219106bc6d17cebb5d0c7f5d4bc7d6d.zip |
qemu-kvm needs -enable-kvm flag for VT optimization
Recent qemu releases require command option '-enable-qemu' in order
for the kvm functionality be activated. Libvirt needs to pass this flag
to qemu when starting a domain. Note that without the option,
even if both the kernel and qemu support KVM, KVM will not be activated
and VMs will be very slow.
* src/qemu/qemu_conf.h src/qemu/qemu_conf.c: parse the extra command
line option from help and add it when running kvm
* tests/qemuhelptest.c: this modified the flags output for qemu-0.10.5
and qemu-kvm-0.11.0-rc2 regression tests
-rw-r--r-- | src/qemu/qemu_conf.c | 14 | ||||
-rw-r--r-- | src/qemu/qemu_conf.h | 1 | ||||
-rw-r--r-- | tests/qemuhelptest.c | 6 |
3 files changed, 19 insertions, 2 deletions
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index c807688e0..f26e94dd8 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -878,6 +878,8 @@ static unsigned int qemudComputeCmdFlags(const char *help, flags |= QEMUD_CMD_FLAG_KQEMU; if (strstr(help, "-no-kvm")) flags |= QEMUD_CMD_FLAG_KVM; + if (strstr(help, "-enable-kvm")) + flags |= QEMUD_CMD_FLAG_ENABLE_KVM; if (strstr(help, "-no-reboot")) flags |= QEMUD_CMD_FLAG_NO_REBOOT; if (strstr(help, "-name")) @@ -1595,6 +1597,7 @@ int qemudBuildCommandLine(virConnectPtr conn, struct utsname ut; int disableKQEMU = 0; int disableKVM = 0; + int enableKVM = 0; int qargc = 0, qarga = 0; const char **qargv = NULL; int qenvc = 0, qenva = 0; @@ -1653,6 +1656,15 @@ int qemudBuildCommandLine(virConnectPtr conn, def->virtType == VIR_DOMAIN_VIRT_QEMU) disableKVM = 1; + /* Should explicitly enable KVM if + * 1. Guest domain is 'kvm' + * 2. The qemu binary has the -enable-kvm flag + * NOTE: user must be responsible for loading the kvm modules + */ + if ((qemuCmdFlags & QEMUD_CMD_FLAG_ENABLE_KVM) && + def->virtType == VIR_DOMAIN_VIRT_KVM) + enableKVM = 1; + /* * Need to force a 32-bit guest CPU type if * @@ -1780,6 +1792,8 @@ int qemudBuildCommandLine(virConnectPtr conn, ADD_ARG_LIT("-no-kqemu"); if (disableKVM) ADD_ARG_LIT("-no-kvm"); + if (enableKVM) + ADD_ARG_LIT("-enable-kvm"); ADD_ARG_LIT("-m"); ADD_ARG_LIT(memory); if (def->hugepage_backed) { diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 5d433d38d..1bf3e1672 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -73,6 +73,7 @@ enum qemud_cmd_flags { QEMUD_CMD_FLAG_XEN_DOMID = (1 << 20), /* -xen-domid (new style xen integration) */ QEMUD_CMD_FLAG_MIGRATE_QEMU_UNIX = (1 << 21), /* Does qemu support unix domain sockets for migration? */ QEMUD_CMD_FLAG_CHARDEV = (1 << 22), /* Is the new -chardev arg available */ + QEMUD_CMD_FLAG_ENABLE_KVM = (1 << 23), /* Is the -enable-kvm flag available to "enable KVM full virtualization support" */ }; /* Main driver state */ diff --git a/tests/qemuhelptest.c b/tests/qemuhelptest.c index 428d9a38d..a747da740 100644 --- a/tests/qemuhelptest.c +++ b/tests/qemuhelptest.c @@ -121,7 +121,8 @@ mymain(int argc, char **argv) QEMUD_CMD_FLAG_DRIVE_FORMAT | QEMUD_CMD_FLAG_DRIVE_SERIAL | QEMUD_CMD_FLAG_VGA | - QEMUD_CMD_FLAG_0_10, + QEMUD_CMD_FLAG_0_10 | + QEMUD_CMD_FLAG_ENABLE_KVM, 10005, 0, 0); DO_TEST("qemu-kvm-0.10.5", QEMUD_CMD_FLAG_VNC_COLON | @@ -177,7 +178,8 @@ mymain(int argc, char **argv) QEMUD_CMD_FLAG_VGA | QEMUD_CMD_FLAG_0_10 | QEMUD_CMD_FLAG_PCIDEVICE | - QEMUD_CMD_FLAG_MEM_PATH, + QEMUD_CMD_FLAG_MEM_PATH | + QEMUD_CMD_FLAG_ENABLE_KVM, 10092, 1, 0); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; |