aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2021-06-18scripts/qmp-shell: Remove too-broad-exceptionJohn Snow1-4/+7
We are only anticipating QMPShellErrors here, for syntax we weren't able to understand. Other errors, if any, should be allowed to percolate upwards. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-36-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qmp-shell: Fix empty-transaction invocationJohn Snow1-6/+8
calling "transaction( )" is pointless, but valid. Rework the parser to allow this kind of invocation. This helps clean up exception handling later by removing accidental breakages of the parser that aren't explicitly forbidden. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-35-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qmp-shell: remove TODOJohn Snow1-2/+0
We still want to revamp qmp-shell again, but there's much more to the idea than the comment now intuits. Remove it. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-34-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qmp-shell: use logging to show warningsJohn Snow1-2/+8
A perfect candidate is non-fatal shell history messages. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-33-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qmp-shell: Use context manager instead of atexitJohn Snow1-16/+19
We can invoke the shell history writing when we leave the QMPShell scope instead of relying on atexit. Doing so may be preferable to avoid global state being registered from within a class instead of from the application logic directly. Use QMP's context manager to hook this history saving at close time, which gets invoked when we leave the context block. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-32-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18python/qmp: return generic type from context managerJohn Snow1-1/+4
__enter__ can be invoked from a subclass, so it needs a more flexible type. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-31-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qmp-shell: unprivatize 'pretty' propertyJohn Snow1-5/+4
Similar to verbose, there's no reason this needs to be hidden. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-30-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qmp-shell: Accept SocketAddrT instead of stringJohn Snow1-5/+7
Don't "extend" QEMUMonitorProtocol by changing the argument types. Move the string parsing just outside of the class instead. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-29-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qmp-shell: add mypy typesJohn Snow1-26/+41
As per my usual, this patch is annotations only. Any changes with side effects are done elsewhere. Note: pylint does not understand the subscripts for Collection in Python 3.6, so use the stronger Sequence type as a workaround. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-28-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18python/qmp: add QMPObject type aliasJohn Snow1-0/+3
This is meant to represent any generic object seen in a QMPMessage, not just the root object itself. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-27-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qmp-shell: initialize completer earlyJohn Snow1-1/+1
Add an empty completer as a more type-safe placeholder instead of 'None'. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-26-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qmp-shell: refactor QMPCompleterJohn Snow1-3/+11
list is a generic type, but we expect to use strings directly. We could subclass list[str], but pylint does not presently understand that invocation. Change this class to envelop a list instead of *being* a list, for simpler mypy typing. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-25-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qmp-shell: Fix "FuzzyJSON" parserJohn Snow1-10/+10
I'm not sure when this regressed (Or maybe if it was ever working right to begin with?), but the Python AST requires you to change "Names" to "Constants" in order to truly convert `false` to `False`. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-24-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qmp-shell: move the REPL functionality into QMPShellJohn Snow1-3/+7
Instead of doing this in main, move it into the class itself. (This makes it easier to put into the qemu.qmp package later by removing as much as we can from the main() function.) Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-23-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qmp-shell: remove prompt argument from read_exec_commandJohn Snow1-3/+3
It's only ever used by one caller, we can just absorb that logic. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-22-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qmp-shell: move get_prompt() to prompt propertyJohn Snow1-4/+5
Small tidying; treat "prompt" like an immutable property instead of function/method/routine. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-21-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qmp-shell: Make verbose a public attributeJohn Snow1-10/+6
No real reason to hide this behind an underscore; make it part of the initializer and make it a regular RW attribute. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-20-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qmp-shell: Add pretty attribute to HMP shellJohn Snow1-7/+4
It's less useful, but it makes the initialization methods LSP consistent, which quiets a mypy complaint. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-19-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qmp-shell: use argparseJohn Snow1-51/+33
Use argparse instead of an open-coded CLI parser, for consistency with everything else. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-18-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qmp-shell: use isinstance() instead of type()John Snow1-2/+2
A bit more idiomatic, and quiets some linter warnings. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-17-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qmp-shell: remove if-raise-else patternsJohn Snow1-4/+4
Shushes pylint. I don't always mind these patterns personally, but I'm not as sure that I want to remove the warning from pylint's repertoire entirely. Oh well. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-16-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qmp-shell: fix shell history exception handlingJohn Snow1-9/+6
We want to remove exceptions that are too broad here; we only want to catch IOErrors that get raised as a direct result of the open call. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-15-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qmp-shell: rename one and two-letter variablesJohn Snow1-12/+12
A bit of churn and housekeeping for pylint, flake8 et al. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-14-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qmp-shell: make QMPCompleter returns explicitJohn Snow1-3/+3
This function returns None when it doesn't find a match; do that explicitly. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-13-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qmp-shell: ignore visit_Name nameJohn Snow1-1/+1
Not something I control, sorry, pylint. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-12-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qmp-shell: use triple-double-quote docstring styleJohn Snow1-2/+5
(2014 me had never written python before.) Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-11-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qmp-shell: declare verbose in __init__John Snow1-0/+1
Linters get angry when we don't define state at init time. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-10-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qmp-shell: Use python3-style super()John Snow1-3/+3
Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-9-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qmp-shell: use @classmethod where appropriateJohn Snow1-2/+4
Methods with no self-use should belong to the class. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-8-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qmp-shell: remove shadowed variable from _print()John Snow1-2/+2
Don't use 'qmp' here, which shadows the qmp module. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-7-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qmp-shell: fix connect method signatureJohn Snow1-1/+1
It needs to match the parent's signature -- the negotiate parameter must be optional. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-6-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qmp-shell: fix exception handlingJohn Snow1-1/+1
Fixes: 50d189c Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-5-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qmp-shell: fix show_banner signatureJohn Snow1-2/+2
The signatures need to match. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-4-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qmp-shell: Apply flake8 rulesJohn Snow1-21/+43
A lot of fiddling around to get us below 80 columns. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-3-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qmp-shell: apply isort rulesJohn Snow1-5/+7
Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-2-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qemu-ga-client: Add forwarder shimJohn Snow1-0/+11
Add a little forwarder shim until we are sure that everyone is comfortable with how to use the tools in their new packaged location. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210604155532.1499282-12-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18python/qemu-ga-client: add entry pointJohn Snow2-2/+1
Remove the shebang, and add a package-defined entry point instead. Now, it can be accessed using 'qemu-ga-client' from the command line after installing the package. The next commit adds a forwarder shim that allows the running of this script without needing to install the package again. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210604155532.1499282-11-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qemu-ga-client: move to python/qemu/qmp/qemu_ga_client.pyJohn Snow1-2/+0
The script itself will be unavailable for a few commits before being restored, with no way to run it right after this commit. This helps move git history into the new file. To prevent linter regressions, though, we do need to immediately touch up the filename to remove dashes (to make the module importable), and remove the executable bit. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210604155532.1499282-10-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qemu-ga-client: add mypy type hintsJohn Snow1-40/+49
This script is in slightly rough shape, but it still works. A lot of care went into its initial development. In good faith, I'm updating it to the latest Python coding standards. If there is in interest in this script, though, I'll be asking for a contributor to take care of it further. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210604155532.1499282-9-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18python/qmp: Correct type of QMPReturnValueJohn Snow1-9/+14
It's only a Dict[str, Any] most of the time. It's not actually guaranteed to be anything in particular. Fix this type to be more accurate to the reality we live in. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210604155532.1499282-8-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qemu-ga-client: apply (most) pylint rulesJohn Snow1-3/+15
I'm only doing a very quick best-effort to preserve this script, to help keep it from breaking further. I think there are pending ideas swirling on the right way to implement better SDKs and better clients, and this script might be a handy reference for those discussions. It presents some interesting design problems, like static type safety when using a dynamic RPC mechanism. I believe it's worth preserving the effort and care that went into making this script by updating it to work with our current infrastructure. However, I am disabling the requirement for docstrings in this file. If you would like to help improve this script, please add docstrings alongside any refactors or rejuvenations you might apply at that time. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210604155532.1499282-7-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qemu-ga-client: add module docstringJohn Snow1-32/+33
Turn that nice usage comment into a docstring. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210604155532.1499282-6-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qemu-ga-client: replace deprecated optparse with argparseJohn Snow1-18/+16
optparse isn't supported anymore, it's from the python2 days. Replace it with the mostly similar argparse. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210604155532.1499282-5-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qemu-ga-client: Fix exception handlingJohn Snow1-6/+4
Fixes: 50d189c These error classes aren't available anymore. Fix the bitrot. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210604155532.1499282-4-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qemu-ga-client: apply (most) flake8 rulesJohn Snow1-12/+16
- Line length should be < 80 - You shouldn't perform unscoped imports except at the top of the module Notably, the sys.path hack creates problems with the import rule. This will be fixed later. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210604155532.1499282-3-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qemu-ga-client: apply isort rulesJohn Snow1-4/+5
Hint: > ln -s scripts/qmp/qemu-ga-client python/qemu/qmp/qemu_ga_client.py > cd python > isort qemu Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210604155532.1499282-2-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18python/qmp: add fuse command to 'qom' toolsJohn Snow2-2/+13
The 'fuse' command will be unavailable if 'fusepy' is not installed. It will simply not load and subsequently be unavailable as a subcommand. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-id: 20210603003719.1321369-20-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qom-fuse: add redirection shim to python/qemu/qmp/qom-fuse.pyJohn Snow1-0/+11
By leaving the script absent for a commit, git-blame travels to the new file instead of staying on the shim. Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-id: 20210603003719.1321369-19-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qom-fuse: move to python/qemu/qmp/qom_fuse.pyJohn Snow1-10/+2
Move qom-fuse over to the python package now that it passes the linter. Update the import paradigms so that it continues to pass in the context of the Python package. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210603003719.1321369-18-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18python: add optional FUSE dependenciesJohn Snow2-1/+14
In preparation for moving qom-fuse over to the python package, we need some new dependencies to support it. Add an optional 'fusepy' dependency that users of the package can opt into with e.g. "pip install qemu[fuse]" which installs the requirements necessary to obtain the additional functionality. Add the same fusepy dependency to the 'devel' extras group -- unfortunately I do not see a way for optional groups to imply other optional groups at present, so the dependency is repeated. The development group needs to include the full set of dependencies for the purpose of static analysis of all features offered by this library. Lastly, add the [fuse] extras group to tox's configuration as a workaround so that if a stale tox environment is found when running `make check-tox`, tox will know to rebuild its environments. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210603003719.1321369-17-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>