While PMSUSPENDED state was added a long time ago, we didn't have corresponding life cycle event. --- examples/domain-events/events-c/event-test.c | 10 ++++++++++ examples/domain-events/events-python/event-test.py | 4 +++- include/libvirt/libvirt.h.in | 14 ++++++++++++++ src/qemu/qemu_process.c | 12 ++++++++++-- 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/examples/domain-events/events-c/event-test.c b/examples/domain-events/events-c/event-test.c index fc4d575..cde60fb 100644 --- a/examples/domain-events/events-c/event-test.c +++ b/examples/domain-events/events-c/event-test.c @@ -90,6 +90,9 @@ const char *eventToString(int event) { case VIR_DOMAIN_EVENT_SHUTDOWN: ret = "Shutdown"; break; + case VIR_DOMAIN_EVENT_PMSUSPENDED: + ret = "PMSuspended"; + break; } return ret; } @@ -193,6 +196,13 @@ static const char *eventDetailToString(int event, int detail) { break; } break; + case VIR_DOMAIN_EVENT_PMSUSPENDED: + switch ((virDomainEventPMSuspendedDetailType) detail) { + case VIR_DOMAIN_EVENT_PMSUSPENDED_MEMORY: + ret = "Memory"; + break; + } + break; } return ret; } diff --git a/examples/domain-events/events-python/event-test.py b/examples/domain-events/events-python/event-test.py index e3b6ed2..fd71acd 100644 --- a/examples/domain-events/events-python/event-test.py +++ b/examples/domain-events/events-python/event-test.py @@ -436,7 +436,8 @@ def eventToString(event): "Suspended", "Resumed", "Stopped", - "Shutdown" ); + "Shutdown", + "PMSuspended" ); return eventStrings[event]; def detailToString(event, detail): @@ -448,6 +449,7 @@ def detailToString(event, detail): ( "Unpaused", "Migrated", "Snapshot" ), ( "Shutdown", "Destroyed", "Crashed", "Migrated", "Saved", "Failed", "Snapshot"), ( "Finished" ) + ( "Memory", ) ) return eventStrings[event][detail] diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index 44c1649..19b13a7 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -2812,6 +2812,7 @@ typedef enum { VIR_DOMAIN_EVENT_RESUMED = 4, VIR_DOMAIN_EVENT_STOPPED = 5, VIR_DOMAIN_EVENT_SHUTDOWN = 6, + VIR_DOMAIN_EVENT_PMSUSPENDED = 7, #ifdef VIR_ENUM_SENTINELS VIR_DOMAIN_EVENT_LAST @@ -2929,6 +2930,19 @@ typedef enum { } virDomainEventShutdownDetailType; /** + * virDomainEventPMSuspendedDetailType: + * + * Details about the 'pmsuspended' lifecycle event + */ +typedef enum { + VIR_DOMAIN_EVENT_PMSUSPENDED_MEMORY = 0, /* Guest was PM suspended to memory */ + +#ifdef VIR_ENUM_SENTINELS + VIR_DOMAIN_EVENT_PMSUSPENDED_LAST +#endif +} virDomainEventPMSuspendedDetailType; + +/** * virConnectDomainEventCallback: * @conn: virConnect connection * @dom: The domain on which the event occurred diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 93653c6..77d679a 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -1120,6 +1120,7 @@ qemuProcessHandlePMSuspend(qemuMonitorPtr mon ATTRIBUTE_UNUSED, { struct qemud_driver *driver = qemu_driver; virDomainEventPtr event = NULL; + virDomainEventPtr lifecycleEvent = NULL; virDomainObjLock(vm); event = virDomainEventPMSuspendNewFromObj(vm); @@ -1131,6 +1132,10 @@ qemuProcessHandlePMSuspend(qemuMonitorPtr mon ATTRIBUTE_UNUSED, virDomainObjSetState(vm, VIR_DOMAIN_PMSUSPENDED, VIR_DOMAIN_PMSUSPENDED_UNKNOWN); + lifecycleEvent = + virDomainEventNewFromObj(vm, + VIR_DOMAIN_EVENT_PMSUSPENDED, + VIR_DOMAIN_EVENT_PMSUSPENDED_MEMORY); if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0) { VIR_WARN("Unable to save status on vm %s after suspend event", @@ -1143,9 +1148,12 @@ qemuProcessHandlePMSuspend(qemuMonitorPtr mon ATTRIBUTE_UNUSED, virDomainObjUnlock(vm); - if (event) { + if (event || lifecycleEvent) { qemuDriverLock(driver); - qemuDomainEventQueue(driver, event); + if (event) + qemuDomainEventQueue(driver, event); + if (lifecycleEvent) + qemuDomainEventQueue(driver, lifecycleEvent); qemuDriverUnlock(driver); } -- 1.7.12 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list