[PATCH v3 02/19] python/qmp: Fix type of SocketAddrT

John Snow posted 19 patches 4 years, 8 months ago
Maintainers: Eduardo Habkost <ehabkost@redhat.com>, John Snow <jsnow@redhat.com>, Cleber Rosa <crosa@redhat.com>, Markus Armbruster <armbru@redhat.com>
[PATCH v3 02/19] python/qmp: Fix type of SocketAddrT
Posted by John Snow 4 years, 8 months ago
In porting the qom tools, qmp-shell, etc; it becomes evident that this
type is wrong.

This is an integer, not a string. We didn't catch this before because
none of QEMUMonitorProtocol's *users* happen to be checked, and the
internal logic of this class is otherwise self-consistent. Additionally,
mypy was not introspecting into the socket() interface to realize we
were passing a bad type for AF_INET. Fixed now.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 python/qemu/qmp/__init__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/python/qemu/qmp/__init__.py b/python/qemu/qmp/__init__.py
index 9606248a3d2..5fb970f8a80 100644
--- a/python/qemu/qmp/__init__.py
+++ b/python/qemu/qmp/__init__.py
@@ -44,7 +44,7 @@
 QMPMessage = Dict[str, Any]
 QMPReturnValue = Dict[str, Any]
 
-InternetAddrT = Tuple[str, str]
+InternetAddrT = Tuple[str, int]
 UnixAddrT = str
 SocketAddrT = Union[InternetAddrT, UnixAddrT]
 
-- 
2.31.1


Re: [PATCH v3 02/19] python/qmp: Fix type of SocketAddrT
Posted by Philippe Mathieu-Daudé 4 years, 8 months ago
On 6/3/21 2:37 AM, John Snow wrote:
> In porting the qom tools, qmp-shell, etc; it becomes evident that this
> type is wrong.
> 
> This is an integer, not a string. We didn't catch this before because
> none of QEMUMonitorProtocol's *users* happen to be checked, and the
> internal logic of this class is otherwise self-consistent. Additionally,
> mypy was not introspecting into the socket() interface to realize we
> were passing a bad type for AF_INET. Fixed now.
> 
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
>  python/qemu/qmp/__init__.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>