Skip to contentSkip to conversation

libxenlight driver

PATCH In review Jim Fehlig 2 participants 2 messages Feb 14, 2011

lore
Share & tools
lore

Jim Fehlig

author
#0 lore raw

PATCH 1/1 libxenlight driver

Hi All,

Here's a first cut of libxenlight driver for libvirt. The driver is stateful and provides functionality for managed (persistent) domains. The driver only maintains state for and manages domains under its control, ignoring domains created by other libxenlight clients, e.g. xl.

As you can see, a fair number of the driver functions are implemented, at least what I think constitutes a minimal set for upstream inclusion. Are there any required functions missing?

I'm still looking into a problem with failure to restart a domain, persistent or otherwise. E.g. virsh start|create domU; virsh shutdown domU; virsh start|create domU. The second start/create fails in libxenlight, but I've not yet tracked down the cause. Also, I've not yet handled restart of libvirtd if domains are running - not sure if this is a requirement for initial inclusion.

TIA for your review and comment.

Regards,
Jim

Quoted 1 line

From d6802cee0c50e9d9d58345ecf94a3f3e2933d190 Mon Sep 17 00:00:00 2001

From: Jim Fehlig <[email protected]>
Date: Thu, 10 Feb 2011 15:42:34 -0700
Subject: [PATCH] Add libxenlight driver

Add a new xen driver based on libxenlight [1], which is the primary toolstack starting with Xen 4.1.0. The driver is stateful, runs privileged only, and is accessed with libxl:/// URI.

[1] http://lists.xensource.com/archives/html/xen-devel/2009-11/msg00436.html

---
 cfg.mk                      |    1 +
 configure.ac                |   48 ++
 daemon/Makefile.am          |    4 +
 daemon/libvirtd.c           |    6 +
 docs/drivers.html.in        |    3 +-
 docs/drvxen.html.in         |    6 +-
 docs/drvxenlight.html.in    |   53 ++
 docs/sitemap.html.in        |    6 +-
 include/libvirt/virterror.h |    1 +
 po/POTFILES.in              |    2 +
 src/Makefile.am             |   32 ++
 src/driver.h                |    3 +-
 src/libvirt.c               |    4 +
 src/libxl/libxl_conf.c      |  783 ++++++++++++++++++++++++++
 src/libxl/libxl_conf.h      |   85 +++
 src/libxl/libxl_driver.c    | 1280 +++++++++++++++++++++++++++++++++++++++++++
 src/libxl/libxl_driver.h    |   27 +
 src/util/virterror.c        |    3 +
 18 files changed, 2343 insertions(+), 4 deletions(-)
cfg.mk +1 -0
index 4bbeb96..6ec11b4 100644
@@ -400,6 +400,7 @@ msg_gen_function += virXenStoreError
 msg_gen_function += virXendError
 msg_gen_function += vmwareError
 msg_gen_function += xenapiSessionErrorHandler
+msg_gen_function += libxlError
 msg_gen_function += xenUnifiedError
 msg_gen_function += xenXMError
 msg_gen_function += VIR_ERROR
configure.ac +48 -0

72 lines not on this page · raw message

daemon/Makefile.am +4 -0
index cdf0f75..c732827 100644
@@ -111,6 +111,10 @@ if WITH_LXC
     libvirtd_LDADD += ../src/libvirt_driver_lxc.la
 endif
 
+if WITH_LIBXL
+    libvirtd_LDADD += ../src/libvirt_driver_libxl.la
+endif
+
 if WITH_UML
     libvirtd_LDADD += ../src/libvirt_driver_uml.la
 endif
daemon/libvirtd.c +6 -0
index f4b3327..962f1fa 100644
@@ -80,6 +80,9 @@
 # ifdef WITH_LXC
 #  include "lxc/lxc_driver.h"
 # endif
+# ifdef WITH_LIBXL
+#  include "libxl/libxl_driver.h"
+# endif
 # ifdef WITH_UML
 #  include "uml/uml_driver.h"
 # endif
@@ -928,6 +931,9 @@ static struct qemud_server *qemudInitialize(void) {
 # ifdef WITH_LXC
     lxcRegister();
 # endif
+# ifdef WITH_LIBXL
+    libxlRegister();
+# endif
 # ifdef WITH_UML
     umlRegister();
 # endif
docs/drivers.html.in +2 -1
index ecad03a..368664e 100644
@@ -28,7 +28,8 @@
       <li><strong><a href="drvvbox.html">VirtualBox</a></strong></li>
       <li><strong><a href="drvesx.html">VMware ESX</a></strong></li>
       <li><strong><a href="drvvmware.html">VMware Workstation/Player</a></strong></li>
-      <li><strong><a href="drvxen.html">Xen</a></strong></li>
+      <li><strong><a href="drvxen.html">Xen 3.0.1 - 4.0.x</a></strong></li>
+      <li><strong><a href="drvxenlight.html">Xen 4.1.0 onwards</a></strong></li>
     </ul>
 
     <h2><a name="stroage">Storage drivers</a></h2>
docs/drvxen.html.in +5 -1
index 4e35afa..4b88a7d 100644
@@ -6,7 +6,11 @@
 
     <p>
       The libvirt Xen driver provides the ability to manage virtual machines
-      on any Xen release from 3.0.1 onwards.
+      on any Xen release from 3.0.1 to 4.0.x.  Starting with Xen 4.1.0,
+      the traditional xm/xend toolstack is replaced with a new toolstack
+      based on libxenlight.  Consult the
+      <a href="drvxenlight.html">libxenlight driver</a> if your Xen host is 
+      configured to use the new toolstack.
     </p>
 
     <h2><a name="prereq">Deployment pre-requisites</a></h2>
docs/drvxenlight.html.in new file +53 -0

53 lines not on this page · raw message

docs/sitemap.html.in +5 -1
index ac0af71..538f227 100644
@@ -156,7 +156,11 @@
             <ul>
               <li>
                 <a href="drvxen.html">Xen</a>
-                <span>Driver the Xen hypervisor</span>
+                <span>Driver the Xen hypervisor, versions 3.0.1 - 4.0.x</span>
+              </li>
+              <li>
+                <a href="drvxenlight.html">libxenlight</a>
+                <span>Driver the Xen hypervisor, version 4.1.0 onwards</span>
               </li>
               <li>
                 <a href="drvqemu.html">QEMU / KVM</a>
include/libvirt/virterror.h +1 -0
index 5962dbf..9f263d2 100644
@@ -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_LIBXL = 40,	/* Error from libxenlight driver */
 } virErrorDomain;
 
 
po/POTFILES.in +2 -0
index 5f2ed75..ba3606a 100644
@@ -34,6 +34,8 @@ src/lxc/lxc_conf.c
 src/lxc/lxc_controller.c
 src/lxc/lxc_driver.c
 src/lxc/veth.c
+src/libxl/libxl_driver.c
+src/libxl/libxl_conf.c
 src/network/bridge_driver.c
 src/node_device/node_device_driver.c
 src/node_device/node_device_hal.c
src/Makefile.am +32 -0
index 2f94efd..834600a 100644
@@ -295,6 +295,10 @@ XENAPI_DRIVER_SOURCES =								\
 		xenapi/xenapi_driver_private.h					\
 		xenapi/xenapi_utils.c xenapi/xenapi_utils.h
 
+LIBXL_DRIVER_SOURCES =						\
+		libxl/libxl_conf.c libxl/libxl_conf.h		\
+		libxl/libxl_driver.c libxl/libxl_driver.h
+
 UML_DRIVER_SOURCES =						\
 		uml/uml_conf.c uml/uml_conf.h			\
 		uml/uml_driver.c uml/uml_driver.h
@@ -675,6 +679,25 @@ endif
 libvirt_driver_xenapi_la_SOURCES = $(XENAPI_DRIVER_SOURCES)
 endif
 
+if WITH_LIBXL
+if WITH_DRIVER_MODULES
+mod_LTLIBRARIES += libvirt_driver_libxl.la
+else
+noinst_LTLIBRARIES += libvirt_driver_libxl.la
+# Stateful, so linked to daemon instead
+#libvirt_la_BUILT_LIBADD += libvirt_driver_libxl.la
+endif
+libvirt_driver_libxl_la_CFLAGS = $(LIBXL_CFLAGS) \
+		-I@top_srcdir@/src/conf $(AM_CFLAGS)
+libvirt_driver_libxl_la_LDFLAGS = $(AM_LDFLAGS)
+libvirt_driver_libxl_la_LIBADD = $(LIBXL_LIBS)
+if WITH_DRIVER_MODULES
+libvirt_driver_libxl_la_LIBADD += ../gnulib/lib/libgnu.la
+libvirt_driver_libxl_la_LDFLAGS += -module -avoid-version
+endif
+libvirt_driver_libxl_la_SOURCES = $(LIBXL_DRIVER_SOURCES)
+endif
+
 if WITH_QEMU
 if WITH_DRIVER_MODULES
 mod_LTLIBRARIES += libvirt_driver_qemu.la
@@ -974,6 +997,7 @@ EXTRA_DIST +=							\
 		$(PHYP_DRIVER_SOURCES)				\
 		$(VBOX_DRIVER_SOURCES)				\
 		$(XENAPI_DRIVER_SOURCES)			\
+		$(LIBXL_DRIVER_SOURCES)			\
 		$(ESX_DRIVER_SOURCES)				\
 		$(ESX_DRIVER_EXTRA_DIST)			\
 		$(NETWORK_DRIVER_SOURCES)			\
@@ -1226,6 +1250,10 @@ if WITH_LXC
 	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/lib/libvirt/lxc"
 	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/run/libvirt/lxc"
 endif
+if WITH_LIBXL
+	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/lib/libvirt/libxl"
+	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/run/libvirt/libxl"
+endif
 if WITH_UML
 	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/lib/libvirt/uml"
 	$(MKDIR_P) "$(DESTDIR)$(localstatedir)/run/libvirt/uml"
@@ -1263,6 +1291,10 @@ if WITH_LXC
 	rmdir "$(DESTDIR)$(localstatedir)/lib/libvirt/lxc" ||:
 	rmdir "$(DESTDIR)$(localstatedir)/run/libvirt/lxc" ||:
 endif
+if WITH_LIBXL
+	rmdir "$(DESTDIR)$(localstatedir)/lib/libvirt/libxl" ||:
+	rmdir "$(DESTDIR)$(localstatedir)/run/libvirt/libxl" ||:
+endif
 if WITH_UML
 	rmdir "$(DESTDIR)$(localstatedir)/lib/libvirt/uml" ||:
 	rmdir "$(DESTDIR)$(localstatedir)/run/libvirt/uml" ||:
src/driver.h +2 -1
index 7451004..b2d9814 100644
@@ -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_LIBXL = 14,
 } virDrvNo;
 
 
src/libvirt.c +4 -0
index 479a9b5..f4b4602 100644
@@ -912,6 +912,10 @@ virGetVersion(unsigned long *libVer, const char *type,
         if (STRCASEEQ(type, "LXC"))
             *typeVer = LIBVIR_VERSION_NUMBER;
 # endif
+# if WITH_LIBXL
+        if (STRCASEEQ(type, "libxl"))
+            *typeVer = LIBVIR_VERSION_NUMBER;
+# endif
 # if WITH_PHYP
         if (STRCASEEQ(type, "phyp"))
             *typeVer = LIBVIR_VERSION_NUMBER;
src/libxl/libxl_conf.c new file +783 -0

783 lines not on this page · raw message

src/libxl/libxl_conf.h new file +85 -0

85 lines not on this page · raw message

src/libxl/libxl_driver.c new file +1280 -0

1,280 lines not on this page · raw message

src/libxl/libxl_driver.h new file +27 -0
new file mode 100644
index 0000000..e047552
@@ -0,0 +1,27 @@
+/*---------------------------------------------------------------------------*/
+/*  Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ */
+/*---------------------------------------------------------------------------*/
+
+#ifndef LIBXL_DRIVER_H
+# define LIBXL_DRIVER_H
+
+# include <config.h>
+
+int libxlRegister(void);
+
+#endif /* LIBXL_DRIVER_H */
src/util/virterror.c +3 -0
index e45b582..c763d92 100644
@@ -89,6 +89,9 @@ static const char *virErrorDomainName(virErrorDomain domain) {
         case VIR_FROM_XENAPI:
             dom = "XenAPI ";
             break;
+        case VIR_FROM_LIBXL:
+            dom = "libxenlight ";
+            break;
         case VIR_FROM_XML:
             dom = "XML ";
             break;
Signature · 1 line
1.7.3.1

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw
Quoted 20 lines · Jim Fehlig

Hi All,

Here's a first cut of libxenlight driver for libvirt. The driver is stateful and provides functionality for managed (persistent) domains. The driver only maintains state for and manages domains under its control, ignoring domains created by other libxenlight clients, e.g. xl.

As you can see, a fair number of the driver functions are implemented, at least what I think constitutes a minimal set for upstream inclusion. Are there any required functions missing?

I'm still looking into a problem with failure to restart a domain, persistent or otherwise. E.g. virsh start|create domU; virsh shutdown domU; virsh start|create domU. The second start/create fails in libxenlight, but I've not yet tracked down the cause. Also, I've not yet handled restart of libvirtd if domains are running - not sure if this is a requirement for initial inclusion.

TIA for your review and comment.

Quoted 8 lines

Regards,
Jim

Add a new xen driver based on libxenlight [1], which is the primary toolstack starting with Xen 4.1.0. The driver is stateful, runs privileged only, and is accessed with libxl:/// URI.

---8<---

Quoted 37 lines
src/libxl/libxl_conf.c new file +37 -0
+static int
+libxlMakeDiskList(virDomainDefPtr def, libxl_domain_config *d_config)
+{
+    virDomainDiskDefPtr *l_disks = def->disks;
+    int ndisks = def->ndisks;
+    libxl_device_disk *x_disks;
+    int i;
+
+    if (VIR_ALLOC_N(x_disks, ndisks) < 0) {
+        virReportOOMError();
+        return -1;
+    }
+
+    for (i = 0; i < ndisks; i++) {
+        if (l_disks[i]->src &&
+             (x_disks[i].physpath = strdup(l_disks[i]->src)) == NULL) {
+            virReportOOMError();
+            goto error;
+        }
+
+        if (l_disks[i]->dst &&
+            (x_disks[i].virtpath = strdup(l_disks[i]->dst)) == NULL) {
+            virReportOOMError();
+            goto error;
+        }
+
+        if (l_disks[i]->driverName) {
+            if (STREQ(l_disks[i]->driverName, "tap") ||
+                STREQ(l_disks[i]->driverName, "tap2")) {
+                if (l_disks[i]->driverType &&
+                    STREQ(l_disks[i]->driverType, "qcow2"))
+                    x_disks[i].phystype = PHYSTYPE_QCOW2;
+                else if (l_disks[i]->driverType &&
+                         STREQ(l_disks[i]->driverType, "aio"))
+                    x_disks[i].phystype = PHYSTYPE_AIO;
+                else if (l_disks[i]->driverType &&
+                         STREQ(l_disks[i]->driverType, "vhd"))

src/libxl/libxl_conf.c line 429

Quoted 10 lines
src/libxl/libxl_conf.c new file +10 -0
+                    x_disks[i].phystype = PHYSTYPE_VHD;
+            } else if (STREQ(l_disks[i]->driverName, "file")) {
+                x_disks[i].phystype = PHYSTYPE_FILE;
+            } else if (STREQ(l_disks[i]->driverName, "phy")) {
+                x_disks[i].phystype = PHYSTYPE_PHY;
+            }
+        } else {
+            /* Default to file?? */
+            x_disks[i].phystype = PHYSTYPE_FILE;
+        }

Just an heads up on disk parsing: we are about to change the disk API, before the xen 4.1 release. That's because we realized that the current API entangles the disk backend and the disk format together; so we are going to separate them, using two separate fields: backend and format. An change in the xl disk config parser will also follow, that should help you make the corresponding changes to this function.

Everything else on the libxenlight side looks good!