aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Reitz <mreitz@redhat.com>2019-09-02 21:33:20 +0200
committerMichael Roth <mdroth@linux.vnet.ibm.com>2019-10-01 16:58:28 -0500
commite40124c4873ca7bee8d56235331047d4386a71e7 (patch)
treeee32495c37cebf2b01d9127d4fd9cf073a8c8d99
parent491bf156718ca25a5c3c2f9d91c216d400e532b9 (diff)
downloadqemu-e40124c4873ca7bee8d56235331047d4386a71e7.zip
qemu-e40124c4873ca7bee8d56235331047d4386a71e7.tar.gz
qemu-e40124c4873ca7bee8d56235331047d4386a71e7.tar.bz2
iotests: Test blockdev-create for vpc
Signed-off-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com> (cherry picked from commit cb73747e1a47b93d3dfdc3f769c576b053916938) Conflicts: tests/qemu-iotests/group *drop context dep. on tests not in 4.0 Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
-rwxr-xr-xtests/qemu-iotests/266153
-rw-r--r--tests/qemu-iotests/266.out137
-rw-r--r--tests/qemu-iotests/group1
3 files changed, 291 insertions, 0 deletions
diff --git a/tests/qemu-iotests/266 b/tests/qemu-iotests/266
new file mode 100755
index 0000000..5b35cd6
--- /dev/null
+++ b/tests/qemu-iotests/266
@@ -0,0 +1,153 @@
+#!/usr/bin/env python
+#
+# Test VPC and file image creation
+#
+# Copyright (C) 2019 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+import iotests
+from iotests import imgfmt
+
+
+def blockdev_create(vm, options):
+ result = vm.qmp_log('blockdev-create', job_id='job0', options=options,
+ filters=[iotests.filter_qmp_testfiles])
+
+ if 'return' in result:
+ assert result['return'] == {}
+ vm.run_job('job0')
+
+
+# Successful image creation (defaults)
+def implicit_defaults(vm, file_path):
+ iotests.log("=== Successful image creation (defaults) ===")
+ iotests.log("")
+
+ # 8 heads, 964 cyls/head, 17 secs/cyl
+ # (Close to 64 MB)
+ size = 8 * 964 * 17 * 512
+
+ blockdev_create(vm, { 'driver': imgfmt,
+ 'file': 'protocol-node',
+ 'size': size })
+
+
+# Successful image creation (explicit defaults)
+def explicit_defaults(vm, file_path):
+ iotests.log("=== Successful image creation (explicit defaults) ===")
+ iotests.log("")
+
+ # 16 heads, 964 cyls/head, 17 secs/cyl
+ # (Close to 128 MB)
+ size = 16 * 964 * 17 * 512
+
+ blockdev_create(vm, { 'driver': imgfmt,
+ 'file': 'protocol-node',
+ 'size': size,
+ 'subformat': 'dynamic',
+ 'force-size': False })
+
+
+# Successful image creation (non-default options)
+def non_defaults(vm, file_path):
+ iotests.log("=== Successful image creation (non-default options) ===")
+ iotests.log("")
+
+ # Not representable in CHS (fine with force-size=True)
+ size = 1048576
+
+ blockdev_create(vm, { 'driver': imgfmt,
+ 'file': 'protocol-node',
+ 'size': size,
+ 'subformat': 'fixed',
+ 'force-size': True })
+
+
+# Size not representable in CHS with force-size=False
+def non_chs_size_without_force(vm, file_path):
+ iotests.log("=== Size not representable in CHS ===")
+ iotests.log("")
+
+ # Not representable in CHS (will not work with force-size=False)
+ size = 1048576
+
+ blockdev_create(vm, { 'driver': imgfmt,
+ 'file': 'protocol-node',
+ 'size': size,
+ 'force-size': False })
+
+
+# Zero size
+def zero_size(vm, file_path):
+ iotests.log("=== Zero size===")
+ iotests.log("")
+
+ blockdev_create(vm, { 'driver': imgfmt,
+ 'file': 'protocol-node',
+ 'size': 0 })
+
+
+# Maximum CHS size
+def maximum_chs_size(vm, file_path):
+ iotests.log("=== Maximum CHS size===")
+ iotests.log("")
+
+ blockdev_create(vm, { 'driver': imgfmt,
+ 'file': 'protocol-node',
+ 'size': 16 * 65535 * 255 * 512 })
+
+
+# Actual maximum size
+def maximum_size(vm, file_path):
+ iotests.log("=== Actual maximum size===")
+ iotests.log("")
+
+ blockdev_create(vm, { 'driver': imgfmt,
+ 'file': 'protocol-node',
+ 'size': 0xff000000 * 512,
+ 'force-size': True })
+
+
+def main():
+ for test_func in [implicit_defaults, explicit_defaults, non_defaults,
+ non_chs_size_without_force, zero_size, maximum_chs_size,
+ maximum_size]:
+
+ with iotests.FilePath('t.vpc') as file_path, \
+ iotests.VM() as vm:
+
+ vm.launch()
+
+ iotests.log('--- Creating empty file ---')
+ blockdev_create(vm, { 'driver': 'file',
+ 'filename': file_path,
+ 'size': 0 })
+
+ vm.qmp_log('blockdev-add', driver='file', filename=file_path,
+ node_name='protocol-node',
+ filters=[iotests.filter_qmp_testfiles])
+ iotests.log('')
+
+ print_info = test_func(vm, file_path)
+ iotests.log('')
+
+ vm.shutdown()
+ iotests.img_info_log(file_path)
+
+
+iotests.script_main(main,
+ supported_fmts=['vpc'],
+ supported_protocols=['file'])
diff --git a/tests/qemu-iotests/266.out b/tests/qemu-iotests/266.out
new file mode 100644
index 0000000..b11953e
--- /dev/null
+++ b/tests/qemu-iotests/266.out
@@ -0,0 +1,137 @@
+--- Creating empty file ---
+{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "size": 0}}}
+{"return": {}}
+{"execute": "job-dismiss", "arguments": {"id": "job0"}}
+{"return": {}}
+{"execute": "blockdev-add", "arguments": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "node-name": "protocol-node"}}
+{"return": {}}
+
+=== Successful image creation (defaults) ===
+
+{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "vpc", "file": "protocol-node", "size": 67125248}}}
+{"return": {}}
+{"execute": "job-dismiss", "arguments": {"id": "job0"}}
+{"return": {}}
+
+image: TEST_IMG
+file format: IMGFMT
+virtual size: 64 MiB (67125248 bytes)
+cluster_size: 2097152
+
+--- Creating empty file ---
+{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "size": 0}}}
+{"return": {}}
+{"execute": "job-dismiss", "arguments": {"id": "job0"}}
+{"return": {}}
+{"execute": "blockdev-add", "arguments": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "node-name": "protocol-node"}}
+{"return": {}}
+
+=== Successful image creation (explicit defaults) ===
+
+{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "vpc", "file": "protocol-node", "force-size": false, "size": 134250496, "subformat": "dynamic"}}}
+{"return": {}}
+{"execute": "job-dismiss", "arguments": {"id": "job0"}}
+{"return": {}}
+
+image: TEST_IMG
+file format: IMGFMT
+virtual size: 128 MiB (134250496 bytes)
+cluster_size: 2097152
+
+--- Creating empty file ---
+{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "size": 0}}}
+{"return": {}}
+{"execute": "job-dismiss", "arguments": {"id": "job0"}}
+{"return": {}}
+{"execute": "blockdev-add", "arguments": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "node-name": "protocol-node"}}
+{"return": {}}
+
+=== Successful image creation (non-default options) ===
+
+{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "vpc", "file": "protocol-node", "force-size": true, "size": 1048576, "subformat": "fixed"}}}
+{"return": {}}
+{"execute": "job-dismiss", "arguments": {"id": "job0"}}
+{"return": {}}
+
+image: TEST_IMG
+file format: IMGFMT
+virtual size: 1 MiB (1048576 bytes)
+
+--- Creating empty file ---
+{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "size": 0}}}
+{"return": {}}
+{"execute": "job-dismiss", "arguments": {"id": "job0"}}
+{"return": {}}
+{"execute": "blockdev-add", "arguments": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "node-name": "protocol-node"}}
+{"return": {}}
+
+=== Size not representable in CHS ===
+
+{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "vpc", "file": "protocol-node", "force-size": false, "size": 1048576}}}
+{"return": {}}
+Job failed: The requested image size cannot be represented in CHS geometry
+{"execute": "job-dismiss", "arguments": {"id": "job0"}}
+{"return": {}}
+
+qemu-img: Could not open 'TEST_IMG': File too small for a VHD header
+
+--- Creating empty file ---
+{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "size": 0}}}
+{"return": {}}
+{"execute": "job-dismiss", "arguments": {"id": "job0"}}
+{"return": {}}
+{"execute": "blockdev-add", "arguments": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "node-name": "protocol-node"}}
+{"return": {}}
+
+=== Zero size===
+
+{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "vpc", "file": "protocol-node", "size": 0}}}
+{"return": {}}
+{"execute": "job-dismiss", "arguments": {"id": "job0"}}
+{"return": {}}
+
+image: TEST_IMG
+file format: IMGFMT
+virtual size: 0 B (0 bytes)
+cluster_size: 2097152
+
+--- Creating empty file ---
+{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "size": 0}}}
+{"return": {}}
+{"execute": "job-dismiss", "arguments": {"id": "job0"}}
+{"return": {}}
+{"execute": "blockdev-add", "arguments": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "node-name": "protocol-node"}}
+{"return": {}}
+
+=== Maximum CHS size===
+
+{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "vpc", "file": "protocol-node", "size": 136899993600}}}
+{"return": {}}
+{"execute": "job-dismiss", "arguments": {"id": "job0"}}
+{"return": {}}
+
+image: TEST_IMG
+file format: IMGFMT
+virtual size: 127 GiB (136899993600 bytes)
+cluster_size: 2097152
+
+--- Creating empty file ---
+{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "size": 0}}}
+{"return": {}}
+{"execute": "job-dismiss", "arguments": {"id": "job0"}}
+{"return": {}}
+{"execute": "blockdev-add", "arguments": {"driver": "file", "filename": "TEST_DIR/PID-t.vpc", "node-name": "protocol-node"}}
+{"return": {}}
+
+=== Actual maximum size===
+
+{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options": {"driver": "vpc", "file": "protocol-node", "force-size": true, "size": 2190433320960}}}
+{"return": {}}
+{"execute": "job-dismiss", "arguments": {"id": "job0"}}
+{"return": {}}
+
+image: TEST_IMG
+file format: IMGFMT
+virtual size: 1.99 TiB (2190433320960 bytes)
+cluster_size: 2097152
+
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
index 7aa6dc9..3605796 100644
--- a/tests/qemu-iotests/group
+++ b/tests/qemu-iotests/group
@@ -251,3 +251,4 @@
253 rw auto quick
255 rw auto quick
256 rw auto quick
+266 rw quick