All of lore.kernel.org
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>,
	qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: Re: [PATCH v2 18/20] iotests: Allow testing FUSE exports
Date: Thu, 15 Oct 2020 17:27:03 +0200	[thread overview]
Message-ID: <941645ba-0451-abfa-6ca3-42c3e49c9dd6@redhat.com> (raw)
In-Reply-To: <20201015114319.GF4610@merkur.fritz.box>


[-- Attachment #1.1: Type: text/plain, Size: 9364 bytes --]

On 15.10.20 13:43, Kevin Wolf wrote:
> Am 22.09.2020 um 12:49 hat Max Reitz geschrieben:
>> This pretends FUSE exports are a kind of protocol.  As such, they are
>> always tested under the format node.  This is probably the best way to
>> test them, actually, because this will generate more I/O load and more
>> varied patterns.
>>
>> Signed-off-by: Max Reitz <mreitz@redhat.com>
>> ---
>>  tests/qemu-iotests/check         |   6 ++
>>  tests/qemu-iotests/common.filter |   5 +-
>>  tests/qemu-iotests/common.rc     | 124 +++++++++++++++++++++++++++++++
>>  3 files changed, 134 insertions(+), 1 deletion(-)
>>
>> diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
>> index 467a7cf1b7..07232138d7 100755
>> --- a/tests/qemu-iotests/check
>> +++ b/tests/qemu-iotests/check
>> @@ -270,6 +270,7 @@ image protocol options
>>      -rbd                test rbd
>>      -sheepdog           test sheepdog
>>      -nbd                test nbd
>> +    -fuse               test fuse
>>      -ssh                test ssh
>>      -nfs                test nfs
>>  
>> @@ -382,6 +383,11 @@ testlist options
>>              xpand=false
>>              ;;
>>  
>> +        -fuse)
>> +            IMGPROTO=fuse
>> +            xpand=false
>> +            ;;
>> +
>>          -ssh)
>>              IMGPROTO=ssh
>>              xpand=false
>> diff --git a/tests/qemu-iotests/common.filter b/tests/qemu-iotests/common.filter
>> index 838ed15793..172ea5752e 100644
>> --- a/tests/qemu-iotests/common.filter
>> +++ b/tests/qemu-iotests/common.filter
>> @@ -44,7 +44,8 @@ _filter_qom_path()
>>  _filter_testdir()
>>  {
>>      $SED -e "s#$TEST_DIR/#TEST_DIR/#g" \
>> -         -e "s#$SOCK_DIR/#SOCK_DIR/#g"
>> +         -e "s#$SOCK_DIR/#SOCK_DIR/#g" \
>> +         -e "s#SOCK_DIR/fuse-#TEST_DIR/#g"
>>  }
>>  
>>  # replace occurrences of the actual IMGFMT value with IMGFMT
>> @@ -127,6 +128,7 @@ _filter_img_create_filenames()
>>          -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \
>>          -e "s#$TEST_DIR#TEST_DIR#g" \
>>          -e "s#$SOCK_DIR#SOCK_DIR#g" \
>> +        -e 's#SOCK_DIR/fuse-#TEST_DIR/#g' \
>>          -e "s#$IMGFMT#IMGFMT#g" \
>>          -e 's#nbd:127.0.0.1:[0-9]\\+#TEST_DIR/t.IMGFMT#g' \
>>          -e 's#nbd+unix:///\??socket=SOCK_DIR/nbd#TEST_DIR/t.IMGFMT#g'
>> @@ -227,6 +229,7 @@ _filter_img_info()
>>          -e "s#$IMGFMT#IMGFMT#g" \
>>          -e 's#nbd://127.0.0.1:[0-9]\\+$#TEST_DIR/t.IMGFMT#g' \
>>          -e 's#nbd+unix:///\??socket=SOCK_DIR/nbd#TEST_DIR/t.IMGFMT#g' \
>> +        -e 's#SOCK_DIR/fuse-#TEST_DIR/#g' \
>>          -e "/encrypted: yes/d" \
>>          -e "/cluster_size: [0-9]\\+/d" \
>>          -e "/table_size: [0-9]\\+/d" \
>> diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
>> index e4751d4985..e17f813f06 100644
>> --- a/tests/qemu-iotests/common.rc
>> +++ b/tests/qemu-iotests/common.rc
>> @@ -257,6 +257,9 @@ if [ "$IMGOPTSSYNTAX" = "true" ]; then
>>          TEST_IMG_FILE=$TEST_DIR/t.$IMGFMT
>>          TEST_IMG="$DRIVER,file.driver=nbd,file.type=unix"
>>          TEST_IMG="$TEST_IMG,file.path=$SOCK_DIR/nbd"
>> +    elif [ "$IMGPROTO" = "fuse" ]; then
>> +        TEST_IMG_FILE=$TEST_DIR/t.$IMGFMT
>> +        TEST_IMG="$DRIVER,file.filename=$SOCK_DIR/fuse-t.$IMGFMT"
>>      elif [ "$IMGPROTO" = "ssh" ]; then
>>          TEST_IMG_FILE=$TEST_DIR/t.$IMGFMT
>>          TEST_IMG="$DRIVER,file.driver=ssh,file.host=127.0.0.1,file.path=$TEST_IMG_FILE"
>> @@ -273,6 +276,9 @@ else
>>      elif [ "$IMGPROTO" = "nbd" ]; then
>>          TEST_IMG_FILE=$TEST_DIR/t.$IMGFMT
>>          TEST_IMG="nbd+unix:///?socket=$SOCK_DIR/nbd"
>> +    elif [ "$IMGPROTO" = "fuse" ]; then
>> +        TEST_IMG_FILE=$TEST_DIR/t.$IMGFMT
>> +        TEST_IMG="$SOCK_DIR/fuse-t.$IMGFMT"
>>      elif [ "$IMGPROTO" = "ssh" ]; then
>>          TEST_IMG_FILE=$TEST_DIR/t.$IMGFMT
>>          REMOTE_TEST_DIR="ssh://\\($USER@\\)\\?127.0.0.1\\(:[0-9]\\+\\)\\?$TEST_DIR"
>> @@ -288,6 +294,9 @@ fi
>>  ORIG_TEST_IMG_FILE=$TEST_IMG_FILE
>>  ORIG_TEST_IMG="$TEST_IMG"
>>  
>> +FUSE_PIDS=()
>> +FUSE_EXPORTS=()
>> +
>>  if [ -z "$TEST_DIR" ]; then
>>          TEST_DIR=$PWD/scratch
>>  fi
>> @@ -357,6 +366,10 @@ _test_img_to_test_img_file()
>>              echo "$1"
>>              ;;
>>  
>> +        fuse)
>> +            echo "$1" | sed -e "s#$SOCK_DIR/fuse-#$TEST_DIR/#"
>> +            ;;
>> +
>>          nfs)
>>              echo "$1" | sed -e "s#nfs://127.0.0.1##"
>>              ;;
>> @@ -385,6 +398,11 @@ _make_test_img()
>>      local opts_param=false
>>      local misc_params=()
>>  
>> +    if [[ $IMGPROTO == fuse && $TEST_IMG == $SOCK_DIR/fuse-* ]]; then
> 
> Given that you sent this series, I assume the test cases pass, but I
> don't understand how this works with more than one image. Shouldn't you
> get an syntax error then because $SOCK_DIR/fuse-* will evaluate to
> multiple words?

Note the [[ ]] – this is a bash condition.  You can do pattern matching
within them, as you see here.  “$TEST_IMG == $SOCK_DIR/fuse-*” checks
whether $TEST_IMG matches the glob pattern given as the second operand.

>> +        # The caller may be trying to overwrite an existing image
>> +        _rm_test_img "$TEST_IMG"
>> +    fi
>> +
>>      if [ -z "$TEST_IMG_FILE" ]; then
>>          img_name=$TEST_IMG
>>      elif [ "$IMGOPTSSYNTAX" != "true" -a \
>> @@ -469,11 +487,105 @@ _make_test_img()
>>          eval "$QEMU_NBD -v -t -k '$SOCK_DIR/nbd' -f $IMGFMT -e 42 -x '' $TEST_IMG_FILE >/dev/null &"
>>          sleep 1 # FIXME: qemu-nbd needs to be listening before we continue
>>      fi
>> +
>> +    if [ $IMGPROTO = "fuse" -a -f "$img_name" ]; then
>> +        local export_mp
>> +        local pid
>> +        local pidfile
>> +        local timeout
>> +
>> +        export_mp=$(echo "$img_name" | sed -e "s#$TEST_DIR/#$SOCK_DIR/fuse-#")
>> +        if ! echo "$export_mp" | grep -q "^$SOCK_DIR"; then
>> +            echo 'Cannot use FUSE exports with images outside of TEST_DIR' >&2
>> +            return 1
>> +        fi
>> +
>> +        touch "$export_mp"
>> +        rm -f "$SOCK_DIR/fuse-output"
>> +
>> +        # Usually, users would export formatted nodes.  But we present fuse as a
>> +        # protocol-level driver here, so we have to leave the format to the
>> +        # client.
>> +        QEMU_STGD_NEED_PID=y $QEMU_STGD \
>> +              --blockdev file,node-name=export-node,filename=$img_name,discard=unmap \
>> +              --export fuse,id=fuse-export,node-name=export-node,mountpoint="$export_mp",writable=on,growable=on \
>> +              &
>> +
>> +        pidfile="$QEMU_TEST_DIR/qemu-storage-daemon.pid"
>> +
>> +        # Wait for the PID file
>> +        while [ ! -f "$pidfile" ]; do
>> +            sleep 0.5
>> +        done
>> +
>> +        pid=$(cat "$pidfile")
>> +        rm -f "$pidfile"
>> +
>> +        FUSE_PIDS+=($pid)
>> +        FUSE_EXPORTS+=("$export_mp")
>> +    fi
>>  }
>>  
>>  _rm_test_img()
>>  {
>>      local img=$1
>> +
>> +    if [[ $IMGPROTO == fuse && $img == $SOCK_DIR/fuse-* ]]; then
>> +        # Drop a FUSE export
>> +        local df_output
>> +        local i
>> +        local image_file
>> +        local index=''
>> +        local timeout
>> +
>> +        for i in "${!FUSE_EXPORTS[@]}"; do
>> +            if [ "${FUSE_EXPORTS[i]}" = "$img" ]; then
>> +                index=$i
>> +                break
>> +            fi
>> +        done
>> +
>> +        if [ -z "$index" ]; then
>> +            # Probably gone already
>> +            return 0
>> +        fi
>> +
>> +        kill "${FUSE_PIDS[index]}"
>> +
>> +        # Wait until the mount is gone
>> +        timeout=10 # *0.5 s
>> +        while true; do
>> +            # Will show the mount point; if the mount is still there,
>> +            # it will be $img.
>> +            df_output=$(df -T "$img" 2>/dev/null)
> 
> 'df -T' doesn't seem to be portable.
> 
> Well, neither is FUSE, so I guess it doesn't matter?

What a nice coincidence. :)

Though then again I have no idea what the -T is for, I don’t grep
anywhere for “fuse”, so we can just drop that -T.

Max

>> +
>> +            # But df may also show an error ("Transpoint endpoint not
>> +            # connected"), so retry in such cases
>> +            if [ -n "$df_output" ]; then
>> +                if ! echo "$df_output" | grep -q "$img"; then
>> +                    break
>> +                fi
>> +            fi
>> +
>> +            sleep 0.5
>> +
>> +            timeout=$((timeout - 1))
>> +            if [ "$timeout" = 0 ]; then
>> +                echo 'Failed to take down FUSE export' >&2
>> +                return 1
>> +            fi
>> +        done
>> +
>> +        rm -f "$img"
>> +
>> +        unset "FUSE_PIDS[$index]"
>> +        unset "FUSE_EXPORTS[$index]"
>> +
>> +        image_file=$(echo "$img" | sed -e "s#$SOCK_DIR/fuse-#$TEST_DIR/#")
>> +        _rm_test_img "$image_file"
>> +        return
>> +    fi
>> +
>>      if [ "$IMGFMT" = "vmdk" ]; then
>>          # Remove all the extents for vmdk
>>          "$QEMU_IMG" info "$img" 2>/dev/null | grep 'filename:' | cut -f 2 -d: \
> 
> Kevin
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2020-10-15 15:39 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-22 10:49 [PATCH v2 00/20] block/export: Allow exporting BDSs via FUSE Max Reitz
2020-09-22 10:49 ` [PATCH v2 01/20] configure: Detect libfuse Max Reitz
2020-09-22 11:14   ` Thomas Huth
2020-09-22 11:21     ` Paolo Bonzini
2020-09-22 11:46     ` Max Reitz
2020-09-22 15:37     ` Max Reitz
2020-09-22 15:45       ` Paolo Bonzini
2020-09-22 10:49 ` [PATCH v2 02/20] fuse: Allow exporting BDSs via FUSE Max Reitz
2020-10-15  8:57   ` Kevin Wolf
2020-10-15 14:46     ` Max Reitz
2020-10-15 15:41       ` Kevin Wolf
2020-10-15 15:59         ` Max Reitz
2020-10-15 17:01           ` Kevin Wolf
2020-09-22 10:49 ` [PATCH v2 03/20] fuse: Implement standard FUSE operations Max Reitz
2020-10-15  9:46   ` Kevin Wolf
2020-10-15 15:18     ` Max Reitz
2020-10-15 15:58       ` Kevin Wolf
2020-10-15 16:04         ` Max Reitz
2020-09-22 10:49 ` [PATCH v2 04/20] fuse: Allow growable exports Max Reitz
2020-10-15 10:41   ` Kevin Wolf
2020-10-15 15:20     ` Max Reitz
2020-09-22 10:49 ` [PATCH v2 05/20] fuse: (Partially) implement fallocate() Max Reitz
2020-09-22 10:49 ` [PATCH v2 06/20] fuse: Implement hole detection through lseek Max Reitz
2020-09-22 10:49 ` [PATCH v2 07/20] iotests: Do not needlessly filter _make_test_img Max Reitz
2020-09-22 10:49 ` [PATCH v2 08/20] iotests: Do not pipe _make_test_img Max Reitz
2020-09-22 10:49 ` [PATCH v2 09/20] iotests: Use convert -n in some cases Max Reitz
2020-09-22 10:49 ` [PATCH v2 10/20] iotests/046: Avoid renaming images Max Reitz
2020-09-22 10:49 ` [PATCH v2 11/20] iotests: Derive image names from $TEST_IMG Max Reitz
2020-09-22 10:49 ` [PATCH v2 12/20] iotests/091: Use _cleanup_qemu instad of "wait" Max Reitz
2020-09-22 10:49 ` [PATCH v2 13/20] iotests: Restrict some Python tests to file Max Reitz
2020-09-22 10:49 ` [PATCH v2 14/20] iotests: Let _make_test_img guess $TEST_IMG_FILE Max Reitz
2020-09-22 10:49 ` [PATCH v2 15/20] iotests/287: Clean up subshell test image Max Reitz
2020-09-22 10:49 ` [PATCH v2 16/20] storage-daemon: Call bdrv_close_all() on exit Max Reitz
2020-09-22 10:49 ` [PATCH v2 17/20] iotests: Give access to the qemu-storage-daemon Max Reitz
2020-10-15 11:27   ` Kevin Wolf
2020-10-15 15:22     ` Max Reitz
2020-09-22 10:49 ` [PATCH v2 18/20] iotests: Allow testing FUSE exports Max Reitz
2020-10-15 11:43   ` Kevin Wolf
2020-10-15 15:27     ` Max Reitz [this message]
2020-09-22 10:49 ` [PATCH v2 19/20] iotests: Enable fuse for many tests Max Reitz
2020-09-22 10:49 ` [PATCH v2 20/20] iotests/308: Add test for FUSE exports Max Reitz
2020-09-22 15:58 ` [PATCH v2 00/20] block/export: Allow exporting BDSs via FUSE Daniel P. Berrangé
2020-09-23  7:21   ` Max Reitz
2020-09-23  9:08   ` Stefan Hajnoczi
2020-10-15 12:01 ` Kevin Wolf
2020-10-15 16:47   ` Max Reitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=941645ba-0451-abfa-6ca3-42c3e49c9dd6@redhat.com \
    --to=mreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.