qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 15/29] block: Add QMP support for streaming to an intermediate layer
Date: Mon, 31 Oct 2016 18:25:44 +0100	[thread overview]
Message-ID: <1477934758-29332-16-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1477934758-29332-1-git-send-email-kwolf@redhat.com>

From: Alberto Garcia <berto@igalia.com>

This patch makes the 'device' parameter of the 'block-stream' command
accept a node name that is not a root node. The presence of this
feature can't be directly tested with introspection; soon we'll
introduce a 'base-node' parameter whose presence can be checked for
this purpose.

In addition to that, operation blockers will be checked in all
intermediate nodes between the top and the base node.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 blockdev.c           | 15 +++++++++------
 qapi/block-core.json | 13 ++++++++++---
 2 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/blockdev.c b/blockdev.c
index de5b5f5..b5d4d69 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2937,7 +2937,7 @@ void qmp_block_stream(bool has_job_id, const char *job_id, const char *device,
                       bool has_on_error, BlockdevOnError on_error,
                       Error **errp)
 {
-    BlockDriverState *bs;
+    BlockDriverState *bs, *iter;
     BlockDriverState *base_bs = NULL;
     AioContext *aio_context;
     Error *local_err = NULL;
@@ -2947,7 +2947,7 @@ void qmp_block_stream(bool has_job_id, const char *job_id, const char *device,
         on_error = BLOCKDEV_ON_ERROR_REPORT;
     }
 
-    bs = qmp_get_root_bs(device, errp);
+    bs = bdrv_lookup_bs(device, device, errp);
     if (!bs) {
         return;
     }
@@ -2955,10 +2955,6 @@ void qmp_block_stream(bool has_job_id, const char *job_id, const char *device,
     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) {
@@ -2969,6 +2965,13 @@ void qmp_block_stream(bool has_job_id, const char *job_id, 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 = backing_bs(iter)) {
+        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 0f2b703..d7a029c 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1464,6 +1464,13 @@
 # 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 chain (but always above the base image; see below) and can be
+# specified using its device or node name. Earlier qemu versions only allowed
+# 'device' to name the top level node; presence of the 'base-node' parameter
+# during introspection can be used as a witness of the enhanced semantics
+# of 'device'.
+#
 # 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
@@ -1475,12 +1482,12 @@
 # @job-id: #optional identifier for the newly-created block job. If
 #          omitted, the device name will be used. (Since 2.7)
 #
-# @device: the device name or node-name of a root node
+# @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
-- 
1.8.3.1

  parent reply	other threads:[~2016-10-31 17:26 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-31 17:25 [Qemu-devel] [PULL 00/29] Block layer patches Kevin Wolf
2016-10-31 17:25 ` [Qemu-devel] [PULL 01/29] block/ssh: Add ssh_has_filename_options_conflict() Kevin Wolf
2016-10-31 17:25 ` [Qemu-devel] [PULL 02/29] util/qemu-sockets: Make inet_connect_saddr() public Kevin Wolf
2016-10-31 17:25 ` [Qemu-devel] [PULL 03/29] block/ssh: Add InetSocketAddress and accept it Kevin Wolf
2016-10-31 17:25 ` [Qemu-devel] [PULL 04/29] block/ssh: Use InetSocketAddress options Kevin Wolf
2016-10-31 17:25 ` [Qemu-devel] [PULL 05/29] qapi: allow blockdev-add for ssh Kevin Wolf
2016-10-31 17:25 ` [Qemu-devel] [PULL 06/29] block: Add bdrv_drain_all_{begin,end}() Kevin Wolf
2016-10-31 17:25 ` [Qemu-devel] [PULL 07/29] block: Pause all jobs during bdrv_reopen_multiple() Kevin Wolf
2016-10-31 17:25 ` [Qemu-devel] [PULL 08/29] block: Add block_job_add_bdrv() Kevin Wolf
2016-10-31 17:25 ` [Qemu-devel] [PULL 09/29] block: Use block_job_add_bdrv() in mirror_start_job() Kevin Wolf
2016-10-31 17:25 ` [Qemu-devel] [PULL 10/29] block: Use block_job_add_bdrv() in backup_start() Kevin Wolf
2016-10-31 17:25 ` [Qemu-devel] [PULL 11/29] block: Check blockers in all nodes involved in a block-commit job Kevin Wolf
2016-10-31 17:25 ` [Qemu-devel] [PULL 12/29] block: Block all nodes involved in the block-commit operation Kevin Wolf
2016-10-31 17:25 ` [Qemu-devel] [PULL 13/29] block: Block all intermediate nodes in commit_active_start() Kevin Wolf
2016-10-31 17:25 ` [Qemu-devel] [PULL 14/29] block: Support streaming to an intermediate layer Kevin Wolf
2016-10-31 17:25 ` Kevin Wolf [this message]
2016-10-31 17:25 ` [Qemu-devel] [PULL 16/29] docs: Document how to stream " Kevin Wolf
2016-10-31 17:25 ` [Qemu-devel] [PULL 17/29] qemu-iotests: Test streaming " Kevin Wolf
2016-10-31 17:25 ` [Qemu-devel] [PULL 18/29] qemu-iotests: Test block-stream operations in parallel Kevin Wolf
2016-10-31 17:25 ` [Qemu-devel] [PULL 19/29] qemu-iotests: Test overlapping stream and commit operations Kevin Wolf
2016-10-31 17:25 ` [Qemu-devel] [PULL 20/29] qemu-iotests: Test block-stream and block-commit in parallel Kevin Wolf
2016-10-31 17:25 ` [Qemu-devel] [PULL 21/29] qemu-iotests: Add iotests.supports_quorum() Kevin Wolf
2016-10-31 17:25 ` [Qemu-devel] [PULL 22/29] qemu-iotests: Test streaming to a Quorum child Kevin Wolf
2016-10-31 17:25 ` [Qemu-devel] [PULL 23/29] block: Add 'base-node' parameter to the 'block-stream' command Kevin Wolf
2016-10-31 17:25 ` [Qemu-devel] [PULL 24/29] qemu-iotests: Test the 'base-node' parameter of 'block-stream' Kevin Wolf
2016-10-31 17:25 ` [Qemu-devel] [PULL 25/29] raw_bsd: add offset and size options Kevin Wolf
2016-10-31 17:25 ` [Qemu-devel] [PULL 26/29] qemu-iotests: test 'offset' and 'size' options in raw driver Kevin Wolf
2016-10-31 17:25 ` [Qemu-devel] [PULL 27/29] block: Mention replication in BlockdevDriver enum docs Kevin Wolf
2016-10-31 17:25 ` [Qemu-devel] [PULL 28/29] block/nfs: Introduce runtime_opts in NFS Kevin Wolf
2016-10-31 17:25 ` [Qemu-devel] [PULL 29/29] qapi: allow blockdev-add for NFS Kevin Wolf
2016-10-31 18:18 ` [Qemu-devel] [PULL 00/29] Block layer patches Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1477934758-29332-16-git-send-email-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).