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

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