From: Max Reitz <mreitz@redhat.com>
To: qemu-block@nongnu.org
Cc: qemu-devel@nongnu.org, Max Reitz <mreitz@redhat.com>,
qemu-stable@nongnu.org, Kevin Wolf <kwolf@redhat.com>
Subject: [Qemu-devel] [PATCH 0/2] qemu-img: Resolve relative backing paths in rebase
Date: Wed, 9 May 2018 17:49:47 +0200 [thread overview]
Message-ID: <20180509154949.8206-1-mreitz@redhat.com> (raw)
The issue addressed in this series affects relative backing paths given
to qemu-img rebase. For the rebasing operation itself, qemu-img uses
the target backing path as-is, that is, relative to its working
directory. But after rebasing, the path is again written as-is into the
overlay, so it is now relative to the overlay.
Simple test case:
$ mkdir /tmp/foo && cd /tmp
$ qemu-img create -f qcow2 foo/base-old.qcow2 64M
Formatting 'foo/base-old.qcow2', fmt=qcow2 size=67108864 cluster_size=65536 lazy_refcounts=off refcount_bits=16
$ qemu-img create -f qcow2 foo/base-new.qcow2 64M
Formatting 'foo/base-new.qcow2', fmt=qcow2 size=67108864 cluster_size=65536 lazy_refcounts=off refcount_bits=16
$ qemu-img create -f qcow2 -b base-old.qcow2 foo/overlay.qcow2 64M
Formatting 'foo/overlay.qcow2', fmt=qcow2 size=67108864 backing_file=base-old.qcow2 cluster_size=65536 lazy_refcounts=off refcount_bits=16
$ qemu-img rebase -b base-new.qcow2 foo/overlay.qcow2
qemu-img: Could not open new backing file 'base-new.qcow2': Could not open 'base-new.qcow2': No such file or directory
Oops. Now one may be tempted to try:
$ qemu-img rebase -b foo/base-new.qcow2 foo/overlay.qcow2
$ echo $?
0
However:
$ qemu-img info foo/overlay.qcow2
[...]
backing file: foo/base-new.qcow2 (actual path: foo/foo/base-new.qcow2)
[...]
$ qemu-io -c close foo/overlay.qcow2
can't open device foo/overlay.qcow2: Could not open backing file: Could not open 'foo/foo/base-new.qcow2': No such file or directory
Oops.
So the only way to do it before this series is:
$ qemu-img rebase -b foo/base-new.qcow2 foo/overlay.qcow2
$ qemu-img rebase -u -b base-new.qcow2 foo/overlay.qcow2
That does not seem right to me.
So this series makes qemu-img rebase always interpret the target backing
path relatively to the overlay image, because that is how we always
interpret relative backing paths.
Max Reitz (2):
qemu-img: Resolve relative backing paths in rebase
iotests: Add test for rebasing with relative paths
qemu-img.c | 22 ++++++++++++-
tests/qemu-iotests/024 | 82 ++++++++++++++++++++++++++++++++++++++++++++--
tests/qemu-iotests/024.out | 30 +++++++++++++++++
3 files changed, 130 insertions(+), 4 deletions(-)
--
2.14.3
next reply other threads:[~2018-05-09 15:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-09 15:49 Max Reitz [this message]
2018-05-09 15:49 ` [Qemu-devel] [PATCH 1/2] qemu-img: Resolve relative backing paths in rebase Max Reitz
2018-05-09 17:20 ` Eric Blake
2018-05-09 17:56 ` [Qemu-devel] [Qemu-block] " Max Reitz
2018-05-09 15:49 ` [Qemu-devel] [PATCH 2/2] iotests: Add test for rebasing with relative paths Max Reitz
2018-05-09 17:24 ` Eric Blake
2018-05-09 17:58 ` [Qemu-devel] [Qemu-block] " Max Reitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180509154949.8206-1-mreitz@redhat.com \
--to=mreitz@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).