ae23c9
From 882087e49dc3c3286db14e7c98f3dc557a7af235 Mon Sep 17 00:00:00 2001
ae23c9
From: Kevin Wolf <kwolf@redhat.com>
ae23c9
Date: Tue, 26 Jun 2018 09:47:45 +0200
ae23c9
Subject: [PATCH 077/268] qemu-iotests: reduce chance of races in 185
ae23c9
ae23c9
RH-Author: Kevin Wolf <kwolf@redhat.com>
ae23c9
Message-id: <20180626094856.6924-3-kwolf@redhat.com>
ae23c9
Patchwork-id: 81061
ae23c9
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH v2 02/73] qemu-iotests: reduce chance of races in 185
ae23c9
Bugzilla: 1513543
ae23c9
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
ae23c9
RH-Acked-by: Max Reitz <mreitz@redhat.com>
ae23c9
RH-Acked-by: Fam Zheng <famz@redhat.com>
ae23c9
ae23c9
From: Stefan Hajnoczi <stefanha@redhat.com>
ae23c9
ae23c9
Commit 8565c3ab537e78f3e69977ec2c609dc9417a806e ("qemu-iotests: fix
ae23c9
185") identified a race condition in a sub-test.
ae23c9
ae23c9
Similar issues also affect the other sub-tests.  If disk I/O completes
ae23c9
quickly, it races with the QMP 'quit' command.  This causes spurious
ae23c9
test failures because QMP events are emitted in an unpredictable order.
ae23c9
ae23c9
This test relies on QEMU internals and there is no QMP API for getting
ae23c9
deterministic behavior needed to make this test 100% reliable.  At the
ae23c9
same time, the test is useful and it would be a shame to remove it.
ae23c9
ae23c9
Add sleep 0.5 to reduce the chance of races.  This is not a real fix but
ae23c9
appears to reduce spurious failures in practice.
ae23c9
ae23c9
Cc: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
ae23c9
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
ae23c9
Reviewed-by: Eric Blake <eblake@redhat.com>
ae23c9
Message-id: 20180508135436.30140-2-stefanha@redhat.com
ae23c9
Reviewed-by: Jeff Cody <jcody@redhat.com>
ae23c9
Signed-off-by: Jeff Cody <jcody@redhat.com>
ae23c9
(cherry picked from commit ddf2d98a94c8a98a661a217fb629cfd15f4dcec7)
ae23c9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ae23c9
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
ae23c9
---
ae23c9
 tests/qemu-iotests/185 | 12 ++++++++++++
ae23c9
 1 file changed, 12 insertions(+)
ae23c9
ae23c9
diff --git a/tests/qemu-iotests/185 b/tests/qemu-iotests/185
ae23c9
index 298d88d..975404c 100755
ae23c9
--- a/tests/qemu-iotests/185
ae23c9
+++ b/tests/qemu-iotests/185
ae23c9
@@ -118,6 +118,9 @@ _send_qemu_cmd $h \
ae23c9
                       'speed': 65536 } }" \
ae23c9
     "return"
ae23c9
 
ae23c9
+# If we don't sleep here 'quit' command races with disk I/O
ae23c9
+sleep 0.5
ae23c9
+
ae23c9
 _send_qemu_cmd $h "{ 'execute': 'quit' }" "return"
ae23c9
 wait=1 _cleanup_qemu
ae23c9
 
ae23c9
@@ -137,6 +140,9 @@ _send_qemu_cmd $h \
ae23c9
                       'speed': 65536 } }" \
ae23c9
     "return"
ae23c9
 
ae23c9
+# If we don't sleep here 'quit' command races with disk I/O
ae23c9
+sleep 0.5
ae23c9
+
ae23c9
 _send_qemu_cmd $h "{ 'execute': 'quit' }" "return"
ae23c9
 wait=1 _cleanup_qemu
ae23c9
 
ae23c9
@@ -183,6 +189,9 @@ _send_qemu_cmd $h \
ae23c9
                       'speed': 65536 } }" \
ae23c9
     "return"
ae23c9
 
ae23c9
+# If we don't sleep here 'quit' command races with disk I/O
ae23c9
+sleep 0.5
ae23c9
+
ae23c9
 _send_qemu_cmd $h "{ 'execute': 'quit' }" "return"
ae23c9
 wait=1 _cleanup_qemu
ae23c9
 
ae23c9
@@ -201,6 +210,9 @@ _send_qemu_cmd $h \
ae23c9
                       'speed': 65536 } }" \
ae23c9
     "return"
ae23c9
 
ae23c9
+# If we don't sleep here 'quit' command races with disk I/O
ae23c9
+sleep 0.5
ae23c9
+
ae23c9
 _send_qemu_cmd $h "{ 'execute': 'quit' }" "return"
ae23c9
 wait=1 _cleanup_qemu
ae23c9
 
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9