Skip to contentSkip to conversation

qemu-img: Report error even with --oformat=json

PATCH Applied Markus Armbruster 2 participants 2 messages Jun 2, 2014 1 message not in the archive

lore
Share & tools
lore

Markus Armbruster

author Reviewed-by
#1 lore raw
In reply to a message not in the archive
Quoted 25 lines · Max Reitz

img_check() should report that the format of the given image does not support checks even if JSON output is desired. JSON data is output to stdout, as opposed to error messages, which are (in the case of qemu-img) printed to stderr. Therefore, it is easy to distinguish between the two.

Also, img_info() does already use error_report() for human-readable messages even though JSON output is desired (through collect_image_info_list()).

---
As the old code deliberately emitted the error only in case of human-readable output, I asked Federico, the original author, for his opinion in https://bugzilla.redhat.com/show_bug.cgi?id=1054753, but did not receive a reply so far.

---
 qemu-img.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
qemu-img.c +0 -0
index d118da5..b3d2bc6 100644

qemu-img.c static int img_check(int argc, char **argv) · line 667

Quoted 8 lines
qemu-img.c +1 -3
@@ -663,9 +663,7 @@ static int img_check(int argc, char **argv)
     ret = collect_image_check(bs, check, filename, fmt, fix);
 
     if (ret == -ENOTSUP) {
-        if (output_format == OFORMAT_HUMAN) {
-            error_report("This image format does not support checks");
-        }
+        error_report("This image format does not support checks");
         ret = 63;

Undocumented return code. Care to fix that, too?

qemu-img.c static int img_check(int argc, char **argv) · line 669

Quoted 2 lines
qemu-img.c +0 -0
         goto fail;
     }
Applied
#2 lore raw
In reply to a message not in the archive

Am 31.05.2014 um 21:33 hat Max Reitz geschrieben:

Quoted 11 lines

img_check() should report that the format of the given image does not support checks even if JSON output is desired. JSON data is output to stdout, as opposed to error messages, which are (in the case of qemu-img) printed to stderr. Therefore, it is easy to distinguish between the two.

Also, img_info() does already use error_report() for human-readable messages even though JSON output is desired (through collect_image_info_list()).

Thanks, applied to the block branch.

Kevin