From: Miloslav Trmač <mitr(a)redhat.com>
The libvirt_util.la library was mistakenly linked into libvirtd
directly. Since libvirt_util.la is already linked to libvirt.so,
this resulted in libvirtd getting two copies of the code and
more critically 2 copies of static global variables.
Testing in turn exposed a issue with loadable modules. The
gnulib replacement functions are not exported to loadable
modules. Rather than trying to figure out the name sof all
gnulib functions & export them, just linkage all loadable
modules against libgnu.la statically.
* daemon/Makefile.am: Remove linkage of libvirt_util.la
and libvirt_driver.la
* src/Makefile.am: Link driver modules against libgnu.la
* src/libvirt.c: Don't try to load modules which were
compiled out
* src/libvirt_private.syms: Export all other internal
symbols that are required by drivers
---
daemon/Makefile.am | 6 ++----
src/Makefile.am | 24 +++++++++++++++++++-----
src/libvirt.c | 14 ++++++++++++++
src/libvirt_private.syms | 45 +++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 80 insertions(+), 9 deletions(-)
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index b020b77..987133c 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -99,11 +99,9 @@ libvirtd_LDADD = \
$(SASL_LIBS) \
$(POLKIT_LIBS)
-libvirtd_LDADD += ../src/libvirt_util.la ../src/libvirt-qemu.la
+libvirtd_LDADD += ../src/libvirt-qemu.la
-if WITH_DRIVER_MODULES
- libvirtd_LDADD += ../src/libvirt_driver.la
-else
+if ! WITH_DRIVER_MODULES
if WITH_QEMU
libvirtd_LDADD += ../src/libvirt_driver_qemu.la
endif
diff --git a/src/Makefile.am b/src/Makefile.am
index 8ec8230..521246c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -82,7 +82,7 @@ UTIL_SOURCES = \
util/uuid.c util/uuid.h \
util/util.c util/util.h \
util/xml.c util/xml.h \
- util/virtaudit.c util/virtaudit.h \
+ util/virtaudit.c util/virtaudit.h \
util/virterror.c util/virterror_internal.h
EXTRA_DIST += util/threads-pthread.c util/threads-win32.c
@@ -566,6 +566,7 @@ libvirt_driver_xen_la_CFLAGS = \
libvirt_driver_xen_la_LDFLAGS = $(AM_LDFLAGS)
libvirt_driver_xen_la_LIBADD = $(XEN_LIBS)
if WITH_DRIVER_MODULES
+libvirt_driver_xen_la_LIBADD += ../gnulib/lib/libgnu.la
libvirt_driver_xen_la_LDFLAGS += -module -avoid-version
endif
libvirt_driver_xen_la_SOURCES = $(XEN_DRIVER_SOURCES)
@@ -578,7 +579,8 @@ else
noinst_LTLIBRARIES += libvirt_driver_phyp.la
libvirt_la_BUILT_LIBADD += libvirt_driver_phyp.la
endif
-libvirt_driver_phyp_la_LIBADD = $(LIBSSH2_LIBS)
+libvirt_driver_phyp_la_LIBADD = ../gnulib/lib/libgnu.la
+libvirt_driver_phyp_la_LIBADD += $(LIBSSH2_LIBS)
libvirt_driver_phyp_la_CFLAGS = $(LIBSSH2_CFLAGS) \
-I@top_srcdir@/src/conf $(AM_CFLAGS)
libvirt_driver_phyp_la_SOURCES = $(PHYP_DRIVER_SOURCES)
@@ -594,6 +596,7 @@ endif
libvirt_driver_openvz_la_CFLAGS = \
-I@top_srcdir@/src/conf $(AM_CFLAGS)
if WITH_DRIVER_MODULES
+libvirt_driver_openvz_la_LIBADD = ../gnulib/lib/libgnu.la
libvirt_driver_openvz_la_LDFLAGS = -module -avoid-version $(AM_LDFLAGS)
endif
libvirt_driver_openvz_la_SOURCES = $(OPENVZ_DRIVER_SOURCES)
@@ -608,10 +611,11 @@ libvirt_la_BUILT_LIBADD += libvirt_driver_vbox.la
endif
libvirt_driver_vbox_la_CFLAGS = \
-I@top_srcdir@/src/conf $(AM_CFLAGS)
+libvirt_driver_vbox_la_LIBADD = $(DLOPEN_LIBS)
if WITH_DRIVER_MODULES
+libvirt_driver_vbox_la_LIBADD += ../gnulib/lib/libgnu.la
libvirt_driver_vbox_la_LDFLAGS = -module -avoid-version $(AM_LDFLAGS)
endif
-libvirt_driver_vbox_la_LIBADD = $(DLOPEN_LIBS)
libvirt_driver_vbox_la_SOURCES = $(VBOX_DRIVER_SOURCES)
endif
@@ -627,6 +631,7 @@ libvirt_driver_xenapi_la_CFLAGS = $(LIBXENSERVER_CFLAGS)
$(LIBCURL_CFLAGS) \
libvirt_driver_xenapi_la_LDFLAGS = $(AM_LDFLAGS)
libvirt_driver_xenapi_la_LIBADD = $(LIBXENSERVER_LIBS) $(LIBCURL_LIBS)
if WITH_DRIVER_MODULES
+libvirt_driver_xenapi_la_LIBADD += ../gnulib/lib/libgnu.la
libvirt_driver_xenapi_la_LDFLAGS += -module -avoid-version
endif
libvirt_driver_xenapi_la_SOURCES = $(XENAPI_DRIVER_SOURCES)
@@ -645,6 +650,7 @@ libvirt_driver_qemu_la_CFLAGS = $(NUMACTL_CFLAGS) \
libvirt_driver_qemu_la_LDFLAGS = $(AM_LDFLAGS)
libvirt_driver_qemu_la_LIBADD = $(NUMACTL_LIBS)
if WITH_DRIVER_MODULES
+libvirt_driver_qemu_la_LIBADD += ../gnulib/lib/libgnu.la
libvirt_driver_qemu_la_LDFLAGS += -module -avoid-version
endif
libvirt_driver_qemu_la_SOURCES = $(QEMU_DRIVER_SOURCES)
@@ -670,6 +676,7 @@ endif
libvirt_driver_lxc_la_CFLAGS = \
-I@top_srcdir@/src/conf $(AM_CFLAGS)
if WITH_DRIVER_MODULES
+libvirt_driver_lxc_la_LIBADD = ../gnulib/lib/libgnu.la
libvirt_driver_lxc_la_LDFLAGS = -module -avoid-version $(AM_LDFLAGS)
endif
libvirt_driver_lxc_la_SOURCES = $(LXC_DRIVER_SOURCES)
@@ -695,6 +702,7 @@ libvirt_driver_uml_la_CFLAGS = $(NUMACTL_CFLAGS) \
libvirt_driver_uml_la_LDFLAGS = $(AM_LDFLAGS)
libvirt_driver_uml_la_LIBADD = $(NUMACTL_LIBS)
if WITH_DRIVER_MODULES
+libvirt_driver_uml_la_LIBADD += ../gnulib/lib/libgnu.la
libvirt_driver_uml_la_LDFLAGS += -module -avoid-version
endif
libvirt_driver_uml_la_SOURCES = $(UML_DRIVER_SOURCES)
@@ -714,6 +722,7 @@ libvirt_driver_one_la_LDFLAGS = $(AM_LDFLAGS)
libvirt_driver_one_la_LIBADD = $(XMLRPC_LIBS)
#libvirt_driver_one_la_CFLAGS = "-DWITH_ONE"
if WITH_DRIVER_MODULES
+libvirt_driver_one_la_LIBADD += ../gnulib/lib/libgnu.la
libvirt_driver_one_la_LDFLAGS += -module -avoid-version
endif
libvirt_driver_one_la_SOURCES = $(ONE_DRIVER_SOURCES)
@@ -737,6 +746,7 @@ libvirt_driver_esx_la_CFLAGS = $(LIBCURL_CFLAGS) \
libvirt_driver_esx_la_LDFLAGS = $(AM_LDFLAGS)
libvirt_driver_esx_la_LIBADD = $(LIBCURL_LIBS)
if WITH_DRIVER_MODULES
+libvirt_driver_esx_la_LIBADD += ../gnulib/lib/libgnu.la
libvirt_driver_esx_la_LDFLAGS += -module -avoid-version
endif
libvirt_driver_esx_la_SOURCES = $(ESX_DRIVER_SOURCES)
@@ -754,6 +764,7 @@ endif
libvirt_driver_network_la_CFLAGS = \
-I@top_srcdir@/src/conf $(AM_CFLAGS)
if WITH_DRIVER_MODULES
+libvirt_driver_network_la_LIBADD = ../gnulib/lib/libgnu.la
libvirt_driver_network_la_LDFLAGS = -module -avoid-version $(AM_LDFLAGS)
endif
libvirt_driver_network_la_SOURCES = $(NETWORK_DRIVER_SOURCES)
@@ -775,6 +786,7 @@ libvirt_driver_interface_la_CFLAGS = $(NETCF_CFLAGS) \
libvirt_driver_interface_la_LDFLAGS = $(AM_LDFLAGS)
libvirt_driver_interface_la_LIBADD = $(NETCF_LIBS)
if WITH_DRIVER_MODULES
+libvirt_driver_interface_la_LIBADD += ../gnulib/lib/libgnu.la
libvirt_driver_interface_la_LDFLAGS += -module -avoid-version
endif
libvirt_driver_interface_la_SOURCES = $(INTERFACE_DRIVER_SOURCES)
@@ -791,8 +803,8 @@ endif
libvirt_driver_secret_la_CFLAGS = \
-I@top_srcdir@/src/conf $(AM_CFLAGS)
if WITH_DRIVER_MODULES
-libvirt_driver_secret_la_LDFLAGS = -module -avoid-version $(AM_LDFLAGS)
libvirt_driver_secret_la_LIBADD = ../gnulib/lib/libgnu.la
+libvirt_driver_secret_la_LDFLAGS = -module -avoid-version $(AM_LDFLAGS)
endif
libvirt_driver_secret_la_SOURCES = $(SECRET_DRIVER_SOURCES)
endif
@@ -812,6 +824,7 @@ noinst_LTLIBRARIES += libvirt_driver_storage.la
#libvirt_la_BUILT_LIBADD += libvirt_driver_storage.la
endif
if WITH_DRIVER_MODULES
+libvirt_driver_storage_la_LIBADD += ../gnulib/lib/libgnu.la
libvirt_driver_storage_la_LDFLAGS += -module -avoid-version
endif
libvirt_driver_storage_la_SOURCES += $(STORAGE_DRIVER_SOURCES)
@@ -867,6 +880,7 @@ libvirt_driver_nodedev_la_LIBADD += $(UDEV_LIBS) $(PCIACCESS_LIBS)
endif
if WITH_DRIVER_MODULES
+libvirt_driver_nodedev_la_LIBADD += ../gnulib/lib/libgnu.la
libvirt_driver_nodedev_la_LDFLAGS += -module -avoid-version
endif
endif
@@ -884,8 +898,8 @@ libvirt_driver_nwfilter_la_CFLAGS = $(LIBPCAP_CFLAGS) \
libvirt_driver_nwfilter_la_LDFLAGS = $(LD_AMFLAGS)
libvirt_driver_nwfilter_la_LIBADD = $(LIBPCAP_LIBS)
if WITH_DRIVER_MODULES
-libvirt_driver_nwfilter_la_LDFLAGS += -module -avoid-version
libvirt_driver_nwfilter_la_LIBADD += ../gnulib/lib/libgnu.la
+libvirt_driver_nwfilter_la_LDFLAGS += -module -avoid-version
endif
libvirt_driver_nwfilter_la_SOURCES = $(NWFILTER_DRIVER_SOURCES)
endif
diff --git a/src/libvirt.c b/src/libvirt.c
index ca383ba..61c47b4 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -355,13 +355,27 @@ virInitialize(void)
* If they try to open a connection for a module that
* is not loaded they'll get a suitable error at that point
*/
+# ifdef WITH_TEST
virDriverLoadModule("test");
+# endif
+# ifdef WITH_XEN
virDriverLoadModule("xen");
+# endif
+# ifdef WITH_OPENVZ
virDriverLoadModule("openvz");
+# endif
+# ifdef WITH_VBOX
virDriverLoadModule("vbox");
+# endif
+# ifdef WITH_ESX
virDriverLoadModule("esx");
+# endif
+# ifdef WITH_XENAPI
virDriverLoadModule("xenapi");
+# endif
+# ifdef WITH_REMOTE
virDriverLoadModule("remote");
+# endif
#else
# ifdef WITH_TEST
if (testRegister() == -1) return -1;
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 301b0ef..73c3492 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -3,6 +3,10 @@
# more details.
#
+# authhelper.h
+virRequestUsername;
+virRequestPassword;
+
# bitmap.h
virBitmapAlloc;
@@ -21,6 +25,8 @@ virBufferContentAndReset;
virBufferError;
virBufferURIEncodeString;
virBufferFreeAndReset;
+virBufferUse;
+virBufferStrcat;
# caps.h
@@ -146,8 +152,12 @@ virDomainDiskInsert;
virDomainDiskInsertPreAlloced;
virDomainDiskRemove;
virDomainDiskDefAssignAddress;
+virDomainDiskTypeToString;
+virDomainDiskTypeFromString;
virDomainControllerInsert;
virDomainControllerInsertPreAlloced;
+virDomainControllerModelTypeFromString;
+virDomainControllerModelTypeToString;
virDomainFindByID;
virDomainFindByName;
virDomainFindByUUID;
@@ -161,6 +171,8 @@ virDomainHostdevSubsysTypeToString;
virDomainInputDefFree;
virDomainLifecycleTypeFromString;
virDomainLifecycleTypeToString;
+virDomainLifecycleCrashTypeFromString;
+virDomainLifecycleCrashTypeToString;
virDomainLoadAllConfigs;
virDomainNetDefFree;
virDomainNetTypeToString;
@@ -225,11 +237,17 @@ virDomainSnapshotHasChildren;
virDomainSnapshotObjUnref;
virDomainSnapshotDefParseString;
virDomainSnapshotDefFormat;
+virDomainSnapshotDefFree;
virDomainSnapshotAssignDef;
virDomainObjAssignDef;
virDomainChrDefForeach;
virDomainDiskDefForeachPath;
virDomainChrConsoleTargetTypeToString;
+virDomainChrConsoleTargetTypeFromString;
+virDomainChrTcpProtocolTypeToString;
+virDomainChrTcpProtocolTypeFromString;
+virDomainDiskCacheTypeToString;
+virDomainDiskCacheTypeFromString;
# domain_event.h
@@ -276,6 +294,11 @@ virDomainConfNWFilterInstantiate;
virDomainConfNWFilterTeardown;
virDomainConfVMNWFilterTeardown;
+
+# driver.h
+virDriverLoadModule;
+
+
# ebtables.h
ebtablesAddForwardAllowIn;
ebtablesAddForwardPolicyReject;
@@ -503,6 +526,8 @@ virNodeDeviceDefFree;
virNodeDevCapsDefFree;
virNodeDeviceDefFormat;
virNodeDeviceDefParseString;
+virNodeDeviceDefParseNode;
+virNodeDeviceDefParseFile;
virNodeDeviceObjLock;
virNodeDeviceObjUnlock;
virNodeDeviceAssignDef;
@@ -644,6 +669,7 @@ virStorageFileIsSharedFS;
# threads.h
virMutexInit;
+virMutexInitRecursive;
virMutexDestroy;
virMutexLock;
virMutexUnlock;
@@ -698,6 +724,7 @@ virParseVersionString;
virPipeReadUntilEOF;
virAsprintf;
virRun;
+virRunWithHook;
virSkipSpaces;
virKillProcess;
virGetUserDirectory;
@@ -708,6 +735,18 @@ virFileFindMountPoint;
virFileWaitForDevices;
virFileMatchesNameSuffix;
virArgvToString;
+virStrcpy;
+virStrncpy;
+virBuildPathInternal;
+virFileStripSuffix;
+virFileOperation;
+virFork;
+virRandom;
+virRandomInitialize;
+virDirCreate;
+virIndexToDiskName;
+virHexToBin;
+
# interface.h
ifaceCtrl;
@@ -732,6 +771,12 @@ virUUIDParse;
virSetHostUUIDStr;
virGetHostUUID;
+# virtaudit.h
+virAuditClose;
+virAuditLog;
+virAuditOpen;
+virAuditSend;
+
# virterror_internal.h
virReportErrorHelper;
--
1.7.2.3