All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alberto Garcia <berto@igalia.com>
To: qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, Kevin Wolf <kwolf@redhat.com>,
	Eric Blake <eblake@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	Max Reitz <mreitz@redhat.com>, Alberto Garcia <berto@igalia.com>
Subject: [Qemu-devel] [PATCH v13 18/19] block: Add 'base-node' parameter to the 'block-stream' command
Date: Fri, 28 Oct 2016 10:08:19 +0300	[thread overview]
Message-ID: <0c8ac71920b7972363021ff878c7002b42089edf.1477638050.git.berto@igalia.com> (raw)
In-Reply-To: <cover.1477638050.git.berto@igalia.com>
In-Reply-To: <cover.1477638050.git.berto@igalia.com>

The way to specify the node from which to copy data in the
block-stream operation is by using the 'base' parameter. This
parameter however takes a file name, not a node name.

Since we want to be able to perform this operation using only node
names, this patch adds a new 'base-node' parameter.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
---
 blockdev.c            | 21 +++++++++++++++++++++
 docs/qmp-commands.txt |  7 +++++--
 hmp.c                 |  2 +-
 qapi/block-core.json  |  8 ++++++--
 4 files changed, 33 insertions(+), 5 deletions(-)

diff --git a/blockdev.c b/blockdev.c
index b5d4d69..ded1326 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2932,6 +2932,7 @@ static void block_job_cb(void *opaque, int ret)
 
 void qmp_block_stream(bool has_job_id, const char *job_id, const char *device,
                       bool has_base, const char *base,
+                      bool has_base_node, const char *base_node,
                       bool has_backing_file, const char *backing_file,
                       bool has_speed, int64_t speed,
                       bool has_on_error, BlockdevOnError on_error,
@@ -2955,6 +2956,12 @@ 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 (has_base && has_base_node) {
+        error_setg(errp, "'base' and 'base-node' cannot be specified "
+                   "at the same time");
+        goto out;
+    }
+
     if (has_base) {
         base_bs = bdrv_find_backing_image(bs, base);
         if (base_bs == NULL) {
@@ -2965,6 +2972,20 @@ void qmp_block_stream(bool has_job_id, const char *job_id, const char *device,
         base_name = base;
     }
 
+    if (has_base_node) {
+        base_bs = bdrv_lookup_bs(NULL, base_node, errp);
+        if (!base_bs) {
+            goto out;
+        }
+        if (bs == base_bs || !bdrv_chain_contains(bs, base_bs)) {
+            error_setg(errp, "Node '%s' is not a backing image of '%s'",
+                       base_node, device);
+            goto out;
+        }
+        assert(bdrv_get_aio_context(base_bs) == aio_context);
+        base_name = base_bs->filename;
+    }
+
     /* 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)) {
diff --git a/docs/qmp-commands.txt b/docs/qmp-commands.txt
index 284576d..0fde435 100644
--- a/docs/qmp-commands.txt
+++ b/docs/qmp-commands.txt
@@ -740,8 +740,11 @@ Arguments:
 - "job-id": Identifier for the newly-created block job. If omitted,
             the device name will be used. (json-string, optional)
 - "device": The device name or node-name of a root node (json-string)
-- "base": The file name of the backing image above which copying starts
-          (json-string, optional)
+- "base": The file name of the backing image above which copying starts.
+          It cannot be set if 'base-node' is also set (json-string, optional)
+- "base-node": the node name of the backing image above which copying starts.
+               It cannot be set if 'base' is also set.
+               (json-string, optional) (Since 2.8)
 - "backing-file": The backing file string to write into the active layer. This
                   filename is not validated.
 
diff --git a/hmp.c b/hmp.c
index 3d60259..81447fa 100644
--- a/hmp.c
+++ b/hmp.c
@@ -1555,7 +1555,7 @@ void hmp_block_stream(Monitor *mon, const QDict *qdict)
     int64_t speed = qdict_get_try_int(qdict, "speed", 0);
 
     qmp_block_stream(false, NULL, device, base != NULL, base, false, NULL,
-                     qdict_haskey(qdict, "speed"), speed,
+                     false, NULL, qdict_haskey(qdict, "speed"), speed,
                      true, BLOCKDEV_ON_ERROR_REPORT, &error);
 
     hmp_handle_error(mon, &error);
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 821762c..999a9bb 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1484,7 +1484,11 @@
 #
 # @device: the device or node name of the top image
 #
-# @base:   #optional the common backing file name
+# @base:   #optional the common backing file name.
+#                    It cannot be set if @base-node is also set.
+#
+# @base-node: #optional the node name of the backing file.
+#                       It cannot be set if @base is also set. (Since 2.8)
 #
 # @backing-file: #optional The backing file string to write into the top
 #                          image. This filename is not validated.
@@ -1511,7 +1515,7 @@
 ##
 { 'command': 'block-stream',
   'data': { '*job-id': 'str', 'device': 'str', '*base': 'str',
-            '*backing-file': 'str', '*speed': 'int',
+            '*base-node': 'str', '*backing-file': 'str', '*speed': 'int',
             '*on-error': 'BlockdevOnError' } }
 
 ##
-- 
2.9.3

  parent reply	other threads:[~2016-10-28  7:10 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-28  7:08 [Qemu-devel] [PATCH v13 00/19] Support streaming to an intermediate layer Alberto Garcia
2016-10-28  7:08 ` [Qemu-devel] [PATCH v13 01/19] block: Add bdrv_drain_all_{begin, end}() Alberto Garcia
2016-10-28  7:08 ` [Qemu-devel] [PATCH v13 02/19] block: Pause all jobs during bdrv_reopen_multiple() Alberto Garcia
2016-10-28  7:08 ` [Qemu-devel] [PATCH v13 03/19] block: Add block_job_add_bdrv() Alberto Garcia
2016-10-28  7:08 ` [Qemu-devel] [PATCH v13 04/19] block: Use block_job_add_bdrv() in mirror_start_job() Alberto Garcia
2016-10-28  7:08 ` [Qemu-devel] [PATCH v13 05/19] block: Use block_job_add_bdrv() in backup_start() Alberto Garcia
2016-10-28  7:08 ` [Qemu-devel] [PATCH v13 06/19] block: Check blockers in all nodes involved in a block-commit job Alberto Garcia
2016-10-28  7:08 ` [Qemu-devel] [PATCH v13 07/19] block: Block all nodes involved in the block-commit operation Alberto Garcia
2016-10-28  7:08 ` [Qemu-devel] [PATCH v13 08/19] block: Block all intermediate nodes in commit_active_start() Alberto Garcia
2016-10-28  7:08 ` [Qemu-devel] [PATCH v13 09/19] block: Support streaming to an intermediate layer Alberto Garcia
2016-10-28  7:08 ` [Qemu-devel] [PATCH v13 10/19] block: Add QMP support for " Alberto Garcia
2016-10-28  7:08 ` [Qemu-devel] [PATCH v13 11/19] docs: Document how to stream " Alberto Garcia
2016-10-28  7:08 ` [Qemu-devel] [PATCH v13 12/19] qemu-iotests: Test streaming " Alberto Garcia
2016-10-28  7:08 ` [Qemu-devel] [PATCH v13 13/19] qemu-iotests: Test block-stream operations in parallel Alberto Garcia
2016-10-28  7:08 ` [Qemu-devel] [PATCH v13 14/19] qemu-iotests: Test overlapping stream and commit operations Alberto Garcia
2016-10-28  7:08 ` [Qemu-devel] [PATCH v13 15/19] qemu-iotests: Test block-stream and block-commit in parallel Alberto Garcia
2016-10-28  7:08 ` [Qemu-devel] [PATCH v13 16/19] qemu-iotests: Add iotests.supports_quorum() Alberto Garcia
2016-10-28  7:08 ` [Qemu-devel] [PATCH v13 17/19] qemu-iotests: Test streaming to a Quorum child Alberto Garcia
2016-10-28  7:08 ` Alberto Garcia [this message]
2016-10-28  7:08 ` [Qemu-devel] [PATCH v13 19/19] qemu-iotests: Test the 'base-node' parameter of 'block-stream' Alberto Garcia
2016-10-28 10:50 ` [Qemu-devel] [PATCH v13 00/19] Support streaming to an intermediate layer Kevin Wolf

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=0c8ac71920b7972363021ff878c7002b42089edf.1477638050.git.berto@igalia.com \
    --to=berto@igalia.com \
    --cc=armbru@redhat.com \
    --cc=eblake@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.