提交 9bfa132c 编写于 作者: J Jiri Denemark

examples: Update event tests for shutdown event

上级 b265beda
...@@ -40,7 +40,7 @@ void usage(const char *pname); ...@@ -40,7 +40,7 @@ void usage(const char *pname);
const char *eventToString(int event) { const char *eventToString(int event) {
const char *ret = ""; const char *ret = "";
switch(event) { switch ((virDomainEventType) event) {
case VIR_DOMAIN_EVENT_DEFINED: case VIR_DOMAIN_EVENT_DEFINED:
ret ="Defined"; ret ="Defined";
break; break;
...@@ -59,13 +59,16 @@ const char *eventToString(int event) { ...@@ -59,13 +59,16 @@ const char *eventToString(int event) {
case VIR_DOMAIN_EVENT_STOPPED: case VIR_DOMAIN_EVENT_STOPPED:
ret ="Stopped"; ret ="Stopped";
break; break;
case VIR_DOMAIN_EVENT_SHUTDOWN:
ret = "Shutdown";
break;
} }
return ret; return ret;
} }
static const char *eventDetailToString(int event, int detail) { static const char *eventDetailToString(int event, int detail) {
const char *ret = ""; const char *ret = "";
switch(event) { switch ((virDomainEventType) event) {
case VIR_DOMAIN_EVENT_DEFINED: case VIR_DOMAIN_EVENT_DEFINED:
if (detail == VIR_DOMAIN_EVENT_DEFINED_ADDED) if (detail == VIR_DOMAIN_EVENT_DEFINED_ADDED)
ret = "Added"; ret = "Added";
...@@ -77,7 +80,7 @@ static const char *eventDetailToString(int event, int detail) { ...@@ -77,7 +80,7 @@ static const char *eventDetailToString(int event, int detail) {
ret = "Removed"; ret = "Removed";
break; break;
case VIR_DOMAIN_EVENT_STARTED: case VIR_DOMAIN_EVENT_STARTED:
switch (detail) { switch ((virDomainEventStartedDetailType) detail) {
case VIR_DOMAIN_EVENT_STARTED_BOOTED: case VIR_DOMAIN_EVENT_STARTED_BOOTED:
ret = "Booted"; ret = "Booted";
break; break;
...@@ -93,7 +96,7 @@ static const char *eventDetailToString(int event, int detail) { ...@@ -93,7 +96,7 @@ static const char *eventDetailToString(int event, int detail) {
} }
break; break;
case VIR_DOMAIN_EVENT_SUSPENDED: case VIR_DOMAIN_EVENT_SUSPENDED:
switch (detail) { switch ((virDomainEventSuspendedDetailType) detail) {
case VIR_DOMAIN_EVENT_SUSPENDED_PAUSED: case VIR_DOMAIN_EVENT_SUSPENDED_PAUSED:
ret = "Paused"; ret = "Paused";
break; break;
...@@ -115,7 +118,7 @@ static const char *eventDetailToString(int event, int detail) { ...@@ -115,7 +118,7 @@ static const char *eventDetailToString(int event, int detail) {
} }
break; break;
case VIR_DOMAIN_EVENT_RESUMED: case VIR_DOMAIN_EVENT_RESUMED:
switch (detail) { switch ((virDomainEventResumedDetailType) detail) {
case VIR_DOMAIN_EVENT_RESUMED_UNPAUSED: case VIR_DOMAIN_EVENT_RESUMED_UNPAUSED:
ret = "Unpaused"; ret = "Unpaused";
break; break;
...@@ -128,7 +131,7 @@ static const char *eventDetailToString(int event, int detail) { ...@@ -128,7 +131,7 @@ static const char *eventDetailToString(int event, int detail) {
} }
break; break;
case VIR_DOMAIN_EVENT_STOPPED: case VIR_DOMAIN_EVENT_STOPPED:
switch (detail) { switch ((virDomainEventStoppedDetailType) detail) {
case VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN: case VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN:
ret = "Shutdown"; ret = "Shutdown";
break; break;
...@@ -152,6 +155,13 @@ static const char *eventDetailToString(int event, int detail) { ...@@ -152,6 +155,13 @@ static const char *eventDetailToString(int event, int detail) {
break; break;
} }
break; break;
case VIR_DOMAIN_EVENT_SHUTDOWN:
switch ((virDomainEventShutdownDetailType) detail) {
case VIR_DOMAIN_EVENT_SHUTDOWN_FINISHED:
ret = "Finished";
break;
}
break;
} }
return ret; return ret;
} }
......
...@@ -430,7 +430,8 @@ def eventToString(event): ...@@ -430,7 +430,8 @@ def eventToString(event):
"Started", "Started",
"Suspended", "Suspended",
"Resumed", "Resumed",
"Stopped" ); "Stopped",
"Shutdown" );
return eventStrings[event]; return eventStrings[event];
def detailToString(event, detail): def detailToString(event, detail):
...@@ -440,7 +441,8 @@ def detailToString(event, detail): ...@@ -440,7 +441,8 @@ def detailToString(event, detail):
( "Booted", "Migrated", "Restored", "Snapshot" ), ( "Booted", "Migrated", "Restored", "Snapshot" ),
( "Paused", "Migrated", "IOError", "Watchdog" ), ( "Paused", "Migrated", "IOError", "Watchdog" ),
( "Unpaused", "Migrated"), ( "Unpaused", "Migrated"),
( "Shutdown", "Destroyed", "Crashed", "Migrated", "Saved", "Failed", "Snapshot") ( "Shutdown", "Destroyed", "Crashed", "Migrated", "Saved", "Failed", "Snapshot"),
( "Finished" )
) )
return eventStrings[event][detail] return eventStrings[event][detail]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册