All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wen Congyang <wency@cn.fujitsu.com>
To: Kevin Wolf <kwolf@redhat.com>, qemu-block@nongnu.org
Cc: berto@igalia.com, qemu-devel@nongnu.org, mreitz@redhat.com
Subject: Re: [Qemu-devel] [PATCH v3 06/21] block: Exclude nested options only for children in append_open_options()
Date: Tue, 15 Dec 2015 10:16:48 +0800	[thread overview]
Message-ID: <566F7810.3050105@cn.fujitsu.com> (raw)
In-Reply-To: <1449236124-19605-7-git-send-email-kwolf@redhat.com>

On 12/04/2015 09:35 PM, Kevin Wolf wrote:
> Some drivers have nested options (e.g. blkdebug rule arrays), which
> don't belong to a child node and shouldn't be removed. Don't remove all
> options with "." in their name, but check for the complete prefixes of
> actually existing child nodes.

I think we should have some way to get the child->name. For example, the
monitor command 'info block' or 'query-block' display it.

Thanks
Wen Congyang

> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  block.c                   | 20 ++++++++++++++++----
>  include/block/block_int.h |  1 +
>  2 files changed, 17 insertions(+), 4 deletions(-)
> 
> diff --git a/block.c b/block.c
> index 73f0816..0dfff7a 100644
> --- a/block.c
> +++ b/block.c
> @@ -1101,11 +1101,13 @@ static int bdrv_fill_options(QDict **options, const char **pfilename,
>  
>  static BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs,
>                                      BlockDriverState *child_bs,
> +                                    const char *child_name,
>                                      const BdrvChildRole *child_role)
>  {
>      BdrvChild *child = g_new(BdrvChild, 1);
>      *child = (BdrvChild) {
>          .bs     = child_bs,
> +        .name   = g_strdup(child_name),
>          .role   = child_role,
>      };
>  
> @@ -1119,6 +1121,7 @@ static void bdrv_detach_child(BdrvChild *child)
>  {
>      QLIST_REMOVE(child, next);
>      QLIST_REMOVE(child, next_parent);
> +    g_free(child->name);
>      g_free(child);
>  }
>  
> @@ -1165,7 +1168,7 @@ void bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd)
>          bs->backing = NULL;
>          goto out;
>      }
> -    bs->backing = bdrv_attach_child(bs, backing_hd, &child_backing);
> +    bs->backing = bdrv_attach_child(bs, backing_hd, "backing", &child_backing);
>      bs->open_flags &= ~BDRV_O_NO_BACKING;
>      pstrcpy(bs->backing_file, sizeof(bs->backing_file), backing_hd->filename);
>      pstrcpy(bs->backing_format, sizeof(bs->backing_format),
> @@ -1321,7 +1324,7 @@ BdrvChild *bdrv_open_child(const char *filename,
>          goto done;
>      }
>  
> -    c = bdrv_attach_child(parent, bs, child_role);
> +    c = bdrv_attach_child(parent, bs, bdref_key, child_role);
>  
>  done:
>      qdict_del(options, bdref_key);
> @@ -3951,13 +3954,22 @@ static bool append_open_options(QDict *d, BlockDriverState *bs)
>  {
>      const QDictEntry *entry;
>      QemuOptDesc *desc;
> +    BdrvChild *child;
>      bool found_any = false;
> +    const char *p;
>  
>      for (entry = qdict_first(bs->options); entry;
>           entry = qdict_next(bs->options, entry))
>      {
> -        /* Only take options for this level */
> -        if (strchr(qdict_entry_key(entry), '.')) {
> +        /* Exclude options for children */
> +        QLIST_FOREACH(child, &bs->children, next) {
> +            if (strstart(qdict_entry_key(entry), child->name, &p)
> +                && (!*p || *p == '.'))
> +            {
> +                break;
> +            }
> +        }
> +        if (child) {
>              continue;
>          }
>  
> diff --git a/include/block/block_int.h b/include/block/block_int.h
> index 77dc165..7265247 100644
> --- a/include/block/block_int.h
> +++ b/include/block/block_int.h
> @@ -351,6 +351,7 @@ extern const BdrvChildRole child_format;
>  
>  struct BdrvChild {
>      BlockDriverState *bs;
> +    char *name;
>      const BdrvChildRole *role;
>      QLIST_ENTRY(BdrvChild) next;
>      QLIST_ENTRY(BdrvChild) next_parent;
> 

  parent reply	other threads:[~2015-12-15  2:17 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-04 13:35 [Qemu-devel] [PATCH v3 00/21] block: Cache mode for children etc Kevin Wolf
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 01/21] qcow2: Add .bdrv_join_options callback Kevin Wolf
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 02/21] block: Fix reopen with semantically overlapping options Kevin Wolf
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 03/21] mirror: Error out when a BDS would get two BBs Kevin Wolf
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 04/21] block: Allow references for backing files Kevin Wolf
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 05/21] block: Consider all block layer options in append_open_options Kevin Wolf
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 06/21] block: Exclude nested options only for children in append_open_options() Kevin Wolf
2015-12-04 21:47   ` Max Reitz
2015-12-15  2:16   ` Wen Congyang [this message]
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 07/21] block: Pass driver-specific options to .bdrv_refresh_filename() Kevin Wolf
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 08/21] block: Keep "driver" in bs->options Kevin Wolf
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 09/21] block: Allow specifying child options in reopen Kevin Wolf
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 10/21] block: reopen: Document option precedence and refactor accordingly Kevin Wolf
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 11/21] block: Add infrastructure for option inheritance Kevin Wolf
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 12/21] block: Split out parse_json_protocol() Kevin Wolf
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 13/21] block: Introduce bs->explicit_options Kevin Wolf
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 14/21] blockdev: Set 'format' indicates non-empty drive Kevin Wolf
2015-12-04 21:59   ` Max Reitz
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 15/21] qemu-iotests: Remove cache mode test without medium Kevin Wolf
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 16/21] block: reopen: Extract QemuOpts for generic block layer options Kevin Wolf
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 17/21] block: Move cache options into options QDict Kevin Wolf
2015-12-04 22:07   ` Max Reitz
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 18/21] blkdebug: Enable reopen Kevin Wolf
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 19/21] qemu-iotests: Try setting cache mode for children Kevin Wolf
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 20/21] qemu-iotests: Test cache mode option inheritance Kevin Wolf
2015-12-04 13:35 ` [Qemu-devel] [PATCH v3 21/21] qemu-iotests: Test reopen with node-name/driver options Kevin Wolf
2015-12-07  9:25 ` [Qemu-devel] [PATCH v3 00/21] block: Cache mode for children etc 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=566F7810.3050105@cn.fujitsu.com \
    --to=wency@cn.fujitsu.com \
    --cc=berto@igalia.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.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.