qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>, qemu-block@nongnu.org
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 06/21] block: Exclude nested options only for children in append_open_options()
Date: Fri, 27 Nov 2015 19:02:27 +0100	[thread overview]
Message-ID: <56589AB3.5080805@redhat.com> (raw)
In-Reply-To: <565899D4.1090907@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 4697 bytes --]

On 27.11.2015 18:58, Max Reitz wrote:
> On 23.11.2015 16:59, 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.
>>
>> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
>> ---
>>  block.c                   | 19 +++++++++++++++----
>>  include/block/block_int.h |  1 +
>>  2 files changed, 16 insertions(+), 4 deletions(-)
> 
> Thanks, now I don't need to fix it myself. :-)
> 
> (I would have had to do that for an in-work series of mine)
> 
>> diff --git a/block.c b/block.c
>> index 23d9e10..02125e2 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   = child_name,
>>          .role   = child_role,
>>      };
>>  
>> @@ -1165,7 +1167,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),
>> @@ -1322,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);
>> @@ -3952,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;
>>          }
>>  
> 
> A good general solution, but I think bdrv_refresh_filename() may be bad
> enough to break with general solutions. ;-)
> 
> bdrv_refresh_filename() only considers "file" and "backing" (actually,
> it only supports "file" for now, I'm working on "backing", though). The
> only drivers with other children are quorum, blkdebug, blkverify and
> VMDK. The former three have their own implementation of
> bdrv_refresh_filename(), so they don't use append_open_options() at all.
> The latter, however, (VMDK) does not.
> 
> This change to append_open_options results in the extent.%d options
> simply being omitted altogether because bdrv_refresh_filename() does not
> fetch them. Before, they were included in the VMDK BDS's options, which
> is not ideal but works more or less.
> 
> In order to "fix" this, I see three ways right now:
> 1. Just care about "file" and "backing". bdrv_refresh_filename()
>    doesn't support anything else, so that will be fine.
> 2. Implement bdrv_refresh_filename() specifically for VMDK so
>    append_open_options() will never have to handle anything but "file"
>    and "backing".
> 3. Fix bdrv_refresh_filename() so that it handles all children and not
>    just "file" and "backing".
> 
> Since we are shooting for 2.6 anyway (I assume ;-)), I think we should
> go for option 3. This means that this patch is fine, and I'll see to
> fixing bdrv_refresh_filename() (because I'm working on that anyway).
> 
> Reviewed-by: Max Reitz <mreitz@redhat.com>

Oops, focused so much on this that I missed the issue Wen Congyang
found. So this R-b is assuming that is fixed *cough*.

Max


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

  reply	other threads:[~2015-11-27 18:02 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-23 15:59 [Qemu-devel] [PATCH v2 00/21] block: Cache mode for children etc Kevin Wolf
2015-11-23 15:59 ` [Qemu-devel] [PATCH v2 01/21] qcow2: Add .bdrv_join_options callback Kevin Wolf
2015-11-27 16:51   ` Max Reitz
2015-11-30 14:05   ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2015-11-23 15:59 ` [Qemu-devel] [PATCH v2 02/21] block: Fix reopen with semantically overlapping options Kevin Wolf
2015-11-27 16:56   ` Max Reitz
2015-11-30 14:08   ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2015-11-23 15:59 ` [Qemu-devel] [PATCH v2 03/21] mirror: Error out when a BDS would get two BBs Kevin Wolf
2015-11-27 17:06   ` Max Reitz
2015-11-30 14:51   ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2015-12-04 13:18     ` Kevin Wolf
2015-11-23 15:59 ` [Qemu-devel] [PATCH v2 04/21] block: Allow references for backing files Kevin Wolf
2015-11-27 17:28   ` Max Reitz
2015-11-23 15:59 ` [Qemu-devel] [PATCH v2 05/21] block: Consider all block layer options in append_open_options Kevin Wolf
2015-11-30 15:59   ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2015-11-23 15:59 ` [Qemu-devel] [PATCH v2 06/21] block: Exclude nested options only for children in append_open_options() Kevin Wolf
2015-11-24  1:03   ` Wen Congyang
2015-11-27 17:58   ` Max Reitz
2015-11-27 18:02     ` Max Reitz [this message]
2015-11-30  9:01     ` Kevin Wolf
2015-11-30 16:13       ` Max Reitz
2015-11-23 15:59 ` [Qemu-devel] [PATCH v2 07/21] block: Pass driver-specific options to .bdrv_refresh_filename() Kevin Wolf
2015-12-02 14:06   ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2015-11-23 15:59 ` [Qemu-devel] [PATCH v2 08/21] block: Keep "driver" in bs->options Kevin Wolf
2015-11-23 15:59 ` [Qemu-devel] [PATCH v2 09/21] block: Allow specifying child options in reopen Kevin Wolf
2015-12-02 14:22   ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2015-11-23 15:59 ` [Qemu-devel] [PATCH v2 10/21] block: reopen: Document option precedence and refactor accordingly Kevin Wolf
2015-11-23 15:59 ` [Qemu-devel] [PATCH v2 11/21] block: Add infrastructure for option inheritance Kevin Wolf
2015-11-27 18:09   ` Max Reitz
2015-11-23 15:59 ` [Qemu-devel] [PATCH v2 12/21] block: Split out parse_json_protocol() Kevin Wolf
2015-11-27 18:22   ` Max Reitz
2015-11-23 15:59 ` [Qemu-devel] [PATCH v2 13/21] block: Introduce bs->explicit_options Kevin Wolf
2015-11-27 18:38   ` Max Reitz
2016-01-08  9:18   ` Paolo Bonzini
2015-11-23 15:59 ` [Qemu-devel] [PATCH v2 14/21] blockdev: Set 'format' indicates non-empty drive Kevin Wolf
2015-11-24  9:37   ` Wen Congyang
2015-11-27 19:08   ` Max Reitz
2015-11-23 15:59 ` [Qemu-devel] [PATCH v2 15/21] qemu-iotests: Remove cache mode test without medium Kevin Wolf
2015-11-23 15:59 ` [Qemu-devel] [PATCH v2 16/21] block: reopen: Extract QemuOpts for generic block layer options Kevin Wolf
2015-11-23 15:59 ` [Qemu-devel] [PATCH v2 17/21] block: Move cache options into options QDict Kevin Wolf
2015-11-27 19:57   ` Max Reitz
2015-11-30  9:37     ` Kevin Wolf
2015-11-23 15:59 ` [Qemu-devel] [PATCH v2 18/21] blkdebug: Enable reopen Kevin Wolf
2015-11-27 19:57   ` Max Reitz
2015-12-02 14:38   ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2015-11-23 15:59 ` [Qemu-devel] [PATCH v2 19/21] qemu-iotests: Try setting cache mode for children Kevin Wolf
2015-11-23 15:59 ` [Qemu-devel] [PATCH v2 20/21] qemu-iotests: Test cache mode option inheritance Kevin Wolf
2015-11-27 21:12   ` Max Reitz
2015-11-30 10:32     ` Kevin Wolf
2015-11-23 16:00 ` [Qemu-devel] [PATCH v2 21/21] qemu-iotests: Test reopen with node-name/driver options 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=56589AB3.5080805@redhat.com \
    --to=mreitz@redhat.com \
    --cc=kwolf@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).