]> git.proxmox.com Git - mirror_qemu.git/commitdiff
qemu-img: Flush stdout before before potential stderr messages
authorEric Blake <eblake@redhat.com>
Mon, 6 Jul 2020 20:39:45 +0000 (15:39 -0500)
committerKevin Wolf <kwolf@redhat.com>
Tue, 14 Jul 2020 13:18:59 +0000 (15:18 +0200)
During 'qemu-img create ... 2>&1', if --quiet is not in force, we can
end up with buffered I/O in stdout that was produced before failure,
but which appears in output after failure.  This is confusing; the fix
is to flush stdout prior to attempting anything that might produce an
error message.  Several iotests demonstrate the resulting ordering
change now that the merged outputs now reflect chronology.  (An even
better fix would be to avoid printf from within block.c altogether,
but that's much more invasive...)

Signed-off-by: Eric Blake <eblake@redhat.com>
Message-Id: <20200706203954.341758-2-eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block.c
tests/qemu-iotests/049.out
tests/qemu-iotests/054.out
tests/qemu-iotests/079.out
tests/qemu-iotests/112.out
tests/qemu-iotests/259.out
tests/qemu-iotests/282.out

diff --git a/block.c b/block.c
index 3031413debe62ec243528402f91377e8d48d503b..98cad57cda683ca7185e1c09687836fe805e0aac 100644 (file)
--- a/block.c
+++ b/block.c
@@ -6164,6 +6164,7 @@ void bdrv_img_create(const char *filename, const char *fmt,
         printf("Formatting '%s', fmt=%s ", filename, fmt);
         qemu_opts_print(opts, " ");
         puts("");
+        fflush(stdout);
     }
 
     ret = bdrv_create(drv, filename, opts, &local_err);
index e77966446bb152404a18ee76a066b7bb4116b216..4c21dc70a5787f29ea7084b599ef937d19314c3f 100644 (file)
@@ -167,12 +167,12 @@ qemu-img create -f qcow2 -o compat=1.1 TEST_DIR/t.qcow2 64M
 Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=67108864 compat=1.1 lazy_refcounts=off refcount_bits=16
 
 qemu-img create -f qcow2 -o compat=0.42 TEST_DIR/t.qcow2 64M
-qemu-img: TEST_DIR/t.qcow2: Invalid parameter '0.42'
 Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=67108864 compat=0.42 lazy_refcounts=off refcount_bits=16
+qemu-img: TEST_DIR/t.qcow2: Invalid parameter '0.42'
 
 qemu-img create -f qcow2 -o compat=foobar TEST_DIR/t.qcow2 64M
-qemu-img: TEST_DIR/t.qcow2: Invalid parameter 'foobar'
 Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=67108864 compat=foobar lazy_refcounts=off refcount_bits=16
+qemu-img: TEST_DIR/t.qcow2: Invalid parameter 'foobar'
 
 == Check preallocation option ==
 
@@ -183,8 +183,8 @@ qemu-img create -f qcow2 -o preallocation=metadata TEST_DIR/t.qcow2 64M
 Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 preallocation=metadata compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
 
 qemu-img create -f qcow2 -o preallocation=1234 TEST_DIR/t.qcow2 64M
-qemu-img: TEST_DIR/t.qcow2: Invalid parameter '1234'
 Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 preallocation=1234 compression_type=zlib size=67108864 lazy_refcounts=off refcount_bits=16
+qemu-img: TEST_DIR/t.qcow2: Invalid parameter '1234'
 
 == Check encryption option ==
 
@@ -206,7 +206,7 @@ qemu-img create -f qcow2 -o compat=0.10,lazy_refcounts=off TEST_DIR/t.qcow2 64M
 Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=67108864 compat=0.10 lazy_refcounts=off refcount_bits=16
 
 qemu-img create -f qcow2 -o compat=0.10,lazy_refcounts=on TEST_DIR/t.qcow2 64M
-qemu-img: TEST_DIR/t.qcow2: Lazy refcounts only supported with compatibility level 1.1 and above (use version=v3 or greater)
 Formatting 'TEST_DIR/t.qcow2', fmt=qcow2 cluster_size=65536 compression_type=zlib size=67108864 compat=0.10 lazy_refcounts=on refcount_bits=16
+qemu-img: TEST_DIR/t.qcow2: Lazy refcounts only supported with compatibility level 1.1 and above (use version=v3 or greater)
 
 *** done
index e6ec430edd4771759fab14377542f9acbbe0e47d..71f18bb9876001533d5e847a814f34ac31ae2023 100644 (file)
@@ -1,8 +1,8 @@
 QA output created by 054
 
 creating too large image (1 EB)
-qemu-img: TEST_DIR/t.IMGFMT: The image size is too large for file format 'IMGFMT' (try using a larger cluster size)
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1152921504606846976
+qemu-img: TEST_DIR/t.IMGFMT: The image size is too large for file format 'IMGFMT' (try using a larger cluster size)
 
 creating too large image (1 EB) using qcow2.py
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4294967296
index aab922fb369b6007a4ce1113079d439e324eed06..f65a9ca84feac8a21efebcfe42d8ecaafca7e93a 100644 (file)
@@ -9,6 +9,6 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4294967296 preallocation=metadat
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4294967296 preallocation=metadata
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4294967296 preallocation=metadata
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4294967296 preallocation=metadata
-qemu-img: TEST_DIR/t.IMGFMT: Cluster size must be a power of two between 512 and 2048k
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4294967296 preallocation=metadata
+qemu-img: TEST_DIR/t.IMGFMT: Cluster size must be a power of two between 512 and 2048k
 *** done
index 182655dbf67f9a384c8ac3a6c7fe4f0d4fdbed3d..dd3cc4383c12898b179954be6fd3d7e717614968 100644 (file)
@@ -2,7 +2,6 @@ QA output created by 112
 
 === refcount_bits limits ===
 
-qemu-img: TEST_DIR/t.IMGFMT: Refcount width must be a power of two and may not exceed 64 bits
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 qemu-img: TEST_DIR/t.IMGFMT: Refcount width must be a power of two and may not exceed 64 bits
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
@@ -10,6 +9,7 @@ qemu-img: TEST_DIR/t.IMGFMT: Refcount width must be a power of two and may not e
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 qemu-img: TEST_DIR/t.IMGFMT: Refcount width must be a power of two and may not exceed 64 bits
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
+qemu-img: TEST_DIR/t.IMGFMT: Refcount width must be a power of two and may not exceed 64 bits
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 refcount bits: 1
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
@@ -21,10 +21,10 @@ refcount bits: 16
 
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 refcount bits: 16
-qemu-img: TEST_DIR/t.IMGFMT: Different refcount widths than 16 bits require compatibility level 1.1 or above (use version=v3 or greater)
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
 qemu-img: TEST_DIR/t.IMGFMT: Different refcount widths than 16 bits require compatibility level 1.1 or above (use version=v3 or greater)
 Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
+qemu-img: TEST_DIR/t.IMGFMT: Different refcount widths than 16 bits require compatibility level 1.1 or above (use version=v3 or greater)
 
 === Snapshot limit on refcount_bits=1 ===
 
index ffed19c2a0af4a484bd110f3ac17b5258a25604d..e27b9ff38d7567a0cb3fc51c562f8da9fe965605 100644 (file)
@@ -9,6 +9,6 @@ virtual size: 64 MiB (67108864 bytes)
 disk size: unavailable
 
 --- Testing creation for which the node would need to grow ---
-qemu-img: TEST_DIR/t.IMGFMT: Could not resize image: Image format driver does not support resize
 Formatting 'TEST_DIR/t.IMGFMT', fmt=qcow2 size=67108864 preallocation=metadata
+qemu-img: TEST_DIR/t.IMGFMT: Could not resize image: Image format driver does not support resize
 *** done
index 5d079dabce1dfd4a9f9ae7043184eae379132ad0..67db7ab15affae3789b5afdc2d190c7eadcdae2c 100644 (file)
@@ -1,11 +1,11 @@
 QA output created by 282
 == Create non-UTF8 secret ==
 == Throws an error because of invalid UTF-8 secret ==
-qemu-img: vol.img: Data from secret sec0 is not valid UTF-8
 Formatting 'vol.img', fmt=luks size=4194304 key-secret=sec0
+qemu-img: vol.img: Data from secret sec0 is not valid UTF-8
 == Image file should not exist after the error ==
 == Create a stub image file and run qemu-img again ==
-qemu-img: vol.img: Data from secret sec0 is not valid UTF-8
 Formatting 'vol.img', fmt=luks size=4194304 key-secret=sec0
+qemu-img: vol.img: Data from secret sec0 is not valid UTF-8
 == Pre-existing image file should also be deleted after the error ==
- *** done
+*** done