qcow: manually add more coroutine_fn annotations
[qemu.git] / tests / avocado / info_usernet.py
blobb862a47dba08f42881d866ac913028c2a60a2c4a
1 # Test for the hmp command "info usernet"
3 # Copyright (c) 2021 Red Hat, Inc.
5 # Author:
6 # Cleber Rosa <crosa@redhat.com>
8 # This work is licensed under the terms of the GNU GPL, version 2 or
9 # later. See the COPYING file in the top-level directory.
11 from avocado_qemu import QemuSystemTest
13 from qemu.utils import get_info_usernet_hostfwd_port
16 class InfoUsernet(QemuSystemTest):
18 def test_hostfwd(self):
19 self.require_netdev('user')
20 self.vm.add_args('-netdev', 'user,id=vnet,hostfwd=:127.0.0.1:0-:22')
21 self.vm.launch()
22 res = self.vm.command('human-monitor-command',
23 command_line='info usernet')
24 port = get_info_usernet_hostfwd_port(res)
25 self.assertIsNotNone(port,
26 ('"info usernet" output content does not seem to '
27 'contain the redirected port'))
28 self.assertGreater(port, 0,
29 ('Found a redirected port that is not greater than'
30 ' zero'))