diff mbox

[v12,10/19] block: Add QMP support for streaming to an intermediate layer

Message ID 66bc85ae1f3a1e7d5691739327542299d583ce1b.1477476553.git.berto@igalia.com (mailing list archive)
State New, archived
Headers show

Commit Message

Alberto Garcia Oct. 26, 2016, 10:29 a.m. UTC
This patch makes the 'device' parameter of the 'block-stream' command
accept a node name that is not a root node.

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>
---
 blockdev.c           | 15 +++++++++------
 qapi/block-core.json | 10 +++++++---
 2 files changed, 16 insertions(+), 9 deletions(-)

Comments

Kevin Wolf Oct. 26, 2016, 2:58 p.m. UTC | #1
Am 26.10.2016 um 12:29 hat Alberto Garcia geschrieben:
> This patch makes the 'device' parameter of the 'block-stream' command
> accept a node name that is not a root node.
> 
> 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>

> --- a/qapi/block-core.json
> +++ b/qapi/block-core.json
> @@ -1464,6 +1464,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 chain (but always above the base image; see below) 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
> @@ -1475,12 +1479,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

As we discussed in v10, this is not discoverable through introspection.
You added patch 18 which introduces a base-node option and can serve as
a witness for the changed semantics, which is good. Should this be
documented here?

Kevin
Alberto Garcia Oct. 26, 2016, 5:23 p.m. UTC | #2
On Wed 26 Oct 2016 04:58:00 PM CEST, Kevin Wolf <kwolf@redhat.com> wrote:
> Am 26.10.2016 um 12:29 hat Alberto Garcia geschrieben:
>> This patch makes the 'device' parameter of the 'block-stream' command
>> accept a node name that is not a root node.
>> 
>> 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>
>
>> --- a/qapi/block-core.json
>> +++ b/qapi/block-core.json
>> @@ -1464,6 +1464,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 chain (but always above the base image; see below) 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
>> @@ -1475,12 +1479,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
>
> As we discussed in v10, this is not discoverable through
> introspection.  You added patch 18 which introduces a base-node option
> and can serve as a witness for the changed semantics, which is
> good. Should this be documented here?

In the commit message I don't see why not, but in the JSON file?

"This feature was added together with the base-node parameter" ?

Berto
Kevin Wolf Oct. 27, 2016, 8:58 a.m. UTC | #3
Am 26.10.2016 um 19:23 hat Alberto Garcia geschrieben:
> On Wed 26 Oct 2016 04:58:00 PM CEST, Kevin Wolf <kwolf@redhat.com> wrote:
> > Am 26.10.2016 um 12:29 hat Alberto Garcia geschrieben:
> >> This patch makes the 'device' parameter of the 'block-stream' command
> >> accept a node name that is not a root node.
> >> 
> >> 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>
> >
> >> --- a/qapi/block-core.json
> >> +++ b/qapi/block-core.json
> >> @@ -1464,6 +1464,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 chain (but always above the base image; see below) 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
> >> @@ -1475,12 +1479,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
> >
> > As we discussed in v10, this is not discoverable through
> > introspection.  You added patch 18 which introduces a base-node option
> > and can serve as a witness for the changed semantics, which is
> > good. Should this be documented here?
> 
> In the commit message I don't see why not, but in the JSON file?
> 
> "This feature was added together with the base-node parameter" ?

Eric may have a better suggestion for the wording, but maybe something
like this:

"Presence of this feature can't directly be tested with introspection;
check for the presence of base-node instead as a witness for it."

Kevin
Alberto Garcia Oct. 27, 2016, 10:08 a.m. UTC | #4
On Thu 27 Oct 2016 10:58:04 AM CEST, Kevin Wolf wrote:
>> >> +# 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.
>> >> +#
>> >>  # 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 +1479,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
>> >
>> > As we discussed in v10, this is not discoverable through
>> > introspection.  You added patch 18 which introduces a base-node
>> > option and can serve as a witness for the changed semantics, which
>> > is good. Should this be documented here?
>> 
>> In the commit message I don't see why not, but in the JSON file?
>> 
>> "This feature was added together with the base-node parameter" ?
>
> Eric may have a better suggestion for the wording, but maybe something
> like this:
>
> "Presence of this feature can't directly be tested with introspection;
> check for the presence of base-node instead as a witness for it."

Ok, sounds good to me. If there's a next version of the series I will
include that text, else feel free to put it when you commit.

Berto
Eric Blake Oct. 27, 2016, 2:46 p.m. UTC | #5
On 10/27/2016 03:58 AM, Kevin Wolf wrote:
>>>> -# @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
>>>
>>> As we discussed in v10, this is not discoverable through
>>> introspection.  You added patch 18 which introduces a base-node option
>>> and can serve as a witness for the changed semantics, which is
>>> good. Should this be documented here?
>>
>> In the commit message I don't see why not, but in the JSON file?
>>
>> "This feature was added together with the base-node parameter" ?
> 
> Eric may have a better suggestion for the wording, but maybe something
> like this:
> 
> "Presence of this feature can't directly be tested with introspection;
> check for the presence of base-node instead as a witness for it."

The sentence on checking for the feature should go earlier, with this
paragraph.  Maybe as follows:

# The node that receives the data is called the top image, and 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'.
diff mbox

Patch

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 97b1205..5fe55ff 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -1464,6 +1464,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 chain (but always above the base image; see below) 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
@@ -1475,12 +1479,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