mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
lib: libvirt: Remove assumptions that g->hv != NULL
For the libvirt backend we no longer need to determine if we're using a custom hypervisor using black magic. Instead we can simply check if g->hv is non-NULL.
This commit is contained in:
committed by
rwmjones
parent
503e9fde5a
commit
39d4437e29
@@ -154,7 +154,6 @@ struct libvirt_xml_params {
|
||||
size_t appliance_index; /* index of appliance */
|
||||
bool enable_svirt; /* false if we decided to disable sVirt */
|
||||
bool current_proc_is_root; /* true = euid is root */
|
||||
bool is_custom; /* true if user sets non-default g->hv */
|
||||
};
|
||||
|
||||
static int parse_capabilities (guestfs_h *g, const char *capabilities_xml, struct backend_libvirt_data *data);
|
||||
@@ -167,7 +166,6 @@ 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, 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);
|
||||
@@ -574,8 +572,12 @@ 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.is_custom = is_custom_hv (g, data);
|
||||
params.enable_svirt = !params.is_custom;
|
||||
|
||||
/* Disable sVirt if the user set a custom hypervisor because SELinux
|
||||
* rules probably refer to a specific qemu binary (or label) which a
|
||||
* custom hypervisor probably doesn't have.
|
||||
*/
|
||||
params.enable_svirt = g->hv == NULL;
|
||||
|
||||
/* workaround a libvirt validation bug that rejects disabling selinux
|
||||
* at domain level and also at disk level, as of libvirt 11.8.0
|
||||
@@ -880,24 +882,6 @@ parse_domcapabilities (guestfs_h *g, const char *domcapabilities_xml,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
is_custom_hv (guestfs_h *g, struct backend_libvirt_data *data)
|
||||
{
|
||||
CLEANUP_FREE char *rawpath = NULL;
|
||||
|
||||
if (STREQ (g->hv, data->default_qemu))
|
||||
return 0;
|
||||
|
||||
/* ignore error here, let guest startup fail later */
|
||||
rawpath = realpath(g->hv, NULL);
|
||||
if (rawpath && STREQ (rawpath, data->default_qemu))
|
||||
return 0;
|
||||
|
||||
debug (g, "user passed custom hv=%s (realpath=%s) libvirt default=%s",
|
||||
g->hv, rawpath, data->default_qemu);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if HAVE_LIBSELINUX
|
||||
|
||||
/* Set sVirt (SELinux) socket create context. For details see:
|
||||
@@ -1303,7 +1287,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 (params->is_custom)
|
||||
if (g->hv)
|
||||
single_element ("emulator", g->hv);
|
||||
|
||||
/* Add a random number generator (backend for virtio-rng). */
|
||||
|
||||
Reference in New Issue
Block a user