iotests: add qemu_img_json()
commit29768d04afe5c87272e8fb7de1290f7a4f530785
authorJohn Snow <jsnow@redhat.com>
Mon, 21 Mar 2022 20:16:06 +0000 (21 16:16 -0400)
committerHanna Reitz <hreitz@redhat.com>
Tue, 22 Mar 2022 09:14:28 +0000 (22 10:14 +0100)
tree2bf8cadeea979a8c3fed38e0596fda55f7c0bee8
parent569131d585efb9a2fe9188c0edd12d22619afaca
iotests: add qemu_img_json()

qemu_img_json() is a new helper built on top of qemu_img() that tries to
pull a valid JSON document out of the stdout stream.

In the event that the return code is negative (the program crashed), or
the code is greater than zero and did not produce valid JSON output, the
VerboseProcessError raised by qemu_img() is re-raised.

In the event that the return code is zero but we can't parse valid JSON,
allow the JSON deserialization error to be raised.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20220321201618.903471-7-jsnow@redhat.com>
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
tests/qemu-iotests/iotests.py