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

[libvirt] [PATCH 2/3] Integrate libxenlight driver into libvirt



---
 configure.ac                |   35 +++++++++++++++++++++++++++++++++--
 include/libvirt/virterror.h |    1 +
 po/POTFILES.in              |    2 ++
 src/Makefile.am             |   25 +++++++++++++++++++++++++
 src/driver.h                |    3 ++-
 src/libvirt.c               |   13 +++++++++++++
 src/util/virterror.c        |    3 +++
 tools/virsh.c               |    3 +++
 8 files changed, 82 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index 8a4083f..65a9409 100644
--- a/configure.ac
+++ b/configure.ac
@@ -239,6 +239,8 @@ AC_ARG_WITH([phyp],
   AC_HELP_STRING([--with-phyp], [add PHYP support @<:@default=check@:>@]),[],[with_phyp=check])
 AC_ARG_WITH([xenapi],
   AC_HELP_STRING([--with-xenapi], [add XenAPI support @<:@default=check@:>@]),[],[with_xenapi=check])
+AC_ARG_WITH([xenlight],
+  AC_HELP_STRING([--with-xenlight], [add XenLight support@<:@default=check@:>@]),[],[with_xenlight=check])
 AC_ARG_WITH([vbox],
   AC_HELP_STRING([--with-vbox=@<:@PFX@:>@],
                  [VirtualBox XPCOMC location @<:@default=yes@:>@]),[],
@@ -478,7 +480,9 @@ old_LIBS="$LIBS"
 old_CFLAGS="$CFLAGS"
 XEN_LIBS=""
 XEN_CFLAGS=""
-dnl search for the Xen store library
+XENLIGHT_LIBS=""
+XENLIGHT_CFLAGS=""
+dnl search for Xen libraries
 if test "$with_xen" != "no" ; then
     if test "$with_xen" != "yes" && test "$with_xen" != "check" ; then
         XEN_CFLAGS="-I$with_xen/include"
@@ -496,6 +500,19 @@ if test "$with_xen" != "no" ; then
            fi
            with_xen=no
        ])
+    old_LIBS_XL="$LIBS"
+    XL_LIBS="-lutil -luuid -lblktapctl -lxenstore -lxenguest"
+    LIBS="$LIBS $XL_LIBS"
+    AC_CHECK_LIB([xenlight], [libxl_ctx_init], [
+           with_xenlight=yes
+           XENLIGHT_LIBS="$XL_LIBS -lxenlight"
+       ],[
+           if test "$with_xenlight" = "yes"; then
+               AC_MSG_ERROR([You need XEN >= 4.1 with libxenlight to use the XenLight driver!])
+           fi
+           with_xenlight=no
+       ])
+    LIBS="$old_LIBS_XL"
 fi
 
 if test "$with_xen" != "no" ; then
@@ -536,11 +553,19 @@ fi
 if test "$with_xen" = "yes"; then
     AC_DEFINE_UNQUOTED([WITH_XEN], 1, [whether Xen driver is enabled])
 fi
-
 AM_CONDITIONAL([WITH_XEN], [test "$with_xen" = "yes"])
+
 AC_SUBST([XEN_CFLAGS])
 AC_SUBST([XEN_LIBS])
 
+if test "$with_xenlight" = "yes"; then
+    AC_DEFINE_UNQUOTED([WITH_XENLIGHT], 1, [whether XenLight driver is enabled])
+fi
+AM_CONDITIONAL([WITH_XENLIGHT], [test "$with_xenlight" = "yes"])
+
+AC_SUBST([XENLIGHT_CFLAGS])
+AC_SUBST([XENLIGHT_LIBS])
+
 dnl
 dnl check for kernel headers required by xen_inotify
 dnl
@@ -2333,6 +2358,7 @@ AC_MSG_NOTICE([  OpenVZ: $with_openvz])
 AC_MSG_NOTICE([  VMware: $with_vmware])
 AC_MSG_NOTICE([    VBox: $with_vbox])
 AC_MSG_NOTICE([  XenAPI: $with_xenapi])
+AC_MSG_NOTICE([XenLight: $with_xenlight])
 AC_MSG_NOTICE([     LXC: $with_lxc])
 AC_MSG_NOTICE([    PHYP: $with_phyp])
 AC_MSG_NOTICE([     ONE: $with_one])
@@ -2442,6 +2468,11 @@ AC_MSG_NOTICE([  xenapi: $LIBXENSERVER_CFLAGS $LIBXENSERVER_LIBS])
 else
 AC_MSG_NOTICE([  xenapi: no])
 fi
+if test "$with_xenlight" = "yes" ; then
+AC_MSG_NOTICE([xenlight: $XENLIGHT_CFLAGS $XENLIGHT_LIBS])
+else
+AC_MSG_NOTICE([xenlight: no])
+fi
 if test "$with_hal" = "yes" ; then
 AC_MSG_NOTICE([     hal: $HAL_CFLAGS $HAL_LIBS])
 else
diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h
index 5962dbf..867bbbd 100644
--- a/include/libvirt/virterror.h
+++ b/include/libvirt/virterror.h
@@ -79,6 +79,7 @@ typedef enum {
     VIR_FROM_SYSINFO = 37,	/* Error from sysinfo/SMBIOS */
     VIR_FROM_STREAMS = 38,	/* Error from I/O streams */
     VIR_FROM_VMWARE = 39,	/* Error from VMware driver */
+    VIR_FROM_XENLIGHT = 40,     /* Error from XenLight driver */
 } virErrorDomain;
 
 
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 5f2ed75..e99eaf9 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -117,6 +117,8 @@ src/xen/xm_internal.c
 src/xen/xs_internal.c
 src/xenapi/xenapi_driver.c
 src/xenapi/xenapi_utils.c
+src/xenlight/xl_driver.c
+src/xenlight/xl_utils.c
 tools/console.c
 tools/libvirt-guests.init.sh
 tools/virsh.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 2f94efd..99958b6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -295,6 +295,10 @@ XENAPI_DRIVER_SOURCES =								\
 		xenapi/xenapi_driver_private.h					\
 		xenapi/xenapi_utils.c xenapi/xenapi_utils.h
 
+XENLIGHT_DRIVER_SOURCES =					\
+		xenlight/xl_driver.c xenlight/xl_driver.h	\
+		xenlight/xl_utils.c xenlight/xl_utils.h
+
 UML_DRIVER_SOURCES =						\
 		uml/uml_conf.c uml/uml_conf.h			\
 		uml/uml_driver.c uml/uml_driver.h
@@ -675,6 +679,26 @@ endif
 libvirt_driver_xenapi_la_SOURCES = $(XENAPI_DRIVER_SOURCES)
 endif
 
+if WITH_XENLIGHT
+if WITH_DRIVER_MODULES
+mod_LTLIBRARIES += libvirt_driver_xenlight.la
+else
+noinst_LTLIBRARIES += libvirt_driver_xenlight.la
+libvirt_la_BUILT_LIBADD += libvirt_driver_xenlight.la
+endif
+libvirt_driver_xenlight_la_CFLAGS = $(XEN_CFLAGS) \
+		$(XENLIGHT_CFLAGS) \
+		-I top_srcdir@/src/conf $(AM_CFLAGS)
+libvirt_driver_xenlight_la_LDFLAGS = $(AM_LDFLAGS)
+libvirt_driver_xenlight_la_LIBADD = $(XEN_LIBS) \
+		$(XENLIGHT_LIBS)
+if WITH_DRIVER_MODULES
+libvirt_driver_xenlight_la_LIBADD += ../gnulib/lib/libgnu.la
+libvirt_driver_xenlight_la_LDFLAGS += -module -avoid-version
+endif
+libvirt_driver_xenlight_la_SOURCES = $(XENLIGHT_DRIVER_SOURCES)
+endif
+
 if WITH_QEMU
 if WITH_DRIVER_MODULES
 mod_LTLIBRARIES += libvirt_driver_qemu.la
@@ -974,6 +998,7 @@ EXTRA_DIST +=							\
 		$(PHYP_DRIVER_SOURCES)				\
 		$(VBOX_DRIVER_SOURCES)				\
 		$(XENAPI_DRIVER_SOURCES)			\
+		$(XENLIGHT_DRIVER_SOURCES)			\
 		$(ESX_DRIVER_SOURCES)				\
 		$(ESX_DRIVER_EXTRA_DIST)			\
 		$(NETWORK_DRIVER_SOURCES)			\
diff --git a/src/driver.h b/src/driver.h
index 7451004..66c632b 100644
--- a/src/driver.h
+++ b/src/driver.h
@@ -28,7 +28,8 @@ typedef enum {
     VIR_DRV_ESX = 10,
     VIR_DRV_PHYP = 11,
     VIR_DRV_XENAPI = 12,
-    VIR_DRV_VMWARE = 13
+    VIR_DRV_VMWARE = 13,
+    VIR_DRV_XENLIGHT = 14
 } virDrvNo;
 
 
diff --git a/src/libvirt.c b/src/libvirt.c
index 479a9b5..52d400f 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -69,6 +69,9 @@
 # ifdef WITH_XENAPI
 #  include "xenapi/xenapi_driver.h"
 # endif
+# ifdef WITH_XENLIGHT
+#  include "xenlight/xl_driver.h"
+# endif
 #endif
 
 #define VIR_FROM_THIS VIR_FROM_NONE
@@ -398,6 +401,9 @@ virInitialize(void)
 # ifdef WITH_XENAPI
     virDriverLoadModule("xenapi");
 # endif
+# ifdef WITH_XENLIGHT
+    virDriverLoadModule("xenlight");
+# endif
 # ifdef WITH_REMOTE
     virDriverLoadModule("remote");
 # endif
@@ -426,6 +432,9 @@ virInitialize(void)
 # ifdef WITH_XENAPI
     if (xenapiRegister() == -1) return -1;
 # endif
+# ifdef WITH_XENLIGHT
+    if (xlRegister() == -1) return -1;
+# endif
 # ifdef WITH_REMOTE
     if (remoteRegister () == -1) return -1;
 # endif
@@ -944,6 +953,10 @@ virGetVersion(unsigned long *libVer, const char *type,
         if (STRCASEEQ(type, "XenAPI"))
             *typeVer = LIBVIR_VERSION_NUMBER;
 # endif
+# if WITH_XENLIGHT
+        if (STRCASEEQ(type, "XenLight"))
+            *typeVer = LIBVIR_VERSION_NUMBER;
+# endif
 # if WITH_REMOTE
         if (STRCASEEQ(type, "Remote"))
             *typeVer = remoteVersion();
diff --git a/src/util/virterror.c b/src/util/virterror.c
index e45b582..1d3fca1 100644
--- a/src/util/virterror.c
+++ b/src/util/virterror.c
@@ -89,6 +89,9 @@ static const char *virErrorDomainName(virErrorDomain domain) {
         case VIR_FROM_XENAPI:
             dom = "XenAPI ";
             break;
+        case VIR_FROM_XENLIGHT:
+            dom = "XenLight ";
+            break;
         case VIR_FROM_XML:
             dom = "XML ";
             break;
diff --git a/tools/virsh.c b/tools/virsh.c
index be2cd67..9d62afb 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -12072,6 +12072,9 @@ vshShowVersion(vshControl *ctl ATTRIBUTE_UNUSED)
 #ifdef WITH_XENAPI
     vshPrint(ctl, " XenAPI");
 #endif
+#ifdef WITH_XENLIGHT
+    vshPrint(ctl, " XenLight");
+#endif
 #ifdef WITH_LXC
     vshPrint(ctl, " LXC");
 #endif

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