qemu-iotests/109: Fix lock race condition
commit53dd4015acb48bad5aee5ba707848370dc442077
authorCleber Rosa <crosa@redhat.com>
Tue, 1 Aug 2017 21:31:27 +0000 (1 17:31 -0400)
committerKevin Wolf <kwolf@redhat.com>
Tue, 8 Aug 2017 12:36:59 +0000 (8 14:36 +0200)
treeb43684c4705a5bc6e32014349f4005cb724911bd
parentb4174c4b08a719e7df7e4f35c29f44b7c2517237
qemu-iotests/109: Fix lock race condition

A race condition is currently present between the clean up attempt of
the QEMU process and the execution of qemu-img.  The actual (bad)
output is:

 -Warning: Image size mismatch!
 -Images are identical.
 +qemu-img: Could not open '<build_dir>/tests/qemu-iotests/scratch/t.raw': Failed to get "consistent read" lock
 +Is another process using the image?

A KILL signal is sent to the QEMU process, but qemu-img may begin to
run before the QEMU process is really gone.  qemu-img will then
attempt to open the TEST_IMG file before it can secure a lock on it.

This attempts a more graceful shutdown, and waits for the QEMU process
to exit.

Signed-off-by: Cleber Rosa <crosa@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Jeff Cody <jcody@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
tests/qemu-iotests/109
tests/qemu-iotests/109.out