diff --git a/examples/domain-events/events-c/event-test.c b/examples/domain-events/events-c/event-test.c index fc4d5750d9b10dff415d7357f38e26dde625a449..cde60fb8a4f4f399448dc770651ca55f152c327c 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 e3b6ed276650acf026ff047dac185bb7069f1161..fd71acd21775905c84ab083fd96987e228ff26b2 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 0c522716aeb15e21b0d97d17df1e73a6a4f84f03..deb35ecb77c634e2e17bf16505cc3165b0ae6699 100644 --- a/include/libvirt/libvirt.h.in +++ b/include/libvirt/libvirt.h.in @@ -2845,6 +2845,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 @@ -2961,6 +2962,19 @@ typedef enum { #endif } 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 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 93653c6da8c1ecdaf4887d9a138428d8f977a9ed..77d679aace8a54e05e26a5fdcbeef4d79bb2d6f7 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); }