qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [Qemu-devel] [RFC PATCH 2/2] block: auto-generated node


From: John Snow
Subject: Re: [Qemu-block] [Qemu-devel] [RFC PATCH 2/2] block: auto-generated node-names
Date: Tue, 1 Sep 2015 15:25:10 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0


On 09/01/2015 01:23 PM, Jeff Cody wrote:
> If a node-name is not specified, automatically generate the node-name.
> 
> Generated node-names will use the "block" sub-system identifier.
> 
> Signed-off-by: Jeff Cody <address@hidden>
> ---
>  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;
> +    } else {
> +        /* 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;
> +        }
>      }
>  
>      /* 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 = {
> 


Reviewed-by: John Snow <address@hidden>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]