Thanks to the previous commit the RESUME event handler knows what reason should be used when changing the domain state to VIR_DOMAIN_RUNNING, but the emitted VIR_DOMAIN_EVENT_RESUMED event still uses a generic VIR_DOMAIN_EVENT_RESUMED_UNPAUSED detail. Luckily, the event detail can be easily deduced from the running reason, which saves us from having to pass one more value to the handler. Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx> Reviewed-by: John Ferlan <jferlan@xxxxxxxxxx> --- Notes: Version 2: - no change src/qemu/qemu_domain.c | 29 +++++++++++++++++++++++++++++ src/qemu/qemu_domain.h | 3 +++ src/qemu/qemu_process.c | 11 +++++++---- 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index b20d43059e..939b2a3da2 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -13505,3 +13505,32 @@ qemuDomainStorageIdReset(qemuDomainObjPrivatePtr priv) { priv->nodenameindex = 0; } + + +virDomainEventResumedDetailType +qemuDomainRunningReasonToResumeEvent(virDomainRunningReason reason) +{ + switch (reason) { + case VIR_DOMAIN_RUNNING_RESTORED: + case VIR_DOMAIN_RUNNING_FROM_SNAPSHOT: + return VIR_DOMAIN_EVENT_RESUMED_FROM_SNAPSHOT; + + case VIR_DOMAIN_RUNNING_MIGRATED: + case VIR_DOMAIN_RUNNING_MIGRATION_CANCELED: + return VIR_DOMAIN_EVENT_RESUMED_MIGRATED; + + case VIR_DOMAIN_RUNNING_POSTCOPY: + return VIR_DOMAIN_EVENT_RESUMED_POSTCOPY; + + case VIR_DOMAIN_RUNNING_UNKNOWN: + case VIR_DOMAIN_RUNNING_SAVE_CANCELED: + case VIR_DOMAIN_RUNNING_BOOTED: + case VIR_DOMAIN_RUNNING_UNPAUSED: + case VIR_DOMAIN_RUNNING_WAKEUP: + case VIR_DOMAIN_RUNNING_CRASHED: + case VIR_DOMAIN_RUNNING_LAST: + break; + } + + return VIR_DOMAIN_EVENT_RESUMED_UNPAUSED; +} diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 461859e37f..2f8a1bf03c 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -1082,4 +1082,7 @@ char * qemuDomainGetManagedPRSocketPath(qemuDomainObjPrivatePtr priv); unsigned int qemuDomainStorageIdNew(qemuDomainObjPrivatePtr priv); void qemuDomainStorageIdReset(qemuDomainObjPrivatePtr priv); +virDomainEventResumedDetailType +qemuDomainRunningReasonToResumeEvent(virDomainRunningReason reason); + #endif /* __QEMU_DOMAIN_H__ */ diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index f79db1d4cf..a7d71962da 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -714,6 +714,7 @@ qemuProcessHandleResume(qemuMonitorPtr mon ATTRIBUTE_UNUSED, virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); qemuDomainObjPrivatePtr priv; virDomainRunningReason reason = VIR_DOMAIN_RUNNING_UNPAUSED; + virDomainEventResumedDetailType eventDetail; virObjectLock(vm); @@ -729,14 +730,16 @@ qemuProcessHandleResume(qemuMonitorPtr mon ATTRIBUTE_UNUSED, goto unlock; } + eventDetail = qemuDomainRunningReasonToResumeEvent(reason); VIR_DEBUG("Transitioned guest %s out of paused into resumed state, " - "reason '%s'", - vm->def->name, virDomainRunningReasonTypeToString(reason)); + "reason '%s', event detail %d", + vm->def->name, virDomainRunningReasonTypeToString(reason), + eventDetail); virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, reason); event = virDomainEventLifecycleNewFromObj(vm, - VIR_DOMAIN_EVENT_RESUMED, - VIR_DOMAIN_EVENT_RESUMED_UNPAUSED); + VIR_DOMAIN_EVENT_RESUMED, + eventDetail); if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0) { VIR_WARN("Unable to save status on vm %s after state change", -- 2.19.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list