Bug 1010610 - Backport option "--output=json|human" to qemu-img info command
Backport option "--output=json|human" to qemu-img info command
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: qemu-kvm (Show other bugs)
6.5
Unspecified Unspecified
urgent Severity high
: rc
: ---
Assigned To: Paolo Bonzini
Virtualization Bugs
: TestBlocker
: 999749 (view as bug list)
Depends On:
Blocks: 914802 1000882
  Show dependency treegraph
 
Reported: 2013-09-21 23:11 EDT by xu
Modified: 2014-03-21 05:33 EDT (History)
10 users (show)

See Also:
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 01:02:31 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description xu 2013-09-21 23:11:49 EDT
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@irqsave.net>
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@irqsave.net>
    Signed-off-by: Kevin Wolf <kwolf@redhat.com>

we need to backport it;


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:
Comment 9 xu 2013-10-08 07:01:25 EDT
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 01:02:31 EST
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 05:33:26 EDT
*** Bug 999749 has been marked as a duplicate of this bug. ***

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