mirror of https://github.com/xemu-project/xemu.git
iotests: Let _make_test_img parse its parameters
This will allow us to add more options than just -b. Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com> Message-id: 20191107163708.833192-9-mreitz@redhat.com Signed-off-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
parent
8d1c81379c
commit
eea871d047
|
@ -303,12 +303,12 @@ _make_test_img()
|
||||||
# extra qemu-img options can be added by tests
|
# extra qemu-img options can be added by tests
|
||||||
# at least one argument (the image size) needs to be added
|
# at least one argument (the image size) needs to be added
|
||||||
local extra_img_options=""
|
local extra_img_options=""
|
||||||
local image_size=$*
|
|
||||||
local optstr=""
|
local optstr=""
|
||||||
local img_name=""
|
local img_name=""
|
||||||
local use_backing=0
|
local use_backing=0
|
||||||
local backing_file=""
|
local backing_file=""
|
||||||
local object_options=""
|
local object_options=""
|
||||||
|
local misc_params=()
|
||||||
|
|
||||||
if [ -n "$TEST_IMG_FILE" ]; then
|
if [ -n "$TEST_IMG_FILE" ]; then
|
||||||
img_name=$TEST_IMG_FILE
|
img_name=$TEST_IMG_FILE
|
||||||
|
@ -324,11 +324,23 @@ _make_test_img()
|
||||||
optstr=$(_optstr_add "$optstr" "key-secret=keysec0")
|
optstr=$(_optstr_add "$optstr" "key-secret=keysec0")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$1" = "-b" ]; then
|
for param; do
|
||||||
use_backing=1
|
if [ "$use_backing" = "1" -a -z "$backing_file" ]; then
|
||||||
backing_file=$2
|
backing_file=$param
|
||||||
image_size=$3
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
case "$param" in
|
||||||
|
-b)
|
||||||
|
use_backing=1
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
misc_params=("${misc_params[@]}" "$param")
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
if [ \( "$IMGFMT" = "qcow2" -o "$IMGFMT" = "qed" \) -a -n "$CLUSTER_SIZE" ]; then
|
if [ \( "$IMGFMT" = "qcow2" -o "$IMGFMT" = "qed" \) -a -n "$CLUSTER_SIZE" ]; then
|
||||||
optstr=$(_optstr_add "$optstr" "cluster_size=$CLUSTER_SIZE")
|
optstr=$(_optstr_add "$optstr" "cluster_size=$CLUSTER_SIZE")
|
||||||
fi
|
fi
|
||||||
|
@ -344,9 +356,9 @@ _make_test_img()
|
||||||
# XXX(hch): have global image options?
|
# XXX(hch): have global image options?
|
||||||
(
|
(
|
||||||
if [ $use_backing = 1 ]; then
|
if [ $use_backing = 1 ]; then
|
||||||
$QEMU_IMG create $object_options -f $IMGFMT $extra_img_options -b "$backing_file" "$img_name" $image_size 2>&1
|
$QEMU_IMG create $object_options -f $IMGFMT $extra_img_options -b "$backing_file" "$img_name" "${misc_params[@]}" 2>&1
|
||||||
else
|
else
|
||||||
$QEMU_IMG create $object_options -f $IMGFMT $extra_img_options "$img_name" $image_size 2>&1
|
$QEMU_IMG create $object_options -f $IMGFMT $extra_img_options "$img_name" "${misc_params[@]}" 2>&1
|
||||||
fi
|
fi
|
||||||
) | _filter_img_create
|
) | _filter_img_create
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue