[libvirt] [PATCH] Allow use of file images for LXC container filesystems

Daniel P. Berrange berrange at redhat.com
Wed Sep 28 08:02:20 UTC 2011


On Tue, Sep 27, 2011 at 05:27:42PM -0600, Eric Blake wrote:
> On 08/04/2011 09:41 AM, Daniel P. Berrange wrote:
> >From: "Daniel P. Berrange"<berrange at redhat.com>
> >
> >A previous commit gave the LXC driver the ability to mount
> >block devices for the container filesystem. Through use of
> >the loopback device functionality, we can build on this to
> >support use of plain file images for LXC filesytems.
> >
> >By setting the LO_FLAGS_AUTOCLEAR flag we can ensure that
> >the loop device automatically disappears when the container
> >dies / shuts down
> >
> 
> >+static int lxcSetupLoopDevice(virDomainFSDefPtr fs)
> >+{
> >+    int lofd = -1;
> >+    int fsfd = -1;
> >+    struct loop_info64 lo;
> >+    char *loname = NULL;
> >+    int ret = -1;
> >+
> >+    if ((lofd = lxcGetLoopFD(&loname))<  0)
> >+        return -1;
> >+
> >+    memset(&lo, 0, sizeof(lo));
> >+    lo.lo_flags = LO_FLAGS_AUTOCLEAR;
> 
> The kernel headers available on RHEL 5 or CentOS 5 lack this enum
> value, which causes compilation to fail if you are trying to build
> lxc support for these older systems.  When I have some time, I will
> probably just write a patch that adds a configure.ac probe for
> LO_FLAGS_AUTOCLEAR, and where it is missing, make any attempt to do
> plan9 file system passthrough to lxc guests fail since they are
> unsupported on these old kernels.  You should still be able to use
> the other aspects of lxc that don't involve file system passthrough,
> although obviously lxc isn't getting much testing on these older
> systems.

plan9 FS is only a KVM thing.

This code shouldn't ever be being compiled on RHEL5, since it does not
have any kernel container namespace support at all. So if we have a new
enough kernel for LXC, we should have LO_FLAGS_AUTOCLEAR

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list