0a122b
From 36be200f11e87ccd97a54236550be41bc3ec6862 Mon Sep 17 00:00:00 2001
0a122b
From: Max Reitz <mreitz@redhat.com>
0a122b
Date: Thu, 9 Jan 2014 09:11:13 +0100
0a122b
Subject: [PATCH 03/14] qemu-iotests: Snapshotting zero clusters
0a122b
0a122b
Message-id: <1389131839-12920-4-git-send-email-mreitz@redhat.com>
0a122b
Patchwork-id: 56539
0a122b
O-Subject: [RHEL-7.0 qemu-kvm PATCH v2 03/14] qemu-iotests: Snapshotting zero clusters
0a122b
Bugzilla: 1033490
0a122b
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
0a122b
RH-Acked-by: Fam Zheng <famz@redhat.com>
0a122b
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
0a122b
0a122b
BZ: 1033490
0a122b
0a122b
This test creates an image with unallocated zero clusters, then creates
0a122b
a snapshot. Afterwards, there should be neither any errors nor leaks.
0a122b
0a122b
Signed-off-by: Max Reitz <mreitz@redhat.com>
0a122b
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
0a122b
(cherry picked from commit 449df7063815489a0b091bcb3afa9ae80ae3acbf)
0a122b
0a122b
Signed-off-by: Max Reitz <mreitz@redhat.com>
0a122b
0a122b
Conflicts:
0a122b
	tests/qemu-iotests/group
0a122b
---
0a122b
 tests/qemu-iotests/062     | 64 ++++++++++++++++++++++++++++++++++++++++++++++
0a122b
 tests/qemu-iotests/062.out |  9 +++++++
0a122b
 tests/qemu-iotests/group   |  1 +
0a122b
 3 files changed, 74 insertions(+)
0a122b
 create mode 100755 tests/qemu-iotests/062
0a122b
 create mode 100644 tests/qemu-iotests/062.out
0a122b
0a122b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
0a122b
---
0a122b
 tests/qemu-iotests/062     |   64 ++++++++++++++++++++++++++++++++++++++++++++
0a122b
 tests/qemu-iotests/062.out |    9 ++++++
0a122b
 tests/qemu-iotests/group   |    1 +
0a122b
 3 files changed, 74 insertions(+), 0 deletions(-)
0a122b
 create mode 100644 tests/qemu-iotests/062
0a122b
 create mode 100644 tests/qemu-iotests/062.out
0a122b
0a122b
diff --git a/tests/qemu-iotests/062 b/tests/qemu-iotests/062
0a122b
new file mode 100644
0a122b
index 0000000..0511246
0a122b
--- /dev/null
0a122b
+++ b/tests/qemu-iotests/062
0a122b
@@ -0,0 +1,64 @@
0a122b
+#!/bin/bash
0a122b
+#
0a122b
+# Test case for snapshotting images with unallocated zero clusters in
0a122b
+# qcow2
0a122b
+#
0a122b
+# Copyright (C) 2013 Red Hat, Inc.
0a122b
+#
0a122b
+# This program is free software; you can redistribute it and/or modify
0a122b
+# it under the terms of the GNU General Public License as published by
0a122b
+# the Free Software Foundation; either version 2 of the License, or
0a122b
+# (at your option) any later version.
0a122b
+#
0a122b
+# This program is distributed in the hope that it will be useful,
0a122b
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
0a122b
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0a122b
+# GNU General Public License for more details.
0a122b
+#
0a122b
+# You should have received a copy of the GNU General Public License
0a122b
+# along with this program.  If not, see <http: www.gnu.org="" licenses=""/>.
0a122b
+#
0a122b
+
0a122b
+# creator
0a122b
+owner=mreitz@redhat.com
0a122b
+
0a122b
+seq=`basename $0`
0a122b
+echo "QA output created by $seq"
0a122b
+
0a122b
+here=`pwd`
0a122b
+tmp=/tmp/$$
0a122b
+status=1	# failure is the default!
0a122b
+
0a122b
+_cleanup()
0a122b
+{
0a122b
+	_cleanup_test_img
0a122b
+}
0a122b
+trap "_cleanup; exit \$status" 0 1 2 3 15
0a122b
+
0a122b
+# get standard environment, filters and checks
0a122b
+. ./common.rc
0a122b
+. ./common.filter
0a122b
+
0a122b
+# This tests qocw2-specific low-level functionality
0a122b
+_supported_fmt qcow2
0a122b
+_supported_proto generic
0a122b
+_supported_os Linux
0a122b
+
0a122b
+IMGOPTS="compat=1.1"
0a122b
+IMG_SIZE=64M
0a122b
+
0a122b
+echo
0a122b
+echo "=== Testing snapshotting an image with zero clusters ==="
0a122b
+echo
0a122b
+_make_test_img $IMG_SIZE
0a122b
+# Write some zero clusters
0a122b
+$QEMU_IO -c "write -z 0 256k" "$TEST_IMG" | _filter_qemu_io
0a122b
+# Create a snapshot
0a122b
+$QEMU_IMG snapshot -c foo "$TEST_IMG"
0a122b
+# Check the image (there shouldn't be any errors or leaks)
0a122b
+_check_test_img
0a122b
+
0a122b
+# success, all done
0a122b
+echo "*** done"
0a122b
+rm -f $seq.full
0a122b
+status=0
0a122b
diff --git a/tests/qemu-iotests/062.out b/tests/qemu-iotests/062.out
0a122b
new file mode 100644
0a122b
index 0000000..442d761
0a122b
--- /dev/null
0a122b
+++ b/tests/qemu-iotests/062.out
0a122b
@@ -0,0 +1,9 @@
0a122b
+QA output created by 062
0a122b
+
0a122b
+=== Testing snapshotting an image with zero clusters ===
0a122b
+
0a122b
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 
0a122b
+wrote 262144/262144 bytes at offset 0
0a122b
+256 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
0a122b
+No errors were found on the image.
0a122b
+*** done
0a122b
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
0a122b
index 0867b0f..2d0aba0 100644
0a122b
--- a/tests/qemu-iotests/group
0a122b
+++ b/tests/qemu-iotests/group
0a122b
@@ -63,6 +63,7 @@
0a122b
 054 rw auto
0a122b
 059 rw auto
0a122b
 060 rw auto
0a122b
+062 rw auto
0a122b
 063 rw auto
0a122b
 064 rw auto
0a122b
 065 rw auto
0a122b
-- 
0a122b
1.7.1
0a122b