3afc3290 | 27-May-2021 |
John Snow <jsnow@redhat.com> |
python: add VERSION file
Python infrastructure as it exists today is not capable reliably of single-sourcing a package version from a parent directory. The authors of pip are working to correct this
python: add VERSION file
Python infrastructure as it exists today is not capable reliably of single-sourcing a package version from a parent directory. The authors of pip are working to correct this, but as of today this is not possible.
The problem is that when using pip to build and install a python package, it copies files over to a temporary directory and performs its build there. This loses access to any information in the parent directory, including git itself.
Further, Python versions have a standard (PEP 440) that may or may not follow QEMU's versioning. In general, it does; but naturally QEMU does not follow PEP 440. To avoid any automatically-generated conflict, a manual version file is preferred.
I am proposing:
- Python tooling follows the QEMU version, indirectly, but with a major version of 0 to indicate that the API is not expected to be stable. This would mean version 0.5.2.0, 0.5.1.1, 0.5.3.0, etc.
- In the event that a Python package needs to be updated independently of the QEMU version, a pre-release alpha version should be preferred, but *only* after inclusion to the qemu development or stable branches.
e.g. 0.5.2.0a1, 0.5.2.0a2, and so on should be preferred prior to 5.2.0's release.
- The Python core tooling makes absolutely no version compatibility checks or constraints. It *may* work with releases of QEMU from the past or future, but it is not required to.
i.e., "qemu.machine" will, for now, remain in lock-step with QEMU.
- We reserve the right to split the qemu package into independently versioned subpackages at a later date. This might allow for us to begin versioning QMP independently from QEMU at a later date, if we so choose.
Implement this versioning scheme by adding a VERSION file and setting it to 0.6.0.0a1.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Cleber Rosa <crosa@redhat.com> Message-id: 20210527211715.394144-12-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
show more ...
|
ea1213b7 | 27-May-2021 |
John Snow <jsnow@redhat.com> |
python: add qemu package installer
Add setup.cfg and setup.py, necessary for installing a package via pip. Add a ReST document (PACKAGE.rst) explaining the basics of what this package is for and who
python: add qemu package installer
Add setup.cfg and setup.py, necessary for installing a package via pip. Add a ReST document (PACKAGE.rst) explaining the basics of what this package is for and who to contact for more information. This document will be used as the landing page for the package on PyPI.
List the subpackages we intend to package by name instead of using find_namespace because find_namespace will naively also packages tests, things it finds in the dist/ folder, etc. I could not figure out how to modify this behavior; adding allow/deny lists to setuptools kept changing the packaged hierarchy. This works, roll with it.
I am not yet using a pyproject.toml style package manifest, because "editable" installs are not defined (yet?) by PEP-517/518.
I consider editable installs crucial for development, though they have (apparently) always been somewhat poorly defined.
Pip now (19.2 and later) now supports editable installs for projects using pyproject.toml manifests, but might require the use of the --no-use-pep517 flag, which somewhat defeats the point. Full support for setup.py-less editable installs was not introduced until pip 21.1.1: https://github.com/pypa/pip/pull/9547/commits/7a95720e796a5e56481c1cc20b6ce6249c50f357
For now, while the dust settles, stick with the de-facto setup.py/setup.cfg combination supported by setuptools. It will be worth re-evaluating this point again in the future when our supported build platforms all ship a fairly modern pip.
Additional reading on this matter:
https://github.com/pypa/packaging-problems/issues/256 https://github.com/pypa/pip/issues/6334 https://github.com/pypa/pip/issues/6375 https://github.com/pypa/pip/issues/6434 https://github.com/pypa/pip/issues/6438
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Cleber Rosa <crosa@redhat.com> Message-id: 20210527211715.394144-11-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
show more ...
|
beb6b57b | 27-May-2021 |
John Snow <jsnow@redhat.com> |
python: create qemu packages
move python/qemu/*.py to python/qemu/[machine, qmp, utils]/*.py and update import directives across the tree.
This is done to create a PEP420 namespace package, in whic
python: create qemu packages
move python/qemu/*.py to python/qemu/[machine, qmp, utils]/*.py and update import directives across the tree.
This is done to create a PEP420 namespace package, in which we may create subpackages. To do this, the namespace directory ("qemu") should not have any modules in it. Those files will go into new 'machine', 'qmp' and 'utils' subpackages instead.
Implement machine/__init__.py making the top-level classes and functions from its various modules available directly inside the package. Change qmp.py to qmp/__init__.py similarly, such that all of the useful QMP library classes are available directly from "qemu.qmp" instead of "qemu.qmp.qmp".
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Cleber Rosa <crosa@redhat.com> Message-id: 20210527211715.394144-10-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
show more ...
|
859aeb67 | 27-May-2021 |
John Snow <jsnow@redhat.com> |
python/machine: Trim line length to below 80 chars
One more little delinting fix that snuck in.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@vir
python/machine: Trim line length to below 80 chars
One more little delinting fix that snuck in.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Cleber Rosa <crosa@redhat.com> Message-id: 20210527211715.394144-8-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
show more ...
|
a0eae17a | 27-May-2021 |
John Snow <jsnow@redhat.com> |
python/machine: disable warning for Popen in _launch()
We handle this resource rather meticulously in shutdown/kill/wait/__exit__ et al, through the laborious mechanisms in _do_shutdown().
Quiet th
python/machine: disable warning for Popen in _launch()
We handle this resource rather meticulously in shutdown/kill/wait/__exit__ et al, through the laborious mechanisms in _do_shutdown().
Quiet this pylint warning here.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Cleber Rosa <crosa@redhat.com> Message-id: 20210527211715.394144-7-jsnow@redhat.com Message-id: 20210517184808.3562549-7-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
show more ...
|
63c33f3c | 27-May-2021 |
John Snow <jsnow@redhat.com> |
python/machine: Disable pylint warning for open() in _pre_launch
Shift the open() call later so that the pylint pragma applies *only* to that one open() call. Add a note that suggests why this is sa
python/machine: Disable pylint warning for open() in _pre_launch
Shift the open() call later so that the pylint pragma applies *only* to that one open() call. Add a note that suggests why this is safe: the resource is unconditionally cleaned up in _post_shutdown().
_post_shutdown is called after failed launches (see launch()), and unconditionally after every call to shutdown(), and therefore also on __exit__.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com> Reviewed-by: Cleber Rosa <crosa@redhat.com> Message-id: 20210527211715.394144-6-jsnow@redhat.com Message-id: 20210517184808.3562549-6-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
show more ...
|
8825fed8 | 27-May-2021 |
John Snow <jsnow@redhat.com> |
python/console_socket: Add a pylint ignore
We manage cleaning up this resource ourselves. Pylint should shush.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Cleber Rosa <crosa@redhat.com
python/console_socket: Add a pylint ignore
We manage cleaning up this resource ourselves. Pylint should shush.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Cleber Rosa <crosa@redhat.com> Message-id: 20210527211715.394144-5-jsnow@redhat.com Message-id: 20210517184808.3562549-5-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
show more ...
|
14b41797 | 27-May-2021 |
John Snow <jsnow@redhat.com> |
python/machine: use subprocess.run instead of subprocess.Popen
use run() instead of Popen() -- to assert to pylint that we are not forgetting to close a long-running program.
Signed-off-by: John Sn
python/machine: use subprocess.run instead of subprocess.Popen
use run() instead of Popen() -- to assert to pylint that we are not forgetting to close a long-running program.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Cleber Rosa <crosa@redhat.com> Tested-by: Cleber Rosa <crosa@redhat.com> Message-id: 20210527211715.394144-4-jsnow@redhat.com Message-id: 20210517184808.3562549-4-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
show more ...
|
07b71233 | 27-May-2021 |
John Snow <jsnow@redhat.com> |
python/machine: use subprocess.DEVNULL instead of open(os.path.devnull)
One less file resource to manage, and it helps quiet some pylint >= 2.8.0 warnings about not using a with-context manager for
python/machine: use subprocess.DEVNULL instead of open(os.path.devnull)
One less file resource to manage, and it helps quiet some pylint >= 2.8.0 warnings about not using a with-context manager for the open call.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Cleber Rosa <crosa@redhat.com> Message-id: 20210527211715.394144-3-jsnow@redhat.com Message-id: 20210517184808.3562549-3-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
show more ...
|
976218cb | 11-Apr-2021 |
Cleber Rosa <crosa@redhat.com> |
Python: add utility function for retrieving port redirection
Slightly different versions for the same utility code are currently present on different locations. This unifies them all, giving prefer
Python: add utility function for retrieving port redirection
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.utils" module to host the utility function and a test.
Signed-off-by: Cleber Rosa <crosa@redhat.com> Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com> Reviewed-by: Eric Auger <eric.auger@redhat.com> Reviewed-by: Willian Rampazzo <willianr@redhat.com> Message-Id: <20210412044644.55083-4-crosa@redhat.com> Signed-off-by: John Snow <jsnow@redhat.com> [Squashed in below fix. --js] Signed-off-by: John Snow <jsnow@redhat.com> Signed-off-by: Cleber Rosa <crosa@redhat.com> Message-Id: <20210601154546.130870-2-crosa@redhat.com> Signed-off-by: John Snow <jsnow@redhat.com>
show more ...
|
39cf73c3 | 09-Oct-2020 |
John Snow <jsnow@redhat.com> |
python/qemu/qmp.py: Fix settimeout operation
We enabled callers to interface directly with settimeout, but this reacts poorly with blocking/nonblocking operation; as they are using the same internal
python/qemu/qmp.py: Fix settimeout operation
We enabled callers to interface directly with settimeout, but this reacts poorly with blocking/nonblocking operation; as they are using the same internal mechanism.
1. Whenever we change the blocking mechanism temporarily, always set it back to what it was afterwards.
2. Disallow callers from setting a timeout of "0", which means Non-blocking mode. This is going to create more weird problems than anybody wants, so just forbid it.
I opt not to coerce '0' to 'None' to maintain the principal of least surprise in mirroring the semantics of Python's interface.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-id: 20201009175123.249009-4-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
show more ...
|
d5cca076 | 09-Oct-2020 |
John Snow <jsnow@redhat.com> |
python/qemu/qmp.py: re-raise OSError when encountered
Nested if conditions don't change when the exception block fires; we need to explicitly re-raise the error if we didn't intend to capture and su
python/qemu/qmp.py: re-raise OSError when encountered
Nested if conditions don't change when the exception block fires; we need to explicitly re-raise the error if we didn't intend to capture and suppress it.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-id: 20201009175123.249009-3-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
show more ...
|
c3a404d3 | 09-Oct-2020 |
John Snow <jsnow@redhat.com> |
python: add mypy config
Formalize the options used for checking the python library. You can run mypy from the directory that mypy.ini is in by typing `mypy qemu/`.
Signed-off-by: John Snow <jsnow@r
python: add mypy config
Formalize the options used for checking the python library. You can run mypy from the directory that mypy.ini is in by typing `mypy qemu/`.
Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20201009175123.249009-2-jsnow@redhat.com [Edit: Added newline; thanks Bin Meng --js] Signed-off-by: John Snow <jsnow@redhat.com>
show more ...
|
d2b08b79 | 06-Oct-2020 |
John Snow <jsnow@redhat.com> |
python/qemu/qmp.py: Preserve error context on re-raise
Use the "from ..." phrasing when re-raising errors to preserve their initial context, to help aid debugging when things go wrong.
This also si
python/qemu/qmp.py: Preserve error context on re-raise
Use the "from ..." phrasing when re-raising errors to preserve their initial context, to help aid debugging when things go wrong.
This also silences a pylint 2.6.0+ error.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Message-id: 20201006235817.3280413-18-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
show more ...
|
af0db882 | 06-Oct-2020 |
John Snow <jsnow@redhat.com> |
python/qemu/console_socket.py: avoid encoding to/from string
We can work directly in bytes instead of translating back and forth to string, which removes the question of which encodings to use.
Sig
python/qemu/console_socket.py: avoid encoding to/from string
We can work directly in bytes instead of translating back and forth to string, which removes the question of which encodings to use.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Message-id: 20201006235817.3280413-17-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
show more ...
|
e35c1382 | 06-Oct-2020 |
John Snow <jsnow@redhat.com> |
python/qemu/console_socket.py: Add type hint annotations
Finish the typing of console_socket.py with annotations and no code changes.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Kevin
python/qemu/console_socket.py: Add type hint annotations
Finish the typing of console_socket.py with annotations and no code changes.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Message-id: 20201006235817.3280413-16-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
show more ...
|
714ac05a | 06-Oct-2020 |
John Snow <jsnow@redhat.com> |
python/qemu/console_socket.py: Clarify type of drain_thread
Mypy needs just a little help to guess the type here.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.c
python/qemu/console_socket.py: Clarify type of drain_thread
Mypy needs just a little help to guess the type here.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Message-id: 20201006235817.3280413-15-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
show more ...
|
6cf4cce7 | 06-Oct-2020 |
John Snow <jsnow@redhat.com> |
python/qemu/console_socket.py: fix typing of settimeout
The types and names of the parameters must match the socket.socket interface.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Kevin
python/qemu/console_socket.py: fix typing of settimeout
The types and names of the parameters must match the socket.socket interface.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Message-id: 20201006235817.3280413-14-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
show more ...
|
ff3513e6 | 06-Oct-2020 |
John Snow <jsnow@redhat.com> |
python/qemu/console_socket.py: Correct type of recv()
The type and parameter names of recv() should match socket.socket().
OK, easy enough, but in the cases we don't pass straight through to the re
python/qemu/console_socket.py: Correct type of recv()
The type and parameter names of recv() should match socket.socket().
OK, easy enough, but in the cases we don't pass straight through to the real socket implementation, we probably can't accept such flags. OK, for now, assert that we don't receive flags in such cases.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Message-id: 20201006235817.3280413-13-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
show more ...
|