2 QEMU development and testing utilities
4 This package provides a small handful of utilities for performing
5 various tasks not directly related to the launching of a VM.
8 # Copyright (C) 2021 Red Hat Inc.
14 # This work is licensed under the terms of the GNU GPL, version 2. See
15 # the COPYING file in the top-level directory.
19 from typing import Optional
21 # pylint: disable=import-error
22 from .accel import kvm_available, list_accel, tcg_available
26 'get_info_usernet_hostfwd_port',
33 def get_info_usernet_hostfwd_port(info_usernet_output: str) -> Optional[int]:
35 Returns the port given to the hostfwd parameter via info usernet
37 :param info_usernet_output: output generated by hmp command "info usernet"
38 :return: the port number allocated by the hostfwd option
40 for line in info_usernet_output.split('\r\n'):
41 regex = r'TCP.HOST_FORWARD.*127\.0\.0\.1\s+(\d+)\s+10\.'
42 match = re.search(regex, line)