Bug 811649 - libguestfs cannot open disk images which are symlinks to files that contain ':' (colon) character
libguestfs cannot open disk images which are symlinks to files that contain '...
Status: CLOSED UPSTREAM
Product: Virtualization Tools
Classification: Community
Component: libguestfs (Show other bugs)
unspecified
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Richard W.M. Jones
:
Depends On:
Blocks: 812092
  Show dependency treegraph
 
Reported: 2012-04-11 11:46 EDT by Richard W.M. Jones
Modified: 2013-05-11 10:43 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 812092 (view as bug list)
Environment:
Last Closed: 2012-04-12 16:56:49 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Richard W.M. Jones 2012-04-11 11:46:34 EDT
Description of problem:

(Reported by Igor Lvovsky using RHEL 6.2 + libguestfs 1.16.15
from preview repository.  I can't reproduce it at the moment)

A qcow2 image is located on an NFS export.

add_drive_opts is OK.

launch fails with some unknown error.

Version-Release number of selected component (if applicable):

libguestfs 1.16.15 on RHEL 6.2/6.3.
Comment 1 Richard W.M. Jones 2012-04-11 11:59:31 EDT
OK I *can* reproduce this.

Using Python, RHEL 6.3, libguestfs 1.16.15.

I wrote the following script:

------------------- /tmp/test.py -----------
import guestfs
guest = guestfs.GuestFS()
guest.set_qemu('/usr/libexec/qemu-kvm')
guest.add_drive_opts('/mnt/scratch/test1.img', format='qcow2')
guest.launch()
--------------------------------------------

/mnt/scratch is an NFSv4 filesystem exported from another machine.

test1.img is a raw disk image created on another machine.

Running this script produces:

$ python /tmp/test.py 
python: Objects/stringobject.c:115: PyString_FromString: Assertion `str != ((void *)0)' failed.
Aborted (core dumped)
Comment 2 Richard W.M. Jones 2012-04-11 12:00:44 EDT
Enabling debug:

[00275ms] /usr/libexec/qemu-kvm \
    -global virtio-blk-pci.scsi=off \
    -drive file=/mnt/scratch/test1.img,cache=off,format=qcow2,if=virtio \
    -nodefconfig \
    -nodefaults \
    -nographic \
    -m 500 \
    -no-reboot \
    -device virtio-serial \
    -serial stdio \
    -chardev socket,path=/tmp/libguestfsTuLj1x/guestfsd.sock,id=channel0 \
    -device virtserialport,chardev=channel0,name=org.libguestfs.channel.0 \
    -kernel /var/tmp/.guestfs-500/kernel.19013 \
    -initrd /var/tmp/.guestfs-500/initrd.19013 \
    -append 'panic=1 console=ttyS0 udevtimeout=300 no_timer_check acpi=off printk.time=1 cgroup_disable=memory selinux=0 guestfs_verbose=1 TERM=xterm ' \
    -drive file=/var/tmp/.guestfs-500/root.19013,snapshot=on,if=virtio,cache=unsafeopen /dev/kvm: No such file or directory
Could not initialize KVM, will disable KVM support
qemu-kvm: -drive file=/mnt/scratch/test1.img,cache=off,format=qcow2,if=virtio: could not open disk image /mnt/scratch/test1.img: Invalid argument
libguestfs: child_cleanup: 0x1707040: child process died
python: Objects/stringobject.c:115: PyString_FromString: Assertion `str != ((void *)0)' failed.
Aborted (core dumped)

NB. the core dump is a separate issue, bug 811650.
Comment 3 Richard W.M. Jones 2012-04-11 12:04:05 EDT
Can also reproduce this on libguestfs 1.17.27 on Fedora.
Comment 4 Richard W.M. Jones 2012-04-11 12:20:21 EDT
Sorry, my stupid mistake.  Of course the error from
qemu there is correct because I used a raw format image,
but forced the format to be qcow2.

I cannot reproduce the "fails to start" problem after
fixing that.
Comment 5 Richard W.M. Jones 2012-04-12 09:10:33 EDT
I reproduced this on Igor's original machine, and
the error is very strange.  In the text below, compare
the original string passed to add_drive_opts with the
corrupted(?) string that gets placed on the qemu
command line.

In [1]: import guestfs
In [2]: g = guestfs.GuestFS()
In [3]: g.set_verbose(1)
In [4]: g.add_drive_opts('/rhev/data-center/1b6f5ed0-6363-4600-b050-0438efd36570/d09e3b5f-c06a-4fb8-9e11-219e70787edc/kuku', format='qcow2')
In [5]: g.launch()

[00145ms] /usr/libexec/qemu-kvm \
    -global virtio-blk-pci.scsi=off \
    -drive file=/rhev/data-center/mnt/dandylion:_export_regression_reg1/d09e3b5f-c06a-4fb8-9e11-219e70787edc/kuku,cache=off,format=qcow2,if=virtio \
    -nodefconfig \
    -enable-kvm \
    -nodefaults \
    -nographic \
    -m 500 \
    -no-reboot \
    -device virtio-serial \
    -serial stdio \
    -chardev socket,path=/tmp/libguestfsd3mNvG/guestfsd.sock,id=channel0 \
    -device virtserialport,chardev=channel0,name=org.libguestfs.channel.0 \
    -kernel /var/tmp/.guestfs-36/kernel.11742 \
    -initrd /var/tmp/.guestfs-36/initrd.11742 \
    -append 'panic=1 console=ttyS0 udevtimeout=300 no_timer_check acpi=off printk.time=1 cgroup_disable=memory selinux=0 guestfs_verbose=1 TERM=xterm ' \
    -drive file=/var/tmp/.guestfs-36/root.11742,snapshot=on,if=virtio,cache=unsafeqemu-kvm: -drive file=/rhev/data-center/mnt/dandylion:_export_regression_reg1/d09e3b5f-c06a-4fb8-9e11-219e70787edc/kuku,cache=off,format=qcow2,if=virtio: could not open disk image /rhev/data-center/mnt/dandylion:_export_regression_reg1/d09e3b5f-c06a-4fb8-9e11-219e70787edc/kuku: No such file or directory
libguestfs: child_cleanup: 0x1abcdf0: child process died
Comment 6 Richard W.M. Jones 2012-04-12 09:30:47 EDT
The problem is that *we* are rewriting the path (calling
realpath(3)) and the destination path contains a colon which
breaks qemu's parsing.

A simple reproducer:

$ qemu-img create -f qcow2 '/tmp/foo' 1G
Formatting '/tmp/foo', fmt=qcow2 size=1073741824 encryption=off cluster_size=65536 
$ mv /tmp/foo /tmp/foo:bar
$ guestfish -a /tmp/foo\:bar -v run
[... fails with ...]
qemu-kvm: -drive file=/tmp/foo:bar,cache=off,if=virtio: could not open disk image /tmp/foo:bar: No such file or directory
Comment 7 Richard W.M. Jones 2012-04-12 16:56:49 EDT
I pushed patches upstream (in libguestfs 1.17.29)
that should fix this.

4dba0e1e9d7fca190e7877856ce69618d99e85c9
4be630edb31f654068509d470e8b44039580954d
d2183a62aadff11609b561d3f821ec7d6094aa39
a9bd90abfb3d4519278dfff305b8b7033ae6d76a
Comment 8 Richard W.M. Jones 2013-05-11 10:43:26 EDT
qemu has fixed this upstream, so I've been able to put
a complete fix into libguestfs.

https://github.com/libguestfs/libguestfs/commit/a95214b1985e694946e3426120a6fdc13a3f081f

Note You need to log in before you can comment on or make changes to this bug.