diff options
author | Stefan Hajnoczi | 2017-08-29 14:27:44 +0200 |
---|---|---|
committer | Eric Blake | 2017-08-30 20:00:37 +0200 |
commit | 6e592fc92234a58c7156c385840633c17dedd24f (patch) | |
tree | 8607bdac5d5cd3ff46b465e74af74eb39052c257 | |
parent | nbd-client: avoid read_reply_co entry if send failed (diff) | |
download | qemu-6e592fc92234a58c7156c385840633c17dedd24f.tar.gz qemu-6e592fc92234a58c7156c385840633c17dedd24f.tar.xz qemu-6e592fc92234a58c7156c385840633c17dedd24f.zip |
qemu-iotests: improve nbd-fault-injector.py startup protocol
Currently 083 waits for the nbd-fault-injector.py server to start up by
looping until netstat shows the TCP listen socket.
The startup protocol can be simplified by passing a 0 port number to
nbd-fault-injector.py. The kernel will allocate a port in bind(2) and
the final port number can be printed by nbd-fault-injector.py.
This should make it slightly nicer and less TCP-specific to wait for
server startup. This patch changes nbd-fault-injector.py, the next one
will rewrite server startup in 083.
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20170829122745.14309-3-stefanha@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
-rwxr-xr-x | tests/qemu-iotests/nbd-fault-injector.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/qemu-iotests/nbd-fault-injector.py b/tests/qemu-iotests/nbd-fault-injector.py index 6c07191a5a..1c10dcb51c 100755 --- a/tests/qemu-iotests/nbd-fault-injector.py +++ b/tests/qemu-iotests/nbd-fault-injector.py @@ -235,11 +235,15 @@ def open_socket(path): sock = socket.socket() sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.bind((host, int(port))) + + # If given port was 0 the final port number is now available + path = '%s:%d' % sock.getsockname() else: sock = socket.socket(socket.AF_UNIX) sock.bind(path) sock.listen(0) print 'Listening on %s' % path + sys.stdout.flush() # another process may be waiting, show message now return sock def usage(args): |