diff options
author | Max Reitz <mreitz@redhat.com> | 2019-02-01 20:29:29 +0100 |
---|---|---|
committer | Max Reitz <mreitz@redhat.com> | 2019-02-25 15:11:27 +0100 |
commit | fb695c74aa43c9bdc67b3079cddec1cc8e1b913e (patch) | |
tree | 1fa6feb81854cbbc59a1745c224a2a549d6dce7f /block.c | |
parent | 998b3a1e5a2dd23bf89a853e15fabdaa8d788a72 (diff) | |
download | qemu-fb695c74aa43c9bdc67b3079cddec1cc8e1b913e.zip qemu-fb695c74aa43c9bdc67b3079cddec1cc8e1b913e.tar.gz qemu-fb695c74aa43c9bdc67b3079cddec1cc8e1b913e.tar.bz2 |
block: Do not copy exact_filename from format file
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 <mreitz@redhat.com>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Message-id: 20190201192935.18394-26-mreitz@redhat.com
Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r-- | block.c | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -5731,9 +5731,21 @@ void bdrv_refresh_filename(BlockDriverState *bs) bs->exact_filename[0] = '\0'; - /* If no specific options have been given for this BDS, the filename 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_filename. + */ + 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); } } |