All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Jeff Cody <jcody@redhat.com>
Cc: kwolf@redhat.com, programmingkidx@gmail.com, jsnow@redhat.com,
	qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 2/2] block: auto-generated node-names
Date: Fri, 18 Sep 2015 15:03:51 +0200	[thread overview]
Message-ID: <87fv2b3mmg.fsf@blackfin.pond.sub.org> (raw)
In-Reply-To: <f9b451fde3aa9b57372f29ae2bb8e7bbecf81a35.1441140367.git.jcody@redhat.com> (Jeff Cody's message of "Tue, 1 Sep 2015 18:30:16 -0400")

Jeff Cody <jcody@redhat.com> writes:

> If a node-name is not specified, automatically generate the node-name.
>
> Generated node-names will use the "block" sub-system identifier.
>
> Reviewed-by: Eric Blake <eblake@redhat.com>
> Reviewed-by: John Snow <jsnow@redhat.com>
> Signed-off-by: Jeff Cody <jcody@redhat.com>
> ---
>  block.c | 25 ++++++++++++++++---------
>  1 file changed, 16 insertions(+), 9 deletions(-)
>
> diff --git a/block.c b/block.c
> index d088ee0..892e127 100644
> --- a/block.c
> +++ b/block.c
> @@ -771,32 +771,39 @@ static void bdrv_assign_node_name(BlockDriverState *bs,
>                                    const char *node_name,
>                                    Error **errp)
>  {
> +    char *gen_node_name = NULL;
> +
>      if (!node_name) {
> -        return;
> -    }
> -
> -    /* Check for empty string or invalid characters */
> -    if (!id_wellformed(node_name)) {
> -        error_setg(errp, "Invalid node name");
> -        return;
> +        gen_node_name = id_generate(ID_BLOCK);
> +        node_name = gen_node_name;

I'd do

        node_name = gen_node_name = id_generate(ID_BLOCK);

but that's clearly a matter of taste.

> +    } else {
> +        /* Check for empty string or invalid characters, but not if it is
> +         * generated (generated names use characters not available to the user)
> +         * */

Untidy comment.  Make it:

        /*
         * Check for empty string or invalid characters, but not if it
         * is generated (generated names use characters not available to
         * the user)
         */

> +        if (!id_wellformed(node_name)) {
> +            error_setg(errp, "Invalid node name");
> +            return;
> +        }
>      }

I'd probably do an else if here.  Additional benefit: smaller diff.

>  
>      /* takes care of avoiding namespaces collisions */
>      if (blk_by_name(node_name)) {
>          error_setg(errp, "node-name=%s is conflicting with a device id",
>                     node_name);
> -        return;
> +        goto out;
>      }
>  
>      /* takes care of avoiding duplicates node names */
>      if (bdrv_find_node(node_name)) {
>          error_setg(errp, "Duplicate node name");
> -        return;
> +        goto out;
>      }
>  
>      /* 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);
> +out:
> +    g_free(gen_node_name);
>  }
>  
>  static QemuOptsList bdrv_runtime_opts = {

  reply	other threads:[~2015-09-18 13:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-01 22:30 [Qemu-devel] [PATCH v2 0/2] Auto-generated IDs Jeff Cody
2015-09-01 22:30 ` [Qemu-devel] [PATCH v2 1/2] util - add automated ID generation utility Jeff Cody
2015-09-01 22:55   ` Eric Blake
2015-09-02  0:08     ` Jeff Cody
2015-09-02  0:13   ` John Snow
2015-09-02  6:35   ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2015-09-03 14:47     ` Jeff Cody
2015-09-18 12:58   ` [Qemu-devel] " Markus Armbruster
2015-09-01 22:30 ` [Qemu-devel] [PATCH v2 2/2] block: auto-generated node-names Jeff Cody
2015-09-18 13:03   ` Markus Armbruster [this message]
2015-09-03 15:02 ` [Qemu-devel] [PATCH v2 0/2] Auto-generated IDs Kevin Wolf
2015-09-03 15:54   ` [Qemu-devel] [Qemu-block] " Kevin Wolf
2015-09-18 13:06 ` [Qemu-devel] " Markus Armbruster

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=87fv2b3mmg.fsf@blackfin.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=jcody@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=programmingkidx@gmail.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.