[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 05/11] block: Add QMP support for streaming to an in
From: |
Alberto Garcia |
Subject: |
[Qemu-devel] [PATCH 05/11] block: Add QMP support for streaming to an intermediate layer |
Date: |
Wed, 13 May 2015 16:27:35 +0300 |
This patch makes the 'device' parameter of the 'block-stream' command
accept a node name as well as a device name.
In addition to that, operation blockers will be checked in all
intermediate nodes between the top and the base node.
Since qmp_block_stream() now uses the error from bdrv_lookup_bs() and
no longer returns DeviceNotFound, iotest 030 is updated to expect
GenericError instead.
Signed-off-by: Alberto Garcia <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
---
blockdev.c | 20 ++++++++++----------
qapi/block-core.json | 10 +++++++---
tests/qemu-iotests/030 | 2 +-
3 files changed, 18 insertions(+), 14 deletions(-)
diff --git a/blockdev.c b/blockdev.c
index 1fcf466..85d2d5e 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2263,8 +2263,7 @@ void qmp_block_stream(const char *device,
bool has_on_error, BlockdevOnError on_error,
Error **errp)
{
- BlockBackend *blk;
- BlockDriverState *bs;
+ BlockDriverState *bs, *iter;
BlockDriverState *base_bs = NULL;
AioContext *aio_context;
Error *local_err = NULL;
@@ -2274,20 +2273,14 @@ void qmp_block_stream(const char *device,
on_error = BLOCKDEV_ON_ERROR_REPORT;
}
- blk = blk_by_name(device);
- if (!blk) {
- error_set(errp, QERR_DEVICE_NOT_FOUND, device);
+ bs = bdrv_lookup_bs(device, device, errp);
+ if (!bs) {
return;
}
- bs = blk_bs(blk);
aio_context = bdrv_get_aio_context(bs);
aio_context_acquire(aio_context);
- if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_STREAM, errp)) {
- goto out;
- }
-
if (has_base) {
base_bs = bdrv_find_backing_image(bs, base);
if (base_bs == NULL) {
@@ -2298,6 +2291,13 @@ void qmp_block_stream(const char *device,
base_name = base;
}
+ /* Check for op blockers in the whole chain between bs and base */
+ for (iter = bs; iter && iter != base_bs; iter = iter->backing_hd) {
+ if (bdrv_op_is_blocked(iter, BLOCK_OP_TYPE_STREAM, errp)) {
+ goto out;
+ }
+ }
+
/* if we are streaming the entire chain, the result will have no backing
* file, and specifying one is therefore an error */
if (base_bs == NULL && has_backing_file) {
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 9b5cddd..769b6c7 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1095,6 +1095,10 @@
# with query-block-jobs. The operation can be stopped before it has completed
# using the block-job-cancel command.
#
+# The node that receives the data is called the top image, can be located
+# in any part of the whole chain and can be specified using its device
+# or node name.
+#
# If a base file is specified then sectors are not copied from that base file
and
# its backing chain. When streaming completes the image file will have the
base
# file as its backing file. This can be used to stream a subset of the backing
@@ -1103,12 +1107,12 @@
# On successful completion the image file is updated to drop the backing file
# and the BLOCK_JOB_COMPLETED event is emitted.
#
-# @device: the device name
+# @device: the device or node name of the top image
#
# @base: #optional the common backing file name
#
-# @backing-file: #optional The backing file string to write into the active
-# layer. This filename is not validated.
+# @backing-file: #optional The backing file string to write into the top
+# image. This filename is not validated.
#
# If a pathname string is such that it cannot be
# resolved by QEMU, that means that subsequent QMP or
diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030
index 952a524..7ca9b25 100755
--- a/tests/qemu-iotests/030
+++ b/tests/qemu-iotests/030
@@ -107,7 +107,7 @@ class TestSingleDrive(iotests.QMPTestCase):
def test_device_not_found(self):
result = self.vm.qmp('block-stream', device='nonexistent')
- self.assert_qmp(result, 'error/class', 'DeviceNotFound')
+ self.assert_qmp(result, 'error/class', 'GenericError')
class TestSmallerBackingFile(iotests.QMPTestCase):
--
2.1.4
- [Qemu-devel] [PATCH v7 00/11] Support streaming to an intermediate layer, Alberto Garcia, 2015/05/13
- [Qemu-devel] [PATCH 09/11] qemu-iotests: test streaming to an intermediate layer, Alberto Garcia, 2015/05/13
- [Qemu-devel] [PATCH 08/11] qemu-iotests: add no-op streaming test, Alberto Garcia, 2015/05/13
- [Qemu-devel] [PATCH 01/11] block: keep a list of block jobs, Alberto Garcia, 2015/05/13
- [Qemu-devel] [PATCH 05/11] block: Add QMP support for streaming to an intermediate layer,
Alberto Garcia <=
- [Qemu-devel] [PATCH 07/11] qemu-iotests: fix test_stream_partial(), Alberto Garcia, 2015/05/13
- [Qemu-devel] [PATCH 04/11] block: Support streaming to an intermediate layer, Alberto Garcia, 2015/05/13
- [Qemu-devel] [PATCH 06/11] docs: Document how to stream to an intermediate layer, Alberto Garcia, 2015/05/13
- [Qemu-devel] [PATCH 11/11] qemu-iotests: test overlapping block-stream operations, Alberto Garcia, 2015/05/13