Blame SOURCES/kvm-iotests-169-add-cases-for-source-vm-resuming.patch

383d26
From b12adbb5e07d5c146f500e920a3dc1278dfebe53 Mon Sep 17 00:00:00 2001
383d26
From: John Snow <jsnow@redhat.com>
383d26
Date: Wed, 6 Feb 2019 22:12:43 +0100
383d26
Subject: [PATCH 33/33] iotests: 169: add cases for source vm resuming
383d26
383d26
RH-Author: John Snow <jsnow@redhat.com>
383d26
Message-id: <20190206221243.7407-24-jsnow@redhat.com>
383d26
Patchwork-id: 84277
383d26
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH v2 23/23] iotests: 169: add cases for source vm resuming
383d26
Bugzilla: 1658343
383d26
RH-Acked-by: Thomas Huth <thuth@redhat.com>
383d26
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
383d26
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
383d26
383d26
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
383d26
383d26
Test that we can resume source vm after [failed] migration, and bitmaps
383d26
are ok.
383d26
383d26
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
383d26
Signed-off-by: John Snow <jsnow@redhat.com>
383d26
(cherry picked from commit 3e6d88f280a53b5b399e73b1f80efe4c3db306f1)
383d26
Signed-off-by: John Snow <jsnow@redhat.com>
383d26
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
383d26
---
383d26
 tests/qemu-iotests/169     | 60 +++++++++++++++++++++++++++++++++++++++++++++-
383d26
 tests/qemu-iotests/169.out |  4 ++--
383d26
 2 files changed, 61 insertions(+), 3 deletions(-)
383d26
383d26
diff --git a/tests/qemu-iotests/169 b/tests/qemu-iotests/169
383d26
index 8b7947d..69850c4 100755
383d26
--- a/tests/qemu-iotests/169
383d26
+++ b/tests/qemu-iotests/169
383d26
@@ -77,6 +77,58 @@ class TestDirtyBitmapMigration(iotests.QMPTestCase):
383d26
             self.assert_qmp(result, 'error/desc',
383d26
                             "Dirty bitmap 'bitmap0' not found");
383d26
 
383d26
+    def do_test_migration_resume_source(self, persistent, migrate_bitmaps):
383d26
+        granularity = 512
383d26
+
383d26
+        # regions = ((start, count), ...)
383d26
+        regions = ((0, 0x10000),
383d26
+                   (0xf0000, 0x10000),
383d26
+                   (0xa0201, 0x1000))
383d26
+
383d26
+        mig_caps = [{'capability': 'events', 'state': True}]
383d26
+        if migrate_bitmaps:
383d26
+            mig_caps.append({'capability': 'dirty-bitmaps', 'state': True})
383d26
+
383d26
+        result = self.vm_a.qmp('migrate-set-capabilities',
383d26
+                               capabilities=mig_caps)
383d26
+        self.assert_qmp(result, 'return', {})
383d26
+
383d26
+        self.add_bitmap(self.vm_a, granularity, persistent)
383d26
+        for r in regions:
383d26
+            self.vm_a.hmp_qemu_io('drive0', 'write %d %d' % r)
383d26
+        sha256 = self.get_bitmap_hash(self.vm_a)
383d26
+
383d26
+        result = self.vm_a.qmp('migrate', uri=mig_cmd)
383d26
+        while True:
383d26
+            event = self.vm_a.event_wait('MIGRATION')
383d26
+            if event['data']['status'] == 'completed':
383d26
+                break
383d26
+
383d26
+        # test that bitmap is still here
383d26
+        removed = (not migrate_bitmaps) and persistent
383d26
+        self.check_bitmap(self.vm_a, False if removed else sha256)
383d26
+
383d26
+        self.vm_a.qmp('cont')
383d26
+
383d26
+        # test that bitmap is still here after invalidation
383d26
+        self.check_bitmap(self.vm_a, sha256)
383d26
+
383d26
+        # shutdown and check that invalidation didn't fail
383d26
+        self.vm_a.shutdown()
383d26
+
383d26
+        # catch 'Could not reopen qcow2 layer: Bitmap already exists'
383d26
+        # possible error
383d26
+        log = self.vm_a.get_log()
383d26
+        log = re.sub(r'^\[I \d+\.\d+\] OPENED\n', '', log)
383d26
+        log = re.sub(r'^(wrote .* bytes at offset .*\n.*KiB.*ops.*sec.*\n){3}',
383d26
+                     '', log)
383d26
+        log = re.sub(r'\[I \+\d+\.\d+\] CLOSED\n?$', '', log)
383d26
+        self.assertEqual(log, '')
383d26
+
383d26
+        # test that bitmap is still persistent
383d26
+        self.vm_a.launch()
383d26
+        self.check_bitmap(self.vm_a, sha256 if persistent else False)
383d26
+
383d26
     def do_test_migration(self, persistent, migrate_bitmaps, online,
383d26
                           shared_storage):
383d26
         granularity = 512
383d26
@@ -152,7 +204,7 @@ class TestDirtyBitmapMigration(iotests.QMPTestCase):
383d26
 
383d26
 def inject_test_case(klass, name, method, *args, **kwargs):
383d26
     mc = operator.methodcaller(method, *args, **kwargs)
383d26
-    setattr(klass, 'test_' + name, new.instancemethod(mc, None, klass))
383d26
+    setattr(klass, 'test_' + method + name, new.instancemethod(mc, None, klass))
383d26
 
383d26
 for cmb in list(itertools.product((True, False), repeat=4)):
383d26
     name = ('_' if cmb[0] else '_not_') + 'persistent_'
383d26
@@ -163,6 +215,12 @@ for cmb in list(itertools.product((True, False), repeat=4)):
383d26
     inject_test_case(TestDirtyBitmapMigration, name, 'do_test_migration',
383d26
                      *list(cmb))
383d26
 
383d26
+for cmb in list(itertools.product((True, False), repeat=2)):
383d26
+    name = ('_' if cmb[0] else '_not_') + 'persistent_'
383d26
+    name += ('_' if cmb[1] else '_not_') + 'migbitmap'
383d26
+
383d26
+    inject_test_case(TestDirtyBitmapMigration, name,
383d26
+                     'do_test_migration_resume_source', *list(cmb))
383d26
 
383d26
 if __name__ == '__main__':
383d26
     iotests.main(supported_fmts=['qcow2'])
383d26
diff --git a/tests/qemu-iotests/169.out b/tests/qemu-iotests/169.out
383d26
index b6f2576..3a89159 100644
383d26
--- a/tests/qemu-iotests/169.out
383d26
+++ b/tests/qemu-iotests/169.out
383d26
@@ -1,5 +1,5 @@
383d26
-................
383d26
+....................
383d26
 ----------------------------------------------------------------------
383d26
-Ran 16 tests
383d26
+Ran 20 tests
383d26
 
383d26
 OK
383d26
-- 
383d26
1.8.3.1
383d26