yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

902636
From aff543186ff316d66b2c7acb434c6c17bdb8da78 Mon Sep 17 00:00:00 2001
902636
From: Kevin Wolf <kwolf@redhat.com>
902636
Date: Wed, 3 Jun 2020 16:03:25 +0100
902636
Subject: [PATCH 26/26] iotests: Mirror with different source/target size
902636
902636
RH-Author: Kevin Wolf <kwolf@redhat.com>
902636
Message-id: <20200603160325.67506-12-kwolf@redhat.com>
902636
Patchwork-id: 97109
902636
O-Subject: [RHEL-AV-8.2.1 qemu-kvm PATCH v2 11/11] iotests: Mirror with different source/target size
902636
Bugzilla: 1778593
902636
RH-Acked-by: Eric Blake <eblake@redhat.com>
902636
RH-Acked-by: Max Reitz <mreitz@redhat.com>
902636
RH-Acked-by: Stefano Garzarella <sgarzare@redhat.com>
902636
902636
This tests that the mirror job catches situations where the target node
902636
has a different size than the source node. It must also forbid resize
902636
operations when the job is already running.
902636
902636
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
902636
Reviewed-by: Eric Blake <eblake@redhat.com>
902636
Message-Id: <20200511135825.219437-5-kwolf@redhat.com>
902636
Reviewed-by: Max Reitz <mreitz@redhat.com>
902636
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
902636
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
902636
(cherry picked from commit 16cea4ee1c8e5a69a058e76f426b2e17974d8d7d)
902636
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
902636
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
902636
---
902636
 tests/qemu-iotests/041     | 45 +++++++++++++++++++++++++++++++++++++++++++++
902636
 tests/qemu-iotests/041.out |  4 ++--
902636
 2 files changed, 47 insertions(+), 2 deletions(-)
902636
902636
diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041
902636
index a543b15..20fb68a 100755
902636
--- a/tests/qemu-iotests/041
902636
+++ b/tests/qemu-iotests/041
902636
@@ -240,6 +240,49 @@ class TestSingleBlockdev(TestSingleDrive):
902636
                              target=self.qmp_target)
902636
         self.assert_qmp(result, 'error/class', 'GenericError')
902636
 
902636
+    def do_test_resize(self, device, node):
902636
+        def pre_finalize():
902636
+            if device:
902636
+                result = self.vm.qmp('block_resize', device=device, size=65536)
902636
+                self.assert_qmp(result, 'error/class', 'GenericError')
902636
+
902636
+            result = self.vm.qmp('block_resize', node_name=node, size=65536)
902636
+            self.assert_qmp(result, 'error/class', 'GenericError')
902636
+
902636
+        result = self.vm.qmp(self.qmp_cmd, job_id='job0', device='drive0',
902636
+                             sync='full', target=self.qmp_target,
902636
+                             auto_finalize=False, auto_dismiss=False)
902636
+        self.assert_qmp(result, 'return', {})
902636
+
902636
+        result = self.vm.run_job('job0', auto_finalize=False,
902636
+                                 pre_finalize=pre_finalize, use_log=False)
902636
+        self.assertEqual(result, None)
902636
+
902636
+    def test_source_resize(self):
902636
+        self.do_test_resize('drive0', 'top')
902636
+
902636
+    def test_target_resize(self):
902636
+        self.do_test_resize(None, self.qmp_target)
902636
+
902636
+    def do_test_target_size(self, size):
902636
+        result = self.vm.qmp('block_resize', node_name=self.qmp_target,
902636
+                             size=size)
902636
+        self.assert_qmp(result, 'return', {})
902636
+
902636
+        result = self.vm.qmp(self.qmp_cmd, job_id='job0',
902636
+                             device='drive0', sync='full', auto_dismiss=False,
902636
+                             target=self.qmp_target)
902636
+        self.assert_qmp(result, 'return', {})
902636
+
902636
+        result = self.vm.run_job('job0', use_log=False)
902636
+        self.assertEqual(result, 'Source and target image have different sizes')
902636
+
902636
+    def test_small_target(self):
902636
+        self.do_test_target_size(self.image_len // 2)
902636
+
902636
+    def test_large_target(self):
902636
+        self.do_test_target_size(self.image_len * 2)
902636
+
902636
     test_large_cluster = None
902636
     test_image_not_found = None
902636
     test_small_buffer2 = None
902636
@@ -251,6 +294,8 @@ class TestSingleDriveZeroLength(TestSingleDrive):
902636
 
902636
 class TestSingleBlockdevZeroLength(TestSingleBlockdev):
902636
     image_len = 0
902636
+    test_small_target = None
902636
+    test_large_target = None
902636
 
902636
 class TestSingleDriveUnalignedLength(TestSingleDrive):
902636
     image_len = 1025 * 1024
902636
diff --git a/tests/qemu-iotests/041.out b/tests/qemu-iotests/041.out
902636
index 2c448b4..3ea6aa4 100644
902636
--- a/tests/qemu-iotests/041.out
902636
+++ b/tests/qemu-iotests/041.out
902636
@@ -1,5 +1,5 @@
902636
-..........................................................................................
902636
+....................................................................................................
902636
 ----------------------------------------------------------------------
902636
-Ran 90 tests
902636
+Ran 100 tests
902636
 
902636
 OK
902636
-- 
902636
1.8.3.1
902636