mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
examples: Update event tests for shutdown event
This commit is contained in:
parent
b265beda55
commit
9bfa132c70
@ -40,7 +40,7 @@ void usage(const char *pname);
|
||||
|
||||
const char *eventToString(int event) {
|
||||
const char *ret = "";
|
||||
switch(event) {
|
||||
switch ((virDomainEventType) event) {
|
||||
case VIR_DOMAIN_EVENT_DEFINED:
|
||||
ret ="Defined";
|
||||
break;
|
||||
@ -59,13 +59,16 @@ const char *eventToString(int event) {
|
||||
case VIR_DOMAIN_EVENT_STOPPED:
|
||||
ret ="Stopped";
|
||||
break;
|
||||
case VIR_DOMAIN_EVENT_SHUTDOWN:
|
||||
ret = "Shutdown";
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const char *eventDetailToString(int event, int detail) {
|
||||
const char *ret = "";
|
||||
switch(event) {
|
||||
switch ((virDomainEventType) event) {
|
||||
case VIR_DOMAIN_EVENT_DEFINED:
|
||||
if (detail == VIR_DOMAIN_EVENT_DEFINED_ADDED)
|
||||
ret = "Added";
|
||||
@ -77,7 +80,7 @@ static const char *eventDetailToString(int event, int detail) {
|
||||
ret = "Removed";
|
||||
break;
|
||||
case VIR_DOMAIN_EVENT_STARTED:
|
||||
switch (detail) {
|
||||
switch ((virDomainEventStartedDetailType) detail) {
|
||||
case VIR_DOMAIN_EVENT_STARTED_BOOTED:
|
||||
ret = "Booted";
|
||||
break;
|
||||
@ -93,7 +96,7 @@ static const char *eventDetailToString(int event, int detail) {
|
||||
}
|
||||
break;
|
||||
case VIR_DOMAIN_EVENT_SUSPENDED:
|
||||
switch (detail) {
|
||||
switch ((virDomainEventSuspendedDetailType) detail) {
|
||||
case VIR_DOMAIN_EVENT_SUSPENDED_PAUSED:
|
||||
ret = "Paused";
|
||||
break;
|
||||
@ -115,7 +118,7 @@ static const char *eventDetailToString(int event, int detail) {
|
||||
}
|
||||
break;
|
||||
case VIR_DOMAIN_EVENT_RESUMED:
|
||||
switch (detail) {
|
||||
switch ((virDomainEventResumedDetailType) detail) {
|
||||
case VIR_DOMAIN_EVENT_RESUMED_UNPAUSED:
|
||||
ret = "Unpaused";
|
||||
break;
|
||||
@ -128,7 +131,7 @@ static const char *eventDetailToString(int event, int detail) {
|
||||
}
|
||||
break;
|
||||
case VIR_DOMAIN_EVENT_STOPPED:
|
||||
switch (detail) {
|
||||
switch ((virDomainEventStoppedDetailType) detail) {
|
||||
case VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN:
|
||||
ret = "Shutdown";
|
||||
break;
|
||||
@ -152,6 +155,13 @@ static const char *eventDetailToString(int event, int detail) {
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case VIR_DOMAIN_EVENT_SHUTDOWN:
|
||||
switch ((virDomainEventShutdownDetailType) detail) {
|
||||
case VIR_DOMAIN_EVENT_SHUTDOWN_FINISHED:
|
||||
ret = "Finished";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
@ -430,7 +430,8 @@ def eventToString(event):
|
||||
"Started",
|
||||
"Suspended",
|
||||
"Resumed",
|
||||
"Stopped" );
|
||||
"Stopped",
|
||||
"Shutdown" );
|
||||
return eventStrings[event];
|
||||
|
||||
def detailToString(event, detail):
|
||||
@ -440,7 +441,8 @@ def detailToString(event, detail):
|
||||
( "Booted", "Migrated", "Restored", "Snapshot" ),
|
||||
( "Paused", "Migrated", "IOError", "Watchdog" ),
|
||||
( "Unpaused", "Migrated"),
|
||||
( "Shutdown", "Destroyed", "Crashed", "Migrated", "Saved", "Failed", "Snapshot")
|
||||
( "Shutdown", "Destroyed", "Crashed", "Migrated", "Saved", "Failed", "Snapshot"),
|
||||
( "Finished" )
|
||||
)
|
||||
return eventStrings[event][detail]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user