Blame SOURCES/kvm-iotests-Let-_make_test_img-parse-its-parameters.patch

902636
From 3c96dbd74fb67e2ae1a116b2771290b192041707 Mon Sep 17 00:00:00 2001
902636
From: Eric Blake <eblake@redhat.com>
902636
Date: Tue, 2 Jun 2020 02:34:10 +0100
902636
Subject: [PATCH 05/26] iotests: Let _make_test_img parse its parameters
902636
902636
RH-Author: Eric Blake <eblake@redhat.com>
902636
Message-id: <20200602023420.2133649-3-eblake@redhat.com>
902636
Patchwork-id: 97070
902636
O-Subject: [RHEL-AV-8.2.1 qemu-kvm PATCH 02/12] iotests: Let _make_test_img parse its parameters
902636
Bugzilla: 1779893 1779904
902636
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
902636
RH-Acked-by: Max Reitz <mreitz@redhat.com>
902636
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
902636
902636
From: Max Reitz <mreitz@redhat.com>
902636
902636
This will allow us to add more options than just -b.
902636
902636
Signed-off-by: Max Reitz <mreitz@redhat.com>
902636
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
902636
Message-id: 20191107163708.833192-9-mreitz@redhat.com
902636
Signed-off-by: Max Reitz <mreitz@redhat.com>
902636
(cherry picked from commit eea871d047701b563cfd66c1566b9ff6d163882b)
902636
Signed-off-by: Eric Blake <eblake@redhat.com>
902636
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
902636
---
902636
 tests/qemu-iotests/common.rc | 28 ++++++++++++++++++++--------
902636
 1 file changed, 20 insertions(+), 8 deletions(-)
902636
902636
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
902636
index 0cc8acc..99fef4d 100644
902636
--- a/tests/qemu-iotests/common.rc
902636
+++ b/tests/qemu-iotests/common.rc
902636
@@ -302,12 +302,12 @@ _make_test_img()
902636
     # extra qemu-img options can be added by tests
902636
     # at least one argument (the image size) needs to be added
902636
     local extra_img_options=""
902636
-    local image_size=$*
902636
     local optstr=""
902636
     local img_name=""
902636
     local use_backing=0
902636
     local backing_file=""
902636
     local object_options=""
902636
+    local misc_params=()
902636
 
902636
     if [ -n "$TEST_IMG_FILE" ]; then
902636
         img_name=$TEST_IMG_FILE
902636
@@ -323,11 +323,23 @@ _make_test_img()
902636
         optstr=$(_optstr_add "$optstr" "key-secret=keysec0")
902636
     fi
902636
 
902636
-    if [ "$1" = "-b" ]; then
902636
-        use_backing=1
902636
-        backing_file=$2
902636
-        image_size=$3
902636
-    fi
902636
+    for param; do
902636
+        if [ "$use_backing" = "1" -a -z "$backing_file" ]; then
902636
+            backing_file=$param
902636
+            continue
902636
+        fi
902636
+
902636
+        case "$param" in
902636
+            -b)
902636
+                use_backing=1
902636
+                ;;
902636
+
902636
+            *)
902636
+                misc_params=("${misc_params[@]}" "$param")
902636
+                ;;
902636
+        esac
902636
+    done
902636
+
902636
     if [ \( "$IMGFMT" = "qcow2" -o "$IMGFMT" = "qed" \) -a -n "$CLUSTER_SIZE" ]; then
902636
         optstr=$(_optstr_add "$optstr" "cluster_size=$CLUSTER_SIZE")
902636
     fi
902636
@@ -343,9 +355,9 @@ _make_test_img()
902636
     # XXX(hch): have global image options?
902636
     (
902636
      if [ $use_backing = 1 ]; then
902636
-        $QEMU_IMG create $object_options -f $IMGFMT $extra_img_options -b "$backing_file" "$img_name" $image_size 2>&1
902636
+        $QEMU_IMG create $object_options -f $IMGFMT $extra_img_options -b "$backing_file" "$img_name" "${misc_params[@]}" 2>&1
902636
      else
902636
-        $QEMU_IMG create $object_options -f $IMGFMT $extra_img_options "$img_name" $image_size 2>&1
902636
+        $QEMU_IMG create $object_options -f $IMGFMT $extra_img_options "$img_name" "${misc_params[@]}" 2>&1
902636
      fi
902636
     ) | _filter_img_create
902636
 
902636
-- 
902636
1.8.3.1
902636