Skip to content

block: Fix backing paths for filenames with colons

Max Reitz qemu-devel 2 versions Applied

Status from this message: Applied to my block tree, with the spelling in patch 3 fixed as

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest3 patches 4 repliesApplied
  2. v12 patches 2 repliesSuperseded

Changes in v2 from the cover letter

- Kept patch 1 unchanged
- Added patch 2
- Extended patch 3 (did NOT change the patch title)

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/3block: Fix backing paths for filenames with colonsblock.c+10 -50 replies
2/3block/file-*: *_parse_filename() and colonsblock.c block/file-posix.c block/file-win32.c +1 more+43 -241 reply
3/3iotests: Add test for colon handlingtests/qemu-iotests/126 tests/qemu-iotests/126.out tests/qemu-iotests/group+129 -02 replies

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchEric Blake
1/3R-b
2/3R-b
3/3R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [Qemu-devel] [PATCH v2 0/3] block: Fix backing paths for filenames with colons

There are (at least) two issues with filenames that contain colons when trying to use relative backing filenames with them, for each of which there is a patch in this series.

The first patch fixes an issue in the general block layer (path_combine() does not have the same opinion on what constitutes a protocol prefix as path_has_protocl()), the second fixes an issue in file-* (when stripping off the optional "file:" prefix we should not create a filename that seems to have another valid protocol prefix).

The third patch adds a test.

Bonus info: The following is something I did not change, although it is weird:

$ mkdir foo && cd foo
$ ../qemu-img create -f qcow2 file:image:base.qcow2 64M
Formatting 'file:image:base.qcow2', fmt=qcow2 size=67108864
    encryption=off cluster_size=65536 lazy_refcounts=off
    refcount_bits=16
$ ../qemu-img create -f qcow2 -b file:image:base.qcow2 file:image:top.qcow2
Formatting 'file:image:top.qcow2', fmt=qcow2 size=67108864
    backing_file=file:image:base.qcow2 encryption=off
    cluster_size=65536 lazy_refcounts=off refcount_bits=16
$ cd ..
$ ./qemu-img info foo/image:top.qcow2
image: foo/image:top.qcow2
file format: qcow2
virtual size: 64M (67108864 bytes)
disk size: 196K
cluster_size: 65536
backing file: file:image:base.qcow2
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false
$ ./qemu-io foo/image:top.qcow2
can't open device foo/image:top.qcow2: Could not open backing file:
    Could not open './image:base.qcow2': No such file or directory

Patch 3 adds a comment to the test which explains this behavior in a bit more detail, but the gist is this: qemu generally thinks that protocol-prefixed filenames are absolute filenames; but from a file-posix perspective, "file:foo" is still a relative filename.

I think the above behavior is what we want and that it's the best we can do, but it still is weird, so I just wanted to mention it.

v2:
- Kept patch 1 unchanged
- Added patch 2
- Extended patch 3 (did NOT change the patch title)

git-backport-diff against v2:

Key:
[----] : patches are identical
[####] : number of functional differences between upstream/downstream patch [down] : patch is downstream-only
The flags [FC] indicate (F)unctional and (C)ontextual differences, respectively

001/3:[----] [--] 'block: Fix backing paths for filenames with colons' 002/3:[down] 'block/file-*: *_parse_filename() and colons' 003/3:[0036] [FC] 'iotests: Add test for colon handling'

Max Reitz (3):
block: Fix backing paths for filenames with colons block/file-*: *_parse_filename() and colons
iotests: Add test for colon handling

 include/block/block_int.h  |   3 ++
 block.c                    |  50 ++++++++++++++++++---
 block/file-posix.c         |  17 ++------
 block/file-win32.c         |  12 +-----
 tests/qemu-iotests/126     | 105 +++++++++++++++++++++++++++++++++++++++++++++
 tests/qemu-iotests/126.out |  23 ++++++++++
 tests/qemu-iotests/group   |   1 +
 7 files changed, 182 insertions(+), 29 deletions(-)
 create mode 100755 tests/qemu-iotests/126
 create mode 100644 tests/qemu-iotests/126.out
Signature · 1 line
2.9.4