On 08/04/2011 09:41 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange"<berrange(a)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.
--
Eric Blake eblake(a)redhat.com +1-801-349-2682
Libvirt virtualization library
http://libvirt.org