|
|
1bdc94 |
From d1e2ed07917410e71f10b8dda80ef94a3d333d3c Mon Sep 17 00:00:00 2001
|
|
|
1bdc94 |
From: Max Reitz <mreitz@redhat.com>
|
|
|
1bdc94 |
Date: Mon, 18 Jun 2018 16:12:12 +0200
|
|
|
1bdc94 |
Subject: [PATCH 36/54] iotests: Add test for COR across nodes
|
|
|
1bdc94 |
|
|
|
1bdc94 |
RH-Author: Max Reitz <mreitz@redhat.com>
|
|
|
1bdc94 |
Message-id: <20180618161212.14444-11-mreitz@redhat.com>
|
|
|
1bdc94 |
Patchwork-id: 80771
|
|
|
1bdc94 |
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 10/10] iotests: Add test for COR across nodes
|
|
|
1bdc94 |
Bugzilla: 1518738
|
|
|
1bdc94 |
RH-Acked-by: John Snow <jsnow@redhat.com>
|
|
|
1bdc94 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
1bdc94 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
1bdc94 |
|
|
|
1bdc94 |
COR across nodes (that is, you have some filter node between the
|
|
|
1bdc94 |
actually COR target and the node that performs the COR) cannot reliably
|
|
|
1bdc94 |
work together with the permission system when there is no explicit COR
|
|
|
1bdc94 |
node that can request the WRITE_UNCHANGED permission for its child.
|
|
|
1bdc94 |
This is because COR (currently) sneaks its requests by the usual
|
|
|
1bdc94 |
permission checks, so it can work without a WRITE* permission; but if
|
|
|
1bdc94 |
there is a filter node in between, that will re-issue the request, which
|
|
|
1bdc94 |
then passes through the usual check -- and if nobody has requested a
|
|
|
1bdc94 |
WRITE_UNCHANGED permission, that check will fail.
|
|
|
1bdc94 |
|
|
|
1bdc94 |
There is no real direct fix apart from hoping that there is someone who
|
|
|
1bdc94 |
has requested that permission; in case of just the qemu-io HMP command
|
|
|
1bdc94 |
(and no guest device), however, that is not the case. The real real fix
|
|
|
1bdc94 |
is to implement the copy-on-read flag through an implicitly added COR
|
|
|
1bdc94 |
node. Such a node can request the necessary permissions as shown in
|
|
|
1bdc94 |
this test.
|
|
|
1bdc94 |
|
|
|
1bdc94 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
1bdc94 |
Message-id: 20180421132929.21610-10-mreitz@redhat.com
|
|
|
1bdc94 |
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
1bdc94 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
1bdc94 |
(cherry picked from commit 3e7a95feb9b5d66cff7fee38b3c423135ed245f6)
|
|
|
1bdc94 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
1bdc94 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
1bdc94 |
---
|
|
|
1bdc94 |
tests/qemu-iotests/216 | 115 +++++++++++++++++++++++++++++++++++++++++++++
|
|
|
1bdc94 |
tests/qemu-iotests/216.out | 28 +++++++++++
|
|
|
1bdc94 |
tests/qemu-iotests/group | 1 +
|
|
|
1bdc94 |
3 files changed, 144 insertions(+)
|
|
|
1bdc94 |
create mode 100755 tests/qemu-iotests/216
|
|
|
1bdc94 |
create mode 100644 tests/qemu-iotests/216.out
|
|
|
1bdc94 |
|
|
|
1bdc94 |
diff --git a/tests/qemu-iotests/216 b/tests/qemu-iotests/216
|
|
|
1bdc94 |
new file mode 100755
|
|
|
1bdc94 |
index 0000000..ca9b47a
|
|
|
1bdc94 |
--- /dev/null
|
|
|
1bdc94 |
+++ b/tests/qemu-iotests/216
|
|
|
1bdc94 |
@@ -0,0 +1,115 @@
|
|
|
1bdc94 |
+#!/usr/bin/env python
|
|
|
1bdc94 |
+#
|
|
|
1bdc94 |
+# Copy-on-read tests using a COR filter node
|
|
|
1bdc94 |
+#
|
|
|
1bdc94 |
+# Copyright (C) 2018 Red Hat, Inc.
|
|
|
1bdc94 |
+#
|
|
|
1bdc94 |
+# This program is free software; you can redistribute it and/or modify
|
|
|
1bdc94 |
+# it under the terms of the GNU General Public License as published by
|
|
|
1bdc94 |
+# the Free Software Foundation; either version 2 of the License, or
|
|
|
1bdc94 |
+# (at your option) any later version.
|
|
|
1bdc94 |
+#
|
|
|
1bdc94 |
+# This program is distributed in the hope that it will be useful,
|
|
|
1bdc94 |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
1bdc94 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
1bdc94 |
+# GNU General Public License for more details.
|
|
|
1bdc94 |
+#
|
|
|
1bdc94 |
+# You should have received a copy of the GNU General Public License
|
|
|
1bdc94 |
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
1bdc94 |
+#
|
|
|
1bdc94 |
+# Creator/Owner: Max Reitz <mreitz@redhat.com>
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+import iotests
|
|
|
1bdc94 |
+from iotests import log, qemu_img_pipe, qemu_io, filter_qemu_io
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+# Need backing file support
|
|
|
1bdc94 |
+iotests.verify_image_format(supported_fmts=['qcow2', 'qcow', 'qed', 'vmdk'])
|
|
|
1bdc94 |
+iotests.verify_platform(['linux'])
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+log('')
|
|
|
1bdc94 |
+log('=== Copy-on-read across nodes ===')
|
|
|
1bdc94 |
+log('')
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+# The old copy-on-read mechanism without a filter node cannot request
|
|
|
1bdc94 |
+# WRITE_UNCHANGED permissions for its child. Therefore it just tries
|
|
|
1bdc94 |
+# to sneak its write by the usual permission system and holds its
|
|
|
1bdc94 |
+# fingers crossed. However, that sneaking does not work so well when
|
|
|
1bdc94 |
+# there is a filter node in the way: That will receive the write
|
|
|
1bdc94 |
+# request and re-issue a new one to its child, which this time is a
|
|
|
1bdc94 |
+# proper write request that will make the permission system cough --
|
|
|
1bdc94 |
+# unless there is someone at the top (like a guest device) that has
|
|
|
1bdc94 |
+# requested write permissions.
|
|
|
1bdc94 |
+#
|
|
|
1bdc94 |
+# A COR filter node, however, can request the proper permissions for
|
|
|
1bdc94 |
+# its child and therefore is not hit by this issue.
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+with iotests.FilePath('base.img') as base_img_path, \
|
|
|
1bdc94 |
+ iotests.FilePath('top.img') as top_img_path, \
|
|
|
1bdc94 |
+ iotests.VM() as vm:
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+ log('--- Setting up images ---')
|
|
|
1bdc94 |
+ log('')
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+ qemu_img_pipe('create', '-f', iotests.imgfmt, base_img_path, '64M')
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+ log(filter_qemu_io(qemu_io(base_img_path, '-c', 'write -P 1 0M 1M')))
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+ qemu_img_pipe('create', '-f', iotests.imgfmt, '-b', base_img_path,
|
|
|
1bdc94 |
+ top_img_path)
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+ log(filter_qemu_io(qemu_io(top_img_path, '-c', 'write -P 2 1M 1M')))
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+ log('')
|
|
|
1bdc94 |
+ log('--- Doing COR ---')
|
|
|
1bdc94 |
+ log('')
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+ # Compare with e.g. the following:
|
|
|
1bdc94 |
+ # vm.add_drive_raw('if=none,node-name=node0,copy-on-read=on,driver=raw,' \
|
|
|
1bdc94 |
+ # 'file.driver=%s,file.file.filename=%s' %
|
|
|
1bdc94 |
+ # (iotests.imgfmt, top_img_path))
|
|
|
1bdc94 |
+ # (Remove the blockdev-add instead.)
|
|
|
1bdc94 |
+ # ((Not tested here because it hits an assertion in the permission
|
|
|
1bdc94 |
+ # system.))
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+ vm.launch()
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+ log(vm.qmp('blockdev-add',
|
|
|
1bdc94 |
+ node_name='node0',
|
|
|
1bdc94 |
+ driver='copy-on-read',
|
|
|
1bdc94 |
+ file={
|
|
|
1bdc94 |
+ 'driver': 'raw',
|
|
|
1bdc94 |
+ 'file': {
|
|
|
1bdc94 |
+ 'driver': 'copy-on-read',
|
|
|
1bdc94 |
+ 'file': {
|
|
|
1bdc94 |
+ 'driver': 'raw',
|
|
|
1bdc94 |
+ 'file': {
|
|
|
1bdc94 |
+ 'driver': iotests.imgfmt,
|
|
|
1bdc94 |
+ 'file': {
|
|
|
1bdc94 |
+ 'driver': 'file',
|
|
|
1bdc94 |
+ 'filename': top_img_path
|
|
|
1bdc94 |
+ },
|
|
|
1bdc94 |
+ 'backing': {
|
|
|
1bdc94 |
+ 'driver': iotests.imgfmt,
|
|
|
1bdc94 |
+ 'file': {
|
|
|
1bdc94 |
+ 'driver': 'file',
|
|
|
1bdc94 |
+ 'filename': base_img_path
|
|
|
1bdc94 |
+ }
|
|
|
1bdc94 |
+ }
|
|
|
1bdc94 |
+ }
|
|
|
1bdc94 |
+ }
|
|
|
1bdc94 |
+ }
|
|
|
1bdc94 |
+ }))
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+ # Trigger COR
|
|
|
1bdc94 |
+ log(vm.qmp('human-monitor-command',
|
|
|
1bdc94 |
+ command_line='qemu-io node0 "read 0 64M"'))
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+ vm.shutdown()
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+ log('')
|
|
|
1bdc94 |
+ log('--- Checking COR result ---')
|
|
|
1bdc94 |
+ log('')
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+ log(filter_qemu_io(qemu_io(base_img_path, '-c', 'discard 0 64M')))
|
|
|
1bdc94 |
+ log(filter_qemu_io(qemu_io(top_img_path, '-c', 'read -P 1 0M 1M')))
|
|
|
1bdc94 |
+ log(filter_qemu_io(qemu_io(top_img_path, '-c', 'read -P 2 1M 1M')))
|
|
|
1bdc94 |
diff --git a/tests/qemu-iotests/216.out b/tests/qemu-iotests/216.out
|
|
|
1bdc94 |
new file mode 100644
|
|
|
1bdc94 |
index 0000000..d3fc590
|
|
|
1bdc94 |
--- /dev/null
|
|
|
1bdc94 |
+++ b/tests/qemu-iotests/216.out
|
|
|
1bdc94 |
@@ -0,0 +1,28 @@
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+=== Copy-on-read across nodes ===
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+--- Setting up images ---
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+wrote 1048576/1048576 bytes at offset 0
|
|
|
1bdc94 |
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+wrote 1048576/1048576 bytes at offset 1048576
|
|
|
1bdc94 |
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+--- Doing COR ---
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+{u'return': {}}
|
|
|
1bdc94 |
+{u'return': u''}
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+--- Checking COR result ---
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+discard 67108864/67108864 bytes at offset 0
|
|
|
1bdc94 |
+64 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+read 1048576/1048576 bytes at offset 0
|
|
|
1bdc94 |
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
+read 1048576/1048576 bytes at offset 1048576
|
|
|
1bdc94 |
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
|
|
|
1bdc94 |
+
|
|
|
1bdc94 |
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
|
|
|
1bdc94 |
index cd5d26c..d228008 100644
|
|
|
1bdc94 |
--- a/tests/qemu-iotests/group
|
|
|
1bdc94 |
+++ b/tests/qemu-iotests/group
|
|
|
1bdc94 |
@@ -214,4 +214,5 @@
|
|
|
1bdc94 |
213 rw auto quick
|
|
|
1bdc94 |
214 rw auto
|
|
|
1bdc94 |
215 rw auto quick
|
|
|
1bdc94 |
+216 rw auto quick
|
|
|
1bdc94 |
218 rw auto quick
|
|
|
1bdc94 |
--
|
|
|
1bdc94 |
1.8.3.1
|
|
|
1bdc94 |
|