aboutsummaryrefslogtreecommitdiff
path: root/scripts
AgeCommit message (Collapse)AuthorFilesLines
2021-06-25scripts/checkpatch: roll diff tweaking into checkpatch itselfAlex Bennée1-1/+6
Rather than relying on external tweaks lets just do it inside checkpatch's direct commitish handling which is QEMU specific code anyway. Suggested-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Willian Rampazzo <willianr@redhat.com> Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com> Message-Id: <20210623102749.25686-4-alex.bennee@linaro.org>
2021-06-21Merge remote-tracking branch 'remotes/jsnow-gitlab/tags/python-pull-request' ↵Peter Maydell7-1136/+25
into staging Python Pull request Moves QMP-related tools not used for build or automatic testing from scripts/ to python/qemu/qmp/ where they will be protected from bitrot by the check-python-* CI jobs. stub forwarders are left in the old locations for now. # gpg: Signature made Sat 19 Jun 2021 00:02:40 BST # gpg: using RSA key F9B7ABDBBCACDF95BE76CBD07DEF8106AAFC390E # gpg: Good signature from "John Snow (John Huston) <jsnow@redhat.com>" [full] # Primary key fingerprint: FAEB 9711 A12C F475 812F 18F2 88A9 064D 1835 61EB # Subkey fingerprint: F9B7 ABDB BCAC DF95 BE76 CBD0 7DEF 8106 AAFC 390E * remotes/jsnow-gitlab/tags/python-pull-request: (72 commits) scripts/qmp-shell: add redirection shim python: add qmp-shell entry point scripts/qmp-shell: move to python/qemu/qmp/qmp_shell.py scripts/qmp-shell: add docstrings scripts/qmp-shell: make QMPShellError inherit QMPError scripts/qmp-shell: remove double-underscores scripts/qmp-shell: convert usage comment to docstring scripts/qmp-shell: Remove too-broad-exception scripts/qmp-shell: Fix empty-transaction invocation scripts/qmp-shell: remove TODO scripts/qmp-shell: use logging to show warnings scripts/qmp-shell: Use context manager instead of atexit python/qmp: return generic type from context manager scripts/qmp-shell: unprivatize 'pretty' property scripts/qmp-shell: Accept SocketAddrT instead of string scripts/qmp-shell: add mypy types python/qmp: add QMPObject type alias scripts/qmp-shell: initialize completer early scripts/qmp-shell: refactor QMPCompleter scripts/qmp-shell: Fix "FuzzyJSON" parser ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2021-06-21Merge remote-tracking branch ↵Peter Maydell1-0/+194
'remotes/ehabkost-gl/tags/x86-next-pull-request' into staging x86 queue, 2021-06-18 Features: * Add ratelimit for bus locks acquired in guest (Chenyi Qiang) Documentation: * SEV documentation updates (Tom Lendacky) * Add a table showing x86-64 ABI compatibility levels (Daniel P. Berrangé) Automated changes: * Update Linux headers to 5.13-rc4 (Eduardo Habkost) # gpg: Signature made Fri 18 Jun 2021 20:51:26 BST # gpg: using RSA key 5A322FD5ABC4D3DBACCFD1AA2807936F984DC5A6 # gpg: issuer "ehabkost@redhat.com" # gpg: Good signature from "Eduardo Habkost <ehabkost@redhat.com>" [full] # Primary key fingerprint: 5A32 2FD5 ABC4 D3DB ACCF D1AA 2807 936F 984D C5A6 * remotes/ehabkost-gl/tags/x86-next-pull-request: scripts: helper to generate x86_64 CPU ABI compat info docs: add a table showing x86-64 ABI compatibility levels docs/interop/firmware.json: Add SEV-ES support docs: Add SEV-ES documentation to amd-memory-encryption.txt doc: Fix some mistakes in the SEV documentation i386: Add ratelimit for bus locks acquired in guest Update Linux headers to 5.13-rc4 Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2021-06-18scripts/qmp-shell: add redirection shimJohn Snow1-0/+11
qmp-shell has a new home, add a redirect for a little while as the dust settles. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-43-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qmp-shell: move to python/qemu/qmp/qmp_shell.pyJohn Snow1-538/+0
The script will be unavailable for a commit or two, which will help preserve development history attached to the new file. A forwarder will be added shortly afterwards. With qmp_shell in the python qemu.qmp package, now it is fully type checked, linted, etc. via the Python CI. It will be quite a bit harder to accidentally break it again in the future. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-41-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qmp-shell: add docstringsJohn Snow1-1/+38
Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-40-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qmp-shell: make QMPShellError inherit QMPErrorJohn Snow1-1/+1
In preparation for moving qmp-shell into the qemu.qmp package, make QMPShellError inherit from QMPError so that all custom errors in this package all derive from QMPError. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-39-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qmp-shell: remove double-underscoresJohn Snow1-26/+26
They're not needed; single underscore is enough to express intent that these methods are "internal". double underscore is used as a weak name mangling, but that isn't beneficial for us here. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-38-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
2021-06-18scripts/qmp-shell: convert usage comment to docstringJohn Snow1-56/+72
The nice usage comment should be a docstring instead of a comment, so that it's visible from other python tooling. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20210607200649.1840382-37-jsnow@redhat.com Signed-off-by: John Snow <jsnow@redhat.com>
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-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-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-18scripts/qemu-ga-client: move to python/qemu/qmp/qemu_ga_client.pyJohn Snow1-327/+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-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>