mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
Add PMSUSPENDED life cycle event
While PMSUSPENDED state was added a long time ago, we didn't have corresponding life cycle event.
This commit is contained in:
parent
afab4824eb
commit
fc4115e8d6
@ -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;
|
||||
}
|
||||
|
@ -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]
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user