All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Benoît Canet" <benoit.canet@irqsave.net>
To: Jeff Cody <jcody@redhat.com>
Cc: kwolf@redhat.com, benoit.canet@irqsave.net, pkrempa@redhat.com,
	famz@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH 4/5] block: Accept node-name arguments for block-commit
Date: Thu, 15 May 2014 14:09:50 +0200	[thread overview]
Message-ID: <20140515120950.GG2812@irqsave.net> (raw)
In-Reply-To: <13ae3f12913b517c7f2e5e356b54b6bf872045da.1400123059.git.jcody@redhat.com>

The Wednesday 14 May 2014 à 23:20:18 (-0400), Jeff Cody wrote :
> This modifies the block operation block-commit so that it will
> accept node-name arguments for either 'top' or 'base' BDS.
> 
> The filename and node-name are mutually exclusive to each other;
> i.e.:
>     "top" and "top-node-name" are mutually exclusive (enforced)
>     "base" and "base-node-name" are mutually exclusive (enforced)
> 
> The preferred and recommended method now of using block-commit
> is to specify the BDS to operate on via their node-name arguments.
> 
> This also adds an explicit check that base_bs is in the chain of
> top_bs, because if they are referenced by their unique node-name
> arguments, the discovery process does not intrinsically verify
> they are in the same chain.
> 
> Signed-off-by: Jeff Cody <jcody@redhat.com>
> ---
>  blockdev.c       | 35 +++++++++++++++++++++++++++++++++--
>  qapi-schema.json | 35 ++++++++++++++++++++++++++---------
>  qmp-commands.hx  | 29 ++++++++++++++++++++++-------
>  3 files changed, 81 insertions(+), 18 deletions(-)
> 
> diff --git a/blockdev.c b/blockdev.c
> index 02c6525..d8cb396 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -1869,7 +1869,9 @@ void qmp_block_stream(const char *device, bool has_base,
>  
>  void qmp_block_commit(const char *device,
>                        bool has_base, const char *base,
> +                      bool has_base_node_name, const char *base_node_name,
>                        bool has_top, const char *top,
> +                      bool has_top_node_name, const char *top_node_name,
>                        bool has_speed, int64_t speed,
>                        Error **errp)
>  {
> @@ -1888,6 +1890,15 @@ void qmp_block_commit(const char *device,
>      /* drain all i/o before commits */
>      bdrv_drain_all();
>  
> +    if (has_base && has_base_node_name) {
> +        error_setg(errp, "'base' and 'base-node-name' are mutually exclusive");
> +        return;
> +    }
> +    if (has_top && has_top_node_name) {
> +        error_setg(errp, "'top' and 'top-node-name' are mutually exclusive");
> +        return;
> +    }
> +
>      bs = bdrv_find(device);
>      if (!bs) {
>          error_set(errp, QERR_DEVICE_NOT_FOUND, device);
> @@ -1897,7 +1908,14 @@ void qmp_block_commit(const char *device,
>      /* default top_bs is the active layer */
>      top_bs = bs;
>  
> -    if (top) {
> +    /* Find the 'top' image file for the commit */
> +    if (has_top_node_name) {
> +        top_bs = bdrv_lookup_bs(NULL, top_node_name, &local_err);
> +        if (local_err) {
> +            error_propagate(errp, local_err);
> +            return;
> +        }
> +    } else if (has_top && top) {
>          if (strcmp(bs->filename, top) != 0) {
>              top_bs = bdrv_find_backing_image(bs, top);
>          }
> @@ -1908,7 +1926,14 @@ void qmp_block_commit(const char *device,
>          return;
>      }
>  
> -    if (has_base && base) {
> +    /* Find the 'base' image file for the commit */
> +    if (has_base_node_name) {
> +        base_bs = bdrv_lookup_bs(NULL, base_node_name, &local_err);
> +        if (local_err) {
> +            error_propagate(errp, local_err);
> +            return;
> +        }
> +    } else if (has_base && base) {
>          base_bs = bdrv_find_backing_image(top_bs, base);
>      } else {
>          base_bs = bdrv_find_base(top_bs);
> @@ -1919,6 +1944,12 @@ void qmp_block_commit(const char *device,
>          return;
>      }
>  
> +    /* Verify that 'base' is in the same chain as 'top' */
> +    if (!bdrv_is_in_chain(top_bs, base_bs)) {
> +        error_setg(errp, "'base' and 'top' are not in the same chain");
> +        return;
> +    }
> +
>      if (top_bs == bs) {
>          commit_active_start(bs, base_bs, speed, on_error, block_job_cb,
>                              bs, &local_err);
> diff --git a/qapi-schema.json b/qapi-schema.json
> index 06a9b5d..eddb2b8 100644
> --- a/qapi-schema.json
> +++ b/qapi-schema.json
> @@ -2096,12 +2096,27 @@
>  #
>  # @device:  the name of the device
>  #
> -# @base:   #optional The file name of the backing image to write data into.
> -#                    If not specified, this is the deepest backing image
> +# For 'base', either @base or @base-node-name may be set but not both. If
> +# neither is specified, this is the deepest backing image
>  #
> -# @top:    #optional The file name of the backing image within the image chain,
> -#                    which contains the topmost data to be committed down. If
> -#                    not specified, this is the active layer.
> +# @base:          #optional The file name of the backing image to write data
> +#                           into.
> +#
> +# @base-node-name #optional The name of the block driver state node of the
> +#                           backing image to write data into.
> +#                           (Since 2.1)
> +#
> +# For 'top', either @top or @top-node-name must be set but not both.
> +#
> +# @top:           #optional The file name of the backing image within the image
> +#                           chain, which contains the topmost data to be
> +#                           committed down. If not specified, this is the
> +#                           active layer.
> +#
> +# @top-node-name: #optional The block driver state node name of the backing
> +#                           image within the image chain, which contains the
> +#                           topmost data to be committed down.
> +#                           (Since 2.1)
>  #
>  #                    If top == base, that is an error.
>  #                    If top == active, the job will not be completed by itself,
> @@ -2120,17 +2135,19 @@
>  #
>  # Returns: Nothing on success
>  #          If commit or stream is already active on this device, DeviceInUse
> -#          If @device does not exist, DeviceNotFound
> +#          If @device does not exist or cannot be determined, DeviceNotFound
>  #          If image commit is not supported by this device, NotSupported
> -#          If @base or @top is invalid, a generic error is returned
> +#          If @base, @top, @base-node-name, @top-node-name invalid, GenericError
>  #          If @speed is invalid, InvalidParameter
> +#          If both @base and @base-node-name are specified, GenericError
> +#          If both @top and @top-node-name are specified, GenericError
>  #
>  # Since: 1.3
>  #
>  ##
>  { 'command': 'block-commit',
> -  'data': { 'device': 'str', '*base': 'str', '*top': 'str',
> -            '*speed': 'int' } }
> +  'data': { 'device': 'str', '*base': 'str', '*base-node-name': 'str',
> +            '*top': 'str', '*top-node-name': 'str', '*speed': 'int' } }
>  
>  ##
>  # @drive-backup
> diff --git a/qmp-commands.hx b/qmp-commands.hx
> index 1aa3c65..2b9b1dc 100644
> --- a/qmp-commands.hx
> +++ b/qmp-commands.hx
> @@ -985,7 +985,7 @@ EQMP
>  
>      {
>          .name       = "block-commit",
> -        .args_type  = "device:B,base:s?,top:s?,speed:o?",
> +        .args_type  = "device:B,base:s?,base-node-name:s?,top:s?,top-node-name:s?,speed:o?",
>          .mhandler.cmd_new = qmp_marshal_input_block_commit,
>      },
>  
> @@ -999,12 +999,27 @@ data between 'top' and 'base' into 'base'.
>  Arguments:
>  
>  - "device": The device's ID, must be unique (json-string)
> -- "base": The file name of the backing image to write data into.
> -          If not specified, this is the deepest backing image
> -          (json-string, optional)
> -- "top":  The file name of the backing image within the image chain,
> -          which contains the topmost data to be committed down. If
> -          not specified, this is the active layer. (json-string, optional)
> +
> +For 'base', either base or base-node-name may be set but not both. If
> +neither is specified, this is the deepest backing image
> +
> +- "base":           The file name of the backing image to write data into.
> +                    (json-string, optional)
> +- "base-node-name": The name of the block driver state node of the
> +                    backing image to write data into.
> +                    (json-string, optional) (Since 2.1)
> +
> +For 'top', either top or top-node-name must be set but not both.
> +
> +- "top":            The file name of the backing image within the image chain,
> +                    which contains the topmost data to be committed down. If
> +                    not specified, this is the active layer.
> +                    (json-string, optional)
> +
> +- "top-node-name": The block driver state node name of the backing
> +                   image within the image chain, which contains the
> +                   topmost data to be committed down.
> +                   (json-string, optional) (Since 2.1)

                          ^ (cosmetic) this block is not aligned with the upper ones.
>  
>            If top == base, that is an error.
>            If top == active, the job will not be completed by itself,
> -- 
> 1.8.3.1
> 

  reply	other threads:[~2014-05-15 12:09 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-15  3:20 [Qemu-devel] [PATCH 0/5] block: Modify block-commit to use node-names Jeff Cody
2014-05-15  3:20 ` [Qemu-devel] [PATCH 1/5] block: Auto-generate node_names for each BDS entry Jeff Cody
2014-05-15 11:58   ` Benoît Canet
2014-05-15 12:06     ` Jeff Cody
2014-05-15 12:32       ` Benoît Canet
2014-05-15 12:37         ` Jeff Cody
2014-05-15 14:11   ` Eric Blake
2014-05-15 15:59   ` Eric Blake
2014-05-15 18:41     ` Jeff Cody
2014-05-15 19:12       ` Eric Blake
2014-05-16  9:39       ` Kevin Wolf
2014-05-16 11:35         ` Jeff Cody
2014-05-16 12:47           ` Eric Blake
2014-05-16 17:16             ` Kevin Wolf
2014-05-15  3:20 ` [Qemu-devel] [PATCH 2/5] block: add helper function to determine if a BDS is in a chain Jeff Cody
2014-05-15 11:48   ` Benoît Canet
2014-05-15 14:16   ` Eric Blake
2014-05-15 14:24     ` Kevin Wolf
2014-05-15 14:31     ` Jeff Cody
2014-05-15  3:20 ` [Qemu-devel] [PATCH 3/5] block: make 'top' argument to block-commit optional Jeff Cody
2014-05-15 11:47   ` Benoît Canet
2014-05-15 11:49     ` Jeff Cody
2014-05-15 15:07   ` Eric Blake
2014-05-15  3:20 ` [Qemu-devel] [PATCH 4/5] block: Accept node-name arguments for block-commit Jeff Cody
2014-05-15 12:09   ` Benoît Canet [this message]
2014-05-15 15:42   ` Eric Blake
2014-05-15 18:04     ` Jeff Cody
2014-05-15  3:20 ` [Qemu-devel] [PATCH 5/5] block: extend block-commit to accept a string for the backing file Jeff Cody
2014-05-15 12:26   ` Benoît Canet
2014-05-15 12:57     ` Eric Blake
2014-05-15 13:10       ` Jeff Cody
2014-05-15 13:14         ` Eric Blake
2014-05-15 16:06   ` Eric Blake
2014-05-15 18:22     ` Jeff Cody
2014-05-15 18:52       ` Eric Blake

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=20140515120950.GG2812@irqsave.net \
    --to=benoit.canet@irqsave.net \
    --cc=famz@redhat.com \
    --cc=jcody@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pkrempa@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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.