[PATCH] daemon: Fix driver registration ordering

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

 



There are some stateless drivers which implement subdrivers
(typically vbox and its own network and storage subdrivers). However,
as of ba5f3c7c8ecc10 the vbox driver lives in the daemon, not the
client library. This means, in order for vbox (or any stateless domain
driver) to use its subdrivers, it must register before the general
drivers. Later, when the virConnectOpen function goes through the
subdrivers, stateless drivers are searched first. If the connection
request is aiming at stateless driver, it will be opened. Otherwise
the generic subdriver is opened.

The other change done in this commit is moving interface module load a
bit earlier to match the ordering in case libvirt is built without
driver modules.

Reported-by: Taowei Luo <uaedante@xxxxxxxxx>
Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 daemon/libvirtd.c | 31 ++++++++++++++++++-------------
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c
index a1f64ad..69baef6 100644
--- a/daemon/libvirtd.c
+++ b/daemon/libvirtd.c
@@ -365,10 +365,15 @@ static void daemonInitialize(void)
 {
     /*
      * Note that the order is important: the first ones have a higher
-     * priority when calling virStateInitialize. We must register
-     * the network, storage and nodedev drivers before any domain
-     * drivers, since their resources must be auto-started before
-     * any domains can be auto-started.
+     * priority when calling virStateInitialize. We must register the
+     * network, storage and nodedev drivers before any stateless
+     * domain drivers, since their resources must be auto-started
+     * before any domains can be auto-started. Moreover, some
+     * stateless drivers implement their own subdrivers (e.g. the vbox
+     * driver has its own network and storage subdriers) which need to
+     * have higher priority. Otherwise, when connecting the such
+     * driver generic subdriver may be opened instead of the one
+     * corresponding to the stateless driver.
      */
 #ifdef WITH_DRIVER_MODULES
     /* We don't care if any of these fail, because the whole point
@@ -376,9 +381,15 @@ static void daemonInitialize(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_VBOX
+    virDriverLoadModule("vbox");
+# endif
 # ifdef WITH_NETWORK
     virDriverLoadModule("network");
 # endif
+# ifdef WITH_INTERFACE
+    virDriverLoadModule("interface");
+# endif
 # ifdef WITH_STORAGE
     virDriverLoadModule("storage");
 # endif
@@ -391,9 +402,6 @@ static void daemonInitialize(void)
 # ifdef WITH_NWFILTER
     virDriverLoadModule("nwfilter");
 # endif
-# ifdef WITH_INTERFACE
-    virDriverLoadModule("interface");
-# endif
 # ifdef WITH_XEN
     virDriverLoadModule("xen");
 # endif
@@ -409,13 +417,13 @@ 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();
+# endif
 # ifdef WITH_NETWORK
     networkRegister();
 # endif
@@ -449,9 +457,6 @@ static void daemonInitialize(void)
 # ifdef WITH_UML
     umlRegister();
 # endif
-# ifdef WITH_VBOX
-    vboxRegister();
-# endif
 # ifdef WITH_BHYVE
     bhyveRegister();
 # 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]