From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50518) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VrcnT-0005z7-3A for qemu-devel@nongnu.org; Fri, 13 Dec 2013 19:09:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VrcnN-0004gN-2q for qemu-devel@nongnu.org; Fri, 13 Dec 2013 19:09:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:7474) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VrcnM-0004gF-Q7 for qemu-devel@nongnu.org; Fri, 13 Dec 2013 19:09:25 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rBE09Noj019282 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 13 Dec 2013 19:09:23 -0500 Message-ID: <52ABA1E5.1020501@redhat.com> Date: Sat, 14 Dec 2013 01:10:13 +0100 From: Max Reitz MIME-Version: 1.0 References: <1386954633-28905-1-git-send-email-mreitz@redhat.com> <1386954633-28905-12-git-send-email-mreitz@redhat.com> <20131213200614.GY3916@dhcp-200-207.str.redhat.com> In-Reply-To: <20131213200614.GY3916@dhcp-200-207.str.redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v5 11/22] block: Allow block devices without files List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: Fam Zheng , qemu-devel@nongnu.org, Stefan Hajnoczi On 13.12.2013 21:06, Kevin Wolf wrote: > Am 13.12.2013 um 18:10 hat Max Reitz geschrieben: >> blkdebug and blkverify will, in order to retain compatibility, not >> support the field "file" implicitly through bdrv_open(). In order to be >> able to use those drivers without giving a filename anyway, it is >> necessary to be able to have block devices without files implicitly >> opened by bdrv_open(). This is the case, if there was neither a file >> name, a reference to an existing block device to use as a file nor >> options specific to the file. >> >> Signed-off-by: Max Reitz >> --- >> block.c | 15 +++++++++------ >> 1 file changed, 9 insertions(+), 6 deletions(-) >> >> diff --git a/block.c b/block.c >> index bef4f82..9659eb5 100644 >> --- a/block.c >> +++ b/block.c >> @@ -1145,11 +1145,14 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options, >> qdict_extract_subqdict(options, &file_options, "file."); >> file_reference = qdict_get_try_str(options, "file"); >> >> - ret = bdrv_file_open(&file, filename, file_reference, file_options, >> - bdrv_open_flags(bs, flags | BDRV_O_UNMAP), &local_err); >> - qdict_del(options, "file"); >> - if (ret < 0) { >> - goto fail; >> + if (filename || file_reference || qdict_size(file_options)) { >> + ret = bdrv_file_open(&file, filename, file_reference, file_options, >> + bdrv_open_flags(bs, flags | BDRV_O_UNMAP), >> + &local_err); >> + qdict_del(options, "file"); >> + if (ret < 0) { >> + goto fail; >> + } >> } >> >> /* Find the right image format driver */ >> @@ -1178,7 +1181,7 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options, > Manually adding more context before the next hunk: > >> if (!drv) { >> ret = find_image_format(file, filename, &drv, &local_err); >> } > We can get file == NULL now, which will cause a segfault in > find_image_format. (For a reproducer of the segfault, try > 'x86_64-softmmu/qemu-system-x86_64 -drive foo=bar') Right, thanks. Max