Blame SOURCES/kvm-qemu-iotests-improve-nbd-fault-injector.py-startup-p.patch

4a2fec
From 2f7ffaddd0a233a233125320b6595a091c19c18f Mon Sep 17 00:00:00 2001
4a2fec
From: Eric Blake <eblake@redhat.com>
4a2fec
Date: Fri, 6 Oct 2017 19:24:07 +0200
4a2fec
Subject: [PATCH 15/34] qemu-iotests: improve nbd-fault-injector.py startup
4a2fec
 protocol
4a2fec
4a2fec
RH-Author: Eric Blake <eblake@redhat.com>
4a2fec
Message-id: <20171006192409.29915-3-eblake@redhat.com>
4a2fec
Patchwork-id: 76914
4a2fec
O-Subject: [RHEV-7.5 qemu-kvm-rhev PATCH 2/4] qemu-iotests: improve nbd-fault-injector.py startup protocol
4a2fec
Bugzilla: 1482478
4a2fec
RH-Acked-by: Max Reitz <mreitz@redhat.com>
4a2fec
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
4a2fec
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
4a2fec
From: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
4a2fec
Currently 083 waits for the nbd-fault-injector.py server to start up by
4a2fec
looping until netstat shows the TCP listen socket.
4a2fec
4a2fec
The startup protocol can be simplified by passing a 0 port number to
4a2fec
nbd-fault-injector.py.  The kernel will allocate a port in bind(2) and
4a2fec
the final port number can be printed by nbd-fault-injector.py.
4a2fec
4a2fec
This should make it slightly nicer and less TCP-specific to wait for
4a2fec
server startup.  This patch changes nbd-fault-injector.py, the next one
4a2fec
will rewrite server startup in 083.
4a2fec
4a2fec
Reviewed-by: Eric Blake <eblake@redhat.com>
4a2fec
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
4a2fec
Message-Id: <20170829122745.14309-3-stefanha@redhat.com>
4a2fec
Signed-off-by: Eric Blake <eblake@redhat.com>
4a2fec
(cherry picked from commit 6e592fc92234a58c7156c385840633c17dedd24f)
4a2fec
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
---
4a2fec
 tests/qemu-iotests/nbd-fault-injector.py | 4 ++++
4a2fec
 1 file changed, 4 insertions(+)
4a2fec
4a2fec
diff --git a/tests/qemu-iotests/nbd-fault-injector.py b/tests/qemu-iotests/nbd-fault-injector.py
4a2fec
index 6c07191..1c10dcb 100755
4a2fec
--- a/tests/qemu-iotests/nbd-fault-injector.py
4a2fec
+++ b/tests/qemu-iotests/nbd-fault-injector.py
4a2fec
@@ -235,11 +235,15 @@ def open_socket(path):
4a2fec
         sock = socket.socket()
4a2fec
         sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
4a2fec
         sock.bind((host, int(port)))
4a2fec
+
4a2fec
+        # If given port was 0 the final port number is now available
4a2fec
+        path = '%s:%d' % sock.getsockname()
4a2fec
     else:
4a2fec
         sock = socket.socket(socket.AF_UNIX)
4a2fec
         sock.bind(path)
4a2fec
     sock.listen(0)
4a2fec
     print 'Listening on %s' % path
4a2fec
+    sys.stdout.flush() # another process may be waiting, show message now
4a2fec
     return sock
4a2fec
 
4a2fec
 def usage(args):
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec