]> xenbits.xensource.com Git - libvirt.git/commitdiff
Separate out StateAutoStart from StateInitialize
authorJohn Ferlan <jferlan@redhat.com>
Thu, 25 Jul 2013 12:01:02 +0000 (08:01 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Fri, 26 Jul 2013 13:30:53 +0000 (09:30 -0400)
Separation allows for dependent drivers to be make a connection during
the AutoStart phase of state initialization.

src/driver.h
src/libvirt.c

index cc03e9f768208484a076fdef71599e35c9f38404..be643338a97fd995811abeb048a1d827e7f45608 100644 (file)
@@ -1800,6 +1800,9 @@ typedef int
                          virStateInhibitCallback callback,
                          void *opaque);
 
+typedef void
+(*virDrvStateAutoStart)(void);
+
 typedef int
 (*virDrvStateCleanup)(void);
 
@@ -1815,6 +1818,7 @@ typedef virStateDriver *virStateDriverPtr;
 struct _virStateDriver {
     const char *name;
     virDrvStateInitialize stateInitialize;
+    virDrvStateAutoStart stateAutoStart;
     virDrvStateCleanup stateCleanup;
     virDrvStateReload stateReload;
     virDrvStateStop stateStop;
index 444c1c329371e135ad12085d7cceaf66b0515e45..815748806a88012a644dab3f67edfd341a47db73 100644 (file)
@@ -808,7 +808,11 @@ virRegisterStateDriver(virStateDriverPtr driver)
  * @callback: callback to invoke to inhibit shutdown of the daemon
  * @opaque: data to pass to @callback
  *
- * Initialize all virtualization drivers.
+ * Initialize all virtualization drivers. Accomplished in two phases,
+ * the first being state and structure initialization followed by any
+ * auto start supported by the driver.  This is done to ensure dependencies
+ * that some drivers may have on another driver having been initialized
+ * will exist, such as the storage driver's need to use the secret driver.
  *
  * Returns 0 if all succeed, -1 upon any failure.
  */
@@ -836,6 +840,14 @@ int virStateInitialize(bool privileged,
             }
         }
     }
+
+    for (i = 0; i < virStateDriverTabCount; i++) {
+        if (virStateDriverTab[i]->stateAutoStart) {
+            VIR_DEBUG("Running global auto start for %s state driver",
+                      virStateDriverTab[i]->name);
+            virStateDriverTab[i]->stateAutoStart();
+        }
+    }
     return 0;
 }