summaryrefslogtreecommitdiffstats
path: root/python/qemu/qmp.py
Commit message (Collapse)AuthorAgeFilesLines
* python: Treat None-return of greeting cmdLukáš Doktor2020-02-071-1/+1
| | | | | | | | | | | | In case qemu process dies the "monitor.cmd" returns None which gets passed to the "__negotiate_capabilities" and leads to unhandled exception. Let's only check the resp in case it has a value. Signed-off-by: Lukáš Doktor <ldoktor@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com> Message-Id: <20200120071202.30646-1-ldoktor@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
* python/qemu: qmp: Remove unnused attributesWainer dos Santos Moschetta2020-02-071-4/+0Star
| | | | | | | | | | | The `error` and `timeout` attributes in QEMUMonitorProtocol are not used, so this delete them. Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20191227134101.244496-6-wainersm@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
* python/qemu: qmp: Make QEMUMonitorProtocol a context managerWainer dos Santos Moschetta2020-02-071-2/+13
| | | | | | | | | | | | | | | This implement the __enter__ and __exit__ functions on QEMUMonitorProtocol class so that it can be used on 'with' statement and the resources will be free up on block end: with QEMUMonitorProtocol(socket_path) as qmp: qmp.connect() qmp.command('query-status') Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Message-Id: <20200204141111.3207-5-wainersm@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
* python/qemu: qmp: Make accept()'s timeout configurableWainer dos Santos Moschetta2020-02-071-2/+9
| | | | | | | | | | | | Currently the timeout of QEMUMonitorProtocol.accept() is hard-coded to 15.0 seconds. This added the parameter `timeout` so the value can be configured by the user. Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Message-Id: <20200204141111.3207-4-wainersm@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
* python/qemu: Delint the qmp moduleWainer dos Santos Moschetta2020-02-071-10/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | This clean up the pylint-3 report on qmp: ************* Module qemu.qmp python/qemu/qmp.py:1:0: C0111: Missing module docstring (missing-docstring) python/qemu/qmp.py:17:0: C0111: Missing class docstring (missing-docstring) python/qemu/qmp.py:21:0: C0111: Missing class docstring (missing-docstring) python/qemu/qmp.py:25:0: C0111: Missing class docstring (missing-docstring) python/qemu/qmp.py:29:0: C0111: Missing class docstring (missing-docstring) python/qemu/qmp.py:33:0: C0111: Missing class docstring (missing-docstring) python/qemu/qmp.py:33:0: R0205: Class 'QEMUMonitorProtocol' inherits from object, can be safely removed from bases in python3 (useless-object-inheritance) python/qemu/qmp.py:80:4: R1710: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements) python/qemu/qmp.py:131:4: R1710: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements) python/qemu/qmp.py:159:4: R1710: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements) python/qemu/qmp.py:245:4: C0111: Missing method docstring (missing-docstring) python/qemu/qmp.py:249:4: C0111: Missing method docstring (missing-docstring) python/qemu/qmp.py:252:4: C0111: Missing method docstring (missing-docstring) python/qemu/qmp.py:255:4: C0111: Missing method docstring (missing-docstring) Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20191227134101.244496-3-wainersm@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
* python/qemu: qmp: Replace socket.error with OSErrorWainer dos Santos Moschetta2020-02-071-8/+8
| | | | | | | | | | | The socket.error is deprecated from Python 3.3, instead it is made a link to OSError. This change replaces the occurences of socket.error with OSError. Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Message-Id: <20191227134101.244496-2-wainersm@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
* Introduce a Python module structureCleber Rosa2019-02-221-0/+256
This is a simple move of Python code that wraps common QEMU functionality, and are used by a number of different tests and scripts. By treating that code as a real Python module, we can more easily: * reuse code * have a proper place for the module's own unittests * apply a more consistent style * generate documentation Signed-off-by: Cleber Rosa <crosa@redhat.com> Reviewed-by: Caio Carrara <ccarrara@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Message-Id: <20190206162901.19082-2-crosa@redhat.com> Signed-off-by: Cleber Rosa <crosa@redhat.com>