virStateDriver - Separate AutoStart from Initialize

Adjust these drivers to handle their Autostart functionality after each
of the drivers has gone through their Initialization functions
This commit is contained in:
John Ferlan 2013-07-25 08:03:38 -04:00
parent e4a969092b
commit cefb97fb81
6 changed files with 91 additions and 11 deletions

View File

@ -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,
};

View File

@ -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,
};

View File

@ -430,7 +430,6 @@ networkStateInitialize(bool privileged,
networkFindActiveConfigs(driverState);
networkReloadFirewallRules(driverState);
networkRefreshDaemons(driverState);
networkAutostartConfigs(driverState);
networkDriverUnlock(driverState);
@ -473,6 +472,22 @@ error:
goto cleanup;
}
/**
* networkStateAutoStart:
*
* Function to AutoStart the bridge configs
*/
static void
networkStateAutoStart(void)
{
if (!driverState)
return;
networkDriverLock(driverState);
networkAutostartConfigs(driverState);
networkDriverUnlock(driverState);
}
/**
* networkStateReload:
*
@ -3693,6 +3708,7 @@ static virNetworkDriver networkDriver = {
static virStateDriver networkStateDriver = {
.name = "Network",
.stateInitialize = networkStateInitialize,
.stateAutoStart = networkStateAutoStart,
.stateCleanup = networkStateCleanup,
.stateReload = networkStateReload,
};

View File

@ -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,

View File

@ -182,7 +182,6 @@ storageStateInitialize(bool privileged,
driverState->configDir,
driverState->autostartDir) < 0)
goto error;
storageDriverAutostart(driverState);
storageDriverUnlock(driverState);
return 0;
@ -194,6 +193,22 @@ error:
return -1;
}
/**
* storageStateAutoStart:
*
* Function to auto start the storage driver
*/
static void
storageStateAutoStart(void)
{
if (!driverState)
return;
storageDriverLock(driverState);
storageDriverAutostart(driverState);
storageDriverUnlock(driverState);
}
/**
* storageStateReload:
*
@ -2599,6 +2614,7 @@ static virStorageDriver storageDriver = {
static virStateDriver stateDriver = {
.name = "Storage",
.stateInitialize = storageStateInitialize,
.stateAutoStart = storageStateAutoStart,
.stateCleanup = storageStateCleanup,
.stateReload = storageStateReload,
};

View File

@ -570,8 +570,6 @@ umlStateInitialize(bool privileged,
umlDriverUnlock(uml_driver);
umlAutostartConfigs(uml_driver);
VIR_FREE(userdir);
virNWFilterRegisterCallbackDriver(&umlCallbackDriver);
@ -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,
};