* [Qemu-devel] [PATCH] tests: allow qemu-iotests to be run against nbd backend
@ 2012-10-31 14:01 nick
2012-10-31 14:33 ` Paolo Bonzini
0 siblings, 1 reply; 5+ messages in thread
From: nick @ 2012-10-31 14:01 UTC (permalink / raw)
To: qemu-devel; +Cc: kwolf, pbonzini, Nick Thomas
From: Nick Thomas <nick@bytemark.co.uk>
To do this, we start a qemu-nbd process at _make_test_img and kill
it in _cleanup_test_img. $TEST_IMG is changed to point at the TCP
server.
Signed-off-by: Nick Thomas <nick@bytemark.co.uk>
---
tests/qemu-iotests/common | 7 +++++--
tests/qemu-iotests/common.config | 8 +++++++-
tests/qemu-iotests/common.rc | 23 ++++++++++++++++++++++-
3 files changed, 34 insertions(+), 4 deletions(-)
diff --git a/tests/qemu-iotests/common b/tests/qemu-iotests/common
index 1f6fdf5..09dfdf1 100644
--- a/tests/qemu-iotests/common
+++ b/tests/qemu-iotests/common
@@ -136,6 +136,7 @@ check options
-vmdk test vmdk
-rbd test rbd
-sheepdog test sheepdog
+ -nbd test nbd
-xdiff graphical mode diff
-nocache use O_DIRECT on backing file
-misalign misalign memory allocations
@@ -197,12 +198,14 @@ testlist options
IMGPROTO=rbd
xpand=false
;;
-
-sheepdog)
IMGPROTO=sheepdog
xpand=false
;;
-
+ -nbd)
+ IMGPROTO=nbd
+ xpand=false
+ ;;
-nocache)
QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS --nocache"
xpand=false
diff --git a/tests/qemu-iotests/common.config b/tests/qemu-iotests/common.config
index df082e7..5383e4d 100644
--- a/tests/qemu-iotests/common.config
+++ b/tests/qemu-iotests/common.config
@@ -102,9 +102,15 @@ if [ -z "$QEMU_IO_PROG" ]; then
fi
[ "$QEMU_IO_PROG" = "" ] && _fatal "qemu-io not found"
+if [ -z "$QEMU_NBD_PROG" ]; then
+ export QEMU_NBD_PROG="`set_prog_path qemu-nbd`"
+fi
+[ "$QEMU_IO_PROG" = "" ] && _fatal "qemu-io not found"
+
export QEMU=$QEMU_PROG
-export QEMU_IMG=$QEMU_IMG_PROG
+export QEMU_IMG=$QEMU_IMG_PROG
export QEMU_IO="$QEMU_IO_PROG $QEMU_IO_OPTIONS"
+export QEMU_NBD=$QEMU_NBD_PROG
[ -f /etc/qemu-iotest.config ] && . /etc/qemu-iotest.config
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
index 334534f..aef5f52 100644
--- a/tests/qemu-iotests/common.rc
+++ b/tests/qemu-iotests/common.rc
@@ -49,6 +49,9 @@ umask 022
if [ "$IMGPROTO" = "file" ]; then
TEST_IMG=$TEST_DIR/t.$IMGFMT
+elif [ "$IMGPROTO" = "nbd" ]; then
+ TEST_IMG_FILE=$TEST_DIR/t.$IMGFMT
+ TEST_IMG="nbd:127.0.0.1:10810"
else
TEST_IMG=$IMGPROTO:$TEST_DIR/t.$IMGFMT
fi
@@ -86,6 +89,13 @@ _make_test_img()
local extra_img_options=""
local image_size=$*
local optstr=""
+ local img_name=""
+
+ if [ -n "$TEST_IMG_FILE" ]; then
+ img_name=$TEST_IMG_FILE
+ else
+ img_name=$TEST_IMG
+ fi
if [ -n "$IMGOPTS" ]; then
optstr=$(_optstr_add "$optstr" "$IMGOPTS")
@@ -104,7 +114,7 @@ _make_test_img()
fi
# XXX(hch): have global image options?
- $QEMU_IMG create -f $IMGFMT $extra_img_options $TEST_IMG $image_size | \
+ $QEMU_IMG create -f $IMGFMT $extra_img_options $img_name $image_size | \
sed -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \
-e "s#$TEST_DIR#TEST_DIR#g" \
-e "s#$IMGFMT#IMGFMT#g" \
@@ -115,12 +125,23 @@ _make_test_img()
-e "s# compat6=\\(on\\|off\\)##g" \
-e "s# static=\\(on\\|off\\)##g" \
-e "s# lazy_refcounts=\\(on\\|off\\)##g"
+
+ # Start an NBD server on the image file, which is what we'll be talking to
+ if [ $IMGPROTO = "nbd" ]; then
+ eval "$QEMU_NBD -v -t -b 127.0.0.1 -p 10810 $TEST_IMG_FILE &"
+ QEMU_NBD_PID=$!
+ sleep 1 # FIXME: qemu-nbd needs to be listening before we continue
+ fi
}
_cleanup_test_img()
{
case "$IMGPROTO" in
+ nbd)
+ kill $QEMU_NBD_PID
+ rm -f $TEST_IMG_FILE
+ ;;
file)
rm -f $TEST_DIR/t.$IMGFMT
rm -f $TEST_DIR/t.$IMGFMT.orig
--
1.7.2.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] tests: allow qemu-iotests to be run against nbd backend
2012-10-31 14:01 [Qemu-devel] [PATCH] tests: allow qemu-iotests to be run against nbd backend nick
@ 2012-10-31 14:33 ` Paolo Bonzini
2012-10-31 16:44 ` Kevin Wolf
0 siblings, 1 reply; 5+ messages in thread
From: Paolo Bonzini @ 2012-10-31 14:33 UTC (permalink / raw)
To: nick; +Cc: kwolf, qemu-devel
Il 31/10/2012 15:01, nick@bytemark.co.uk ha scritto:
> From: Nick Thomas <nick@bytemark.co.uk>
>
> To do this, we start a qemu-nbd process at _make_test_img and kill
> it in _cleanup_test_img. $TEST_IMG is changed to point at the TCP
> server.
>
> Signed-off-by: Nick Thomas <nick@bytemark.co.uk>
> ---
> tests/qemu-iotests/common | 7 +++++--
> tests/qemu-iotests/common.config | 8 +++++++-
> tests/qemu-iotests/common.rc | 23 ++++++++++++++++++++++-
> 3 files changed, 34 insertions(+), 4 deletions(-)
>
> diff --git a/tests/qemu-iotests/common b/tests/qemu-iotests/common
> index 1f6fdf5..09dfdf1 100644
> --- a/tests/qemu-iotests/common
> +++ b/tests/qemu-iotests/common
> @@ -136,6 +136,7 @@ check options
> -vmdk test vmdk
> -rbd test rbd
> -sheepdog test sheepdog
> + -nbd test nbd
> -xdiff graphical mode diff
> -nocache use O_DIRECT on backing file
> -misalign misalign memory allocations
> @@ -197,12 +198,14 @@ testlist options
> IMGPROTO=rbd
> xpand=false
> ;;
> -
> -sheepdog)
> IMGPROTO=sheepdog
> xpand=false
> ;;
> -
> + -nbd)
> + IMGPROTO=nbd
> + xpand=false
> + ;;
> -nocache)
> QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS --nocache"
> xpand=false
> diff --git a/tests/qemu-iotests/common.config b/tests/qemu-iotests/common.config
> index df082e7..5383e4d 100644
> --- a/tests/qemu-iotests/common.config
> +++ b/tests/qemu-iotests/common.config
> @@ -102,9 +102,15 @@ if [ -z "$QEMU_IO_PROG" ]; then
> fi
> [ "$QEMU_IO_PROG" = "" ] && _fatal "qemu-io not found"
>
> +if [ -z "$QEMU_NBD_PROG" ]; then
> + export QEMU_NBD_PROG="`set_prog_path qemu-nbd`"
> +fi
> +[ "$QEMU_IO_PROG" = "" ] && _fatal "qemu-io not found"
> +
> export QEMU=$QEMU_PROG
> -export QEMU_IMG=$QEMU_IMG_PROG
> +export QEMU_IMG=$QEMU_IMG_PROG
> export QEMU_IO="$QEMU_IO_PROG $QEMU_IO_OPTIONS"
> +export QEMU_NBD=$QEMU_NBD_PROG
>
> [ -f /etc/qemu-iotest.config ] && . /etc/qemu-iotest.config
>
> diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
> index 334534f..aef5f52 100644
> --- a/tests/qemu-iotests/common.rc
> +++ b/tests/qemu-iotests/common.rc
> @@ -49,6 +49,9 @@ umask 022
>
> if [ "$IMGPROTO" = "file" ]; then
> TEST_IMG=$TEST_DIR/t.$IMGFMT
> +elif [ "$IMGPROTO" = "nbd" ]; then
> + TEST_IMG_FILE=$TEST_DIR/t.$IMGFMT
> + TEST_IMG="nbd:127.0.0.1:10810"
> else
> TEST_IMG=$IMGPROTO:$TEST_DIR/t.$IMGFMT
> fi
> @@ -86,6 +89,13 @@ _make_test_img()
> local extra_img_options=""
> local image_size=$*
> local optstr=""
> + local img_name=""
> +
> + if [ -n "$TEST_IMG_FILE" ]; then
> + img_name=$TEST_IMG_FILE
> + else
> + img_name=$TEST_IMG
> + fi
>
> if [ -n "$IMGOPTS" ]; then
> optstr=$(_optstr_add "$optstr" "$IMGOPTS")
> @@ -104,7 +114,7 @@ _make_test_img()
> fi
>
> # XXX(hch): have global image options?
> - $QEMU_IMG create -f $IMGFMT $extra_img_options $TEST_IMG $image_size | \
> + $QEMU_IMG create -f $IMGFMT $extra_img_options $img_name $image_size | \
> sed -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \
> -e "s#$TEST_DIR#TEST_DIR#g" \
> -e "s#$IMGFMT#IMGFMT#g" \
> @@ -115,12 +125,23 @@ _make_test_img()
> -e "s# compat6=\\(on\\|off\\)##g" \
> -e "s# static=\\(on\\|off\\)##g" \
> -e "s# lazy_refcounts=\\(on\\|off\\)##g"
> +
> + # Start an NBD server on the image file, which is what we'll be talking to
> + if [ $IMGPROTO = "nbd" ]; then
> + eval "$QEMU_NBD -v -t -b 127.0.0.1 -p 10810 $TEST_IMG_FILE &"
> + QEMU_NBD_PID=$!
> + sleep 1 # FIXME: qemu-nbd needs to be listening before we continue
> + fi
> }
>
> _cleanup_test_img()
> {
> case "$IMGPROTO" in
>
> + nbd)
> + kill $QEMU_NBD_PID
> + rm -f $TEST_IMG_FILE
> + ;;
> file)
> rm -f $TEST_DIR/t.$IMGFMT
> rm -f $TEST_DIR/t.$IMGFMT.orig
>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Paolo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] tests: allow qemu-iotests to be run against nbd backend
2012-10-31 14:33 ` Paolo Bonzini
@ 2012-10-31 16:44 ` Kevin Wolf
2012-11-01 11:30 ` Nicholas Thomas
0 siblings, 1 reply; 5+ messages in thread
From: Kevin Wolf @ 2012-10-31 16:44 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: qemu-devel, nick
Am 31.10.2012 15:33, schrieb Paolo Bonzini:
> Il 31/10/2012 15:01, nick@bytemark.co.uk ha scritto:
>> From: Nick Thomas <nick@bytemark.co.uk>
>>
>> To do this, we start a qemu-nbd process at _make_test_img and kill
>> it in _cleanup_test_img. $TEST_IMG is changed to point at the TCP
>> server.
>>
>> Signed-off-by: Nick Thomas <nick@bytemark.co.uk>
>> ---
>> tests/qemu-iotests/common | 7 +++++--
>> tests/qemu-iotests/common.config | 8 +++++++-
>> tests/qemu-iotests/common.rc | 23 ++++++++++++++++++++++-
>> 3 files changed, 34 insertions(+), 4 deletions(-)
>>
>> diff --git a/tests/qemu-iotests/common b/tests/qemu-iotests/common
>> index 1f6fdf5..09dfdf1 100644
>> --- a/tests/qemu-iotests/common
>> +++ b/tests/qemu-iotests/common
>> @@ -136,6 +136,7 @@ check options
>> -vmdk test vmdk
>> -rbd test rbd
>> -sheepdog test sheepdog
>> + -nbd test nbd
>> -xdiff graphical mode diff
>> -nocache use O_DIRECT on backing file
>> -misalign misalign memory allocations
>> @@ -197,12 +198,14 @@ testlist options
>> IMGPROTO=rbd
>> xpand=false
>> ;;
>> -
>> -sheepdog)
>> IMGPROTO=sheepdog
>> xpand=false
>> ;;
>> -
>> + -nbd)
>> + IMGPROTO=nbd
>> + xpand=false
>> + ;;
>> -nocache)
>> QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS --nocache"
>> xpand=false
>> diff --git a/tests/qemu-iotests/common.config b/tests/qemu-iotests/common.config
>> index df082e7..5383e4d 100644
>> --- a/tests/qemu-iotests/common.config
>> +++ b/tests/qemu-iotests/common.config
>> @@ -102,9 +102,15 @@ if [ -z "$QEMU_IO_PROG" ]; then
>> fi
>> [ "$QEMU_IO_PROG" = "" ] && _fatal "qemu-io not found"
>>
>> +if [ -z "$QEMU_NBD_PROG" ]; then
>> + export QEMU_NBD_PROG="`set_prog_path qemu-nbd`"
>> +fi
>> +[ "$QEMU_IO_PROG" = "" ] && _fatal "qemu-io not found"
I think you intended to check $QEMU_NBD_PROG.
It would be nice to require it only if we're really using NBD, is this
already known at this place?
Kevin
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] tests: allow qemu-iotests to be run against nbd backend
2012-10-31 16:44 ` Kevin Wolf
@ 2012-11-01 11:30 ` Nicholas Thomas
2012-11-02 9:10 ` Kevin Wolf
0 siblings, 1 reply; 5+ messages in thread
From: Nicholas Thomas @ 2012-11-01 11:30 UTC (permalink / raw)
To: Kevin Wolf; +Cc: Paolo Bonzini, qemu-devel
On Wed, 2012-10-31 at 17:44 +0100, Kevin Wolf wrote:
> Am 31.10.2012 15:33, schrieb Paolo Bonzini:
> > Il 31/10/2012 15:01, nick@bytemark.co.uk ha scritto:
> >> From: Nick Thomas <nick@bytemark.co.uk>
> >>
> >> To do this, we start a qemu-nbd process at _make_test_img and kill
> >> it in _cleanup_test_img. $TEST_IMG is changed to point at the TCP
> >> server.
> >>
> >> Signed-off-by: Nick Thomas <nick@bytemark.co.uk>
> >> ---
> >> tests/qemu-iotests/common | 7 +++++--
> >> tests/qemu-iotests/common.config | 8 +++++++-
> >> tests/qemu-iotests/common.rc | 23 ++++++++++++++++++++++-
> >> 3 files changed, 34 insertions(+), 4 deletions(-)
> >>
> >> diff --git a/tests/qemu-iotests/common b/tests/qemu-iotests/common
> >> index 1f6fdf5..09dfdf1 100644
> >> --- a/tests/qemu-iotests/common
> >> +++ b/tests/qemu-iotests/common
> >> @@ -136,6 +136,7 @@ check options
> >> -vmdk test vmdk
> >> -rbd test rbd
> >> -sheepdog test sheepdog
> >> + -nbd test nbd
> >> -xdiff graphical mode diff
> >> -nocache use O_DIRECT on backing file
> >> -misalign misalign memory allocations
> >> @@ -197,12 +198,14 @@ testlist options
> >> IMGPROTO=rbd
> >> xpand=false
> >> ;;
> >> -
> >> -sheepdog)
> >> IMGPROTO=sheepdog
> >> xpand=false
> >> ;;
> >> -
> >> + -nbd)
> >> + IMGPROTO=nbd
> >> + xpand=false
> >> + ;;
> >> -nocache)
> >> QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS --nocache"
> >> xpand=false
> >> diff --git a/tests/qemu-iotests/common.config b/tests/qemu-iotests/common.config
> >> index df082e7..5383e4d 100644
> >> --- a/tests/qemu-iotests/common.config
> >> +++ b/tests/qemu-iotests/common.config
> >> @@ -102,9 +102,15 @@ if [ -z "$QEMU_IO_PROG" ]; then
> >> fi
> >> [ "$QEMU_IO_PROG" = "" ] && _fatal "qemu-io not found"
> >>
> >> +if [ -z "$QEMU_NBD_PROG" ]; then
> >> + export QEMU_NBD_PROG="`set_prog_path qemu-nbd`"
> >> +fi
> >> +[ "$QEMU_IO_PROG" = "" ] && _fatal "qemu-io not found"
>
> I think you intended to check $QEMU_NBD_PROG.
Good catch, thanks.
> It would be nice to require it only if we're really using NBD, is this
> already known at this place?
$IMGPROTO is how we'd discriminate, and that's set in
qemu-iotests/common, which is sourced after qemu-iotests/common.config,
at least by qemu-iotests/check.
There's actually a similar set of tests in common (where we *do* have
$IMGPROTO), so maybe the ones in common.config are unnecessary, and can
be removed?
/Nick
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH] tests: allow qemu-iotests to be run against nbd backend
2012-11-01 11:30 ` Nicholas Thomas
@ 2012-11-02 9:10 ` Kevin Wolf
0 siblings, 0 replies; 5+ messages in thread
From: Kevin Wolf @ 2012-11-02 9:10 UTC (permalink / raw)
To: Nicholas Thomas; +Cc: Paolo Bonzini, qemu-devel
Am 01.11.2012 12:30, schrieb Nicholas Thomas:
> On Wed, 2012-10-31 at 17:44 +0100, Kevin Wolf wrote:
>> Am 31.10.2012 15:33, schrieb Paolo Bonzini:
>>> Il 31/10/2012 15:01, nick@bytemark.co.uk ha scritto:
>>>> From: Nick Thomas <nick@bytemark.co.uk>
>>>>
>>>> To do this, we start a qemu-nbd process at _make_test_img and kill
>>>> it in _cleanup_test_img. $TEST_IMG is changed to point at the TCP
>>>> server.
>>>>
>>>> Signed-off-by: Nick Thomas <nick@bytemark.co.uk>
>>>> ---
>>>> tests/qemu-iotests/common | 7 +++++--
>>>> tests/qemu-iotests/common.config | 8 +++++++-
>>>> tests/qemu-iotests/common.rc | 23 ++++++++++++++++++++++-
>>>> 3 files changed, 34 insertions(+), 4 deletions(-)
>>>>
>>>> diff --git a/tests/qemu-iotests/common b/tests/qemu-iotests/common
>>>> index 1f6fdf5..09dfdf1 100644
>>>> --- a/tests/qemu-iotests/common
>>>> +++ b/tests/qemu-iotests/common
>>>> @@ -136,6 +136,7 @@ check options
>>>> -vmdk test vmdk
>>>> -rbd test rbd
>>>> -sheepdog test sheepdog
>>>> + -nbd test nbd
>>>> -xdiff graphical mode diff
>>>> -nocache use O_DIRECT on backing file
>>>> -misalign misalign memory allocations
>>>> @@ -197,12 +198,14 @@ testlist options
>>>> IMGPROTO=rbd
>>>> xpand=false
>>>> ;;
>>>> -
>>>> -sheepdog)
>>>> IMGPROTO=sheepdog
>>>> xpand=false
>>>> ;;
>>>> -
>>>> + -nbd)
>>>> + IMGPROTO=nbd
>>>> + xpand=false
>>>> + ;;
>>>> -nocache)
>>>> QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS --nocache"
>>>> xpand=false
>>>> diff --git a/tests/qemu-iotests/common.config b/tests/qemu-iotests/common.config
>>>> index df082e7..5383e4d 100644
>>>> --- a/tests/qemu-iotests/common.config
>>>> +++ b/tests/qemu-iotests/common.config
>>>> @@ -102,9 +102,15 @@ if [ -z "$QEMU_IO_PROG" ]; then
>>>> fi
>>>> [ "$QEMU_IO_PROG" = "" ] && _fatal "qemu-io not found"
>>>>
>>>> +if [ -z "$QEMU_NBD_PROG" ]; then
>>>> + export QEMU_NBD_PROG="`set_prog_path qemu-nbd`"
>>>> +fi
>>>> +[ "$QEMU_IO_PROG" = "" ] && _fatal "qemu-io not found"
>>
>> I think you intended to check $QEMU_NBD_PROG.
>
> Good catch, thanks.
>
>> It would be nice to require it only if we're really using NBD, is this
>> already known at this place?
>
> $IMGPROTO is how we'd discriminate, and that's set in
> qemu-iotests/common, which is sourced after qemu-iotests/common.config,
> at least by qemu-iotests/check.
>
> There's actually a similar set of tests in common (where we *do* have
> $IMGPROTO), so maybe the ones in common.config are unnecessary, and can
> be removed?
Hm, yes, I think so.
And when you touch common to add a qemu-nbd check, you can fix the
message for qemu-io, too:
[ "$QEMU_IO" = "" ] && _fatal "qemu-img not found"
Kevin
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-11-02 9:11 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-31 14:01 [Qemu-devel] [PATCH] tests: allow qemu-iotests to be run against nbd backend nick
2012-10-31 14:33 ` Paolo Bonzini
2012-10-31 16:44 ` Kevin Wolf
2012-11-01 11:30 ` Nicholas Thomas
2012-11-02 9:10 ` Kevin Wolf
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.