[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v12 12/31] block: Add bdrv_make_absolute_filename()
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH v12 12/31] block: Add bdrv_make_absolute_filename() |
Date: |
Mon, 17 Dec 2018 23:43:29 +0100 |
This is a general function for making a filename that is relative to a
certain BDS absolute.
It calls bdrv_get_full_backing_filename_from_filename() for now, but
that will be changed in a follow-up patch.
Signed-off-by: Max Reitz <address@hidden>
Reviewed-by: Alberto Garcia <address@hidden>
---
block.c | 27 ++++++++++++++++++++-------
1 file changed, 20 insertions(+), 7 deletions(-)
diff --git a/block.c b/block.c
index 615ffa7f40..08b89b86fd 100644
--- a/block.c
+++ b/block.c
@@ -338,16 +338,29 @@ char *bdrv_get_full_backing_filename_from_filename(const
char *backed,
}
}
-char *bdrv_get_full_backing_filename(BlockDriverState *bs, Error **errp)
+/*
+ * If @filename is empty or NULL, this function returns NULL without
+ * setting @errp. In all other cases, NULL will only be returned with
+ * @errp set.
+ */
+static char *bdrv_make_absolute_filename(BlockDriverState *relative_to,
+ const char *filename, Error **errp)
{
- char *backed;
+ char *bs_filename;
- bdrv_refresh_filename(bs);
+ bdrv_refresh_filename(relative_to);
+
+ bs_filename = relative_to->exact_filename[0]
+ ? relative_to->exact_filename
+ : relative_to->filename;
- backed = bs->exact_filename[0] ? bs->exact_filename : bs->filename;
- return bdrv_get_full_backing_filename_from_filename(backed,
- bs->backing_file,
- errp);
+ return bdrv_get_full_backing_filename_from_filename(bs_filename,
+ filename ?: "", errp);
+}
+
+char *bdrv_get_full_backing_filename(BlockDriverState *bs, Error **errp)
+{
+ return bdrv_make_absolute_filename(bs, bs->backing_file, errp);
}
void bdrv_register(BlockDriver *bdrv)
--
2.19.2
- [Qemu-devel] [PATCH v12 00/31] block: Fix some filename generation issues, Max Reitz, 2018/12/17
- [Qemu-devel] [PATCH v12 01/31] block: Use bdrv_refresh_filename() to pull, Max Reitz, 2018/12/17
- [Qemu-devel] [PATCH v12 02/31] block: Use children list in bdrv_refresh_filename, Max Reitz, 2018/12/17
- [Qemu-devel] [PATCH v12 03/31] block: Skip implicit nodes for filename info, Max Reitz, 2018/12/17
- [Qemu-devel] [PATCH v12 04/31] block: Add BDS.auto_backing_file, Max Reitz, 2018/12/17
- [Qemu-devel] [PATCH v12 06/31] iotests.py: Add filter_imgfmt(), Max Reitz, 2018/12/17
- [Qemu-devel] [PATCH v12 05/31] block: Respect backing bs in bdrv_refresh_filename, Max Reitz, 2018/12/17
- [Qemu-devel] [PATCH v12 07/31] iotests.py: Add node_info(), Max Reitz, 2018/12/17
- [Qemu-devel] [PATCH v12 09/31] block: Make path_combine() return the path, Max Reitz, 2018/12/17
- [Qemu-devel] [PATCH v12 08/31] iotests: Add test for backing file overrides, Max Reitz, 2018/12/17
- [Qemu-devel] [PATCH v12 12/31] block: Add bdrv_make_absolute_filename(),
Max Reitz <=
- [Qemu-devel] [PATCH v12 10/31] block: bdrv_get_full_backing_filename_from_...'s ret. val., Max Reitz, 2018/12/17
- [Qemu-devel] [PATCH v12 11/31] block: bdrv_get_full_backing_filename's ret. val., Max Reitz, 2018/12/17
- [Qemu-devel] [PATCH v12 13/31] block: Fix bdrv_find_backing_image(), Max Reitz, 2018/12/17
- [Qemu-devel] [PATCH v12 14/31] block: Add bdrv_dirname(), Max Reitz, 2018/12/17
- [Qemu-devel] [PATCH v12 15/31] blkverify: Make bdrv_dirname() return NULL, Max Reitz, 2018/12/17
- [Qemu-devel] [PATCH v12 16/31] quorum: Make bdrv_dirname() return NULL, Max Reitz, 2018/12/17
- [Qemu-devel] [PATCH v12 17/31] block/nbd: Make bdrv_dirname() return NULL, Max Reitz, 2018/12/17
- [Qemu-devel] [PATCH v12 18/31] block/nfs: Implement bdrv_dirname(), Max Reitz, 2018/12/17
- [Qemu-devel] [PATCH v12 19/31] block: Use bdrv_dirname() for relative filenames, Max Reitz, 2018/12/17
- [Qemu-devel] [PATCH v12 20/31] iotests: Add quorum case to test 110, Max Reitz, 2018/12/17