From nobody Fri Sep 20 22:14:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1504009904420165.33023277939787; Tue, 29 Aug 2017 05:31:44 -0700 (PDT) Received: from localhost ([::1]:44728 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmfgE-0008Jy-AS for importer@patchew.org; Tue, 29 Aug 2017 08:31:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43065) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmfcf-0005Ze-Kx for qemu-devel@nongnu.org; Tue, 29 Aug 2017 08:28:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmfce-0002kS-G1 for qemu-devel@nongnu.org; Tue, 29 Aug 2017 08:28:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:18537) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmfcb-0002ih-Bo; Tue, 29 Aug 2017 08:27:57 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4EA1780C03; Tue, 29 Aug 2017 12:27:56 +0000 (UTC) Received: from localhost (ovpn-117-175.ams2.redhat.com [10.36.117.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4F33970651; Tue, 29 Aug 2017 12:27:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4EA1780C03 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=stefanha@redhat.com From: Stefan Hajnoczi To: Date: Tue, 29 Aug 2017 13:27:43 +0100 Message-Id: <20170829122745.14309-2-stefanha@redhat.com> In-Reply-To: <20170829122745.14309-1-stefanha@redhat.com> References: <20170829122745.14309-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 29 Aug 2017 12:27:56 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 1/3] nbd-client: avoid read_reply_co entry if send failed X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , qemu-block@nongnu.org, Stefan Hajnoczi , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The following segfault is encountered if the NBD server closes the UNIX domain socket immediately after negotiation: Program terminated with signal SIGSEGV, Segmentation fault. #0 aio_co_schedule (ctx=3D0x0, co=3D0xd3c0ff2ef0) at util/async.c:441 441 QSLIST_INSERT_HEAD_ATOMIC(&ctx->scheduled_coroutines, (gdb) bt #0 0x000000d3c01a50f8 in aio_co_schedule (ctx=3D0x0, co=3D0xd3c0ff2ef0) = at util/async.c:441 #1 0x000000d3c012fa90 in nbd_coroutine_end (bs=3Dbs@entry=3D0xd3c0fec650= , request=3D) at block/nbd-client.c:207 #2 0x000000d3c012fb58 in nbd_client_co_preadv (bs=3D0xd3c0fec650, offset= =3D0, bytes=3D, qiov=3D0x7ffc10a91b20, flags=3D0) at block/n= bd-client.c:237 #3 0x000000d3c0128e63 in bdrv_driver_preadv (bs=3Dbs@entry=3D0xd3c0fec65= 0, offset=3Doffset@entry=3D0, bytes=3Dbytes@entry=3D512, qiov=3Dqiov@entry= =3D0x7ffc10a91b20, flags=3D0) at block/io.c:836 #4 0x000000d3c012c3e0 in bdrv_aligned_preadv (child=3Dchild@entry=3D0xd3= c0ff51d0, req=3Dreq@entry=3D0x7f31885d6e90, offset=3Doffset@entry=3D0, byte= s=3Dbytes@entry=3D512, align=3Dalign@entry=3D1, qiov=3Dqiov@entry=3D0x7ffc1= 0a91b20, f +lags=3D0) at block/io.c:1086 #5 0x000000d3c012c6b8 in bdrv_co_preadv (child=3D0xd3c0ff51d0, offset=3D= offset@entry=3D0, bytes=3Dbytes@entry=3D512, qiov=3Dqiov@entry=3D0x7ffc10a9= 1b20, flags=3Dflags@entry=3D0) at block/io.c:1182 #6 0x000000d3c011cc17 in blk_co_preadv (blk=3D0xd3c0ff4f80, offset=3D0, = bytes=3D512, qiov=3D0x7ffc10a91b20, flags=3D0) at block/block-backend.c:1032 #7 0x000000d3c011ccec in blk_read_entry (opaque=3D0x7ffc10a91b40) at blo= ck/block-backend.c:1079 #8 0x000000d3c01bbb96 in coroutine_trampoline (i0=3D, i1= =3D) at util/coroutine-ucontext.c:79 #9 0x00007f3196cb8600 in __start_context () at /lib64/libc.so.6 The problem is that nbd_client_init() uses nbd_client_attach_aio_context() -> aio_co_schedule(new_context, client->read_reply_co). Execution of read_reply_co is deferred to a BH which doesn't run until later. In the mean time blk_co_preadv() can be called and nbd_coroutine_end() calls aio_wake() on read_reply_co. At this point in time read_reply_co's ctx isn't set because it has never been entered yet. This patch simplifies the nbd_co_send_request() -> nbd_co_receive_reply() -> nbd_coroutine_end() lifecycle to just nbd_co_send_request() -> nbd_co_receive_reply(). The request is "ended" if an error occurs at any point. Callers no longer have to invoke nbd_coroutine_end(). This cleanup also eliminates the segfault because we don't call aio_co_schedule() to wake up s->read_reply_co if sending the request failed. It is only necessary to wake up s->read_reply_co if a reply was received. Note this only happens with UNIX domain sockets on Linux. It doesn't seem possible to reproduce this with TCP sockets. Suggested-by: Paolo Bonzini Signed-off-by: Stefan Hajnoczi Reviewed-by: Eric Blake --- block/nbd-client.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/block/nbd-client.c b/block/nbd-client.c index 25bcaa2346..ea728fffc8 100644 --- a/block/nbd-client.c +++ b/block/nbd-client.c @@ -144,12 +144,12 @@ static int nbd_co_send_request(BlockDriverState *bs, request->handle =3D INDEX_TO_HANDLE(s, i); =20 if (s->quit) { - qemu_co_mutex_unlock(&s->send_mutex); - return -EIO; + rc =3D -EIO; + goto err; } if (!s->ioc) { - qemu_co_mutex_unlock(&s->send_mutex); - return -EPIPE; + rc =3D -EPIPE; + goto err; } =20 if (qiov) { @@ -166,8 +166,13 @@ static int nbd_co_send_request(BlockDriverState *bs, } else { rc =3D nbd_send_request(s->ioc, request); } + +err: if (rc < 0) { s->quit =3D true; + s->requests[i].coroutine =3D NULL; + s->in_flight--; + qemu_co_queue_next(&s->free_sema); } qemu_co_mutex_unlock(&s->send_mutex); return rc; @@ -201,13 +206,6 @@ static void nbd_co_receive_reply(NBDClientSession *s, /* Tell the read handler to read another header. */ s->reply.handle =3D 0; } -} - -static void nbd_coroutine_end(BlockDriverState *bs, - NBDRequest *request) -{ - NBDClientSession *s =3D nbd_get_client_session(bs); - int i =3D HANDLE_TO_INDEX(s, request->handle); =20 s->requests[i].coroutine =3D NULL; =20 @@ -243,7 +241,6 @@ int nbd_client_co_preadv(BlockDriverState *bs, uint64_t= offset, } else { nbd_co_receive_reply(client, &request, &reply, qiov); } - nbd_coroutine_end(bs, &request); return -reply.error; } =20 @@ -272,7 +269,6 @@ int nbd_client_co_pwritev(BlockDriverState *bs, uint64_= t offset, } else { nbd_co_receive_reply(client, &request, &reply, NULL); } - nbd_coroutine_end(bs, &request); return -reply.error; } =20 @@ -306,7 +302,6 @@ int nbd_client_co_pwrite_zeroes(BlockDriverState *bs, i= nt64_t offset, } else { nbd_co_receive_reply(client, &request, &reply, NULL); } - nbd_coroutine_end(bs, &request); return -reply.error; } =20 @@ -330,7 +325,6 @@ int nbd_client_co_flush(BlockDriverState *bs) } else { nbd_co_receive_reply(client, &request, &reply, NULL); } - nbd_coroutine_end(bs, &request); return -reply.error; } =20 @@ -355,7 +349,6 @@ int nbd_client_co_pdiscard(BlockDriverState *bs, int64_= t offset, int bytes) } else { nbd_co_receive_reply(client, &request, &reply, NULL); } - nbd_coroutine_end(bs, &request); return -reply.error; =20 } --=20 2.13.5 From nobody Fri Sep 20 22:14:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1504009801686939.6779340410525; Tue, 29 Aug 2017 05:30:01 -0700 (PDT) Received: from localhost ([::1]:44709 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmfeZ-0006nd-5B for importer@patchew.org; Tue, 29 Aug 2017 08:29:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43106) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmfcn-0005f5-Cm for qemu-devel@nongnu.org; Tue, 29 Aug 2017 08:28:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmfcm-0002mh-GZ for qemu-devel@nongnu.org; Tue, 29 Aug 2017 08:28:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37020) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmfcf-0002kW-BJ; Tue, 29 Aug 2017 08:28:01 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 61710C058EB7; Tue, 29 Aug 2017 12:28:00 +0000 (UTC) Received: from localhost (ovpn-117-175.ams2.redhat.com [10.36.117.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id AB8A87FB50; Tue, 29 Aug 2017 12:27:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 61710C058EB7 Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=stefanha@redhat.com From: Stefan Hajnoczi To: Date: Tue, 29 Aug 2017 13:27:44 +0100 Message-Id: <20170829122745.14309-3-stefanha@redhat.com> In-Reply-To: <20170829122745.14309-1-stefanha@redhat.com> References: <20170829122745.14309-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 29 Aug 2017 12:28:00 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 2/3] qemu-iotests: improve nbd-fault-injector.py startup protocol X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , qemu-block@nongnu.org, Stefan Hajnoczi , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: Stefan Hajnoczi --- tests/qemu-iotests/nbd-fault-injector.py | 4 ++++ 1 file changed, 4 insertions(+) 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 =3D 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 =3D '%s:%d' % sock.getsockname() else: sock =3D 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 =20 def usage(args): --=20 2.13.5 From nobody Fri Sep 20 22:14:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1504009811634313.56282274554394; Tue, 29 Aug 2017 05:30:11 -0700 (PDT) Received: from localhost ([::1]:44711 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmfej-0006xU-Lu for importer@patchew.org; Tue, 29 Aug 2017 08:30:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43123) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmfcr-0005j5-DN for qemu-devel@nongnu.org; Tue, 29 Aug 2017 08:28:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmfcp-0002nG-Fp for qemu-devel@nongnu.org; Tue, 29 Aug 2017 08:28:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51058) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmfcj-0002m7-Qd; Tue, 29 Aug 2017 08:28:06 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D711B1F570; Tue, 29 Aug 2017 12:28:03 +0000 (UTC) Received: from localhost (ovpn-117-175.ams2.redhat.com [10.36.117.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id C1D036BC1A; Tue, 29 Aug 2017 12:28:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D711B1F570 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=stefanha@redhat.com From: Stefan Hajnoczi To: Date: Tue, 29 Aug 2017 13:27:45 +0100 Message-Id: <20170829122745.14309-4-stefanha@redhat.com> In-Reply-To: <20170829122745.14309-1-stefanha@redhat.com> References: <20170829122745.14309-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 29 Aug 2017 12:28:04 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 3/3] qemu-iotests: test NBD over UNIX domain sockets in 083 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Vladimir Sementsov-Ogievskiy , qemu-block@nongnu.org, Stefan Hajnoczi , Paolo Bonzini Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 083 only tests TCP. Some failures might be specific to UNIX domain sockets. A few adjustments are necessary: 1. Generating a port number and waiting for server startup is TCP-specific. Use the new nbd-fault-injector.py startup protocol to fetch the address. This is a little more elegant because we don't need netstat anymore. 2. The NBD filter does not work for the UNIX domain sockets URIs we generate and must be extended. 3. Run all tests twice: once for TCP and once for UNIX domain sockets. Reviewed-by: Eric Blake Signed-off-by: Stefan Hajnoczi --- tests/qemu-iotests/083 | 138 +++++++++++++++++++++++------------= -- tests/qemu-iotests/083.out | 145 ++++++++++++++++++++++++++++++++++-= ---- tests/qemu-iotests/common.filter | 4 +- 3 files changed, 215 insertions(+), 72 deletions(-) diff --git a/tests/qemu-iotests/083 b/tests/qemu-iotests/083 index bff9360048..0306f112da 100755 --- a/tests/qemu-iotests/083 +++ b/tests/qemu-iotests/083 @@ -27,6 +27,14 @@ echo "QA output created by $seq" here=3D`pwd` status=3D1 # failure is the default! =20 +_cleanup() +{ + rm -f nbd.sock + rm -f nbd-fault-injector.out + rm -f nbd-fault-injector.conf +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + # get standard environment, filters and checks . ./common.rc . ./common.filter @@ -35,81 +43,105 @@ _supported_fmt generic _supported_proto nbd _supported_os Linux =20 -# Pick a TCP port based on our pid. This way multiple instances of this t= est -# can run in parallel without conflicting. -choose_tcp_port() { - echo $((($$ % 31744) + 1024)) # 1024 <=3D port < 32768 -} - -wait_for_tcp_port() { - while ! (netstat --tcp --listening --numeric | \ - grep "$1.*0\\.0\\.0\\.0:\\*.*LISTEN") >/dev/null 2>&1; do - sleep 0.1 - done -} - check_disconnect() { + local event export_name=3Dfoo extra_args nbd_addr nbd_url proto when + + while true; do + case $1 in + --classic-negotiation) + shift + extra_args=3D--classic-negotiation + export_name=3D + ;; + --tcp) + shift + proto=3Dtcp + ;; + --unix) + shift + proto=3Dunix + ;; + *) + break + ;; + esac + done + event=3D$1 when=3D$2 - negotiation=3D$3 echo "=3D=3D=3D Check disconnect $when $event =3D=3D=3D" echo =20 - port=3D$(choose_tcp_port) - cat > "$TEST_DIR/nbd-fault-injector.conf" <"$TEST_DIR/nbd-fault-injector.out" 2>&1 & + + # Wait for server to be ready + while ! grep -q 'Listening on ' "$TEST_DIR/nbd-fault-injector.out"; do + sleep 0.1 + done + + # Extract the final address (port number has now been assigned in tcp cas= e) + nbd_addr=3D$(sed 's/Listening on \(.*\)$/\1/' "$TEST_DIR/nbd-fault-inject= or.out") + + if [ "$proto" =3D "tcp" ]; then + nbd_url=3D"nbd+tcp://$nbd_addr/$export_name" + else + nbd_url=3D"nbd+unix:///$export_name?socket=3D$nbd_addr" fi =20 - $PYTHON nbd-fault-injector.py $extra_args "127.0.0.1:$port" "$TEST_DIR/nb= d-fault-injector.conf" >/dev/null 2>&1 & - wait_for_tcp_port "127\\.0\\.0\\.1:$port" $QEMU_IO -c "read 0 512" "$nbd_url" 2>&1 | _filter_qemu_io | _filter_nbd =20 echo } =20 -for event in neg1 "export" neg2 request reply data; do - for when in before after; do - check_disconnect "$event" "$when" - done - - # Also inject short replies from the NBD server - case "$event" in - neg1) - for when in 8 16; do - check_disconnect "$event" "$when" - done - ;; - "export") - for when in 4 12 16; do - check_disconnect "$event" "$when" - done - ;; - neg2) - for when in 8 10; do - check_disconnect "$event" "$when" +for proto in tcp unix; do + for event in neg1 "export" neg2 request reply data; do + for when in before after; do + check_disconnect "--$proto" "$event" "$when" done - ;; - reply) - for when in 4 8; do - check_disconnect "$event" "$when" - done - ;; - esac -done =20 -# Also check classic negotiation without export information -for when in before 8 16 24 28 after; do - check_disconnect "neg-classic" "$when" --classic-negotiation + # Also inject short replies from the NBD server + case "$event" in + neg1) + for when in 8 16; do + check_disconnect "--$proto" "$event" "$when" + done + ;; + "export") + for when in 4 12 16; do + check_disconnect "--$proto" "$event" "$when" + done + ;; + neg2) + for when in 8 10; do + check_disconnect "--$proto" "$event" "$when" + done + ;; + reply) + for when in 4 8; do + check_disconnect "--$proto" "$event" "$when" + done + ;; + esac + done + + # Also check classic negotiation without export information + for when in before 8 16 24 28 after; do + check_disconnect "--$proto" --classic-negotiation "neg-classic" "$when" + done done =20 # success, all done diff --git a/tests/qemu-iotests/083.out b/tests/qemu-iotests/083.out index a24c6bfece..a7fb081889 100644 --- a/tests/qemu-iotests/083.out +++ b/tests/qemu-iotests/083.out @@ -1,43 +1,43 @@ QA output created by 083 =3D=3D=3D Check disconnect before neg1 =3D=3D=3D =20 -can't open device nbd:127.0.0.1:PORT:exportname=3Dfoo +can't open device nbd+tcp://127.0.0.1:PORT/foo =20 =3D=3D=3D Check disconnect after neg1 =3D=3D=3D =20 -can't open device nbd:127.0.0.1:PORT:exportname=3Dfoo +can't open device nbd+tcp://127.0.0.1:PORT/foo =20 =3D=3D=3D Check disconnect 8 neg1 =3D=3D=3D =20 -can't open device nbd:127.0.0.1:PORT:exportname=3Dfoo +can't open device nbd+tcp://127.0.0.1:PORT/foo =20 =3D=3D=3D Check disconnect 16 neg1 =3D=3D=3D =20 -can't open device nbd:127.0.0.1:PORT:exportname=3Dfoo +can't open device nbd+tcp://127.0.0.1:PORT/foo =20 =3D=3D=3D Check disconnect before export =3D=3D=3D =20 -can't open device nbd:127.0.0.1:PORT:exportname=3Dfoo +can't open device nbd+tcp://127.0.0.1:PORT/foo =20 =3D=3D=3D Check disconnect after export =3D=3D=3D =20 -can't open device nbd:127.0.0.1:PORT:exportname=3Dfoo +can't open device nbd+tcp://127.0.0.1:PORT/foo =20 =3D=3D=3D Check disconnect 4 export =3D=3D=3D =20 -can't open device nbd:127.0.0.1:PORT:exportname=3Dfoo +can't open device nbd+tcp://127.0.0.1:PORT/foo =20 =3D=3D=3D Check disconnect 12 export =3D=3D=3D =20 -can't open device nbd:127.0.0.1:PORT:exportname=3Dfoo +can't open device nbd+tcp://127.0.0.1:PORT/foo =20 =3D=3D=3D Check disconnect 16 export =3D=3D=3D =20 -can't open device nbd:127.0.0.1:PORT:exportname=3Dfoo +can't open device nbd+tcp://127.0.0.1:PORT/foo =20 =3D=3D=3D Check disconnect before neg2 =3D=3D=3D =20 -can't open device nbd:127.0.0.1:PORT:exportname=3Dfoo +can't open device nbd+tcp://127.0.0.1:PORT/foo =20 =3D=3D=3D Check disconnect after neg2 =3D=3D=3D =20 @@ -45,11 +45,11 @@ read failed: Input/output error =20 =3D=3D=3D Check disconnect 8 neg2 =3D=3D=3D =20 -can't open device nbd:127.0.0.1:PORT:exportname=3Dfoo +can't open device nbd+tcp://127.0.0.1:PORT/foo =20 =3D=3D=3D Check disconnect 10 neg2 =3D=3D=3D =20 -can't open device nbd:127.0.0.1:PORT:exportname=3Dfoo +can't open device nbd+tcp://127.0.0.1:PORT/foo =20 =3D=3D=3D Check disconnect before request =3D=3D=3D =20 @@ -88,23 +88,134 @@ read 512/512 bytes at offset 0 =20 =3D=3D=3D Check disconnect before neg-classic =3D=3D=3D =20 -can't open device nbd:127.0.0.1:PORT +can't open device nbd+tcp://127.0.0.1:PORT/ =20 =3D=3D=3D Check disconnect 8 neg-classic =3D=3D=3D =20 -can't open device nbd:127.0.0.1:PORT +can't open device nbd+tcp://127.0.0.1:PORT/ =20 =3D=3D=3D Check disconnect 16 neg-classic =3D=3D=3D =20 -can't open device nbd:127.0.0.1:PORT +can't open device nbd+tcp://127.0.0.1:PORT/ =20 =3D=3D=3D Check disconnect 24 neg-classic =3D=3D=3D =20 -can't open device nbd:127.0.0.1:PORT +can't open device nbd+tcp://127.0.0.1:PORT/ =20 =3D=3D=3D Check disconnect 28 neg-classic =3D=3D=3D =20 -can't open device nbd:127.0.0.1:PORT +can't open device nbd+tcp://127.0.0.1:PORT/ + +=3D=3D=3D Check disconnect after neg-classic =3D=3D=3D + +read failed: Input/output error + +=3D=3D=3D Check disconnect before neg1 =3D=3D=3D + +can't open device nbd+unix:///foo?socket=3DTEST_DIR/nbd.sock + +=3D=3D=3D Check disconnect after neg1 =3D=3D=3D + +can't open device nbd+unix:///foo?socket=3DTEST_DIR/nbd.sock + +=3D=3D=3D Check disconnect 8 neg1 =3D=3D=3D + +can't open device nbd+unix:///foo?socket=3DTEST_DIR/nbd.sock + +=3D=3D=3D Check disconnect 16 neg1 =3D=3D=3D + +can't open device nbd+unix:///foo?socket=3DTEST_DIR/nbd.sock + +=3D=3D=3D Check disconnect before export =3D=3D=3D + +can't open device nbd+unix:///foo?socket=3DTEST_DIR/nbd.sock + +=3D=3D=3D Check disconnect after export =3D=3D=3D + +can't open device nbd+unix:///foo?socket=3DTEST_DIR/nbd.sock + +=3D=3D=3D Check disconnect 4 export =3D=3D=3D + +can't open device nbd+unix:///foo?socket=3DTEST_DIR/nbd.sock + +=3D=3D=3D Check disconnect 12 export =3D=3D=3D + +can't open device nbd+unix:///foo?socket=3DTEST_DIR/nbd.sock + +=3D=3D=3D Check disconnect 16 export =3D=3D=3D + +can't open device nbd+unix:///foo?socket=3DTEST_DIR/nbd.sock + +=3D=3D=3D Check disconnect before neg2 =3D=3D=3D + +can't open device nbd+unix:///foo?socket=3DTEST_DIR/nbd.sock + +=3D=3D=3D Check disconnect after neg2 =3D=3D=3D + +read failed: Input/output error + +=3D=3D=3D Check disconnect 8 neg2 =3D=3D=3D + +can't open device nbd+unix:///foo?socket=3DTEST_DIR/nbd.sock + +=3D=3D=3D Check disconnect 10 neg2 =3D=3D=3D + +can't open device nbd+unix:///foo?socket=3DTEST_DIR/nbd.sock + +=3D=3D=3D Check disconnect before request =3D=3D=3D + +read failed: Input/output error + +=3D=3D=3D Check disconnect after request =3D=3D=3D + +read failed: Input/output error + +=3D=3D=3D Check disconnect before reply =3D=3D=3D + +read failed: Input/output error + +=3D=3D=3D Check disconnect after reply =3D=3D=3D + +read failed: Input/output error + +=3D=3D=3D Check disconnect 4 reply =3D=3D=3D + +read failed +read failed: Input/output error + +=3D=3D=3D Check disconnect 8 reply =3D=3D=3D + +read failed +read failed: Input/output error + +=3D=3D=3D Check disconnect before data =3D=3D=3D + +read failed: Input/output error + +=3D=3D=3D Check disconnect after data =3D=3D=3D + +read 512/512 bytes at offset 0 +512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +=3D=3D=3D Check disconnect before neg-classic =3D=3D=3D + +can't open device nbd+unix:///?socket=3DTEST_DIR/nbd.sock + +=3D=3D=3D Check disconnect 8 neg-classic =3D=3D=3D + +can't open device nbd+unix:///?socket=3DTEST_DIR/nbd.sock + +=3D=3D=3D Check disconnect 16 neg-classic =3D=3D=3D + +can't open device nbd+unix:///?socket=3DTEST_DIR/nbd.sock + +=3D=3D=3D Check disconnect 24 neg-classic =3D=3D=3D + +can't open device nbd+unix:///?socket=3DTEST_DIR/nbd.sock + +=3D=3D=3D Check disconnect 28 neg-classic =3D=3D=3D + +can't open device nbd+unix:///?socket=3DTEST_DIR/nbd.sock =20 =3D=3D=3D Check disconnect after neg-classic =3D=3D=3D =20 diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.f= ilter index 7a58e57317..9d5442ecd9 100644 --- a/tests/qemu-iotests/common.filter +++ b/tests/qemu-iotests/common.filter @@ -170,9 +170,9 @@ _filter_nbd() # # Filter out the TCP port number since this changes between runs. sed -e '/nbd\/.*\.c:/d' \ - -e 's#nbd:\(//\)\?127\.0\.0\.1:[0-9]*#nbd:\1127.0.0.1:PORT#g' \ + -e 's#127\.0\.0\.1:[0-9]*#127.0.0.1:PORT#g' \ -e "s#?socket=3D$TEST_DIR#?socket=3DTEST_DIR#g" \ - -e 's#\(exportname=3Dfoo\|PORT\): Failed to .*$#\1#' + -e 's#\(foo\|PORT/\?\|.sock\): Failed to .*$#\1#' } =20 # make sure this script returns success --=20 2.13.5