qemu: save domain state to XML after reboot

Currently qemuDomainReboot() does reboot in two phases:
qemuMonitorSystemPowerdown() and qemuProcessFakeReboot().

qemuMonitorSystemPowerdown() shutdowns the domain and saves domain
state/reason as VIR_DOMAIN_SHUTDOWN_UNKNOWN.

qemuProcessFakeReboot() sets domain state/reason to
VIR_DOMAIN_RESUMED_UNPAUSED but does not save domain state changes.

Subsequent restart of libvirtd leads to restoring domain state/reason to
saved that is VIR_DOMAIN_SHUTDOWN_UNKNOWN and to automatic shutdown of
the domain. This commit adds virDomainSaveStatus() into
qemuProcessFakeReboot() to avoid unexpected shutdowns.
This commit is contained in:
Sergey Fionov 2013-05-18 15:47:51 +04:00 committed by Eric Blake
parent befc36a81d
commit 2697c8a116

View File

@ -547,6 +547,7 @@ qemuProcessFakeReboot(void *opaque)
virDomainObjPtr vm = opaque; virDomainObjPtr vm = opaque;
qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjPrivatePtr priv = vm->privateData;
virDomainEventPtr event = NULL; virDomainEventPtr event = NULL;
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
int ret = -1; int ret = -1;
VIR_DEBUG("vm=%p", vm); VIR_DEBUG("vm=%p", vm);
virObjectLock(vm); virObjectLock(vm);
@ -585,6 +586,11 @@ qemuProcessFakeReboot(void *opaque)
VIR_DOMAIN_EVENT_RESUMED, VIR_DOMAIN_EVENT_RESUMED,
VIR_DOMAIN_EVENT_RESUMED_UNPAUSED); VIR_DOMAIN_EVENT_RESUMED_UNPAUSED);
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) {
VIR_WARN("Unable to save status on vm %s after state change",
vm->def->name);
}
ret = 0; ret = 0;
endjob: endjob:
@ -601,6 +607,7 @@ cleanup:
} }
if (event) if (event)
qemuDomainEventQueue(driver, event); qemuDomainEventQueue(driver, event);
virObjectUnref(cfg);
} }