* [Qemu-devel] [PATCH for-2.12] qemu-iotests: Fix locking issue in 102
@ 2017-11-29 18:51 Max Reitz
2017-11-29 21:22 ` Eric Blake
2018-01-17 13:29 ` Max Reitz
0 siblings, 2 replies; 3+ messages in thread
From: Max Reitz @ 2017-11-29 18:51 UTC (permalink / raw)
To: qemu-block; +Cc: qemu-devel, Max Reitz, Kevin Wolf
102 truncates a qcow2 file (the raw file) on purpose while a VM is
running. However, image locking will usually prevent exactly this.
The fact that most people have not noticed until now (I suppose you may
have seen sporadic failures, but not taken them too seriously, like me)
further shows that this truncation is actually not really done
concurrently, but that the VM is still starting up by this point and has
not yet opened the image. Remedy this by waiting for the monitor shell
to appear before the qemu-img invocation so we know the VM is up.
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
tests/qemu-iotests/102 | 7 ++++++-
tests/qemu-iotests/102.out | 3 ++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/tests/qemu-iotests/102 b/tests/qemu-iotests/102
index d7ad8d9840..04b3f28445 100755
--- a/tests/qemu-iotests/102
+++ b/tests/qemu-iotests/102
@@ -69,7 +69,12 @@ $QEMU_IO -c 'write 0 64k' "$TEST_IMG" | _filter_qemu_io
qemu_comm_method=monitor _launch_qemu -drive if=none,file="$TEST_IMG",id=drv0
-$QEMU_IMG resize -f raw --shrink "$TEST_IMG" $((5 * 64 * 1024))
+# Wait for a prompt to appear (so we know qemu has opened the image)
+_send_qemu_cmd '' '(qemu)'
+
+$QEMU_IMG resize --shrink --image-opts \
+ "driver=raw,file.driver=file,file.filename=$TEST_IMG,file.locking=off" \
+ $((5 * 64 * 1024))
_send_qemu_cmd $QEMU_HANDLE 'qemu-io drv0 map' 'allocated' \
| sed -e 's/^(qemu).*qemu-io drv0 map...$/(qemu) qemu-io drv0 map/'
diff --git a/tests/qemu-iotests/102.out b/tests/qemu-iotests/102.out
index ccf172abd9..4401b08fee 100644
--- a/tests/qemu-iotests/102.out
+++ b/tests/qemu-iotests/102.out
@@ -14,8 +14,9 @@ Offset Length Mapped to File
Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=65536
wrote 65536/65536 bytes at offset 0
64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-Image resized.
QEMU X.Y.Z monitor - type 'help' for more information
+Image resized.
+(qemu)
(qemu) qemu-io drv0 map
64 KiB (0x10000) bytes allocated at offset 0 bytes (0x0)
*** done
--
2.13.6
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH for-2.12] qemu-iotests: Fix locking issue in 102
2017-11-29 18:51 [Qemu-devel] [PATCH for-2.12] qemu-iotests: Fix locking issue in 102 Max Reitz
@ 2017-11-29 21:22 ` Eric Blake
2018-01-17 13:29 ` Max Reitz
1 sibling, 0 replies; 3+ messages in thread
From: Eric Blake @ 2017-11-29 21:22 UTC (permalink / raw)
To: Max Reitz, qemu-block; +Cc: Kevin Wolf, qemu-devel
On 11/29/2017 12:51 PM, Max Reitz wrote:
> 102 truncates a qcow2 file (the raw file) on purpose while a VM is
> running. However, image locking will usually prevent exactly this.
>
> The fact that most people have not noticed until now (I suppose you may
> have seen sporadic failures, but not taken them too seriously, like me)
> further shows that this truncation is actually not really done
> concurrently, but that the VM is still starting up by this point and has
> not yet opened the image. Remedy this by waiting for the monitor shell
> to appear before the qemu-img invocation so we know the VM is up.
>
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
> tests/qemu-iotests/102 | 7 ++++++-
> tests/qemu-iotests/102.out | 3 ++-
> 2 files changed, 8 insertions(+), 2 deletions(-)
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH for-2.12] qemu-iotests: Fix locking issue in 102
2017-11-29 18:51 [Qemu-devel] [PATCH for-2.12] qemu-iotests: Fix locking issue in 102 Max Reitz
2017-11-29 21:22 ` Eric Blake
@ 2018-01-17 13:29 ` Max Reitz
1 sibling, 0 replies; 3+ messages in thread
From: Max Reitz @ 2018-01-17 13:29 UTC (permalink / raw)
To: qemu-block; +Cc: qemu-devel, Kevin Wolf
[-- Attachment #1: Type: text/plain, Size: 854 bytes --]
On 2017-11-29 19:51, Max Reitz wrote:
> 102 truncates a qcow2 file (the raw file) on purpose while a VM is
> running. However, image locking will usually prevent exactly this.
>
> The fact that most people have not noticed until now (I suppose you may
> have seen sporadic failures, but not taken them too seriously, like me)
> further shows that this truncation is actually not really done
> concurrently, but that the VM is still starting up by this point and has
> not yet opened the image. Remedy this by waiting for the monitor shell
> to appear before the qemu-img invocation so we know the VM is up.
>
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
> tests/qemu-iotests/102 | 7 ++++++-
> tests/qemu-iotests/102.out | 3 ++-
> 2 files changed, 8 insertions(+), 2 deletions(-)
Applied to my block branch.
Max
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 512 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-01-17 13:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-29 18:51 [Qemu-devel] [PATCH for-2.12] qemu-iotests: Fix locking issue in 102 Max Reitz
2017-11-29 21:22 ` Eric Blake
2018-01-17 13:29 ` Max Reitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).