]> xenbits.xensource.com Git - libvirt.git/commitdiff
lxc: don't unmount subtree if it contains the source of the mount
authorCédric Bosdonnat <cbosdonnat@suse.com>
Mon, 24 Nov 2014 14:10:19 +0000 (15:10 +0100)
committerCédric Bosdonnat <cbosdonnat@suse.com>
Tue, 25 Nov 2014 10:40:55 +0000 (11:40 +0100)
The typical case where we had a problem is with such a filesystem
definition as created by virt-sandbox-service:

    <filesystem type='bind' accessmode='passthrough'>
      <source dir='/var/lib/libvirt/filesystems/mysshd/var'/>
      <target dir='/var'/>
    </filesystem>

In this case, we don't want to unmount the /var subtree or we may
loose the access to the source folder.

src/lxc/lxc_container.c

index 12f3a41a0f0ddb1467b8b1a3a5774fcfb64cba39..334a1dfc6f6eb8706c5cda37c9d6cb37e1acbc8b 100644 (file)
@@ -1597,11 +1597,15 @@ static int lxcContainerMountAllFS(virDomainDefPtr vmDef,
         if (STREQ(vmDef->fss[i]->dst, "/"))
             continue;
 
+        VIR_DEBUG("Mounting '%s' -> '%s'", vmDef->fss[i]->src, vmDef->fss[i]->dst);
+
         if (lxcContainerResolveSymlinks(vmDef->fss[i], false) < 0)
             return -1;
 
-        if (lxcContainerUnmountSubtree(vmDef->fss[i]->dst,
-                                       false) < 0)
+
+        if (!(vmDef->fss[i]->src &&
+              STRPREFIX(vmDef->fss[i]->src, vmDef->fss[i]->dst)) &&
+            lxcContainerUnmountSubtree(vmDef->fss[i]->dst, false) < 0)
             return -1;
 
         if (lxcContainerMountFS(vmDef->fss[i], sec_mount_options) < 0)