mirror of https://gitee.com/openkylin/qemu.git
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>
This commit is contained in:
parent
312758e237
commit
4a0082401a
2
block.c
2
block.c
|
@ -1204,7 +1204,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;
|
||||
|
|
Loading…
Reference in New Issue