Red Hat Bugzilla – Bug 1010610
Backport option "--output=json|human" to qemu-img info command
Last modified: 2014-03-21 05:33:26 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:
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
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
*** Bug 999749 has been marked as a duplicate of this bug. ***