|
|
ddf19c |
From 6b9a6ba9ed753ad7aa714b35de938ebeeb4fa6cb Mon Sep 17 00:00:00 2001
|
|
|
ddf19c |
From: Sergio Lopez Pascual <slp@redhat.com>
|
|
|
ddf19c |
Date: Fri, 7 Feb 2020 10:27:49 +0000
|
|
|
ddf19c |
Subject: [PATCH 16/18] iotests: Test handling of AioContexts with some
|
|
|
ddf19c |
blockdev actions
|
|
|
ddf19c |
|
|
|
ddf19c |
RH-Author: Sergio Lopez Pascual <slp@redhat.com>
|
|
|
ddf19c |
Message-id: <20200207112749.25073-10-slp@redhat.com>
|
|
|
ddf19c |
Patchwork-id: 93762
|
|
|
ddf19c |
O-Subject: [RHEL-AV-8.2.0 qemu-kvm PATCH v2 9/9] iotests: Test handling of AioContexts with some blockdev actions
|
|
|
ddf19c |
Bugzilla: 1745606 1746217 1773517 1779036 1782111 1782175 1783965
|
|
|
ddf19c |
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
|
|
|
ddf19c |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
ddf19c |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
ddf19c |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
ddf19c |
|
|
|
ddf19c |
Includes the following tests:
|
|
|
ddf19c |
|
|
|
ddf19c |
- Adding a dirty bitmap.
|
|
|
ddf19c |
* RHBZ: 1782175
|
|
|
ddf19c |
|
|
|
ddf19c |
- Starting a drive-mirror to an NBD-backed target.
|
|
|
ddf19c |
* RHBZ: 1746217, 1773517
|
|
|
ddf19c |
|
|
|
ddf19c |
- Aborting an external snapshot transaction.
|
|
|
ddf19c |
* RHBZ: 1779036
|
|
|
ddf19c |
|
|
|
ddf19c |
- Aborting a blockdev backup transaction.
|
|
|
ddf19c |
* RHBZ: 1782111
|
|
|
ddf19c |
|
|
|
ddf19c |
For each one of them, a VM with a number of disks running in an
|
|
|
ddf19c |
IOThread AioContext is used.
|
|
|
ddf19c |
|
|
|
ddf19c |
Signed-off-by: Sergio Lopez <slp@redhat.com>
|
|
|
ddf19c |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
ddf19c |
(cherry picked from commit 9b8c59e7610b9c5315ef093d801843dbe8debfac)
|
|
|
ddf19c |
Signed-off-by: Sergio Lopez <slp@redhat.com>
|
|
|
ddf19c |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
ddf19c |
---
|
|
|
ddf19c |
tests/qemu-iotests/281 | 247 +++++++++++++++++++++++++++++++++++++++++++++
|
|
|
ddf19c |
tests/qemu-iotests/281.out | 5 +
|
|
|
ddf19c |
tests/qemu-iotests/group | 1 +
|
|
|
ddf19c |
3 files changed, 253 insertions(+)
|
|
|
ddf19c |
create mode 100755 tests/qemu-iotests/281
|
|
|
ddf19c |
create mode 100644 tests/qemu-iotests/281.out
|
|
|
ddf19c |
|
|
|
ddf19c |
diff --git a/tests/qemu-iotests/281 b/tests/qemu-iotests/281
|
|
|
ddf19c |
new file mode 100755
|
|
|
ddf19c |
index 0000000..269d583
|
|
|
ddf19c |
--- /dev/null
|
|
|
ddf19c |
+++ b/tests/qemu-iotests/281
|
|
|
ddf19c |
@@ -0,0 +1,247 @@
|
|
|
ddf19c |
+#!/usr/bin/env python
|
|
|
ddf19c |
+#
|
|
|
ddf19c |
+# Test cases for blockdev + IOThread interactions
|
|
|
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 |
+import os
|
|
|
ddf19c |
+import iotests
|
|
|
ddf19c |
+from iotests import qemu_img
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+image_len = 64 * 1024 * 1024
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+# Test for RHBZ#1782175
|
|
|
ddf19c |
+class TestDirtyBitmapIOThread(iotests.QMPTestCase):
|
|
|
ddf19c |
+ drive0_img = os.path.join(iotests.test_dir, 'drive0.img')
|
|
|
ddf19c |
+ images = { 'drive0': drive0_img }
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ def setUp(self):
|
|
|
ddf19c |
+ for name in self.images:
|
|
|
ddf19c |
+ qemu_img('create', '-f', iotests.imgfmt,
|
|
|
ddf19c |
+ self.images[name], str(image_len))
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ self.vm = iotests.VM()
|
|
|
ddf19c |
+ self.vm.add_object('iothread,id=iothread0')
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ for name in self.images:
|
|
|
ddf19c |
+ self.vm.add_blockdev('driver=file,filename=%s,node-name=file_%s'
|
|
|
ddf19c |
+ % (self.images[name], name))
|
|
|
ddf19c |
+ self.vm.add_blockdev('driver=qcow2,file=file_%s,node-name=%s'
|
|
|
ddf19c |
+ % (name, name))
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ self.vm.launch()
|
|
|
ddf19c |
+ self.vm.qmp('x-blockdev-set-iothread',
|
|
|
ddf19c |
+ node_name='drive0', iothread='iothread0',
|
|
|
ddf19c |
+ force=True)
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ def tearDown(self):
|
|
|
ddf19c |
+ self.vm.shutdown()
|
|
|
ddf19c |
+ for name in self.images:
|
|
|
ddf19c |
+ os.remove(self.images[name])
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ def test_add_dirty_bitmap(self):
|
|
|
ddf19c |
+ result = self.vm.qmp(
|
|
|
ddf19c |
+ 'block-dirty-bitmap-add',
|
|
|
ddf19c |
+ node='drive0',
|
|
|
ddf19c |
+ name='bitmap1',
|
|
|
ddf19c |
+ persistent=True,
|
|
|
ddf19c |
+ )
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ self.assert_qmp(result, 'return', {})
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+# Test for RHBZ#1746217 & RHBZ#1773517
|
|
|
ddf19c |
+class TestNBDMirrorIOThread(iotests.QMPTestCase):
|
|
|
ddf19c |
+ nbd_sock = os.path.join(iotests.sock_dir, 'nbd.sock')
|
|
|
ddf19c |
+ drive0_img = os.path.join(iotests.test_dir, 'drive0.img')
|
|
|
ddf19c |
+ mirror_img = os.path.join(iotests.test_dir, 'mirror.img')
|
|
|
ddf19c |
+ images = { 'drive0': drive0_img, 'mirror': mirror_img }
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ def setUp(self):
|
|
|
ddf19c |
+ for name in self.images:
|
|
|
ddf19c |
+ qemu_img('create', '-f', iotests.imgfmt,
|
|
|
ddf19c |
+ self.images[name], str(image_len))
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ self.vm_src = iotests.VM(path_suffix='src')
|
|
|
ddf19c |
+ self.vm_src.add_object('iothread,id=iothread0')
|
|
|
ddf19c |
+ self.vm_src.add_blockdev('driver=file,filename=%s,node-name=file0'
|
|
|
ddf19c |
+ % (self.drive0_img))
|
|
|
ddf19c |
+ self.vm_src.add_blockdev('driver=qcow2,file=file0,node-name=drive0')
|
|
|
ddf19c |
+ self.vm_src.launch()
|
|
|
ddf19c |
+ self.vm_src.qmp('x-blockdev-set-iothread',
|
|
|
ddf19c |
+ node_name='drive0', iothread='iothread0',
|
|
|
ddf19c |
+ force=True)
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ self.vm_tgt = iotests.VM(path_suffix='tgt')
|
|
|
ddf19c |
+ self.vm_tgt.add_object('iothread,id=iothread0')
|
|
|
ddf19c |
+ self.vm_tgt.add_blockdev('driver=file,filename=%s,node-name=file0'
|
|
|
ddf19c |
+ % (self.mirror_img))
|
|
|
ddf19c |
+ self.vm_tgt.add_blockdev('driver=qcow2,file=file0,node-name=drive0')
|
|
|
ddf19c |
+ self.vm_tgt.launch()
|
|
|
ddf19c |
+ self.vm_tgt.qmp('x-blockdev-set-iothread',
|
|
|
ddf19c |
+ node_name='drive0', iothread='iothread0',
|
|
|
ddf19c |
+ force=True)
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ def tearDown(self):
|
|
|
ddf19c |
+ self.vm_src.shutdown()
|
|
|
ddf19c |
+ self.vm_tgt.shutdown()
|
|
|
ddf19c |
+ for name in self.images:
|
|
|
ddf19c |
+ os.remove(self.images[name])
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ def test_nbd_mirror(self):
|
|
|
ddf19c |
+ result = self.vm_tgt.qmp(
|
|
|
ddf19c |
+ 'nbd-server-start',
|
|
|
ddf19c |
+ addr={
|
|
|
ddf19c |
+ 'type': 'unix',
|
|
|
ddf19c |
+ 'data': { 'path': self.nbd_sock }
|
|
|
ddf19c |
+ }
|
|
|
ddf19c |
+ )
|
|
|
ddf19c |
+ self.assert_qmp(result, 'return', {})
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ result = self.vm_tgt.qmp(
|
|
|
ddf19c |
+ 'nbd-server-add',
|
|
|
ddf19c |
+ device='drive0',
|
|
|
ddf19c |
+ writable=True
|
|
|
ddf19c |
+ )
|
|
|
ddf19c |
+ self.assert_qmp(result, 'return', {})
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ result = self.vm_src.qmp(
|
|
|
ddf19c |
+ 'drive-mirror',
|
|
|
ddf19c |
+ device='drive0',
|
|
|
ddf19c |
+ target='nbd+unix:///drive0?socket=' + self.nbd_sock,
|
|
|
ddf19c |
+ sync='full',
|
|
|
ddf19c |
+ mode='existing',
|
|
|
ddf19c |
+ speed=64*1024*1024,
|
|
|
ddf19c |
+ job_id='j1'
|
|
|
ddf19c |
+ )
|
|
|
ddf19c |
+ self.assert_qmp(result, 'return', {})
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ self.vm_src.event_wait(name="BLOCK_JOB_READY")
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+# Test for RHBZ#1779036
|
|
|
ddf19c |
+class TestExternalSnapshotAbort(iotests.QMPTestCase):
|
|
|
ddf19c |
+ drive0_img = os.path.join(iotests.test_dir, 'drive0.img')
|
|
|
ddf19c |
+ snapshot_img = os.path.join(iotests.test_dir, 'snapshot.img')
|
|
|
ddf19c |
+ images = { 'drive0': drive0_img, 'snapshot': snapshot_img }
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ def setUp(self):
|
|
|
ddf19c |
+ for name in self.images:
|
|
|
ddf19c |
+ qemu_img('create', '-f', iotests.imgfmt,
|
|
|
ddf19c |
+ self.images[name], str(image_len))
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ self.vm = iotests.VM()
|
|
|
ddf19c |
+ self.vm.add_object('iothread,id=iothread0')
|
|
|
ddf19c |
+ self.vm.add_blockdev('driver=file,filename=%s,node-name=file0'
|
|
|
ddf19c |
+ % (self.drive0_img))
|
|
|
ddf19c |
+ self.vm.add_blockdev('driver=qcow2,file=file0,node-name=drive0')
|
|
|
ddf19c |
+ self.vm.launch()
|
|
|
ddf19c |
+ self.vm.qmp('x-blockdev-set-iothread',
|
|
|
ddf19c |
+ node_name='drive0', iothread='iothread0',
|
|
|
ddf19c |
+ force=True)
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ def tearDown(self):
|
|
|
ddf19c |
+ self.vm.shutdown()
|
|
|
ddf19c |
+ for name in self.images:
|
|
|
ddf19c |
+ os.remove(self.images[name])
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ def test_external_snapshot_abort(self):
|
|
|
ddf19c |
+ # Use a two actions transaction with a bogus values on the second
|
|
|
ddf19c |
+ # one to trigger an abort of the transaction.
|
|
|
ddf19c |
+ result = self.vm.qmp('transaction', actions=[
|
|
|
ddf19c |
+ {
|
|
|
ddf19c |
+ 'type': 'blockdev-snapshot-sync',
|
|
|
ddf19c |
+ 'data': { 'node-name': 'drive0',
|
|
|
ddf19c |
+ 'snapshot-file': self.snapshot_img,
|
|
|
ddf19c |
+ 'snapshot-node-name': 'snap1',
|
|
|
ddf19c |
+ 'mode': 'absolute-paths',
|
|
|
ddf19c |
+ 'format': 'qcow2' }
|
|
|
ddf19c |
+ },
|
|
|
ddf19c |
+ {
|
|
|
ddf19c |
+ 'type': 'blockdev-snapshot-sync',
|
|
|
ddf19c |
+ 'data': { 'node-name': 'drive0',
|
|
|
ddf19c |
+ 'snapshot-file': '/fakesnapshot',
|
|
|
ddf19c |
+ 'snapshot-node-name': 'snap2',
|
|
|
ddf19c |
+ 'mode': 'absolute-paths',
|
|
|
ddf19c |
+ 'format': 'qcow2' }
|
|
|
ddf19c |
+ },
|
|
|
ddf19c |
+ ])
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ # Crashes on failure, we expect this error.
|
|
|
ddf19c |
+ self.assert_qmp(result, 'error/class', 'GenericError')
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+# Test for RHBZ#1782111
|
|
|
ddf19c |
+class TestBlockdevBackupAbort(iotests.QMPTestCase):
|
|
|
ddf19c |
+ drive0_img = os.path.join(iotests.test_dir, 'drive0.img')
|
|
|
ddf19c |
+ drive1_img = os.path.join(iotests.test_dir, 'drive1.img')
|
|
|
ddf19c |
+ snap0_img = os.path.join(iotests.test_dir, 'snap0.img')
|
|
|
ddf19c |
+ snap1_img = os.path.join(iotests.test_dir, 'snap1.img')
|
|
|
ddf19c |
+ images = { 'drive0': drive0_img,
|
|
|
ddf19c |
+ 'drive1': drive1_img,
|
|
|
ddf19c |
+ 'snap0': snap0_img,
|
|
|
ddf19c |
+ 'snap1': snap1_img }
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ def setUp(self):
|
|
|
ddf19c |
+ for name in self.images:
|
|
|
ddf19c |
+ qemu_img('create', '-f', iotests.imgfmt,
|
|
|
ddf19c |
+ self.images[name], str(image_len))
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ self.vm = iotests.VM()
|
|
|
ddf19c |
+ self.vm.add_object('iothread,id=iothread0')
|
|
|
ddf19c |
+ self.vm.add_device('virtio-scsi,iothread=iothread0')
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ for name in self.images:
|
|
|
ddf19c |
+ self.vm.add_blockdev('driver=file,filename=%s,node-name=file_%s'
|
|
|
ddf19c |
+ % (self.images[name], name))
|
|
|
ddf19c |
+ self.vm.add_blockdev('driver=qcow2,file=file_%s,node-name=%s'
|
|
|
ddf19c |
+ % (name, name))
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ self.vm.add_device('scsi-hd,drive=drive0')
|
|
|
ddf19c |
+ self.vm.add_device('scsi-hd,drive=drive1')
|
|
|
ddf19c |
+ self.vm.launch()
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ def tearDown(self):
|
|
|
ddf19c |
+ self.vm.shutdown()
|
|
|
ddf19c |
+ for name in self.images:
|
|
|
ddf19c |
+ os.remove(self.images[name])
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ def test_blockdev_backup_abort(self):
|
|
|
ddf19c |
+ # Use a two actions transaction with a bogus values on the second
|
|
|
ddf19c |
+ # one to trigger an abort of the transaction.
|
|
|
ddf19c |
+ result = self.vm.qmp('transaction', actions=[
|
|
|
ddf19c |
+ {
|
|
|
ddf19c |
+ 'type': 'blockdev-backup',
|
|
|
ddf19c |
+ 'data': { 'device': 'drive0',
|
|
|
ddf19c |
+ 'target': 'snap0',
|
|
|
ddf19c |
+ 'sync': 'full',
|
|
|
ddf19c |
+ 'job-id': 'j1' }
|
|
|
ddf19c |
+ },
|
|
|
ddf19c |
+ {
|
|
|
ddf19c |
+ 'type': 'blockdev-backup',
|
|
|
ddf19c |
+ 'data': { 'device': 'drive1',
|
|
|
ddf19c |
+ 'target': 'snap1',
|
|
|
ddf19c |
+ 'sync': 'full' }
|
|
|
ddf19c |
+ },
|
|
|
ddf19c |
+ ])
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+ # Hangs on failure, we expect this error.
|
|
|
ddf19c |
+ self.assert_qmp(result, 'error/class', 'GenericError')
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+if __name__ == '__main__':
|
|
|
ddf19c |
+ iotests.main(supported_fmts=['qcow2'],
|
|
|
ddf19c |
+ supported_protocols=['file'])
|
|
|
ddf19c |
diff --git a/tests/qemu-iotests/281.out b/tests/qemu-iotests/281.out
|
|
|
ddf19c |
new file mode 100644
|
|
|
ddf19c |
index 0000000..89968f3
|
|
|
ddf19c |
--- /dev/null
|
|
|
ddf19c |
+++ b/tests/qemu-iotests/281.out
|
|
|
ddf19c |
@@ -0,0 +1,5 @@
|
|
|
ddf19c |
+....
|
|
|
ddf19c |
+----------------------------------------------------------------------
|
|
|
ddf19c |
+Ran 4 tests
|
|
|
ddf19c |
+
|
|
|
ddf19c |
+OK
|
|
|
ddf19c |
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
|
|
|
ddf19c |
index 01301cd..c0e8197 100644
|
|
|
ddf19c |
--- a/tests/qemu-iotests/group
|
|
|
ddf19c |
+++ b/tests/qemu-iotests/group
|
|
|
ddf19c |
@@ -287,3 +287,4 @@
|
|
|
ddf19c |
273 backing quick
|
|
|
ddf19c |
277 rw quick
|
|
|
ddf19c |
280 rw migration quick
|
|
|
ddf19c |
+281 rw quick
|
|
|
ddf19c |
--
|
|
|
ddf19c |
1.8.3.1
|
|
|
ddf19c |
|