diff mbox series

[2/3] iotests: Bind qemu-nbd to localhost in 147

Message ID 20181221234750.23577-3-mreitz@redhat.com
State New
Headers show
Series iotests: Allow 147 to be run concurrently | expand

Commit Message

Max Reitz Dec. 21, 2018, 11:47 p.m. UTC
By default, qemu-nbd binds to 0.0.0.0.  However, we then proceed to
connect to "localhost".  Usually, this works out fine; but if this test
is run concurrently, some other test function may have bound a different
server to ::1 (on the same port -- you can bind different serves to the
same port, as long as one is on IPv4 and the other on IPv6).

So running qemu-nbd works, it can bind to 0.0.0.0:NBD_PORT.  But
potentially a concurrent test has successfully taken [::1]:NBD_PORT.  In
this case, trying to connect to "localhost" will lead us to the IPv6
instance, where we do not want to end up.

Fix this by just binding to "localhost".  This will make qemu-nbd error
out immediately and not give us cryptic errors later.

(Also, it will allow us to just try a different port as of a future
patch.)

Signed-off-by: Max Reitz <mreitz@redhat.com>
---
 tests/qemu-iotests/147 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Eric Blake Jan. 21, 2019, 8:56 p.m. UTC | #1
On 12/21/18 5:47 PM, Max Reitz wrote:
> By default, qemu-nbd binds to 0.0.0.0.  However, we then proceed to
> connect to "localhost".  Usually, this works out fine; but if this test
> is run concurrently, some other test function may have bound a different
> server to ::1 (on the same port -- you can bind different serves to the

s/serves/servers/

> same port, as long as one is on IPv4 and the other on IPv6).
> 
> So running qemu-nbd works, it can bind to 0.0.0.0:NBD_PORT.  But
> potentially a concurrent test has successfully taken [::1]:NBD_PORT.  In
> this case, trying to connect to "localhost" will lead us to the IPv6
> instance, where we do not want to end up.
> 
> Fix this by just binding to "localhost".  This will make qemu-nbd error
> out immediately and not give us cryptic errors later.
> 
> (Also, it will allow us to just try a different port as of a future
> patch.)
> 
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
>  tests/qemu-iotests/147 | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 

Reviewed-by: Eric Blake <eblake@redhat.com>
diff mbox series

Patch

diff --git a/tests/qemu-iotests/147 b/tests/qemu-iotests/147
index 05b374b7d3..3e10a9969e 100755
--- a/tests/qemu-iotests/147
+++ b/tests/qemu-iotests/147
@@ -92,7 +92,7 @@  class QemuNBD(NBDBlockdevAddBase):
         self.assertEqual(qemu_nbd('-f', imgfmt, test_img, *args), 0)
 
     def test_inet(self):
-        self._server_up('-p', str(NBD_PORT))
+        self._server_up('-b', 'localhost', '-p', str(NBD_PORT))
         address = { 'type': 'inet',
                     'data': {
                         'host': 'localhost',