thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
ddf19c
From 55f3a02574da226299d99bd74d12dd91b0f228dc Mon Sep 17 00:00:00 2001
ddf19c
From: Maxim Levitsky <mlevitsk@redhat.com>
ddf19c
Date: Wed, 11 Mar 2020 10:51:46 +0000
ddf19c
Subject: [PATCH 05/20] iotests: Add test for image creation fallback
ddf19c
ddf19c
RH-Author: Maxim Levitsky <mlevitsk@redhat.com>
ddf19c
Message-id: <20200311105147.13208-6-mlevitsk@redhat.com>
ddf19c
Patchwork-id: 94228
ddf19c
O-Subject: [RHEL-AV-8.2.0 qemu-kvm PATCH v2 5/6] iotests: Add test for image creation fallback
ddf19c
Bugzilla: 1640894
ddf19c
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
ddf19c
RH-Acked-by: John Snow <jsnow@redhat.com>
ddf19c
RH-Acked-by: Max Reitz <mreitz@redhat.com>
ddf19c
ddf19c
From: Max Reitz <mreitz@redhat.com>
ddf19c
ddf19c
Signed-off-by: Max Reitz <mreitz@redhat.com>
ddf19c
Message-Id: <20200122164532.178040-6-mreitz@redhat.com>
ddf19c
Reviewed-by: Eric Blake <eblake@redhat.com>
ddf19c
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
ddf19c
[mreitz: Added a note that NBD does not support resizing, which is why
ddf19c
         the second case is expected to fail]
ddf19c
Signed-off-by: Max Reitz <mreitz@redhat.com>
ddf19c
(cherry picked from commit 4dddeac115c5a2c5f74731fda0afd031a0b45490)
ddf19c
Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
ddf19c
ddf19c
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ddf19c
---
ddf19c
 tests/qemu-iotests/259     | 62 ++++++++++++++++++++++++++++++++++++++++++++++
ddf19c
 tests/qemu-iotests/259.out | 14 +++++++++++
ddf19c
 tests/qemu-iotests/group   |  1 +
ddf19c
 3 files changed, 77 insertions(+)
ddf19c
 create mode 100755 tests/qemu-iotests/259
ddf19c
 create mode 100644 tests/qemu-iotests/259.out
ddf19c
ddf19c
diff --git a/tests/qemu-iotests/259 b/tests/qemu-iotests/259
ddf19c
new file mode 100755
ddf19c
index 0000000..62e29af
ddf19c
--- /dev/null
ddf19c
+++ b/tests/qemu-iotests/259
ddf19c
@@ -0,0 +1,62 @@
ddf19c
+#!/usr/bin/env bash
ddf19c
+#
ddf19c
+# Test generic image creation fallback (by using NBD)
ddf19c
+#
ddf19c
+# Copyright (C) 2019 Red Hat, Inc.
ddf19c
+#
ddf19c
+# This program is free software; you can redistribute it and/or modify
ddf19c
+# it under the terms of the GNU General Public License as published by
ddf19c
+# the Free Software Foundation; either version 2 of the License, or
ddf19c
+# (at your option) any later version.
ddf19c
+#
ddf19c
+# This program is distributed in the hope that it will be useful,
ddf19c
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
ddf19c
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ddf19c
+# GNU General Public License for more details.
ddf19c
+#
ddf19c
+# You should have received a copy of the GNU General Public License
ddf19c
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
ddf19c
+#
ddf19c
+
ddf19c
+# creator
ddf19c
+owner=mreitz@redhat.com
ddf19c
+
ddf19c
+seq=$(basename $0)
ddf19c
+echo "QA output created by $seq"
ddf19c
+
ddf19c
+status=1	# failure is the default!
ddf19c
+
ddf19c
+_cleanup()
ddf19c
+{
ddf19c
+    _cleanup_test_img
ddf19c
+}
ddf19c
+trap "_cleanup; exit \$status" 0 1 2 3 15
ddf19c
+
ddf19c
+# get standard environment, filters and checks
ddf19c
+. ./common.rc
ddf19c
+. ./common.filter
ddf19c
+
ddf19c
+_supported_fmt raw
ddf19c
+_supported_proto nbd
ddf19c
+_supported_os Linux
ddf19c
+
ddf19c
+
ddf19c
+_make_test_img 64M
ddf19c
+
ddf19c
+echo
ddf19c
+echo '--- Testing creation ---'
ddf19c
+
ddf19c
+$QEMU_IMG create -f qcow2 "$TEST_IMG" 64M | _filter_img_create
ddf19c
+$QEMU_IMG info "$TEST_IMG" | _filter_img_info
ddf19c
+
ddf19c
+echo
ddf19c
+echo '--- Testing creation for which the node would need to grow ---'
ddf19c
+
ddf19c
+# NBD does not support resizing, so this will fail
ddf19c
+$QEMU_IMG create -f qcow2 -o preallocation=metadata "$TEST_IMG" 64M 2>&1 \
ddf19c
+    | _filter_img_create
ddf19c
+
ddf19c
+# success, all done
ddf19c
+echo "*** done"
ddf19c
+rm -f $seq.full
ddf19c
+status=0
ddf19c
diff --git a/tests/qemu-iotests/259.out b/tests/qemu-iotests/259.out
ddf19c
new file mode 100644
ddf19c
index 0000000..ffed19c
ddf19c
--- /dev/null
ddf19c
+++ b/tests/qemu-iotests/259.out
ddf19c
@@ -0,0 +1,14 @@
ddf19c
+QA output created by 259
ddf19c
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
ddf19c
+
ddf19c
+--- Testing creation ---
ddf19c
+Formatting 'TEST_DIR/t.IMGFMT', fmt=qcow2 size=67108864
ddf19c
+image: TEST_DIR/t.IMGFMT
ddf19c
+file format: qcow2
ddf19c
+virtual size: 64 MiB (67108864 bytes)
ddf19c
+disk size: unavailable
ddf19c
+
ddf19c
+--- Testing creation for which the node would need to grow ---
ddf19c
+qemu-img: TEST_DIR/t.IMGFMT: Could not resize image: Image format driver does not support resize
ddf19c
+Formatting 'TEST_DIR/t.IMGFMT', fmt=qcow2 size=67108864 preallocation=metadata
ddf19c
+*** done
ddf19c
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
ddf19c
index c0e8197..e47cbfc 100644
ddf19c
--- a/tests/qemu-iotests/group
ddf19c
+++ b/tests/qemu-iotests/group
ddf19c
@@ -273,6 +273,7 @@
ddf19c
 256 rw quick
ddf19c
 257 rw
ddf19c
 258 rw quick
ddf19c
+259 rw auto quick
ddf19c
 260 rw quick
ddf19c
 261 rw
ddf19c
 262 rw quick migration
ddf19c
-- 
ddf19c
1.8.3.1
ddf19c