[Libvir] [RFC] 1/3 Base linux container support

This patch contains the base linux container support * new switch --with-lxc to enable support (off by default) * Add new source files to Makefile.am * Add define for lxc in driver.h * Add call to lxcRegister() in libvirt.c * Add define for errors from lxc in virterror.h * Add case for errors from lxc in virterror.c Index: configure.in =================================================================== RCS file: /data/cvs/libvirt/configure.in,v retrieving revision 1.124 diff -u -p -r1.124 configure.in --- configure.in 23 Jan 2008 19:37:10 -0000 1.124 +++ configure.in 19 Feb 2008 18:50:55 -0000 @@ -131,6 +131,8 @@ AC_ARG_WITH(qemu, [ --with-qemu add QEMU/KVM support (on)],[],[with_qemu=yes]) AC_ARG_WITH(openvz, [ --with-openvz add OpenVZ support (off)],[],[with_openvz=no]) +AC_ARG_WITH(lxc, +[ --with-lxc add Linux Container support (off)],[],[with_lxc=no]) AC_ARG_WITH(test, [ --with-test add test driver support (on)],[],[with_test=yes]) AC_ARG_WITH(remote, @@ -228,6 +230,9 @@ WITH_XEN=0 if test "$with_openvz" = "yes" ; then LIBVIRT_FEATURES="$LIBVIRT_FEATURES -DWITH_OPENVZ" fi +if test "$with_lxc" = "yes" ; then + LIBVIRT_FEATURES="$LIBVIRT_FEATURES -DWITH_LXC" +fi if test "$with_qemu" = "yes" ; then LIBVIRT_FEATURES="$LIBVIRT_FEATURES -DWITH_QEMU" fi @@ -720,6 +725,7 @@ AC_MSG_NOTICE([ Xen: $with_xen]) AC_MSG_NOTICE([ Proxy: $with_xen_proxy]) AC_MSG_NOTICE([ QEMU: $with_qemu]) AC_MSG_NOTICE([ OpenVZ: $with_openvz]) +AC_MSG_NOTICE([ LXC: $with_lxc]) AC_MSG_NOTICE([ Test: $with_test]) AC_MSG_NOTICE([ Remote: $with_remote]) AC_MSG_NOTICE([Libvirtd: $with_libvirtd]) Index: include/libvirt/virterror.h =================================================================== RCS file: /data/cvs/libvirt/include/libvirt/virterror.h,v retrieving revision 1.31 diff -u -p -r1.31 virterror.h --- include/libvirt/virterror.h 5 Dec 2007 15:24:15 -0000 1.31 +++ include/libvirt/virterror.h 19 Feb 2008 18:50:56 -0000 @@ -54,6 +54,7 @@ typedef enum { VIR_FROM_OPENVZ, /* Error from OpenVZ driver */ VIR_FROM_XENXM, /* Error at Xen XM layer */ VIR_FROM_STATS_LINUX, /* Error in the Linux Stats code */ + VIR_FROM_LXC, /* Error from Linux Container driver */ } virErrorDomain; Index: src/Makefile.am =================================================================== RCS file: /data/cvs/libvirt/src/Makefile.am,v retrieving revision 1.62 diff -u -p -r1.62 Makefile.am --- src/Makefile.am 5 Jan 2008 16:06:36 -0000 1.62 +++ src/Makefile.am 19 Feb 2008 18:50:56 -0000 @@ -57,6 +57,8 @@ CLIENT_SOURCES = \ qemu_conf.c qemu_conf.h \ openvz_conf.c openvz_conf.h \ openvz_driver.c openvz_driver.h \ + lxc_driver.c lxc_driver.h \ + lxc_conf.c lxc_conf.h \ nodeinfo.h nodeinfo.c \ util.c util.h Index: src/driver.h =================================================================== RCS file: /data/cvs/libvirt/src/driver.h,v retrieving revision 1.41 diff -u -p -r1.41 driver.h --- src/driver.h 5 Feb 2008 19:27:37 -0000 1.41 +++ src/driver.h 19 Feb 2008 18:50:56 -0000 @@ -24,6 +24,7 @@ typedef enum { VIR_DRV_QEMU = 3, VIR_DRV_REMOTE = 4, VIR_DRV_OPENVZ = 5, + VIR_DRV_LXC = 6 } virDrvNo; Index: src/libvirt.c =================================================================== RCS file: /data/cvs/libvirt/src/libvirt.c,v retrieving revision 1.120 diff -u -p -r1.120 libvirt.c --- src/libvirt.c 5 Feb 2008 19:27:37 -0000 1.120 +++ src/libvirt.c 19 Feb 2008 18:50:57 -0000 @@ -40,6 +40,9 @@ #ifdef WITH_OPENVZ #include "openvz_driver.h" #endif +#ifdef WITH_LXC +#include "lxc_driver.h" +#endif /* * TODO: @@ -213,6 +216,9 @@ virInitialize(void) #ifdef WITH_OPENVZ if (openvzRegister() == -1) return -1; #endif +#ifdef WITH_LXC + if (lxcRegister() == -1) return -1; +#endif #ifdef WITH_REMOTE if (remoteRegister () == -1) return -1; #endif Index: src/virterror.c =================================================================== RCS file: /data/cvs/libvirt/src/virterror.c,v retrieving revision 1.36 diff -u -p -r1.36 virterror.c --- src/virterror.c 5 Feb 2008 19:27:37 -0000 1.36 +++ src/virterror.c 19 Feb 2008 18:50:57 -0000 @@ -296,6 +296,9 @@ virDefaultErrorFunc(virErrorPtr err) case VIR_FROM_STATS_LINUX: dom = "Linux Stats "; break; + case VIR_FROM_LXC: + dom = "LXC "; + break; } if ((err->dom != NULL) && (err->code != VIR_ERR_INVALID_DOMAIN)) { -- Best Regards, Dave Leskovec IBM Linux Technology Center Open Virtualization

This patch all looks sensible. Rich. -- Emerging Technologies, Red Hat - http://et.redhat.com/~rjones/ Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SL4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 03798903

On Wed, Feb 20, 2008 at 10:24:49PM -0800, Dave Leskovec wrote:
This patch contains the base linux container support
Looks fine to me, Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/

On Wed, Feb 20, 2008 at 10:24:49PM -0800, Dave Leskovec wrote:
This patch contains the base linux container support
* new switch --with-lxc to enable support (off by default)
Any reason this can't be on-by-default ? I know OpenVZ is off by default but I'd like to see that on by default too. As it stands it never even gets compiled by most people so we don't see whether it breaks. Support for Linux containers can be enabled/disable by user on the fly just by rebooting into a new enough kernel, so we should enable it in libvirt no matter what & probe at runtime if needed.
* Add new source files to Makefile.am * Add define for lxc in driver.h * Add call to lxcRegister() in libvirt.c * Add define for errors from lxc in virterror.h * Add case for errors from lxc in virterror.c
Rest of this patch looks fine. Dan. -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|

On Thu, Feb 21, 2008 at 02:40:07PM +0000, Daniel P. Berrange wrote:
On Wed, Feb 20, 2008 at 10:24:49PM -0800, Dave Leskovec wrote:
This patch contains the base linux container support
* new switch --with-lxc to enable support (off by default)
Any reason this can't be on-by-default ? I know OpenVZ is off by default but I'd like to see that on by default too. As it stands it never even gets compiled by most people so we don't see whether it breaks.
Actually I should clarify - it should be on by default *IF* configure is run on Linux - obviously not applicable for Solaris. Dan. -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|

Daniel P. Berrange wrote:
On Wed, Feb 20, 2008 at 10:24:49PM -0800, Dave Leskovec wrote:
This patch contains the base linux container support
* new switch --with-lxc to enable support (off by default)
Any reason this can't be on-by-default ? I know OpenVZ is off by default but I'd like to see that on by default too. As it stands it never even gets compiled by most people so we don't see whether it breaks.
Support for Linux containers can be enabled/disable by user on the fly just by rebooting into a new enough kernel, so we should enable it in libvirt no matter what & probe at runtime if needed.
I left it off by default because OpenVZ is that way but also because compiles on older (pre 2.6.24) kernels will get errors due to missing CLONE flags in sched.h -- Best Regards, Dave Leskovec IBM Linux Technology Center Open Virtualization
participants (4)
-
Daniel P. Berrange
-
Daniel Veillard
-
Dave Leskovec
-
Richard W.M. Jones