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 1010610

Summary: Backport option "--output=json|human" to qemu-img info command
Product: Red Hat Enterprise Linux 6 Reporter: Xu Tian <xutian>
Component: qemu-kvmAssignee: Paolo Bonzini <pbonzini>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: high Docs Contact:
Priority: urgent    
Version: 6.5CC: acathrow, areis, bsarathy, juzhang, mkenneth, pbonzini, qzhang, sluo, tlavigne, virt-maint
Target Milestone: rcKeywords: TestBlocker
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: qemu-kvm-0.12.1.2-2.409.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-11-21 06:02:31 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:    
Bug Blocks: 914802, 1000882    

Description Xu Tian 2013-09-22 03:11:49 UTC
Description of problem:


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

print image info to json format is support by upstream, see below commit

commit c054b3fd78f28b12f4d066583fc0ade017752479
Author: BenoƮt Canet <benoit>
Date:   Wed Sep 5 13:09:02 2012 +0200

    qemu-img: Add json output option to the info command.
    
    This option --output=[human|json] make qemu-img info output on
    human or JSON representation at the choice of the user.
    
    example:
    {
        "snapshots": [
            {
                "vm-clock-nsec": 637102488,
                "name": "vm-20120821145509",
                "date-sec": 1345553709,
                "date-nsec": 220289000,
                "vm-clock-sec": 20,
                "id": "1",
                "vm-state-size": 96522745
            },
            {
                "vm-clock-nsec": 28210866,
                "name": "vm-20120821154059",
                "date-sec": 1345556459,
                "date-nsec": 171392000,
                "vm-clock-sec": 46,
                "id": "2",
                "vm-state-size": 101208714
            }
        ],
        "virtual-size": 1073741824,
        "filename": "snap.qcow2",
        "cluster-size": 65536,
        "format": "qcow2",
        "actual-size": 985587712,
        "dirty-flag": false
    }
    
    Signed-off-by: Benoit Canet <benoit>
    Signed-off-by: Kevin Wolf <kwolf>

we need to backport it;


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 9 Xu Tian 2013-10-08 11:01:25 UTC
Verify this feature with qemu-img-0.12.1.2-2.409.el6.x86_64, all test pass
1.  check image file
qemu-img create -f qcow2 test.img 1G
Formatting 'test.img', fmt=qcow2 size=1073741824 encryption=off cluster_size=65536
qemu-img info  --output=json ./test.img
{
    "virtual-size": 1073741824,
    "filename": "./test.img",
    "cluster-size": 65536,
    "format": "qcow2",
    "actual-size": 139264,
    "dirty-flag": false
}

2. check image with internal snapshot
qemu-img snapshot -c sn1 test.img
qemu-img info  --output=json ./test.img
{
    "snapshots": [
        {
            "vm-clock-nsec": 0,
            "name": "sn1",
            "date-sec": 1381232657,
            "date-nsec": 430549000,
            "vm-clock-sec": 0,
            "id": "1",
            "vm-state-size": 0
        }
    ],
    "virtual-size": 1073741824,
    "filename": "./test.img",
    "cluster-size": 65536,
    "format": "qcow2",
    "actual-size": 151552,
    "dirty-flag": false
}

3. check image file with snapshot file 
qemu-img create  -F qcow2 -b ./test.img -f qcow2 sn1
Formatting 'sn1', fmt=qcow2 size=1073741824 backing_file='./test.img' backing_fmt='qcow2' encryption=off cluster_size=65536
qemu-img info  --output=json ./test.img
{
    "snapshots": [
        {
            "vm-clock-nsec": 0,
            "name": "sn1",
            "date-sec": 1381232657,
            "date-nsec": 430549000,
            "vm-clock-sec": 0,
            "id": "1",
            "vm-state-size": 0
        }
    ],
    "virtual-size": 1073741824,
    "filename": "./test.img",
    "cluster-size": 65536,
    "format": "qcow2",
    "actual-size": 151552,
    "dirty-flag": false
}

4. check snapshot file info
qemu-img info  --output=json ./sn1
{
    "backing-filename-format": "qcow2",
    "virtual-size": 1073741824,
    "filename": "./sn1",
    "cluster-size": 65536,
    "format": "qcow2",
    "actual-size": 200704,
    "full-backing-filename": "././test.img",
    "backing-filename": "./test.img",
    "dirty-flag": false
}

5. check converted snapshot image info 
qemu-img convert ./sn1 -f qcow2 -O raw sn1.raw
qemu-img info --output=json ./sn1.raw
{
    "virtual-size": 1073741824,
    "filename": "./sn1.raw",
    "format": "raw",
    "actual-size": 0
}

thanks,
Xu

Comment 11 errata-xmlrpc 2013-11-21 06:02:31 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.

http://rhn.redhat.com/errata/RHSA-2013-1553.html

Comment 12 Kevin Wolf 2014-03-21 09:33:26 UTC
*** Bug 999749 has been marked as a duplicate of this bug. ***