958e1b
From 5fe07e00b182e79e2e8095916d18cc0f37348efe Mon Sep 17 00:00:00 2001
eb5a2f
From: Max Reitz <mreitz@redhat.com>
eb5a2f
Date: Fri, 2 May 2014 16:06:21 +0200
958e1b
Subject: [PATCH 03/31] qemu-iotests: Discard preallocated zero clusters
eb5a2f
eb5a2f
RH-Author: Max Reitz <mreitz@redhat.com>
eb5a2f
Message-id: <1399046781-16359-3-git-send-email-mreitz@redhat.com>
eb5a2f
Patchwork-id: 58645
eb5a2f
O-Subject: [RHEL-7.0 qemu-kvm PATCH 2/2] qemu-iotests: Discard preallocated zero clusters
958e1b
Bugzilla: 1052093
eb5a2f
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
eb5a2f
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
eb5a2f
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
eb5a2f
958e1b
BZ: 1052093
958e1b
eb5a2f
Add a new test case for discarding preallocated zero clusters; doing
eb5a2f
this should not result in any leaks.
eb5a2f
eb5a2f
Signed-off-by: Max Reitz <mreitz@redhat.com>
eb5a2f
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
eb5a2f
(cherry picked from commit 975a93c082452db9aa1397a797ca8f13ba367393)
eb5a2f
eb5a2f
Conflicts:
eb5a2f
	tests/qemu-iotests/group
eb5a2f
eb5a2f
Signed-off-by: Max Reitz <mreitz@redhat.com>
eb5a2f
---
eb5a2f
 tests/qemu-iotests/066     | 63 ++++++++++++++++++++++++++++++++++++++++++++++
eb5a2f
 tests/qemu-iotests/066.out | 13 ++++++++++
eb5a2f
 tests/qemu-iotests/group   |  1 +
eb5a2f
 3 files changed, 77 insertions(+)
eb5a2f
 create mode 100755 tests/qemu-iotests/066
eb5a2f
 create mode 100644 tests/qemu-iotests/066.out
eb5a2f
eb5a2f
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
eb5a2f
---
eb5a2f
 tests/qemu-iotests/066     |   63 ++++++++++++++++++++++++++++++++++++++++++++
eb5a2f
 tests/qemu-iotests/066.out |   13 +++++++++
eb5a2f
 tests/qemu-iotests/group   |    1 +
eb5a2f
 3 files changed, 77 insertions(+), 0 deletions(-)
eb5a2f
 create mode 100755 tests/qemu-iotests/066
eb5a2f
 create mode 100644 tests/qemu-iotests/066.out
eb5a2f
eb5a2f
diff --git a/tests/qemu-iotests/066 b/tests/qemu-iotests/066
eb5a2f
new file mode 100755
eb5a2f
index 0000000..1c2452b
eb5a2f
--- /dev/null
eb5a2f
+++ b/tests/qemu-iotests/066
eb5a2f
@@ -0,0 +1,63 @@
eb5a2f
+#!/bin/bash
eb5a2f
+#
eb5a2f
+# Test case for discarding preallocated zero clusters in qcow2
eb5a2f
+#
eb5a2f
+# Copyright (C) 2013 Red Hat, Inc.
eb5a2f
+#
eb5a2f
+# This program is free software; you can redistribute it and/or modify
eb5a2f
+# it under the terms of the GNU General Public License as published by
eb5a2f
+# the Free Software Foundation; either version 2 of the License, or
eb5a2f
+# (at your option) any later version.
eb5a2f
+#
eb5a2f
+# This program is distributed in the hope that it will be useful,
eb5a2f
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
eb5a2f
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
eb5a2f
+# GNU General Public License for more details.
eb5a2f
+#
eb5a2f
+# You should have received a copy of the GNU General Public License
eb5a2f
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
eb5a2f
+#
eb5a2f
+
eb5a2f
+# creator
eb5a2f
+owner=mreitz@redhat.com
eb5a2f
+
eb5a2f
+seq="$(basename $0)"
eb5a2f
+echo "QA output created by $seq"
eb5a2f
+
eb5a2f
+here="$PWD"
eb5a2f
+tmp=/tmp/$$
eb5a2f
+status=1	# failure is the default!
eb5a2f
+
eb5a2f
+_cleanup()
eb5a2f
+{
eb5a2f
+	_cleanup_test_img
eb5a2f
+}
eb5a2f
+trap "_cleanup; exit \$status" 0 1 2 3 15
eb5a2f
+
eb5a2f
+# get standard environment, filters and checks
eb5a2f
+. ./common.rc
eb5a2f
+. ./common.filter
eb5a2f
+
eb5a2f
+# This tests qocw2-specific low-level functionality
eb5a2f
+_supported_fmt qcow2
eb5a2f
+_supported_proto generic
eb5a2f
+_supported_os Linux
eb5a2f
+
eb5a2f
+IMGOPTS="compat=1.1"
eb5a2f
+IMG_SIZE=64M
eb5a2f
+
eb5a2f
+echo
eb5a2f
+echo "=== Testing snapshotting an image with zero clusters ==="
eb5a2f
+echo
eb5a2f
+_make_test_img $IMG_SIZE
eb5a2f
+# Write some normal clusters, zero them (creating preallocated zero clusters)
eb5a2f
+# and discard those
eb5a2f
+$QEMU_IO -c "write 0 256k" -c "write -z 0 256k" -c "discard 0 256k" "$TEST_IMG" \
eb5a2f
+         | _filter_qemu_io
eb5a2f
+# Check the image (there shouldn't be any leaks)
eb5a2f
+_check_test_img
eb5a2f
+
eb5a2f
+# success, all done
eb5a2f
+echo "*** done"
eb5a2f
+rm -f $seq.full
eb5a2f
+status=0
eb5a2f
diff --git a/tests/qemu-iotests/066.out b/tests/qemu-iotests/066.out
eb5a2f
new file mode 100644
eb5a2f
index 0000000..9139780
eb5a2f
--- /dev/null
eb5a2f
+++ b/tests/qemu-iotests/066.out
eb5a2f
@@ -0,0 +1,13 @@
eb5a2f
+QA output created by 066
eb5a2f
+
eb5a2f
+=== Testing snapshotting an image with zero clusters ===
eb5a2f
+
eb5a2f
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864 
eb5a2f
+wrote 262144/262144 bytes at offset 0
eb5a2f
+256 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
eb5a2f
+wrote 262144/262144 bytes at offset 0
eb5a2f
+256 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
eb5a2f
+discard 262144/262144 bytes at offset 0
eb5a2f
+256 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
eb5a2f
+No errors were found on the image.
eb5a2f
+*** done
eb5a2f
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
958e1b
index ad96fcf..1c91036 100644
eb5a2f
--- a/tests/qemu-iotests/group
eb5a2f
+++ b/tests/qemu-iotests/group
eb5a2f
@@ -68,6 +68,7 @@
eb5a2f
 063 rw auto
eb5a2f
 064 rw auto
eb5a2f
 065 rw auto
eb5a2f
+066 rw auto
eb5a2f
 067 rw auto
eb5a2f
 068 rw auto
eb5a2f
 070 rw auto
eb5a2f
-- 
eb5a2f
1.7.1
eb5a2f