mips-fulong2e: obey -vga none
[qemu/ar7.git] / tests / acceptance / migration.py
blob6115cf6c2440110dfa0876f9be67be0b94ede601
1 # Migration test
3 # Copyright (c) 2019 Red Hat, Inc.
5 # Authors:
6 # Cleber Rosa <crosa@redhat.com>
7 # Caio Carrara <ccarrara@redhat.com>
9 # This work is licensed under the terms of the GNU GPL, version 2 or
10 # later. See the COPYING file in the top-level directory.
13 from avocado_qemu import Test
15 from avocado.utils import network
16 from avocado.utils import wait
19 class Migration(Test):
20 """
21 :avocado: enable
22 """
24 timeout = 10
26 @staticmethod
27 def migration_finished(vm):
28 return vm.command('query-migrate')['status'] in ('completed', 'failed')
30 def _get_free_port(self):
31 port = network.find_free_port()
32 if port is None:
33 self.cancel('Failed to find a free port')
34 return port
37 def test_migration_with_tcp_localhost(self):
38 source_vm = self.get_vm()
39 dest_uri = 'tcp:localhost:%u' % self._get_free_port()
40 dest_vm = self.get_vm('-incoming', dest_uri)
41 dest_vm.launch()
42 source_vm.launch()
43 source_vm.qmp('migrate', uri=dest_uri)
44 wait.wait_for(
45 self.migration_finished,
46 timeout=self.timeout,
47 step=0.1,
48 args=(source_vm,)
50 self.assertEqual(dest_vm.command('query-migrate')['status'], 'completed')
51 self.assertEqual(source_vm.command('query-migrate')['status'], 'completed')
52 self.assertEqual(dest_vm.command('query-status')['status'], 'running')
53 self.assertEqual(source_vm.command('query-status')['status'], 'postmigrate')