thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

Blame SOURCES/kvm-qemu-iotests-Discard-specific-info-in-_img_info.patch

218e99
From 9fe83d3e480a74024150774c38373122084dfe10 Mon Sep 17 00:00:00 2001
218e99
From: Max Reitz <mreitz@redhat.com>
218e99
Date: Wed, 6 Nov 2013 16:53:38 +0100
218e99
Subject: [PATCH 81/87] qemu-iotests: Discard specific info in _img_info
218e99
218e99
RH-Author: Max Reitz <mreitz@redhat.com>
218e99
Message-id: <1383756824-6921-16-git-send-email-mreitz@redhat.com>
218e99
Patchwork-id: 55570
218e99
O-Subject: [RHEL-7.0 qemu-kvm PATCH v2 15/21] qemu-iotests: Discard specific info in _img_info
218e99
Bugzilla: 980771
218e99
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
218e99
RH-Acked-by: Fam Zheng <famz@redhat.com>
218e99
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
218e99
218e99
BZ: 980771
218e99
218e99
In _img_info, filter out additional information specific to the image
218e99
format provided by qemu-img info, since tests designed for multiple
218e99
image formats would produce different outputs for every image format
218e99
otherwise.
218e99
218e99
In a human-readable dump, that new information will always be last for
218e99
each "image information block" (multiple blocks are emitted when
218e99
inspecting the backing file chain). Every block is separated by an empty
218e99
line. Therefore, in this case, everything starting with the line "Format
218e99
specific information:" up to that empty line (or EOF, if it is the last
218e99
block) has to be stripped.
218e99
218e99
The JSON dump will always emit pretty JSON data. Therefore, the opening
218e99
and closing braces of every object will be on lines which are indented
218e99
by exactly the same amount, and all lines in between will have more
218e99
indentation. Thus, in this case, everything starting with a line
218e99
matching the regular expression /^ *"format-specific": {/ until /^ *},?/
218e99
has to be stripped, where the number of spaces at the beginning of the
218e99
respective lines is equal.
218e99
218e99
Signed-off-by: Max Reitz <mreitz@redhat.com>
218e99
Reviewed-by: Eric Blake <eblake@redhat.com>
218e99
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
218e99
(cherry picked from commit 4c2e946500c45685fdec61b3d929311dc26a2ad5)
218e99
218e99
Signed-off-by: Max Reitz <mreitz@redhat.com>
218e99
---
218e99
 tests/qemu-iotests/common.rc | 20 +++++++++++++++++++-
218e99
 1 file changed, 19 insertions(+), 1 deletion(-)
218e99
218e99
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
218e99
---
218e99
 tests/qemu-iotests/common.rc |   20 +++++++++++++++++++-
218e99
 1 files changed, 19 insertions(+), 1 deletions(-)
218e99
218e99
diff --git a/tests/qemu-iotests/common.rc b/tests/qemu-iotests/common.rc
218e99
index 1b22db0..227c003 100644
218e99
--- a/tests/qemu-iotests/common.rc
218e99
+++ b/tests/qemu-iotests/common.rc
218e99
@@ -197,12 +197,30 @@ _check_test_img()
218e99
 
218e99
 _img_info()
218e99
 {
218e99
+    discard=0
218e99
+    regex_json_spec_start='^ *"format-specific": \{'
218e99
     $QEMU_IMG info "$@" "$TEST_IMG" 2>&1 | \
218e99
         sed -e "s#$IMGPROTO:$TEST_DIR#TEST_DIR#g" \
218e99
             -e "s#$TEST_DIR#TEST_DIR#g" \
218e99
             -e "s#$IMGFMT#IMGFMT#g" \
218e99
             -e "/^disk size:/ D" \
218e99
-            -e "/actual-size/ D"
218e99
+            -e "/actual-size/ D" | \
218e99
+        while IFS='' read line; do
218e99
+            if [[ $line == "Format specific information:" ]]; then
218e99
+                discard=1
218e99
+            elif [[ $line =~ $regex_json_spec_start ]]; then
218e99
+                discard=2
218e99
+                regex_json_spec_end="^${line%%[^ ]*}\\},? *$"
218e99
+            fi
218e99
+            if [[ $discard == 0 ]]; then
218e99
+                echo "$line"
218e99
+            elif [[ $discard == 1 && ! $line ]]; then
218e99
+                echo
218e99
+                discard=0
218e99
+            elif [[ $discard == 2 && $line =~ $regex_json_spec_end ]]; then
218e99
+                discard=0
218e99
+            fi
218e99
+        done
218e99
 }
218e99
 
218e99
 _get_pids_by_name()
218e99
-- 
218e99
1.7.1
218e99