yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

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

ddf19c
From aff543186ff316d66b2c7acb434c6c17bdb8da78 Mon Sep 17 00:00:00 2001
ddf19c
From: Kevin Wolf <kwolf@redhat.com>
ddf19c
Date: Wed, 3 Jun 2020 16:03:25 +0100
ddf19c
Subject: [PATCH 26/26] iotests: Mirror with different source/target size
ddf19c
ddf19c
RH-Author: Kevin Wolf <kwolf@redhat.com>
ddf19c
Message-id: <20200603160325.67506-12-kwolf@redhat.com>
ddf19c
Patchwork-id: 97109
ddf19c
O-Subject: [RHEL-AV-8.2.1 qemu-kvm PATCH v2 11/11] iotests: Mirror 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 mirror 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
Reviewed-by: Eric Blake <eblake@redhat.com>
ddf19c
Message-Id: <20200511135825.219437-5-kwolf@redhat.com>
ddf19c
Reviewed-by: Max Reitz <mreitz@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 16cea4ee1c8e5a69a058e76f426b2e17974d8d7d)
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/041     | 45 +++++++++++++++++++++++++++++++++++++++++++++
ddf19c
 tests/qemu-iotests/041.out |  4 ++--
ddf19c
 2 files changed, 47 insertions(+), 2 deletions(-)
ddf19c
ddf19c
diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041
ddf19c
index a543b15..20fb68a 100755
ddf19c
--- a/tests/qemu-iotests/041
ddf19c
+++ b/tests/qemu-iotests/041
ddf19c
@@ -240,6 +240,49 @@ class TestSingleBlockdev(TestSingleDrive):
ddf19c
                              target=self.qmp_target)
ddf19c
         self.assert_qmp(result, 'error/class', 'GenericError')
ddf19c
 
ddf19c
+    def do_test_resize(self, device, node):
ddf19c
+        def pre_finalize():
ddf19c
+            if device:
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(self.qmp_cmd, job_id='job0', device='drive0',
ddf19c
+                             sync='full', target=self.qmp_target,
ddf19c
+                             auto_finalize=False, auto_dismiss=False)
ddf19c
+        self.assert_qmp(result, 'return', {})
ddf19c
+
ddf19c
+        result = self.vm.run_job('job0', auto_finalize=False,
ddf19c
+                                 pre_finalize=pre_finalize, use_log=False)
ddf19c
+        self.assertEqual(result, None)
ddf19c
+
ddf19c
+    def test_source_resize(self):
ddf19c
+        self.do_test_resize('drive0', 'top')
ddf19c
+
ddf19c
+    def test_target_resize(self):
ddf19c
+        self.do_test_resize(None, self.qmp_target)
ddf19c
+
ddf19c
+    def do_test_target_size(self, size):
ddf19c
+        result = self.vm.qmp('block_resize', node_name=self.qmp_target,
ddf19c
+                             size=size)
ddf19c
+        self.assert_qmp(result, 'return', {})
ddf19c
+
ddf19c
+        result = self.vm.qmp(self.qmp_cmd, job_id='job0',
ddf19c
+                             device='drive0', sync='full', auto_dismiss=False,
ddf19c
+                             target=self.qmp_target)
ddf19c
+        self.assert_qmp(result, 'return', {})
ddf19c
+
ddf19c
+        result = self.vm.run_job('job0', use_log=False)
ddf19c
+        self.assertEqual(result, 'Source and target image have different sizes')
ddf19c
+
ddf19c
+    def test_small_target(self):
ddf19c
+        self.do_test_target_size(self.image_len // 2)
ddf19c
+
ddf19c
+    def test_large_target(self):
ddf19c
+        self.do_test_target_size(self.image_len * 2)
ddf19c
+
ddf19c
     test_large_cluster = None
ddf19c
     test_image_not_found = None
ddf19c
     test_small_buffer2 = None
ddf19c
@@ -251,6 +294,8 @@ class TestSingleDriveZeroLength(TestSingleDrive):
ddf19c
 
ddf19c
 class TestSingleBlockdevZeroLength(TestSingleBlockdev):
ddf19c
     image_len = 0
ddf19c
+    test_small_target = None
ddf19c
+    test_large_target = None
ddf19c
 
ddf19c
 class TestSingleDriveUnalignedLength(TestSingleDrive):
ddf19c
     image_len = 1025 * 1024
ddf19c
diff --git a/tests/qemu-iotests/041.out b/tests/qemu-iotests/041.out
ddf19c
index 2c448b4..3ea6aa4 100644
ddf19c
--- a/tests/qemu-iotests/041.out
ddf19c
+++ b/tests/qemu-iotests/041.out
ddf19c
@@ -1,5 +1,5 @@
ddf19c
-..........................................................................................
ddf19c
+....................................................................................................
ddf19c
 ----------------------------------------------------------------------
ddf19c
-Ran 90 tests
ddf19c
+Ran 100 tests
ddf19c
 
ddf19c
 OK
ddf19c
-- 
ddf19c
1.8.3.1
ddf19c