All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/2] qemu-img: Resolve relative backing paths in rebase
@ 2018-05-09 15:49 Max Reitz
  2018-05-09 15:49 ` [Qemu-devel] [PATCH 1/2] " Max Reitz
  2018-05-09 15:49 ` [Qemu-devel] [PATCH 2/2] iotests: Add test for rebasing with relative paths Max Reitz
  0 siblings, 2 replies; 7+ messages in thread
From: Max Reitz @ 2018-05-09 15:49 UTC (permalink / raw)
  To: qemu-block; +Cc: qemu-devel, Max Reitz, qemu-stable, Kevin Wolf

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-05-09 17:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-09 15:49 [Qemu-devel] [PATCH 0/2] qemu-img: Resolve relative backing paths in rebase Max Reitz
2018-05-09 15:49 ` [Qemu-devel] [PATCH 1/2] " 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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.