Blame SOURCES/kvm-qemu-iotests-Test-change-backing-file-command.patch

4a2fec
From f3eb0c097a879c9bc80a5a2589560b7ebde3720b Mon Sep 17 00:00:00 2001
4a2fec
From: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
Date: Tue, 5 Dec 2017 10:26:10 +0100
4a2fec
Subject: [PATCH 35/36] qemu-iotests: Test change-backing-file command
4a2fec
4a2fec
RH-Author: Kevin Wolf <kwolf@redhat.com>
4a2fec
Message-id: <20171204121007.12964-8-kwolf@redhat.com>
4a2fec
Patchwork-id: 78111
4a2fec
O-Subject: [RHV-7.5 qemu-kvm-rhev PATCH v2 7/8] qemu-iotests: Test change-backing-file command
4a2fec
Bugzilla: 1492178
4a2fec
RH-Acked-by: Fam Zheng <famz@redhat.com>
4a2fec
RH-Acked-by: Max Reitz <mreitz@redhat.com>
4a2fec
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
4a2fec
4a2fec
This involves a temporary read-write reopen if the backing file link in
4a2fec
the middle of a backing file chain should be changed and is therefore a
4a2fec
good test for the latest bdrv_reopen() vs. op blockers fixes.
4a2fec
4a2fec
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
4a2fec
(cherry picked from commit 3fb23e07516aae13d1ba566740c1c81ae12184b7)
4a2fec
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4a2fec
---
4a2fec
 tests/qemu-iotests/195     | 92 ++++++++++++++++++++++++++++++++++++++++++++++
4a2fec
 tests/qemu-iotests/195.out | 78 +++++++++++++++++++++++++++++++++++++++
4a2fec
 tests/qemu-iotests/group   |  1 +
4a2fec
 3 files changed, 171 insertions(+)
4a2fec
 create mode 100644 tests/qemu-iotests/195
4a2fec
 create mode 100644 tests/qemu-iotests/195.out
4a2fec
4a2fec
diff --git a/tests/qemu-iotests/195 b/tests/qemu-iotests/195
4a2fec
new file mode 100644
4a2fec
index 0000000..05a239c
4a2fec
--- /dev/null
4a2fec
+++ b/tests/qemu-iotests/195
4a2fec
@@ -0,0 +1,92 @@
4a2fec
+#!/bin/bash
4a2fec
+#
4a2fec
+# Test change-backing-file command
4a2fec
+#
4a2fec
+# Copyright (C) 2017 Red Hat, Inc.
4a2fec
+#
4a2fec
+# This program is free software; you can redistribute it and/or modify
4a2fec
+# it under the terms of the GNU General Public License as published by
4a2fec
+# the Free Software Foundation; either version 2 of the License, or
4a2fec
+# (at your option) any later version.
4a2fec
+#
4a2fec
+# This program is distributed in the hope that it will be useful,
4a2fec
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
4a2fec
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
4a2fec
+# GNU General Public License for more details.
4a2fec
+#
4a2fec
+# You should have received a copy of the GNU General Public License
4a2fec
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
4a2fec
+#
4a2fec
+
4a2fec
+# creator
4a2fec
+owner=kwolf@redhat.com
4a2fec
+
4a2fec
+seq=`basename $0`
4a2fec
+echo "QA output created by $seq"
4a2fec
+
4a2fec
+here=`pwd`
4a2fec
+status=1 # failure is the default!
4a2fec
+
4a2fec
+_cleanup()
4a2fec
+{
4a2fec
+    _cleanup_test_img
4a2fec
+    rm -f "$TEST_IMG.mid"
4a2fec
+}
4a2fec
+trap "_cleanup; exit \$status" 0 1 2 3 15
4a2fec
+
4a2fec
+# get standard environment, filters and checks
4a2fec
+. ./common.rc
4a2fec
+. ./common.filter
4a2fec
+
4a2fec
+_supported_fmt qcow2
4a2fec
+_supported_proto file
4a2fec
+_supported_os Linux
4a2fec
+
4a2fec
+function do_run_qemu()
4a2fec
+{
4a2fec
+    echo Testing: "$@" | _filter_imgfmt
4a2fec
+    $QEMU -nographic -qmp-pretty stdio -serial none "$@"
4a2fec
+    echo
4a2fec
+}
4a2fec
+
4a2fec
+function run_qemu()
4a2fec
+{
4a2fec
+    do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qemu | _filter_qmp \
4a2fec
+                          | _filter_qemu_io | _filter_generated_node_ids
4a2fec
+}
4a2fec
+
4a2fec
+size=64M
4a2fec
+TEST_IMG="$TEST_IMG.base" _make_test_img $size
4a2fec
+TEST_IMG="$TEST_IMG.mid" _make_test_img -b "$TEST_IMG.base"
4a2fec
+_make_test_img -b "$TEST_IMG.mid"
4a2fec
+
4a2fec
+echo
4a2fec
+echo "Change backing file of mid (opened read-only)"
4a2fec
+echo
4a2fec
+
4a2fec
+run_qemu -drive if=none,file="$TEST_IMG",backing.node-name=mid <
4a2fec
+{"execute":"qmp_capabilities"}
4a2fec
+{"execute":"change-backing-file", "arguments":{"device":"none0","image-node-name":"mid","backing-file":"/dev/null"}}
4a2fec
+{"execute":"quit"}
4a2fec
+EOF
4a2fec
+
4a2fec
+TEST_IMG="$TEST_IMG.mid" _img_info
4a2fec
+
4a2fec
+echo
4a2fec
+echo "Change backing file of top (opened writable)"
4a2fec
+echo
4a2fec
+
4a2fec
+TEST_IMG="$TEST_IMG.mid" _make_test_img -b "$TEST_IMG.base"
4a2fec
+
4a2fec
+run_qemu -drive if=none,file="$TEST_IMG",node-name=top <
4a2fec
+{"execute":"qmp_capabilities"}
4a2fec
+{"execute":"change-backing-file", "arguments":{"device":"none0","image-node-name":"top","backing-file":"/dev/null"}}
4a2fec
+{"execute":"quit"}
4a2fec
+EOF
4a2fec
+
4a2fec
+_img_info
4a2fec
+
4a2fec
+# success, all done
4a2fec
+echo "*** done"
4a2fec
+rm -f $seq.full
4a2fec
+status=0
4a2fec
diff --git a/tests/qemu-iotests/195.out b/tests/qemu-iotests/195.out
4a2fec
new file mode 100644
4a2fec
index 0000000..7613575
4a2fec
--- /dev/null
4a2fec
+++ b/tests/qemu-iotests/195.out
4a2fec
@@ -0,0 +1,78 @@
4a2fec
+QA output created by 195
4a2fec
+Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=67108864
4a2fec
+Formatting 'TEST_DIR/t.IMGFMT.mid', fmt=IMGFMT size=67108864 backing_file=TEST_DIR/t.IMGFMT.base
4a2fec
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 backing_file=TEST_DIR/t.IMGFMT.mid
4a2fec
+
4a2fec
+Change backing file of mid (opened read-only)
4a2fec
+
4a2fec
+Testing: -drive if=none,file=TEST_DIR/t.IMGFMT,backing.node-name=mid
4a2fec
+{
4a2fec
+    QMP_VERSION
4a2fec
+}
4a2fec
+{
4a2fec
+    "return": {
4a2fec
+    }
4a2fec
+}
4a2fec
+{
4a2fec
+    "return": {
4a2fec
+    }
4a2fec
+}
4a2fec
+{
4a2fec
+    "return": {
4a2fec
+    }
4a2fec
+}
4a2fec
+{
4a2fec
+    "timestamp": {
4a2fec
+        "seconds":  TIMESTAMP,
4a2fec
+        "microseconds":  TIMESTAMP
4a2fec
+    },
4a2fec
+    "event": "SHUTDOWN",
4a2fec
+    "data": {
4a2fec
+        "guest": false
4a2fec
+    }
4a2fec
+}
4a2fec
+
4a2fec
+image: TEST_DIR/t.IMGFMT.mid
4a2fec
+file format: IMGFMT
4a2fec
+virtual size: 64M (67108864 bytes)
4a2fec
+cluster_size: 65536
4a2fec
+backing file: /dev/null
4a2fec
+backing file format: IMGFMT
4a2fec
+
4a2fec
+Change backing file of top (opened writable)
4a2fec
+
4a2fec
+Formatting 'TEST_DIR/t.IMGFMT.mid', fmt=IMGFMT size=67108864 backing_file=TEST_DIR/t.IMGFMT.base
4a2fec
+Testing: -drive if=none,file=TEST_DIR/t.IMGFMT,node-name=top
4a2fec
+{
4a2fec
+    QMP_VERSION
4a2fec
+}
4a2fec
+{
4a2fec
+    "return": {
4a2fec
+    }
4a2fec
+}
4a2fec
+{
4a2fec
+    "return": {
4a2fec
+    }
4a2fec
+}
4a2fec
+{
4a2fec
+    "return": {
4a2fec
+    }
4a2fec
+}
4a2fec
+{
4a2fec
+    "timestamp": {
4a2fec
+        "seconds":  TIMESTAMP,
4a2fec
+        "microseconds":  TIMESTAMP
4a2fec
+    },
4a2fec
+    "event": "SHUTDOWN",
4a2fec
+    "data": {
4a2fec
+        "guest": false
4a2fec
+    }
4a2fec
+}
4a2fec
+
4a2fec
+image: TEST_DIR/t.IMGFMT
4a2fec
+file format: IMGFMT
4a2fec
+virtual size: 64M (67108864 bytes)
4a2fec
+cluster_size: 65536
4a2fec
+backing file: /dev/null
4a2fec
+backing file format: IMGFMT
4a2fec
+*** done
4a2fec
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
4a2fec
index 13760b3..491a5f5 100644
4a2fec
--- a/tests/qemu-iotests/group
4a2fec
+++ b/tests/qemu-iotests/group
4a2fec
@@ -188,4 +188,5 @@
4a2fec
 190 rw auto quick
4a2fec
 192 rw auto quick
4a2fec
 194 rw auto migration quick
4a2fec
+195 rw auto quick
4a2fec
 198 rw auto
4a2fec
-- 
4a2fec
1.8.3.1
4a2fec