|
|
1bdc94 |
From 3a3096956fec2d02a3ffe5bc4163a7a35e49707d Mon Sep 17 00:00:00 2001
|
|
|
1bdc94 |
From: Max Reitz <mreitz@redhat.com>
|
|
|
1bdc94 |
Date: Mon, 18 Jun 2018 17:48:32 +0200
|
|
|
1bdc94 |
Subject: [PATCH 10/89] qemu-img: Resolve relative backing paths in rebase
|
|
|
1bdc94 |
|
|
|
1bdc94 |
RH-Author: Max Reitz <mreitz@redhat.com>
|
|
|
1bdc94 |
Message-id: <20180618174833.19439-2-mreitz@redhat.com>
|
|
|
1bdc94 |
Patchwork-id: 80790
|
|
|
1bdc94 |
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 1/2] qemu-img: Resolve relative backing paths in rebase
|
|
|
1bdc94 |
Bugzilla: 1569835
|
|
|
1bdc94 |
RH-Acked-by: John Snow <jsnow@redhat.com>
|
|
|
1bdc94 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
1bdc94 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
1bdc94 |
|
|
|
1bdc94 |
Currently, rebase interprets a relative path for the new backing image
|
|
|
1bdc94 |
as follows:
|
|
|
1bdc94 |
(1) Open the new backing image with the given relative path (thus relative to
|
|
|
1bdc94 |
qemu-img's working directory).
|
|
|
1bdc94 |
(2) Write it directly into the overlay's backing path field (thus
|
|
|
1bdc94 |
relative to the overlay).
|
|
|
1bdc94 |
|
|
|
1bdc94 |
If the overlay is not in qemu-img's working directory, both will be
|
|
|
1bdc94 |
different interpretations, which may either lead to an error somewhere
|
|
|
1bdc94 |
(either rebase fails because it cannot open the new backing image, or
|
|
|
1bdc94 |
your overlay becomes unusable because its backing path does not point to
|
|
|
1bdc94 |
a file), or, even worse, it may result in your rebase being performed
|
|
|
1bdc94 |
for a different backing file than what your overlay will point to after
|
|
|
1bdc94 |
the rebase.
|
|
|
1bdc94 |
|
|
|
1bdc94 |
Fix this by interpreting the target backing path as relative to the
|
|
|
1bdc94 |
overlay, like qemu-img does everywhere else.
|
|
|
1bdc94 |
|
|
|
1bdc94 |
Buglink: https://bugzilla.redhat.com/show_bug.cgi?id=1569835
|
|
|
1bdc94 |
Cc: qemu-stable@nongnu.org
|
|
|
1bdc94 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
1bdc94 |
Message-id: 20180509182002.8044-2-mreitz@redhat.com
|
|
|
1bdc94 |
Reviewed-by: Eric Blake <eblake@redhat.com>
|
|
|
1bdc94 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
1bdc94 |
(cherry picked from commit d16699b64671466b42079c45b89127aeea1ca565)
|
|
|
1bdc94 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
1bdc94 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
1bdc94 |
---
|
|
|
1bdc94 |
qemu-img.c | 23 ++++++++++++++++++++++-
|
|
|
1bdc94 |
1 file changed, 22 insertions(+), 1 deletion(-)
|
|
|
1bdc94 |
|
|
|
1bdc94 |
diff --git a/qemu-img.c b/qemu-img.c
|
|
|
1bdc94 |
index 4bcf157..76d6e47 100644
|
|
|
1bdc94 |
--- a/qemu-img.c
|
|
|
1bdc94 |
+++ b/qemu-img.c
|
|
|
1bdc94 |
@@ -3202,6 +3202,9 @@ static int img_rebase(int argc, char **argv)
|
|
|
1bdc94 |
}
|
|
|
1bdc94 |
|
|
|
1bdc94 |
if (out_baseimg[0]) {
|
|
|
1bdc94 |
+ const char *overlay_filename;
|
|
|
1bdc94 |
+ char *out_real_path;
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
options = qdict_new();
|
|
|
1bdc94 |
if (out_basefmt) {
|
|
|
1bdc94 |
qdict_put_str(options, "driver", out_basefmt);
|
|
|
1bdc94 |
@@ -3210,8 +3213,26 @@ static int img_rebase(int argc, char **argv)
|
|
|
1bdc94 |
qdict_put_bool(options, BDRV_OPT_FORCE_SHARE, true);
|
|
|
1bdc94 |
}
|
|
|
1bdc94 |
|
|
|
1bdc94 |
- blk_new_backing = blk_new_open(out_baseimg, NULL,
|
|
|
1bdc94 |
+ overlay_filename = bs->exact_filename[0] ? bs->exact_filename
|
|
|
1bdc94 |
+ : bs->filename;
|
|
|
1bdc94 |
+ out_real_path = g_malloc(PATH_MAX);
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+ bdrv_get_full_backing_filename_from_filename(overlay_filename,
|
|
|
1bdc94 |
+ out_baseimg,
|
|
|
1bdc94 |
+ out_real_path,
|
|
|
1bdc94 |
+ PATH_MAX,
|
|
|
1bdc94 |
+ &local_err);
|
|
|
1bdc94 |
+ if (local_err) {
|
|
|
1bdc94 |
+ error_reportf_err(local_err,
|
|
|
1bdc94 |
+ "Could not resolve backing filename: ");
|
|
|
1bdc94 |
+ ret = -1;
|
|
|
1bdc94 |
+ g_free(out_real_path);
|
|
|
1bdc94 |
+ goto out;
|
|
|
1bdc94 |
+ }
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+ blk_new_backing = blk_new_open(out_real_path, NULL,
|
|
|
1bdc94 |
options, src_flags, &local_err);
|
|
|
1bdc94 |
+ g_free(out_real_path);
|
|
|
1bdc94 |
if (!blk_new_backing) {
|
|
|
1bdc94 |
error_reportf_err(local_err,
|
|
|
1bdc94 |
"Could not open new backing file '%s': ",
|
|
|
1bdc94 |
--
|
|
|
1bdc94 |
1.8.3.1
|
|
|
1bdc94 |
|