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 ...
|
f12a282f | 06-Oct-2020 |
John Snow <jsnow@redhat.com> |
python/qemu: Add mypy type annotations
These should all be purely annotations with no changes in behavior at all. You need to be in the python folder, but you should be able to confirm that these an
python/qemu: Add mypy type annotations
These should all be purely annotations with no changes in behavior at all. You need to be in the python folder, but you should be able to confirm that these annotations are correct (or at least self-consistent) by running `mypy --strict qemu`.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Message-id: 20201006235817.3280413-12-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
show more ...
|
aad3f3bb | 06-Oct-2020 |
John Snow <jsnow@redhat.com> |
python/qemu: make 'args' style arguments immutable
These arguments don't need to be mutable and aren't really used as such. Clarify their types as immutable and adjust code to match where necessary.
python/qemu: make 'args' style arguments immutable
These arguments don't need to be mutable and aren't really used as such. Clarify their types as immutable and adjust code to match where necessary.
In general, It's probably best not to accept a user-defined mutable object and store it as internal object state unless there's a strong justification for doing so. Instead, try to use generic types as input with empty tuples as the default, and coerce to list where necessary.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-id: 20201006235817.3280413-10-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
show more ...
|
9223fda4 | 06-Oct-2020 |
John Snow <jsnow@redhat.com> |
python/machine.py: fix _popen access
As always, Optional[T] causes problems with unchecked access. Add a helper that asserts the pipe is present before we attempt to talk with it.
Signed-off-by: Jo
python/machine.py: fix _popen access
As always, Optional[T] causes problems with unchecked access. Add a helper that asserts the pipe is present before we attempt to talk with it.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Message-id: 20201006235817.3280413-9-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
show more ...
|
be1183e5 | 06-Oct-2020 |
John Snow <jsnow@redhat.com> |
python/machine.py: Add _qmp access shim
Like many other Optional[] types, it's not always a given that this object will be set. Wrap it in a type-shim that raises a meaningful error and will always
python/machine.py: Add _qmp access shim
Like many other Optional[] types, it's not always a given that this object will be set. Wrap it in a type-shim that raises a meaningful error and will always return a concrete type.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Message-id: 20201006235817.3280413-8-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
show more ...
|
aaa81ec6 | 06-Oct-2020 |
John Snow <jsnow@redhat.com> |
python/machine.py: use qmp.command
machine.py and qmp.py both do the same thing here; refactor machine.py to use qmp.py's functionality more directly.
Signed-off-by: John Snow <jsnow@redhat.com> Re
python/machine.py: use qmp.command
machine.py and qmp.py both do the same thing here; refactor machine.py to use qmp.py's functionality more directly.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-id: 20201006235817.3280413-7-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
show more ...
|
1847a4a8 | 06-Oct-2020 |
John Snow <jsnow@redhat.com> |
python/machine.py: Handle None events in events_wait
If the timeout is 0, we can get None back. Handle this explicitly.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Kevin Wolf <kwolf@re
python/machine.py: Handle None events in events_wait
If the timeout is 0, we can get None back. Handle this explicitly.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Message-id: 20201006235817.3280413-6-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
show more ...
|