[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH v4 6/6] launch: libvirt: Fix labelling of overlay files.

We had code (added for RHBZ#912499) which labels overlay files
correctly so that libvirt can read them.  Unfortunately this code was
broken by subsequent commits: the new backend setting for the
imagelabel is only copied to the 'data' struct during launch, but the
create_cow_overlay callback is called before launch (when adding

The fix is easy: ensure create_cow_overlay_libvirt checks for the
backend setting and initializes the 'data' struct.

This change also means we need to free (data->selinux_imagelabel)
before setting it in launch (and we do the same for
data->selinux_label, although that's not strictly necessary).

For background on this, see:
 src/launch-libvirt.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/launch-libvirt.c b/src/launch-libvirt.c
index 1f3c451..ea0502f 100644
--- a/src/launch-libvirt.c
+++ b/src/launch-libvirt.c
@@ -217,6 +217,15 @@ create_cow_overlay_libvirt (guestfs_h *g, void *datav, struct drive *drv)
     return NULL;
+  /* Since this function is called before launch, the field won't be
+   * initialized correctly, so we have to initialize it here.
+   */
+  guestfs_push_error_handler (g, NULL, NULL);
+  free (data->selinux_imagelabel);
+  data->selinux_imagelabel =
+    guestfs_get_backend_setting (g, "internal_libvirt_imagelabel");
+  guestfs_pop_error_handler (g);
   if (data->selinux_imagelabel) {
     debug (g, "setting SELinux label on %s to %s",
            overlay, data->selinux_imagelabel);
@@ -350,8 +359,10 @@ launch_libvirt (guestfs_h *g, void *datav, const char *libvirt_uri)
   /* Misc backend settings. */
   guestfs_push_error_handler (g, NULL, NULL);
+  free (data->selinux_label);
   data->selinux_label =
     guestfs_get_backend_setting (g, "internal_libvirt_label");
+  free (data->selinux_imagelabel);
   data->selinux_imagelabel =
     guestfs_get_backend_setting (g, "internal_libvirt_imagelabel");
   data->selinux_norelabel_disks =

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]