提交 7c5a0c94 编写于 作者: O Osier Yang

qemu: Update domain status to running while wakeup event is emitted

This introduces a new running reason VIR_DOMAIN_RUNNING_WAKEUP,
and new suspend event type VIR_DOMAIN_EVENT_STARTED_WAKEUP.

While a wakeup event is emitted, the domain which entered into
VIR_DOMAIN_PMSUSPENDED will be transferred to "running"
with reason VIR_DOMAIN_RUNNING_WAKEUP, and a new domain lifecycle
event emitted with type VIR_DOMAIN_EVENT_STARTED_WAKEUP.
上级 321fa64b
...@@ -93,6 +93,9 @@ static const char *eventDetailToString(int event, int detail) { ...@@ -93,6 +93,9 @@ static const char *eventDetailToString(int event, int detail) {
case VIR_DOMAIN_EVENT_STARTED_FROM_SNAPSHOT: case VIR_DOMAIN_EVENT_STARTED_FROM_SNAPSHOT:
ret = "Snapshot"; ret = "Snapshot";
break; break;
case VIR_DOMAIN_EVENT_STARTED_WAKEUP:
ret = "Event wakeup";
break;
} }
break; break;
case VIR_DOMAIN_EVENT_SUSPENDED: case VIR_DOMAIN_EVENT_SUSPENDED:
......
...@@ -123,6 +123,8 @@ typedef enum { ...@@ -123,6 +123,8 @@ typedef enum {
VIR_DOMAIN_RUNNING_UNPAUSED = 5, /* returned from paused state */ VIR_DOMAIN_RUNNING_UNPAUSED = 5, /* returned from paused state */
VIR_DOMAIN_RUNNING_MIGRATION_CANCELED = 6, /* returned from migration */ VIR_DOMAIN_RUNNING_MIGRATION_CANCELED = 6, /* returned from migration */
VIR_DOMAIN_RUNNING_SAVE_CANCELED = 7, /* returned from failed save process */ VIR_DOMAIN_RUNNING_SAVE_CANCELED = 7, /* returned from failed save process */
VIR_DOMAIN_RUNNING_WAKEUP = 8, /* returned from pmsuspended due to
wakeup event */
#ifdef VIR_ENUM_SENTINELS #ifdef VIR_ENUM_SENTINELS
VIR_DOMAIN_RUNNING_LAST VIR_DOMAIN_RUNNING_LAST
...@@ -2695,6 +2697,7 @@ typedef enum { ...@@ -2695,6 +2697,7 @@ typedef enum {
VIR_DOMAIN_EVENT_STARTED_MIGRATED = 1, /* Incoming migration from another host */ VIR_DOMAIN_EVENT_STARTED_MIGRATED = 1, /* Incoming migration from another host */
VIR_DOMAIN_EVENT_STARTED_RESTORED = 2, /* Restored from a state file */ VIR_DOMAIN_EVENT_STARTED_RESTORED = 2, /* Restored from a state file */
VIR_DOMAIN_EVENT_STARTED_FROM_SNAPSHOT = 3, /* Restored from snapshot */ VIR_DOMAIN_EVENT_STARTED_FROM_SNAPSHOT = 3, /* Restored from snapshot */
VIR_DOMAIN_EVENT_STARTED_WAKEUP = 4, /* Started due to wakeup event */
#ifdef VIR_ENUM_SENTINELS #ifdef VIR_ENUM_SENTINELS
VIR_DOMAIN_EVENT_STARTED_LAST VIR_DOMAIN_EVENT_STARTED_LAST
......
...@@ -1067,15 +1067,38 @@ qemuProcessHandlePMWakeup(qemuMonitorPtr mon ATTRIBUTE_UNUSED, ...@@ -1067,15 +1067,38 @@ qemuProcessHandlePMWakeup(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
{ {
struct qemud_driver *driver = qemu_driver; struct qemud_driver *driver = qemu_driver;
virDomainEventPtr event = NULL; virDomainEventPtr event = NULL;
virDomainEventPtr lifecycleEvent = NULL;
virDomainObjLock(vm); virDomainObjLock(vm);
event = virDomainEventPMWakeupNewFromObj(vm); event = virDomainEventPMWakeupNewFromObj(vm);
/* Don't set domain status back to running if it wasn't paused
* from guest side, otherwise it can just cause confusion.
*/
if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PMSUSPENDED) {
VIR_DEBUG("Transitioned guest %s from pmsuspended to running "
"state due to QMP wakeup event", vm->def->name);
virDomainObjSetState(vm, VIR_DOMAIN_RUNNING,
VIR_DOMAIN_RUNNING_WAKEUP);
lifecycleEvent = virDomainEventNewFromObj(vm,
VIR_DOMAIN_EVENT_STARTED,
VIR_DOMAIN_EVENT_STARTED_WAKEUP);
if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0) {
VIR_WARN("Unable to save status on vm %s after wakeup event",
vm->def->name);
}
}
virDomainObjUnlock(vm); virDomainObjUnlock(vm);
if (event) { if (event || lifecycleEvent) {
qemuDriverLock(driver); qemuDriverLock(driver);
qemuDomainEventQueue(driver, event); if (event)
qemuDomainEventQueue(driver, event);
if (lifecycleEvent)
qemuDomainEventQueue(driver, lifecycleEvent);
qemuDriverUnlock(driver); qemuDriverUnlock(driver);
} }
......
...@@ -18859,6 +18859,8 @@ vshDomainStateReasonToString(int state, int reason) ...@@ -18859,6 +18859,8 @@ vshDomainStateReasonToString(int state, int reason)
return N_("migration canceled"); return N_("migration canceled");
case VIR_DOMAIN_RUNNING_SAVE_CANCELED: case VIR_DOMAIN_RUNNING_SAVE_CANCELED:
return N_("save canceled"); return N_("save canceled");
case VIR_DOMAIN_RUNNING_WAKEUP:
return N_("event wakeup");
case VIR_DOMAIN_RUNNING_UNKNOWN: case VIR_DOMAIN_RUNNING_UNKNOWN:
case VIR_DOMAIN_RUNNING_LAST: case VIR_DOMAIN_RUNNING_LAST:
; ;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册