1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

Optional dlopen support for drivers

This commit is contained in:
Daniel P. Berrange 2008-11-21 12:16:08 +00:00
parent 410fb96cbc
commit 2c855c1c66
16 changed files with 372 additions and 26 deletions

View File

@ -1,3 +1,25 @@
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

View File

@ -1066,6 +1066,38 @@ dnl Look for windres to build a Windows icon resource.
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.
@ -1122,6 +1154,14 @@ AC_MSG_NOTICE([ LVM: $with_storage_lvm])
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])

View File

@ -91,6 +91,7 @@ libvirtd_DEPENDENCIES = ../src/libvirt.la
libvirtd_LDADD = \
../gnulib/lib/libgnu.la
if ! WITH_DRIVER_MODULES
if WITH_QEMU
libvirtd_LDADD += ../src/libvirt_driver_qemu.la
endif
@ -110,6 +111,7 @@ endif
if WITH_NETWORK
libvirtd_LDADD += ../src/libvirt_driver_network.la
endif
endif
libvirtd_LDADD += ../src/libvirt.la

View File

@ -61,6 +61,9 @@
#include "mdns.h"
#endif
#ifdef WITH_DRIVER_MODULES
#include "driver.h"
#else
#ifdef WITH_QEMU
#include "qemu_driver.h"
#endif
@ -76,6 +79,7 @@
#ifdef WITH_STORAGE_DIR
#include "storage_driver.h"
#endif
#endif
static int godaemon = 0; /* -d: Be a daemon */
@ -748,8 +752,20 @@ static struct qemud_server *qemudInitialize(int sigread) {
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();
@ -762,6 +778,7 @@ static struct qemud_server *qemudInitialize(int sigread) {
#endif
#ifdef WITH_STORAGE_DIR
storageRegister();
#endif
#endif
virEventRegisterImpl(virEventAddHandleImpl,

View File

@ -6,7 +6,10 @@ INCLUDES = \
-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 @@ EXTRA_DIST = libvirt_sym.version $(conf_DATA) $(ICON_FILES)
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 @@ 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 \
@ -169,73 +176,138 @@ libvirt_driver_la_CFLAGS = $(XEN_CFLAGS)
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
@ -277,6 +349,7 @@ libvirt_la_LDFLAGS = -Wl,--version-script=$(srcdir)/libvirt_sym.version \
-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

97
src/driver.c Normal file
View File

@ -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

View File

@ -8,6 +8,7 @@
#include <libxml/uri.h>
#include "internal.h"
/*
* List of registered drivers numbers
*/
@ -645,5 +646,6 @@ int virRegisterStorageDriver(virStorageDriverPtr);
#ifdef WITH_LIBVIRTD
int virRegisterStateDriver(virStateDriverPtr);
#endif
void *virDriverLoadModule(const char *name);
#endif /* __VIR_DRIVER_H__ */

View File

@ -41,6 +41,7 @@
#include "util.h"
#include "memory.h"
#ifndef WITH_DRIVER_MODULES
#ifdef WITH_TEST
#include "test.h"
#endif
@ -53,6 +54,7 @@
#ifdef WITH_OPENVZ
#include "openvz_driver.h"
#endif
#endif
/*
* TODO:
@ -270,17 +272,29 @@ virInitialize(void)
* 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);
@ -458,6 +472,9 @@ virRegisterNetworkDriver(virNetworkDriverPtr driver)
return(-1);
}
DEBUG ("registering %s as network driver %d",
driver->name, virNetworkDriverTabCount);
virNetworkDriverTab[virNetworkDriverTabCount] = driver;
return virNetworkDriverTabCount++;
}
@ -486,6 +503,9 @@ virRegisterStorageDriver(virStorageDriverPtr driver)
return(-1);
}
DEBUG ("registering %s as storage driver %d",
driver->name, virStorageDriverTabCount);
virStorageDriverTab[virStorageDriverTabCount] = driver;
return virStorageDriverTabCount++;
}

View File

@ -283,8 +283,12 @@ LIBVIRT_PRIVATE_@VERSION@ {
virCapabilitiesAddGuest;
virCapabilitiesAddGuestDomain;
virCapabilitiesAddGuestFeature;
virCapabilitiesAddHostMigrateTransport;
virCapabilitiesAddHostNUMACell;
virCapabilitiesAddHostFeature;
virCapabilitiesDefaultGuestArch;
virCapabilitiesDefaultGuestEmulator;
virCapabilitiesDefaultGuestMachine;
virCapabilitiesFormatXML;
virCapabilitiesFree;
virCapabilitiesNew;
@ -296,6 +300,7 @@ LIBVIRT_PRIVATE_@VERSION@ {
virConfReadFile;
virConfReadMem;
virConfFree;
virConfFreeValue;
virConfGetValue;
virConfSetValue;
virConfWriteFile;
@ -307,6 +312,7 @@ LIBVIRT_PRIVATE_@VERSION@ {
virGetNetwork;
virGetStoragePool;
virGetStorageVol;
virUnrefDomain;
/* domain_conf.h */
@ -314,25 +320,43 @@ LIBVIRT_PRIVATE_@VERSION@ {
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 */
@ -340,6 +364,34 @@ LIBVIRT_PRIVATE_@VERSION@ {
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 */
@ -397,12 +449,15 @@ LIBVIRT_PRIVATE_@VERSION@ {
virNetworkAssignDef;
virNetworkDefFormat;
virNetworkDefFree;
virNetworkDefParseFile;
virNetworkDefParseNode;
virNetworkDefParseString;
virNetworkDeleteConfig;
virNetworkFindByName;
virNetworkFindByUUID;
virNetworkLoadAllConfigs;
virNetworkObjListFree;
virNetworkDefParseNode;
virNetworkRemoveInactive;
virNetworkSaveConfig;
@ -411,8 +466,15 @@ LIBVIRT_PRIVATE_@VERSION@ {
virNodeInfoPopulate;
/* qparams.h */
qparam_get_query;
qparam_query_parse;
free_qparam_set;
/* stats_linux.h */
linuxDomainInterfaceStats;
xenLinuxDomainBlockStats;
/* storage_backend.h */
@ -429,6 +491,7 @@ LIBVIRT_PRIVATE_@VERSION@ {
/* storage_conf.h */
virStorageBackendPoolOptionsForType;
virStoragePoolDefFormat;
virStoragePoolDefFree;
virStoragePoolDefParse;
@ -461,6 +524,7 @@ LIBVIRT_PRIVATE_@VERSION@ {
virStrToLong_i;
virStrToLong_ll;
virStrToLong_ull;
virFileLinkPointsTo;
saferead;
safewrite;
virMacAddrCompare;
@ -469,6 +533,8 @@ LIBVIRT_PRIVATE_@VERSION@ {
virEventAddHandle;
virEventRemoveHandle;
virExec;
virFormatMacAddr;
virParseMacAddr;
virFileDeletePid;
virFileExists;
virFileHasSuffix;
@ -479,18 +545,26 @@ LIBVIRT_PRIVATE_@VERSION@ {
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 */

View File

@ -3804,7 +3804,7 @@ static virStateDriver qemuStateDriver = {
.active = qemudActive,
};
int qemudRegister(void) {
int qemuRegister(void) {
virRegisterDriver(&qemuDriver);
virRegisterStateDriver(&qemuStateDriver);
return 0;

View File

@ -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 */

View File

@ -1359,14 +1359,14 @@ static virDriver xenUnifiedDriver = {
};
/**
* 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 ();

View File

@ -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

View File

@ -19,6 +19,11 @@ INCLUDES = \
$(COVERAGE_CFLAGS) \
$(WARN_CFLAGS)
if WITH_DRIVER_MODULES
INCLUDES += \
-DTEST_DRIVER_DIR=\"$(top_builddir)/src/.libs\"
endif
LDADDS = \
@STATIC_BINARIES@ \
$(LIBXML_LIBS) \
@ -83,6 +88,7 @@ TESTS_ENVIRONMENT = \
abs_srcdir=`cd '$(srcdir)'; pwd` \
PATH="$(path_add)$(PATH_SEPARATOR)$$PATH" \
SHELL="$(SHELL)" \
LIBVIRT_DRIVER_DIR="$(abs_top_builddir)/src/.libs" \
$(VG)
valgrind:
@ -100,17 +106,17 @@ xmlrpctest_LDADD = $(LDADDS)
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 = \
@ -137,7 +143,7 @@ conftest_LDADD = $(LDADDS)
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

View File

@ -151,6 +151,9 @@ void virtTestCaptureProgramExecChild(const char *const argv[],
int stderrfd = -1;
const char *const env[] = {
"LANG=C",
#if WITH_DRIVER_MODULES
"LIBVIRT_DRIVER_DIR=" TEST_DRIVER_DIR,
#endif
NULL
};

View File

@ -55,13 +55,11 @@ static int testCompareParseXML(const char *xmcfg, const char *xml,
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 @@ static int testCompareParseXML(const char *xmcfg, const char *xml,
if (conf)
virConfFree(conf);
virDomainDefFree(def);
if (conn) {
conn->privateData = old_priv;
virConnectClose(conn);
}
virUnrefConnect(conn);
return ret;
}
@ -113,13 +108,11 @@ static int testCompareFormatXML(const char *xmcfg, const char *xml,
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 @@ static int testCompareFormatXML(const char *xmcfg, const char *xml,
virConfFree(conf);
VIR_FREE(gotxml);
virDomainDefFree(def);
if (conn) {
conn->privateData = old_priv;
virConnectClose(conn);
}
virUnrefConnect(conn);
return ret;
}