[Pkg-libvirt-commits] [libguestfs] 69/146: launch: libvirt: Fix labelling of overlay files.

Hilko Bengen bengen at moszumanska.debian.org
Sun Mar 29 17:00:35 UTC 2015


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to branch master
in repository libguestfs.

commit e7c1c1df1dbe5baf1af962b2bd26eeda50733a47
Author: Richard W.M. Jones <rjones at redhat.com>
Date:   Thu Dec 11 14:05:47 2014 +0000

    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
    drives).
    
    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:
    https://bugzilla.redhat.com/show_bug.cgi?id=912499#c10
    
    (cherry picked from commit 39f7eaea80c103d9b1cdf1826c4bc70c304c860e)
---
 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;
 
 #if HAVE_LIBSELINUX
+  /* 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 =

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list