Bug 1503497 - qemu-kvm fails to open qcow2 files in read-only mode with qemu-kvm 1.5.3
Summary: qemu-kvm fails to open qcow2 files in read-only mode with qemu-kvm 1.5.3
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libguestfs
Version: 7.4
Hardware: x86_64
OS: Linux
high
medium
Target Milestone: rc
: ---
Assignee: Richard W.M. Jones
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-10-18 09:33 UTC by YongkuiGuo
Modified: 2018-04-10 09:21 UTC (History)
5 users (show)

Fixed In Version: libguestfs-1.36.10-6.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-04-10 09:20:40 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2018:0677 0 None None None 2018-04-10 09:21:36 UTC

Description YongkuiGuo 2017-10-18 09:33:32 UTC
Description of problem:

After executing 'add-drive-ro-with-if ...' and 'run' commands in guestfish shell, the error is thrown as below:
"qemu-kvm: ... could not open disk image hd0: The 'qcow2' block driver requires a file name"


Version-Release number of selected component (if applicable):
libguestfs-1.36.7-1.el7.x86_64


How reproducible:
100%


Steps:

1.#qemu-img create /tmp/autotest-libguestfs/ide.img 1G

2.#export LIBGUESTFS_BACKEND=direct

3.#guestfish

Welcome to guestfish, the guest filesystem shell for
editing virtual machine filesystems and disk images.

Type: 'help' for help on commands
      'man' to read the manual
      'quit' to quit the shell

><fs> trace 1
libguestfs: trace: set_trace true
libguestfs: trace: set_trace = 0
><fs> add-drive-ro-with-if /tmp/autotest-libguestfs/ide.img ide
libguestfs: trace: add_drive_ro_with_if "/tmp/autotest-libguestfs/ide.img" "ide"
libguestfs: trace: add_drive "/tmp/autotest-libguestfs/ide.img" "readonly:true" "iface:ide"
libguestfs: creating COW overlay to protect original drive content
libguestfs: trace: get_tmpdir
libguestfs: trace: get_tmpdir = "/tmp"
libguestfs: trace: disk_create "/tmp/libguestfsoU3y9U/overlay1" "qcow2" -1 "backingfile:/tmp/autotest-libguestfs/ide.img"
libguestfs: command: run: qemu-img
libguestfs: command: run: \ create
libguestfs: command: run: \ -f qcow2
libguestfs: command: run: \ -o backing_file=/tmp/autotest-libguestfs/ide.img
libguestfs: command: run: \ /tmp/libguestfsoU3y9U/overlay1
Formatting '/tmp/libguestfsoU3y9U/overlay1', fmt=qcow2 size=1073741824 backing_file='/tmp/autotest-libguestfs/ide.img' encryption=off cluster_size=65536 lazy_refcounts=off
libguestfs: trace: disk_create = 0
libguestfs: trace: add_drive = 0
libguestfs: trace: add_drive_ro_with_if = 0

><fs> run
libguestfs: trace: launch
libguestfs: trace: version
libguestfs: trace: version = <struct guestfs_version = major: 1, minor: 36, release: 6, extra: rhel=7,release=2.el7,libvirt, >
libguestfs: trace: get_backend
libguestfs: trace: get_backend = "direct"
libguestfs: launch: program=guestfish
libguestfs: launch: version=1.36.6rhel=7,release=2.el7,libvirt
libguestfs: launch: backend registered: unix
libguestfs: launch: backend registered: uml
libguestfs: launch: backend registered: libvirt
libguestfs: launch: backend registered: direct
libguestfs: launch: backend=direct
libguestfs: launch: tmpdir=/tmp/libguestfsoU3y9U
libguestfs: launch: umask=0022
libguestfs: launch: euid=0
libguestfs: trace: get_backend_setting "force_tcg"
libguestfs: trace: get_backend_setting = NULL (error)
libguestfs: trace: get_cachedir
libguestfs: trace: get_cachedir = "/var/tmp"
libguestfs: begin building supermin appliance
libguestfs: run supermin
libguestfs: command: run: /usr/bin/supermin5
libguestfs: command: run: \ --build
libguestfs: command: run: \ --verbose
libguestfs: command: run: \ --if-newer
libguestfs: command: run: \ --lock /var/tmp/.guestfs-0/lock
libguestfs: command: run: \ --copy-kernel
libguestfs: command: run: \ -f ext2
libguestfs: command: run: \ --host-cpu x86_64
libguestfs: command: run: \ /usr/lib64/guestfs/supermin.d
libguestfs: command: run: \ -o /var/tmp/.guestfs-0/appliance.d
supermin: version: 5.1.16
supermin: rpm: detected RPM version 4.11
supermin: package handler: fedora/rpm
supermin: acquiring lock on /var/tmp/.guestfs-0/lock
supermin: if-newer: output does not need rebuilding
libguestfs: finished building supermin appliance
libguestfs: begin testing qemu features
libguestfs: trace: get_cachedir
libguestfs: trace: get_cachedir = "/var/tmp"
libguestfs: checking for previously cached test results of /usr/libexec/qemu-kvm, in /var/tmp/.guestfs-0
libguestfs: loading previously cached test results
libguestfs: QMP parse error: parse error: premature EOF\n                                       \n                     (right here) ------^\n (ignored)
libguestfs: qemu version: 1.5
libguestfs: qemu mandatory locking: no
libguestfs: trace: get_sockdir
libguestfs: trace: get_sockdir = "/tmp"
libguestfs: finished testing qemu features
libguestfs: trace: get_backend_setting "gdb"
libguestfs: trace: get_backend_setting = NULL (error)
[00020ms] /usr/libexec/qemu-kvm \
    -global virtio-blk-pci.scsi=off \
    -nodefconfig \
    -enable-fips \
    -nodefaults \
    -display none \
    -machine accel=kvm:tcg \
    -cpu host \
    -m 500 \
    -no-reboot \
    -rtc driftfix=slew \
    -no-hpet \
    -global kvm-pit.lost_tick_policy=discard \
    -kernel /var/tmp/.guestfs-0/appliance.d/kernel \
    -initrd /var/tmp/.guestfs-0/appliance.d/initrd \
    -object rng-random,filename=/dev/urandom,id=rng0 \
    -device virtio-rng-pci,rng=rng0 \
    -device virtio-scsi-pci,id=scsi \
    -drive file.file.filename=/tmp/libguestfsoU3y9U/overlay1,cache=unsafe,file.driver=qcow2,id=hd0,if=ide \
    -drive file.file.filename=/tmp/libguestfsoU3y9U/overlay2,cache=unsafe,file.driver=qcow2,id=hd1,if=ide \
    -drive file=/var/tmp/.guestfs-0/appliance.d/root,snapshot=on,id=appliance,cache=unsafe,if=none,format=raw \
    -device scsi-hd,drive=appliance \
    -device virtio-serial-pci \
    -serial stdio \
    -device sga \
    -chardev socket,path=/tmp/libguestfsjAk9lf/guestfsd.sock,id=channel0 \
    -device virtserialport,chardev=channel0,name=org.libguestfs.channel.0 \
    -append 'panic=1 console=ttyS0 edd=off udevtimeout=6000 udev.event-timeout=6000 no_timer_check printk.time=1 cgroup_disable=memory usbcore.nousb cryptomgr.notests tsc=reliable 8250.nr_uarts=1 root=/dev/sdc selinux=0 guestfs_verbose=1 TERM=xterm-256color'
qemu-kvm: -drive file.file.filename=/tmp/libguestfsoU3y9U/overlay1,cache=unsafe,file.driver=qcow2,id=hd0,if=ide: could not open disk image hd0: The 'qcow2' block driver requires a file name
libguestfs: error: appliance closed the connection unexpectedly, see earlier error messages
libguestfs: child_cleanup: 0x560110f5cd00: child process died
libguestfs: sending SIGTERM to process 16944
libguestfs: error: /usr/libexec/qemu-kvm exited with error status 1, see debug messages above
libguestfs: error: guestfs_launch failed, see earlier error messages
libguestfs: trace: launch = -1 (error)


Actual results:
The run command failed.


Expected results:
The run command should be executed successfully.

Additional info:

Comment 2 Richard W.M. Jones 2017-10-18 09:53:20 UTC
FYI I wasn't able to reproduce this upstream (which surprised me
actually).

Note also this is with qemu-kvm 1.5.3.

Comment 3 Václav Kadlčík 2017-12-22 14:29:01 UTC
I think I ran into the same problem with virt-copy-out
in the upcoming RHEL 7.5.

# rpm -qa | grep libguestfs
libguestfs-1.36.10-2.el7.x86_64
libguestfs-tools-c-1.36.10-2.el7.x86_64

# export LIBGUESTFS_BACKEND=direct; export LIBGUESTFS_DEBUG=1
# virt-copy-out -a image.qcow2 /etc/hosts .

...
libguestfs: loading previously cached test results
libguestfs: QMP parse error: parse error: premature EOF\n                                       \n                     (right here) ------^\n (ignored)
libguestfs: qemu version: 1.5
libguestfs: qemu mandatory locking: no
libguestfs: finished testing qemu features
[00080ms] /usr/libexec/qemu-kvm \
    -global virtio-blk-pci.scsi=off \
    -nodefconfig \
    -enable-fips \
    -nodefaults \
    -display none \
    -machine accel=kvm:tcg \
    -cpu host \
    -m 500 \
    -no-reboot \
    -rtc driftfix=slew \
    -no-hpet \
    -global kvm-pit.lost_tick_policy=discard \
    -kernel /var/tmp/.guestfs-0/appliance.d/kernel \
    -initrd /var/tmp/.guestfs-0/appliance.d/initrd \
    -object rng-random,filename=/dev/urandom,id=rng0 \
    -device virtio-rng-pci,rng=rng0 \
    -device virtio-scsi-pci,id=scsi \
    -drive file.file.filename=/tmp/libguestfsKTphDm/overlay1.qcow2,cache=unsafe,file.driver=qcow2,id=hd0,if=none \
    -device scsi-hd,drive=hd0 \
    -drive file=/var/tmp/.guestfs-0/appliance.d/root,snapshot=on,id=appliance,cache=unsafe,if=none,format=raw \
    -device scsi-hd,drive=appliance \
    -device virtio-serial-pci \
    -serial stdio \
    -device sga \
    -chardev socket,path=/tmp/libguestfsv2xZDq/guestfsd.sock,id=channel0 \
    -device virtserialport,chardev=channel0,name=org.libguestfs.channel.0 \
    -append 'panic=1 console=ttyS0 edd=off udevtimeout=6000 udev.event-timeout=6000 no_timer_check printk.time=1 cgroup_disable=memory usbcore.nousb cryptomgr.notests tsc=reliable 8250.nr_uarts=1 root=/dev/sdb selinux=0 guestfs_verbose=1 TERM=screen'
qemu-kvm: -drive file.file.filename=/tmp/libguestfsKTphDm/overlay1.qcow2,cache=unsafe,file.driver=qcow2,id=hd0,if=none: could not open disk image hd0: The 'qcow2' block driver requires a file name
libguestfs: error: appliance closed the connection unexpectedly, see earlier error messages
...

Comment 6 YongkuiGuo 2018-01-17 05:05:54 UTC
Hi rjone,
When I used qemu-kvm-rhev-2.10.0-16.el7.x86_64 instead of qemu-kvm-1.5.3-153.el7.x86_64, I found that the error in comment0 disappeared. Maybe there are some specific patches in qemu-kvm-rhev-2.10.0-16 but not in qemu-img-1.5.3-153. Do you know the difference between the two versions?

Comment 7 Richard W.M. Jones 2018-01-17 09:50:45 UTC
The two line reproducer is:

$ qemu-img create ide.img 1G
$ guestfish backend direct : add-drive ide.img readonly:true iface:ide : run -vx

This works with qemu-kvm-rhev and fails with qemu-kvm-1.5.3-141.el7.x86_64

Comment 8 Richard W.M. Jones 2018-01-17 10:06:58 UTC
Actually the ‘iface’ parameter is NOT necessary, so the reproducer is just:

$ qemu-img create disk.qcow2 1G
$ guestfish backend direct : add-drive disk.qcow2 readonly:true : run -vx

Comment 9 Richard W.M. Jones 2018-01-17 10:25:49 UTC
Patch posted:
https://www.redhat.com/archives/libguestfs/2018-January/msg00087.html

This is actually more serious than I initially understood.  I thought
it only affected the deprecated ‘iface’ parameter, but in fact it
affects any use of qcow2 files with qemu-kvm 1.5.3, so it will affect
many users.  We therefore need to think about whether we can still put
this into RHEL 7.5 or into a z-stream.

Comment 12 YongkuiGuo 2018-01-23 11:56:09 UTC
Verified with the following packages:
libguestfs-1.36.10-6.el7.x86_64
qemu-kvm-1.5.3-153.el7.x86_64

Steps:
1.#qemu-img create disk.qcow2 1G
2.#guestfish backend direct : add-drive disk.qcow2 readonly:true : run -vx

It works fine. No error occurs. Verified this bug.

Comment 15 errata-xmlrpc 2018-04-10 09:20:40 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2018:0677


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