cleanup:
@@ -1586,7 +1590,6 @@ static int lxcDomainStartWithFlags(virDomainPtr dom, unsigned int flags)
event = virDomainEventNewFromObj(vm,
VIR_DOMAIN_EVENT_STARTED,
VIR_DOMAIN_EVENT_STARTED_BOOTED);
-
cleanup:
if (vm)
virDomainObjUnlock(vm);
@@ -1925,18 +1928,6 @@ lxcReconnectVM(void *payload, const void *name ATTRIBUTE_UNUSED, void *opaque)
goto cleanup;
}
- if ((config = virDomainConfigFile(driver->stateDir,
- vm->def->name)) == NULL)
- goto cleanup;
-
- /* Try and load the live config */
- tmp = virDomainDefParseFile(driver->caps, config, 0);
- VIR_FREE(config);
- if (tmp) {
- vm->newDef = vm->def;
- vm->def = tmp;
- }
-
if (vm->pid != 0) {
vm->def->id = vm->pid;
virDomainObjSetState(vm, VIR_DOMAIN_RUNNING,
@@ -2029,6 +2020,17 @@ static int lxcStartup(int privileged)
lxc_driver->caps->privateDataAllocFunc = lxcDomainObjPrivateAlloc;
lxc_driver->caps->privateDataFreeFunc = lxcDomainObjPrivateFree;
+ /* Get all the running persistent or transient configs first */
+ if (virDomainLoadAllConfigs(lxc_driver->caps,
+&lxc_driver->domains,
+ lxc_driver->stateDir,
+ NULL,
+ 1, NULL, NULL)< 0)
+ goto cleanup;
+
+ virHashForEach(lxc_driver->domains.objs, lxcReconnectVM, lxc_driver);
+
+ /* Then inactive persistent configs */
if (virDomainLoadAllConfigs(lxc_driver->caps,
&lxc_driver->domains,
lxc_driver->configDir,
@@ -2036,8 +2038,6 @@ static int lxcStartup(int privileged)
0, NULL, NULL)< 0)
goto cleanup;
- virHashForEach(lxc_driver->domains.objs, lxcReconnectVM, lxc_driver);
-
lxcDriverUnlock(lxc_driver);
lxcAutostartConfigs(lxc_driver);