Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1379930

Summary: image exported by qemu-nbd couldn't get right 'file format'
Product: Red Hat Enterprise Linux 7 Reporter: Han Han <hhan>
Component: qemu-kvm-rhevAssignee: Virtualization Maintenance <virt-maint>
Status: CLOSED NOTABUG QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.3CC: amit.shah, berrange, cfergeau, chayang, dwmw2, dyuan, extras-qa, itamar, juzhang, pbonzini, pingl, rjones, virt-maint, virt-maint, xuzhang
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1379929 Environment:
Last Closed: 2016-09-28 09:07:40 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:
Bug Depends On: 1379929    
Bug Blocks:    

Description Han Han 2016-09-28 07:20:46 UTC
The  bug is also reproduced on qemu-kvm-rhev-2.6.0-27.el7.x86_64.
+++ This bug was initially created as a clone of Bug #1379929 +++

Description of problem:
As subject

Version-Release number of selected component (if applicable):
nbdkit-1.1.12-1.fc25.x86_64
qemu-img-2.7.0-1.fc26.x86_64


How reproducible:
100%

Steps to Reproduce:
1. Create a qcow2 image:
# qemu-img create /tmp/xx.qcow2 -f qcow2 100M
Formatting '/tmp/xx.qcow2', fmt=qcow2 size=104857600 encryption=off cluster_size=65536 lazy_refcounts=off refcount_bits=16

Export by qemu-nbd:
# qemu-nbd -t -p 30001 --format=qcow2 /tmp/xx.qcow2

2. Check the image local and via nbd
# qemu-img info /tmp/xx.qcow2
image: /tmp/xx.qcow2
file format: qcow2
virtual size: 100M (104857600 bytes)
disk size: 196K
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false

#  qemu-img info nbd://localhost:30001
image: nbd://localhost:30001
file format: raw
virtual size: 100M (104857600 bytes)
disk size: unavailable

Actual results:
As step2

Expected results:
qemu-img info via nbd get right result.

Additional info:
Try to do above steps with nbdkit and the result is right.
# nbdkit -p 30000 file file=/tmp/xx.qcow2
# qemu-img info nbd://localhost:30000
image: nbd://localhost:30000
file format: qcow2
virtual size: 100M (104857600 bytes)
disk size: unavailable
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false

Comment 2 Daniel Berrangé 2016-09-28 09:07:40 UTC
When you ran 'qemu-nbd' you gave it a --format=qcow2 argument, so it is exporting the *contents* of the qcow2 image, ie a *raw* volume.  So the qemu-img info command is correct in reporting that it is raw.

Comment 3 Han Han 2016-09-28 09:53:14 UTC
(In reply to Daniel Berrange from comment #2)
> When you ran 'qemu-nbd' you gave it a --format=qcow2 argument, so it is
> exporting the *contents* of the qcow2 image, ie a *raw* volume.  So the
> qemu-img info command is correct in reporting that it is raw.

I try to use 'qemu-nbd -t -p 30001 --format=raw' and get qcow2 format when using qemu-img info. Well, for the issue in comment0, it is not a bug.

But the manual of qemu-nbd is confusing:
-f, --format=fmt
           Force the use of the block driver for format fmt instead of auto-detecting
I couldn't get the info of 'exporting the *contents* of the qcow2 image'. Maybe we should improve the manual page and give some examples.

Comment 4 Daniel Berrangé 2016-09-28 09:54:34 UTC
I don't think there's anything that needs fixing here, this behaviour is consistent with elsewhere.