Bug 1406981

Summary: guestfish failed to launch nbd qcow2 image with --format=qcow2
Product: Red Hat Enterprise Linux 7 Reporter: Xianghua Chen <xchen>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED NOTABUG QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.4CC: ptoscano, wshi
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-12-22 11:59:21 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
log.nbd-qcow2 none

Description Xianghua Chen 2016-12-22 01:30:26 UTC
Created attachment 1234583 [details]
log.nbd-qcow2

Description of problem:
guestfish failed to launch nbd qcow2 image with --format=qcow2

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

How reproducible:
100%

Steps:
1. Prepare a nbd server on fedora: 10.66.9.95
# modprobe nbd

Prepare a qcow2 guest image:
$ qemu-img info RHEL-Server-7.2-64-hvm.qcow2
image: RHEL-Server-7.2-64-hvm.qcow2
file format: qcow2
virtual size: 8.0G (8589934592 bytes)
disk size: 2.2G
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false

$ qemu-nbd RHEL-Server-7.2-64-hvm.qcow2 -t

2. On rhel7 client:
# guestfish -a nbd://10.66.9.95 -i
libguestfs: error: could not auto-detect the format when using a non-file protocol.
If the format is known, pass the format to libguestfs, eg. using the
'--format' option, or via the optional 'format' argument to 'add-drive'.


# guestfish --format=qcow2 -a nbd://10.66.9.95 -i -v -x
... ...
ibguestfs: error: could not create appliance through libvirt.
Try running qemu directly without libvirt using this environment variable:
export LIBGUESTFS_BACKEND=direct
Original error from libvirt: internal error: process exited while connecting to monitor: 2016-12-21T08:25:14.437395Z qemu-kvm: -drive file=nbd:10.66.9.95:10809,format=qcow2,if=none,id=drive-scsi0-0-0-0,cache=writeback: could not open disk image nbd:10.66.9.95:10809: Image is not in qcow2 format [code=1 int1=-1]
libguestfs: clear_socket_create_context: setsockcreatecon failed: NULL: Invalid argument [you can ignore this message if you are not using SELinux + sVirt]
libguestfs: trace: launch = -1 (error)



If I use --format=raw it'll be ok:
# guestfish --format=raw -a nbd://10.66.9.95 -i


Please check the -v -x log in attachment.



Actual results:
The first 2 command in step2 all failed.

Expected results:
The guestfish with --format=qcow2 or with no --format should all work.
The guestfish with --format=raw should not work.


Additional info:
# qemu-img info nbd://10.66.9.95
image:
file format: raw
virtual size: 8.0G (8589934592 bytes)
disk size: unavailable

Seems like qemu's problem?
But libguestfs should detect it without using --format or have other workaround for this.

Comment 1 Richard W.M. Jones 2016-12-22 11:59:21 UTC
This is correct and not a bug.  The qemu-nbd process opens the
qcow2 file and serves it as a raw file.  On the client side (libguestfs)
you therefore have to access it as raw.