Blame SOURCES/kvm-iotests-Backup-with-different-source-target-size.patch

ddf19c
From 456c5e79c32e3f2f9319a7d1452fe523aded7835 Mon Sep 17 00:00:00 2001
ddf19c
From: Kevin Wolf <kwolf@redhat.com>
ddf19c
Date: Wed, 3 Jun 2020 16:03:21 +0100
ddf19c
Subject: [PATCH 22/26] iotests: Backup with different source/target size
ddf19c
ddf19c
RH-Author: Kevin Wolf <kwolf@redhat.com>
ddf19c
Message-id: <20200603160325.67506-8-kwolf@redhat.com>
ddf19c
Patchwork-id: 97106
ddf19c
O-Subject: [RHEL-AV-8.2.1 qemu-kvm PATCH v2 07/11] iotests: Backup with different source/target size
ddf19c
Bugzilla: 1778593
ddf19c
RH-Acked-by: Eric Blake <eblake@redhat.com>
ddf19c
RH-Acked-by: Max Reitz <mreitz@redhat.com>
ddf19c
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
ddf19c
ddf19c
This tests that the backup job catches situations where the target node
ddf19c
has a different size than the source node. It must also forbid resize
ddf19c
operations when the job is already running.
ddf19c
ddf19c
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ddf19c
Message-Id: <20200430142755.315494-5-kwolf@redhat.com>
ddf19c
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
ddf19c
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ddf19c
(cherry picked from commit 0a82a9273062d05764e3df3637b3aa95ad8291c6)
ddf19c
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ddf19c
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
ddf19c
---
ddf19c
 tests/qemu-iotests/055     | 42 ++++++++++++++++++++++++++++++++++++++++--
ddf19c
 tests/qemu-iotests/055.out |  4 ++--
ddf19c
 2 files changed, 42 insertions(+), 4 deletions(-)
ddf19c
ddf19c
diff --git a/tests/qemu-iotests/055 b/tests/qemu-iotests/055
ddf19c
index c9cdc06..1c70389 100755
ddf19c
--- a/tests/qemu-iotests/055
ddf19c
+++ b/tests/qemu-iotests/055
ddf19c
@@ -48,8 +48,10 @@ class TestSingleDrive(iotests.QMPTestCase):
ddf19c
     def setUp(self):
ddf19c
         qemu_img('create', '-f', iotests.imgfmt, blockdev_target_img, str(image_len))
ddf19c
 
ddf19c
-        self.vm = iotests.VM().add_drive('blkdebug::' + test_img)
ddf19c
-        self.vm.add_drive(blockdev_target_img, interface="none")
ddf19c
+        self.vm = iotests.VM()
ddf19c
+        self.vm.add_drive('blkdebug::' + test_img, 'node-name=source')
ddf19c
+        self.vm.add_drive(blockdev_target_img, 'node-name=target',
ddf19c
+                          interface="none")
ddf19c
         if iotests.qemu_default_machine == 'pc':
ddf19c
             self.vm.add_drive(None, 'media=cdrom', 'ide')
ddf19c
         self.vm.launch()
ddf19c
@@ -112,6 +114,42 @@ class TestSingleDrive(iotests.QMPTestCase):
ddf19c
     def test_pause_blockdev_backup(self):
ddf19c
         self.do_test_pause('blockdev-backup', 'drive1', blockdev_target_img)
ddf19c
 
ddf19c
+    def do_test_resize_blockdev_backup(self, device, node):
ddf19c
+        def pre_finalize():
ddf19c
+            result = self.vm.qmp('block_resize', device=device, size=65536)
ddf19c
+            self.assert_qmp(result, 'error/class', 'GenericError')
ddf19c
+
ddf19c
+            result = self.vm.qmp('block_resize', node_name=node, size=65536)
ddf19c
+            self.assert_qmp(result, 'error/class', 'GenericError')
ddf19c
+
ddf19c
+        result = self.vm.qmp('blockdev-backup', job_id='job0', device='drive0',
ddf19c
+                             target='drive1', sync='full', auto_finalize=False,
ddf19c
+                             auto_dismiss=False)
ddf19c
+        self.assert_qmp(result, 'return', {})
ddf19c
+
ddf19c
+        self.vm.run_job('job0', auto_finalize=False, pre_finalize=pre_finalize,
ddf19c
+                        use_log=False)
ddf19c
+
ddf19c
+    def test_source_resize_blockdev_backup(self):
ddf19c
+        self.do_test_resize_blockdev_backup('drive0', 'source')
ddf19c
+
ddf19c
+    def test_target_resize_blockdev_backup(self):
ddf19c
+        self.do_test_resize_blockdev_backup('drive1', 'target')
ddf19c
+
ddf19c
+    def do_test_target_size(self, size):
ddf19c
+        result = self.vm.qmp('block_resize', device='drive1', size=size)
ddf19c
+        self.assert_qmp(result, 'return', {})
ddf19c
+
ddf19c
+        result = self.vm.qmp('blockdev-backup', job_id='job0', device='drive0',
ddf19c
+                             target='drive1', sync='full')
ddf19c
+        self.assert_qmp(result, 'error/class', 'GenericError')
ddf19c
+
ddf19c
+    def test_small_target(self):
ddf19c
+        self.do_test_target_size(image_len // 2)
ddf19c
+
ddf19c
+    def test_large_target(self):
ddf19c
+        self.do_test_target_size(image_len * 2)
ddf19c
+
ddf19c
     def test_medium_not_found(self):
ddf19c
         if iotests.qemu_default_machine != 'pc':
ddf19c
             return
ddf19c
diff --git a/tests/qemu-iotests/055.out b/tests/qemu-iotests/055.out
ddf19c
index 5c26d15..0a5e958 100644
ddf19c
--- a/tests/qemu-iotests/055.out
ddf19c
+++ b/tests/qemu-iotests/055.out
ddf19c
@@ -1,5 +1,5 @@
ddf19c
-....................................
ddf19c
+........................................
ddf19c
 ----------------------------------------------------------------------
ddf19c
-Ran 36 tests
ddf19c
+Ran 40 tests
ddf19c
 
ddf19c
 OK
ddf19c
-- 
ddf19c
1.8.3.1
ddf19c