From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([209.51.188.92]:38399) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gyI5j-0001Fp-Np for qemu-devel@nongnu.org; Mon, 25 Feb 2019 10:22:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gyI5h-0001kA-OE for qemu-devel@nongnu.org; Mon, 25 Feb 2019 10:22:51 -0500 From: Kevin Wolf Date: Mon, 25 Feb 2019 16:20:33 +0100 Message-Id: <20190225152053.15976-52-kwolf@redhat.com> In-Reply-To: <20190225152053.15976-1-kwolf@redhat.com> References: <20190225152053.15976-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 51/71] block: Do not copy exact_filename from format file List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org From: Max Reitz If a format BDS's file BDS is in turn a format BDS, we cannot simply use the same filename, because when opening a BDS tree based on a filename alone, qemu will create only one format node on top of one protocol node (disregarding a potential backing file). Signed-off-by: Max Reitz Reviewed-by: Alberto Garcia Message-id: 20190201192935.18394-26-mreitz@redhat.com Signed-off-by: Max Reitz --- block.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/block.c b/block.c index 23869623ea..9d9929e1a2 100644 --- a/block.c +++ b/block.c @@ -5731,9 +5731,21 @@ void bdrv_refresh_filename(BlockDriverState *bs) =20 bs->exact_filename[0] =3D '\0'; =20 - /* If no specific options have been given for this BDS, the file= name of - * the underlying file should suffice for this one as well */ - if (bs->file->bs->exact_filename[0] && !generate_json_filename) = { + /* + * We can use the underlying file's filename if: + * - it has a filename, + * - the file is a protocol BDS, and + * - opening that file (as this BDS's format) will automatically= create + * the BDS tree we have right now, that is: + * - the user did not significantly change this BDS's behavior= with + * some explicit (strong) options + * - no non-file child of this BDS has been overridden by the = user + * Both of these conditions are represented by generate_json_f= ilename. + */ + if (bs->file->bs->exact_filename[0] && + bs->file->bs->drv->bdrv_file_open && + !generate_json_filename) + { strcpy(bs->exact_filename, bs->file->bs->exact_filename); } } --=20 2.20.1