This lets us generate XML conditionally based on libvirt version.
---
src/launch-libvirt.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/launch-libvirt.c b/src/launch-libvirt.c
index e4563f8..7653bf9 100644
--- a/src/launch-libvirt.c
+++ b/src/launch-libvirt.c
@@ -100,6 +100,7 @@ xmlBufferDetach (xmlBufferPtr buf)
/* Per-handle data. */
struct backend_libvirt_data {
+ unsigned long version; /* libvirt version */
virConnectPtr conn; /* libvirt connection */
virDomainPtr dom; /* libvirt domain */
char *selinux_label;
@@ -208,7 +209,6 @@ launch_libvirt (guestfs_h *g, void *datav, const char *libvirt_uri)
{
struct backend_libvirt_data *data = datav;
int daemon_accept_sock = -1, console_sock = -1;
- unsigned long version;
virConnectPtr conn = NULL;
virDomainPtr dom = NULL;
CLEANUP_FREE char *capabilities_xml = NULL;
@@ -234,11 +234,13 @@ launch_libvirt (guestfs_h *g, void *datav, const char *libvirt_uri)
return -1;
}
- virGetVersion (&version, NULL, NULL);
+ virGetVersion (&data->version, NULL, NULL);
debug (g, "libvirt version = %lu (%lu.%lu.%lu)",
- version,
- version / 1000000UL, version / 1000UL % 1000UL, version % 1000UL);
- if (version < MIN_LIBVIRT_VERSION) {
+ data->version,
+ data->version / 1000000UL,
+ data->version / 1000UL % 1000UL,
+ data->version % 1000UL);
+ if (data->version < MIN_LIBVIRT_VERSION) {
error (g, _("you must have libvirt >= %d.%d.%d "
"to use the 'libvirt' backend"),
MIN_LIBVIRT_MAJOR, MIN_LIBVIRT_MINOR, MIN_LIBVIRT_MICRO);
--
1.8.5.3