Commit 6e592fc9 authored by Stefan Hajnoczi's avatar Stefan Hajnoczi Committed by Eric Blake
Browse files

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: default avatarEric Blake <eblake@redhat.com>
Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20170829122745.14309-3-stefanha@redhat.com>
Signed-off-by: default avatarEric Blake <eblake@redhat.com>
parent 3c2d5183
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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):