From a589569f2f40a0454b52398035cfe7fbe44ab1e9 Mon Sep 17 00:00:00 2001 From: Wenchao Xia Date: Wed, 18 Jun 2014 08:43:30 +0200 Subject: qapi: adjust existing defines In order to let event defines use existing types later, instead of redefine new ones, some old type defines for spice and vnc are changed, and BlockErrorAction is moved from block.h to qapi schema. Note that BlockErrorAction is not merged with BlockdevOnError. At this point, VncInfo is not made a child of VncBasicInfo, because VncBasicInfo has mandatory fields where VncInfo makes them optional. Signed-off-by: Wenchao Xia Signed-off-by: Paolo Bonzini Reviewed-by: Eric Blake Signed-off-by: Luiz Capitulino --- qapi-schema.json | 110 ++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 85 insertions(+), 25 deletions(-) (limited to 'qapi-schema.json') diff --git a/qapi-schema.json b/qapi-schema.json index 98350048f6..4334e8ff33 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -630,21 +630,59 @@ { 'command': 'query-iothreads', 'returns': ['IOThreadInfo'] } ## -# @VncClientInfo: +# @NetworkAddressFamily # -# Information about a connected VNC client. +# The network address family +# +# @ipv4: IPV4 family +# +# @ipv6: IPV6 family +# +# @unix: unix socket +# +# @unknown: otherwise +# +# Since: 2.1 +## +{ 'enum': 'NetworkAddressFamily', + 'data': [ 'ipv4', 'ipv6', 'unix', 'unknown' ] } + +## +# @VncBasicInfo # -# @host: The host name of the client. QEMU tries to resolve this to a DNS name -# when possible. +# The basic information for vnc network connection # -# @family: 'ipv6' if the client is connected via IPv6 and TCP -# 'ipv4' if the client is connected via IPv4 and TCP -# 'unix' if the client is connected via a unix domain socket -# 'unknown' otherwise +# @host: IP address +# +# @service: The service name of vnc port. This may depend on the host system's +# service database so symbolic names should not be relied on. +# +# @family: address family +# +# Since: 2.1 +## +{ 'type': 'VncBasicInfo', + 'data': { 'host': 'str', + 'service': 'str', + 'family': 'NetworkAddressFamily' } } + +## +# @VncServerInfo +# +# The network connection information for server +# +# @auth: #optional, authentication method +# +# Since: 2.1 +## +{ 'type': 'VncServerInfo', + 'base': 'VncBasicInfo', + 'data': { '*auth': 'str' } } + +## +# @VncClientInfo: # -# @service: The service name of the client's port. This may depends on the -# host system's service database so symbolic names should not be -# relied on. +# Information about a connected VNC client. # # @x509_dname: #optional If x509 authentication is in use, the Distinguished # Name of the client. @@ -655,8 +693,8 @@ # Since: 0.14.0 ## { 'type': 'VncClientInfo', - 'data': {'host': 'str', 'family': 'str', 'service': 'str', - '*x509_dname': 'str', '*sasl_username': 'str'} } + 'base': 'VncBasicInfo', + 'data': { '*x509_dname' : 'str', '*sasl_username': 'str' } } ## # @VncInfo: @@ -695,7 +733,8 @@ # Since: 0.14.0 ## { 'type': 'VncInfo', - 'data': {'enabled': 'bool', '*host': 'str', '*family': 'str', + 'data': {'enabled': 'bool', '*host': 'str', + '*family': 'NetworkAddressFamily', '*service': 'str', '*auth': 'str', '*clients': ['VncClientInfo']} } ## @@ -710,19 +749,40 @@ { 'command': 'query-vnc', 'returns': 'VncInfo' } ## -# @SpiceChannel +# @SpiceBasicInfo # -# Information about a SPICE client channel. +# The basic information for SPICE network connection +# +# @host: IP address +# +# @port: port number +# +# @family: address family +# +# Since: 2.1 +## +{ 'type': 'SpiceBasicInfo', + 'data': { 'host': 'str', + 'port': 'str', + 'family': 'NetworkAddressFamily' } } + +## +# @SpiceServerInfo # -# @host: The host name of the client. QEMU tries to resolve this to a DNS name -# when possible. +# Information about a SPICE server # -# @family: 'ipv6' if the client is connected via IPv6 and TCP -# 'ipv4' if the client is connected via IPv4 and TCP -# 'unix' if the client is connected via a unix domain socket -# 'unknown' otherwise +# @auth: #optional, authentication method # -# @port: The client's port number. +# Since: 2.1 +## +{ 'type': 'SpiceServerInfo', + 'base': 'SpiceBasicInfo', + 'data': { '*auth': 'str' } } + +## +# @SpiceChannel +# +# Information about a SPICE client channel. # # @connection-id: SPICE connection id number. All channels with the same id # belong to the same SPICE session. @@ -740,8 +800,8 @@ # Since: 0.14.0 ## { 'type': 'SpiceChannel', - 'data': {'host': 'str', 'family': 'str', 'port': 'str', - 'connection-id': 'int', 'channel-type': 'int', 'channel-id': 'int', + 'base': 'SpiceBasicInfo', + 'data': {'connection-id': 'int', 'channel-type': 'int', 'channel-id': 'int', 'tls': 'bool'} } ## -- cgit v1.2.3-55-g7522 From f668470f403e83cc4622b1b4e563e2c61fbdfe62 Mon Sep 17 00:00:00 2001 From: Wenchao Xia Date: Wed, 18 Jun 2014 08:43:32 +0200 Subject: qapi: add new schema file qapi-event.json Signed-off-by: Wenchao Xia Signed-off-by: Paolo Bonzini Reviewed-by: Eric Blake Signed-off-by: Luiz Capitulino --- Makefile | 3 ++- qapi-event.json | 0 qapi-schema.json | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 qapi-event.json (limited to 'qapi-schema.json') diff --git a/Makefile b/Makefile index f473cf5637..7d0c8ec7cc 100644 --- a/Makefile +++ b/Makefile @@ -247,7 +247,8 @@ $(SRC_PATH)/qga/qapi-schema.json $(SRC_PATH)/scripts/qapi-commands.py $(qapi-py) " GEN $@") qapi-modules = $(SRC_PATH)/qapi-schema.json $(SRC_PATH)/qapi/common.json \ - $(SRC_PATH)/qapi/block.json $(SRC_PATH)/qapi/block-core.json + $(SRC_PATH)/qapi/block.json $(SRC_PATH)/qapi/block-core.json \ + $(SRC_PATH)/qapi-event.json qapi-types.c qapi-types.h :\ $(qapi-modules) $(SRC_PATH)/scripts/qapi-types.py $(qapi-py) diff --git a/qapi-event.json b/qapi-event.json new file mode 100644 index 0000000000..e69de29bb2 diff --git a/qapi-schema.json b/qapi-schema.json index 4334e8ff33..e8c55e21a4 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3346,3 +3346,5 @@ # Since: 2.1 ## { 'command': 'query-acpi-ospm-status', 'returns': ['ACPIOSTInfo'] } + +{ 'include': 'qapi-event.json' } -- cgit v1.2.3-55-g7522 From 99eaf09c73b213e32e297b1d08d035abb5b268e9 Mon Sep 17 00:00:00 2001 From: Wenchao Xia Date: Wed, 18 Jun 2014 08:43:42 +0200 Subject: qapi event: convert WATCHDOG Signed-off-by: Wenchao Xia Signed-off-by: Paolo Bonzini Reviewed-by: Eric Blake Signed-off-by: Luiz Capitulino --- docs/qmp/qmp-events.txt | 19 ------------------- hw/watchdog/watchdog.c | 23 +++++++---------------- monitor.c | 2 +- qapi-event.json | 15 +++++++++++++++ qapi-schema.json | 24 ++++++++++++++++++++++++ 5 files changed, 47 insertions(+), 36 deletions(-) (limited to 'qapi-schema.json') diff --git a/docs/qmp/qmp-events.txt b/docs/qmp/qmp-events.txt index f5e2a924c1..8efc8df413 100644 --- a/docs/qmp/qmp-events.txt +++ b/docs/qmp/qmp-events.txt @@ -425,22 +425,3 @@ Example: "client": { "family": "ipv4", "service": "46089", "host": "127.0.0.1", "sasl_username": "luiz" } }, "timestamp": { "seconds": 1263475302, "microseconds": 150772 } } - -WATCHDOG --------- - -Emitted when the watchdog device's timer is expired. - -Data: - -- "action": Action that has been taken, it's one of the following (json-string): - "reset", "shutdown", "poweroff", "pause", "debug", or "none" - -Example: - -{ "event": "WATCHDOG", - "data": { "action": "reset" }, - "timestamp": { "seconds": 1267061043, "microseconds": 959568 } } - -Note: If action is "reset", "shutdown", or "pause" the WATCHDOG event is -followed respectively by the RESET, SHUTDOWN, or STOP events. diff --git a/hw/watchdog/watchdog.c b/hw/watchdog/watchdog.c index f28161b2d6..4aebd34924 100644 --- a/hw/watchdog/watchdog.c +++ b/hw/watchdog/watchdog.c @@ -24,9 +24,9 @@ #include "qemu/config-file.h" #include "qemu/queue.h" #include "qapi/qmp/types.h" -#include "monitor/monitor.h" #include "sysemu/sysemu.h" #include "sysemu/watchdog.h" +#include "qapi-event.h" /* Possible values for action parameter. */ #define WDT_RESET 1 /* Hard reset. */ @@ -101,15 +101,6 @@ int select_watchdog_action(const char *p) return 0; } -static void watchdog_mon_event(const char *action) -{ - QObject *data; - - data = qobject_from_jsonf("{ 'action': %s }", action); - monitor_protocol_event(QEVENT_WATCHDOG, data); - qobject_decref(data); -} - /* This actually performs the "action" once a watchdog has expired, * ie. reboot, shutdown, exit, etc. */ @@ -117,31 +108,31 @@ void watchdog_perform_action(void) { switch(watchdog_action) { case WDT_RESET: /* same as 'system_reset' in monitor */ - watchdog_mon_event("reset"); + qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_RESET, &error_abort); qemu_system_reset_request(); break; case WDT_SHUTDOWN: /* same as 'system_powerdown' in monitor */ - watchdog_mon_event("shutdown"); + qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_SHUTDOWN, &error_abort); qemu_system_powerdown_request(); break; case WDT_POWEROFF: /* same as 'quit' command in monitor */ - watchdog_mon_event("poweroff"); + qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_POWEROFF, &error_abort); exit(0); case WDT_PAUSE: /* same as 'stop' command in monitor */ - watchdog_mon_event("pause"); + qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_PAUSE, &error_abort); vm_stop(RUN_STATE_WATCHDOG); break; case WDT_DEBUG: - watchdog_mon_event("debug"); + qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_DEBUG, &error_abort); fprintf(stderr, "watchdog: timer fired\n"); break; case WDT_NONE: - watchdog_mon_event("none"); + qapi_event_send_watchdog(WATCHDOG_EXPIRATION_ACTION_NONE, &error_abort); break; } } diff --git a/monitor.c b/monitor.c index 41ef40ef18..0b4a4b428e 100644 --- a/monitor.c +++ b/monitor.c @@ -616,6 +616,7 @@ static void monitor_qapi_event_init(void) { /* Limit guest-triggerable events to 1 per second */ monitor_qapi_event_throttle(QAPI_EVENT_RTC_CHANGE, 1000); + monitor_qapi_event_throttle(QAPI_EVENT_WATCHDOG, 1000); qmp_event_set_func_emit(monitor_qapi_event_queue); } @@ -744,7 +745,6 @@ static void monitor_protocol_event_init(void) { /* Limit RTC & BALLOON events to 1 per second */ monitor_protocol_event_throttle(QEVENT_BALLOON_CHANGE, 1000); - monitor_protocol_event_throttle(QEVENT_WATCHDOG, 1000); /* limit the rate of quorum events to avoid hammering the management */ monitor_protocol_event_throttle(QEVENT_QUORUM_REPORT_BAD, 1000); monitor_protocol_event_throttle(QEVENT_QUORUM_FAILURE, 1000); diff --git a/qapi-event.json b/qapi-event.json index e6cfafae78..e7dbfab56f 100644 --- a/qapi-event.json +++ b/qapi-event.json @@ -91,3 +91,18 @@ ## { 'event': 'RTC_CHANGE', 'data': { 'offset': 'int' } } + +## +# @WATCHDOG +# +# Emitted when the watchdog device's timer is expired +# +# @action: action that has been taken +# +# Note: If action is "reset", "shutdown", or "pause" the WATCHDOG event is +# followed respectively by the RESET, SHUTDOWN, or STOP events +# +# Since: 0.13.0 +## +{ 'event': 'WATCHDOG', + 'data': { 'action': 'WatchdogExpirationAction' } } diff --git a/qapi-schema.json b/qapi-schema.json index e8c55e21a4..0bf5894f7e 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3347,4 +3347,28 @@ ## { 'command': 'query-acpi-ospm-status', 'returns': ['ACPIOSTInfo'] } +## +# @WatchdogExpirationAction +# +# An enumeration of the actions taken when the watchdog device's timer is +# expired +# +# @reset: system resets +# +# @shutdown: system shutdown, note that it is similar to @powerdown, which +# tries to set to system status and notify guest +# +# @poweroff: system poweroff, the emulator program exits +# +# @pause: system pauses, similar to @stop +# +# @debug: system enters debug state +# +# @none: nothing is done +# +# Since: 2.1 +## +{ 'enum': 'WatchdogExpirationAction', + 'data': [ 'reset', 'shutdown', 'poweroff', 'pause', 'debug', 'none' ] } + { 'include': 'qapi-event.json' } -- cgit v1.2.3-55-g7522 From 5a2d2cbd8850db7c03d1333d6c29aab6e3bc75ad Mon Sep 17 00:00:00 2001 From: Wenchao Xia Date: Wed, 18 Jun 2014 08:43:45 +0200 Subject: qapi event: convert BLOCK_IO_ERROR and BLOCK_JOB_ERROR Signed-off-by: Wenchao Xia Signed-off-by: Paolo Bonzini Reviewed-by: Eric Blake Signed-off-by: Luiz Capitulino --- block.c | 41 ++++++++--------------------------------- blockjob.c | 6 +++++- docs/qmp/qmp-events.txt | 47 ----------------------------------------------- include/block/block_int.h | 3 --- qapi-schema.json | 14 ++++++++++++++ qapi/block-core.json | 39 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 66 insertions(+), 84 deletions(-) (limited to 'qapi-schema.json') diff --git a/block.c b/block.c index 288efbca98..e6f9b71e11 100644 --- a/block.c +++ b/block.c @@ -24,7 +24,6 @@ #include "config-host.h" #include "qemu-common.h" #include "trace.h" -#include "monitor/monitor.h" #include "block/block_int.h" #include "block/blockjob.h" #include "qemu/module.h" @@ -2133,36 +2132,6 @@ void bdrv_set_dev_ops(BlockDriverState *bs, const BlockDevOps *ops, bs->dev_opaque = opaque; } -void bdrv_emit_qmp_error_event(const BlockDriverState *bdrv, - enum MonitorEvent ev, - BlockErrorAction action, bool is_read) -{ - QObject *data; - const char *action_str; - - switch (action) { - case BLOCK_ERROR_ACTION_REPORT: - action_str = "report"; - break; - case BLOCK_ERROR_ACTION_IGNORE: - action_str = "ignore"; - break; - case BLOCK_ERROR_ACTION_STOP: - action_str = "stop"; - break; - default: - abort(); - } - - data = qobject_from_jsonf("{ 'device': %s, 'action': %s, 'operation': %s }", - bdrv->device_name, - action_str, - is_read ? "read" : "write"); - monitor_protocol_event(ev, data); - - qobject_decref(data); -} - static void bdrv_dev_change_media_cb(BlockDriverState *bs, bool load) { if (bs->dev_ops && bs->dev_ops->change_media_cb) { @@ -3636,10 +3605,16 @@ void bdrv_error_action(BlockDriverState *bs, BlockErrorAction action, * also ensures that the STOP/RESUME pair of events is emitted. */ qemu_system_vmstop_request_prepare(); - bdrv_emit_qmp_error_event(bs, QEVENT_BLOCK_IO_ERROR, action, is_read); + qapi_event_send_block_io_error(bdrv_get_device_name(bs), + is_read ? IO_OPERATION_TYPE_READ : + IO_OPERATION_TYPE_WRITE, + action, &error_abort); qemu_system_vmstop_request(RUN_STATE_IO_ERROR); } else { - bdrv_emit_qmp_error_event(bs, QEVENT_BLOCK_IO_ERROR, action, is_read); + qapi_event_send_block_io_error(bdrv_get_device_name(bs), + is_read ? IO_OPERATION_TYPE_READ : + IO_OPERATION_TYPE_WRITE, + action, &error_abort); } } diff --git a/blockjob.c b/blockjob.c index bc63d42dc8..ee2a6fbbdc 100644 --- a/blockjob.c +++ b/blockjob.c @@ -34,6 +34,7 @@ #include "block/coroutine.h" #include "qmp-commands.h" #include "qemu/timer.h" +#include "qapi-event.h" void *block_job_create(const BlockJobDriver *driver, BlockDriverState *bs, int64_t speed, BlockDriverCompletionFunc *cb, @@ -277,7 +278,10 @@ BlockErrorAction block_job_error_action(BlockJob *job, BlockDriverState *bs, default: abort(); } - bdrv_emit_qmp_error_event(job->bs, QEVENT_BLOCK_JOB_ERROR, action, is_read); + qapi_event_send_block_job_error(bdrv_get_device_name(bs), + is_read ? IO_OPERATION_TYPE_READ : + IO_OPERATION_TYPE_WRITE, + action, &error_abort); if (action == BLOCK_ERROR_ACTION_STOP) { block_job_pause(job); block_job_iostatus_set_err(job, error); diff --git a/docs/qmp/qmp-events.txt b/docs/qmp/qmp-events.txt index d97b389b07..56bd145ab3 100644 --- a/docs/qmp/qmp-events.txt +++ b/docs/qmp/qmp-events.txt @@ -50,31 +50,6 @@ Example: "size": 65536 }, "timestamp": { "seconds": 1378126126, "microseconds": 966463 } } -BLOCK_IO_ERROR --------------- - -Emitted when a disk I/O error occurs. - -Data: - -- "device": device name (json-string) -- "operation": I/O operation (json-string, "read" or "write") -- "action": action that has been taken, it's one of the following (json-string): - "ignore": error has been ignored - "report": error has been reported to the device - "stop": the VM is going to stop because of the error - -Example: - -{ "event": "BLOCK_IO_ERROR", - "data": { "device": "ide0-hd1", - "operation": "write", - "action": "stop" }, - "timestamp": { "seconds": 1265044230, "microseconds": 450486 } } - -Note: If action is "stop", a STOP event will eventually follow the -BLOCK_IO_ERROR event. - BLOCK_JOB_CANCELLED ------------------- @@ -128,28 +103,6 @@ Example: "speed": 0 }, "timestamp": { "seconds": 1267061043, "microseconds": 959568 } } -BLOCK_JOB_ERROR ---------------- - -Emitted when a block job encounters an error. - -Data: - -- "device": device name (json-string) -- "operation": I/O operation (json-string, "read" or "write") -- "action": action that has been taken, it's one of the following (json-string): - "ignore": error has been ignored, the job may fail later - "report": error will be reported and the job canceled - "stop": error caused job to be paused - -Example: - -{ "event": "BLOCK_JOB_ERROR", - "data": { "device": "ide0-hd1", - "operation": "write", - "action": "stop" }, - "timestamp": { "seconds": 1265044230, "microseconds": 450486 } } - BLOCK_JOB_READY --------------- diff --git a/include/block/block_int.h b/include/block/block_int.h index 7aa2213f77..715c761fad 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -425,9 +425,6 @@ void bdrv_attach_aio_context(BlockDriverState *bs, #ifdef _WIN32 int is_windows_drive(const char *filename); #endif -void bdrv_emit_qmp_error_event(const BlockDriverState *bdrv, - enum MonitorEvent ev, - BlockErrorAction action, bool is_read); /** * stream_start: diff --git a/qapi-schema.json b/qapi-schema.json index 0bf5894f7e..a8de08c0a4 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3371,4 +3371,18 @@ { 'enum': 'WatchdogExpirationAction', 'data': [ 'reset', 'shutdown', 'poweroff', 'pause', 'debug', 'none' ] } +## +# @IoOperationType +# +# An enumeration of the I/O operation types +# +# @read: read operation +# +# @write: write operation +# +# Since: 2.1 +## +{ 'enum': 'IoOperationType', + 'data': [ 'read', 'write' ] } + { 'include': 'qapi-event.json' } diff --git a/qapi/block-core.json b/qapi/block-core.json index b7f36c638a..682864df3f 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1426,3 +1426,42 @@ ## { 'enum': 'BlockErrorAction', 'data': [ 'ignore', 'report', 'stop' ] } + + +## +# @BLOCK_IO_ERROR +# +# Emitted when a disk I/O error occurs +# +# @device: device name +# +# @operation: I/O operation +# +# @action: action that has been taken +# +# Note: If action is "stop", a STOP event will eventually follow the +# BLOCK_IO_ERROR event +# +# Since: 0.13.0 +## +{ 'event': 'BLOCK_IO_ERROR', + 'data': { 'device': 'str', 'operation': 'IoOperationType', + 'action': 'BlockErrorAction' } } + +## +# @BLOCK_JOB_ERROR +# +# Emitted when a block job encounters an error +# +# @device: device name +# +# @operation: I/O operation +# +# @action: action that has been taken +# +# Since: 1.3 +## +{ 'event': 'BLOCK_JOB_ERROR', + 'data': { 'device' : 'str', + 'operation': 'IoOperationType', + 'action' : 'BlockdevOnError' } } -- cgit v1.2.3-55-g7522 From 3a4496903795e05c1e8367bb4c9862d5670f48d7 Mon Sep 17 00:00:00 2001 From: Wenchao Xia Date: Wed, 18 Jun 2014 08:43:52 +0200 Subject: qapi event: convert GUEST_PANICKED 'monitor.h' is still included in target-s390x/kvm.c, since I have no good way to verify whether other code need it on my x86 host. Signed-off-by: Wenchao Xia Signed-off-by: Paolo Bonzini Reviewed-by: Eric Blake Signed-off-by: Luiz Capitulino --- docs/qmp/qmp-events.txt | 14 -------------- hw/misc/pvpanic.c | 13 ++----------- qapi-event.json | 12 ++++++++++++ qapi-schema.json | 12 ++++++++++++ target-s390x/kvm.c | 9 +++------ 5 files changed, 29 insertions(+), 31 deletions(-) (limited to 'qapi-schema.json') diff --git a/docs/qmp/qmp-events.txt b/docs/qmp/qmp-events.txt index 1b0e25fd42..adf45d37c4 100644 --- a/docs/qmp/qmp-events.txt +++ b/docs/qmp/qmp-events.txt @@ -1,20 +1,6 @@ QEMU Machine Protocol Events ============================ -GUEST_PANICKED --------------- - -Emitted when guest OS panic is detected. - -Data: - -- "action": Action that has been taken (json-string, currently always "pause"). - -Example: - -{ "event": "GUEST_PANICKED", - "data": { "action": "pause" } } - QUORUM_FAILURE -------------- diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c index 5377feed69..994f8af8e6 100644 --- a/hw/misc/pvpanic.c +++ b/hw/misc/pvpanic.c @@ -14,12 +14,12 @@ #include "qapi/qmp/qobject.h" #include "qapi/qmp/qjson.h" -#include "monitor/monitor.h" #include "sysemu/sysemu.h" #include "qemu/log.h" #include "hw/nvram/fw_cfg.h" #include "hw/i386/pc.h" +#include "qapi-event.h" /* The bit of supported pv event */ #define PVPANIC_F_PANICKED 0 @@ -31,15 +31,6 @@ #define ISA_PVPANIC_DEVICE(obj) \ OBJECT_CHECK(PVPanicState, (obj), TYPE_ISA_PVPANIC_DEVICE) -static void panicked_mon_event(const char *action) -{ - QObject *data; - - data = qobject_from_jsonf("{ 'action': %s }", action); - monitor_protocol_event(QEVENT_GUEST_PANICKED, data); - qobject_decref(data); -} - static void handle_event(int event) { static bool logged; @@ -50,7 +41,7 @@ static void handle_event(int event) } if (event & PVPANIC_PANICKED) { - panicked_mon_event("pause"); + qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_PAUSE, &error_abort); vm_stop(RUN_STATE_GUEST_PANICKED); return; } diff --git a/qapi-event.json b/qapi-event.json index b7438d5877..8a3f3ae118 100644 --- a/qapi-event.json +++ b/qapi-event.json @@ -266,3 +266,15 @@ ## { 'event': 'BALLOON_CHANGE', 'data': { 'actual': 'int' } } + +## +# @GUEST_PANICKED +# +# Emitted when guest OS panic is detected +# +# @action: action that has been taken, currently always "pause" +# +# Since: 1.5 +## +{ 'event': 'GUEST_PANICKED', + 'data': { 'action': 'GuestPanicAction' } } diff --git a/qapi-schema.json b/qapi-schema.json index a8de08c0a4..cf3e21a2ab 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3385,4 +3385,16 @@ { 'enum': 'IoOperationType', 'data': [ 'read', 'write' ] } +## +# @GuestPanicAction +# +# An enumeration of the actions taken when guest OS panic is detected +# +# @pause: system pauses +# +# Since: 2.1 +## +{ 'enum': 'GuestPanicAction', + 'data': [ 'pause' ] } + { 'include': 'qapi-event.json' } diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c index a1a4cc2cab..a6e587b589 100644 --- a/target-s390x/kvm.c +++ b/target-s390x/kvm.c @@ -39,6 +39,7 @@ #include "monitor/monitor.h" #include "exec/gdbstub.h" #include "trace.h" +#include "qapi-event.h" /* #define DEBUG_KVM */ @@ -1029,12 +1030,8 @@ static bool is_special_wait_psw(CPUState *cs) static void guest_panicked(void) { - QObject *data; - - data = qobject_from_jsonf("{ 'action': %s }", "pause"); - monitor_protocol_event(QEVENT_GUEST_PANICKED, data); - qobject_decref(data); - + qapi_event_send_guest_panicked(GUEST_PANIC_ACTION_PAUSE, + &error_abort); vm_stop(RUN_STATE_GUEST_PANICKED); } -- cgit v1.2.3-55-g7522