tests/functional/migration: Use the migrate_vms helper
Change do_migrate() to call the migrate_vms() helper and provide it with the two VMs already created. Rename do_migrate -> migrate and adjust the callers. While here, standardize on the "src" and "dst" names. Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Peter Xu <peterx@redhat.com> Signed-off-by: Fabiano Rosas <farosas@suse.de> Message-ID: <20260303173320.10942-4-farosas@suse.de> Signed-off-by: Thomas Huth <thuth@redhat.com>
Fabiano Rosas committed
Mar 3, 2026 at 14:33 UTC
4a2476634a7ea8fe27f7a8efc70e651c3d167e51
1 file changed
+18
-16
tests/functional/migration.py
+18
-16
@@ -45,17 +45,19 @@ class MigrationTest(QemuSystemTest):
45
src_vm.qmp('migrate', uri=src_uri)
46
self.assert_migration(src_vm, dst_vm)
47
48
- def do_migrate(self, dest_uri, src_uri=None):
49
- dest_vm = self.get_vm('-incoming', dest_uri, name="dest-qemu")
50
- dest_vm.add_args('-nodefaults')
51
- dest_vm.launch()
48
+ def migrate(self, dst_uri, src_uri=None):
49
+ dst_vm = self.get_vm('-incoming', 'defer', name="dst-qemu")
50
+ dst_vm.add_args('-nodefaults')
51
+ dst_vm.launch()
52
+
53
+ src_vm = self.get_vm(name="src-qemu")
54
+ src_vm.add_args('-nodefaults')
55
+ src_vm.launch()
56
+
57
if src_uri is None:
53
- src_uri = dest_uri
54
- source_vm = self.get_vm(name="source-qemu")
55
- source_vm.add_args('-nodefaults')
56
- source_vm.launch()
57
- source_vm.qmp('migrate', uri=src_uri)
58
- self.assert_migration(source_vm, dest_vm)
58
+ src_uri = dst_uri
59
+
60
+ self.migrate_vms(dst_uri, src_uri, dst_vm, src_vm)
61
62
def _get_free_port(self, ports):
63
port = ports.find_free_port()
@@ -65,18 +67,18 @@ class MigrationTest(QemuSystemTest):
67
68
def migration_with_tcp_localhost(self):
69
with Ports() as ports:
68
- dest_uri = 'tcp:localhost:%u' % self._get_free_port(ports)
69
- self.do_migrate(dest_uri)
70
+ dst_uri = 'tcp:localhost:%u' % self._get_free_port(ports)
71
+ self.migrate(dst_uri)
72
73
def migration_with_unix(self):
72
- dest_uri = 'unix:%s/migration.sock' % self.socket_dir().name
73
- self.do_migrate(dest_uri)
74
+ dst_uri = 'unix:%s/migration.sock' % self.socket_dir().name
75
+ self.migrate(dst_uri)
76
77
def migration_with_exec(self):
78
if not which('ncat'):
79
self.skipTest('ncat is not available')
80
with Ports() as ports:
81
free_port = self._get_free_port(ports)
80
- dest_uri = 'exec:ncat -l localhost %u' % free_port
82
+ dst_uri = 'exec:ncat -l localhost %u' % free_port
83
src_uri = 'exec:ncat localhost %u' % free_port
82
- self.do_migrate(dest_uri, src_uri)
84
+ self.migrate(dst_uri, src_uri)