From 68836022d26fdb3f55596cd12ecf1cf6e54f547c Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 23 Jul 2012 13:14:16 +0100 Subject: launch: libvirt: Add a hack to detect if KVM is available. We need to select the 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. --- src/launch-libvirt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/launch-libvirt.c') 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", -- cgit