[libvirt] [PATCH] Fix several undefined symbol errors in loadable driver modules

Link all loadable driver modules to libvirt.la and libgnu.la. Add several missing symbols to libvirt_private.syms in order to have them properly exported. --- src/Makefile.am | 25 ++++++++++++++++++++++--- src/libvirt_private.syms | 25 +++++++++++++++++++++++++ tests/Makefile.am | 6 +++++- 3 files changed, 52 insertions(+), 4 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index ece18a6..588adf5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -456,6 +456,7 @@ libvirt_driver_test_la_CFLAGS = \ -I@top_srcdir@/src/conf if WITH_DRIVER_MODULES libvirt_driver_test_la_LDFLAGS = -module -avoid-version +libvirt_driver_test_la_LIBADD = libvirt.la ../gnulib/lib/libgnu.la endif libvirt_driver_test_la_SOURCES = $(TEST_DRIVER_SOURCES) endif @@ -475,6 +476,7 @@ libvirt_driver_remote_la_LDFLAGS = libvirt_driver_remote_la_LIBADD = $(GNUTLS_LIBS) $(SASL_LIBS) if WITH_DRIVER_MODULES libvirt_driver_remote_la_LDFLAGS += -module -avoid-version +libvirt_driver_remote_la_LIBADD += libvirt.la ../gnulib/lib/libgnu.la endif libvirt_driver_remote_la_SOURCES = $(REMOTE_DRIVER_SOURCES) @@ -525,6 +527,7 @@ libvirt_driver_xen_la_LDFLAGS = libvirt_driver_xen_la_LIBADD = $(XEN_LIBS) if WITH_DRIVER_MODULES libvirt_driver_xen_la_LDFLAGS += -module -avoid-version +libvirt_driver_xen_la_LIBADD += libvirt.la ../gnulib/lib/libgnu.la endif libvirt_driver_xen_la_SOURCES = $(XEN_DRIVER_SOURCES) endif @@ -539,6 +542,10 @@ endif libvirt_driver_phyp_la_LIBADD = $(LIBSSH2_LIBS) libvirt_driver_phyp_la_CFLAGS = $(LIBSSH2_CFLAGS) \ -I@top_srcdir@/src/conf +if WITH_DRIVER_MODULES +libvirt_driver_phyp_la_LDFLAGS = -module -avoid-version +libvirt_driver_phyp_la_LIBADD += libvirt.la ../gnulib/lib/libgnu.la +endif libvirt_driver_phyp_la_SOURCES = $(PHYP_DRIVER_SOURCES) endif @@ -553,6 +560,7 @@ libvirt_driver_openvz_la_CFLAGS = \ -I@top_srcdir@/src/conf if WITH_DRIVER_MODULES libvirt_driver_openvz_la_LDFLAGS = -module -avoid-version +libvirt_driver_openvz_la_LIBADD = libvirt.la ../gnulib/lib/libgnu.la endif libvirt_driver_openvz_la_SOURCES = $(OPENVZ_DRIVER_SOURCES) endif @@ -566,10 +574,11 @@ libvirt_la_BUILT_LIBADD += libvirt_driver_vbox.la endif libvirt_driver_vbox_la_CFLAGS = \ -I@top_srcdir@/src/conf +libvirt_driver_vbox_la_LIBADD = $(DLOPEN_LIBS) if WITH_DRIVER_MODULES libvirt_driver_vbox_la_LDFLAGS = -module -avoid-version +libvirt_driver_vbox_la_LIBADD += libvirt.la ../gnulib/lib/libgnu.la endif -libvirt_driver_vbox_la_LIBADD = $(DLOPEN_LIBS) libvirt_driver_vbox_la_SOURCES = $(VBOX_DRIVER_SOURCES) endif @@ -586,6 +595,7 @@ libvirt_driver_xenapi_la_LDFLAGS = libvirt_driver_xenapi_la_LIBADD = $(LIBXENSERVER_LIBS) $(LIBCURL_LIBS) if WITH_DRIVER_MODULES libvirt_driver_xenapi_la_LDFLAGS += -module -avoid-version +libvirt_driver_xenapi_la_LIBADD += libvirt.la ../gnulib/lib/libgnu.la endif libvirt_driver_xenapi_la_SOURCES = $(XENAPI_DRIVER_SOURCES) endif @@ -604,6 +614,7 @@ libvirt_driver_qemu_la_LDFLAGS = libvirt_driver_qemu_la_LIBADD = $(NUMACTL_LIBS) if WITH_DRIVER_MODULES libvirt_driver_qemu_la_LDFLAGS += -module -avoid-version +libvirt_driver_qemu_la_LIBADD += libvirt.la ../gnulib/lib/libgnu.la endif libvirt_driver_qemu_la_SOURCES = $(QEMU_DRIVER_SOURCES) @@ -629,6 +640,7 @@ libvirt_driver_lxc_la_CFLAGS = \ -I@top_srcdir@/src/conf if WITH_DRIVER_MODULES libvirt_driver_lxc_la_LDFLAGS = -module -avoid-version +libvirt_driver_lxc_la_LIBADD = libvirt.la ../gnulib/lib/libgnu.la endif libvirt_driver_lxc_la_SOURCES = $(LXC_DRIVER_SOURCES) @@ -654,6 +666,7 @@ libvirt_driver_uml_la_LDFLAGS = libvirt_driver_uml_la_LIBADD = $(NUMACTL_LIBS) if WITH_DRIVER_MODULES libvirt_driver_uml_la_LDFLAGS += -module -avoid-version +libvirt_driver_uml_la_LIBADD += libvirt.la ../gnulib/lib/libgnu.la endif libvirt_driver_uml_la_SOURCES = $(UML_DRIVER_SOURCES) endif @@ -673,6 +686,7 @@ libvirt_driver_one_la_LIBADD = $(XMLRPC_LIBS) #libvirt_driver_one_la_CFLAGS = "-DWITH_ONE" if WITH_DRIVER_MODULES libvirt_driver_one_la_LDFLAGS += -module -avoid-version +libvirt_driver_one_la_LIBADD += libvirt.la ../gnulib/lib/libgnu.la endif libvirt_driver_one_la_SOURCES = $(ONE_DRIVER_SOURCES) endif @@ -696,6 +710,7 @@ libvirt_driver_esx_la_LDFLAGS = libvirt_driver_esx_la_LIBADD = $(LIBCURL_LIBS) if WITH_DRIVER_MODULES libvirt_driver_esx_la_LDFLAGS += -module -avoid-version +libvirt_driver_esx_la_LIBADD += libvirt.la ../gnulib/lib/libgnu.la endif libvirt_driver_esx_la_SOURCES = $(ESX_DRIVER_SOURCES) libvirt_driver_esx_la_DEPENDENCIES = $(ESX_DRIVER_GENERATED) @@ -713,6 +728,7 @@ libvirt_driver_network_la_CFLAGS = \ -I@top_srcdir@/src/conf if WITH_DRIVER_MODULES libvirt_driver_network_la_LDFLAGS = -module -avoid-version +libvirt_driver_network_la_LIBADD = libvirt.la ../gnulib/lib/libgnu.la endif libvirt_driver_network_la_SOURCES = $(NETWORK_DRIVER_SOURCES) endif @@ -734,6 +750,7 @@ libvirt_driver_interface_la_LDFLAGS = libvirt_driver_interface_la_LIBADD = $(NETCF_LIBS) if WITH_DRIVER_MODULES libvirt_driver_interface_la_LDFLAGS += -module -avoid-version +libvirt_driver_interface_la_LIBADD += libvirt.la ../gnulib/lib/libgnu.la endif libvirt_driver_interface_la_SOURCES = $(INTERFACE_DRIVER_SOURCES) endif @@ -750,7 +767,7 @@ libvirt_driver_secret_la_CFLAGS = \ -I@top_srcdir@/src/conf if WITH_DRIVER_MODULES libvirt_driver_secret_la_LDFLAGS = -module -avoid-version -libvirt_driver_secret_la_LIBADD = ../gnulib/lib/libgnu.la +libvirt_driver_secret_la_LIBADD = libvirt.la ../gnulib/lib/libgnu.la endif libvirt_driver_secret_la_SOURCES = $(SECRET_DRIVER_SOURCES) endif @@ -771,6 +788,7 @@ noinst_LTLIBRARIES += libvirt_driver_storage.la endif if WITH_DRIVER_MODULES libvirt_driver_storage_la_LDFLAGS += -module -avoid-version +libvirt_driver_storage_la_LIBADD += libvirt.la ../gnulib/lib/libgnu.la endif libvirt_driver_storage_la_SOURCES += $(STORAGE_DRIVER_SOURCES) libvirt_driver_storage_la_SOURCES += $(STORAGE_DRIVER_FS_SOURCES) @@ -826,6 +844,7 @@ endif if WITH_DRIVER_MODULES libvirt_driver_nodedev_la_LDFLAGS += -module -avoid-version +libvirt_driver_nodedev_la_LIBADD += libvirt.la ../gnulib/lib/libgnu.la endif endif @@ -843,7 +862,7 @@ libvirt_driver_nwfilter_la_LDFLAGS = 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_LIBADD += libvirt.la ../gnulib/lib/libgnu.la endif libvirt_driver_nwfilter_la_SOURCES = $(NWFILTER_DRIVER_SOURCES) endif diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 4e61e55..b6d36a2 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -4,6 +4,11 @@ # +# authhelper.h +virRequestUsername; +virRequestPassword; + + # bitmap.h virBitmapAlloc; virBitmapFree; @@ -17,6 +22,8 @@ virBufferVSprintf; virBufferEscapeString; virBufferAdd; virBufferAddChar; +virBufferStrcat; +virBufferUse; virBufferContentAndReset; virBufferError; virBufferURIEncodeString; @@ -139,7 +146,9 @@ virDomainDeleteConfig; virDomainDeviceDefFree; virDomainDeviceDefParse; virDomainDeviceTypeToString; +virDomainDiskTypeToString; virDomainDiskBusTypeToString; +virDomainDiskCacheTypeToString; virDomainDiskDefFree; virDomainDiskDeviceTypeToString; virDomainDiskInsert; @@ -222,6 +231,7 @@ virDomainSnapshotHasChildren; virDomainSnapshotObjUnref; virDomainSnapshotDefParseString; virDomainSnapshotDefFormat; +virDomainSnapshotDefFree; virDomainSnapshotAssignDef; virDomainObjAssignDef; @@ -494,6 +504,8 @@ virNodeDeviceObjListFree; virNodeDeviceDefFree; virNodeDevCapsDefFree; virNodeDeviceDefFormat; +virNodeDeviceDefParseFile; +virNodeDeviceDefParseNode; virNodeDeviceDefParseString; virNodeDeviceObjLock; virNodeDeviceObjUnlock; @@ -633,6 +645,7 @@ virStorageFileIsSharedFS; # threads.h virMutexInit; +virMutexInitRecursive; virMutexDestroy; virMutexLock; virMutexUnlock; @@ -645,13 +658,20 @@ virCondSignal; virCondBroadcast; # util.h +virBuildPathInternal; +virDirCreate; +virFileOperation; virFileReadAll; virFileWriteStr; +virFileStripSuffix; +virFork; virStrToLong_i; virStrToLong_ll; virStrToLong_ull; virStrToLong_ui; virStrToDouble; +virStrcpy; +virStrncpy; virFileLinkPointsTo; virFileResolveLink; saferead; @@ -687,6 +707,7 @@ virParseVersionString; virPipeReadUntilEOF; virAsprintf; virRun; +virRunWithHook; virSkipSpaces; virKillProcess; virGetUserDirectory; @@ -697,6 +718,10 @@ virFileFindMountPoint; virFileWaitForDevices; virFileMatchesNameSuffix; virArgvToString; +virRandom; +virRandomInitialize; +virIndexToDiskName; + # interface.h ifaceCtrl; diff --git a/tests/Makefile.am b/tests/Makefile.am index a3661f6..a6a8fea 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -39,6 +39,10 @@ LDADDS = \ $(LIBSOCKET) \ $(COVERAGE_LDFLAGS) +if WITH_DRIVER_MODULES +LDADDS += ../src/libvirt.la +endif + EXTRA_DIST = \ oomtrace.pl \ test-lib.sh \ @@ -329,7 +333,7 @@ nodeinfotest_LDADD = $(LDADDS) statstest_SOURCES = \ statstest.c testutils.h testutils.c -statstest_LDADD = $(LDADDS) +statstest_LDADD = ../src/libvirt_driver_xen.la $(LDADDS) if WITH_SECDRIVER_SELINUX seclabeltest_SOURCES = \ -- 1.7.0.4

On Wed, Jun 23, 2010 at 12:33:54PM +0200, Matthias Bolte wrote:
Link all loadable driver modules to libvirt.la and libgnu.la.
Add several missing symbols to libvirt_private.syms in order to have them properly exported. --- src/Makefile.am | 25 ++++++++++++++++++++++--- src/libvirt_private.syms | 25 +++++++++++++++++++++++++ tests/Makefile.am | 6 +++++- 3 files changed, 52 insertions(+), 4 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am index ece18a6..588adf5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -456,6 +456,7 @@ libvirt_driver_test_la_CFLAGS = \ -I@top_srcdir@/src/conf if WITH_DRIVER_MODULES libvirt_driver_test_la_LDFLAGS = -module -avoid-version +libvirt_driver_test_la_LIBADD = libvirt.la ../gnulib/lib/libgnu.la
I don't think it is right to link to libvirt.la here or with other driver modules. The libvirtd daemon links to libvirt.la already, and is built such that all exported symbols are available to modules that are dlopen()d Thus it should be sufficient to add symbols to libvirt_private.syms and not link to libvirt.la in driver modules. It might still be neccessary to link to libgnu.la because that is statically linked into libvirtd and thus only gets symbols that libvirtd needs. The modules might need further symbols from libgnu.la so its reasonable to link to it directly. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On 06/23/2010 12:50 PM, Daniel P. Berrange wrote:
libvirt_driver_test_la_LDFLAGS = -module -avoid-version +libvirt_driver_test_la_LIBADD = libvirt.la ../gnulib/lib/libgnu.la I don't think it is right to link to libvirt.la here or with other driver modules.
The libvirtd daemon links to libvirt.la already, and is built such that all exported symbols are available to modules that are dlopen()d Thus it should be sufficient to add symbols to libvirt_private.syms and not link to libvirt.la in driver modules.
I don't think that works on Windows. Windows DLLs must not have undefined symbols. They do not get "magic" access to symbols exported by previously loaded libraries and (as in this case) programs. Paolo

On Wed, Jun 23, 2010 at 01:08:40PM +0200, Paolo Bonzini wrote:
On 06/23/2010 12:50 PM, Daniel P. Berrange wrote:
libvirt_driver_test_la_LDFLAGS = -module -avoid-version +libvirt_driver_test_la_LIBADD = libvirt.la ../gnulib/lib/libgnu.la I don't think it is right to link to libvirt.la here or with other driver modules.
The libvirtd daemon links to libvirt.la already, and is built such that all exported symbols are available to modules that are dlopen()d Thus it should be sufficient to add symbols to libvirt_private.syms and not link to libvirt.la in driver modules.
I don't think that works on Windows. Windows DLLs must not have undefined symbols. They do not get "magic" access to symbols exported by previously loaded libraries and (as in this case) programs.
libtool can get around that limitation if you use its libltdl library, but to be honest I don't really care very mcuh. Ee don't even build libvirtd on windows currently, and even if we did, it isn't a show stopper to just build libvirtd in the traditional way without using the dlopen support. Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

On 06/23/2010 01:13 PM, Daniel P. Berrange wrote:
On Wed, Jun 23, 2010 at 01:08:40PM +0200, Paolo Bonzini wrote:
On 06/23/2010 12:50 PM, Daniel P. Berrange wrote:
libvirt_driver_test_la_LDFLAGS = -module -avoid-version +libvirt_driver_test_la_LIBADD = libvirt.la ../gnulib/lib/libgnu.la
I don't think it is right to link to libvirt.la here or with other driver modules.
The libvirtd daemon links to libvirt.la already, and is built such that all exported symbols are available to modules that are dlopen()d Thus it should be sufficient to add symbols to libvirt_private.syms and not link to libvirt.la in driver modules.
I don't think that works on Windows. Windows DLLs must not have undefined symbols. They do not get "magic" access to symbols exported by previously loaded libraries and (as in this case) programs.
libtool can get around that limitation if you use its libltdl library,
Too painful to be useful. :)
but to be honest I don't really care very mcuh. Ee don't even build libvirtd on windows currently, and even if we did, it isn't a show stopper to just build libvirtd in the traditional way without using the dlopen support.
Agreed. Paolo

2010/6/23 Daniel P. Berrange <berrange@redhat.com>:
On Wed, Jun 23, 2010 at 12:33:54PM +0200, Matthias Bolte wrote:
Link all loadable driver modules to libvirt.la and libgnu.la.
Add several missing symbols to libvirt_private.syms in order to have them properly exported. --- src/Makefile.am | 25 ++++++++++++++++++++++--- src/libvirt_private.syms | 25 +++++++++++++++++++++++++ tests/Makefile.am | 6 +++++- 3 files changed, 52 insertions(+), 4 deletions(-)
diff --git a/src/Makefile.am b/src/Makefile.am index ece18a6..588adf5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -456,6 +456,7 @@ libvirt_driver_test_la_CFLAGS = \ -I@top_srcdir@/src/conf if WITH_DRIVER_MODULES libvirt_driver_test_la_LDFLAGS = -module -avoid-version +libvirt_driver_test_la_LIBADD = libvirt.la ../gnulib/lib/libgnu.la
I don't think it is right to link to libvirt.la here or with other driver modules.
The libvirtd daemon links to libvirt.la already, and is built such that all exported symbols are available to modules that are dlopen()d Thus it should be sufficient to add symbols to libvirt_private.syms and not link to libvirt.la in driver modules.
It might still be neccessary to link to libgnu.la because that is statically linked into libvirtd and thus only gets symbols that libvirtd needs. The modules might need further symbols from libgnu.la so its reasonable to link to it directly.
Hm, you're right. I just tested it and I don't need to link to libvirt.la in order to have libvirtd and virsh work properly. But virt-manager or just importing the libvirt python module fails with undefined symbol error for symbols that are listed in libvirt_private.syms. I'll have to investigate more. Matthias
participants (3)
-
Daniel P. Berrange
-
Matthias Bolte
-
Paolo Bonzini