[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH 12/19] block: Fix bdrv_find_backing_image()
From: |
Max Reitz |
Subject: |
[Qemu-block] [PATCH 12/19] block: Fix bdrv_find_backing_image() |
Date: |
Tue, 26 Apr 2016 23:32:11 +0200 |
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 | 28 +++++++++++++---------------
1 file changed, 13 insertions(+), 15 deletions(-)
diff --git a/block.c b/block.c
index 49dc2cb..6e89abd 100644
--- a/block.c
+++ b/block.c
@@ -192,15 +192,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);
-}
-
char *bdrv_get_full_backing_filename_from_filename(const char *backed,
const char *backing,
Error **errp)
@@ -3147,7 +3138,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);
@@ -3163,22 +3153,31 @@ 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);
+ filename_tmp = bdrv_make_absolute_filename(curr_bs, backing_file,
+ NULL);
+ if (!filename_tmp) {
+ continue;
+ }
/* We are going to compare absolute pathnames */
if (!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);
+ filename_tmp = bdrv_get_full_backing_filename(curr_bs, NULL);
+ if (!filename_tmp) {
+ continue;
+ }
if (!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;
@@ -3189,7 +3188,6 @@ BlockDriverState
*bdrv_find_backing_image(BlockDriverState *bs,
g_free(filename_full);
g_free(backing_file_full);
- g_free(filename_tmp);
return retval;
}
--
2.8.0
- Re: [Qemu-block] [PATCH 02/19] block: Add BDS.backing_overridden, (continued)
- [Qemu-block] [PATCH 05/19] block: Add bdrv_default_refresh_protocol_filename, Max Reitz, 2016/04/26
- [Qemu-block] [PATCH 03/19] block: Respect backing bs in bdrv_refresh_filename, Max Reitz, 2016/04/26
- [Qemu-block] [PATCH 04/19] block: Add bdrv_default_refresh_format_filename, Max Reitz, 2016/04/26
- [Qemu-block] [PATCH 06/19] block: Make bdrv_default_refresh_format_filename public, Max Reitz, 2016/04/26
- [Qemu-block] [PATCH 07/19] qcow2: Implement bdrv_refresh_filename(), Max Reitz, 2016/04/26
- [Qemu-block] [PATCH 11/19] block: Add bdrv_make_absolute_filename(), Max Reitz, 2016/04/26
- [Qemu-block] [PATCH 08/19] block: Make path_combine() return the path, Max Reitz, 2016/04/26
- [Qemu-block] [PATCH 09/19] block: bdrv_get_full_backing_filename_from_...'s ret. val., Max Reitz, 2016/04/26
- [Qemu-block] [PATCH 10/19] block: bdrv_get_full_backing_filename's ret. val., Max Reitz, 2016/04/26
- [Qemu-block] [PATCH 12/19] block: Fix bdrv_find_backing_image(),
Max Reitz <=
- [Qemu-block] [PATCH 14/19] blkverify: Make bdrv_dirname() return NULL, Max Reitz, 2016/04/26
- [Qemu-block] [PATCH 13/19] block: Add bdrv_dirname(), Max Reitz, 2016/04/26
- [Qemu-block] [PATCH 17/19] block: Use bdrv_dirname() for relative filenames, Max Reitz, 2016/04/26
- [Qemu-block] [PATCH 19/19] iotests: Add quorum case to test 110, Max Reitz, 2016/04/26
- [Qemu-block] [PATCH 15/19] quorum: Make bdrv_dirname() return NULL, Max Reitz, 2016/04/26
- [Qemu-block] [PATCH 16/19] block/nbd: Implement bdrv_dirname(), Max Reitz, 2016/04/26
- [Qemu-block] [PATCH 18/19] block: Add 'base-directory' BDS option, Max Reitz, 2016/04/26