qemu-img cannot be used if filenames contain a ':'

Bug #1216009 reported by Robie Basak
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
qemu (Ubuntu)
Fix Released
Medium
Unassigned
Precise
Won't Fix
Undecided
Unassigned

Bug Description

I cannot use qemu-img to create a qcow2 format file with a name containing a colon (':')

Steps to reproduce:

1) qemu-img create -f qcow2 foo 1 # this works
2) qemu-img create -f qcow2 foo:bar 1 # this fails

Expected results: both commands should succeed, and I should end up with files "foo" and "foo:bar".
Actual results: the second command fails with the error: qemu-img: Unknown protocol 'foo:bar'

Affected:
qemu-utils 1.0+noroms-0ubuntu14.10
qemu-utils 1.5.0+dfsg-3ubuntu3

The root cause seems to be in qemu-img.c:print_block_option_help which calls bdrv_find_protocol(filename). This leads to block.c:bdrv_find_protocol which has the following comment:

    /*
     * XXX(hch): we really should not let host device detection
     * override an explicit protocol specification, but moving this
     * later breaks access to device names with colons in them.
     * Thanks to the brain-dead persistent naming schemes on udev-
     * based Linux systems those actually are quite common.
     */

Impact: this stops me using libvirt to import an image into a file-backed storage pool with a libvirt name containing a colon (':'), since libvirt maps these to files in the filesystem, and then qemu-img (or kvm-img as libvirt uses) fails on it. Thus I can't use libvirt storage volumes with colons in the name. I'm doing this to map product IDs in the new Ubuntu cloud image simplestreams naming scheme (and product IDs contain colons).

I also tried: qemu-img create -f qcow2 file://foo 1
But this just leads to: open("file://foo", O_WRONLY|O_CREAT|O_TRUNC, 0644) = -1 ENOENT (No such file or directory)

Workaround: qemu-img create -f qcow2 ./foo:bar 1 works on 1.5.0+dfsg-3ubuntu3, but not on 1.0+noroms-0ubuntu14.10. This may be related to: http://lists.nongnu.org/archive/html/qemu-devel/2013-07/msg01654.html

Scott Moser (smoser)
Changed in qemu (Ubuntu):
importance: Undecided → Medium
status: New → Fix Released
Robie Basak (racb)
summary: - qemu-img fails if filenames contain a ':'
+ qemu-img cannot be used if filenames contain a ':'
Revision history for this message
Scott Moser (smoser) wrote :

i marked fix-released as in saucy you can do:
 $ qemu-img create ./foo:bar 1
 Formatting './foo:bar', fmt=raw size=1

or
 $ qemu-img create $PWD/foo:bar 1
 Formatting '/tmp/foo:bar', fmt=raw size=1

both of these are reasonable work arounds, but do not work on precise.

Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

Sounds like we might need commit

98289620e0460fa595581020ab20127da4a2fc44 block: Don't parse protocol from file.filename

which says

    This allows opening relative file names that contain a colon.

Revision history for this message
Serge Hallyn (serge-hallyn) wrote :

Although note that saucy doesn't have that patch either. Hm.

Revision history for this message
Steve Langasek (vorlon) wrote :

The Precise Pangolin has reached end of life, so this bug will not be fixed for that release

Changed in qemu (Ubuntu Precise):
status: New → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.