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

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