tests/nbd: Move wait for qemu-nbd to start up earlier.

tests/nbd/test-nbd.pl contains a hack (a call to sleep) to wait
for qemu-nbd to start up in another process.

This sleep was previously located before the call to $g->launch()
since that is where (previous to commit 4a0f5ed382) the backend would
have connected to the NBD server.

However in the new code, an initial NBD connection test is done when
the drive is added (ie. $g->add_drive (..., protocol=>"nbd")), which
duly failed intermittently because the qemu-nbd server had not opened
its socket yet.

Move the wait earlier -- just after the fork -- to avoid this.

This updates commit 4a0f5ed382.
This commit is contained in:
Richard W.M. Jones
2014-01-18 14:20:43 +00:00
parent b6ff642168
commit 3858eeb517

View File

@@ -74,17 +74,17 @@ sub run_test {
die "qemu-nbd: $!";
}
# XXX qemu-nbd lacks any way to tell if it is awake and listening
# for connections. It could write a pid file or something. Could
# we check that the socket has been opened by looking in netstat?
sleep (2);
my $g = Sys::Guestfs->new ();
# Add an NBD drive.
$g->add_drive ("", readonly => $readonly, format => "raw",
protocol => "nbd", server => [$server]);
# XXX qemu-nbd lacks any way to tell if it is awake and listening
# for connections. It could write a pid file or something. Could
# we check that the socket has been opened by looking in netstat?
sleep (2);
# This dies if qemu cannot connect to the NBD server.
$g->launch ();