[libvirt] PATCH: 10/11: Build stateful drivers into libvirtd instead of libvirt.so

Daniel P. Berrange berrange at redhat.com
Thu Oct 30 13:42:19 UTC 2008


This patches changes the way some of the drivers are built. Specifically
the stateful drivers (QEMU, LXC, Network and Storage) are no longer
compiled into libvirt.so Instead they are linked directly to the libvirt
binary. They could only ever be executed as part of the daemon, and we had
code checks to ensure this, so this just makes it sane at build time.

More importantly this is required for David Lively's host device support.
That support uses HAL, which uses DBus, which is GPL/AFL licensed. As
such we cannot ever link HAL/DBus against libvirt.so without loosing
our LGPL status. With this patch, HAL/DBus bits will only ever be linked
into the libvirtd daemon binary, so there is no LGPL compat problems in
libvirt.so

The changes this patch does are fairly simple

 - qemud/Makefile.am - add the libtool convenience libraries for qemu,
   lxc, storage and network drivers to libvirtd
 - src/Makefile.am - remove the libtool convenience libraries for
   qemu, lxc, storage & network drivers from libvirt.la
 - src/libvirt.c: Do not invoke the register methods for qemu, lxc,
   storage or network drivers in virInitialize()
 - qemud/qemud.c: Invoke the register methods for qemu, lxc, storage
   and network drivers after first calling virInitialize()
 - libvirt_sym.version.in: add all the internal symbols needed to be
   exported for qemu, lxc, storage & network drivers

The end result here is functionally identical to before, with one
annoying exception. If you passed a 'NULL' uri to virConnectOpen
it would manually probe each driver to find a suitable URI. Since
QEMU, LXC drivers are not in libvirt.so anymore this probing
ceases to work.

I've not figured out best way to deal with this yet. One option is
to not actually move the drivers out of libvirt.so at all. Just do
it for the forthcoming node devices driver. ANother option is to just
have a tiny QEMU/LXC stub driver in libvirt.so solely containing the
probe() code. A further option is to make the remote driver implement
the probe() method, so it actally talks to libvirtd and asks that
for a probed URI.

 qemud/Makefile.am          |   20 +++++
 qemud/qemud.c              |   29 +++++++
 src/Makefile.am            |   13 ++-
 src/libvirt.c              |   22 -----
 src/libvirt_sym.version.in |  168 +++++++++++++++++++++++++++++++++++++++++++++
 tests/Makefile.am          |    4 -
 6 files changed, 227 insertions(+), 29 deletions(-)


Daniel

diff -r f19d084a0d4f qemud/Makefile.am
--- a/qemud/Makefile.am	Thu Oct 30 10:46:21 2008 +0000
+++ b/qemud/Makefile.am	Thu Oct 30 11:04:27 2008 +0000
@@ -88,7 +88,25 @@
 	$(POLKIT_LIBS)
 
 libvirtd_DEPENDENCIES = ../src/libvirt.la
-libvirtd_LDADD = ../src/libvirt.la ../gnulib/lib/libgnu.la
+libvirtd_LDADD =					\
+		../gnulib/lib/libgnu.la			\
+		../src/libvirt.la
+
+if WITH_QEMU
+libvirtd_LDADD += ../src/libvirt_driver_qemu.la
+endif
+
+if WITH_LXC
+libvirtd_LDADD += ../src/libvirt_driver_lxc.la
+endif
+
+if WITH_STORAGE_DIR
+libvirtd_LDADD += ../src/libvirt_driver_storage.la
+endif
+
+if WITH_NETWORK
+libvirtd_LDADD += ../src/libvirt_driver_network.la
+endif
 
 if HAVE_POLKIT
 policydir = $(datadir)/PolicyKit/policy
diff -r f19d084a0d4f qemud/qemud.c
--- a/qemud/qemud.c	Thu Oct 30 10:46:21 2008 +0000
+++ b/qemud/qemud.c	Thu Oct 30 11:04:27 2008 +0000
@@ -60,6 +60,20 @@
 #ifdef HAVE_AVAHI
 #include "mdns.h"
 #endif
+
+#ifdef WITH_QEMU
+#include "qemu_driver.h"
+#endif
+#ifdef WITH_LXC
+#include "lxc_driver.h"
+#endif
+#ifdef WITH_NETWORK
+#include "network_driver.h"
+#endif
+#ifdef WITH_STORAGE_DIR
+#include "storage_driver.h"
+#endif
+
 
 static int godaemon = 0;        /* -d: Be a daemon */
 static int verbose = 0;         /* -v: Verbose mode */
@@ -727,6 +741,21 @@
     }
 
     server->sigread = sigread;
+
+    virInitialize();
+
+#ifdef WITH_QEMU
+    qemudRegister();
+#endif
+#ifdef WITH_LXC
+    lxcRegister();
+#endif
+#ifdef WITH_NETWORK
+    networkRegister();
+#endif
+#ifdef WITH_STORAGE_DIR
+    storageRegister();
+#endif
 
     virEventRegisterImpl(virEventAddHandleImpl,
                          virEventUpdateHandleImpl,
diff -r f19d084a0d4f src/Makefile.am
--- a/src/Makefile.am	Thu Oct 30 10:46:21 2008 +0000
+++ b/src/Makefile.am	Thu Oct 30 11:04:27 2008 +0000
@@ -195,7 +195,8 @@
 
 if WITH_QEMU
 noinst_LTLIBRARIES += libvirt_driver_qemu.la
-libvirt_la_LIBADD += libvirt_driver_qemu.la
+# Stateful, so linked to daemon instead
+#libvirt_la_LIBADD += libvirt_driver_qemu.la
 libvirt_driver_qemu_la_CFLAGS = $(NUMACTL_CFLAGS)
 libvirt_driver_qemu_la_LDFLAGS = $(NUMACTL_LIBS)
 libvirt_driver_qemu_la_SOURCES = $(QEMU_DRIVER_SOURCES)
@@ -203,14 +204,16 @@
 
 if WITH_LXC
 noinst_LTLIBRARIES += libvirt_driver_lxc.la
-libvirt_la_LIBADD += libvirt_driver_lxc.la
+# Stateful, so linked to daemon instead
+#libvirt_la_LIBADD += libvirt_driver_lxc.la
 libvirt_driver_lxc_la_SOURCES = $(LXC_DRIVER_SOURCES)
 endif
 
 
 if WITH_NETWORK
 noinst_LTLIBRARIES += libvirt_driver_network.la
-libvirt_la_LIBADD += libvirt_driver_network.la
+# Stateful, so linked to daemon instead
+#libvirt_la_LIBADD += libvirt_driver_network.la
 libvirt_driver_network_la_SOURCES = $(NETWORK_DRIVER_SOURCES)
 endif
 
@@ -218,7 +221,8 @@
 libvirt_driver_storage_la_SOURCES =
 if WITH_STORAGE_DIR
 noinst_LTLIBRARIES += libvirt_driver_storage.la
-libvirt_la_LIBADD += libvirt_driver_storage.la
+# Stateful, so linked to daemon instead
+#libvirt_la_LIBADD += libvirt_driver_storage.la
 libvirt_driver_storage_la_SOURCES += $(STORAGE_DRIVER_SOURCES)
 libvirt_driver_storage_la_SOURCES += $(STORAGE_DRIVER_FS_SOURCES)
 endif
@@ -260,6 +264,7 @@
                     $(COVERAGE_CFLAGS:-f%=-Wc,-f%) \
 		    @CYGWIN_EXTRA_LDFLAGS@ @MINGW_EXTRA_LDFLAGS@
 libvirt_la_CFLAGS = $(COVERAGE_CFLAGS) -DIN_LIBVIRT
+libvirt_la_DEPENDENCIES = $(libvirt_la_LIBADD) $(srcdir)/libvirt_sym.version
 
 # Create an automake "convenience library" version of libvirt_la,
 # just for testing, since the test harness requires access to internal
diff -r f19d084a0d4f src/libvirt.c
--- a/src/libvirt.c	Thu Oct 30 10:46:21 2008 +0000
+++ b/src/libvirt.c	Thu Oct 30 11:04:27 2008 +0000
@@ -49,18 +49,8 @@
 #ifdef WITH_REMOTE
 #include "remote_internal.h"
 #endif
-#ifdef WITH_QEMU
-#include "qemu_driver.h"
-#endif
 #ifdef WITH_OPENVZ
 #include "openvz_driver.h"
-#endif
-#ifdef WITH_LXC
-#include "lxc_driver.h"
-#endif
-#include "storage_driver.h"
-#ifdef WITH_NETWORK
-#include "network_driver.h"
 #endif
 
 /*
@@ -289,20 +279,8 @@
 #ifdef WITH_XEN
     if (xenUnifiedRegister () == -1) return -1;
 #endif
-#ifdef WITH_QEMU
-    if (qemudRegister() == -1) return -1;
-#endif
 #ifdef WITH_OPENVZ
     if (openvzRegister() == -1) return -1;
-#endif
-#ifdef WITH_LXC
-    if (lxcRegister() == -1) return -1;
-#endif
-#ifdef WITH_NETWORK
-    if (networkRegister() == -1) return -1;
-#endif
-#ifdef WITH_STORAGE_DIR
-    if (storageRegister() == -1) return -1;
 #endif
 #ifdef WITH_REMOTE
     if (remoteRegister () == -1) return -1;
diff -r f19d084a0d4f src/libvirt_sym.version.in
--- a/src/libvirt_sym.version.in	Thu Oct 30 10:46:21 2008 +0000
+++ b/src/libvirt_sym.version.in	Thu Oct 30 11:04:27 2008 +0000
@@ -257,6 +257,19 @@
 LIBVIRT_PRIVATE_ at VERSION@ {
 
   global:
+	/* bridge.h */
+	brAddBridge;
+	brAddInterface;
+	brAddTap;
+	brDeleteBridge;
+	brInit;
+	brSetEnableSTP;
+	brSetForwardDelay;
+	brSetInetAddress;
+	brSetInetNetmask;
+	brSetInterfaceUp;
+	brShutdown;
+
 
 	/* buf.h */
 	virBufferVSprintf;
@@ -264,6 +277,18 @@
 	virBufferAddChar;
 	virBufferContentAndReset;
 	virBufferError;
+
+
+	/* caps.h */
+	virCapabilitiesAddGuest;
+	virCapabilitiesAddGuestDomain;
+	virCapabilitiesAddGuestFeature;
+	virCapabilitiesAddHostNUMACell;
+	virCapabilitiesDefaultGuestEmulator;
+	virCapabilitiesFormatXML;
+	virCapabilitiesFree;
+	virCapabilitiesNew;
+	virCapabilitiesSetMacPrefix;
 
 
 	/* conf.h */
@@ -284,7 +309,62 @@
 	virGetStorageVol;
 
 
+	/* domain_conf.h */
+	virDiskNameToBusDeviceIndex;
+	virDiskNameToIndex;
+	virDomainAssignDef;
+	virDomainConfigFile;
+	virDomainDefDefaultEmulator;
+	virDomainDefFormat;
+	virDomainDefFree;
+	virDomainDefParseFile;
+	virDomainDefParseString;
+	virDomainDeleteConfig;
+	virDomainDeviceDefParse;
+	virDomainDiskBusTypeToString;
+	virDomainDiskDeviceTypeToString;
+	virDomainDiskQSort;
+	virDomainEventCallbackListAdd;
+	virDomainEventCallbackListFree;
+	virDomainEventCallbackListRemove;
+	virDomainFindByID;
+	virDomainFindByName;
+	virDomainFindByUUID;
+	virDomainLoadAllConfigs;
+	virDomainObjListFree;
+	virDomainRemoveInactive;
+	virDomainSaveConfig;
+	virDomainSoundModelTypeToString;
+	virDomainVirtTypeToString;
+
+
+	/* iptables.h */
+	iptablesAddForwardAllowCross;
+	iptablesAddForwardAllowIn;
+	iptablesAddForwardAllowOut;
+	iptablesAddForwardAllowRelatedIn;
+	iptablesAddForwardMasquerade;
+	iptablesAddForwardRejectIn;
+	iptablesAddForwardRejectOut;
+	iptablesAddTcpInput;
+	iptablesAddUdpInput;
+	iptablesContextFree;
+	iptablesContextNew;
+	iptablesReloadRules;
+	iptablesRemoveForwardAllowCross;
+	iptablesRemoveForwardAllowIn;
+	iptablesRemoveForwardAllowOut;
+	iptablesRemoveForwardAllowRelatedIn;
+	iptablesRemoveForwardMasquerade;
+	iptablesRemoveForwardRejectIn;
+	iptablesRemoveForwardRejectOut;
+	iptablesRemoveTcpInput;
+	iptablesRemoveUdpInput;
+	iptablesSaveRules;
+
+
 	/* libvirt_internal.h */
+	debugFlag;
 	virStateInitialize;
 	virStateCleanup;
 	virStateReload;
@@ -294,6 +374,10 @@
 	virDomainMigratePrepare;
 	virDomainMigratePerform;
 	virDomainMigrateFinish;
+	virRegisterDriver;
+	virRegisterNetworkDriver;
+	virRegisterStateDriver;
+	virRegisterStorageDriver;
 
 
 	/* memory.h */
@@ -303,13 +387,97 @@
 	virFree;
 
 
+	/* network_conf.h */
+	virNetworkAssignDef;
+	virNetworkDefFormat;
+	virNetworkDefFree;
+	virNetworkDefParseString;
+	virNetworkDeleteConfig;
+	virNetworkFindByName;
+	virNetworkFindByUUID;
+	virNetworkLoadAllConfigs;
+	virNetworkObjListFree;
+	virNetworkRemoveInactive;
+	virNetworkSaveConfig;
+
+
+	/* nodeinfo.h */
+	virNodeInfoPopulate;
+
+
+	/* stats_linux.h */
+	linuxDomainInterfaceStats;
+
+
+	/* storage_backend.h */
+	virStorageBackendForType;
+	virStorageBackendFromString;
+	virStorageBackendPartTableTypeFromString;
+	virStorageBackendPartTableTypeToString;
+	virStorageBackendRegister;
+	virStorageBackendRunProgNul;
+	virStorageBackendRunProgRegex;
+	virStorageBackendStablePath;
+	virStorageBackendUpdateVolInfo;
+	virStorageBackendUpdateVolInfoFD;
+
+
+	/* storage_conf.h */
+	virStoragePoolDefFormat;
+	virStoragePoolDefFree;
+	virStoragePoolDefParse;
+	virStoragePoolLoadAllConfigs;
+	virStoragePoolObjAssignDef;
+	virStoragePoolObjClearVols;
+	virStoragePoolObjDeleteDef;
+	virStoragePoolObjFindByName;
+	virStoragePoolObjFindByUUID;
+	virStoragePoolObjListFree;
+	virStoragePoolObjRemove;
+	virStoragePoolObjSaveDef;
+	virStoragePoolSourceFree;
+	virStoragePoolSourceListFormat;
+	virStorageVolDefFindByKey;
+	virStorageVolDefFindByName;
+	virStorageVolDefFindByPath;
+	virStorageVolDefFormat;
+	virStorageVolDefFree;
+	virStorageVolDefParse;
+
+
 	/* util.h */
 	virFileReadAll;
 	virStrToLong_i;
+	virStrToLong_ll;
 	virStrToLong_ull;
 	saferead;
 	safewrite;
 	virMacAddrCompare;
+	virEnumFromString;
+	virEnumToString;
+	virEventAddHandle;
+	virEventRemoveHandle;
+	virExec;
+	virFileDeletePid;
+	virFileExists;
+	virFileHasSuffix;
+	virFileMakePath;
+	virFileOpenTty;
+	virFileReadLimFD;
+	virFileReadPid;
+	virRun;
+
+
+	/* uuid.h */
+	virUUIDFormat;
+
+
+	/* virterror_internal.h */
+	virReportErrorHelper;
+
+
+	/* xml.h */
+	virXPathString;
 
 
 	/* Finally everything else is totally private */
diff -r f19d084a0d4f tests/Makefile.am
--- a/tests/Makefile.am	Thu Oct 30 10:46:21 2008 +0000
+++ b/tests/Makefile.am	Thu Oct 30 11:04:27 2008 +0000
@@ -107,12 +107,12 @@
 qemuxml2argvtest_SOURCES = \
 	qemuxml2argvtest.c testutilsqemu.c testutilsqemu.h \
 	testutils.c testutils.h
-qemuxml2argvtest_LDADD = $(LDADDS)
+qemuxml2argvtest_LDADD = ../src/libvirt_driver_qemu.la $(LDADDS)
 
 qemuxml2xmltest_SOURCES = \
 	qemuxml2xmltest.c testutilsqemu.c testutilsqemu.h \
 	testutils.c testutils.h
-qemuxml2xmltest_LDADD = $(LDADDS)
+qemuxml2xmltest_LDADD = ../src/libvirt_driver_qemu.la $(LDADDS)
 
 virshtest_SOURCES = \
 	virshtest.c \


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




More information about the libvir-list mailing list