+Fri Nov 21 12:03:14 BST 2008 Daniel P. Berrange <berrange@redhat.com>
+
+ Optional (disabled by default) dlopen support
+ * configure.in: Probe for dlopen
+ * qemud/Makefile.am: Don't link to drivers when dlopen is used
+ * qemud/qemud.c: Load external driver modules at startup
+ * src/Makefile.am: Don't link to drivers when dlopen is used
+ * src/driver.c, src/driver.h: Add API for dlopen'ing modules
+ * src/libvirt.c: Load external driver modules at startup
+ * src/libvirt_sym.version.in: Export more internal symbols
+ needed for external driver modules
+ * src/qemud_driver.c, src/qemu_driver.h, src/xen_unified.c,
+ src/xen_unified.h: Sanitize driver registration methodname
+ to match module name
+ * tests/Makefile.am: Set LIBVIRT_DRIVER_DIR when running
+ tests with dlopen enabled. Link to driver modules in Xen
+ test cases
+ * tests/testutils.c: Set LIBVIRT_DRIVER_DIR when running
+ external programs
+ * tests/xmconfigtest.c: Don't open test driver during xen
+ tests.
+
Fri Nov 21 11:43:14 BST 2008 Daniel P. Berrange <berrange@redhat.com>
* src/libvirt_sym.version.in: Add export of domain event
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.
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])
libvirtd_LDADD = \
../gnulib/lib/libgnu.la
+if ! WITH_DRIVER_MODULES
if WITH_QEMU
libvirtd_LDADD += ../src/libvirt_driver_qemu.la
endif
if WITH_NETWORK
libvirtd_LDADD += ../src/libvirt_driver_network.la
endif
+endif
libvirtd_LDADD += ../src/libvirt.la
#include "mdns.h"
#endif
+#ifdef WITH_DRIVER_MODULES
+#include "driver.h"
+#else
#ifdef WITH_QEMU
#include "qemu_driver.h"
#endif
#ifdef WITH_STORAGE_DIR
#include "storage_driver.h"
#endif
+#endif
static int godaemon = 0; /* -d: Be a daemon */
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("uml");
+ virDriverLoadModule("network");
+ virDriverLoadModule("storage");
+#else
#ifdef WITH_QEMU
- qemudRegister();
+ qemuRegister();
#endif
#ifdef WITH_LXC
lxcRegister();
#endif
#ifdef WITH_STORAGE_DIR
storageRegister();
+#endif
#endif
virEventRegisterImpl(virEventAddHandleImpl,
-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)\"" \
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 = \
# Internal generic driver infrastructure
DRIVER_SOURCES = \
- driver.h \
+ driver.c driver.h \
internal.h \
datatypes.c datatypes.h \
domain_event.c domain_event.h \
libvirt_driver_la_LDFLAGS = $(XEN_LIBS)
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
+if WITH_DRIVER_MODULES
+libvirt_driver_test_la_LDFLAGS = -module -avoid-version
+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_UML
+if WITH_DRIVER_MODULES
+mod_LTLIBRARIES += libvirt_driver_uml.la
+else
noinst_LTLIBRARIES += libvirt_driver_uml.la
# Stateful, so linked to daemon instead
#libvirt_la_LIBADD += libvirt_driver_uml.la
+endif
+libvirt_driver_uml_la_CFLAGS = $(NUMACTL_CFLAGS)
+libvirt_driver_uml_la_LDFLAGS = $(NUMACTL_LIBS)
+if WITH_DRIVER_MODULES
+libvirt_driver_uml_la_LDFLAGS += -module -avoid-version
+endif
libvirt_driver_uml_la_SOURCES = $(UML_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
-version-info @LIBVIRT_VERSION_INFO@ \
$(COVERAGE_CFLAGS:-f%=-Wc,-f%) \
$(LIBXML_LIBS) $(SELINUX_LIBS) \
+ $(XEN_LIBS) $(DRIVER_MODULE_LIBS) \
@CYGWIN_EXTRA_LDFLAGS@ @MINGW_EXTRA_LDFLAGS@
libvirt_la_CFLAGS = $(COVERAGE_CFLAGS) -DIN_LIBVIRT
libvirt_la_DEPENDENCIES = $(libvirt_la_LIBADD) $(srcdir)/libvirt_sym.version
--- /dev/null
+/*
+ * 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(®func, "%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
#include <libxml/uri.h>
+#include "internal.h"
/*
* List of registered drivers numbers
*/
#ifdef WITH_LIBVIRTD
int virRegisterStateDriver(virStateDriverPtr);
#endif
+void *virDriverLoadModule(const char *name);
#endif /* __VIR_DRIVER_H__ */
#include "util.h"
#include "memory.h"
+#ifndef WITH_DRIVER_MODULES
#ifdef WITH_TEST
#include "test.h"
#endif
#ifdef WITH_OPENVZ
#include "openvz_driver.h"
#endif
+#endif
/*
* TODO:
* 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;
#endif
#ifdef WITH_REMOTE
if (remoteRegister () == -1) return -1;
+#endif
#endif
return(0);
return(-1);
}
+ DEBUG ("registering %s as network driver %d",
+ driver->name, virNetworkDriverTabCount);
+
virNetworkDriverTab[virNetworkDriverTabCount] = driver;
return virNetworkDriverTabCount++;
}
return(-1);
}
+ DEBUG ("registering %s as storage driver %d",
+ driver->name, virStorageDriverTabCount);
+
virStorageDriverTab[virStorageDriverTabCount] = driver;
return virStorageDriverTabCount++;
}
virCapabilitiesAddGuest;
virCapabilitiesAddGuestDomain;
virCapabilitiesAddGuestFeature;
+ virCapabilitiesAddHostMigrateTransport;
virCapabilitiesAddHostNUMACell;
+ virCapabilitiesAddHostFeature;
+ virCapabilitiesDefaultGuestArch;
virCapabilitiesDefaultGuestEmulator;
+ virCapabilitiesDefaultGuestMachine;
virCapabilitiesFormatXML;
virCapabilitiesFree;
virCapabilitiesNew;
virConfReadFile;
virConfReadMem;
virConfFree;
+ virConfFreeValue;
virConfGetValue;
virConfSetValue;
virConfWriteFile;
virGetNetwork;
virGetStoragePool;
virGetStorageVol;
+ virUnrefDomain;
/* domain_conf.h */
virDiskNameToIndex;
virDomainAssignDef;
virDomainConfigFile;
+ virDomainCpuSetFormat;
+ virDomainCpuSetParse;
+ virDomainChrDefFree;
+ virDomainChrTypeFromString;
+ virDomainChrTypeToString;
virDomainDefDefaultEmulator;
virDomainDefFormat;
virDomainDefFree;
virDomainDefParseFile;
+ virDomainDefParseNode;
virDomainDefParseString;
virDomainDeleteConfig;
+ virDomainDeviceDefFree;
virDomainDeviceDefParse;
virDomainDiskBusTypeToString;
+ virDomainDiskDefFree;
virDomainDiskDeviceTypeToString;
virDomainDiskQSort;
virDomainFindByID;
virDomainFindByName;
virDomainFindByUUID;
+ virDomainGraphicsTypeFromString;
+ virDomainGraphicsDefFree;
+ virDomainInputDefFree;
+ virDomainLifecycleTypeFromString;
+ virDomainLifecycleTypeToString;
virDomainLoadAllConfigs;
+ virDomainNetDefFree;
+ virDomainObjFree;
virDomainObjListFree;
virDomainRemoveInactive;
virDomainSaveConfig;
+ virDomainSoundDefFree;
+ virDomainSoundModelTypeFromString;
virDomainSoundModelTypeToString;
virDomainVirtTypeToString;
+ virDomainFSDefFree;
/* domain_event.h */
virDomainEventCallbackListFree;
virDomainEventCallbackListRemove;
virDomainEventCallbackListRemoveConn;
+ 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 */
virNetworkAssignDef;
virNetworkDefFormat;
virNetworkDefFree;
+ virNetworkDefParseFile;
+ virNetworkDefParseNode;
virNetworkDefParseString;
virNetworkDeleteConfig;
virNetworkFindByName;
virNetworkFindByUUID;
virNetworkLoadAllConfigs;
virNetworkObjListFree;
+ virNetworkDefParseNode;
virNetworkRemoveInactive;
virNetworkSaveConfig;
virNodeInfoPopulate;
+ /* qparams.h */
+ qparam_get_query;
+ qparam_query_parse;
+ free_qparam_set;
+
+
/* stats_linux.h */
linuxDomainInterfaceStats;
+ xenLinuxDomainBlockStats;
/* storage_backend.h */
/* storage_conf.h */
+ virStorageBackendPoolOptionsForType;
virStoragePoolDefFormat;
virStoragePoolDefFree;
virStoragePoolDefParse;
virStrToLong_i;
virStrToLong_ll;
virStrToLong_ull;
+ virFileLinkPointsTo;
saferead;
safewrite;
virMacAddrCompare;
virEventAddHandle;
virEventRemoveHandle;
virExec;
+ virFormatMacAddr;
+ virParseMacAddr;
virFileDeletePid;
virFileExists;
virFileHasSuffix;
virFileReadPid;
virParseNumber;
virRun;
+ virSkipSpaces;
/* uuid.h */
virUUIDFormat;
+ virUUIDGenerate;
+ virUUIDParse;
/* virterror_internal.h */
virReportErrorHelper;
+ virErrorMsg;
+ virRaiseError;
/* xml.h */
+ virXPathLong;
+ virXPathNodeSet;
virXPathString;
+ virXMLPropString;
/* Finally everything else is totally private */
.active = qemudActive,
};
-int qemudRegister(void) {
+int qemuRegister(void) {
virRegisterDriver(&qemuDriver);
virRegisterStateDriver(&qemuStateDriver);
return 0;
# define KVM_CAP_NR_VCPUS 9 /* returns max vcpus per vm */
#endif
-int qemudRegister(void);
+int qemuRegister(void);
#endif /* QEMUD_DRIVER_H */
};
/**
- * 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 ();
#include <winsock2.h>
#endif
-extern int xenUnifiedRegister (void);
+extern int xenRegister (void);
#define XEN_UNIFIED_HYPERVISOR_OFFSET 0
#define XEN_UNIFIED_PROXY_OFFSET 1
$(COVERAGE_CFLAGS) \
$(WARN_CFLAGS)
+if WITH_DRIVER_MODULES
+INCLUDES += \
+ -DTEST_DRIVER_DIR=\"$(top_builddir)/src/.libs\"
+endif
+
LDADDS = \
@STATIC_BINARIES@ \
$(LIBXML_LIBS) \
abs_srcdir=`cd '$(srcdir)'; pwd` \
PATH="$(path_add)$(PATH_SEPARATOR)$$PATH" \
SHELL="$(SHELL)" \
+ LIBVIRT_DRIVER_DIR="$(abs_top_builddir)/src/.libs" \
$(VG)
valgrind:
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)
if WITH_QEMU
qemuxml2argvtest_SOURCES = \
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
int stderrfd = -1;
const char *const env[] = {
"LANG=C",
+#if WITH_DRIVER_MODULES
+ "LIBVIRT_DRIVER_DIR=" TEST_DRIVER_DIR,
+#endif
NULL
};
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;
if (conf)
virConfFree(conf);
virDomainDefFree(def);
- if (conn) {
- conn->privateData = old_priv;
- virConnectClose(conn);
- }
+ virUnrefConnect(conn);
return ret;
}
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;
virConfFree(conf);
VIR_FREE(gotxml);
virDomainDefFree(def);
- if (conn) {
- conn->privateData = old_priv;
- virConnectClose(conn);
- }
+ virUnrefConnect(conn);
return ret;
}