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

Dave Leskovec dlesko at linux.vnet.ibm.com
Thu Feb 21 06:24:49 UTC 2008


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




More information about the libvir-list mailing list