]> xenbits.xensource.com Git - libvirt.git/commitdiff
daemon: Fix driver registration ordering
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 15 Aug 2014 10:26:09 +0000 (12:26 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 18 Aug 2014 09:49:10 +0000 (11:49 +0200)
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@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
daemon/libvirtd.c

index a1f64adf7e962a51d9c01180e343fbaecda0e8a3..7a59afef94c8c495d0daa13f20ee59cd4e2456bc 100644 (file)
@@ -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 stateful domain
+     * driver, 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 to such driver the 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