[PATCH 3/3] vbox: Register per partes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Since times when vbox moved to the daemon (due to some licensing
issue) the subdrivers that vbox implements were registered, but not
opened since our generic subdrivers took priority. I've tried to fix
this in 65b7d553f39ff9 but it was not correct. Apparently moving
vbox driver registration upfront changes the default connection URI
which makes some users sad. So, this commit breaks vbox into pieces
and register vbox's network and storage drivers first, and vbox driver
then at the end. This way, the vbox driver is registered in the order
it always was, but its subdrivers are registered prior the generic
ones.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 daemon/libvirtd.c      | 16 ++++++++++++++--
 src/Makefile.am        | 41 ++++++++++++++++++++++++++++++++++++++---
 src/vbox/vbox_driver.c | 50 +++++++++++++++++++++++++++++++++++++++++++++-----
 src/vbox/vbox_driver.h | 10 ++++++++++
 4 files changed, 107 insertions(+), 10 deletions(-)

diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index 4cf78e6..c3bd2ab 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -383,7 +383,7 @@ static void daemonInitialize(void)
      * is not loaded they'll get a suitable error at that point
      */
 # ifdef WITH_VBOX
-    virDriverLoadModule("vbox");
+    virDriverLoadModule("vbox_network");
 # endif
 # ifdef WITH_NETWORK
     virDriverLoadModule("network");
@@ -391,6 +391,9 @@ static void daemonInitialize(void)
 # ifdef WITH_INTERFACE
     virDriverLoadModule("interface");
 # endif
+# ifdef WITH_VBOX
+    virDriverLoadModule("vbox_storage");
+# endif
 # ifdef WITH_STORAGE
     virDriverLoadModule("storage");
 # endif
@@ -418,12 +421,15 @@ static void daemonInitialize(void)
 # ifdef WITH_UML
     virDriverLoadModule("uml");
 # endif
+# ifdef WITH_VBOX
+    virDriverLoadModule("vbox");
+# endif
 # ifdef WITH_BHYVE
     virDriverLoadModule("bhyve");
 # endif
 #else
 # ifdef WITH_VBOX
-    vboxRegister();
+    vboxNetworkRegister();
 # endif
 # ifdef WITH_NETWORK
     networkRegister();
@@ -431,6 +437,9 @@ static void daemonInitialize(void)
 # ifdef WITH_INTERFACE
     interfaceRegister();
 # endif
+# ifdef WITH_VBOX
+    vboxStorageRegister();
+# endif
 # ifdef WITH_STORAGE
     storageRegister();
 # endif
@@ -458,6 +467,9 @@ static void daemonInitialize(void)
 # ifdef WITH_UML
     umlRegister();
 # endif
+# ifdef WITH_VBOX
+    vboxRegister();
+# endif
 # ifdef WITH_BHYVE
     bhyveRegister();
 # endif
diff --git a/src/Makefile.am b/src/Makefile.am
index 538530e..46e411e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1135,13 +1135,27 @@ libvirt_driver_vmware_la_SOURCES = $(VMWARE_DRIVER_SOURCES)
 endif WITH_VMWARE
 
 if WITH_VBOX
-noinst_LTLIBRARIES += libvirt_driver_vbox_impl.la
+noinst_LTLIBRARIES += \
+		libvirt_driver_vbox_impl.la	\
+		libvirt_driver_vbox_network_impl.la	\
+		libvirt_driver_vbox_storage_impl.la
 libvirt_driver_vbox_la_SOURCES =
 libvirt_driver_vbox_la_LIBADD = libvirt_driver_vbox_impl.la
+libvirt_driver_vbox_network_la_SOURCES =
+libvirt_driver_vbox_network_la_LIBADD = libvirt_driver_vbox_network_impl.la
+libvirt_driver_vbox_storage_la_SOURCES =
+libvirt_driver_vbox_storage_la_LIBADD = libvirt_driver_vbox_storage_impl.la
 if WITH_DRIVER_MODULES
-mod_LTLIBRARIES += libvirt_driver_vbox.la
+mod_LTLIBRARIES += \
+		libvirt_driver_vbox.la	\
+		libvirt_driver_vbox_network.la	\
+		libvirt_driver_vbox_storage.la
 libvirt_driver_vbox_la_LIBADD += ../gnulib/lib/libgnu.la
 libvirt_driver_vbox_la_LDFLAGS = -module -avoid-version $(AM_LDFLAGS)
+libvirt_driver_vbox_network_la_LIBADD += ../gnulib/lib/libgnu.la
+libvirt_driver_vbox_network_la_LDFLAGS = -module -avoid-version $(AM_LDFLAGS)
+libvirt_driver_vbox_storage_la_LIBADD += ../gnulib/lib/libgnu.la
+libvirt_driver_vbox_storage_la_LDFLAGS = -module -avoid-version $(AM_LDFLAGS)
 else ! WITH_DRIVER_MODULES
 noinst_LTLIBRARIES += libvirt_driver_vbox.la
 # GPLv2-only license requries that it be linked into
@@ -1151,12 +1165,33 @@ endif ! WITH_DRIVER_MODULES
 
 libvirt_driver_vbox_impl_la_CFLAGS =				\
 		-I$(top_srcdir)/src/conf			\
-		$(AM_CFLAGS)
+		$(AM_CFLAGS)	\
+		-DVBOX_DRIVER
 libvirt_driver_vbox_impl_la_LDFLAGS = $(AM_LDFLAGS)
 libvirt_driver_vbox_impl_la_LIBADD =  $(DLOPEN_LIBS)		\
 		$(MSCOM_LIBS)					\
 		$(LIBXML_LIBS)
 libvirt_driver_vbox_impl_la_SOURCES = $(VBOX_DRIVER_SOURCES)
+
+libvirt_driver_vbox_network_impl_la_CFLAGS =	\
+		-I$(top_srcdir)/src/conf	\
+		$(AM_CFLAGS)	\
+		-DVBOX_NETWORK_DRIVER
+libvirt_driver_vbox_network_impl_la_LDFLAGS = $(AM_LDFLAGS)
+libvirt_driver_vbox_network_impl_la_LIBADD = $(DLOPEN_LIBS)		\
+		$(MSCOM_LIBS)					\
+		$(LIBXML_LIBS)
+libvirt_driver_vbox_network_impl_la_SOURCES = $(VBOX_DRIVER_SOURCES)
+
+libvirt_driver_vbox_storage_impl_la_CFLAGS =	\
+		-I$(top_srcdir)/src/conf	\
+		$(AM_CFLAGS)	\
+		-DVBOX_STORAGE_DRIVER
+libvirt_driver_vbox_storage_impl_la_LDFLAGS = $(AM_LDFLAGS)
+libvirt_driver_vbox_storage_impl_la_LIBADD = $(DLOPEN_LIBS)		\
+		$(MSCOM_LIBS)					\
+		$(LIBXML_LIBS)
+libvirt_driver_vbox_storage_impl_la_SOURCES = $(VBOX_DRIVER_SOURCES)
 endif WITH_VBOX
 
 if WITH_XENAPI
diff --git a/src/vbox/vbox_driver.c b/src/vbox/vbox_driver.c
index 498be71..d33f78f 100644
--- a/src/vbox/vbox_driver.c
+++ b/src/vbox/vbox_driver.c
@@ -75,12 +75,15 @@ static virDriver vboxDriverDummy;
 
 #define VIR_FROM_THIS VIR_FROM_VBOX
 
-int vboxRegister(void)
+static void
+vboxGetDrivers(virDriverPtr *driver_ret,
+               virNetworkDriverPtr *networkDriver_ret,
+               virStorageDriverPtr *storageDriver_ret)
 {
-    virDriverPtr        driver;
+    virDriverPtr driver;
     virNetworkDriverPtr networkDriver;
     virStorageDriverPtr storageDriver;
-    uint32_t            uVersion;
+    uint32_t uVersion;
 
     /*
      * If the glue layer does not initialize, we register a driver
@@ -157,15 +160,52 @@ int vboxRegister(void)
         VIR_DEBUG("VBoxCGlueInit failed, using dummy driver");
     }
 
-    if (virRegisterDriver(driver) < 0)
-        return -1;
+    if (driver_ret)
+        *driver_ret = driver;
+    if (networkDriver_ret)
+        *networkDriver_ret = networkDriver;
+    if (storageDriver_ret)
+        *storageDriver_ret = storageDriver;
+}
+
+
+#if !defined(WITH_DRIVER_MODULES) || defined(VBOX_NETWORK_DRIVER)
+int vboxNetworkRegister(void)
+{
+    virNetworkDriverPtr networkDriver;
+
+    vboxGetDrivers(NULL, &networkDriver, NULL);
     if (virRegisterNetworkDriver(networkDriver) < 0)
         return -1;
+    return 0;
+}
+#endif
+
+#if !defined(WITH_DRIVER_MODULES) || defined(VBOX_STORAGE_DRIVER)
+int vboxStorageRegister(void)
+{
+    virStorageDriverPtr storageDriver;
+
+    vboxGetDrivers(NULL, NULL, &storageDriver);
+
     if (virRegisterStorageDriver(storageDriver) < 0)
         return -1;
+    return 0;
+}
+#endif
+
+#if !defined(WITH_DRIVER_MODULES) || defined(VBOX_DRIVER)
+int vboxRegister(void)
+{
+    virDriverPtr driver;
+
+    vboxGetDrivers(&driver, NULL, NULL);
 
+    if (virRegisterDriver(driver) < 0)
+        return -1;
     return 0;
 }
+#endif
 
 static virDrvOpenStatus dummyConnectOpen(virConnectPtr conn,
                                          virConnectAuthPtr auth ATTRIBUTE_UNUSED,
diff --git a/src/vbox/vbox_driver.h b/src/vbox/vbox_driver.h
index 399e4c6..ccd331a 100644
--- a/src/vbox/vbox_driver.h
+++ b/src/vbox/vbox_driver.h
@@ -31,6 +31,16 @@
 
 # include "internal.h"
 
+# if !defined(WITH_DRIVER_MODULES) || defined(VBOX_NETWORK_DRIVER)
+int vboxNetworkRegister(void);
+# endif
+
+# if !defined(WITH_DRIVER_MODULES) || defined(VBOX_STORAGE_DRIVER)
+int vboxStorageRegister(void);
+# endif
+
+# if !defined(WITH_DRIVER_MODULES) || defined(VBOX_DRIVER)
 int vboxRegister(void);
+# endif
 
 #endif
-- 
1.8.5.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]