diff options
author | Max Reitz <mreitz@redhat.com> | 2017-04-13 18:06:24 +0200 |
---|---|---|
committer | Michael Roth <mdroth@linux.vnet.ibm.com> | 2017-07-31 16:23:04 -0500 |
commit | bd1039b4639a9db4a292a9478f914932b2d54ffa (patch) | |
tree | 4013069139e3066f3b61d4737d807f52daf9c428 /block.c | |
parent | bc70597a487a3bb8585c155a43d09dcff5e4ffd2 (diff) | |
download | qemu-bd1039b4639a9db4a292a9478f914932b2d54ffa.zip qemu-bd1039b4639a9db4a292a9478f914932b2d54ffa.tar.gz qemu-bd1039b4639a9db4a292a9478f914932b2d54ffa.tar.bz2 |
block: An empty filename counts as no filename
Reproducer:
$ ./qemu-img info ''
qemu-img: ./block.c:1008: bdrv_open_driver: Assertion
`!drv->bdrv_needs_filename || bs->filename[0]' failed.
[1] 26105 abort (core dumped) ./qemu-img info ''
This patch fixes this to be:
$ ./qemu-img info ''
qemu-img: Could not open '': The 'file' block driver requires a file
name
Cc: qemu-stable <qemu-stable@nongnu.org>
Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit 4a0082401a770261b85625a41eef4a4e89ad7a74)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Diffstat (limited to 'block.c')
-rw-r--r-- | block.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -1167,7 +1167,7 @@ static int bdrv_open_common(BlockDriverState *bs, BlockBackend *file, filename = qdict_get_try_str(options, "filename"); } - if (drv->bdrv_needs_filename && !filename) { + if (drv->bdrv_needs_filename && (!filename || !filename[0])) { error_setg(errp, "The '%s' block driver requires a file name", drv->format_name); ret = -EINVAL; |