diff mbox

[1/5] block: Keep "filename" option after parsing

Message ID 1394055700-5988-2-git-send-email-mreitz@redhat.com
State New
Headers show

Commit Message

Max Reitz March 5, 2014, 9:41 p.m. UTC
Currently, bdrv_file_open() always removes the "filename" option from
the options QDict after bdrv_parse_filename() has been (successfully)
called. However, for drivers with bdrv_needs_filename, it makes more
sense for bdrv_parse_filename() to overwrite the "filename" option and
for bdrv_file_open() to fetch the filename from there.

Since there currently are no drivers that implement
bdrv_parse_filename() and have bdrv_needs_filename set, this does not
change current behavior.

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 block.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Benoît Canet March 6, 2014, 1 p.m. UTC | #1
The Wednesday 05 Mar 2014 à 22:41:36 (+0100), Max Reitz wrote :
> Currently, bdrv_file_open() always removes the "filename" option from
> the options QDict after bdrv_parse_filename() has been (successfully)
> called. However, for drivers with bdrv_needs_filename, it makes more
> sense for bdrv_parse_filename() to overwrite the "filename" option and
> for bdrv_file_open() to fetch the filename from there.
> 
> Since there currently are no drivers that implement
> bdrv_parse_filename() and have bdrv_needs_filename set, this does not
> change current behavior.
> 
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>  block.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/block.c b/block.c
> index f01b91c..845cbfb 100644
> --- a/block.c
> +++ b/block.c
> @@ -1017,7 +1017,12 @@ static int bdrv_file_open(BlockDriverState *bs, const char *filename,
>              ret = -EINVAL;
>              goto fail;
>          }
> -        qdict_del(*options, "filename");
> +
> +        if (!drv->bdrv_needs_filename) {
> +            qdict_del(*options, "filename");
> +        } else {
> +            filename = qdict_get_str(*options, "filename");
> +        }
>      }
>  
>      if (!drv->bdrv_file_open) {
> -- 
> 1.9.0
> 
> 
Looks innocuous.

Reviewed-by: Benoit Canet <benoit@irqsave.net>
diff mbox

Patch

diff --git a/block.c b/block.c
index f01b91c..845cbfb 100644
--- a/block.c
+++ b/block.c
@@ -1017,7 +1017,12 @@  static int bdrv_file_open(BlockDriverState *bs, const char *filename,
             ret = -EINVAL;
             goto fail;
         }
-        qdict_del(*options, "filename");
+
+        if (!drv->bdrv_needs_filename) {
+            qdict_del(*options, "filename");
+        } else {
+            filename = qdict_get_str(*options, "filename");
+        }
     }
 
     if (!drv->bdrv_file_open) {