[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v7 for-2.12 10/25] block: Fix bdrv_find_backing_imag
From: |
Max Reitz |
Subject: |
[Qemu-devel] [PATCH v7 for-2.12 10/25] block: Fix bdrv_find_backing_image() |
Date: |
Mon, 20 Nov 2017 21:09:49 +0100 |
bdrv_find_backing_image() should use bdrv_get_full_backing_filename() or
bdrv_make_absolute_filename() instead of trying to do what those
functions do by itself.
path_combine_deprecated() can now be dropped, so let's do that.
Signed-off-by: Max Reitz <address@hidden>
---
block.c | 30 ++++++++++--------------------
1 file changed, 10 insertions(+), 20 deletions(-)
diff --git a/block.c b/block.c
index a11cebf0cb..ecea78dae0 100644
--- a/block.c
+++ b/block.c
@@ -196,15 +196,6 @@ char *path_combine(const char *base_path, const char
*filename)
return result;
}
-static void path_combine_deprecated(char *dest, int dest_size,
- const char *base_path,
- const char *filename)
-{
- char *combined = path_combine(base_path, filename);
- pstrcpy(dest, dest_size, combined);
- g_free(combined);
-}
-
/*
* Helper function for bdrv_parse_filename() implementations to remove optional
* protocol prefixes (especially "file:") from a filename and for putting the
@@ -4133,7 +4124,6 @@ BlockDriverState
*bdrv_find_backing_image(BlockDriverState *bs,
filename_full = g_malloc(PATH_MAX);
backing_file_full = g_malloc(PATH_MAX);
- filename_tmp = g_malloc(PATH_MAX);
is_protocol = path_has_protocol(backing_file);
@@ -4162,22 +4152,23 @@ BlockDriverState
*bdrv_find_backing_image(BlockDriverState *bs,
} else {
/* If not an absolute filename path, make it relative to the
current
* image's filename path */
- path_combine_deprecated(filename_tmp, PATH_MAX, curr_bs->filename,
- backing_file);
-
- /* We are going to compare absolute pathnames */
- if (!realpath(filename_tmp, filename_full)) {
+ filename_tmp = bdrv_make_absolute_filename(curr_bs, backing_file,
+ NULL);
+ /* We are going to compare canonicalized absolute pathnames */
+ if (!filename_tmp || !realpath(filename_tmp, filename_full)) {
+ g_free(filename_tmp);
continue;
}
+ g_free(filename_tmp);
/* We need to make sure the backing filename we are comparing
against
* is relative to the current image filename (or absolute) */
- path_combine_deprecated(filename_tmp, PATH_MAX, curr_bs->filename,
- curr_bs->backing_file);
-
- if (!realpath(filename_tmp, backing_file_full)) {
+ filename_tmp = bdrv_get_full_backing_filename(curr_bs, NULL);
+ if (!filename_tmp || !realpath(filename_tmp, backing_file_full)) {
+ g_free(filename_tmp);
continue;
}
+ g_free(filename_tmp);
if (strcmp(backing_file_full, filename_full) == 0) {
retval = curr_bs->backing->bs;
@@ -4188,7 +4179,6 @@ BlockDriverState
*bdrv_find_backing_image(BlockDriverState *bs,
g_free(filename_full);
g_free(backing_file_full);
- g_free(filename_tmp);
return retval;
}
--
2.13.6
- [Qemu-devel] [PATCH v7 for-2.12 00/25] block: Fix some filename generation issues, Max Reitz, 2017/11/20
- [Qemu-devel] [PATCH v7 for-2.12 01/25] block/mirror: Small absolute-paths simplification, Max Reitz, 2017/11/20
- [Qemu-devel] [PATCH v7 for-2.12 02/25] block: Use children list in bdrv_refresh_filename, Max Reitz, 2017/11/20
- [Qemu-devel] [PATCH v7 for-2.12 03/25] block: Add BDS.backing_overridden, Max Reitz, 2017/11/20
- [Qemu-devel] [PATCH v7 for-2.12 04/25] iotests: Drop explicit base blockdev in 191, Max Reitz, 2017/11/20
- [Qemu-devel] [PATCH v7 for-2.12 05/25] block: Respect backing bs in bdrv_refresh_filename, Max Reitz, 2017/11/20
- [Qemu-devel] [PATCH v7 for-2.12 06/25] block: Make path_combine() return the path, Max Reitz, 2017/11/20
- [Qemu-devel] [PATCH v7 for-2.12 07/25] block: bdrv_get_full_backing_filename_from_...'s ret. val., Max Reitz, 2017/11/20
- [Qemu-devel] [PATCH v7 for-2.12 08/25] block: bdrv_get_full_backing_filename's ret. val., Max Reitz, 2017/11/20
- [Qemu-devel] [PATCH v7 for-2.12 09/25] block: Add bdrv_make_absolute_filename(), Max Reitz, 2017/11/20
- [Qemu-devel] [PATCH v7 for-2.12 10/25] block: Fix bdrv_find_backing_image(),
Max Reitz <=
- [Qemu-devel] [PATCH v7 for-2.12 11/25] block: Add bdrv_dirname(), Max Reitz, 2017/11/20
- [Qemu-devel] [PATCH v7 for-2.12 12/25] blkverify: Make bdrv_dirname() return NULL, Max Reitz, 2017/11/20
- [Qemu-devel] [PATCH v7 for-2.12 13/25] quorum: Make bdrv_dirname() return NULL, Max Reitz, 2017/11/20
- [Qemu-devel] [PATCH v7 for-2.12 14/25] block/nbd: Make bdrv_dirname() return NULL, Max Reitz, 2017/11/20
- [Qemu-devel] [PATCH v7 for-2.12 15/25] block/nfs: Implement bdrv_dirname(), Max Reitz, 2017/11/20
- [Qemu-devel] [PATCH v7 for-2.12 16/25] block: Use bdrv_dirname() for relative filenames, Max Reitz, 2017/11/20
- [Qemu-devel] [PATCH v7 for-2.12 17/25] iotests: Add quorum case to test 110, Max Reitz, 2017/11/20
- [Qemu-devel] [PATCH v7 for-2.12 19/25] block: Add BlockDriver.bdrv_gather_child_options, Max Reitz, 2017/11/20
- [Qemu-devel] [PATCH v7 for-2.12 18/25] block: Add sgfnt_runtime_opts to BlockDriver, Max Reitz, 2017/11/20
- [Qemu-devel] [PATCH v7 for-2.12 20/25] block: Generically refresh runtime options, Max Reitz, 2017/11/20