Some old type defines for spice and vnc are changed to let new event defines use them instead of redefine. Note that define of BlockErrorAction is moved from block.h to qapi schema, and it is not merged with BlockdevOnError. In schema NIC_RX_FILTER_CHANGED's param 'name' is changed as optional one, since in caller it is optional.
Signed-off-by: Wenchao Xia <wenchaoq...@gmail.com> --- block.c | 17 +- block/backup.c | 2 +- block/mirror.c | 7 +- block/stream.c | 4 +- blockjob.c | 11 +- docs/qmp/qmp-events.txt | 354 +-------------------------- hmp.c | 5 +- hw/block/virtio-blk.c | 6 +- hw/ide/core.c | 6 +- hw/scsi/scsi-disk.c | 6 +- include/block/block.h | 4 - include/qemu/sockets.h | 2 + qapi-schema.json | 632 +++++++++++++++++++++++++++++++++++++++++++++-- ui/spice-core.c | 7 +- ui/vnc.c | 9 +- util/qemu-sockets.c | 10 + 16 files changed, 664 insertions(+), 418 deletions(-) diff --git a/block.c b/block.c index 4745712..e9a55bb 100644 --- a/block.c +++ b/block.c @@ -2046,13 +2046,13 @@ void bdrv_emit_qmp_error_event(const BlockDriverState *bdrv, const char *action_str; switch (action) { - case BDRV_ACTION_REPORT: + case BLOCK_ERROR_ACTION_REPORT: action_str = "report"; break; - case BDRV_ACTION_IGNORE: + case BLOCK_ERROR_ACTION_IGNORE: action_str = "ignore"; break; - case BDRV_ACTION_STOP: + case BLOCK_ERROR_ACTION_STOP: action_str = "stop"; break; default: @@ -3496,13 +3496,14 @@ BlockErrorAction bdrv_get_error_action(BlockDriverState *bs, bool is_read, int e switch (on_err) { case BLOCKDEV_ON_ERROR_ENOSPC: - return (error == ENOSPC) ? BDRV_ACTION_STOP : BDRV_ACTION_REPORT; + return (error == ENOSPC) ? + BLOCK_ERROR_ACTION_STOP : BLOCK_ERROR_ACTION_REPORT; case BLOCKDEV_ON_ERROR_STOP: - return BDRV_ACTION_STOP; + return BLOCK_ERROR_ACTION_STOP; case BLOCKDEV_ON_ERROR_REPORT: - return BDRV_ACTION_REPORT; + return BLOCK_ERROR_ACTION_REPORT; case BLOCKDEV_ON_ERROR_IGNORE: - return BDRV_ACTION_IGNORE; + return BLOCK_ERROR_ACTION_IGNORE; default: abort(); } @@ -3517,7 +3518,7 @@ void bdrv_error_action(BlockDriverState *bs, BlockErrorAction action, { assert(error >= 0); bdrv_emit_qmp_error_event(bs, QEVENT_BLOCK_IO_ERROR, action, is_read); - if (action == BDRV_ACTION_STOP) { + if (action == BLOCK_ERROR_ACTION_STOP) { vm_stop(RUN_STATE_IO_ERROR); bdrv_iostatus_set_err(bs, error); } diff --git a/block/backup.c b/block/backup.c index 15a2e55..7978ae2 100644 --- a/block/backup.c +++ b/block/backup.c @@ -325,7 +325,7 @@ static void coroutine_fn backup_run(void *opaque) /* Depending on error action, fail now or retry cluster */ BlockErrorAction action = backup_error_action(job, error_is_read, -ret); - if (action == BDRV_ACTION_REPORT) { + if (action == BLOCK_ERROR_ACTION_REPORT) { break; } else { start--; diff --git a/block/mirror.c b/block/mirror.c index 36f4f8e..8a1a359 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -118,7 +118,7 @@ static void mirror_write_complete(void *opaque, int ret) bdrv_set_dirty(source, op->sector_num, op->nb_sectors); action = mirror_error_action(s, false, -ret); - if (action == BDRV_ACTION_REPORT && s->ret >= 0) { + if (action == BLOCK_ERROR_ACTION_REPORT && s->ret >= 0) { s->ret = ret; } } @@ -135,7 +135,7 @@ static void mirror_read_complete(void *opaque, int ret) bdrv_set_dirty(source, op->sector_num, op->nb_sectors); action = mirror_error_action(s, true, -ret); - if (action == BDRV_ACTION_REPORT && s->ret >= 0) { + if (action == BLOCK_ERROR_ACTION_REPORT && s->ret >= 0) { s->ret = ret; } @@ -412,7 +412,8 @@ static void coroutine_fn mirror_run(void *opaque) trace_mirror_before_flush(s); ret = bdrv_flush(s->target); if (ret < 0) { - if (mirror_error_action(s, false, -ret) == BDRV_ACTION_REPORT) { + if (mirror_error_action(s, false, -ret) == + BLOCK_ERROR_ACTION_REPORT) { goto immediate_exit; } } else { diff --git a/block/stream.c b/block/stream.c index dd0b4ac..b923bb3 100644 --- a/block/stream.c +++ b/block/stream.c @@ -159,14 +159,14 @@ wait: BlockErrorAction action = block_job_error_action(&s->common, s->common.bs, s->on_error, true, -ret); - if (action == BDRV_ACTION_STOP) { + if (action == BLOCK_ERROR_ACTION_STOP) { n = 0; continue; } if (error == 0) { error = ret; } - if (action == BDRV_ACTION_REPORT) { + if (action == BLOCK_ERROR_ACTION_REPORT) { break; } } diff --git a/blockjob.c b/blockjob.c index cd4784f..b8f6662 100644 --- a/blockjob.c +++ b/blockjob.c @@ -258,22 +258,23 @@ BlockErrorAction block_job_error_action(BlockJob *job, BlockDriverState *bs, switch (on_err) { case BLOCKDEV_ON_ERROR_ENOSPC: - action = (error == ENOSPC) ? BDRV_ACTION_STOP : BDRV_ACTION_REPORT; + action = (error == ENOSPC) ? + BLOCK_ERROR_ACTION_STOP : BLOCK_ERROR_ACTION_REPORT; break; case BLOCKDEV_ON_ERROR_STOP: - action = BDRV_ACTION_STOP; + action = BLOCK_ERROR_ACTION_STOP; break; case BLOCKDEV_ON_ERROR_REPORT: - action = BDRV_ACTION_REPORT; + action = BLOCK_ERROR_ACTION_REPORT; break; case BLOCKDEV_ON_ERROR_IGNORE: - action = BDRV_ACTION_IGNORE; + action = BLOCK_ERROR_ACTION_IGNORE; break; default: abort(); } bdrv_emit_qmp_error_event(job->bs, QEVENT_BLOCK_JOB_ERROR, action, is_read); - if (action == BDRV_ACTION_STOP) { + if (action == BLOCK_ERROR_ACTION_STOP) { block_job_pause(job); block_job_iostatus_set_err(job, error); if (bs != job->bs) { diff --git a/docs/qmp/qmp-events.txt b/docs/qmp/qmp-events.txt index 145402e..4a47645 100644 --- a/docs/qmp/qmp-events.txt +++ b/docs/qmp/qmp-events.txt @@ -1,39 +1,14 @@ - QEMU Machine Protocol Events - ============================ + QEMU Machine Protocol Events Examples + ===================================== BALLOON_CHANGE -------------- - -Emitted when the guest changes the actual BALLOON level. This -value is equivalent to the 'actual' field return by the -'query-balloon' command - -Data: - -- "actual": actual level of the guest memory balloon in bytes (json-number) - -Example: - { "event": "BALLOON_CHANGE", "data": { "actual": 944766976 }, "timestamp": { "seconds": 1267020223, "microseconds": 435656 } } BLOCK_IMAGE_CORRUPTED --------------------- - -Emitted when a disk image is being marked corrupt. - -Data: - -- "device": Device name (json-string) -- "msg": Informative message (e.g., reason for the corruption) (json-string) -- "offset": If the corruption resulted from an image access, this is the access - offset into the image (json-int) -- "size": If the corruption resulted from an image access, this is the access - size (json-int) - -Example: - { "event": "BLOCK_IMAGE_CORRUPTED", "data": { "device": "ide0-hd0", "msg": "Prevented active L1 table overwrite", "offset": 196608, @@ -42,47 +17,14 @@ Example: 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": error caused VM to be stopped - -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 ------------------- - -Emitted when a block job has been cancelled. - -Data: - -- "type": Job type (json-string; "stream" for image streaming - "commit" for block commit) -- "device": Device name (json-string) -- "len": Maximum progress value (json-int) -- "offset": Current progress value (json-int) - On success this is equal to len. - On failure this is less than len. -- "speed": Rate limit, bytes per second (json-int) - -Example: - { "event": "BLOCK_JOB_CANCELLED", "data": { "type": "stream", "device": "virtio-disk0", "len": 10737418240, "offset": 134217728, @@ -91,27 +33,6 @@ Example: BLOCK_JOB_COMPLETED ------------------- - -Emitted when a block job has completed. - -Data: - -- "type": Job type (json-string; "stream" for image streaming - "commit" for block commit) -- "device": Device name (json-string) -- "len": Maximum progress value (json-int) -- "offset": Current progress value (json-int) - On success this is equal to len. - On failure this is less than len. -- "speed": Rate limit, bytes per second (json-int) -- "error": Error message (json-string, optional) - Only present on failure. This field contains a human-readable - error message. There are no semantics other than that streaming - has failed and clients should not try to interpret the error - string. - -Example: - { "event": "BLOCK_JOB_COMPLETED", "data": { "type": "stream", "device": "virtio-disk0", "len": 10737418240, "offset": 10737418240, @@ -120,20 +41,6 @@ Example: 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", @@ -142,35 +49,12 @@ Example: BLOCK_JOB_READY --------------- - -Emitted when a block job is ready to complete. - -Data: - -- "device": device name (json-string) - -Example: - { "event": "BLOCK_JOB_READY", "data": { "device": "ide0-hd1" }, "timestamp": { "seconds": 1265044230, "microseconds": 450486 } } -Note: The "ready to complete" status is always reset by a BLOCK_JOB_ERROR -event. - DEVICE_DELETED -------------- - -Emitted whenever the device removal completion is acknowledged -by the guest. -At this point, it's safe to reuse the specified device ID. -Device removal can be initiated by the guest or by HMP/QMP commands. - -Data: - -- "device": device name (json-string, optional) -- "path": device path (json-string) - { "event": "DEVICE_DELETED", "data": { "device": "virtio-net-pci-0", "path": "/machine/peripheral/virtio-net-pci-0" }, @@ -178,16 +62,6 @@ Data: DEVICE_TRAY_MOVED ----------------- - -It's emitted whenever the tray of a removable device is moved by the guest -or by HMP/QMP commands. - -Data: - -- "device": device name (json-string) -- "tray-open": true if the tray has been opened or false if it has been closed - (json-bool) - { "event": "DEVICE_TRAY_MOVED", "data": { "device": "ide1-cd0", "tray-open": true @@ -196,29 +70,11 @@ Data: 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" } } NIC_RX_FILTER_CHANGED --------------------- - -The event is emitted once until the query command is executed, -the first event will always be emitted. - -Data: - -- "name": net client name (json-string) -- "path": device path (json-string) - { "event": "NIC_RX_FILTER_CHANGED", "data": { "name": "vnet0", "path": "/machine/peripheral/vnet0/virtio-backend" }, @@ -227,116 +83,39 @@ Data: QUORUM_FAILURE -------------- - -Emitted by the Quorum block driver if it fails to establish a quorum. - -Data: - -- "reference": device name if defined else node name. -- "sector-num": Number of the first sector of the failed read operation. -- "sector-count": Failed read operation sector count. - -Example: - { "event": "QUORUM_FAILURE", "data": { "reference": "usr1", "sector-num": 345435, "sector-count": 5 }, "timestamp": { "seconds": 1344522075, "microseconds": 745528 } } QUORUM_REPORT_BAD ----------------- - -Emitted to report a corruption of a Quorum file. - -Data: - -- "error": Error message (json-string, optional) - Only present on failure. This field contains a human-readable - error message. There are no semantics other than that the - block layer reported an error and clients should not try to - interpret the error string. -- "node-name": The graph node name of the block driver state. -- "sector-num": Number of the first sector of the failed read operation. -- "sector-count": Failed read operation sector count. - -Example: - { "event": "QUORUM_REPORT_BAD", "data": { "node-name": "1.raw", "sector-num": 345435, "sector-count": 5 }, "timestamp": { "seconds": 1344522075, "microseconds": 745528 } } RESET ----- - -Emitted when the Virtual Machine is reseted. - -Data: None. - -Example: - { "event": "RESET", "timestamp": { "seconds": 1267041653, "microseconds": 9518 } } RESUME ------ - -Emitted when the Virtual Machine resumes execution. - -Data: None. - -Example: - { "event": "RESUME", "timestamp": { "seconds": 1271770767, "microseconds": 582542 } } RTC_CHANGE ---------- - -Emitted when the guest changes the RTC time. - -Data: - -- "offset": Offset between base RTC clock (as specified by -rtc base), and -new RTC clock value (json-number) - -Example: - { "event": "RTC_CHANGE", "data": { "offset": 78 }, "timestamp": { "seconds": 1267020223, "microseconds": 435656 } } SHUTDOWN -------- - -Emitted when the Virtual Machine is powered down. - -Data: None. - -Example: - { "event": "SHUTDOWN", "timestamp": { "seconds": 1267040730, "microseconds": 682951 } } -Note: If the command-line option "-no-shutdown" has been specified, a STOP -event will eventually follow the SHUTDOWN event. - SPICE_CONNECTED, SPICE_DISCONNECTED ----------------------------------- - -Emitted when a SPICE client connects or disconnects. - -Data: - -- "server": Server information (json-object) - - "host": IP address (json-string) - - "port": port number (json-string) - - "family": address family (json-string, "ipv4" or "ipv6") -- "client": Client information (json-object) - - "host": IP address (json-string) - - "port": port number (json-string) - - "family": address family (json-string, "ipv4" or "ipv6") - -Example: - { "timestamp": {"seconds": 1290688046, "microseconds": 388707}, "event": "SPICE_CONNECTED", "data": { @@ -346,32 +125,6 @@ Example: SPICE_INITIALIZED ----------------- - -Emitted after initial handshake and authentication takes place (if any) -and the SPICE channel is up'n'running - -Data: - -- "server": Server information (json-object) - - "host": IP address (json-string) - - "port": port number (json-string) - - "family": address family (json-string, "ipv4" or "ipv6") - - "auth": authentication method (json-string, optional) -- "client": Client information (json-object) - - "host": IP address (json-string) - - "port": port number (json-string) - - "family": address family (json-string, "ipv4" or "ipv6") - - "connection-id": spice connection id. All channels with the same id - belong to the same spice session (json-int) - - "channel-type": channel type. "1" is the main control channel, filter for - this one if you want track spice sessions only (json-int) - - "channel-id": channel id. Usually "0", might be different needed when - multiple channels of the same type exist, such as multiple - display channels in a multihead setup (json-int) - - "tls": whevener the channel is encrypted (json-bool) - -Example: - { "timestamp": {"seconds": 1290688046, "microseconds": 417172}, "event": "SPICE_INITIALIZED", "data": {"server": {"auth": "spice", "port": "5921", @@ -383,61 +136,21 @@ Example: STOP ---- - -Emitted when the Virtual Machine is stopped. - -Data: None. - -Example: - { "event": "STOP", "timestamp": { "seconds": 1267041730, "microseconds": 281295 } } SUSPEND ------- - -Emitted when guest enters S3 state. - -Data: None. - -Example: - { "event": "SUSPEND", "timestamp": { "seconds": 1344456160, "microseconds": 309119 } } SUSPEND_DISK ------------ - -Emitted when the guest makes a request to enter S4 state. - -Data: None. - -Example: - { "event": "SUSPEND_DISK", "timestamp": { "seconds": 1344456160, "microseconds": 309119 } } -Note: QEMU shuts down when entering S4 state. - VNC_CONNECTED ------------- - -Emitted when a VNC client establishes a connection. - -Data: - -- "server": Server information (json-object) - - "host": IP address (json-string) - - "service": port number (json-string) - - "family": address family (json-string, "ipv4" or "ipv6") - - "auth": authentication method (json-string, optional) -- "client": Client information (json-object) - - "host": IP address (json-string) - - "service": port number (json-string) - - "family": address family (json-string, "ipv4" or "ipv6") - -Example: - { "event": "VNC_CONNECTED", "data": { "server": { "auth": "sasl", "family": "ipv4", @@ -446,31 +159,8 @@ Example: "host": "127.0.0.1" } }, "timestamp": { "seconds": 1262976601, "microseconds": 975795 } } - -Note: This event is emitted before any authentication takes place, thus -the authentication ID is not provided. - VNC_DISCONNECTED ---------------- - -Emitted when the connection is closed. - -Data: - -- "server": Server information (json-object) - - "host": IP address (json-string) - - "service": port number (json-string) - - "family": address family (json-string, "ipv4" or "ipv6") - - "auth": authentication method (json-string, optional) -- "client": Client information (json-object) - - "host": IP address (json-string) - - "service": port number (json-string) - - "family": address family (json-string, "ipv4" or "ipv6") - - "x509_dname": TLS dname (json-string, optional) - - "sasl_username": SASL username (json-string, optional) - -Example: - { "event": "VNC_DISCONNECTED", "data": { "server": { "auth": "sasl", "family": "ipv4", @@ -481,26 +171,6 @@ Example: VNC_INITIALIZED --------------- - -Emitted after authentication takes place (if any) and the VNC session is -made active. - -Data: - -- "server": Server information (json-object) - - "host": IP address (json-string) - - "service": port number (json-string) - - "family": address family (json-string, "ipv4" or "ipv6") - - "auth": authentication method (json-string, optional) -- "client": Client information (json-object) - - "host": IP address (json-string) - - "service": port number (json-string) - - "family": address family (json-string, "ipv4" or "ipv6") - - "x509_dname": TLS dname (json-string, optional) - - "sasl_username": SASL username (json-string, optional) - -Example: - { "event": "VNC_INITIALIZED", "data": { "server": { "auth": "sasl", "family": "ipv4", @@ -511,31 +181,11 @@ Example: WAKEUP ------ - -Emitted when the guest has woken up from S3 and is running. - -Data: None. - -Example: - { "event": "WAKEUP", "timestamp": { "seconds": 1344522075, "microseconds": 745528 } } 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/hmp.c b/hmp.c index ca869ba..10598d3 100644 --- a/hmp.c +++ b/hmp.c @@ -453,7 +453,8 @@ void hmp_info_vnc(Monitor *mon, const QDict *qdict) for (client = info->clients; client; client = client->next) { monitor_printf(mon, "Client:\n"); monitor_printf(mon, " address: %s:%s\n", - client->value->host, client->value->service); + client->value->base->host, + client->value->base->service); monitor_printf(mon, " x509_dname: %s\n", client->value->x509_dname ? client->value->x509_dname : "none"); @@ -501,7 +502,7 @@ void hmp_info_spice(Monitor *mon, const QDict *qdict) for (chan = info->channels; chan; chan = chan->next) { monitor_printf(mon, "Channel:\n"); monitor_printf(mon, " address: %s:%s%s\n", - chan->value->host, chan->value->port, + chan->value->base->host, chan->value->base->port, chan->value->tls ? " [tls]" : ""); monitor_printf(mon, " session: %" PRId64 "\n", chan->value->connection_id); diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index 8a568e5..62ac610 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -57,17 +57,17 @@ static int virtio_blk_handle_rw_error(VirtIOBlockReq *req, int error, BlockErrorAction action = bdrv_get_error_action(req->dev->bs, is_read, error); VirtIOBlock *s = req->dev; - if (action == BDRV_ACTION_STOP) { + if (action == BLOCK_ERROR_ACTION_STOP) { req->next = s->rq; s->rq = req; - } else if (action == BDRV_ACTION_REPORT) { + } else if (action == BLOCK_ERROR_ACTION_REPORT) { virtio_blk_req_complete(req, VIRTIO_BLK_S_IOERR); bdrv_acct_done(s->bs, &req->acct); g_free(req); } bdrv_error_action(s->bs, action, is_read, error); - return action != BDRV_ACTION_IGNORE; + return action != BLOCK_ERROR_ACTION_IGNORE; } static void virtio_blk_rw_complete(void *opaque, int ret) diff --git a/hw/ide/core.c b/hw/ide/core.c index c943a4d..f6ea5c6 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -596,10 +596,10 @@ static int ide_handle_rw_error(IDEState *s, int error, int op) bool is_read = (op & BM_STATUS_RETRY_READ) != 0; BlockErrorAction action = bdrv_get_error_action(s->bs, is_read, error); - if (action == BDRV_ACTION_STOP) { + if (action == BLOCK_ERROR_ACTION_STOP) { s->bus->dma->ops->set_unit(s->bus->dma, s->unit); s->bus->error_status = op; - } else if (action == BDRV_ACTION_REPORT) { + } else if (action == BLOCK_ERROR_ACTION_REPORT) { if (op & BM_STATUS_DMA_RETRY) { dma_buf_commit(s); ide_dma_error(s); @@ -608,7 +608,7 @@ static int ide_handle_rw_error(IDEState *s, int error, int op) } } bdrv_error_action(s->bs, action, is_read, error); - return action != BDRV_ACTION_IGNORE; + return action != BLOCK_ERROR_ACTION_IGNORE; } void ide_dma_cb(void *opaque, int ret) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index 48a28ae..5c141c0 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -419,7 +419,7 @@ static int scsi_handle_rw_error(SCSIDiskReq *r, int error) SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev); BlockErrorAction action = bdrv_get_error_action(s->qdev.conf.bs, is_read, error); - if (action == BDRV_ACTION_REPORT) { + if (action == BLOCK_ERROR_ACTION_REPORT) { switch (error) { case ENOMEDIUM: scsi_check_condition(r, SENSE_CODE(NO_MEDIUM)); @@ -439,10 +439,10 @@ static int scsi_handle_rw_error(SCSIDiskReq *r, int error) } } bdrv_error_action(s->qdev.conf.bs, action, is_read, error); - if (action == BDRV_ACTION_STOP) { + if (action == BLOCK_ERROR_ACTION_STOP) { scsi_req_retry(&r->req); } - return action != BDRV_ACTION_IGNORE; + return action != BLOCK_ERROR_ACTION_IGNORE; } static void scsi_write_complete(void * opaque, int ret) diff --git a/include/block/block.h b/include/block/block.h index c12808a..d874465 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -142,10 +142,6 @@ typedef enum { #define BDRV_BLOCK_RAW 8 #define BDRV_BLOCK_OFFSET_MASK BDRV_SECTOR_MASK -typedef enum { - BDRV_ACTION_REPORT, BDRV_ACTION_IGNORE, BDRV_ACTION_STOP -} BlockErrorAction; - typedef QSIMPLEQ_HEAD(BlockReopenQueue, BlockReopenQueueEntry) BlockReopenQueue; typedef struct BDRVReopenState { diff --git a/include/qemu/sockets.h b/include/qemu/sockets.h index 45588d7..af24669 100644 --- a/include/qemu/sockets.h +++ b/include/qemu/sockets.h @@ -29,6 +29,7 @@ int inet_aton(const char *cp, struct in_addr *ia); #include "qemu/option.h" #include "qapi/error.h" #include "qapi/qmp/qerror.h" +#include "qapi-types.h" extern QemuOptsList socket_optslist; @@ -61,6 +62,7 @@ int inet_nonblocking_connect(const char *str, int inet_dgram_opts(QemuOpts *opts, Error **errp); const char *inet_strfamily(int family); +NetworkAddressFamily inet_netfamily(int family); int unix_listen_opts(QemuOpts *opts, Error **errp); int unix_listen(const char *path, char *ostr, int olen, Error **errp); diff --git a/qapi-schema.json b/qapi-schema.json index 0b00427..cb790e2 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -1155,21 +1155,58 @@ { 'command': 'query-blockstats', 'returns': ['BlockStats'] } ## -# @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 +# +# The basic information for vnc network connection # -# @host: The host name of the client. QEMU tries to resolve this to a DNS name -# when possible. +# @host: IP address # -# @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 +# @service: port number # -# @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. +# @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: +# +# Information about a connected VNC client. # # @x509_dname: #optional If x509 authentication is in use, the Distinguished # Name of the client. @@ -1180,8 +1217,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: @@ -1220,7 +1257,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']} } ## @@ -1235,19 +1273,40 @@ { 'command': 'query-vnc', 'returns': 'VncInfo' } ## -# @SpiceChannel +# @SpiceBasicInfo # -# Information about a SPICE client channel. +# The basic information for SPICE network connection +# +# @host: IP address # -# @host: The host name of the client. QEMU tries to resolve this to a DNS name -# when possible. +# @port: port number # -# @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 +# @family: address family +# +# Since: 2.1 +## +{ 'type': 'SpiceBasicInfo', + 'data': { 'host': 'str', + 'port': 'str', + 'family': 'NetworkAddressFamily' } } + +## +# @SpiceServerInfo +# +# Information about a SPICE server +# +# @auth: #optional, authentication method +# +# Since: 2.1 +## +{ 'type': 'SpiceServerInfo', + 'base': 'SpiceBasicInfo', + 'data': { '*auth': 'str' } } + +## +# @SpiceChannel # -# @port: The client's port number. +# Information about a SPICE client channel. # # @connection-id: SPICE connection id number. All channels with the same id # belong to the same SPICE session. @@ -1265,8 +1324,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'} } ## @@ -4695,3 +4754,526 @@ 'btn' : 'InputBtnEvent', 'rel' : 'InputMoveEvent', 'abs' : 'InputMoveEvent' } } + +## +# Event defines +## + +## +# @SHUTDOWN +# +# Emitted when the virtual machine shutdown, qemu terminated the emulation and +# is about to exit. +# +# Note: If the command-line option "-no-shutdown" has been specified, qemu will +# not exit, and a STOP event will eventually follow the SHUTDOWN event +# +# Since: 2.1 +## +{ 'event': 'SHUTDOWN' } + +## +# @POWERDOWN +# +# Emitted when the virtual machine is powered down through the power control +# system, such as via ACPI. +# +# Since: 2.1 +## +{ 'event': 'POWERDOWN' } + +## +# @RESET +# +# Emitted when the virtual machine is reset +# +# Since: 2.1 +## +{ 'event': 'RESET' } + +## +# @STOP +# +# Emitted when the virtual machine is stopped +# +# Since: 2.1 +## +{ 'event': 'STOP' } + +## +# @RESUME +# +# Emitted when the virtual machine resumes execution +# +# Since: 2.1 +## +{ 'event': 'RESUME' } + +## +# @SUSPEND +# +# Emitted when guest enters a hardware suspension state, for example, S3 state, +# which is sometimes called standby state +# +# Since: 2.1 +## +{ 'event': 'SUSPEND' } + +## +# @SUSPEND_DISK +# +# Emitted when guest enters a hardware suspension state with data saved on +# disk, for example, S4 state, which is sometimes called hibernate state +# +# Note: QEMU shuts down (similar to event @SHUTDOWN) when entering this state +# +# Since: 2.1 +## +{ 'event': 'SUSPEND_DISK' } + +## +# @WAKEUP +# +# Emitted when the guest has woken up from suspend state and is running +# +# Since: 2.1 +## +{ 'event': 'WAKEUP' } + +## +# @RTC_CHANGE +# +# Emitted when the guest changes the RTC time. +# +# @offset: offset between base RTC clock (as specified by -rtc base), and +# new RTC clock value +# +# Since: 2.1 +## +{ 'event': 'RTC_CHANGE', + 'data': { 'offset': 'int' } } + +## +# @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' ] } + +## +# @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: 2.1 +## +{ 'event': 'WATCHDOG', + 'data': { 'action': 'WatchdogExpirationAction' } } + +## +# @DEVICE_DELETED +# +# Emitted whenever the device removal completion is acknowledged by the guest. +# At this point, it's safe to reuse the specified device ID. Device removal can +# be initiated by the guest or by HMP/QMP commands. +# +# @device: #optional, device name +# +# @path: device path +# +# Since: 2.1 +## +{ 'event': 'DEVICE_DELETED', + 'data': { '*device': 'str', 'path': 'str' } } + +## +# @DEVICE_TRAY_MOVED +# +# Emitted whenever the tray of a removable device is moved by the guest or by +# HMP/QMP commands +# +# @device: device name +# +# @tray-open: true if the tray has been opened or false if it has been closed +# +# Since: 2.1 +## +{ 'event': 'DEVICE_TRAY_MOVED', + 'data': { 'device': 'str', 'tray-open': 'bool' } } + +## +# @IoOperationType +# +# An enumeration of the I/O operation types +# +# @read: read operation +# +# @write: write operation +# +# Since: 2.1 +## +{ 'enum': 'IoOperationType', + 'data': [ 'read', 'write' ] } + +## +# @BlockErrorAction +# +# An enumeration of action that has been taken when a DISK I/O occurs +# +# @ignore: error has been ignored +# +# @report: error has been reported to the device +# +# @stop: error caused VM to be stopped +# +# Since: 2.1 +## +{ '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: 2.1 +## +{ 'event': 'BLOCK_IO_ERROR', + 'data': { 'device': 'str', 'operation': 'IoOperationType', + 'action': 'BlockErrorAction' } } + +## +# @BLOCK_IMAGE_CORRUPTED +# +# Emitted when a disk image is being marked corrupt +# +# @device: device name +# +# @msg: informative message, for example, reason for the corruption +# +# @offset: #optional, if the corruption resulted from an image access, this is +# the access offset into the image +# @size: #optional, if the corruption resulted from an image access, this is +# the access size +# +# Since: 2.1 +## +{ 'event': 'BLOCK_IMAGE_CORRUPTED', + 'data': { 'device' : 'str', + 'msg' : 'str', + '*offset': 'int', + '*size' : 'int' } } + +## +# @BLOCK_JOB_COMPLETED +# +# Emitted when a block job has completed +# +# @type: job type +# +# @device: device name +# +# @len: maximum progress value +# +# @offset: current progress value. On success this is equal to len. +# On failure this is less than len +# +# @speed: rate limit, bytes per second +# +# @error: #optional, error message. Only present on failure. This field +# contains a human-readable error message. There are no semantics +# other than that streaming has failed and clients should not try to +# interpret the error string +# +# Since: 2.1 +## +{ 'event': 'BLOCK_JOB_COMPLETED', + 'data': { 'type' : 'BlockJobType', + 'device': 'str', + 'len' : 'int', + 'offset': 'int', + 'speed' : 'int', + '*error': 'str' } } + +## +# @BLOCK_JOB_CANCELLED +# +# Emitted when a block job has been cancelled +# +# @type: job type +# +# @device: device name +# +# @len: maximum progress value +# +# @offset: current progress value. On success this is equal to len. +# On failure this is less than len +# +# @speed: rate limit, bytes per second +# +# Since: 2.1 +## +{ 'event': 'BLOCK_JOB_CANCELLED', + 'data': { 'type' : 'BlockJobType', + 'device': 'str', + 'len' : 'int', + 'offset': 'int', + 'speed' : 'int' } } + +## +# @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: 2.1 +## +{ 'event': 'BLOCK_JOB_ERROR', + 'data': { 'device' : 'str', + 'operation': 'IoOperationType', + 'action' : 'BlockdevOnError' } } + +## +# @BLOCK_JOB_READY +# +# Emitted when a block job is ready to complete +# +# @device: device name +# +# Note: The "ready to complete" status is always reset by a @BLOCK_JOB_ERROR +# event +# +# Since: 2.1 +## +{ 'event': 'BLOCK_JOB_READY', + 'data': { 'device': 'str' } } + +## +# @NIC_RX_FILTER_CHANGED +# +# Emitted once until the 'query-rx-filter' command is executed, the first event +# will always be emitted +# +# @name: #optional, net client name +# +# @path: device path +# +# Since: 2.1 +## +{ 'event': 'NIC_RX_FILTER_CHANGED', + 'data': { '*name': 'str', 'path': 'str' } } + +## +# @VNC_CONNECTED +# +# Emitted when a VNC client establishes a connection +# +# @server: server information +# +# @client: client information +# +# Note: This event is emitted before any authentication takes place, thus +# the authentication ID is not provided +# +# Since: 2.1 +## +{ 'event': 'VNC_CONNECTED', + 'data': { 'server': 'VncServerInfo', + 'client': 'VncBasicInfo' } } + +## +# @VNC_INITIALIZED +# +# Emitted after authentication takes place (if any) and the VNC session is +# made active +# +# @server: server information +# +# @client: client information +# +# Since: 2.1 +## +{ 'event': 'VNC_INITIALIZED', + 'data': { 'server': 'VncServerInfo', + 'client': 'VncClientInfo' } } + +## +# @VNC_DISCONNECTED +# +# Emitted when the connection is closed +# +# @server: server information +# +# @client: client information +# +# Since: 2.1 +## +{ 'event': 'VNC_DISCONNECTED', + 'data': { 'server': 'VncServerInfo', + 'client': 'VncClientInfo' } } + +## +# @SPICE_CONNECTED +# +# Emitted when a SPICE client establishes a connection +# +# @server: server information +# +# @client: client information +# +# Since: 2.1 +## +{ 'event': 'SPICE_CONNECTED', + 'data': { 'server': 'SpiceBasicInfo', + 'client': 'SpiceBasicInfo' } } + +## +# @SPICE_INITIALIZED +# +# Emitted after initial handshake and authentication takes place (if any) +# and the SPICE channel is up and running +# +# @server: server information +# +# @client: client information +# +# Since: 2.1 +## +{ 'event': 'SPICE_INITIALIZED', + 'data': { 'server': 'SpiceServerInfo', + 'client': 'SpiceChannel' } } + +## +# @SPICE_DISCONNECTED +# +# Emitted when the SPICE connection is closed +# +# @server: server information +# +# @client: client information +# +# Since: 2.1 +## +{ 'event': 'SPICE_DISCONNECTED', + 'data': { 'server': 'SpiceBasicInfo', + 'client': 'SpiceBasicInfo' } } + +## +# @SPICE_MIGRATE_COMPLETED +# +# Emitted when SPICE migration has completed +# +# Since: 2.1 +## +{ 'event': 'SPICE_MIGRATE_COMPLETED' } + +## +# @BALLOON_CHANGE +# +# Emitted when the guest changes the actual BALLOON level. This value is +# equivalent to the @actual field return by the 'query-balloon' command +# +# @actual: actual level of the guest memory balloon in bytes +# +# Since: 2.1 +## +{ 'event': 'BALLOON_CHANGE', + 'data': { 'actual': 'int' } } + +## +# @GuestPanickAction +# +# An enumeration of the actions taken when guest OS panic is detected +# +# @pause: system pauses +# +# Since: 2.1 +## +{ 'enum': 'GuestPanickAction', + 'data': [ 'pause' ] } + +## +# @GUEST_PANICKED +# +# Emitted when guest OS panic is detected +# +# @action: action that has been taken, currently always "pause" +# +# Since: 2.1 +## +{ 'event': 'GUEST_PANICKED', + 'data': { 'action': 'GuestPanickAction' } } + +## +# @QUORUM_FAILURE +# +# Emitted by the Quorum block driver if it fails to establish a quorum +# +# @reference: device name if defined else node name +# +# @sector-num: number of the first sector of the failed read operation +# +# @sector-count: failed read operation sector count +# +# Since: 2.1 +## +{ 'event': 'QUORUM_FAILURE', + 'data': { 'reference': 'str', 'sector-num': 'int', 'sector-count': 'int' } } + +## +# @QUORUM_REPORT_BAD +# +# Emitted to report a corruption of a Quorum file +# +# @error: #optional, error message. Only present on failure. This field +# contains a human-readable error message. There are no semantics other +# than that the block layer reported an error and clients should not +# try to interpret the error string. +# +# @node-name: the graph node name of the block driver state +# +# @sector-num: number of the first sector of the failed read operation +# +# @sector-count: failed read operation sector count +# +# Since: 2.1 +## +{ 'event': 'QUORUM_REPORT_BAD', + 'data': { '*error': 'str', 'node-name': 'str', + 'sector-num': 'int', 'sector-count': 'int' } } diff --git a/ui/spice-core.c b/ui/spice-core.c index 4cce3b3..387f0ab 100644 --- a/ui/spice-core.c +++ b/ui/spice-core.c @@ -390,15 +390,16 @@ static SpiceChannelList *qmp_query_spice_channels(void) chan = g_malloc0(sizeof(*chan)); chan->value = g_malloc0(sizeof(*chan->value)); + chan->value->base = g_malloc0(sizeof(*chan->value->base)); paddr = (struct sockaddr *)&item->info->paddr_ext; plen = item->info->plen_ext; getnameinfo(paddr, plen, host, sizeof(host), port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV); - chan->value->host = g_strdup(host); - chan->value->port = g_strdup(port); - chan->value->family = g_strdup(inet_strfamily(paddr->sa_family)); + chan->value->base->host = g_strdup(host); + chan->value->base->port = g_strdup(port); + chan->value->base->family = inet_netfamily(paddr->sa_family); chan->value->connection_id = item->info->connection_id; chan->value->channel_type = item->info->type; diff --git a/ui/vnc.c b/ui/vnc.c index 2d7def9..b03b3b8 100644 --- a/ui/vnc.c +++ b/ui/vnc.c @@ -320,9 +320,10 @@ static VncClientInfo *qmp_query_vnc_client(const VncState *client) } info = g_malloc0(sizeof(*info)); - info->host = g_strdup(host); - info->service = g_strdup(serv); - info->family = g_strdup(inet_strfamily(sa.ss_family)); + info->base = g_malloc0(sizeof(*info->base)); + info->base->host = g_strdup(host); + info->base->service = g_strdup(serv); + info->base->family = inet_netfamily(sa.ss_family); #ifdef CONFIG_VNC_TLS if (client->tls.session && client->tls.dname) { @@ -397,7 +398,7 @@ VncInfo *qmp_query_vnc(Error **errp) info->service = g_strdup(serv); info->has_family = true; - info->family = g_strdup(inet_strfamily(sa.ss_family)); + info->family = inet_netfamily(sa.ss_family); info->has_auth = true; info->auth = g_strdup(vnc_auth_name(vnc_display)); diff --git a/util/qemu-sockets.c b/util/qemu-sockets.c index 8818d7c..777aca2 100644 --- a/util/qemu-sockets.c +++ b/util/qemu-sockets.c @@ -104,6 +104,16 @@ const char *inet_strfamily(int family) return "unknown"; } +NetworkAddressFamily inet_netfamily(int family) +{ + switch (family) { + case PF_INET6: return NETWORK_ADDRESS_FAMILY_IPV6; + case PF_INET: return NETWORK_ADDRESS_FAMILY_IPV4; + case PF_UNIX: return NETWORK_ADDRESS_FAMILY_UNIX; + } + return NETWORK_ADDRESS_FAMILY_UNKNOWN; +} + int inet_listen_opts(QemuOpts *opts, int port_offset, Error **errp) { struct addrinfo ai,*res,*e; -- 1.7.1