mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-09-06 18:05:37 +00:00
qemu-img: Flush stdout before before potential stderr messages
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>
This commit is contained in:
parent
ffa244c84a
commit
4e2f441878
1
block.c
1
block.c
|
@ -6164,6 +6164,7 @@ void bdrv_img_create(const char *filename, const char *fmt,
|
||||||
printf("Formatting '%s', fmt=%s ", filename, fmt);
|
printf("Formatting '%s', fmt=%s ", filename, fmt);
|
||||||
qemu_opts_print(opts, " ");
|
qemu_opts_print(opts, " ");
|
||||||
puts("");
|
puts("");
|
||||||
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = bdrv_create(drv, filename, opts, &local_err);
|
ret = bdrv_create(drv, filename, opts, &local_err);
|
||||||
|
|
|
@ -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
|
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 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
|
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 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
|
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 ==
|
== 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
|
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 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
|
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 ==
|
== 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
|
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 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
|
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
|
*** done
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
QA output created by 054
|
QA output created by 054
|
||||||
|
|
||||||
creating too large image (1 EB)
|
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
|
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
|
creating too large image (1 EB) using qcow2.py
|
||||||
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4294967296
|
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=4294967296
|
||||||
|
|
|
@ -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
|
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
|
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
|
*** done
|
||||||
|
|
|
@ -2,7 +2,6 @@ QA output created by 112
|
||||||
|
|
||||||
=== refcount_bits limits ===
|
=== 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
|
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
|
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
|
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
|
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
|
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
|
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
|
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
|
||||||
refcount bits: 1
|
refcount bits: 1
|
||||||
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
|
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
|
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
|
||||||
refcount bits: 16
|
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
|
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)
|
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
|
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 ===
|
=== Snapshot limit on refcount_bits=1 ===
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,6 @@ virtual size: 64 MiB (67108864 bytes)
|
||||||
disk size: unavailable
|
disk size: unavailable
|
||||||
|
|
||||||
--- Testing creation for which the node would need to grow ---
|
--- 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
|
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
|
*** done
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
QA output created by 282
|
QA output created by 282
|
||||||
== Create non-UTF8 secret ==
|
== Create non-UTF8 secret ==
|
||||||
== Throws an error because of invalid UTF-8 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
|
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 ==
|
== Image file should not exist after the error ==
|
||||||
== Create a stub image file and run qemu-img again ==
|
== 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
|
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 ==
|
== Pre-existing image file should also be deleted after the error ==
|
||||||
*** done
|
*** done
|
||||||
|
|
Loading…
Reference in a new issue