All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Benoît Canet" <benoit.canet@irqsave.net>
To: "Benoît Canet" <benoit.canet@irqsave.net>
Cc: kwolf@redhat.com, famz@redhat.com, armbru@redhat.com,
	qemu-devel@nongnu.org, stefanha@redhat.com, mreitz@redhat.com
Subject: Re: [Qemu-devel] [PATCH V6 2/8] block: Allow the user to define "node-name" option both on command line and QMP.
Date: Fri, 24 Jan 2014 15:51:11 +0100	[thread overview]
Message-ID: <20140124145111.GB3510@irqsave.net> (raw)
In-Reply-To: <1390509099-695-3-git-send-email-benoit.canet@irqsave.net>

Le Thursday 23 Jan 2014 à 21:31:33 (+0100), Benoît Canet a écrit :
> From: Benoît Canet <benoit@irqsave.net>
> 
> Signed-off-by: Benoit Canet <benoit@irqsave.net>
> ---
>  block.c          | 36 ++++++++++++++++++++++++++++++++++++
>  qapi-schema.json |  2 ++
>  2 files changed, 38 insertions(+)
> 
> diff --git a/block.c b/block.c
> index 60b70bc..d9d02d2 100644
> --- a/block.c
> +++ b/block.c
> @@ -728,6 +728,33 @@ static int bdrv_open_flags(BlockDriverState *bs, int flags)
>      return open_flags;
>  }
>  
> +static int bdrv_assign_node_name(BlockDriverState *bs,
> +                                 const char *node_name,
> +                                 Error **errp)
> +{
> +    if (!node_name) {
> +        return 0;
> +    }
> +
> +    /* empty string node name is invalid */
> +    if (node_name[0] == '\0') {
> +        error_setg(errp, "Empty node name");
> +        return -EINVAL;
> +    }
> +
> +    /* takes care of avoiding duplicates node names */
> +    if (bdrv_find_node(node_name)) {
> +        error_setg(errp, "Duplicate node name");
> +        return -EINVAL;
> +    }
> +
> +    /* copy node name into the bs and insert it into the graph list */
> +    pstrcpy(bs->node_name, sizeof(bs->node_name), node_name);
> +    QTAILQ_INSERT_TAIL(&graph_bdrv_states, bs, node_list);
> +
> +    return 0;
> +}
> +
>  /*
>   * Common part for opening disk images and files
>   *
> @@ -738,6 +765,7 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file,
>  {
>      int ret, open_flags;
>      const char *filename;
> +    const char *node_name = NULL;
>      Error *local_err = NULL;
>  
>      assert(drv != NULL);
> @@ -752,6 +780,14 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file,
>  
>      trace_bdrv_open_common(bs, filename ?: "", flags, drv->format_name);
>  
> +    node_name = qdict_get_try_str(options, "node-name");

> +    qdict_del(options, "node-name");

Kevin: I wonder if I delete the option too early hence zeroing node-name ? 

> +
> +    ret = bdrv_assign_node_name(bs, node_name, errp);
> +    if (ret < 0) {
> +        return ret;
> +    }
> +
>      /* bdrv_open() with directly using a protocol as drv. This layer is already
>       * opened, so assign it to bs (while file becomes a closed BlockDriverState)
>       * and return immediately. */
> diff --git a/qapi-schema.json b/qapi-schema.json
> index 35f7b34..04167da 100644
> --- a/qapi-schema.json
> +++ b/qapi-schema.json
> @@ -4090,6 +4090,7 @@
>  # @id:          #optional id by which the new block device can be referred to.
>  #               This is a required option on the top level of blockdev-add, and
>  #               currently not allowed on any other level.
> +# @node-name:   #optional the name of a block driver state node (Since 2.0)
>  # @discard:     #optional discard-related options (default: ignore)
>  # @cache:       #optional cache-related options
>  # @aio:         #optional AIO backend (default: threads)
> @@ -4105,6 +4106,7 @@
>  { 'type': 'BlockdevOptionsBase',
>    'data': { 'driver': 'str',
>              '*id': 'str',
> +            '*node-name': 'str',
>              '*discard': 'BlockdevDiscardOptions',
>              '*cache': 'BlockdevCacheOptions',
>              '*aio': 'BlockdevAioOptions',
> -- 
> 1.8.3.2
> 

  reply	other threads:[~2014-01-24 14:51 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-23 20:31 [Qemu-devel] [PATCH V6 0/8] Giving names to graph's BlockDriverState Benoît Canet
2014-01-23 20:31 ` [Qemu-devel] [PATCH V6 1/8] block: Add bs->node_name to hold the name of a bs node of the bs graph Benoît Canet
2014-01-23 20:31 ` [Qemu-devel] [PATCH V6 2/8] block: Allow the user to define "node-name" option both on command line and QMP Benoît Canet
2014-01-24 14:51   ` Benoît Canet [this message]
2014-01-24 15:10     ` Kevin Wolf
2014-01-23 20:31 ` [Qemu-devel] [PATCH V6 3/8] qmp: Add QMP query-named-block-nodes to list the named BlockDriverState nodes Benoît Canet
2014-01-23 20:31 ` [Qemu-devel] [PATCH V6 4/8] qmp: Allow to change password on named block driver states Benoît Canet
2014-01-23 20:31 ` [Qemu-devel] [PATCH V6 5/8] block: Create authorizations mechanism for external snapshot and resize Benoît Canet
2014-02-04  0:15   ` Jeff Cody
2014-02-04 10:25     ` Kevin Wolf
2014-02-04 13:03       ` Jeff Cody
2014-02-10 19:39       ` Benoît Canet
2014-02-10 19:45       ` Benoît Canet
2014-02-10 20:18       ` Benoît Canet
2014-01-23 20:31 ` [Qemu-devel] [PATCH V6 6/8] qmp: Allow block_resize to manipulate bs graph nodes Benoît Canet
2014-01-23 20:31 ` [Qemu-devel] [PATCH V6 7/8] qmp: Allow to take external snapshots on bs graphs node Benoît Canet
2014-01-23 20:31 ` [Qemu-devel] [PATCH V6 8/8] block: Use graph node name as reference in bdrv_file_open() Benoît Canet
2014-01-24 13:26   ` Kevin Wolf
2014-01-24 13:37     ` Max Reitz
2014-01-24 14:48       ` Kevin Wolf
2014-01-24 14:54         ` Max Reitz
2014-01-27 14:36           ` Benoît Canet
2014-01-27 19:11             ` Max Reitz
2014-01-28  0:04               ` Benoît Canet
2014-01-31 20:32                 ` Max Reitz
2014-01-31 21:37                   ` Benoît Canet
2014-02-03  9:43                     ` Kevin Wolf
2014-02-04 13:02                       ` Eric Blake
2014-01-24 13:27 ` [Qemu-devel] [PATCH V6 0/8] Giving names to graph's BlockDriverState 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=20140124145111.GB3510@irqsave.net \
    --to=benoit.canet@irqsave.net \
    --cc=armbru@redhat.com \
    --cc=famz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@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.