9ae3a8
From 2235c9a514307669f458b5490f127c6e11989a99 Mon Sep 17 00:00:00 2001
9ae3a8
From: Jeffrey Cody <jcody@redhat.com>
9ae3a8
Date: Wed, 20 Nov 2013 19:43:46 +0100
9ae3a8
Subject: [PATCH 03/25] block: qemu-iotests, fix _make_test_img() to work with spaced pathnames
9ae3a8
9ae3a8
RH-Author: Jeffrey Cody <jcody@redhat.com>
9ae3a8
Message-id: <4c889b5de385100b5406f2cab6dfffd04936e666.1384975172.git.jcody@redhat.com>
9ae3a8
Patchwork-id: 55796
9ae3a8
O-Subject: [RHEL7 qemu-kvm PATCH 03/26] block: qemu-iotests, fix _make_test_img() to work with spaced pathnames
9ae3a8
Bugzilla: 879234
9ae3a8
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
RH-Acked-by: Fam Zheng <famz@redhat.com>
9ae3a8
9ae3a8
_make_test_img() currently works with spaced pathnames only when not
9ae3a8
specifying a backing file.  This fixes it so that the backing file
9ae3a8
argument is properly quoted.
9ae3a8
9ae3a8
Signed-off-by: Jeff Cody <jcody@redhat.com>
9ae3a8
Reviewed-by: Eric Blake <eblake@redhat.com>
9ae3a8
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
(cherry picked from commit 0018c03f5d37f3a7df23eef0e9f1e6e6189ed634)
9ae3a8
---
9ae3a8
 tests/qemu-iotests/common.rc | 13 +++++++++++--
9ae3a8
 1 file changed, 11 insertions(+), 2 deletions(-)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 tests/qemu-iotests/common.rc |   13 +++++++++++--
9ae3a8
 1 files changed, 11 insertions(+), 2 deletions(-)
9ae3a8
9ae3a8
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
9ae3a8
index 4e82604..d24de2c 100644
9ae3a8
--- a/tests/qemu-iotests/common.rc
9ae3a8
+++ b/tests/qemu-iotests/common.rc
9ae3a8
@@ -111,6 +111,8 @@ _make_test_img()
9ae3a8
     local image_size=$*
9ae3a8
     local optstr=""
9ae3a8
     local img_name=""
9ae3a8
+    local use_backing=0
9ae3a8
+    local backing_file=""
9ae3a8
 
9ae3a8
     if [ -n "$TEST_IMG_FILE" ]; then
9ae3a8
         img_name=$TEST_IMG_FILE
9ae3a8
@@ -123,7 +125,8 @@ _make_test_img()
9ae3a8
     fi
9ae3a8
 
9ae3a8
     if [ "$1" = "-b" ]; then
9ae3a8
-        extra_img_options="$1 $2"
9ae3a8
+        use_backing=1
9ae3a8
+        backing_file=$2
9ae3a8
         image_size=$3
9ae3a8
     fi
9ae3a8
     if [ \( "$IMGFMT" = "qcow2" -o "$IMGFMT" = "qed" \) -a -n "$CLUSTER_SIZE" ]; then
9ae3a8
@@ -135,7 +138,13 @@ _make_test_img()
9ae3a8
     fi
9ae3a8
 
9ae3a8
     # XXX(hch): have global image options?
9ae3a8
-    $QEMU_IMG create -f $IMGFMT $extra_img_options $img_name $image_size 2>&1 | \
9ae3a8
+    (
9ae3a8
+     if [ $use_backing = 1 ]; then
9ae3a8
+        $QEMU_IMG create -f $IMGFMT $extra_img_options -b "$backing_file" "$img_name" $image_size 2>&1
9ae3a8
+     else
9ae3a8
+        $QEMU_IMG create -f $IMGFMT $extra_img_options "$img_name" $image_size 2>&1
9ae3a8
+     fi
9ae3a8
+    ) | \
9ae3a8
         sed -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \
9ae3a8
             -e "s#$TEST_DIR#TEST_DIR#g" \
9ae3a8
             -e "s#$IMGFMT#IMGFMT#g" \
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8