]> git.proxmox.com Git - mirror_qemu.git/commit
iotests: Let 233 run concurrently
authorMax Reitz <mreitz@redhat.com>
Wed, 8 May 2019 21:18:20 +0000 (23:18 +0200)
committerEric Blake <eblake@redhat.com>
Thu, 13 Jun 2019 13:50:47 +0000 (08:50 -0500)
commitb28f582c2acaca26b66262d75cc5a0bd2764482c
treede065be8b436fddfd26bd8e7f9e4b21441b5342e
parent4718360a58cb0a02a68d3b0e52a4711d7c398357
iotests: Let 233 run concurrently

common.nbd's nbd_server_set_tcp_port() tries to find a free port, and
then uses it for the whole test run.  However, this is racy because even
if the port was free at the beginning, there is no guarantee it will
continue to be available.  Therefore, 233 currently cannot reliably be
run concurrently with other NBD TCP tests.

This patch addresses the problem by dropping nbd_server_set_tcp_port(),
and instead finding a new port every time nbd_server_start_tcp_socket()
is invoked.  For this, we run qemu-nbd with --fork and on error evaluate
the output to see whether it contains "Address already in use".  If so,
we try the next port.

On success, we still want to continually redirect the output from
qemu-nbd to stderr.  To achieve both, we redirect qemu-nbd's stderr to a
FIFO that we then open in bash.  If the parent process exits with status
0 (which means that the server has started successfully), we launch a
background cat process that copies the FIFO to stderr.  On failure, we
read the whole content into a variable and then evaluate it.

While at it, use --fork in nbd_server_start_unix_socket(), too.  Doing
so allows us to drop nbd_server_wait_for_*_socket().

Note that the reason common.nbd did not use --fork before is that
qemu-nbd did not have --pid-file.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20190508211820.17851-6-mreitz@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
tests/qemu-iotests/233
tests/qemu-iotests/common.nbd