block: add 'node-name' field to BLOCK_IMAGE_CORRUPTED

Since this event can occur in nodes that cannot have a device name
associated, include also a field with the node name.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-id: 147cec5b3594f4bec0cb41c98afe5fcbfb67567c.1428485266.git.berto@igalia.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
Alberto Garcia 2015-04-08 12:29:20 +03:00 committed by Kevin Wolf
parent 81e5f78a9f
commit dc881b441d
3 changed files with 30 additions and 16 deletions

View File

@ -2824,6 +2824,7 @@ void qcow2_signal_corruption(BlockDriverState *bs, bool fatal, int64_t offset,
int64_t size, const char *message_format, ...) int64_t size, const char *message_format, ...)
{ {
BDRVQcowState *s = bs->opaque; BDRVQcowState *s = bs->opaque;
const char *node_name;
char *message; char *message;
va_list ap; va_list ap;
@ -2847,8 +2848,11 @@ void qcow2_signal_corruption(BlockDriverState *bs, bool fatal, int64_t offset,
"corruption events will be suppressed\n", message); "corruption events will be suppressed\n", message);
} }
qapi_event_send_block_image_corrupted(bdrv_get_device_name(bs), message, node_name = bdrv_get_node_name(bs);
offset >= 0, offset, size >= 0, size, qapi_event_send_block_image_corrupted(bdrv_get_device_name(bs),
*node_name != '\0', node_name,
message, offset >= 0, offset,
size >= 0, size,
fatal, &error_abort); fatal, &error_abort);
g_free(message); g_free(message);

View File

@ -31,21 +31,26 @@ Example:
BLOCK_IMAGE_CORRUPTED BLOCK_IMAGE_CORRUPTED
--------------------- ---------------------
Emitted when a disk image is being marked corrupt. Emitted when a disk image is being marked corrupt. The image can be
identified by its device or node name. The 'device' field is always
present for compatibility reasons, but it can be empty ("") if the
image does not have a device name associated.
Data: Data:
- "device": Device name (json-string) - "device": Device name (json-string)
- "msg": Informative message (e.g., reason for the corruption) (json-string) - "node-name": Node name (json-string, optional)
- "offset": If the corruption resulted from an image access, this is the access - "msg": Informative message (e.g., reason for the corruption)
offset into the image (json-int) (json-string)
- "size": If the corruption resulted from an image access, this is the access - "offset": If the corruption resulted from an image access, this
size (json-int) 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: Example:
{ "event": "BLOCK_IMAGE_CORRUPTED", { "event": "BLOCK_IMAGE_CORRUPTED",
"data": { "device": "ide0-hd0", "data": { "device": "ide0-hd0", "node-name": "node0",
"msg": "Prevented active L1 table overwrite", "offset": 196608, "msg": "Prevented active L1 table overwrite", "offset": 196608,
"size": 65536 }, "size": 65536 },
"timestamp": { "seconds": 1378126126, "microseconds": 966463 } } "timestamp": { "seconds": 1378126126, "microseconds": 966463 } }

View File

@ -1757,7 +1757,11 @@
# #
# Emitted when a corruption has been detected in a disk image # Emitted when a corruption has been detected in a disk image
# #
# @device: device name # @device: device name. This is always present for compatibility
# reasons, but it can be empty ("") if the image does not
# have a device name associated.
#
# @node-name: #optional node name (Since: 2.4)
# #
# @msg: informative message for human consumption, such as the kind of # @msg: informative message for human consumption, such as the kind of
# corruption being detected. It should not be parsed by machine as it is # corruption being detected. It should not be parsed by machine as it is
@ -1776,11 +1780,12 @@
# Since: 1.7 # Since: 1.7
## ##
{ 'event': 'BLOCK_IMAGE_CORRUPTED', { 'event': 'BLOCK_IMAGE_CORRUPTED',
'data': { 'device' : 'str', 'data': { 'device' : 'str',
'msg' : 'str', '*node-name' : 'str',
'*offset': 'int', 'msg' : 'str',
'*size' : 'int', '*offset' : 'int',
'fatal' : 'bool' } } '*size' : 'int',
'fatal' : 'bool' } }
## ##
# @BLOCK_IO_ERROR # @BLOCK_IO_ERROR