summaryrefslogtreecommitdiffstats
path: root/src/launch-libvirt.c
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2012-07-23 13:14:16 +0100
committerRichard W.M. Jones <rjones@redhat.com>2012-07-23 13:14:16 +0100
commit68836022d26fdb3f55596cd12ecf1cf6e54f547c (patch)
tree81e54a504fc675a5ced441dd845f2db2564b711c /src/launch-libvirt.c
parent890a4fbc8740b9b2019885a866aa06bc82566a41 (diff)
downloadlibguestfs-68836022d26fdb3f55596cd12ecf1cf6e54f547c.tar.gz
libguestfs-68836022d26fdb3f55596cd12ecf1cf6e54f547c.tar.xz
libguestfs-68836022d26fdb3f55596cd12ecf1cf6e54f547c.zip
launch: libvirt: Add a hack to detect if KVM is available.
We need to select the <domain type=...> attribute depending on whether KVM is detected in the libvirt capabilities. This is a hack because it doesn't try to parse the libvirt capabilities XML.
Diffstat (limited to 'src/launch-libvirt.c')
-rw-r--r--src/launch-libvirt.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/launch-libvirt.c b/src/launch-libvirt.c
index 7f46e2d9..2574b6a9 100644
--- a/src/launch-libvirt.c
+++ b/src/launch-libvirt.c
@@ -436,6 +436,7 @@ construct_libvirt_xml (guestfs_h *g, const char *capabilities_xml,
xmlTextWriterPtr xo = NULL;
struct drive *drv = g->drives;
size_t appliance_index = 0;
+ const char *type;
/* Count the number of disks added, in order to get the offset
* of the appliance disk.
@@ -445,6 +446,9 @@ construct_libvirt_xml (guestfs_h *g, const char *capabilities_xml,
appliance_index++;
}
+ /* Big hack, instead of actually parsing the capabilities XML (XXX). */
+ type = strstr (capabilities_xml, "'kvm'") != NULL ? "kvm" : "qemu";
+
XMLERROR (NULL, xb = xmlBufferCreate ());
XMLERROR (NULL, ob = xmlOutputBufferCreateBuffer (xb, NULL));
XMLERROR (NULL, xo = xmlNewTextWriter (ob));
@@ -455,7 +459,7 @@ construct_libvirt_xml (guestfs_h *g, const char *capabilities_xml,
XMLERROR (-1, xmlTextWriterStartElement (xo, BAD_CAST "domain"));
XMLERROR (-1,
- xmlTextWriterWriteAttribute (xo, BAD_CAST "type", BAD_CAST "kvm"));
+ xmlTextWriterWriteAttribute (xo, BAD_CAST "type", BAD_CAST type));
XMLERROR (-1,
xmlTextWriterWriteAttributeNS (xo,
BAD_CAST "xmlns",