tests/functional/migration: add VM launch/configure hooks
Introduce configure_machine, launch_source_vm and assert_dest_vm methods to allow child classes to override some pieces of source/dest VMs creation, start and check logic. Reviewed-by: Peter Xu <peterx@redhat.com> Acked-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@futurfusion.io> Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Alexander Mikhalitsyn committed
Jun 11, 2026 at 20:08 UTC
cb8f285ce9c9b74e7604eb3bc67928887636ddf2
1 file changed
+20
-3
tests/functional/migration.py
+20
-3
@@ -40,19 +40,36 @@ class MigrationTest(QemuSystemTest):
40
self.assertEqual(dst_vm.cmd('query-status')['status'], 'running')
41
self.assertEqual(src_vm.cmd('query-status')['status'],'postmigrate')
42
43
+ # Can be overridden by subclasses to configure both source/dest VMs.
44
+ def configure_machine(self, vm):
45
+ vm.add_args('-nodefaults')
46
+
47
+ # Can be overridden by subclasses to prepare the source VM before
48
+ # migration, e.g. by running some workload inside the source VM
49
+ # to see if it continues to run properly after migration.
50
+ def launch_source_vm(self, vm):
51
+ vm.launch()
52
+
53
+ # Can be overridden by subclasses to check the destination VM after
54
+ # migration, e.g. by checking if the workload is still running after
55
+ # migration.
56
+ def assert_dest_vm(self, vm):
57
+ pass
58
+
59
def migrate_vms(self, dst_uri, src_uri, dst_vm, src_vm):
60
dst_vm.qmp('migrate-incoming', uri=dst_uri)
61
src_vm.qmp('migrate', uri=src_uri)
62
self.assert_migration(src_vm, dst_vm)
63
+ self.assert_dest_vm(dst_vm)
64
65
def migrate(self, dst_uri, src_uri=None):
66
dst_vm = self.get_vm('-incoming', 'defer', name="dst-qemu")
50
- dst_vm.add_args('-nodefaults')
67
+ self.configure_machine(dst_vm)
68
dst_vm.launch()
69
70
src_vm = self.get_vm(name="src-qemu")
54
- src_vm.add_args('-nodefaults')
55
- src_vm.launch()
71
+ self.configure_machine(src_vm)
72
+ self.launch_source_vm(src_vm)
73
74
if src_uri is None:
75
src_uri = dst_uri