From 010ef312704884412f63b1d6bcb308a766f21f6a Mon Sep 17 00:00:00 2001 From: Max Reitz Date: Fri, 19 May 2017 14:29:46 +0200 Subject: [PATCH 26/27] block: An empty filename counts as no filename MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RH-Author: Max Reitz Message-id: <20170519142946.22012-2-mreitz@redhat.com> Patchwork-id: 75383 O-Subject: [RHV-7.4 qemu-kvm-rhev PATCH 1/1] block: An empty filename counts as no filename Bugzilla: 1452702 RH-Acked-by: Kevin Wolf RH-Acked-by: Wei Huang RH-Acked-by: Jeffrey Cody 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 Signed-off-by: Max Reitz Reviewed-by: Eric Blake Reviewed-by: Fam Zheng Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Kevin Wolf (cherry picked from commit 4a0082401a770261b85625a41eef4a4e89ad7a74) Signed-off-by: Max Reitz Signed-off-by: Miroslav Rezanina --- block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block.c b/block.c index 6201991..5bc0504 100644 --- a/block.c +++ b/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; -- 1.8.3.1