Previously QEMU enabled KQEMU by default and had -no-kqemu.
0.11.x switched to requiring -enable-kqemu. 0.12.x dropped
kqemu entirely. This patch adds support for -enable-kqemu
so 0.11.x works. It replaces a huge set of if() with a
switch() to make the code a bit more readable.
This patch was inspired by the one John Lumby send to the
list a while ago, but the way I've implemented it is more
in line with the logic we have for KVM.
http://www.redhat.com/archives/libvir-list/2010-July/msg00368.html
* src/qemu/qemu_conf.c, src/qemu/qemu_conf.h: Support
-enable-kqemu
---
src/qemu/qemu_conf.c | 84 +++++++++++++++++++++++++++++++++----------------
src/qemu/qemu_conf.h | 1 +
2 files changed, 57 insertions(+), 28 deletions(-)
diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
index fb85220..0ddf128 100644
--- a/src/qemu/qemu_conf.c
+++ b/src/qemu/qemu_conf.c
@@ -1156,6 +1156,8 @@ static unsigned long long qemudComputeCmdFlags(const char *help,
if (strstr(help, "-no-kqemu"))
flags |= QEMUD_CMD_FLAG_KQEMU;
+ if (strstr(help, "-enable-kqemu"))
+ flags |= QEMUD_CMD_FLAG_ENABLE_KQEMU;
if (strstr(help, "-no-kvm"))
flags |= QEMUD_CMD_FLAG_KVM;
if (strstr(help, "-enable-kvm"))
@@ -3662,6 +3664,7 @@ int qemudBuildCommandLine(virConnectPtr conn,
char boot[VIR_DOMAIN_BOOT_LAST];
struct utsname ut;
int disableKQEMU = 0;
+ int enableKQEMU = 0;
int disableKVM = 0;
int enableKVM = 0;
int qargc = 0, qarga = 0;
@@ -3711,38 +3714,59 @@ int qemudBuildCommandLine(virConnectPtr conn,
emulator = def->emulator;
- /* Need to explicitly disable KQEMU if
- * 1. Guest domain is 'qemu'
- * 2. The qemu binary has the -no-kqemu flag
- */
- if ((qemuCmdFlags & QEMUD_CMD_FLAG_KQEMU) &&
- def->virtType == VIR_DOMAIN_VIRT_QEMU)
- disableKQEMU = 1;
-
- /* Need to explicitly disable KVM if
- * 1. Guest domain is 'qemu'
- * 2. The qemu binary has the -no-kvm flag
+ /*
+ * do not use boot=on for drives when not using KVM since this
+ * is not supported at all in upstream QEmu.
*/
if ((qemuCmdFlags & QEMUD_CMD_FLAG_KVM) &&
- def->virtType == VIR_DOMAIN_VIRT_QEMU) {
- disableKVM = 1;
+ (def->virtType == VIR_DOMAIN_VIRT_QEMU) &&
+ (qemuCmdFlags & QEMUD_CMD_FLAG_DRIVE_BOOT))
+ qemuCmdFlags -= QEMUD_CMD_FLAG_DRIVE_BOOT;
+
+ switch (def->virtType) {
+ case VIR_DOMAIN_VIRT_QEMU:
+ if (qemuCmdFlags & QEMUD_CMD_FLAG_KQEMU)
+ disableKQEMU = 1;
+ if (qemuCmdFlags & QEMUD_CMD_FLAG_KVM)
+ disableKVM = 1;
+ break;
- /*
- * do not use boot=on for drives when not using KVM since this
- * is not supported at all in upstream QEmu.
- */
- if (qemuCmdFlags & QEMUD_CMD_FLAG_DRIVE_BOOT)
- qemuCmdFlags -= QEMUD_CMD_FLAG_DRIVE_BOOT;
- }
+ case VIR_DOMAIN_VIRT_KQEMU:
+ if (qemuCmdFlags & QEMUD_CMD_FLAG_KVM)
+ 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;
+ if (qemuCmdFlags & QEMUD_CMD_FLAG_ENABLE_KQEMU) {
+ enableKQEMU = 1;
+ } else if (!(qemuCmdFlags & QEMUD_CMD_FLAG_KQEMU)) {
+ qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("the QEMU binary %s does not support kqemu"),
+ emulator);
+ }
+ break;
+
+ case VIR_DOMAIN_VIRT_KVM:
+ if (qemuCmdFlags & QEMUD_CMD_FLAG_KQEMU)
+ disableKQEMU = 1;
+
+ if (qemuCmdFlags & QEMUD_CMD_FLAG_ENABLE_KVM) {
+ enableKVM = 1;
+ } else if (!(qemuCmdFlags & QEMUD_CMD_FLAG_KVM)) {
+ qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("the QEMU binary %s does not support kvm"),
+ emulator);
+ }
+ break;
+
+ case VIR_DOMAIN_VIRT_XEN:
+ /* XXX better check for xenner */
+ break;
+
+ default:
+ qemuReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+ _("the QEMU binary %s does not support %s"),
+ emulator, virDomainVirtTypeToString(def->virtType));
+ break;
+ }
#define ADD_ARG_SPACE \
do { \
@@ -3857,6 +3881,10 @@ int qemudBuildCommandLine(virConnectPtr conn,
if (disableKQEMU)
ADD_ARG_LIT("-no-kqemu");
+ else if (enableKQEMU) {
+ ADD_ARG_LIT("-enable-kqemu");
+ ADD_ARG_LIT("-kernel-kqemu");
+ }
if (disableKVM)
ADD_ARG_LIT("-no-kvm");
if (enableKVM)
diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h
index 1aa9d2e..4f9c714 100644
--- a/src/qemu/qemu_conf.h
+++ b/src/qemu/qemu_conf.h
@@ -92,6 +92,7 @@ enum qemud_cmd_flags {
QEMUD_CMD_FLAG_PCI_CONFIGFD = (1LL << 36), /* pci-assign.configfd */
QEMUD_CMD_FLAG_NODEFCONFIG = (1LL << 37), /* -nodefconfig */
QEMUD_CMD_FLAG_BOOT_MENU = (1LL << 38), /* -boot menu=on support */
+ QEMUD_CMD_FLAG_ENABLE_KQEMU = (1LL << 39), /* Is the -enable-kqemu flag
available to "enable KQEMU full virtualization support" */
};
/* Main driver state */
--
1.7.2.1