From: Wenchao Xia <xiawenc(a)linux.vnet.ibm.com>
Since in nested KVM, libvirt-cim doesn't handler it well now, so add this
option to manually disable KVM and fall back to qemu. If there is something
fail caused by nested KVM happend, please consider to set this option to be
true for development and testing.
Signed-off-by: Xu Wang <cngesaint(a)outlook.com>
---
libvirt-cim.conf | 10 ++++++++++
libxkutil/misc_util.c | 8 ++++++++
libxkutil/misc_util.h | 1 +
src/Virt_VirtualSystemManagementService.c | 7 +++++++
4 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/libvirt-cim.conf b/libvirt-cim.conf
index 37d7b0f..f378e4c 100644
--- a/libvirt-cim.conf
+++ b/libvirt-cim.conf
@@ -30,3 +30,13 @@
# Default value: NULL, that is not set.
#
# migrate_ssh_temp_key = "/root/vm_migrate_tmp_id_rsa";
+
+# force_use_qemu (bool)
+# Since in nested KVM, libvirt-cim doesn't handler it well now, so add this
+# option to manually disable KVM and fall back to qemu. If there is something
+# fail caused by nested KVM happend, please consider to set this option to be
+# true for development and testing.
+# Possible values: {true,false}
+# Default value: false
+#
+# force_use_qemu = false;
diff --git a/libxkutil/misc_util.c b/libxkutil/misc_util.c
index 00eb4b1..4c0b0a1 100644
--- a/libxkutil/misc_util.c
+++ b/libxkutil/misc_util.c
@@ -227,6 +227,14 @@ static int is_read_only(void)
return prop.value_bool;
}
+bool get_force_use_qemu(void)
+{
+ static LibvirtcimConfigProperty prop = {
+ "force_use_qemu", CONFIG_BOOL, {0}, 0};
+ libvirt_cim_config_get(&prop);
+ return prop.value_bool;
+}
+
const char *get_mig_ssh_tmp_key(void)
{
static LibvirtcimConfigProperty prop = {
diff --git a/libxkutil/misc_util.h b/libxkutil/misc_util.h
index 0f52290..9e6b419 100644
--- a/libxkutil/misc_util.h
+++ b/libxkutil/misc_util.h
@@ -154,6 +154,7 @@ int virt_set_status(const CMPIBroker *broker,
/* get libvirt-cim config */
const char *get_mig_ssh_tmp_key(void);
+bool get_force_use_qemu(void);
/*
* Local Variables:
diff --git a/src/Virt_VirtualSystemManagementService.c
b/src/Virt_VirtualSystemManagementService.c
index cbb646d..81ec064 100644
--- a/src/Virt_VirtualSystemManagementService.c
+++ b/src/Virt_VirtualSystemManagementService.c
@@ -394,6 +394,13 @@ static bool system_has_kvm(const char *pfx)
virConnectPtr conn;
char *caps = NULL;
bool kvm = false;
+ bool force_use_qemu = get_force_use_qemu();
+
+ /* sometimes disable KVM to avoid problem in nested KVM */
+ if (force_use_qemu) {
+ CU_DEBUG("Enter force use qemu mode!");
+ return false;
+ }
conn = connect_by_classname(_BROKER, pfx, &s);
if ((conn == NULL) || (s.rc != CMPI_RC_OK)) {
--
1.7.1