]>
Commit | Line | Data |
---|---|---|
9cd4d906 AD |
1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
2 | From: Eric Blake <eblake@redhat.com> | |
3 | Date: Wed, 27 Sep 2017 17:57:23 +0200 | |
4 | Subject: [PATCH] qemu-iotests: improve nbd-fault-injector.py startup | |
5 | protocol | |
6 | ||
7 | RH-Author: Eric Blake <eblake@redhat.com> | |
8 | Message-id: <20170927175725.20023-6-eblake@redhat.com> | |
9 | Patchwork-id: 76675 | |
10 | O-Subject: [RHEV-7.4.z qemu-kvm-rhev PATCH 5/7] qemu-iotests: improve nbd-fault-injector.py startup protocol | |
11 | Bugzilla: 1495474 | |
12 | RH-Acked-by: Max Reitz <mreitz@redhat.com> | |
13 | RH-Acked-by: Jeffrey Cody <jcody@redhat.com> | |
14 | RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com> | |
15 | ||
16 | From: Stefan Hajnoczi <stefanha@redhat.com> | |
17 | ||
18 | Currently 083 waits for the nbd-fault-injector.py server to start up by | |
19 | looping until netstat shows the TCP listen socket. | |
20 | ||
21 | The startup protocol can be simplified by passing a 0 port number to | |
22 | nbd-fault-injector.py. The kernel will allocate a port in bind(2) and | |
23 | the final port number can be printed by nbd-fault-injector.py. | |
24 | ||
25 | This should make it slightly nicer and less TCP-specific to wait for | |
26 | server startup. This patch changes nbd-fault-injector.py, the next one | |
27 | will rewrite server startup in 083. | |
28 | ||
29 | Reviewed-by: Eric Blake <eblake@redhat.com> | |
30 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | |
31 | Message-Id: <20170829122745.14309-3-stefanha@redhat.com> | |
32 | Signed-off-by: Eric Blake <eblake@redhat.com> | |
33 | (cherry picked from commit 6e592fc92234a58c7156c385840633c17dedd24f) | |
34 | Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com> | |
35 | --- | |
36 | tests/qemu-iotests/nbd-fault-injector.py | 4 ++++ | |
37 | 1 file changed, 4 insertions(+) | |
38 | ||
39 | diff --git a/tests/qemu-iotests/nbd-fault-injector.py b/tests/qemu-iotests/nbd-fault-injector.py | |
40 | index 6c07191..1c10dcb 100755 | |
41 | --- a/tests/qemu-iotests/nbd-fault-injector.py | |
42 | +++ b/tests/qemu-iotests/nbd-fault-injector.py | |
43 | @@ -235,11 +235,15 @@ def open_socket(path): | |
44 | sock = socket.socket() | |
45 | sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) | |
46 | sock.bind((host, int(port))) | |
47 | + | |
48 | + # If given port was 0 the final port number is now available | |
49 | + path = '%s:%d' % sock.getsockname() | |
50 | else: | |
51 | sock = socket.socket(socket.AF_UNIX) | |
52 | sock.bind(path) | |
53 | sock.listen(0) | |
54 | print 'Listening on %s' % path | |
55 | + sys.stdout.flush() # another process may be waiting, show message now | |
56 | return sock | |
57 | ||
58 | def usage(args): | |
59 | -- | |
60 | 1.8.3.1 | |
61 |