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

Re: [libvirt] PATCH: 6/12: Optional dlopen() support



This patch is a small incremental change to optionally allow us to build
every driver as a dlopen()able module. This is disabled by default for
now. I'm not sure whether this is hugely usefl or not, but it was easy
enough to do, so here's the patch.

Daniel

diff -r ecc8ae6295bc configure.in
--- a/configure.in	Wed Nov 12 21:59:22 2008 +0000
+++ b/configure.in	Thu Nov 13 17:13:02 2008 +0000
@@ -1059,6 +1059,38 @@
 AC_CHECK_TOOL([WINDRES], [windres], [no])
 AM_CONDITIONAL([WITH_WIN_ICON], [test "$WINDRES" != "no"])
 
+
+
+dnl Driver-Modules library
+AC_ARG_WITH([driver-modules],
+  [  --with-driver-modules       build drivers as loadable modules],
+  [],
+  [with_driver_modules=no])
+
+DRIVER_MODULES_CFLAGS=
+DRIVER_MODULES_LIBS=
+if test "x$with_driver_modules" = "xyes" ; then
+  old_cflags="$CFLAGS"
+  old_libs="$LIBS"
+  fail=0
+  AC_CHECK_HEADER([dlfcn.h],[],[fail=1])
+  AC_CHECK_LIB([dl], [dlopen],[],[fail=1])
+  test $fail = 1 &&
+      AC_MSG_ERROR([You must have dlfcn.h / dlopen() support to build driver modules])
+
+  CFLAGS="$old_cflags"
+  LIBS="$old_libs"
+fi
+if test "$with_driver_modules" = "yes"; then
+  DRIVER_MODULES_CFLAGS="-export-dynamic"
+  DRIVER_MODULES_LIBS="-ldl"
+  AC_DEFINE_UNQUOTED([WITH_DRIVER_MODULES], 1, [whether to build drivers as modules])
+fi
+AM_CONDITIONAL([WITH_DRIVER_MODULES], [test "$with_driver_modules" != "no"])
+AC_SUBST([DRIVER_MODULES_CFLAGS])
+AC_SUBST([DRIVER_MODULES_LIBS])
+
+
 # Set LV_LIBTOOL_OBJDIR to "." or $lt_cv_objdir, depending on whether
 # we're building shared libraries.  This is the name of the directory
 # in which .o files will be created.
@@ -1114,6 +1146,14 @@
 AC_MSG_NOTICE([   iSCSI: $with_storage_iscsi])
 AC_MSG_NOTICE([    Disk: $with_storage_disk])
 AC_MSG_NOTICE([])
+AC_MSG_NOTICE([Driver Loadable Modules])
+AC_MSG_NOTICE([])
+if test "$with_driver_modules" != "no" ; then
+AC_MSG_NOTICE([  dlopen: $DRIVER_MODULES_CFLAGS $DRIVER_MODULES_LIBS])
+else
+AC_MSG_NOTICE([  dlopen: no])
+fi
+AC_MSG_NOTICE([])
 AC_MSG_NOTICE([Libraries])
 AC_MSG_NOTICE([])
 AC_MSG_NOTICE([  libxml: $LIBXML_CFLAGS $LIBXML_LIBS])
diff -r ecc8ae6295bc qemud/Makefile.am
--- a/qemud/Makefile.am	Wed Nov 12 21:59:22 2008 +0000
+++ b/qemud/Makefile.am	Thu Nov 13 17:13:02 2008 +0000
@@ -92,6 +92,7 @@
 		../gnulib/lib/libgnu.la			\
 		../src/libvirt.la
 
+if ! WITH_DRIVER_MODULES
 if WITH_QEMU
 libvirtd_LDADD += ../src/libvirt_driver_qemu.la
 endif
@@ -106,6 +107,7 @@
 
 if WITH_NETWORK
 libvirtd_LDADD += ../src/libvirt_driver_network.la
+endif
 endif
 
 if HAVE_POLKIT
diff -r ecc8ae6295bc qemud/qemud.c
--- a/qemud/qemud.c	Wed Nov 12 21:59:22 2008 +0000
+++ b/qemud/qemud.c	Thu Nov 13 17:13:02 2008 +0000
@@ -61,6 +61,9 @@
 #include "mdns.h"
 #endif
 
+#ifdef WITH_DRIVER_MODULES
+#include "driver.h"
+#else
 #ifdef WITH_QEMU
 #include "qemu_driver.h"
 #endif
@@ -72,6 +75,7 @@
 #endif
 #ifdef WITH_STORAGE_DIR
 #include "storage_driver.h"
+#endif
 #endif
 
 
@@ -744,8 +748,19 @@
 
     virInitialize();
 
+#ifdef WITH_DRIVER_MODULES
+    /* We don't care if any of these fail, because the whole point
+     * is to allow users to only install modules they want to use.
+     * If they try to use a open a connection for a module that
+     * is not loaded they'll get a suitable error at that point
+     */
+    virDriverLoadModule("qemu");
+    virDriverLoadModule("lxc");
+    virDriverLoadModule("network");
+    virDriverLoadModule("storage");
+#else
 #ifdef WITH_QEMU
-    qemudRegister();
+    qemuRegister();
 #endif
 #ifdef WITH_LXC
     lxcRegister();
@@ -755,6 +770,7 @@
 #endif
 #ifdef WITH_STORAGE_DIR
     storageRegister();
+#endif
 #endif
 
     virEventRegisterImpl(virEventAddHandleImpl,
diff -r ecc8ae6295bc src/Makefile.am
--- a/src/Makefile.am	Wed Nov 12 21:59:22 2008 +0000
+++ b/src/Makefile.am	Thu Nov 13 17:13:02 2008 +0000
@@ -6,7 +6,10 @@
 	   -I top_srcdir@/include \
 	   -I top_srcdir@/qemud \
 	   $(LIBXML_CFLAGS) \
+	   $(XEN_CFLAGS) \
 	   $(SELINUX_CFLAGS) \
+	   $(DRIVER_MODULE_CFLAGS) \
+	   -DLIBDIR=\""$(libdir)"\" \
 	   -DBINDIR=\""$(libexecdir)"\" \
 	   -DSBINDIR=\""$(sbindir)"\" \
 	   -DSYSCONF_DIR="\"$(sysconfdir)\"" \
@@ -30,6 +33,10 @@
 
 lib_LTLIBRARIES = libvirt.la
 
+moddir = $(libdir)/libvirt/drivers
+mod_LTLIBRARIES =
+
+
 # These files are not related to driver APIs. Simply generic
 # helper APIs for various purposes
 UTIL_SOURCES =							\
@@ -49,7 +56,7 @@
 
 # Internal generic driver infrastructure
 DRIVER_SOURCES = 						\
-		driver.h					\
+		driver.c driver.h				\
 		internal.h					\
 		datatypes.c datatypes.h				\
 		domain_event.c domain_event.h			\
@@ -163,67 +170,120 @@
 		$(STORAGE_CONF_SOURCES)
 
 if WITH_TEST
+if WITH_DRIVER_MODULES
+mod_LTLIBRARIES += libvirt_driver_test.la
+else
 noinst_LTLIBRARIES += libvirt_driver_test.la
 libvirt_la_LIBADD += libvirt_driver_test.la
+endif
 libvirt_driver_test_la_SOURCES = $(TEST_DRIVER_SOURCES)
 endif
 
 if WITH_REMOTE
+if WITH_DRIVER_MODULES
+mod_LTLIBRARIES += libvirt_driver_remote.la
+else
 noinst_LTLIBRARIES += libvirt_driver_remote.la
 libvirt_la_LIBADD += libvirt_driver_remote.la
+endif
 libvirt_driver_remote_la_CFLAGS =				\
 		$(GNUTLS_CFLAGS)				\
 		$(SASL_CFLAGS)
 libvirt_driver_remote_la_LDFLAGS =				\
 		$(GNUTLS_LIBS)					\
 		$(SASL_LIBS)
+if WITH_DRIVER_MODULES
+libvirt_driver_remote_la_LDFLAGS += -module -avoid-version
+endif
 libvirt_driver_remote_la_SOURCES = $(REMOTE_DRIVER_SOURCES)
 endif
 
 if WITH_XEN
+if WITH_DRIVER_MODULES
+mod_LTLIBRARIES += libvirt_driver_xen.la
+else
 noinst_LTLIBRARIES += libvirt_driver_xen.la
 libvirt_la_LIBADD += libvirt_driver_xen.la
+endif
 libvirt_driver_xen_la_CFLAGS = $(XEN_CFLAGS)
 libvirt_driver_xen_la_LDFLAGS = $(XEN_LIBS)
+if WITH_DRIVER_MODULES
+libvirt_driver_xen_la_LDFLAGS += -module -avoid-version
+endif
 libvirt_driver_xen_la_SOURCES = $(XEN_DRIVER_SOURCES)
 endif
 
 if WITH_OPENVZ
+if WITH_DRIVER_MODULES
+mod_LTLIBRARIES += libvirt_driver_openvz.la
+else
 noinst_LTLIBRARIES += libvirt_driver_openvz.la
 libvirt_la_LIBADD += libvirt_driver_openvz.la
+endif
+if WITH_DRIVER_MODULES
+libvirt_driver_openvz_la_LDFLAGS = -module -avoid-version
+endif
 libvirt_driver_openvz_la_SOURCES = $(OPENVZ_DRIVER_SOURCES)
 endif
 
 if WITH_QEMU
+if WITH_DRIVER_MODULES
+mod_LTLIBRARIES += libvirt_driver_qemu.la
+else
 noinst_LTLIBRARIES += libvirt_driver_qemu.la
 # Stateful, so linked to daemon instead
 #libvirt_la_LIBADD += libvirt_driver_qemu.la
+endif
 libvirt_driver_qemu_la_CFLAGS = $(NUMACTL_CFLAGS)
 libvirt_driver_qemu_la_LDFLAGS = $(NUMACTL_LIBS)
+if WITH_DRIVER_MODULES
+libvirt_driver_qemu_la_LDFLAGS += -module -avoid-version
+endif
 libvirt_driver_qemu_la_SOURCES = $(QEMU_DRIVER_SOURCES)
 endif
 
 if WITH_LXC
+if WITH_DRIVER_MODULES
+mod_LTLIBRARIES += libvirt_driver_lxc.la
+else
 noinst_LTLIBRARIES += libvirt_driver_lxc.la
 # Stateful, so linked to daemon instead
 #libvirt_la_LIBADD += libvirt_driver_lxc.la
+endif
+if WITH_DRIVER_MODULES
+libvirt_driver_lxc_la_LDFLAGS = -module -avoid-version
+endif
 libvirt_driver_lxc_la_SOURCES = $(LXC_DRIVER_SOURCES)
 endif
 
 
 if WITH_NETWORK
+if WITH_DRIVER_MODULES
+mod_LTLIBRARIES += libvirt_driver_network.la
+else
 noinst_LTLIBRARIES += libvirt_driver_network.la
 # Stateful, so linked to daemon instead
 #libvirt_la_LIBADD += libvirt_driver_network.la
+endif
+if WITH_DRIVER_MODULES
+libvirt_driver_network_la_LDFLAGS = -module -avoid-version
+endif
 libvirt_driver_network_la_SOURCES = $(NETWORK_DRIVER_SOURCES)
 endif
 
 # Needed to keep automake quiet about conditionals
 libvirt_driver_storage_la_SOURCES =
 if WITH_STORAGE_DIR
+if WITH_DRIVER_MODULES
+mod_LTLIBRARIES += libvirt_driver_storage.la
+else
 noinst_LTLIBRARIES += libvirt_driver_storage.la
 # Stateful, so linked to daemon instead
 #libvirt_la_LIBADD += libvirt_driver_storage.la
+endif
+if WITH_DRIVER_MODULES
+libvirt_driver_storage_la_LDFLAGS = -module -avoid-version
+endif
 libvirt_driver_storage_la_SOURCES += $(STORAGE_DRIVER_SOURCES)
 libvirt_driver_storage_la_SOURCES += $(STORAGE_DRIVER_FS_SOURCES)
 endif
@@ -258,7 +318,8 @@
 
 # Empty source list - it merely links a bunch of convenience libs together
 libvirt_la_SOURCES =
-libvirt_la_LIBADD += $(LIBXML_LIBS) $(SELINUX_LIBS) \
+libvirt_la_LIBADD += $(LIBXML_LIBS) $(XEN_LIBS) $(SELINUX_LIBS) \
+		    $(DRIVER_MODULE_LIBS) \
 		    @CYGWIN_EXTRA_LIBADD@ ../gnulib/lib/libgnu.la
 libvirt_la_LDFLAGS = -Wl,--version-script=$(srcdir)/libvirt_sym.version \
                      -version-info @LIBVIRT_VERSION_INFO@ \
diff -r ecc8ae6295bc src/driver.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/driver.c	Thu Nov 13 17:13:02 2008 +0000
@@ -0,0 +1,97 @@
+/*
+ * driver.c: Helpers for loading drivers
+ *
+ * Copyright (C) 2006-2008 Red Hat, Inc.
+ *
+ * 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
+ *
+ */
+
+
+#include <config.h>
+
+#include <unistd.h>
+
+#include "driver.h"
+#include "memory.h"
+#include "logging.h"
+
+#define DEFAULT_DRIVER_DIR LIBDIR "/libvirt/drivers"
+
+#ifdef WITH_DRIVER_MODULES
+
+/* XXX re-implment this for other OS, or use libtools helper lib ? */
+
+#include <dlfcn.h>
+
+void *
+virDriverLoadModule(const char *name)
+{
+    const char *moddir = getenv("LIBVIRT_DRIVER_DIR");
+    char *modfile = NULL, *regfunc = NULL;
+    void *handle = NULL;
+    int (*regsym)(void);
+
+    if (moddir == NULL)
+        moddir = DEFAULT_DRIVER_DIR;
+
+    DEBUG("Module load %s", name);
+
+    if (asprintf(&modfile, "%s/libvirt_driver_%s.so", moddir, name) < 0)
+        return NULL;
+
+    if (access(modfile, R_OK) < 0) {
+        DEBUG("Moodule %s not accessible", modfile);
+        goto cleanup;
+    }
+
+    handle = dlopen(modfile, RTLD_NOW | RTLD_LOCAL);
+    if (!handle) {
+        DEBUG("failed to load module %s %s", modfile, dlerror());
+        goto cleanup;
+    }
+
+    if (asprintf(&regfunc, "%sRegister", name) < 0) {
+        regfunc = NULL;
+        goto cleanup;
+    }
+
+    regsym = dlsym(handle, regfunc);
+    if (!regsym) {
+        DEBUG("Missing module registration symbol %s", regfunc);
+        goto cleanup;
+    }
+
+    if ((*regsym)() < 0) {
+        DEBUG("Failed module registration %s", regfunc);
+        goto cleanup;
+    }
+
+    VIR_FREE(modfile);
+    VIR_FREE(regfunc);
+    return handle;
+
+cleanup:
+    VIR_FREE(modfile);
+    VIR_FREE(regfunc);
+    if (handle)
+        dlclose(handle);
+    return NULL;
+}
+
+
+/* XXX unload modules, but we can't until we can unregister libvirt drivers */
+
+#endif
diff -r ecc8ae6295bc src/driver.h
--- a/src/driver.h	Wed Nov 12 21:59:22 2008 +0000
+++ b/src/driver.h	Thu Nov 13 17:13:02 2008 +0000
@@ -8,6 +8,7 @@
 
 #include <libxml/uri.h>
 
+#include "internal.h"
 /*
  * List of registered drivers numbers
  */
@@ -614,5 +615,6 @@
 #ifdef WITH_LIBVIRTD
 int virRegisterStateDriver(virStateDriverPtr);
 #endif
+void *virDriverLoadModule(const char *name);
 
 #endif /* __VIR_DRIVER_H__ */
diff -r ecc8ae6295bc src/libvirt.c
--- a/src/libvirt.c	Wed Nov 12 21:59:22 2008 +0000
+++ b/src/libvirt.c	Thu Nov 13 17:13:02 2008 +0000
@@ -41,6 +41,7 @@
 #include "util.h"
 #include "memory.h"
 
+#ifndef WITH_DRIVER_MODULES
 #ifdef WITH_TEST
 #include "test.h"
 #endif
@@ -52,6 +53,7 @@
 #endif
 #ifdef WITH_OPENVZ
 #include "openvz_driver.h"
+#endif
 #endif
 
 /*
@@ -270,11 +272,22 @@
      * Note that the order is important: the first ones have a higher
      * priority when calling virConnectOpen.
      */
+#ifdef WITH_DRIVER_MODULES
+    /* We don't care if any of these fail, because the whole point
+     * is to allow users to only install modules they want to use.
+     * If they try to use a open a connection for a module that
+     * is not loaded they'll get a suitable error at that point
+     */
+    virDriverLoadModule("test");
+    virDriverLoadModule("xen");
+    virDriverLoadModule("openvz");
+    virDriverLoadModule("remote");
+#else
 #ifdef WITH_TEST
     if (testRegister() == -1) return -1;
 #endif
 #ifdef WITH_XEN
-    if (xenUnifiedRegister () == -1) return -1;
+    if (xenRegister () == -1) return -1;
 #endif
 #ifdef WITH_OPENVZ
     if (openvzRegister() == -1) return -1;
@@ -282,6 +295,7 @@
 #ifdef WITH_REMOTE
     if (remoteRegister () == -1) return -1;
 #endif
+#endif
 
     return(0);
 }
@@ -458,6 +472,9 @@
         return(-1);
     }
 
+    DEBUG ("registering %s as network driver %d",
+           driver->name, virNetworkDriverTabCount);
+
     virNetworkDriverTab[virNetworkDriverTabCount] = driver;
     return virNetworkDriverTabCount++;
 }
@@ -485,6 +502,9 @@
         virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
         return(-1);
     }
+
+    DEBUG ("registering %s as storage driver %d",
+           driver->name, virStorageDriverTabCount);
 
     virStorageDriverTab[virStorageDriverTabCount] = driver;
     return virStorageDriverTabCount++;
diff -r ecc8ae6295bc src/libvirt_sym.version.in
--- a/src/libvirt_sym.version.in	Wed Nov 12 21:59:22 2008 +0000
+++ b/src/libvirt_sym.version.in	Thu Nov 13 17:13:02 2008 +0000
@@ -283,8 +283,12 @@
 	virCapabilitiesAddGuest;
 	virCapabilitiesAddGuestDomain;
 	virCapabilitiesAddGuestFeature;
+	virCapabilitiesAddHostMigrateTransport;
 	virCapabilitiesAddHostNUMACell;
+	virCapabilitiesAddHostFeature;
+	virCapabilitiesDefaultGuestArch;
 	virCapabilitiesDefaultGuestEmulator;
+	virCapabilitiesDefaultGuestMachine;
 	virCapabilitiesFormatXML;
 	virCapabilitiesFree;
 	virCapabilitiesNew;
@@ -296,6 +300,7 @@
 	virConfReadFile;
 	virConfReadMem;
 	virConfFree;
+	virConfFreeValue;
 	virConfGetValue;
 	virConfSetValue;
 	virConfWriteFile;
@@ -307,6 +312,7 @@
 	virGetNetwork;
 	virGetStoragePool;
 	virGetStorageVol;
+	virUnrefDomain;
 
 
 	/* domain_conf.h */
@@ -314,14 +320,22 @@
 	virDiskNameToIndex;
 	virDomainAssignDef;
 	virDomainConfigFile;
+	virDomainCpuSetFormat;
+	virDomainCpuSetParse;
+	virDomainChrDefFree;
+	virDomainChrTypeFromString;
+	virDomainChrTypeToString;
 	virDomainDefDefaultEmulator;
 	virDomainDefFormat;
 	virDomainDefFree;
 	virDomainDefParseFile;
+	virDomainDefParseNode;
 	virDomainDefParseString;
 	virDomainDeleteConfig;
+	virDomainDeviceDefFree;
 	virDomainDeviceDefParse;
 	virDomainDiskBusTypeToString;
+	virDomainDiskDefFree;
 	virDomainDiskDeviceTypeToString;
 	virDomainDiskQSort;
 	virDomainEventCallbackListAdd;
@@ -330,12 +344,53 @@
 	virDomainFindByID;
 	virDomainFindByName;
 	virDomainFindByUUID;
+	virDomainGraphicsTypeFromString;
+	virDomainGraphicsDefFree;
+	virDomainInputDefFree;
+	virDomainLifecycleTypeFromString;
+	virDomainLifecycleTypeToString;
 	virDomainLoadAllConfigs;
+	virDomainNetDefFree;
+	virDomainObjFree;
 	virDomainObjListFree;
 	virDomainRemoveInactive;
 	virDomainSaveConfig;
+	virDomainSoundDefFree;
+	virDomainSoundModelTypeFromString;
 	virDomainSoundModelTypeToString;
 	virDomainVirtTypeToString;
+	virDomainFSDefFree;
+
+
+	/* domain_event.h */
+	virDomainEventQueueFree;
+	virDomainEventCallbackQueuePop;
+	virDomainEventCallbackQueuePush;
+
+
+	/* driver.h */
+	virDriverLoadModule;
+
+
+	/* event.h */
+	virEventAddHandle;
+	virEventAddTimeout;
+	virEventRemoveHandle;
+	virEventRemoveTimeout;
+	virEventUpdateHandle;
+	virEventUpdateTimeout;
+
+
+	/* hash.h */
+	virHashAddEntry;
+	virHashCreate;
+	virHashForEach;
+	virHashFree;
+	virHashLookup;
+	virHashRemoveEntry;
+	virHashRemoveSet;
+	virHashSearch;
+	virHashSize;
 
 
 	/* iptables.h */
@@ -391,12 +446,15 @@
 	virNetworkAssignDef;
 	virNetworkDefFormat;
 	virNetworkDefFree;
+	virNetworkDefParseFile;
+	virNetworkDefParseNode;
 	virNetworkDefParseString;
 	virNetworkDeleteConfig;
 	virNetworkFindByName;
 	virNetworkFindByUUID;
 	virNetworkLoadAllConfigs;
 	virNetworkObjListFree;
+	virNetworkDefParseNode;
 	virNetworkRemoveInactive;
 	virNetworkSaveConfig;
 
@@ -405,8 +463,15 @@
 	virNodeInfoPopulate;
 
 
+	/* qparams.h */
+	qparam_get_query;
+	qparam_query_parse;
+	free_qparam_set;
+
+
 	/* stats_linux.h */
 	linuxDomainInterfaceStats;
+	xenLinuxDomainBlockStats;
 
 
 	/* storage_backend.h */
@@ -423,6 +488,7 @@
 
 
 	/* storage_conf.h */
+        virStorageBackendPoolOptionsForType;
 	virStoragePoolDefFormat;
 	virStoragePoolDefFree;
 	virStoragePoolDefParse;
@@ -443,6 +509,11 @@
 	virStorageVolDefFormat;
 	virStorageVolDefFree;
 	virStorageVolDefParse;
+	virStoragePoolFormatDiskTypeToString;
+	virStoragePoolFormatFileSystemTypeToString;
+	virStoragePoolFormatFileSystemNetTypeToString;
+	virStorageVolFormatFileSystemTypeToString;
+	virStoragePoolTypeFromString;
 
 
 	/* util.h */
@@ -450,6 +521,7 @@
 	virStrToLong_i;
 	virStrToLong_ll;
 	virStrToLong_ull;
+	virFileLinkPointsTo;
 	saferead;
 	safewrite;
 	virMacAddrCompare;
@@ -458,6 +530,8 @@
 	virEventAddHandle;
 	virEventRemoveHandle;
 	virExec;
+	virFormatMacAddr;
+	virParseMacAddr;
 	virFileDeletePid;
 	virFileExists;
 	virFileHasSuffix;
@@ -465,20 +539,28 @@
 	virFileOpenTty;
 	virFileReadLimFD;
 	virFileReadPid;
+	virParseNumber;
 	virRun;
+	virSkipSpaces;
 
 
 	/* uuid.h */
 	virUUIDFormat;
+	virUUIDGenerate;
+	virUUIDParse;
 
 
 	/* virterror_internal.h */
+	virRaiseError;
 	virReportErrorHelper;
+	virErrorMsg;
 
 
 	/* xml.h */
+	virXPathLong;
+	virXPathNodeSet;
 	virXPathString;
-
+	virXMLPropString;
 
 	/* Finally everything else is totally private */
     local:
diff -r ecc8ae6295bc src/qemu_driver.c
--- a/src/qemu_driver.c	Wed Nov 12 21:59:22 2008 +0000
+++ b/src/qemu_driver.c	Thu Nov 13 17:13:02 2008 +0000
@@ -3440,7 +3440,7 @@
     .active = qemudActive,
 };
 
-int qemudRegister(void) {
+int qemuRegister(void) {
     virRegisterDriver(&qemuDriver);
     virRegisterStateDriver(&qemuStateDriver);
     return 0;
diff -r ecc8ae6295bc src/qemu_driver.h
--- a/src/qemu_driver.h	Wed Nov 12 21:59:22 2008 +0000
+++ b/src/qemu_driver.h	Thu Nov 13 17:13:02 2008 +0000
@@ -47,6 +47,6 @@
 #  define KVM_CAP_NR_VCPUS 9       /* returns max vcpus per vm */
 #endif
 
-int qemudRegister(void);
+int qemuRegister(void);
 
 #endif /* QEMUD_DRIVER_H */
diff -r ecc8ae6295bc src/xen_unified.c
--- a/src/xen_unified.c	Wed Nov 12 21:59:22 2008 +0000
+++ b/src/xen_unified.c	Thu Nov 13 17:13:02 2008 +0000
@@ -1359,14 +1359,14 @@
 };
 
 /**
- * xenUnifiedRegister:
+ * xenRegister:
  *
  * Register xen related drivers
  *
  * Returns the driver priority or -1 in case of error.
  */
 int
-xenUnifiedRegister (void)
+xenRegister (void)
 {
     /* Ignore failures here. */
     (void) xenHypervisorInit ();
diff -r ecc8ae6295bc src/xen_unified.h
--- a/src/xen_unified.h	Wed Nov 12 21:59:22 2008 +0000
+++ b/src/xen_unified.h	Thu Nov 13 17:13:02 2008 +0000
@@ -22,7 +22,7 @@
 #include <winsock2.h>
 #endif
 
-extern int xenUnifiedRegister (void);
+extern int xenRegister (void);
 
 #define XEN_UNIFIED_HYPERVISOR_OFFSET 0
 #define XEN_UNIFIED_PROXY_OFFSET 1
diff -r ecc8ae6295bc tests/Makefile.am
--- a/tests/Makefile.am	Wed Nov 12 21:59:22 2008 +0000
+++ b/tests/Makefile.am	Thu Nov 13 17:13:02 2008 +0000
@@ -18,6 +18,11 @@
         -DGETTEXT_PACKAGE=\"$(PACKAGE)\" \
          $(COVERAGE_CFLAGS) \
          $(WARN_CFLAGS)
+
+if WITH_DRIVER_MODULES
+INCLUDES += \
+	-DTEST_DRIVER_DIR=\"$(top_builddir)/src/.libs\"
+endif
 
 LDADDS = \
 	@STATIC_BINARIES@ \
@@ -76,6 +81,7 @@
   abs_srcdir=`cd '$(srcdir)'; pwd`		\
   PATH="$(path_add)$(PATH_SEPARATOR)$$PATH"	\
   SHELL="$(SHELL)"				\
+  LIBVIRT_DRIVER_DIR="$(abs_top_builddir)/src/.libs" \
   $(VG)
 
 valgrind:
@@ -93,17 +99,17 @@
 xml2sexprtest_SOURCES = \
 	xml2sexprtest.c testutilsxen.c testutilsxen.h \
 	testutils.c testutils.h
-xml2sexprtest_LDADD = $(LDADDS)
+xml2sexprtest_LDADD = ../src/libvirt_driver_xen.la $(LDADDS)
 
 sexpr2xmltest_SOURCES = \
 	sexpr2xmltest.c \
 	testutils.c testutils.h
-sexpr2xmltest_LDADD = $(LDADDS)
+sexpr2xmltest_LDADD = ../src/libvirt_driver_xen.la $(LDADDS)
 
 xmconfigtest_SOURCES = \
 	xmconfigtest.c testutilsxen.c testutilsxen.h \
 	testutils.c testutils.h
-xmconfigtest_LDADD = $(LDADDS)
+xmconfigtest_LDADD = ../src/libvirt_driver_xen.la $(LDADDS)
 
 qemuxml2argvtest_SOURCES = \
 	qemuxml2argvtest.c testutilsqemu.c testutilsqemu.h \
@@ -126,7 +132,7 @@
 
 xencapstest_SOURCES = \
 	xencapstest.c testutils.h testutils.c
-xencapstest_LDADD = $(LDADDS)
+xencapstest_LDADD = ../src/libvirt_driver_xen.la $(LDADDS)
 
 nodeinfotest_SOURCES = \
 	nodeinfotest.c testutils.h testutils.c
diff -r ecc8ae6295bc tests/cpuset
--- a/tests/cpuset	Wed Nov 12 21:59:22 2008 +0000
+++ b/tests/cpuset	Thu Nov 13 17:13:02 2008 +0000
@@ -21,6 +21,9 @@
   virsh --version
 fi
 
+test -z "$srcdir" && srcdir=`pwd`
+test -z "$abs_top_srcdir" && abs_top_srcdir=`pwd`/..
+
 . $srcdir/test-lib.sh
 
 fail=0
@@ -40,6 +43,6 @@
 error: Failed to define domain from xml-invalid
 
 EOF
-compare out exp || fail=1
+compare exp out || fail=1
 
 (exit $fail); exit $fail
diff -r ecc8ae6295bc tests/read-bufsiz
--- a/tests/read-bufsiz	Wed Nov 12 21:59:22 2008 +0000
+++ b/tests/read-bufsiz	Thu Nov 13 17:13:02 2008 +0000
@@ -21,6 +21,9 @@
   virsh --version
 fi
 
+test -z "$srcdir" && srcdir=`pwd`
+test -z "$abs_top_srcdir" && abs_top_srcdir=`pwd`/..
+
 . $srcdir/test-lib.sh
 
 fail=0
@@ -37,7 +40,7 @@
 
   virsh --connect test:///default define $in > out || fail=1
   printf "Domain test defined from $in\n\n" > exp || fail=1
-  compare out exp || fail=1
+  compare exp out || fail=1
 done
 
 (exit $fail); exit $fail
diff -r ecc8ae6295bc tests/read-non-seekable
--- a/tests/read-non-seekable	Wed Nov 12 21:59:22 2008 +0000
+++ b/tests/read-non-seekable	Thu Nov 13 17:13:02 2008 +0000
@@ -20,6 +20,9 @@
   set -x
   virsh --version
 fi
+
+test -z "$srcdir" && srcdir=`pwd`
+test -z "$abs_top_srcdir" && abs_top_srcdir=`pwd`/..
 
 . $srcdir/test-lib.sh
 
diff -r ecc8ae6295bc tests/testutils.c
--- a/tests/testutils.c	Wed Nov 12 21:59:22 2008 +0000
+++ b/tests/testutils.c	Thu Nov 13 17:13:02 2008 +0000
@@ -151,6 +151,9 @@
     int stderrfd = -1;
     const char *const env[] = {
         "LANG=C",
+#if WITH_DRIVER_MODULES
+        "LIBVIRT_DRIVER_DIR=" TEST_DRIVER_DIR,
+#endif
         NULL
     };
 
diff -r ecc8ae6295bc tests/undefine
--- a/tests/undefine	Wed Nov 12 21:59:22 2008 +0000
+++ b/tests/undefine	Thu Nov 13 17:13:02 2008 +0000
@@ -21,6 +21,9 @@
   virsh --version
 fi
 
+test -z "$srcdir" && srcdir=`pwd`
+test -z "$abs_top_srcdir" && abs_top_srcdir=`pwd`/..
+
 . $srcdir/test-lib.sh
 
 fail=0
@@ -32,7 +35,7 @@
 libvir: Test error : internal error Domain 'test' is still running
 error: Failed to undefine domain test
 EOF
-compare out exp || fail=1
+compare exp out || fail=1
 
 # A different diagnostic when specifying a domain ID
 virsh -q -c test:///default undefine 1 > out 2>&1
@@ -41,7 +44,7 @@
 error: a running domain like 1 cannot be undefined;
 to undefine, first shutdown then undefine using its name or UUID
 EOF
-compare out exp || fail=1
+compare exp out || fail=1
 
 # Succeed, now: first shut down, then undefine, both via name.
 virsh -q -c test:///default 'shutdown test; undefine test' > out 2>&1
@@ -50,6 +53,6 @@
 Domain test is being shutdown
 Domain test has been undefined
 EOF
-compare out exp || fail=1
+compare exp out || fail=1
 
 (exit $fail); exit $fail
diff -r ecc8ae6295bc tests/vcpupin
--- a/tests/vcpupin	Wed Nov 12 21:59:22 2008 +0000
+++ b/tests/vcpupin	Thu Nov 13 17:13:02 2008 +0000
@@ -21,6 +21,9 @@
   virsh --version
 fi
 
+test -z "$srcdir" && srcdir=`pwd`
+test -z "$abs_top_srcdir" && abs_top_srcdir=`pwd`/..
+
 . $srcdir/test-lib.sh
 
 fail=0
@@ -32,7 +35,7 @@
 error: vcpupin: Invalid or missing vCPU number.
 
 EOF
-compare out exp || fail=1
+compare exp out || fail=1
 
 # An out-of-range vCPU number deserves a diagnostic, too.
 virsh --connect test:///default vcpupin test 100 0,1 > out 2>&1
@@ -41,6 +44,6 @@
 error: vcpupin: Invalid vCPU number.
 
 EOF
-compare out exp || fail=1
+compare exp out || fail=1
 
 (exit $fail); exit $fail
diff -r ecc8ae6295bc tests/xmconfigtest.c
--- a/tests/xmconfigtest.c	Wed Nov 12 21:59:22 2008 +0000
+++ b/tests/xmconfigtest.c	Thu Nov 13 17:13:02 2008 +0000
@@ -55,13 +55,11 @@
     int ret = -1;
     virConnectPtr conn;
     int wrote = MAX_FILE;
-    void *old_priv = NULL;
     struct _xenUnifiedPrivate priv;
     virDomainDefPtr def = NULL;
 
-    conn = virConnectOpenReadOnly("test:///default");
+    conn = virGetConnect();
     if (!conn) goto fail;
-    old_priv = conn->privateData;
 
     if (virtTestLoadFile(xml, &xmlPtr, MAX_FILE) < 0)
         goto fail;
@@ -95,10 +93,7 @@
     if (conf)
         virConfFree(conf);
     virDomainDefFree(def);
-    if (conn) {
-        conn->privateData = old_priv;
-        virConnectClose(conn);
-    }
+    VIR_FREE(conn);
 
     return ret;
 }
@@ -113,13 +108,11 @@
     virConfPtr conf = NULL;
     int ret = -1;
     virConnectPtr conn;
-    void *old_priv;
     struct _xenUnifiedPrivate priv;
     virDomainDefPtr def = NULL;
 
-    conn = virConnectOpenReadOnly("test:///default");
+    conn = virGetConnect();
     if (!conn) goto fail;
-    old_priv = conn->privateData;
 
     if (virtTestLoadFile(xml, &xmlPtr, MAX_FILE) < 0)
         goto fail;
@@ -153,10 +146,7 @@
         virConfFree(conf);
     VIR_FREE(gotxml);
     virDomainDefFree(def);
-    if (conn) {
-        conn->privateData = old_priv;
-        virConnectClose(conn);
-    }
+    VIR_FREE(conn);
 
     return ret;
 }


-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|


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