Bug 747287

Summary: Misleading error message when permission denied opening a disk image
Product: [Community] Virtualization Tools Reporter: Richard W.M. Jones <rjones>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED UPSTREAM QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: mbooth, virt-maint
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-10-21 15:31:58 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Richard W.M. Jones 2011-10-19 11:19:59 UTC
Description of problem:

When you try to add a disk image which is read-only, qemu
fails to start up and qemu correctly prints an error message.
However the error message is eaten by libguestfs, and instead
we see this error:

  $ guestfish -a test1.img run : list-devices
  libguestfs: error: unexpected end of file when reading from daemon.
  This usually means the libguestfs appliance failed to start up.  Please
  enable debugging (LIBGUESTFS_DEBUG=1) and rerun the command, then look at
  the debug messages output prior to this error.
  Or you can run 'libguestfs-test-tool' and post the complete output into
  a bug report or message to the libguestfs mailing list.

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

1.13.21

How reproducible:

100%

Steps to Reproduce:

  rm test1.img
  truncate -s 1G test1.img
  sudo chown root.root test1.img
  sudo chmod 0444 test1.img

Now compare opening this test image with and without --ro flag:

$ guestfish -a test1.img --ro run : list-devices
/dev/vda

$ guestfish -a test1.img run : list-devices
libguestfs: error: unexpected end of file when reading from daemon.
This usually means the libguestfs appliance failed to start up.  Please
enable debugging (LIBGUESTFS_DEBUG=1) and rerun the command, then look at
the debug messages output prior to this error.
Or you can run 'libguestfs-test-tool' and post the complete output into
a bug report or message to the libguestfs mailing list.

Adding -v or setting LIBGUESTFS_DEBUG=1 shows the real
error message, although the output is a bit messed up:

[...]
    -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.28300,snapshot=on,if=virtio,cache=unsafeqemu-kvm: -drive file=test1.img,cache=off,if=virtio: could not open disk image test1.img: Permission denied
  
Actual results:

Confusing error message.

Expected results:

Should capture and show the qemu error message.

Additional info: