405 Commits

Author SHA1 Message Date
Peter Maydell
1a8f18541e Merge tag 'python-pull-request' of https://gitlab.com/jsnow/qemu into staging
python

upgrade to py312

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEE+ber27ys35W+dsvQfe+BBqr8OQ4FAmqYepEACgkQfe+BBqr8
# OQ6Nyg//SFe2COs76DIzWWTN21N/wo4pHAf6Q0nGGj2NKiPozN0aIAcKA9mw8ZXo
# 6HQTjMJKOq4jnL9pYLNS2MzrhiJrvrR0gBymi0aD93EOAMtqXcLxgaCnpI4wFu8v
# wosIehLduYMytrb80aY8oCbUOl+uTPOYHuDtUc7msBV5iqhFg56emjvOh7B+5SuE
# iKc6ivljUVxoVat3pzKSZsxbVd+iYz3UI8cBPa8ISNkfxgCjUw/+t6cm3fBj+v8u
# q0U2qVBfvMH6wPQ7qA+VZvwnf7UgTymbprGko17EkPZwgtKzM+k2Lr75GjfwLHx5
# i7sjKu7doWfRa7/+bNyYj+lZtCAcGJGZu6yuIE6vBj6eBB8LxGbw/zLU+p5Q+QJe
# +np4dFLkK2rlBRNrg4o/66rCWO/b97F6GBtVOoNx44fWmXZfuKJxh0F6FCpvPvlf
# fiAEHiSNmfmUXIeFGgq3OcP4ZB6BIGlHWA+F4U7gn1ZxGrtvZDImRdy0Qj2IjsL0
# lwBXSdS9FgX/lOe2oOGScZIepJsVhMVZ7y+u4g+//GLjLPO2JGLh3oZZdDXa6af8
# N//steftVLII0JWTB5z+6Hv3A5ek9AxiVSPPYLpTGcvp1Cgni+5BdiGqPs5554qC
# Yh5/F0aafIJsMDSs9sO6U4X46DYp8/DSfJwr3Vn+Y9SSVgdSGlU=
# =QZ+f
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed Sep  2 20:35:45 2026 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

* tag 'python-pull-request' of https://gitlab.com/jsnow/qemu:
  sphinx: drop qapidoc back-compat overboiled spaghetti dinner
  sphinx: drop fakedbusdoc
  sphinx: require sphinx 7.2.6
  python: remove stale setup.cfg options
  python: remove distutils workarounds
  python: allow mypy to run as the current python version
  python: fix license configuration
  python: upgrade to Python3.12+
  qapi: update type hint for objects_seen
  tests: update emsdk-wasm64-cross
  tests: add Python3.12 to centos9.docker
  tests: re-add opencv2 and numpy dependencies
  tests: drop python3-devel mapping
  tests: update netbsd dependencies
  tests: update libvirt-ci, lcitool
  tests: update vm tests to prefer locally-built QEMU

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2026-09-03 09:42:53 +01:00
John Snow
f6ebad194c sphinx: require sphinx 7.2.6
Make the extraordinary leap from Sphinx 3.4.3 to Sphinx
7.2.6. Simplifications and cleanup will follow in subsequent patches.

Note that CentOS Stream 9 only ships a version of Sphinx that runs on
Python 3.9, so regardless of the version of Sphinx we require, if we
require Python 3.10+, CentOS Stream 9 will be unable to build QEMU
documentation in an isolated offline build environment.

CentOS Stream 9 continues to be able to build documentation so long as
PyPI access is permitted during configure, or if the requisite PyPI
packages are installed prior to configure time.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20260825215851.1780608-15-jsnow@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
2026-09-02 15:02:58 -04:00
John Snow
4a7132fa17 python: remove stale setup.cfg options
With the recent version bumps, we no longer need these directives.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20260825215851.1780608-14-jsnow@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
2026-09-02 15:02:58 -04:00
John Snow
37826ad1db python: remove distutils workarounds
These are no longer necessary now that we are using Python3.12+.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20260825215851.1780608-13-jsnow@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
2026-09-02 15:02:58 -04:00
John Snow
151a86b2a6 python: allow mypy to run as the current python version
Currently, we instruct mypy to run assuming a specific version of
python. Lift this restriction so that under tox tests, it will always
run assuming the current running version.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Message-ID: <20260825215851.1780608-12-jsnow@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
2026-09-02 15:02:58 -04:00
John Snow
1e5e440e96 python: fix license configuration
License trove identifiers were deprecated in favor of SPDX
identifiers, correct this to stop some whining from various python
tooling.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20260825215851.1780608-11-jsnow@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
2026-09-02 15:02:58 -04:00
John Snow
bc5d8b4bc0 python: upgrade to Python3.12+
With Python3.9 EOL and Python3.10 soon to be EOL (October 2026), and
with ... no other supported build platform actually using Python 3.11,
require the use of Python3.12 or later.

Additionally, as part of this upgrade, remove the use of tomllib from
mkvenv as it is now standard in the Python stdlib: leaving this
transitional code in causes a regression with mypy which becomes
confused about the overloaded use of 'tomllib'.

Our current minimum requirements as determined by standard repository
packages on supported distributions is as follows:

distro            EOS         python3  pip     setuptools  sphinx  wheel
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
-------------------------------------------------------------------------
centos_stream_9   2026-12-12  3.9.25   21.3.1  53.0.0      3.4.3   0.36.2
centos_stream_9+  2026-12-12  3.12.13  23.2.1  68.2.2      ---     0.41.2
freebsd           --          3.12.14  23.3.2  63.1.0      9.0.4   0.48.0
ubuntu_24_04      2028-04-23  3.12.3   24.0    68.1.2      7.2.6   0.42.0
centos_stream_10  2030-01-01  3.12.13  23.3.2  69.0.3      7.2.6   0.41.2
alpine_3_21       2026-11-01  3.12.14  24.3.1  70.3.0      8.1.3   0.43.0
debian_13         2028-08-09  3.13.5   25.1.1  78.1.1      8.1.3   0.46.1
fedora_43         2026-12-09  3.14.7   25.1.1  78.1.1      8.2.3   0.45.1
ubuntu_26_04      2031-05-29  3.14.4   25.1.1  78.1.1      8.2.3   0.46.3
fedora_44         2027-06-02  3.14.7   26.0.1  80.10.2     8.2.3   0.45.1
macports          --          3.14.7   26.0.1  80.10.2     9.1.0   0.48.0
alpine_3_22       2027-05-01  3.12.14  25.1.1  80.9.0      8.2.3   0.46.3
alpine_3_23       2027-11-01  3.12.14  25.1.1  80.9.0      8.2.3   0.46.3
openbsd           --          3.14.6   26.2.1  80.9.0      9.1.0   0.48.0
alpine_3_24       2028-06-01  3.14.7   26.1.2  82.0.1      9.1.0   0.47.0
pkgsrc_current    --          3.13.15  26.2.1  84.0.0      9.1.0   0.48.0

CentOS stream 9 note: python3.12, python3.12-pip,
python3.12-setuptools and python3.12-wheel are available as optional
packages in the standard repository. Sphinx is not available, but can
be side-loaded from PyPI using pip3.12.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20260825215851.1780608-10-jsnow@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
2026-09-02 15:02:58 -04:00
Peter Maydell
c513597761 Merge tag 'pull-hex-20260901' of https://github.com/qualcomm/qemu into staging
semihosting, fix exc/int, icinva, TLB, htid

# -----BEGIN PGP SIGNATURE-----
#
# iQIzBAABCgAdFiEEPWaq5HRZSCTIjOD4GlSvuOVkbDIFAmqXqBoACgkQGlSvuOVk
# bDL0Tw/9EL4g0nvPQKWbFAbs29GId6RVVS3fNRiHPFgSJSULqYDEkvbTip44gsJ5
# Km4rwJy7nRI6d0tdVZYATLGcP/d+OTWxHxQM4/D7WemK3QEYfSMLLnX0d2aGhuH/
# Okncy0j7b5ogUi+ALbCf5MPeUzrK8x7YFqw7utzeE9QYkyeSorhcpLfLSiHm4ECy
# PoWH2kkFZwrEWdXfTTdHeRLIE1FXVGLL0SYh3vatE5kvh9kBnuyKpHR7Cq7zT+A9
# Fh84i9U7afDsRKrpvPArICqvcybdYFw+wBFgIMMea5jkx1+aHTwJ7NdvIZzjTDx+
# RjVdcm3DlucW+y7qEM+d3kGbLcBSG0Q+yJ02LYqLIp9nBELP4rdKVRC0csegZM03
# zj8EFH4QilrVLSsq4KqhLIBiOMqlz6THWVDxEq8xGCvb9vpAUP5c70BsCY5IF9TZ
# XL2ZhgQ+gkQJ4aPV+XOlkC8hn4dbovNu/0cME76v8MNX1iwQrMwC4GJ/N1qfC4jY
# 3EEkmaW3HGXvFvlAFO5T9eLfXUGmVK+tNLc8pZLV/rDLWiQjs6HYD8XZeq9Goo8N
# gIoa//9ZhgjXKNF+e06BCcqvfaaXXLkaX7n5a5NXQVvebB4FsF53myM3mTwGVmgx
# N5I32V15sAJGMgd0/rrgwKhWoDZcOLZGVLCtqI7i2vT178e+pqA=
# =zqar
# -----END PGP SIGNATURE-----
# gpg: Signature made Wed Sep  2 05:37:46 2026 BST
# gpg:                using RSA key 3D66AAE474594824C88CE0F81A54AFB8E5646C32
# gpg: Good signature from "Brian Cain (OSS Qualcomm) <brian.cain@oss.qualcomm.com>" [unknown]
# gpg:                 aka "Brian Cain <bcain@kernel.org>" [full]
# gpg:                 aka "Brian Cain (QuIC) <bcain@quicinc.com>" [full]
# gpg:                 aka "Brian Cain (CAF) <bcain@codeaurora.org>" [full]
# gpg:                 aka "bcain" [full]
# gpg:                 aka "Brian Cain (QUIC) <quic_bcain@quicinc.com>" [unknown]
# Primary key fingerprint: 6350 20F9 67A7 7164 79EF  49E0 175C 464E 541B 6D47
#      Subkey fingerprint: 3D66 AAE4 7459 4824 C88C  E0F8 1A54 AFB8 E564 6C32

* tag 'pull-hex-20260901' of https://github.com/qualcomm/qemu: (28 commits)
  hw/hexagon: decode an empty TLB size field as 4KB
  hw/hexagon: assign a distinct htid to each DSP machine CPU
  tests/tcg/hexagon: add icinva test
  target/hexagon: invalidate translated code for user icinva
  tests/functional/hexagon: update to v0.2.12, +test_{interrupts, sys_regs}
  target/hexagon: fix iassign{r, w} to cover all threads
  target/hexagon: implement direct-to-guest interrupt delivery
  target/hexagon: raise imprecise exception on multi-TLB match
  target/hexagon: read UTIMERLO/UTIMERHI from the global timer
  target/hexagon: gate GPCYCLE guest register reads on SSR:CE
  target/hexagon: take BQL when reading the system pcycle count
  target/hexagon: guard writes to unimplemented guest registers
  hw/intc: clear pending bit on l2vic de-assertion
  tests/tcg/hexagon: check priv instructions raise SIGILL
  target/hexagon: align exceptions for user/sysemu
  tests/functional: Add hexagon semihosting systests
  python/machine: support routing semihosting output to the test console
  target/hexagon: Add an errno mapping
  target/hexagon: add COREDUMP semihosting operation
  target/hexagon: add main arch-specific semihosting operations
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

# Conflicts:
#	hw/hexagon/hexagon_tlb.c
2026-09-02 17:59:30 +01:00
Brian Cain
6c87b8bbaa python/machine: support routing semihosting output to the test console
The hexagon semihosting systests will wait for output on the semihosting
console.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Signed-off-by: Matheus Tavares Bernardino <matheus.bernardino@oss.qualcomm.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Signed-off-by: Brian Cain <brian.cain@oss.qualcomm.com>
2026-09-01 18:20:10 -07:00
Marc-André Lureau
4d37c61590 python, tests: switch usernet queries from HMP to QMP
Replace human-monitor-command "info usernet" calls with the structured
x-query-usernet QMP command in get_usernet_hostfwd_port() and the VM
test runner boot path.

Since x-query-usernet returns a list of UsernetInfo entries, callers
now iterate over the result and extract the port from each entry's
"info" field. Also switch get_info_usernet_hostfwd_port() from
split('\r\n') to splitlines(), since QMP strings use \n rather than
the HMP monitor's \r\n line endings.

Reviewed-by: Thomas Huth <th.huth+qemu@posteo.eu>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Marc-Andre Lureau <marcandre.lureau@redhat.com>
Message-ID: <20260828-qemu-no-hmp-v5-11-9227de146347@redhat.com>
2026-08-29 12:07:43 +04:00
Paolo Bonzini
4c8c132036 python, meson: update meson required for Rust to 1.12.0
Meson 1.11.0 brings support for parsing Cargo.toml inside QEMU's source
tree, and Meson 1.12.0 brings support for cross-compilation of Cargo
subprojects.

Together, these two features allow QEMU to remove hundreds of lines of
manual compilation scripts.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-08-20 09:06:43 +02:00
Daniel P. Berrangé
05e4982dfc tests: switch from -mon to -object monitor-qmp
Use the new preferred low level option for configuring the
QMP service in libqtest and the python Machine class used
by tests. This will avoid triggering deprecation warnings
after the subsequent commit.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Tested-by: Peter Krempa <pkrempa@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20260706135824.2623960-34-berrange@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2026-07-07 11:16:27 +02:00
Alex Bennée
f0e0f43879 python/qemu: dump a developer friendly version of cmdline to logs
Now we have the arguments nicely split up we can make _console_args a
function call and present a slightly different version to the logs to
save developers manually hacking the command line up.

Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20260619155657.944220-4-alex.bennee@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
2026-06-23 10:55:08 +01:00
Alex Bennée
1c09090b48 python/qemu: split console from harness args
Before we mess with the console output lets create a new helper just
for that.

Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20260619155657.944220-3-alex.bennee@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
2026-06-22 13:45:31 +01:00
Alex Bennée
220530755b python/qemu: split arg between base and harness lists
There are argument we add because we want the test harness to control
QEMU and arguments we default for handling the display and machine
type. Split the obvious ones between base_args and a new list called
harness_args.

We will leave the complexity of the serial ports for now.

Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20260619155657.944220-2-alex.bennee@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
2026-06-22 13:43:43 +01:00
John Snow
ad07a976a8 python: temporarily restrict max mypy version
The newest versions of mypy do not support targeting Python 3.9, which
we still support. I want to address that soon, but in the meantime
it's nice if the tests pass.

Signed-off-by: John Snow <jsnow@redhat.com>
Message-ID: <20260611042332.482979-2-jsnow@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
2026-06-15 16:03:07 +02:00
John Snow
400c6b02e8 python: bump qemu.qmp to v0.0.6
This release removes some deprecated warnings for our use of the old
sendmsg API on older python versions.

Acked-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Signed-off-by: John Snow <jsnow@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2026-05-21 12:39:54 +01:00
Paolo Bonzini
7b4680b03f minikconf: add mypy annotations
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-04-30 17:55:03 +02:00
Paolo Bonzini
5decfc6af7 minikconf: run through isort
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-04-30 15:50:18 +02:00
Pierrick Bouvier
2c86fb811d pythondeps: bump to meson 1.11.1
Prior to 1.11.0, build with rust didn't use link_args.
In QEMU case, it means that plugins could not work, since they rely on
link_args to expose symbols from QEMU binary.

https://mesonbuild.com/Release-notes-for-1-11-0.html#change-to-handling-of-linker-arguments-for-rust

With this change, QEMU built with --enable-rust can pass all CI tests,
including tests related to plugins.

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>
[Move from 1.11.0 to 1.11.1. - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-04-30 15:50:18 +02:00
John Snow
191d4ceb40 python: add formal python3.14 support and testing
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20260226213400.1254014-5-jsnow@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
2026-03-09 14:04:25 -04:00
John Snow
d4ae1c7072 python: drop avocado
Avocado-framework is no longer used for anything, so it can be removed.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20260226213400.1254014-4-jsnow@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
2026-03-09 14:04:19 -04:00
John Snow
d5c6eef38e python: replace avocado tests with pytest
Following suit with the rest of this repository, drop avocado and
replace it with the Python standard "pytest" package.

Our ultimate goal is to merge these python tests with the meson test
suite, so the use of 'pytest' here is only a stop-gap solution to get
the GitLab CI 'check-python-tox' passing again following recent Python
packaging ecosystem changes.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20260226213400.1254014-3-jsnow@redhat.com>
[ran black autoformatter. --js]
Signed-off-by: John Snow <jsnow@redhat.com>
2026-03-09 14:04:03 -04:00
John Snow
4c2c89630c python: pin 'wheel' version in minreqs test
With recent python packaging ecosystem updates, the latest 'wheel' is no
longer compatible with older packages - and was somehow still compatible
with our Python 3.9 environment. Pin wheel to an older version (Version
based on Debian 11's available wheel package) to remove warnings during
the minreqs test.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20260226213400.1254014-2-jsnow@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
2026-03-09 14:03:36 -04:00
Marc-André Lureau
f08abbae62 scripts/vendor.py: add pycotap
Related to commit 5ec1eec110 ("python:
Install pycotap in our venv if necessary")

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Link: https://lore.kernel.org/r/20260211-cleanups-v1-3-e63c96572389@redhat.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-02-27 14:48:04 +01:00
Marc-André Lureau
61fb8ca023 python/wheel: remove meson-1.9.0
Leftover from commit 8c04b6a48b.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Link: https://lore.kernel.org/r/20260211-cleanups-v1-2-e63c96572389@redhat.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2026-02-27 14:48:04 +01:00
John Snow
c676f6cd78 python: update README.rst to reflect qemu.qmp's removal
It is no longer simply possible to just use this directory as if it were
an installed package now that it has dependencies, so update the README
to reflect this.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20260218213416.674483-20-jsnow@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
2026-02-24 13:11:29 -05:00
John Snow
e1e49b35b3 python: delete qemu.qmp
Start relying on the external python-qemu-qmp dependency instead, to
prevent desync between the internal and external libraries.

This library is now entirely independent; to contribute changes, see
https://gitlab.com/qemu-project/python-qemu-qmp/

Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20260218213416.674483-19-jsnow@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
2026-02-24 13:11:29 -05:00
John Snow
93bf95964c python: add vendored qemu.qmp package
In anticipation of deleting the python/qemu/qmp source from the tree,
add a vendored version of the qemu.qmp package to ensure that "make
check" can be run in isolated build environments, offline.

Acked-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20260218213416.674483-13-jsnow@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
2026-02-24 13:11:11 -05:00
John Snow
b42ad8ef32 python/mkvenv: add mechanism to install local package(s)
Currently, we "implicitly" install the local 'qemu' python package for
'make check-venv' with some logic inside tests/Makefile.include. I would
like to make this installation explicit in pythondeps.toml instead.

This patch adds a path constraint that can be used in lieu of version
constraints to specify that a package should be installed from the
source tree instead of from PyPI or vendored packages. This is done to
allow us to install the python packages hosted inside of the tree while
also processing dependencies; i.e. so that our "qemu" package can
specify that it needs "qemu.qmp", which soon will not be included in
qemu.git.

This also has the benefit of being able to specify in a declarative
configuration file that our pyvenv environment *will* have our local
python packages installed and available without any PYTHONPATH hacks,
which should simplify iotests, device-crash-test and functional tests
without needing to manage local inclusion paths in environment
variables.

On the downsides, installing packages through mkvenv/ensuregroup means
that there are extra steps we need to take in order to install a local
package *offline*; namely we must disable build isolation (so we have
access to setuptools) and we must also include python3-wheel in QEMU's
build dependencies in order for "make check" to run successfully when in
an offline, isolated environment. These extra dependencies are handled
in a forthcoming commit; for now, nothing is utilizing this new pathway.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20260218213416.674483-6-jsnow@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
2026-02-23 13:24:42 -05:00
John Snow
6aadbb7e54 python/mkvenv: create timestamp file for each group "ensured"
Each group ensured by the mkvenv script will create an empty timestamp
file named {groupname}.group which can be used to conditionally trigger
dependency installation from various scripts and build machinery.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20260218213416.674483-3-jsnow@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
2026-02-23 13:24:42 -05:00
John Snow
e44a26ba94 python: drop uses of pkg_resources
pkg_resources has been fully dropped from modern pip/setuptools
distributions and we should phase out its use. This patch is enough to,
by itself, repair most GitLab CI tests upstream; with the exception of
tox tests which are still making use of avocado - which will be dropped
in a separate series to restore functionality there.

Signed-off-by: John Snow <jsnow@redhat.com>
Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Message-ID: <20260211195804.135144-3-jsnow@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
2026-02-12 12:34:00 +01:00
John Snow
587f4a1805 python: fix msys64 wheel directory specification
In python3.14, fixes were made to the file URI parsing [1] such that
file URIs that used to work but were technically out of spec are now
broken.

As a result, our msys2 GitLab CI tests began failing.

Stop using "file://" URI links in favor of simple paths (Thanks pbo) to
fix parsing errors under Python 3.14 and fix the msys2 GitLab CI tests.

[1] https://docs.python.org/3/whatsnew/3.14.html#urllib

Reported-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Suggested-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Tested-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20260130050518.517688-2-jsnow@redhat.com>
2026-02-02 16:46:40 +10:00
Paolo Bonzini
8c04b6a48b bump meson wheel to 1.10.0
This version includes several improvements and bugfixes for Rust.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-12-27 10:11:11 +01:00
John Snow
9ccd0c8a88 python/mkvenv: ensure HAVE_LIB variables are actually constants
Pylint 4.x has refined checking for variable names that behave as
constants vs ones that do not; unfortunately our tricky import machinery
is perceived as these variables being re-assigned.

Add a temporary variable with an underscore and assign to the global
constants precisely once to alleviate this new nag message. Add an
ignore for this name for older versions of pylint that developers may
have installed locally.

(In other words: there is no solution that will cater to both pre- and
post- 4.x versions, so we target 4.x here and silence older versions.)

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20251118200657.1043688-2-jsnow@redhat.com>
2025-11-19 10:45:44 +01:00
Thomas Huth
9b03e9cf06 python/qemu: Replace some remaining "avocados" with "functional tests"
The avocado tests have been replaced by the new functional tests,
so also update this in the README.rst files in the python directory
accordingly.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20251008131936.71160-1-thuth@redhat.com>
2025-10-16 17:44:31 +02:00
Paolo Bonzini
091f115ea5 configure: bump Meson to 1.9.0 for use with Rust
Meson 1.9.0 provides mixed linking of Rust and C objects.  As a side effect,
this also allows adding dependencies with "sources: ..." files to Rust crates
that use structured_sources().

It can also clean up up the meson.build files for Rust noticeably, but due
to an issue with doctests (see https://github.com/mesonbuild/meson/pull/14973)
that will have to wait for 1.9.1.

Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Link: https://lore.kernel.org/r/20250908105005.2119297-3-pbonzini@redhat.com
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2025-09-17 19:00:56 +02:00
Daniel P. Berrangé
6ccb48ffc1 python: ensure QEMUQtestProtocol closes its socket
While QEMUQtestMachine closes the socket that was passed to
QEMUQtestProtocol, the python resource leak manager still
believes that the copy QEMUQtestProtocol holds is open. We
must explicitly call close to avoid this leak warnnig.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2025-09-15 14:36:01 -04:00
John Snow
f414048e32 python: synchronize qemu.qmp documentation
This patch collects comments and documentation changes from many commits
in the python-qemu-qmp repository; bringing the qemu.git copy in
bit-identical alignment with the standalone library *except* for several
copyright messages that reference the "LICENSE" file which is, for QEMU,
named "COPYING" instead and are therefore left unchanged.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2025-09-15 14:36:01 -04:00
John Snow
85f223e5b0 python: backport 'avoid creating additional event loops per thread'
This commit is two backports squashed into one to avoid regressions.

python: *really* remove get_event_loop

A prior commit, aa1ff990, switched away from using get_event_loop *by
default*, but this is not good enough to avoid deprecation warnings as
`asyncio.get_event_loop_policy().get_event_loop()` is *also*
deprecated. Replace this mechanism with explicit calls to
asyncio.get_new_loop() and revise the cleanup mechanisms in __del__ to
match.

python: avoid creating additional event loops per thread

"Too hasty by far!", commit 21ce2ee4 attempted to avoid deprecated
behavior altogether by calling new_event_loop() directly if there was no
loop currently running, but this has the unfortunate side effect of
potentially creating multiple event loops per thread if tests
instantiate multiple QMP connections in a single thread. This behavior
is apparently not well-defined and causes problems in some, but not all,
combinations of Python interpreter version and platform environment.

Partially revert to Daniel Berrange's original patch, which calls
get_event_loop and simply suppresses the deprecation warning in
Python<=3.13. This time, however, additionally register new loops
created with new_event_loop() so that future calls to get_event_loop()
will return the loop already created.

Reported-by: Richard W.M. Jones <rjones@redhat.com>
Reported-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: John Snow <jsnow@redhat.com>
cherry picked from commit python-qemu-qmp@21ce2ee4f2df87efe84a27b9c5112487f4670622
cherry picked from commit python-qemu-qmp@c08fb82b38212956ccffc03fc6d015c3979f42fe
Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2025-09-15 14:36:01 -04:00
John Snow
5d99044d09 python: backport 'Remove deprecated get_event_loop calls'
This method was deprecated in 3.12 because it ordinarily should not be
used from coroutines; if there is not a currently running event loop,
this automatically creates a new event loop - which is usually not what
you want from code that would ever run in the bottom half.

In our case, we do want this behavior in two places:

(1) The synchronous shim, for convenience: this allows fully sync
programs to use QEMUMonitorProtocol() without needing to set up an event
loop beforehand. This is intentional to fully box in the async
complexities into the legacy sync shim.

(2) The qmp_tui shell; instead of relying on asyncio.run to create and
run an asyncio program, we need to be able to pass the current asyncio
loop to urwid setup functions. For convenience, again, we create one if
one is not present to simplify the creation of the TUI appliance.

The remaining user of get_event_loop() was in fact one of the erroneous
users that should not have been using this function: if there's no
running event loop inside of a coroutine, you're in big trouble :)

Signed-off-by: John Snow <jsnow@redhat.com>
cherry picked from commit python-qemu-qmp@aa1ff9907603a3033296027e1bd021133df86ef1
Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2025-09-15 14:36:01 -04:00
John Snow
fd0ed46d4e python: backport 'qmp-tui: Do not crash if optional dependencies are not met'
Based on the discussion at https://github.com/pypa/pip/issues/9726 -
even though the setuptools documentation implies that it is possible to
guard script execution with optional dependency groups, this is not true
in practice with the scripts generated by pip.

Just do the simple thing and guard the import statements.

Signed-off-by: John Snow <jsnow@redhat.com>
cherry picked from commit python-qemu-qmp@df520dcacf9a75dd4c82ab1129768de4128b554c
Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2025-09-15 14:36:01 -04:00
John Snow
fcaeeb7653 python: backport 'qmp-shell-wrap: handle missing binary gracefully'
Signed-off-by: John Snow <jsnow@redhat.com>
cherry picked from commit python-qemu-qmp@9c889dcbd58817b0c917a9d2dd16161f48ac8203
Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2025-09-15 14:36:01 -04:00
John Snow
a50b8572f0 python: backport 'make require() preserve async-ness'
This is not strictly needed functionality-wise, but doing this allows
sphinx to see which decorated methods are async. Without this, sphinx
misses the "async" classifier on generated docs, which ... for an async
library, isn't great.

It does make an already gnarly function even gnarlier, though.

So, what's going on here?

A synchronous function (like require() before this patch) can return a
coroutine that can be awaited on, for example:

  def some_func():
      return asyncio.task(asyncio.sleep(5))

  async def some_async_func():
      await some_func()

However, this function is not considered to be an "async" function in
the eyes of the abstract syntax tree. Specifically,
some_func.__code__.co_flags will not be set with CO_COROUTINE.

The interpreter uses this flag to know if it's legal to use "await" from
within the body of the function. Since this function is just wrapping
another function, it doesn't matter much for the decorator, but sphinx
uses the stdlib inspect.iscoroutinefunction() to determine when to add
the "async" prefix in generated output. This function uses the presence
of CO_COROUTINE.

So, in order to preserve the "async" flag for docs, the require()
decorator needs to differentiate based on whether it is decorating a
sync or async function and use a different wrapping mechanism
accordingly.

Phew.

Signed-off-by: John Snow <jsnow@redhat.com>
cherry picked from commit python-qemu-qmp@40aa9699d619849f528032aa456dd061a4afa957
Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2025-09-15 14:36:01 -04:00
Adam Dorsey
653f501434 python: backport 'feat: allow setting read buffer limit'
Expose the limit parameter of the underlying StreamReader and StreamWriter
instances.

This is helpful for the use case of transferring files in and out of a VM
via the QEMU guest agent's guest-file-open, guest-file-read, guest-file-write,
and guest-file-close methods, as it allows pushing the buffer size up to the
guest agent's limit of 48MB per transfer.

Signed-off-by: Adam Dorsey <adam@dorseys.email>
cherry picked from commit python-qemu-qmp@9ba6a698344eb3b570fa4864e906c54042824cd6
cherry picked from commit python-qemu-qmp@e4d0d3f835d82283ee0e48438d1b154e18303491
[Squashed in linter fixups. --js]
Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2025-09-15 14:36:01 -04:00
John Snow
8fd9ccebd9 python: backport 'qmp-shell: add common_parser()'
Signed-off-by: John Snow <jsnow@redhat.com>
cherry picked from commit python-qemu-qmp@20a88c2471f37d10520b2409046d59e1d0f1e905
Signed-off-by: John Snow <jsnow@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2025-09-15 14:36:01 -04:00
John Snow
0408b8d7a0 python: backport 'Use @asynciocontextmanager'
This removes a non-idiomatic use of a "coroutine callback" in favor of
something a bit more standardized.

Signed-off-by: John Snow <jsnow@redhat.com>
cherry picked from commit python-qemu-qmp@commit 97f7ffa3be17a50544b52767d14b6fd478c07b9e
Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2025-09-15 14:36:01 -04:00
John Snow
f9d2e0a3bd python: backport 'drop Python3.6 workarounds'
Now that the minimum version is 3.7, drop some of the 3.6-specific hacks
we've been carrying. A single remaining compatibility hack concerning
3.6's lack of @asynccontextmanager is addressed in the following commit.

Signed-off-by: John Snow <jsnow@redhat.com>
cherry picked from commit python-qemu-qmp@3e8e34e594cfc6b707e6f67959166acde4b421b8
Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2025-09-15 14:36:01 -04:00
John Snow
094ded5227 python: backport 'protocol: adjust logging name when changing client name'
The client name is mutable, so the logging name should also change to
reflect it when it changes.

Signed-off-by: John Snow <jsnow@redhat.com>
cherry picked from commit python-qemu-qmp@e10b73c633ce138ba30bc8beccd2ab31989eaf3d
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2025-09-15 14:36:01 -04:00
John Snow
1e343714bf python: backport 'kick event queue on legacy event_pull()'
This corrects an oversight in qmp-shell operation where new events will
not accumulate in the event queue when pressing "enter" with an empty
command buffer, so no new events show up.

Reported-by: Jag Raman <jag.raman@oracle.com>
Signed-off-by: John Snow <jsnow@redhat.com>
cherry picked from commit python-qemu-qmp@0443582d16cf9efd52b2c41a7b5be7af42c856cd
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
2025-09-15 14:36:01 -04:00