Re: [PATCH 5/5] lxc: don't unmount subtree if it contains the source of the mount

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

 



On Tue, 2014-11-25 at 08:48 +0100, Martin Kletzander wrote:
> On Mon, Nov 24, 2014 at 09:54:46PM +0100, Cédric Bosdonnat wrote:
> >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.
> 
> I probably didn't quite get this.  This is only true when host root is
> the root of the container, isn't it?  And in that case it doesn't make
> much sense to do this.

Indeed that happens when the host root is mounted as the container
root... and that's what virt-sandbox-service does. We have this
situation when the libvirt-sandbox service has a disk image:
  * The disk image is mounted to /var/lib/libvirt/filesystems/<name>
  * Quite a few items from /var/lib/libvirt/filesystems/<name> are
    bind mounted to their equivalent in the container root, and /var is
    one of them.

--
Cedric

> >---
> > src/lxc/lxc_container.c | 8 ++++++--
> > 1 file changed, 6 insertions(+), 2 deletions(-)
> >
> >diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
> >index 12f3a41..334a1df 100644
> >--- a/src/lxc/lxc_container.c
> >+++ b/src/lxc/lxc_container.c
> >@@ -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)
> >--
> >2.1.2
> >
> >--
> >libvir-list mailing list
> >libvir-list@xxxxxxxxxx
> >https://www.redhat.com/mailman/listinfo/libvir-list


--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]