All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Benoît Canet" <benoit.canet@irqsave.net>
To: Max Reitz <mreitz@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 1/2] block: Do not prematurely remove "filename"
Date: Wed, 18 Jun 2014 15:42:52 +0200	[thread overview]
Message-ID: <20140618134252.GB4424@irqsave.net> (raw)
In-Reply-To: <1403043250-28472-2-git-send-email-mreitz@redhat.com>

The Wednesday 18 Jun 2014 à 00:14:09 (+0200), Max Reitz wrote :
> If "filename" is removed from the options QDict before entering
> bdrv_open_common(), it cannot be stored in the BDS. Therefore, wait
> until it has been copied there and remove it from the options only
> afterwards.
> 
> This fixes "filename" in the BDS being empty for block drivers which do
> not need the filename because they have parsed it already (e.g. NBD).
> 
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>  block.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/block.c b/block.c
> index 43abe96..1fdfa66 100644
> --- a/block.c
> +++ b/block.c
> @@ -954,6 +954,14 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file,
>          bs->filename[0] = '\0';
>      }
>  
> +    if (!drv->bdrv_needs_filename) {
> +        qdict_del(options, "filename");
> +        /* The pointer "filename" may reference the just deleted QDict entry; in
> +         * any case, it is no longer needed, so indicate that by setting it to
> +         * NULL. */
> +        filename = NULL;
> +    }
> +
>      bs->drv = drv;
>      bs->opaque = g_malloc0(drv->instance_size);
>  
> @@ -1070,9 +1078,7 @@ static int bdrv_file_open(BlockDriverState *bs, const char *filename,
>              goto fail;
>          }
>  
> -        if (!drv->bdrv_needs_filename) {
> -            qdict_del(*options, "filename");
> -        } else {
> +        if (drv->bdrv_needs_filename) {
>              filename = qdict_get_str(*options, "filename");
>          }
>      }
> -- 
> 2.0.0
> 
> 
Reviewed-by: Benoit Canet <benoit@irqsave.net>

  reply	other threads:[~2014-06-18 13:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-17 22:14 [Qemu-devel] [PATCH 0/2] block: Fix unset "filename" for certain drivers Max Reitz
2014-06-17 22:14 ` [Qemu-devel] [PATCH 1/2] block: Do not prematurely remove "filename" Max Reitz
2014-06-18 13:42   ` Benoît Canet [this message]
2014-06-17 22:14 ` [Qemu-devel] [PATCH 2/2] iotests: Add test for set "filename" for NBD Max Reitz
2014-06-18 13:47   ` Benoît Canet
2014-06-18 18:14     ` Max Reitz
2014-06-19  6:24 ` [Qemu-devel] [PATCH 0/2] block: Fix unset "filename" for certain drivers Stefan Hajnoczi
2014-06-23  8:35 ` Stefan Hajnoczi
2014-06-26 18:58   ` Max Reitz

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=20140618134252.GB4424@irqsave.net \
    --to=benoit.canet@irqsave.net \
    --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.