yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-iotests.py-Let-wait_migration-wait-even-more.patch

22c213
From d6df1426ae65b3a0d50bdbb1f8a7246386dd6ebf Mon Sep 17 00:00:00 2001
22c213
From: Kevin Wolf <kwolf@redhat.com>
22c213
Date: Fri, 7 Feb 2020 11:24:04 +0000
22c213
Subject: [PATCH 07/18] iotests.py: Let wait_migration wait even more
22c213
22c213
RH-Author: Kevin Wolf <kwolf@redhat.com>
22c213
Message-id: <20200207112404.25198-7-kwolf@redhat.com>
22c213
Patchwork-id: 93751
22c213
O-Subject: [RHEL-AV-8.2.0 qemu-kvm PATCH v2 6/6] iotests.py: Let wait_migration wait even more
22c213
Bugzilla: 1781637
22c213
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
22c213
RH-Acked-by: Max Reitz <mreitz@redhat.com>
22c213
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
22c213
22c213
From: Max Reitz <mreitz@redhat.com>
22c213
22c213
The "migration completed" event may be sent (on the source, to be
22c213
specific) before the migration is actually completed, so the VM runstate
22c213
will still be "finish-migrate" instead of "postmigrate".  So ask the
22c213
users of VM.wait_migration() to specify the final runstate they desire
22c213
and then poll the VM until it has reached that state.  (This should be
22c213
over very quickly, so busy polling is fine.)
22c213
22c213
Without this patch, I see intermittent failures in the new iotest 280
22c213
under high system load.  I have not yet seen such failures with other
22c213
iotests that use VM.wait_migration() and query-status afterwards, but
22c213
maybe they just occur even more rarely, or it is because they also wait
22c213
on the destination VM to be running.
22c213
22c213
Signed-off-by: Max Reitz <mreitz@redhat.com>
22c213
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
22c213
(cherry picked from commit 8da7969bd7014f6de037d8ae132b40721944b186)
22c213
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
22c213
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
22c213
---
22c213
 tests/qemu-iotests/234        | 8 ++++----
22c213
 tests/qemu-iotests/262        | 4 ++--
22c213
 tests/qemu-iotests/280        | 2 +-
22c213
 tests/qemu-iotests/iotests.py | 6 +++++-
22c213
 4 files changed, 12 insertions(+), 8 deletions(-)
22c213
22c213
diff --git a/tests/qemu-iotests/234 b/tests/qemu-iotests/234
22c213
index 34c818c..59a7f94 100755
22c213
--- a/tests/qemu-iotests/234
22c213
+++ b/tests/qemu-iotests/234
22c213
@@ -69,9 +69,9 @@ with iotests.FilePath('img') as img_path, \
22c213
     iotests.log(vm_a.qmp('migrate', uri='exec:cat >%s' % (fifo_a)))
22c213
     with iotests.Timeout(3, 'Migration does not complete'):
22c213
         # Wait for the source first (which includes setup=setup)
22c213
-        vm_a.wait_migration()
22c213
+        vm_a.wait_migration('postmigrate')
22c213
         # Wait for the destination second (which does not)
22c213
-        vm_b.wait_migration()
22c213
+        vm_b.wait_migration('running')
22c213
 
22c213
     iotests.log(vm_a.qmp('query-migrate')['return']['status'])
22c213
     iotests.log(vm_b.qmp('query-migrate')['return']['status'])
22c213
@@ -98,9 +98,9 @@ with iotests.FilePath('img') as img_path, \
22c213
     iotests.log(vm_b.qmp('migrate', uri='exec:cat >%s' % (fifo_b)))
22c213
     with iotests.Timeout(3, 'Migration does not complete'):
22c213
         # Wait for the source first (which includes setup=setup)
22c213
-        vm_b.wait_migration()
22c213
+        vm_b.wait_migration('postmigrate')
22c213
         # Wait for the destination second (which does not)
22c213
-        vm_a.wait_migration()
22c213
+        vm_a.wait_migration('running')
22c213
 
22c213
     iotests.log(vm_a.qmp('query-migrate')['return']['status'])
22c213
     iotests.log(vm_b.qmp('query-migrate')['return']['status'])
22c213
diff --git a/tests/qemu-iotests/262 b/tests/qemu-iotests/262
22c213
index 0963daa..bbcb526 100755
22c213
--- a/tests/qemu-iotests/262
22c213
+++ b/tests/qemu-iotests/262
22c213
@@ -71,9 +71,9 @@ with iotests.FilePath('img') as img_path, \
22c213
     iotests.log(vm_a.qmp('migrate', uri='exec:cat >%s' % (fifo)))
22c213
     with iotests.Timeout(3, 'Migration does not complete'):
22c213
         # Wait for the source first (which includes setup=setup)
22c213
-        vm_a.wait_migration()
22c213
+        vm_a.wait_migration('postmigrate')
22c213
         # Wait for the destination second (which does not)
22c213
-        vm_b.wait_migration()
22c213
+        vm_b.wait_migration('running')
22c213
 
22c213
     iotests.log(vm_a.qmp('query-migrate')['return']['status'])
22c213
     iotests.log(vm_b.qmp('query-migrate')['return']['status'])
22c213
diff --git a/tests/qemu-iotests/280 b/tests/qemu-iotests/280
22c213
index 0b1fa8e..85e9114 100755
22c213
--- a/tests/qemu-iotests/280
22c213
+++ b/tests/qemu-iotests/280
22c213
@@ -45,7 +45,7 @@ with iotests.FilePath('base') as base_path , \
22c213
     vm.qmp_log('migrate', uri='exec:cat > /dev/null')
22c213
 
22c213
     with iotests.Timeout(3, 'Migration does not complete'):
22c213
-        vm.wait_migration()
22c213
+        vm.wait_migration('postmigrate')
22c213
 
22c213
     iotests.log('\nVM is now stopped:')
22c213
     iotests.log(vm.qmp('query-migrate')['return']['status'])
22c213
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
22c213
index 5741efb..0c55f7b 100644
22c213
--- a/tests/qemu-iotests/iotests.py
22c213
+++ b/tests/qemu-iotests/iotests.py
22c213
@@ -663,12 +663,16 @@ class VM(qtest.QEMUQtestMachine):
22c213
             }
22c213
         ]))
22c213
 
22c213
-    def wait_migration(self):
22c213
+    def wait_migration(self, expect_runstate):
22c213
         while True:
22c213
             event = self.event_wait('MIGRATION')
22c213
             log(event, filters=[filter_qmp_event])
22c213
             if event['data']['status'] == 'completed':
22c213
                 break
22c213
+        # The event may occur in finish-migrate, so wait for the expected
22c213
+        # post-migration runstate
22c213
+        while self.qmp('query-status')['return']['status'] != expect_runstate:
22c213
+            pass
22c213
 
22c213
     def node_info(self, node_name):
22c213
         nodes = self.qmp('query-named-block-nodes')
22c213
-- 
22c213
1.8.3.1
22c213