From c9543de73d264943fef88f5e53403bbe32917b01 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Fri, 24 May 2019 12:32:29 +0200 Subject: [PATCH] launch: libvirt: fix custom hypervisor check Previously, is_custom_hv() used to compare the QEMU executable found during configure to the hypervisor set to check whether it is a custom one; however, the QEMU found at configure time can be different than what libvirt was configured with. This fixes the libvirt backend when libguestfs is configured with a different QEMU, that now will be specified as emulator overriding the libvirt one. --- lib/launch-libvirt.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/launch-libvirt.c b/lib/launch-libvirt.c index 8ab1211c4..95aed8054 100644 --- a/lib/launch-libvirt.c +++ b/lib/launch-libvirt.c @@ -163,7 +163,7 @@ static void debug_appliance_permissions (guestfs_h *g); static void debug_socket_permissions (guestfs_h *g); static void libvirt_error (guestfs_h *g, const char *fs, ...) __attribute__((format (printf,2,3))); static void libvirt_debug (guestfs_h *g, const char *fs, ...) __attribute__((format (printf,2,3))); -static int is_custom_hv (guestfs_h *g); +static int is_custom_hv (guestfs_h *g, struct backend_libvirt_data *data); static int is_blk (const char *path); static void ignore_errors (void *ignore, virErrorPtr ignore2); static void set_socket_create_context (guestfs_h *g); @@ -606,7 +606,7 @@ launch_libvirt (guestfs_h *g, void *datav, const char *libvirt_uri) params.appliance_index = g->nr_drives; strcpy (params.appliance_dev, "/dev/sd"); guestfs_int_drive_name (params.appliance_index, ¶ms.appliance_dev[7]); - params.enable_svirt = ! is_custom_hv (g); + params.enable_svirt = ! is_custom_hv (g, data); xml = construct_libvirt_xml (g, ¶ms); if (!xml) @@ -873,13 +873,15 @@ parse_domcapabilities (guestfs_h *g, const char *domcapabilities_xml, } static int -is_custom_hv (guestfs_h *g) +is_custom_hv (guestfs_h *g, struct backend_libvirt_data *data) { + if (g->hv && STRNEQ (g->hv, data->default_qemu)) + return 1; #ifdef QEMU - return g->hv && STRNEQ (g->hv, QEMU); -#else - return 1; + if (STRNEQ (data->default_qemu, QEMU)) + return 1; #endif + return 0; } #if HAVE_LIBSELINUX @@ -1265,7 +1267,7 @@ construct_libvirt_xml_devices (guestfs_h *g, /* Path to hypervisor. Only write this if the user has changed the * default, otherwise allow libvirt to choose the best one. */ - if (is_custom_hv (g)) + if (is_custom_hv (g, params->data)) single_element ("emulator", g->hv); #if defined(__arm__) /* Hopefully temporary hack to make ARM work (otherwise libvirt