diff mbox

[Qemu-block,v4,0/3] iotests: Fix test 162

Message ID 1b3f7281-eaa6-586b-0f3c-f30cebf88322@linux.vnet.ibm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Hao QingFeng Oct. 12, 2016, 8:55 a.m. UTC
Max,

Just a common question for this case, if sshx block driver wasn't built 
into qemu-img, this case would fail as below:

exec /home/haoqf/KVMonz/qemu/tests/qemu-iotests/../../qemu-img info 
--image-opts driver=ssh,host=localhost,port=0.42,path=/foo
qemu-img: Could not open 
'driver=ssh,host=localhost,port=0.42,path=/foo': Unknown driver 'ssh'

Adding 162.notrun can bypass this case but it would skip it even if 
qemu-img has sshx block driver, in which case I think it should be run.

So How about adding a script to dynamically check at runtime if the 
current env qemu-img can meet the requirement to run the test or not?

I made a sample here whose result is:

[Without sshx built in]

./check -qcow2 162
... ...
162 0s ... [not run] case 162 not applicable!
Not run: 162
Passed all 0 tests

[Without sshx built in]
./check -qcow2 162
... ...
162 0s ...
Passed all 1 tests

Rough code patch is(new file 162.check is introduced to check if sshx is 
built in):

+   exit 0
+fi
+
+exit 1

Thanks!

Hao QingFeng


在 2016-09-29 4:46, Max Reitz 写道:
> 162 is potentially racy and makes some invalid assumptions about what
> should happen when connecting to a non-existing domain name. This series
> fixes both issues.
>
>
> v4:
> - Added documentation for the new --fork option [Kevin]
>
>
> git-backport-diff against v3:
>
> Key:
> [----] : patches are identical
> [####] : number of functional differences between upstream/downstream
> patch
> [down] : patch is downstream-only
> The flags [FC] indicate (F)unctional and (C)ontextual differences,
> respectively
>
> 001/3:[0004] [FC] 'qemu-nbd: Add --fork option'
> 002/3:[----] [--] 'iotests: Remove raciness from 162'
> 003/3:[----] [--] 'iotests: Do not rely on unavailable domains in 162'
>
>
> Max Reitz (3):
>    qemu-nbd: Add --fork option
>    iotests: Remove raciness from 162
>    iotests: Do not rely on unavailable domains in 162
>
>   qemu-nbd.c                 | 17 ++++++++++++++++-
>   qemu-nbd.texi              |  2 ++
>   tests/qemu-iotests/162     | 22 ++++++++++++++++------
>   tests/qemu-iotests/162.out |  2 +-
>   4 files changed, 35 insertions(+), 8 deletions(-)
>

Comments

Max Reitz Oct. 12, 2016, 7:46 p.m. UTC | #1
On 12.10.2016 10:55, Hao QingFeng wrote:
> Max,
> 
> Just a common question for this case, if sshx block driver wasn't built
> into qemu-img, this case would fail as below:

Good point, and thanks for bringing it up, but it's not directly linked
to this series other than by its subject, of course, so I'd rather add a
fix on top.

> exec /home/haoqf/KVMonz/qemu/tests/qemu-iotests/../../qemu-img info
> --image-opts driver=ssh,host=localhost,port=0.42,path=/foo
> qemu-img: Could not open
> 'driver=ssh,host=localhost,port=0.42,path=/foo': Unknown driver 'ssh'
> 
> Adding 162.notrun can bypass this case but it would skip it even if
> qemu-img has sshx block driver, in which case I think it should be run.
> 
> So How about adding a script to dynamically check at runtime if the
> current env qemu-img can meet the requirement to run the test or not?

Unfortunately, the list of block drivers listed by will not contain ssh
if ssh is built as a module, which is possible.

This is a bug that should be fixed, but I'd rather do so in a separate
series from this one.

In any case, once it is fixed I'd rather just take the approach quorum
tests take already (e.g. test 081), which is something like:

test_ssh=$($QEMU_IMG --help | grep '^Supported formats:.* ssh\( \|$\)')
[ "$test_ssh" = "" ] && _notrun "ssh support required"

Max
Hao QingFeng Oct. 13, 2016, 5:20 a.m. UTC | #2
在 2016-10-13 3:46, Max Reitz 写道:
> On 12.10.2016 10:55, Hao QingFeng wrote:
>> Max,
>>
>> Just a common question for this case, if sshx block driver wasn't built
>> into qemu-img, this case would fail as below:
> Good point, and thanks for bringing it up, but it's not directly linked
> to this series other than by its subject, of course, so I'd rather add a
> fix on top.
Thanks and sorry for sending to the improper mail series.
>> exec /home/haoqf/KVMonz/qemu/tests/qemu-iotests/../../qemu-img info
>> --image-opts driver=ssh,host=localhost,port=0.42,path=/foo
>> qemu-img: Could not open
>> 'driver=ssh,host=localhost,port=0.42,path=/foo': Unknown driver 'ssh'
>>
>> Adding 162.notrun can bypass this case but it would skip it even if
>> qemu-img has sshx block driver, in which case I think it should be run.
>>
>> So How about adding a script to dynamically check at runtime if the
>> current env qemu-img can meet the requirement to run the test or not?
> Unfortunately, the list of block drivers listed by will not contain ssh
> if ssh is built as a module, which is possible.
Actually I am not sure if I understood it. Do you mean 
"CONFIG_LIBSSH2=m" set
rather than "CONFIG_LIBSSH2=y" in config-host.mak? But in the configure it's
set to be "CONFIG_LIBSSH2=y":
if test "$libssh2" = "yes" ; then
   echo "CONFIG_LIBSSH2=y" >> $config_host_mak
   echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
   echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak
fi
Meanwhile I changed it to be "CONFIG_LIBSSH2=m" and reconfig, make the qemu,
qemu-img --help can still prompt ssh.
> This is a bug that should be fixed, but I'd rather do so in a separate
> series from this one.
>
> In any case, once it is fixed I'd rather just take the approach quorum
> tests take already (e.g. test 081), which is something like:
>
> test_ssh=$($QEMU_IMG --help | grep '^Supported formats:.* ssh\( \|$\)')
> [ "$test_ssh" = "" ] && _notrun "ssh support required"
Cool. Agree with this like what was done in 081.  thanks
> Max
>
Max Reitz Oct. 15, 2016, 5:27 p.m. UTC | #3
On 13.10.2016 07:20, Hao QingFeng wrote:
> 
> 
> 在 2016-10-13 3:46, Max Reitz 写道:
>> On 12.10.2016 10:55, Hao QingFeng wrote:
>>> Max,
>>>
>>> Just a common question for this case, if sshx block driver wasn't built
>>> into qemu-img, this case would fail as below:
>> Good point, and thanks for bringing it up, but it's not directly linked
>> to this series other than by its subject, of course, so I'd rather add a
>> fix on top.
> Thanks and sorry for sending to the improper mail series.
>>> exec /home/haoqf/KVMonz/qemu/tests/qemu-iotests/../../qemu-img info
>>> --image-opts driver=ssh,host=localhost,port=0.42,path=/foo
>>> qemu-img: Could not open
>>> 'driver=ssh,host=localhost,port=0.42,path=/foo': Unknown driver 'ssh'
>>>
>>> Adding 162.notrun can bypass this case but it would skip it even if
>>> qemu-img has sshx block driver, in which case I think it should be run.
>>>
>>> So How about adding a script to dynamically check at runtime if the
>>> current env qemu-img can meet the requirement to run the test or not?
>> Unfortunately, the list of block drivers listed by will not contain ssh
>> if ssh is built as a module, which is possible.
> Actually I am not sure if I understood it. Do you mean
> "CONFIG_LIBSSH2=m" set
> rather than "CONFIG_LIBSSH2=y" in config-host.mak? But in the configure
> it's
> set to be "CONFIG_LIBSSH2=y":
> if test "$libssh2" = "yes" ; then
>   echo "CONFIG_LIBSSH2=y" >> $config_host_mak
>   echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
>   echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak
> fi

I don't know which version of qemu you are looking at, but on master it
says "m" instead of "y" there:

http://git.qemu.org/?p=qemu.git;a=blob;f=configure;h=dd9e6792bbe04411d81eb5438d58eb1999d4dcd2;hb=HEAD#l5477

> Meanwhile I changed it to be "CONFIG_LIBSSH2=m" and reconfig, make the
> qemu,
> qemu-img --help can still prompt ssh.

Have you tried building master with --enable-modules specified for
configure?

Max

>> This is a bug that should be fixed, but I'd rather do so in a separate
>> series from this one.
>>
>> In any case, once it is fixed I'd rather just take the approach quorum
>> tests take already (e.g. test 081), which is something like:
>>
>> test_ssh=$($QEMU_IMG --help | grep '^Supported formats:.* ssh\( \|$\)')
>> [ "$test_ssh" = "" ] && _notrun "ssh support required"
> Cool. Agree with this like what was done in 081.  thanks
>> Max
>>
>
Hao QingFeng Oct. 24, 2016, 6:23 a.m. UTC | #4
在 2016-10-16 1:27, Max Reitz 写道:
> On 13.10.2016 07:20, Hao QingFeng wrote:
>>
>> 在 2016-10-13 3:46, Max Reitz 写道:
>>> On 12.10.2016 10:55, Hao QingFeng wrote:
>>>> Max,
>>>>
>>>> Just a common question for this case, if sshx block driver wasn't built
>>>> into qemu-img, this case would fail as below:
>>> Good point, and thanks for bringing it up, but it's not directly linked
>>> to this series other than by its subject, of course, so I'd rather add a
>>> fix on top.
>> Thanks and sorry for sending to the improper mail series.
>>>> exec /home/haoqf/KVMonz/qemu/tests/qemu-iotests/../../qemu-img info
>>>> --image-opts driver=ssh,host=localhost,port=0.42,path=/foo
>>>> qemu-img: Could not open
>>>> 'driver=ssh,host=localhost,port=0.42,path=/foo': Unknown driver 'ssh'
>>>>
>>>> Adding 162.notrun can bypass this case but it would skip it even if
>>>> qemu-img has sshx block driver, in which case I think it should be run.
>>>>
>>>> So How about adding a script to dynamically check at runtime if the
>>>> current env qemu-img can meet the requirement to run the test or not?
>>> Unfortunately, the list of block drivers listed by will not contain ssh
>>> if ssh is built as a module, which is possible.
>> Actually I am not sure if I understood it. Do you mean
>> "CONFIG_LIBSSH2=m" set
>> rather than "CONFIG_LIBSSH2=y" in config-host.mak? But in the configure
>> it's
>> set to be "CONFIG_LIBSSH2=y":
>> if test "$libssh2" = "yes" ; then
>>    echo "CONFIG_LIBSSH2=y" >> $config_host_mak
>>    echo "LIBSSH2_CFLAGS=$libssh2_cflags" >> $config_host_mak
>>    echo "LIBSSH2_LIBS=$libssh2_libs" >> $config_host_mak
>> fi
> I don't know which version of qemu you are looking at, but on master it
> says "m" instead of "y" there:
>
> http://git.qemu.org/?p=qemu.git;a=blob;f=configure;h=dd9e6792bbe04411d81eb5438d58eb1999d4dcd2;hb=HEAD#l5477
>
>> Meanwhile I changed it to be "CONFIG_LIBSSH2=m" and reconfig, make the
>> qemu,
>> qemu-img --help can still prompt ssh.
> Have you tried building master with --enable-modules specified for
> configure?
You are right, I tried the latest master code(commit 
b49e452fe994f8fbcd2) with
"./configure --target-list=s390x-softmmu --enable-debug --enable-modules 
--enable-libssh2 --prefix=/usr"
and qemu-img --help didn't include the ssh and CONFIG_LIBSSH2=m in 
config-host.mak.
Maybe it was changed in recent code. So how to deal with this case for 
162 or just ignore it now?
thanks!

> Max
>
>>> This is a bug that should be fixed, but I'd rather do so in a separate
>>> series from this one.
>>>
>>> In any case, once it is fixed I'd rather just take the approach quorum
>>> tests take already (e.g. test 081), which is something like:
>>>
>>> test_ssh=$($QEMU_IMG --help | grep '^Supported formats:.* ssh\( \|$\)')
>>> [ "$test_ssh" = "" ] && _notrun "ssh support required"
>> Cool. Agree with this like what was done in 081.  thanks
>>> Max
>>>
>
diff mbox

Patch

diff --git a/tests/qemu-iotests/check b/tests/qemu-iotests/check
index 4cba215..e7ef395 100755
--- a/tests/qemu-iotests/check
+++ b/tests/qemu-iotests/check
@@ -18,7 +18,6 @@ 
  #
  # Control script for QA
  #
-
  status=0
  needwrap=true
  try=0
@@ -291,6 +290,24 @@  do
          start=`_wallclock`
          $timestamp && echo -n "        ["`date "+%T"`"]"

+       check_ret=0
+       if [ -f "$source_iotests/$seq.check" -a -x 
"$source_iotests/$seq.check" ]; then
+           if [ "$(head -n 1 "$source_iotests/$seq.check")" == 
"#!/usr/bin/env python" ]; then
+                $PYTHON $seq.check
+            else
+                ./$seq.check
+           fi
+           check_ret=$?
+       fi
+       if [ $check_ret -ne 0 ]; then
+            $timestamp || echo -n " [not run] "
+            $timestamp && echo " [not run]" && echo -n "        $seq -- "
+           echo "case $seq not applicable!"
+            notrun="$notrun $seq"
+           seq="after_$seq"
+           continue
+       fi
+
          if [ "$(head -n 1 "$source_iotests/$seq")" == "#!/usr/bin/env 
python" ]; then
              run_command="$PYTHON $seq"
          else

diff --git a/tests/qemu-iotests/162.check b/tests/qemu-iotests/162.check
new file mode 100755
index 0000000..a80df7a
--- /dev/null
+++ b/tests/qemu-iotests/162.check
@@ -0,0 +1,35 @@ 
+#!/bin/bash
+#Return 0 if the case can run, others can not
+#Typically the block drivers can be queried by "qemu-img --help" and
+#the output is as:
+#Supported formats: dmg luks ssh sheepdog nbd null-aio null-co 
host_cdrom host_device file blkreplay blkverify blkdebug parallels 
quorum qed qcow2 vvfat vpc bochs cloop vmdk vdi qcow raw
+#set -x
+
+#. ./common.config
+found=0
+. ./common.rc
+. ./common.filter
+#_supported_fmt generic
+#_supported_os Linux
+blk_drivers=`$QEMU_IMG --help|grep "Supported formats:"|sed 
's/Supported formats://'`
+#echo "drivers:"$blk_drivers
+#echo $blk_drivers|awk '{print $0}'
+found=$(
+echo $blk_drivers|awk '{n=split($0, arr_drivers, " ");
+               for(i=1; i<=n; i++) print arr_drivers[i]}' | { while 
read driver
+               do
+                   if [ "$driver"x = "sshx" ]; then
+                       echo 1
+                       exit
+                   fi
+               done
+               echo 0
+       }
+)
+
+#echo "ret:$found"
+if [ "$found" = "1" ]; then