Adjust these drivers to handle their Autostart functionality after each
of the drivers has gone through their Initialization functions
---
src/libxl/libxl_driver.c | 16 +++++++++++++---
src/lxc/lxc_driver.c | 16 ++++++++++++++--
src/network/bridge_driver.c | 18 +++++++++++++++++-
src/qemu/qemu_driver.c | 17 +++++++++++++++--
src/storage/storage_driver.c | 18 +++++++++++++++++-
src/uml/uml_driver.c | 17 +++++++++++++++--
6 files changed, 91 insertions(+), 11 deletions(-)
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 98b1985..eb252d0 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -1348,9 +1348,6 @@ libxlStateInitialize(bool privileged,
NULL, NULL) < 0)
goto error;
- virDomainObjListForEach(libxl_driver->domains, libxlAutostartDomain,
- libxl_driver);
-
virDomainObjListForEach(libxl_driver->domains, libxlDomainManagedSaveLoad,
libxl_driver);
@@ -1368,6 +1365,18 @@ fail:
return ret;
}
+static void
+libxlStateAutoStart(void)
+{
+ if (!libxl_driver)
+ return;
+
+ libxlDriverLock(libxl_driver);
+ virDomainObjListForEach(libxl_driver->domains, libxlAutostartDomain,
+ libxl_driver);
+ libxlDriverUnlock(libxl_driver);
+}
+
static int
libxlStateReload(void)
{
@@ -4887,6 +4896,7 @@ static virDriver libxlDriver = {
static virStateDriver libxlStateDriver = {
.name = "LIBXL",
.stateInitialize = libxlStateInitialize,
+ .stateAutoStart = libxlStateAutoStart,
.stateCleanup = libxlStateCleanup,
.stateReload = libxlStateReload,
};
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 21cf2e3..bafbe93 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -1455,8 +1455,6 @@ static int lxcStateInitialize(bool privileged,
NULL, NULL) < 0)
goto cleanup;
- virLXCProcessAutostartAll(lxc_driver);
-
virNWFilterRegisterCallbackDriver(&lxcCallbackDriver);
return 0;
@@ -1466,6 +1464,19 @@ cleanup:
return -1;
}
+/**
+ * lxcStateAutoStart:
+ *
+ * Function to autostart the LXC daemons
+ */
+static void lxcStateAutoStart(void)
+{
+ if (!lxc_driver)
+ return;
+
+ virLXCProcessAutostartAll(lxc_driver);
+}
+
static void lxcNotifyLoadDomain(virDomainObjPtr vm, int newVM, void *opaque)
{
virLXCDriverPtr driver = opaque;
@@ -4665,6 +4676,7 @@ static virDriver lxcDriver = {
static virStateDriver lxcStateDriver = {
.name = LXC_DRIVER_NAME,
.stateInitialize = lxcStateInitialize,
+ .stateAutoStart = lxcStateAutoStart,
.stateCleanup = lxcStateCleanup,
.stateReload = lxcStateReload,
};
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 0bb57ea..ea09663 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -430,7 +430,6 @@ networkStateInitialize(bool privileged,
networkFindActiveConfigs(driverState);
networkReloadFirewallRules(driverState);
networkRefreshDaemons(driverState);
- networkAutostartConfigs(driverState);
networkDriverUnlock(driverState);
@@ -474,6 +473,22 @@ error:
}
/**
+ * networkStateAutoStart:
+ *
+ * Function to AutoStart the bridge configs
+ */
+static void
+networkStateAutoStart(void)
+{
+ if (!driverState)
+ return;
+
+ networkDriverLock(driverState);
+ networkAutostartConfigs(driverState);
+ networkDriverUnlock(driverState);
+}
+
+/**
* networkStateReload:
*
* Function to restart the QEmu daemon, it will recheck the configuration
@@ -3693,6 +3708,7 @@ static virNetworkDriver networkDriver = {
static virStateDriver networkStateDriver = {
.name = "Network",
.stateInitialize = networkStateInitialize,
+ .stateAutoStart = networkStateAutoStart,
.stateCleanup = networkStateCleanup,
.stateReload = networkStateReload,
};
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 2adf6e2..5634abf 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -837,8 +837,6 @@ qemuStateInitialize(bool privileged,
if (!qemu_driver->workerPool)
goto error;
- qemuAutostartDomains(qemu_driver);
-
if (conn)
virConnectClose(conn);
@@ -855,6 +853,20 @@ error:
return -1;
}
+/**
+ * qemuStateAutoStart:
+ *
+ * Function to auto start the QEmu daemons
+ */
+static void
+qemuStateAutoStart(void)
+{
+ if (!qemu_driver)
+ return;
+
+ qemuAutostartDomains(qemu_driver);
+}
+
static void qemuNotifyLoadDomain(virDomainObjPtr vm, int newVM, void *opaque)
{
virQEMUDriverPtr driver = opaque;
@@ -16276,6 +16288,7 @@ static virDriver qemuDriver = {
static virStateDriver qemuStateDriver = {
.name = "QEMU",
.stateInitialize = qemuStateInitialize,
+ .stateAutoStart = qemuStateAutoStart,
.stateCleanup = qemuStateCleanup,
.stateReload = qemuStateReload,
.stateStop = qemuStateStop,
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index 4f0c631..72786dd 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -182,7 +182,6 @@ storageStateInitialize(bool privileged,
driverState->configDir,
driverState->autostartDir) < 0)
goto error;
- storageDriverAutostart(driverState);
storageDriverUnlock(driverState);
return 0;
@@ -195,6 +194,22 @@ error:
}
/**
+ * storageStateAutoStart:
+ *
+ * Function to auto start the storage driver
+ */
+static void
+storageStateAutoStart(void)
+{
+ if (!driverState)
+ return;
+
+ storageDriverLock(driverState);
+ storageDriverAutostart(driverState);
+ storageDriverUnlock(driverState);
+}
+
+/**
* storageStateReload:
*
* Function to restart the storage driver, it will recheck the configuration
@@ -2599,6 +2614,7 @@ static virStorageDriver storageDriver = {
static virStateDriver stateDriver = {
.name = "Storage",
.stateInitialize = storageStateInitialize,
+ .stateAutoStart = storageStateAutoStart,
.stateCleanup = storageStateCleanup,
.stateReload = storageStateReload,
};
diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c
index 7abcd6b..9ca352f 100644
--- a/src/uml/uml_driver.c
+++ b/src/uml/uml_driver.c
@@ -570,8 +570,6 @@ umlStateInitialize(bool privileged,
umlDriverUnlock(uml_driver);
- umlAutostartConfigs(uml_driver);
-
VIR_FREE(userdir);
virNWFilterRegisterCallbackDriver(¨CallbackDriver);
@@ -588,6 +586,20 @@ error:
return -1;
}
+/**
+ * umlStateAutoStart:
+ *
+ * Function to autostart the Uml daemons
+ */
+static void
+umlStateAutoStart(void)
+{
+ if (!uml_driver)
+ return;
+
+ umlAutostartConfigs(uml_driver);
+}
+
static void umlNotifyLoadDomain(virDomainObjPtr vm, int newVM, void *opaque)
{
struct uml_driver *driver = opaque;
@@ -2885,6 +2897,7 @@ static virDriver umlDriver = {
static virStateDriver umlStateDriver = {
.name = "UML",
.stateInitialize = umlStateInitialize,
+ .stateAutoStart = umlStateAutoStart,
.stateCleanup = umlStateCleanup,
.stateReload = umlStateReload,
};
--
1.8.1.4