[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 01/22] block: extend BLOCK_IO_ERROR event with nospac
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 01/22] block: extend BLOCK_IO_ERROR event with nospace indicator |
Date: |
Fri, 12 Sep 2014 17:56:45 +0200 |
From: Luiz Capitulino <address@hidden>
Management software, such as RHEV's vdsm, want to be able to allocate
disk space on demand. The basic use case is to start a VM with a small
disk and then the disk is enlarged when QEMU hits a ENOSPC condition.
To this end, the management software has to be notified when QEMU
encounters ENOSPC. The solution implemented by this commit is simple:
it extends the BLOCK_IO_ERROR with a 'nospace' key, which is true
when QEMU is stopped due to ENOSPC.
Note that support for querying this event is already present in
query-block by means of the 'io-status' key. Also, the new 'nospace'
BLOCK_IO_ERROR field shares the same semantics with 'io-status',
which basically means that werror= has to be set to either
'stop' or 'enospc' to enable 'nospace'.
Finally, this commit also updates the 'io-status' key doc in the
schema with a list of supported device models.
Signed-off-by: Luiz Capitulino <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block.c | 22 ++++++++++++++--------
qapi/block-core.json | 8 +++++++-
2 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/block.c b/block.c
index d06dd51..460effe 100644
--- a/block.c
+++ b/block.c
@@ -3639,6 +3639,18 @@ BlockErrorAction bdrv_get_error_action(BlockDriverState
*bs, bool is_read, int e
}
}
+static void send_qmp_error_event(BlockDriverState *bs,
+ BlockErrorAction action,
+ bool is_read, int error)
+{
+ BlockErrorAction ac;
+
+ ac = is_read ? IO_OPERATION_TYPE_READ : IO_OPERATION_TYPE_WRITE;
+ qapi_event_send_block_io_error(bdrv_get_device_name(bs), ac, action,
+ bdrv_iostatus_is_enabled(bs),
+ error == ENOSPC, &error_abort);
+}
+
/* This is done by device models because, while the block layer knows
* about the error, it does not know whether an operation comes from
* the device or the block layer (from a job, for example).
@@ -3664,16 +3676,10 @@ void bdrv_error_action(BlockDriverState *bs,
BlockErrorAction action,
* also ensures that the STOP/RESUME pair of events is emitted.
*/
qemu_system_vmstop_request_prepare();
- qapi_event_send_block_io_error(bdrv_get_device_name(bs),
- is_read ? IO_OPERATION_TYPE_READ :
- IO_OPERATION_TYPE_WRITE,
- action, &error_abort);
+ send_qmp_error_event(bs, action, is_read, error);
qemu_system_vmstop_request(RUN_STATE_IO_ERROR);
} else {
- qapi_event_send_block_io_error(bdrv_get_device_name(bs),
- is_read ? IO_OPERATION_TYPE_READ :
- IO_OPERATION_TYPE_WRITE,
- action, &error_abort);
+ send_qmp_error_event(bs, action, is_read, error);
}
}
diff --git a/qapi/block-core.json b/qapi/block-core.json
index a685d02..68945c2 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -336,6 +336,7 @@
#
# @io-status: #optional @BlockDeviceIoStatus. Only present if the device
# supports it and the VM is configured to stop on errors
+# (supported device models: virtio-blk, ide, scsi-disk)
#
# @inserted: #optional @BlockDeviceInfo describing the device if media is
# present
@@ -1587,6 +1588,11 @@
#
# @action: action that has been taken
#
+# @nospace: #optional true if I/O error was caused due to a no-space
+# condition. This key is only present if query-block's
+# io-status is present, please see query-block documentation
+# for more information (since: 2.2)
+#
# Note: If action is "stop", a STOP event will eventually follow the
# BLOCK_IO_ERROR event
#
@@ -1594,7 +1600,7 @@
##
{ 'event': 'BLOCK_IO_ERROR',
'data': { 'device': 'str', 'operation': 'IoOperationType',
- 'action': 'BlockErrorAction' } }
+ 'action': 'BlockErrorAction', '*nospace': 'bool' } }
##
# @BLOCK_JOB_COMPLETED
--
1.8.3.1
- [Qemu-devel] [PULL 00/22] Block patches, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 02/22] Fix improper usage of cpu_to_be32 in vpc, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 03/22] qemu-io: Clean up openfile() after commit 2e40134, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 04/22] xen_disk: Plug memory leak on error path, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 05/22] xen: Drop redundant bdrv_close() from pci_piix3_xen_ide_unplug(), Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 09/22] block: Extract the block accounting code, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 01/22] block: extend BLOCK_IO_ERROR event with nospace indicator,
Kevin Wolf <=
- [Qemu-devel] [PULL 07/22] IDE: MMIO IDE device control should be little endian, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 10/22] block: rename BlockAcctType members to start with BLOCK_ instead of BDRV_, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 11/22] block: Make the block accounting functions operate on BlockAcctStats, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 06/22] thread-pool: Drop unnecessary includes, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 08/22] block: Extract the BlockAcctStats structure, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 12/22] block/archipelago: Implement bdrv_truncate(), Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 13/22] qemu-iotests: Run 025 for Archipelago block driver, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 14/22] dataplane: fix virtio_blk_data_plane_create() op blocker error path, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 17/22] iotests: Send the correct fd in socket_scm_helper, Kevin Wolf, 2014/09/12
- [Qemu-devel] [PULL 18/22] block: round up file size to nearest sector, Kevin Wolf, 2014/09/12