From nobody Sun Oct 5 19:25:51 2025 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 150411688594760.2185370189585; Wed, 30 Aug 2017 11:14:45 -0700 (PDT) Received: from localhost ([::1]:52075 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dn7Vj-0008N8-Gn for importer@patchew.org; Wed, 30 Aug 2017 14:14:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53130) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dn7Ol-0001wF-Op for qemu-devel@nongnu.org; Wed, 30 Aug 2017 14:07:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dn7Oj-0001bw-O2 for qemu-devel@nongnu.org; Wed, 30 Aug 2017 14:07:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44108) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dn7Oe-0001Zj-AG; Wed, 30 Aug 2017 14:07:24 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 63A22C0587E8; Wed, 30 Aug 2017 18:07:23 +0000 (UTC) Received: from red.redhat.com (ovpn-122-186.rdu2.redhat.com [10.10.122.186]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8803E17106; Wed, 30 Aug 2017 18:07:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 63A22C0587E8 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=eblake@redhat.com From: Eric Blake To: qemu-devel@nongnu.org Date: Wed, 30 Aug 2017 13:07:04 -0500 Message-Id: <20170830180711.7974-5-eblake@redhat.com> In-Reply-To: <20170830180711.7974-1-eblake@redhat.com> References: <20170830180711.7974-1-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 30 Aug 2017 18:07:23 +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] [PULL 04/11] 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 , "open list:Block layer core" , Stefan Hajnoczi , Max Reitz 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" From: Stefan Hajnoczi 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 Message-Id: <20170829122745.14309-4-stefanha@redhat.com> Signed-off-by: Eric Blake --- tests/qemu-iotests/common.filter | 4 +- tests/qemu-iotests/083 | 138 +++++++++++++++++++++++------------= -- tests/qemu-iotests/083.out | 145 ++++++++++++++++++++++++++++++++++-= ---- 3 files changed, 215 insertions(+), 72 deletions(-) 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#' } # make sure this script returns success 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! +_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 -# 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 - 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 - $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 echo } -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 -# 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 # 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 -can't open device nbd:127.0.0.1:PORT:exportname=3Dfoo +can't open device nbd+tcp://127.0.0.1:PORT/foo =3D=3D=3D Check disconnect after neg1 =3D=3D=3D -can't open device nbd:127.0.0.1:PORT:exportname=3Dfoo +can't open device nbd+tcp://127.0.0.1:PORT/foo =3D=3D=3D Check disconnect 8 neg1 =3D=3D=3D -can't open device nbd:127.0.0.1:PORT:exportname=3Dfoo +can't open device nbd+tcp://127.0.0.1:PORT/foo =3D=3D=3D Check disconnect 16 neg1 =3D=3D=3D -can't open device nbd:127.0.0.1:PORT:exportname=3Dfoo +can't open device nbd+tcp://127.0.0.1:PORT/foo =3D=3D=3D Check disconnect before export =3D=3D=3D -can't open device nbd:127.0.0.1:PORT:exportname=3Dfoo +can't open device nbd+tcp://127.0.0.1:PORT/foo =3D=3D=3D Check disconnect after export =3D=3D=3D -can't open device nbd:127.0.0.1:PORT:exportname=3Dfoo +can't open device nbd+tcp://127.0.0.1:PORT/foo =3D=3D=3D Check disconnect 4 export =3D=3D=3D -can't open device nbd:127.0.0.1:PORT:exportname=3Dfoo +can't open device nbd+tcp://127.0.0.1:PORT/foo =3D=3D=3D Check disconnect 12 export =3D=3D=3D -can't open device nbd:127.0.0.1:PORT:exportname=3Dfoo +can't open device nbd+tcp://127.0.0.1:PORT/foo =3D=3D=3D Check disconnect 16 export =3D=3D=3D -can't open device nbd:127.0.0.1:PORT:exportname=3Dfoo +can't open device nbd+tcp://127.0.0.1:PORT/foo =3D=3D=3D Check disconnect before neg2 =3D=3D=3D -can't open device nbd:127.0.0.1:PORT:exportname=3Dfoo +can't open device nbd+tcp://127.0.0.1:PORT/foo =3D=3D=3D Check disconnect after neg2 =3D=3D=3D @@ -45,11 +45,11 @@ read failed: Input/output error =3D=3D=3D Check disconnect 8 neg2 =3D=3D=3D -can't open device nbd:127.0.0.1:PORT:exportname=3Dfoo +can't open device nbd+tcp://127.0.0.1:PORT/foo =3D=3D=3D Check disconnect 10 neg2 =3D=3D=3D -can't open device nbd:127.0.0.1:PORT:exportname=3Dfoo +can't open device nbd+tcp://127.0.0.1:PORT/foo =3D=3D=3D Check disconnect before request =3D=3D=3D @@ -88,23 +88,134 @@ read 512/512 bytes at offset 0 =3D=3D=3D Check disconnect before neg-classic =3D=3D=3D -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 8 neg-classic =3D=3D=3D -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 16 neg-classic =3D=3D=3D -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 24 neg-classic =3D=3D=3D -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 28 neg-classic =3D=3D=3D -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 =3D=3D=3D Check disconnect after neg-classic =3D=3D=3D --=20 2.13.5