qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 10/22] Python: add utility function for retrieving port redir


From: John Snow
Subject: Re: [PATCH 10/22] Python: add utility function for retrieving port redirection
Date: Thu, 4 Feb 2021 19:25:52 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0

On 2/3/21 12:23 PM, Cleber Rosa wrote:
Slightly different versions for the same utility code are currently
present on different locations.  This unifies them all, giving
preference to the version from virtiofs_submounts.py, because of the
last tweaks added to it.

While at it, this adds a "qemu.util" module to host the utility
function and a test.


qemu.utils, with the s!

And, OK, this makes me feel less weird about creating a qemu.utils package, actually.

ACK (but not reviewed, tested or linted) for the new code heading into python/qemu/.

--js

Signed-off-by: Cleber Rosa <crosa@redhat.com>
---
  python/qemu/utils.py                     | 35 ++++++++++++++++++++++++
  tests/acceptance/info_usernet.py         | 29 ++++++++++++++++++++
  tests/acceptance/linux_ssh_mips_malta.py | 16 +++++------
  tests/acceptance/virtiofs_submounts.py   | 20 +++-----------
  tests/vm/basevm.py                       |  7 ++---
  5 files changed, 77 insertions(+), 30 deletions(-)
  create mode 100644 python/qemu/utils.py
  create mode 100644 tests/acceptance/info_usernet.py

diff --git a/python/qemu/utils.py b/python/qemu/utils.py
new file mode 100644
index 0000000000..89a246ab30
--- /dev/null
+++ b/python/qemu/utils.py
@@ -0,0 +1,35 @@
+"""
+QEMU utility library
+
+This offers miscellaneous utility functions, which may not be easily
+distinguishable or numerous to be in their own module.
+"""
+
+# Copyright (C) 2021 Red Hat Inc.
+#
+# Authors:
+#  Cleber Rosa <crosa@redhat.com>
+#
+# This work is licensed under the terms of the GNU GPL, version 2.  See
+# the COPYING file in the top-level directory.
+#
+
+import re
+from typing import Optional
+
+
+def get_info_usernet_hostfwd_port(info_usernet_output: str) -> Optional[int]:
+    """
+    Returns the port given to the hostfwd parameter via info usernet
+
+    :param info_usernet_output: output generated by hmp command "info usernet"
+    :param info_usernet_output: str
+    :return: the port number allocated by the hostfwd option
+    :rtype: int

We can probably delete the :rtype: field, can't we? Annotations should handle this information now.

(Unless some tool needs it for compatibility reasons, but we don't use this field anywhere else in ./python/ yet.)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]