Skip to contentSkip to conversation

python: drop qemu.qmp from qemu.git tree

PATCH Superseded John Snow 3 participants 28 messages Dec 5, 2025 – Jan 13 Arm/Amlogic Meson SoC support

v3 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

John Snow

author
#0 lore raw

v3 cover python: drop qemu.qmp from qemu.git tree

Hello!

This series drops the in-tree version of our python-qemu-qmp package ("qemu.qmp") in favor of the version hosted on PyPI, whose repository is located at https://gitlab.com/qemu-project/python-qemu-qmp.

GitLab CI: https://gitlab.com/jsnow/qemu/-/pipelines/2197613036
(FreeBSD isn't my fault...!)

The major effects of this patch series are:

1. qemu.qmp will be installed from PyPI or vendored packages instead of being utilized directly from the qemu.git tree.
2. There are no new python dependencies checked or installed during configure. All test dependencies are installed post-hoc on an as-needed basis.
3. "make check-venv" is no longer required to be run manually before any test that is integrated with meson; this includes "make check" and "make check-functional".
4. "make check-venv" no longer installs functional test dependencies: it installs only the core suite of python test dependencies.
5. "make check-venv" is now required as a pre-requisite for running device-crash-test and manually executed iotests.
6. Unfortunately, python3-wheel and python3-setuptools are now required on the host system if tests are to be executed and >= Python 3.13 is used.
7. An awful lot of deleted lines of code, and a lot fewer headaches managing two nearly-identical copies of this source code. O:-)

Patches 1-5 are build system focused; they set up new pythondeps.toml, mkvenv, and meson systems in preparation for relying on an external qemu.qmp library, but does not yet make the switch.

Patches 6-9 are testing and CI focused; they add necessary preparation steps to keep tests running happily once the in-tree qemu.qmp library is removed.

Patches 10-15 are build system focused again; they implement the actual switchover to the external qemu.qmp library.

v3:

- Fixed FreeBSD vm test
- Fixed Cirrus macOS test (Needed setuptools as a dep, "file:///" had one too many forward slashes, which works fine for older pip/setuptools, but was incompatibly fixed recently.)
- Fixed an issue that prevented installing the local python packages in an offline, isolated build environment (need --no-isolated-build and pip environment variable flags)
- Added the python3-wheel and python3-setuptools build dependencies to lcitool, owing to the above issues
- Ensured that the $download flag (for PyPI access) from configure is carried over into pytest/meson.build invocations. This defaults to "enabled", so test dependencies should not have any issue being fetched on most developer workstations and build environments.
- Fixed several bugs in the mkvenv.py local package installation mechanism.
- Flags and workarounds added for installing local packages offline now apply *only* to local package installations, and not "normal" depspecs.
- Reordered patches into more logical "phases" for easier review (I hope...?)

Known issues: "make check-build" still installs all of the test dependencies to the pyvenv. I'm not sure if this is desired or not, but I ran into problems preventing it from doing this without breaking a ton of CI tests. I'll continue to investigate this, but wanted to send this v3 out.

v2:

- move "make check-venv" earlier in GitLab CI/CD pipeline, to avoid re-running configure
- Fix functional tests not using PyPI to fetch pygdbmi package
- Remove pre-requisites which are now merged

--js

John Snow (15):
python/mkvenv: create timestamp file for each group "ensured" python/mkvenv: bump 'qemu.qmp' dependency for testdeps python/mkvenv: add 'checktests' and 'functests' dependency groups python/mkvenv: add mechanism to install local package(s) meson, mkvenv: add checktests and functests custom targets
tests: Use configured python to run GitLab iotests
tests: run "make check-venv" before running iotests
tests: ensure "make check-venv" is run for crash tests tests/lcitool: add python3 wheel and setuptools deps for qemu
python: add vendored qemu.qmp package
meson, mkvenv: make iotests depend on checktests group meson, mkvenv: make functional tests depend on functests group meson, mkvenv: add qemu.git/python/qemu package to pythondeps.toml
tests: replace old "check-venv" target with meson target
python: delete qemu.qmp

 meson.build                                   |    1 +
 .gitlab-ci.d/buildtest.yml                    |   11 +-
 .gitlab-ci.d/cirrus/freebsd-14.vars           |    2 +-
 .gitlab-ci.d/cirrus/macos-14.vars             |    2 +-
 python/qemu/qmp/__init__.py                   |   60 -
 python/qemu/qmp/error.py                      |   53 -
 python/qemu/qmp/events.py                     |  751 -----------
 python/qemu/qmp/legacy.py                     |  339 -----
 python/qemu/qmp/message.py                    |  217 ----
 python/qemu/qmp/models.py                     |  146 ---
 python/qemu/qmp/protocol.py                   | 1101 -----------------
 python/qemu/qmp/py.typed                      |    0
 python/qemu/qmp/qmp_client.py                 |  732 -----------
 python/qemu/qmp/qmp_shell.py                  |  689 -----------
 python/qemu/qmp/qmp_tui.py                    |  665 ----------
 python/qemu/qmp/util.py                       |  150 ---
 python/qemu/utils/qom_fuse.py                 |    1 -
 python/scripts/mkvenv.py                      |   44 +-
 python/scripts/vendor.py                      |    2 +
 python/setup.cfg                              |   31 +-
 python/tests/minreqs.txt                      |    8 +-
 python/tests/protocol.py                      |  596 ---------
 python/wheels/qemu_qmp-0.0.5-py3-none-any.whl |  Bin 0 -> 72263 bytes
 pythondeps.toml                               |   13 +-
 pyvenv/meson.build                            |   40 +
 tests/Makefile.include                        |   25 +-
 tests/docker/dockerfiles/alpine.docker        |    2 +
 tests/docker/dockerfiles/centos9.docker       |    2 +
 tests/functional/meson.build                  |    7 +-
 tests/lcitool/projects/qemu.yml               |    2 +
 tests/qemu-iotests/meson.build                |    2 +-
 tests/vm/generated/freebsd.json               |    2 +
 32 files changed, 126 insertions(+), 5570 deletions(-)
 delete mode 100644 python/qemu/qmp/__init__.py
 delete mode 100644 python/qemu/qmp/error.py
 delete mode 100644 python/qemu/qmp/events.py
 delete mode 100644 python/qemu/qmp/legacy.py
 delete mode 100644 python/qemu/qmp/message.py
 delete mode 100644 python/qemu/qmp/models.py
 delete mode 100644 python/qemu/qmp/protocol.py
 delete mode 100644 python/qemu/qmp/py.typed
 delete mode 100644 python/qemu/qmp/qmp_client.py
 delete mode 100644 python/qemu/qmp/qmp_shell.py
 delete mode 100644 python/qemu/qmp/qmp_tui.py
 delete mode 100644 python/qemu/qmp/util.py
 delete mode 100644 python/tests/protocol.py
 create mode 100644 python/wheels/qemu_qmp-0.0.5-py3-none-any.whl
 create mode 100644 pyvenv/meson.build
Signature · 1 line
2.51.1
author
#1 lore raw

PATCH v3 1/15 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.

---
 python/scripts/mkvenv.py | 6 ++++++
 1 file changed, 6 insertions(+)
python/scripts/mkvenv.py +6 -0
index a064709e6ce..a22e3ee3394 100644
@@ -838,6 +838,12 @@ def ensure_group(
             raise Ouch(result[0])
         raise SystemExit(f"\n{result[0]}\n\n")
 
+    if inside_a_venv():
+        for group in groups:
+            path = Path(sys.prefix).joinpath(f"{group}.group")
+            with open(path, "w", encoding="UTF8"):
+                pass
+
 
 def post_venv_setup() -> None:
     """
Signature · 1 line
2.51.1
Reviewed-by on v3 1/15
#2 lore raw

Re: [PATCH v3 01/15] python/mkvenv: create timestamp file for each group "ensured"

Quoted 16 lines · John Snow

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.

---
  python/scripts/mkvenv.py | 6 ++++++
  1 file changed, 6 insertions(+)
python/scripts/mkvenv.py +0 -0
index a064709e6ce..a22e3ee3394 100644
@@ -838,6 +838,12 @@ def ensure_group(
              raise Ouch(result[0])
          raise SystemExit(f"\n{result[0]}\n\n")

python/scripts/mkvenv.py def ensure_group( · line 849

Quoted 10 lines
python/scripts/mkvenv.py +6 -0
 
+    if inside_a_venv():
+        for group in groups:
+            path = Path(sys.prefix).joinpath(f"{group}.group")
+            with open(path, "w", encoding="UTF8"):
+                pass
+
 
  def post_venv_setup() -> None:
      """
author
#3 lore raw

PATCH v3 2/15 python/mkvenv: bump 'qemu.qmp' dependency for testdeps

In reply to John Snow

First up, use the newest v0.0.5 instead of the older v0.0.3.

Secondly, the use of a period in the key name does not behave as expected when installing and checking for dependencies, so quote this string instead.

---
 pythondeps.toml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
pythondeps.toml +1 -1
index 98e99e79005..1657953ff65 100644
@@ -32,5 +32,5 @@ sphinx = { accepted = ">=3.4.3", installed = "6.2.1", canary = "sphinx-build" }
 sphinx_rtd_theme = { accepted = ">=0.5", installed = "1.2.2" }
 
 [testdeps]
-qemu.qmp = { accepted = ">=0.0.3", installed = "0.0.3" }
+"qemu.qmp" = { accepted = ">=0.0.5", installed = "0.0.5" }
 pygdbmi = { accepted = ">=0.11.0.0", installed = "0.11.0.0" }
Signature · 1 line
2.51.1
author
#4 lore raw

PATCH v3 3/15 python/mkvenv: add 'checktests' and 'functests' dependency groups

In reply to John Snow

'checktests' contains depedencies *required* to run "make check", and as such, we promise that these dependencies can be sourced from the user's distribution repository or from vendored packages so that "make check" can be executed offline in an isolated build environment.

In contrast, pygdbmi is only needed for functional tests and not tests in general; we do not make the same offline/isolated guarantees for functional tests, and this dependency group is allowed to fetch dependencies from PyPI at runtime.

For the time being, Amend the "check-venv" target to install both dependency groups, to avoid a duplicate dependency between them.

---
 pythondeps.toml        | 10 +++++++++-
 tests/Makefile.include |  2 +-
 2 files changed, 10 insertions(+), 2 deletions(-)
pythondeps.toml +9 -1
index 1657953ff65..14ceb4e7787 100644
@@ -31,6 +31,14 @@ meson = { accepted = ">=1.9.0", installed = "1.9.0", canary = "meson" }
 sphinx = { accepted = ">=3.4.3", installed = "6.2.1", canary = "sphinx-build" }
 sphinx_rtd_theme = { accepted = ">=0.5", installed = "1.2.2" }
 
-[testdeps]
+# This test group is for dependencies required to run "make check"
+# successfully, and should only include depedencies that can be
+# guaranteed via configure from system packages, or python packages we
+# vendor.
+[checktests]
 "qemu.qmp" = { accepted = ">=0.0.5", installed = "0.0.5" }
+
+# This test group is for functional tests, and can include dependencies
+# fetched from PyPI.
+[functests]
 pygdbmi = { accepted = ">=0.11.0.0", installed = "0.11.0.0" }
tests/Makefile.include +1 -1
index d4dfbf3716d..40b114bd158 100644
@@ -98,7 +98,7 @@ quiet-venv-pip = $(quiet-@)$(call quiet-command-run, \
 
 $(TESTS_VENV_TOKEN): $(SRC_PATH)/pythondeps.toml
 	$(call quiet-venv-pip,install -e "$(SRC_PATH)/python/")
-	$(MKVENV_ENSUREGROUP) $< testdeps
+	$(MKVENV_ENSUREGROUP) $< checktests functests
 	$(call quiet-command, touch $@)
 
 check-venv: $(TESTS_VENV_TOKEN)
Signature · 1 line
2.51.1
Reviewed-by on v3 3/15
#5 lore raw

Re: [PATCH v3 03/15] python/mkvenv: add 'checktests' and 'functests' dependency groups

Quoted 44 lines · John Snow

'checktests' contains depedencies *required* to run "make check", and as such, we promise that these dependencies can be sourced from the user's distribution repository or from vendored packages so that "make check" can be executed offline in an isolated build environment.

In contrast, pygdbmi is only needed for functional tests and not tests in general; we do not make the same offline/isolated guarantees for functional tests, and this dependency group is allowed to fetch dependencies from PyPI at runtime.

For the time being, Amend the "check-venv" target to install both dependency groups, to avoid a duplicate dependency between them.

---
  pythondeps.toml        | 10 +++++++++-
  tests/Makefile.include |  2 +-
  2 files changed, 10 insertions(+), 2 deletions(-)
pythondeps.toml +9 -1
index 1657953ff65..14ceb4e7787 100644
@@ -31,6 +31,14 @@ meson = { accepted = ">=1.9.0", installed = "1.9.0", canary = "meson" }
  sphinx = { accepted = ">=3.4.3", installed = "6.2.1", canary = "sphinx-build" }
  sphinx_rtd_theme = { accepted = ">=0.5", installed = "1.2.2" }
 
-[testdeps]
+# This test group is for dependencies required to run "make check"
+# successfully, and should only include depedencies that can be
+# guaranteed via configure from system packages, or python packages we
+# vendor.
+[checktests]
  "qemu.qmp" = { accepted = ">=0.0.5", installed = "0.0.5" }
+
+# This test group is for functional tests, and can include dependencies
+# fetched from PyPI.
+[functests]
  pygdbmi = { accepted = ">=0.11.0.0", installed = "0.11.0.0" }
tests/Makefile.include +0 -0
index d4dfbf3716d..40b114bd158 100644

tests/Makefile.include quiet-venv-pip = $(quiet-@)$(call quiet-command-run, \ · line 104

Quoted 8 lines
tests/Makefile.include +1 -1
@@ -98,7 +98,7 @@ quiet-venv-pip = $(quiet-@)$(call quiet-command-run, \
 
  $(TESTS_VENV_TOKEN): $(SRC_PATH)/pythondeps.toml
  	$(call quiet-venv-pip,install -e "$(SRC_PATH)/python/")
-	$(MKVENV_ENSUREGROUP) $< testdeps
+	$(MKVENV_ENSUREGROUP) $< checktests functests
  	$(call quiet-command, touch $@)
 
  check-venv: $(TESTS_VENV_TOKEN)
#6 lore raw

Re: [PATCH v3 03/15] python/mkvenv: add 'checktests' and 'functests' dependency groups

In reply to John Snow
Quoted 5 lines · John Snow

'checktests' contains depedencies *required* to run "make check", and as such, we promise that these dependencies can be sourced from the user's distribution repository or from vendored packages so that "make check" can be executed offline in an isolated build environment.

Quoted 7 lines

In contrast, pygdbmi is only needed for functional tests and not tests in general; we do not make the same offline/isolated guarantees for functional tests, and this dependency group is allowed to fetch dependencies from PyPI at runtime.

For the time being, Amend the "check-venv" target to install both dependency groups, to avoid a duplicate dependency between them.

We now have the 'run' script concept merged, so we can do "./run ..." and it'll "do the right thing" executing with the python venv in $PYTHONPATH, and locally built binaries in $PATH, etc.

What I think is missing is to ensure that qemu.qmp is *always* available in the venv.

The split of python deps between vendored and non-vendored pieces makes sense, but the association of 'qemu.qmp' with tests is overlooking that qemu.qmp is used for more than just the tests - it is also a dep of qmp-shell which is a developer tool. Given this I think tieing install of qemu.qmp to 'make check' (via 'make check-venv') is a mistake. Instead we should unconditionally install it when configure is run.

We have precedent for that in --enable-rust unconditionally installing all vendored Rust crates. Since we vendor qemu.qmp there's no download penalty, and timing the venv creation shows it takes about 1 second which is insignificant in the context of everything else configure does.

Anyway, if we move the 'checktests' group install to configure, then combined with the new 'run' script we would eliminate the main behaviour regression from removing qemu.qmp from git.

Leaving the 'functests' group to be lazy installed is OK, since as a developer if you're running a functional test directly, that is pretty likely to be after you already had run the 'make check-functional' command and saw a failure. IOW the venv will be populated with the needed deps.

Quoted 43 lines
---
 pythondeps.toml        | 10 +++++++++-
 tests/Makefile.include |  2 +-
 2 files changed, 10 insertions(+), 2 deletions(-)
pythondeps.toml +9 -1
index 1657953ff65..14ceb4e7787 100644
@@ -31,6 +31,14 @@ meson = { accepted = ">=1.9.0", installed = "1.9.0", canary = "meson" }
 sphinx = { accepted = ">=3.4.3", installed = "6.2.1", canary = "sphinx-build" }
 sphinx_rtd_theme = { accepted = ">=0.5", installed = "1.2.2" }
 
-[testdeps]
+# This test group is for dependencies required to run "make check"
+# successfully, and should only include depedencies that can be
+# guaranteed via configure from system packages, or python packages we
+# vendor.
+[checktests]
 "qemu.qmp" = { accepted = ">=0.0.5", installed = "0.0.5" }
+
+# This test group is for functional tests, and can include dependencies
+# fetched from PyPI.
+[functests]
 pygdbmi = { accepted = ">=0.11.0.0", installed = "0.11.0.0" }
tests/Makefile.include +1 -1
index d4dfbf3716d..40b114bd158 100644
@@ -98,7 +98,7 @@ quiet-venv-pip = $(quiet-@)$(call quiet-command-run, \
 
 $(TESTS_VENV_TOKEN): $(SRC_PATH)/pythondeps.toml
 	$(call quiet-venv-pip,install -e "$(SRC_PATH)/python/")
-	$(MKVENV_ENSUREGROUP) $< testdeps
+	$(MKVENV_ENSUREGROUP) $< checktests functests
 	$(call quiet-command, touch $@)
 
 check-venv: $(TESTS_VENV_TOKEN)
Signature · 1 line
2.51.1

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
author
#7 lore raw

Re: [PATCH v3 03/15] python/mkvenv: add 'checktests' and 'functests' dependency groups

Quoted 15 lines · Daniel P. Berrangé
Quoted 5 lines · John Snow

'checktests' contains depedencies *required* to run "make check", and as such, we promise that these dependencies can be sourced from the user's distribution repository or from vendored packages so that "make check" can be executed offline in an isolated build environment.

Quoted 7 lines

In contrast, pygdbmi is only needed for functional tests and not tests in general; we do not make the same offline/isolated guarantees for functional tests, and this dependency group is allowed to fetch dependencies from PyPI at runtime.

For the time being, Amend the "check-venv" target to install both dependency groups, to avoid a duplicate dependency between them.

Quoted 7 lines

We now have the 'run' script concept merged, so we can do "./run ..." and it'll "do the right thing" executing with the python venv in $PYTHONPATH, and locally built binaries in $PATH, etc.

What I think is missing is to ensure that qemu.qmp is *always* available in the venv.

Always-always, or should the run script do a just-in-time install when invoked? (Reading ahead: You mean always-always.) I recall we had competing ideas for the runscript, you didn't see mine, and yours got merged. Fine by me, but I forget the details. Where is your script...?

(I forget where the hell I was with all of this, my best recollection is that there is some fine-tuning to do with what dependencies get installed with which targets and when. I suppose I'll try to hammer out this specific issue as it's the most recent one in my inbox, then I will refresh and resend my series and see where we land.)

Quoted 8 lines

The split of python deps between vendored and non-vendored pieces makes sense, but the association of 'qemu.qmp' with tests is overlooking that qemu.qmp is used for more than just the tests - it is also a dep of qmp-shell which is a developer tool. Given this I think tieing install of qemu.qmp to 'make check' (via 'make check-venv') is a mistake. Instead we should unconditionally install it when configure is run.

Ah, okay. I think my only concern about doing this was that it was potentially slow and I was trying to be very aggressive about not installing anything that was not strictly necessary for the build. I do agree it's for more than 'tests', though - as you point out, it's for developer tooling too.

I'm not against always installing it, I think, but I have some lingering half-remembered reasons that made me think we didn't want that. I don't remember why. If there's no opposition to it, I guess I can just do that and see what happens...

Quoted 10 lines

We have precedent for that in --enable-rust unconditionally installing all vendored Rust crates. Since we vendor qemu.qmp there's no download penalty, and timing the venv creation shows it takes about 1 second which is insignificant in the context of everything else configure does.

Anyway, if we move the 'checktests' group install to configure, then combined with the new 'run' script we would eliminate the main behaviour regression from removing qemu.qmp from git.

Alright.

Quoted 7 lines

Leaving the 'functests' group to be lazy installed is OK, since as a developer if you're running a functional test directly, that is pretty likely to be after you already had run the 'make check-functional' command and saw a failure. IOW the venv will be populated with the needed deps.

mmmmm, OK. Let me catch up on some of my other emails and see what the other lingering complaints I can find are, and I will make a pass at a version that just installs qemu.qmp unconditionally. Feel free to yell at me on IRC with any lingering concerns you can think of to help me get back up to speed after my marathon break...

--js

Quoted 52 lines
Quoted 42 lines
---
 pythondeps.toml        | 10 +++++++++-
 tests/Makefile.include |  2 +-
 2 files changed, 10 insertions(+), 2 deletions(-)
pythondeps.toml +9 -1
index 1657953ff65..14ceb4e7787 100644
@@ -31,6 +31,14 @@ meson = { accepted = ">=1.9.0", installed = "1.9.0", canary = "meson" }
 sphinx = { accepted = ">=3.4.3", installed = "6.2.1", canary = "sphinx-build" }
 sphinx_rtd_theme = { accepted = ">=0.5", installed = "1.2.2" }
 
-[testdeps]
+# This test group is for dependencies required to run "make check"
+# successfully, and should only include depedencies that can be
+# guaranteed via configure from system packages, or python packages we
+# vendor.
+[checktests]
 "qemu.qmp" = { accepted = ">=0.0.5", installed = "0.0.5" }
+
+# This test group is for functional tests, and can include dependencies
+# fetched from PyPI.
+[functests]
 pygdbmi = { accepted = ">=0.11.0.0", installed = "0.11.0.0" }
tests/Makefile.include +1 -2
index d4dfbf3716d..40b114bd158 100644
@@ -98,7 +98,7 @@ quiet-venv-pip = $(quiet-@)$(call quiet-command-run, \
 
 $(TESTS_VENV_TOKEN): $(SRC_PATH)/pythondeps.toml
      $(call quiet-venv-pip,install -e "$(SRC_PATH)/python/")
-     $(MKVENV_ENSUREGROUP) $< testdeps
+     $(MKVENV_ENSUREGROUP) $< checktests functests
      $(call quiet-command, touch $@)
 
 check-venv: $(TESTS_VENV_TOKEN)
--
Quoted 2 lines

2.51.1

With regards,
Daniel
--

|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
author
#8 lore raw

PATCH v3 4/15 python/mkvenv: add mechanism to install local package(s)

In reply to John Snow

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.

The version constraint specification that Python specifies does not support relative paths, so it is difficult (or impossible?) to specify a path within the source tree, and we will need a workaround to do so.

By specifying a package name that starts with $SRCROOT, you can now specify a file path to a local package for installation. 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.

---
 python/scripts/mkvenv.py | 38 ++++++++++++++++++++++++++++++++------
 1 file changed, 32 insertions(+), 6 deletions(-)
python/scripts/mkvenv.py +32 -6
index a22e3ee3394..608b8faa9b2 100644
@@ -662,6 +662,7 @@ def pip_install(
     args: Sequence[str],
     online: bool = False,
     wheels_dir: Optional[Union[str, Path]] = None,
+    env: Optional[Dict[str, str]] = None,
 ) -> None:
     """
     Use pip to install a package or package(s) as specified in @args.
@@ -687,6 +688,7 @@ def pip_install(
     full_args += list(args)
     subprocess.run(
         full_args,
+        env=env,
         check=True,
     )
 
@@ -733,9 +735,15 @@ def _do_ensure(
     :param wheels_dir: If specified, search this path for packages.
     """
     absent = []
+    local_packages = []
     present = []
     canary = None
     for name, info in group.items():
+        if name.startswith("$SRCROOT/"):
+            srcroot = Path(__file__).parents[2]
+            pkgpath = name.replace("$SRCROOT/", f"file://{srcroot}/")
+            local_packages.append(pkgpath)
+            continue
         constraint = _make_version_constraint(info, False)
         matcher = Matcher(name + constraint)
         print(f"mkvenv: checking for {matcher}", file=sys.stderr)
@@ -770,15 +778,33 @@ def _do_ensure(
             print(f"mkvenv: installing {', '.join(absent)}", file=sys.stderr)
             try:
                 pip_install(args=absent, online=online, wheels_dir=wheels_dir)
-                return None
+                absent = []
             except subprocess.CalledProcessError:
                 pass
 
-        return diagnose(
-            absent[0],
-            online,
-            wheels_dir,
-            canary,
+        if absent:
+            return diagnose(
+                absent[0],
+                online,
+                wheels_dir,
+                canary,
+            )
+
+    # Handle local packages separately and last so we can use different
+    # installation arguments (-e), and so that any dependencies that may
+    # be covered above will be handled according to the depfile
+    # specifications.
+    if local_packages:
+        print(f"mkvenv: installing {', '.join(local_packages)}",
+              file=sys.stderr)
+        env = dict(os.environ)
+        env['PIP_CONFIG_SETTINGS'] = "editable_mode=compat"
+        pip_install(
+            args=["--no-build-isolation",
+                  "-e"] + local_packages,
+            online=online,
+            wheels_dir=wheels_dir,
+            env=env,
         )
 
     return None
Signature · 1 line
2.51.1
author
#9 lore raw

PATCH v3 5/15 meson, mkvenv: add checktests and functests custom targets

In reply to John Snow

add "pyvenv_checktests_group" and "pyvenv_functests_group" targets to meson. These targets will invoke mkvenv.py to install the associated dependency group to the build/pyvenv directory.

---
 meson.build        |  1 +
 pyvenv/meson.build | 40 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+)
 create mode 100644 pyvenv/meson.build
meson.build +1 -0
index d9293294d8e..d7f06b8392b 100644
@@ -4587,6 +4587,7 @@ subdir('scripts')
 subdir('tools')
 subdir('pc-bios')
 subdir('docs')
+subdir('pyvenv')
 # Tests are disabled on emscripten because they rely on host features that aren't
 # supported by emscripten (e.g. fork and unix socket).
 if host_os != 'emscripten'
pyvenv/meson.build new file +40 -0
new file mode 100644
index 00000000000..6e8acd9f2b8
@@ -0,0 +1,40 @@
+# Note that this file only controls "optional" dependency groups; groups
+# *required* for the build are handled directly in configure instead:
+# namely, meson and sphinx.
+
+# NB: This command may or may not include the "--online" flag, depending
+# on the results of configure.
+ensuregroup_cmd = config_host['MKVENV_ENSUREGROUP'].split()
+
+pyvenv_common_deps = files(
+    meson.project_source_root() + '/pythondeps.toml',
+    meson.project_source_root() + '/python/scripts/mkvenv.py'
+)
+pyvenv_wheel_dir = meson.project_source_root() + '/python/wheels'
+
+
+# This group *must* be available offline, for "make check"
+pyvenv_checktests_group = custom_target(
+    'pyvenv_checktests_group',
+    output: 'checktests.group',
+    input: pyvenv_common_deps,
+    command: ensuregroup_cmd + [
+        '--dir', pyvenv_wheel_dir,
+        '@INPUT0@',
+        'checktests',
+    ],
+)
+
+# This group is allowed to rely on internet, to fetch from PyPI.
+pyvenv_functests_group = custom_target(
+    'pyvenv_functests_group',
+    output: 'functests.group',
+    input: pyvenv_common_deps,
+    depends: pyvenv_checktests_group,
+    command: ensuregroup_cmd + [
+        '--online',
+        '--dir', pyvenv_wheel_dir,
+        '@INPUT0@',
+        'functests',
+    ],
+)
Signature · 1 line
2.51.1
author
#10 lore raw

PATCH v3 6/15 tests: Use configured python to run GitLab iotests

In reply to John Snow

use the configured python (and the pyvenv) to run iotests instead of the system default python3 interpreter.

---
 .gitlab-ci.d/buildtest.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
.gitlab-ci.d/buildtest.yml +2 -2
index 44df116139b..c3a9e8428c2 100644
@@ -351,10 +351,10 @@ build-tcg-disabled:
     - make check-unit
     - make check-qapi-schema
     - cd tests/qemu-iotests/
-    - ./check -raw 001 002 003 004 005 008 009 010 011 012 021 025 032 033 048
+    - ../../pyvenv/bin/python3 ./check -raw 001 002 003 004 005 008 009 010 011 012 021 025 032 033 048
             052 063 077 086 101 104 106 113 148 150 151 152 157 159 160 163
             170 171 184 192 194 208 221 226 227 236 253 277 image-fleecing
-    - ./check -qcow2 028 051 056 057 058 065 068 082 085 091 095 096 102 122
+    - ../../pyvenv/bin/python3 ./check -qcow2 028 051 056 057 058 065 068 082 085 091 095 096 102 122
             124 132 139 142 144 145 151 152 155 157 165 194 196 200 202
             208 209 216 218 227 234 246 247 248 250 254 255 257 258
             260 261 262 263 264 270 272 273 277 279 image-fleecing
Signature · 1 line
2.51.1
author
#11 lore raw

PATCH v3 7/15 tests: run "make check-venv" before running iotests

In reply to John Snow

Soon, qemu.qmp will not be included in the qemu.git tree and so invoking the meson target for preparing the "checktests" mkvenv group will be necessary for this test to run successfully. Doing it now in its own patch separates this change from the big switcheroo patches.

---
 .gitlab-ci.d/buildtest.yml | 1 +
 1 file changed, 1 insertion(+)
.gitlab-ci.d/buildtest.yml +1 -0
index c3a9e8428c2..97bddbffb40 100644
@@ -348,6 +348,7 @@ build-tcg-disabled:
                    --disable-docs --disable-sdl --disable-gtk --disable-vnc
       || { cat config.log meson-logs/meson-log.txt && exit 1; }
     - make -j"$JOBS"
+    - make check-venv
     - make check-unit
     - make check-qapi-schema
     - cd tests/qemu-iotests/
Signature · 1 line
2.51.1
author
#12 lore raw

PATCH v3 8/15 tests: ensure "make check-venv" is run for crash tests

In reply to John Snow

We are preparing to drop the Makefile logic that installs python test prerequisites, and so the trick to suppress ninja from re-configuring the project will no longer work.

Move the "check-venv" step into the build part of the image instead so that it is available for the fedora and debian device crash tests.

---
 .gitlab-ci.d/buildtest.yml | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
.gitlab-ci.d/buildtest.yml +2 -4
index 97bddbffb40..bf0fad1df10 100644
@@ -72,7 +72,7 @@ build-system-debian:
     CONFIGURE_ARGS: --with-coroutine=sigaltstack --enable-rust
     TARGETS: arm-softmmu i386-softmmu riscv64-softmmu sh4eb-softmmu
       sparc-softmmu xtensa-softmmu
-    MAKE_CHECK_ARGS: check-build
+    MAKE_CHECK_ARGS: check-venv check-build
 
 check-system-debian:
   extends: .native_test_job_template
@@ -101,7 +101,6 @@ crash-test-debian:
     IMAGE: debian
   script:
     - cd build
-    - make NINJA=":" check-venv
     - pyvenv/bin/python3 scripts/device-crash-test -q --tcg-only ./qemu-system-i386
 
 build-system-fedora:
@@ -115,7 +114,7 @@ build-system-fedora:
     CONFIGURE_ARGS: --disable-gcrypt --enable-nettle --enable-docs --enable-crypto-afalg --enable-rust
     TARGETS: microblaze-softmmu mips-softmmu
       xtensa-softmmu m68k-softmmu riscv32-softmmu ppc-softmmu sparc64-softmmu
-    MAKE_CHECK_ARGS: check-build check-doc
+    MAKE_CHECK_ARGS: check-venv check-build check-doc
 
 build-system-fedora-rust-nightly:
   extends:
@@ -158,7 +157,6 @@ crash-test-fedora:
     IMAGE: fedora
   script:
     - cd build
-    - make NINJA=":" check-venv
     - pyvenv/bin/python3 scripts/device-crash-test -q ./qemu-system-ppc
     - pyvenv/bin/python3 scripts/device-crash-test -q ./qemu-system-riscv32
 
Signature · 1 line
2.51.1
Reviewed-by on v3 8/15
#13 lore raw

Re: [PATCH v3 08/15] tests: ensure "make check-venv" is run for crash tests

Quoted 11 lines · John Snow

We are preparing to drop the Makefile logic that installs python test prerequisites, and so the trick to suppress ninja from re-configuring the project will no longer work.

Move the "check-venv" step into the build part of the image instead so that it is available for the fedora and debian device crash tests.

---
  .gitlab-ci.d/buildtest.yml | 6 ++----
  1 file changed, 2 insertions(+), 4 deletions(-)
author
#14 lore raw

PATCH v3 9/15 tests/lcitool: add python3 wheel and setuptools deps for qemu

In reply to John Snow

Installing local dependencies while offline, without PyPI access, requires the python3-setuptools and python3-wheel packages. Most distributions have these available anyway for one reason or another, but not all of them.

If you are asking yourself "Wait, aren't these packages guaranteed via installation of pip, via the ensurepip module, which mkvenv takes immense pains to provide for us?" - Well... since Python 3.13, "pip" does not actually come with "setuptools" or "wheel" anymore, and so if we want to build and install a python package, we actually need these available in the host environment.

(Note that you don't need these packages just to install a pre-built package, you only need them to *build* a package. With cutting edge setuptools and pip, all locally installed packages, even in editable mode, must be "built" first before being installed. Thus, these dependencies are being added specifically to facilitate installing qemu.git/python/qemu to the configure-time venv.)

---
 .gitlab-ci.d/cirrus/freebsd-14.vars     | 2 +-
 .gitlab-ci.d/cirrus/macos-14.vars       | 2 +-
 tests/docker/dockerfiles/alpine.docker  | 2 ++
 tests/docker/dockerfiles/centos9.docker | 2 ++
 tests/lcitool/projects/qemu.yml         | 2 ++
 tests/vm/generated/freebsd.json         | 2 ++
 6 files changed, 10 insertions(+), 2 deletions(-)
.gitlab-ci.d/cirrus/freebsd-14.vars +1 -1
index 6477440ef30..98fbde6cc64 100644
@@ -11,6 +11,6 @@ MAKE='/usr/local/bin/gmake'
 NINJA='/usr/local/bin/ninja'
 PACKAGING_COMMAND='pkg'
 PIP3='/usr/local/bin/pip'
-PKGS='alsa-lib bash bison bzip2 ca_root_nss capstone4 ccache4 cmocka coreutils ctags curl cyrus-sasl dbus diffutils dtc flex fusefs-libs3 gettext git glib gmake gnutls gsed gtk-vnc gtk3 json-c libepoxy libffi libgcrypt libjpeg-turbo libnfs libslirp libspice-server libssh libtasn1 llvm lzo2 meson mtools ncurses nettle ninja opencv pixman pkgconf png py311-numpy py311-pillow py311-pip py311-pyyaml py311-sphinx py311-sphinx_rtd_theme py311-tomli python3 rpm2cpio rust rust-bindgen-cli sdl2 sdl2_image snappy sndio socat spice-protocol tesseract usbredir virglrenderer vte3 vulkan-tools xorriso zstd'
+PKGS='alsa-lib bash bison bzip2 ca_root_nss capstone4 ccache4 cmocka coreutils ctags curl cyrus-sasl dbus diffutils dtc flex fusefs-libs3 gettext git glib gmake gnutls gsed gtk-vnc gtk3 json-c libepoxy libffi libgcrypt libjpeg-turbo libnfs libslirp libspice-server libssh libtasn1 llvm lzo2 meson mtools ncurses nettle ninja opencv pixman pkgconf png py311-numpy py311-pillow py311-pip py311-pyyaml py311-setuptools py311-sphinx py311-sphinx_rtd_theme py311-tomli py311-wheel python3 rpm2cpio rust rust-bindgen-cli sdl2 sdl2_image snappy sndio socat spice-protocol tesseract usbredir virglrenderer vte3 vulkan-tools xorriso zstd'
 PYPI_PKGS=''
 PYTHON='/usr/local/bin/python3'
.gitlab-ci.d/cirrus/macos-14.vars +1 -1
index 4701c388e14..6ad20733cd4 100644
@@ -12,5 +12,5 @@ NINJA='/opt/homebrew/bin/ninja'
 PACKAGING_COMMAND='brew'
 PIP3='/opt/homebrew/bin/pip3'
 PKGS='bash bc bindgen bison bzip2 capstone ccache cmocka coreutils ctags curl dbus diffutils dtc flex gcovr gettext git glib gnu-sed gnutls gtk+3 gtk-vnc jemalloc jpeg-turbo json-c libcbor libepoxy libffi libgcrypt libiscsi libnfs libpng libslirp libssh libtasn1 libusb llvm lzo make meson mtools ncurses nettle ninja pixman pkg-config python3 rpm2cpio rust sdl2 sdl2_image snappy socat sparse spice-protocol swtpm tesseract usbredir vde vte3 vulkan-tools xorriso zlib zstd'
-PYPI_PKGS='PyYAML numpy pillow sphinx sphinx-rtd-theme tomli'
+PYPI_PKGS='PyYAML numpy pillow sphinx sphinx-rtd-theme tomli setuptools wheel'
 PYTHON='/opt/homebrew/bin/python3'
tests/docker/dockerfiles/alpine.docker +2 -0
index 03dd6851f60..75c70068683 100644
@@ -87,8 +87,10 @@ RUN apk update && \
         py3-numpy \
         py3-pillow \
         py3-pip \
+        py3-setuptools \
         py3-sphinx \
         py3-sphinx_rtd_theme \
+        py3-wheel \
         py3-yaml \
         python3 \
         rpm2cpio \
tests/docker/dockerfiles/centos9.docker +2 -0
index 670e22be5ad..9bdf983fdcb 100644
@@ -101,9 +101,11 @@ RUN dnf distro-sync -y && \
         python3-numpy \
         python3-pillow \
         python3-pip \
+        python3-setuptools \
         python3-sphinx \
         python3-sphinx_rtd_theme \
         python3-tomli \
+        python3-wheel \
         rdma-core-devel \
         rust \
         rust-std-static \
tests/lcitool/projects/qemu.yml +2 -0
index 1ee7dcf3d46..5e34e953514 100644
@@ -98,11 +98,13 @@ packages:
  - python3-pillow
  - python3-pip
  - python3-PyYAML
+ - python3-setuptools
  - python3-sphinx
  - python3-sphinx-rtd-theme
  - python3-sqlite3
  - python3-tomli
  - python3-venv
+ - python3-wheel
  - rpm2cpio
  - rust
  - rust-std
tests/vm/generated/freebsd.json +2 -0
index f586827b136..08b6eb61553 100644
@@ -57,9 +57,11 @@
     "py311-pillow",
     "py311-pip",
     "py311-pyyaml",
+    "py311-setuptools",
     "py311-sphinx",
     "py311-sphinx_rtd_theme",
     "py311-tomli",
+    "py311-wheel",
     "python3",
     "rpm2cpio",
     "rust",
Signature · 1 line
2.51.1
author
#15 lore raw

PATCH v3 10/15 python: add vendored qemu.qmp package

In reply to John Snow

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.

---
 python/scripts/vendor.py                      |   2 ++
 python/wheels/qemu_qmp-0.0.5-py3-none-any.whl | Bin 0 -> 72263 bytes
 2 files changed, 2 insertions(+)
 create mode 100644 python/wheels/qemu_qmp-0.0.5-py3-none-any.whl
python/scripts/vendor.py +2 -0
index 33ac7a45de0..36cd27046e7 100755
@@ -43,6 +43,8 @@ def main() -> int:
     packages = {
         "meson==1.9.0":
         "45e51ddc41e37d961582d06e78c48e0f9039011587f3495c4d6b0781dad92357",
+        "qemu.qmp==0.0.5":
+        "e05782d6df5844b34e0d2f7c68693525da074deef7b641c1401dda6e4e3d6303",
     }
 
     vendor_dir = Path(__file__, "..", "..", "wheels").resolve()
python/wheels/qemu_qmp-0.0.5-py3-none-any.whl new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..6372b7544ffb015a5c77d9686e921b65c848d433
GIT binary patch
Signature · 1 line
2.51.1
author
#16 lore raw

PATCH v3 11/15 meson, mkvenv: make iotests depend on checktests group

In reply to John Snow
---
 tests/qemu-iotests/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/qemu-iotests/meson.build +1 -1
index d7bae71ced6..86a3541c0ae 100644
@@ -57,7 +57,7 @@ foreach format, speed: qemu_iotests_formats
       test('io-' + format + '-' + item,
            python,
            args: args,
-           depends: qemu_iotests_binaries,
+           depends: qemu_iotests_binaries + pyvenv_checktests_group,
            env: qemu_iotests_env,
            protocol: 'tap',
            timeout: 180,
Signature · 1 line
2.51.1
author
#17 lore raw

PATCH v3 12/15 meson, mkvenv: make functional tests depend on functests group

In reply to John Snow

Note that only the thorough group requires the extra testing dependencies; the quick group is guaranteed to run with our minimal testing dependency set.

---
 tests/functional/meson.build | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tests/functional/meson.build +6 -1
index 725630d3082..b8424a10376 100644
@@ -57,16 +57,20 @@ foreach speed : ['quick', 'thorough']
       continue
     endif
 
+    test_deps = [roms, keymap_targets]
+
     if speed == 'quick'
       suites = ['func-quick', 'func-' + target_base]
       target_tests = get_variable('tests_' + target_base + '_' + sysmode + '_quick', []) \
                      + get_variable('tests_generic_' + sysmode)
+      test_deps += [pyvenv_checktests_group]
     else
       suites = ['func-' + speed, 'func-' + target_base + '-' + speed, speed]
       target_tests = get_variable('tests_' + target_base + '_' + sysmode + '_' + speed, [])
+      test_deps += [pyvenv_functests_group]
     endif
 
-    test_deps = [roms, keymap_targets]
+
     test_env = environment()
     if have_tools
       test_env.set('QEMU_TEST_QEMU_IMG', meson.global_build_root() / 'qemu-img')
@@ -99,6 +103,7 @@ foreach speed : ['quick', 'thorough']
       precache = custom_target('func-precache-' + testname,
                                output: teststamp,
                                command: [python, testpath],
+                               depends: pyvenv_functests_group,
                                depend_files: files(testpath),
                                build_by_default: false,
                                env: test_precache_env)
Signature · 1 line
2.51.1
author
#18 lore raw

PATCH v3 13/15 meson, mkvenv: add qemu.git/python/qemu package to pythondeps.toml

In reply to John Snow

Add the local python package group into pythondeps.toml for the checktests group. This makes qemu.qmp, qemu.machine and qemu.utils packages unconditionally available for tests.

---
 pythondeps.toml | 1 +
 1 file changed, 1 insertion(+)
pythondeps.toml +1 -0
index 14ceb4e7787..6057e3453e1 100644
@@ -37,6 +37,7 @@ sphinx_rtd_theme = { accepted = ">=0.5", installed = "1.2.2" }
 # vendor.
 [checktests]
 "qemu.qmp" = { accepted = ">=0.0.5", installed = "0.0.5" }
+"$SRCROOT/python/" = { }
 
 # This test group is for functional tests, and can include dependencies
 # fetched from PyPI.
Signature · 1 line
2.51.1
author
#19 lore raw

PATCH v3 14/15 tests: replace old "check-venv" target with meson target

In reply to John Snow

With new meson dependencies in place, swap the "check-venv" command to one that invokes the meson dependency system to ensure the appropriate testing dependencies are installed to the pyvenv.

This command is not required when running "make check" as the meson dependency system is aware that it needs to install the testing deps to run that suite, however, for certain manual test invocations (device-crash-test, iotests when run manually) this make target serves as a convenient way to explicitly request those dependencies be added to the pyvenv.

Note that this patch actually changes the meaning of check-venv slightly to how it has been operating in the past: this target now only installs the necessary patches to run "make check" and will no longer pull in dependencies for functional tests. This winds up being safe to do because the meson dependencies will handle functional tests satisfactorily; running "make check-functional" will pull in any additional dependencies needed to run that portion of the test suite on its own.

---
 tests/Makefile.include | 25 ++++++-------------------
 1 file changed, 6 insertions(+), 19 deletions(-)
tests/Makefile.include +6 -19
index 40b114bd158..237d410ad83 100644
@@ -83,33 +83,16 @@ clean-tcg: $(CLEAN_TCG_TARGET_RULES)
 .PHONY: distclean-tcg
 distclean-tcg: $(DISTCLEAN_TCG_TARGET_RULES)
 
-# Python venv for running tests
-
-.PHONY: check-venv
-
 # Build up our target list from the filtered list of ninja targets
 TARGETS=$(patsubst libqemu-%.a, %, $(filter libqemu-%.a, $(ninja-targets)))
 
-TESTS_VENV_TOKEN=$(BUILD_DIR)/pyvenv/tests.group
-
-quiet-venv-pip = $(quiet-@)$(call quiet-command-run, \
-    $(PYTHON) -m pip -q --disable-pip-version-check $1, \
-    "VENVPIP","$1")
-
-$(TESTS_VENV_TOKEN): $(SRC_PATH)/pythondeps.toml
-	$(call quiet-venv-pip,install -e "$(SRC_PATH)/python/")
-	$(MKVENV_ENSUREGROUP) $< checktests functests
-	$(call quiet-command, touch $@)
-
-check-venv: $(TESTS_VENV_TOKEN)
-
 FUNCTIONAL_TARGETS=$(patsubst %-softmmu,check-functional-%, $(filter %-softmmu,$(TARGETS)))
 .PHONY: $(FUNCTIONAL_TARGETS)
-$(FUNCTIONAL_TARGETS): check-venv
+$(FUNCTIONAL_TARGETS):
 	@$(MAKE) SPEED=thorough $(subst -functional,-func,$@)
 
 .PHONY: check-functional
-check-functional: check-venv
+check-functional:
 	@$(NINJA) precache-functional
 	@$(PYTHON) $(SRC_PATH)/scripts/clean_functional_cache.py
 	@QEMU_TEST_NO_DOWNLOAD=1 $(MAKE) SPEED=thorough check-func check-func-quick
@@ -117,6 +100,10 @@ check-functional: check-venv
 .PHONY: check-func check-func-quick
 check-func check-func-quick:
 
+.PHONY: check-venv
+check-venv:
+	@$(NINJA) pyvenv/checktests.group
+
 # Consolidated targets
 
 .PHONY: check check-clean
Signature · 1 line
2.51.1
author
#20 lore raw

PATCH v3 15/15 python: delete qemu.qmp

In reply to John Snow

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/

---
 python/qemu/qmp/__init__.py   |   60 --
 python/qemu/qmp/error.py      |   53 --
 python/qemu/qmp/events.py     |  751 ----------------------
 python/qemu/qmp/legacy.py     |  339 ----------
 python/qemu/qmp/message.py    |  217 -------
 python/qemu/qmp/models.py     |  146 -----
 python/qemu/qmp/protocol.py   | 1101 ---------------------------------
 python/qemu/qmp/py.typed      |    0
 python/qemu/qmp/qmp_client.py |  732 ----------------------
 python/qemu/qmp/qmp_shell.py  |  689 ---------------------
 python/qemu/qmp/qmp_tui.py    |  665 --------------------
 python/qemu/qmp/util.py       |  150 -----
 python/qemu/utils/qom_fuse.py |    1 -
 python/setup.cfg              |   31 +-
 python/tests/minreqs.txt      |    8 +-
 python/tests/protocol.py      |  596 ------------------
 16 files changed, 6 insertions(+), 5533 deletions(-)
 delete mode 100644 python/qemu/qmp/__init__.py
 delete mode 100644 python/qemu/qmp/error.py
 delete mode 100644 python/qemu/qmp/events.py
 delete mode 100644 python/qemu/qmp/legacy.py
 delete mode 100644 python/qemu/qmp/message.py
 delete mode 100644 python/qemu/qmp/models.py
 delete mode 100644 python/qemu/qmp/protocol.py
 delete mode 100644 python/qemu/qmp/py.typed
 delete mode 100644 python/qemu/qmp/qmp_client.py
 delete mode 100644 python/qemu/qmp/qmp_shell.py
 delete mode 100644 python/qemu/qmp/qmp_tui.py
 delete mode 100644 python/qemu/qmp/util.py
 delete mode 100644 python/tests/protocol.py
python/qemu/qmp/__init__.py deleted +0 -60
deleted file mode 100644
index 058139dc3ca..00000000000
@@ -1,60 +0,0 @@
-"""
-QEMU Monitor Protocol (QMP) development library & tooling.
-
-This package provides a fairly low-level class for communicating
-asynchronously with QMP protocol servers, as implemented by QEMU, the
-QEMU Guest Agent, and the QEMU Storage Daemon.
-
-`QMPClient` provides the main functionality of this package. All errors
-raised by this library derive from `QMPError`, see `qmp.error` for
-additional detail. See `qmp.events` for an in-depth tutorial on
-managing QMP events.
-"""
-
-# Copyright (C) 2020-2022 John Snow for Red Hat, Inc.
-#
-# Authors:
-#  John Snow <[email protected]>
-#
-# Based on earlier work by Luiz Capitulino <[email protected]>.
-#
-# This work is licensed under the terms of the GNU LGPL, version 2 or
-# later. See the COPYING file in the top-level directory.
-
-import logging
-
-from .error import QMPError
-from .events import EventListener
-from .message import Message
-from .protocol import (
-    ConnectError,
-    Runstate,
-    SocketAddrT,
-    StateError,
-)
-from .qmp_client import ExecInterruptedError, ExecuteError, QMPClient
-
-
-# Suppress logging unless an application engages it.
-logging.getLogger('qemu.qmp').addHandler(logging.NullHandler())
-
-
-# IMPORTANT: When modifying this list, update the Sphinx overview docs.
-# Anything visible in the qemu.qmp namespace should be on the overview page.
-__all__ = (
-    # Classes, most to least important
-    'QMPClient',
-    'Message',
-    'EventListener',
-    'Runstate',
-
-    # Exceptions, most generic to most explicit
-    'QMPError',
-    'StateError',
-    'ConnectError',
-    'ExecuteError',
-    'ExecInterruptedError',
-
-    # Type aliases
-    'SocketAddrT',
-)
python/qemu/qmp/error.py deleted +0 -53

53 lines not on this page · raw message

python/qemu/qmp/events.py deleted +0 -751

751 lines not on this page · raw message

python/qemu/qmp/legacy.py deleted +0 -339

339 lines not on this page · raw message

python/qemu/qmp/message.py deleted +0 -217

217 lines not on this page · raw message

python/qemu/qmp/models.py deleted +0 -146

146 lines not on this page · raw message

python/qemu/qmp/protocol.py deleted +0 -1101

1,101 lines not on this page · raw message

python/qemu/qmp/py.typed deleted +0 -0
deleted file mode 100644
index e69de29bb2d..00000000000
python/qemu/qmp/qmp_client.py deleted +0 -732

333 lines not on this page · raw message

python/qemu/qmp/qmp_shell.py deleted +0 -689

689 lines not on this page · raw message

python/qemu/qmp/qmp_tui.py deleted +0 -665

665 lines not on this page · raw message

python/qemu/qmp/util.py deleted +0 -150

150 lines not on this page · raw message

python/qemu/utils/qom_fuse.py +0 -1
index cf7e344bd53..e377ef6942f 100644

Lines of this file are not shown. View the raw message.

python/setup.cfg +3 -28
index f40f11396c9..c46a95f8d41 100644

Lines of this file are not shown. View the raw message.

python/tests/minreqs.txt +3 -5
index cd2e2a81c3d..855b5129c94 100644

Lines of this file are not shown. View the raw message.

python/tests/protocol.py deleted +0 -596

596 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.51.1

Part of the diff is not shown here. View the raw message.

author
#21 lore raw
In reply to John Snow

First of all: Ping!

Please-Review: Daniel P. Berrangé <[email protected]>
Please-Review: Paolo Bonzini <[email protected]>
Please-Review: Alex Bennée <[email protected]>

It would be nice to get this series staged right as the tree opens so that I can address any build issues it creates in a timely manner during the next window.

Second, [below, in-line] ...

Quoted 63 lines · John Snow

Hello!

This series drops the in-tree version of our python-qemu-qmp package ("qemu.qmp") in favor of the version hosted on PyPI, whose repository is located at https://gitlab.com/qemu-project/python-qemu-qmp.

GitLab CI: https://gitlab.com/jsnow/qemu/-/pipelines/2197613036
(FreeBSD isn't my fault...!)

The major effects of this patch series are:

1. qemu.qmp will be installed from PyPI or vendored packages instead of being utilized directly from the qemu.git tree.
2. There are no new python dependencies checked or installed during configure. All test dependencies are installed post-hoc on an as-needed basis.
3. "make check-venv" is no longer required to be run manually before any test that is integrated with meson; this includes "make check" and "make check-functional".
4. "make check-venv" no longer installs functional test dependencies: it installs only the core suite of python test dependencies.
5. "make check-venv" is now required as a pre-requisite for running device-crash-test and manually executed iotests.
6. Unfortunately, python3-wheel and python3-setuptools are now required on the host system if tests are to be executed and >= Python 3.13 is used.
7. An awful lot of deleted lines of code, and a lot fewer headaches managing two nearly-identical copies of this source code. O:-)

Patches 1-5 are build system focused; they set up new pythondeps.toml, mkvenv, and meson systems in preparation for relying on an external qemu.qmp library, but does not yet make the switch.

Patches 6-9 are testing and CI focused; they add necessary preparation steps to keep tests running happily once the in-tree qemu.qmp library is removed.

Patches 10-15 are build system focused again; they implement the actual switchover to the external qemu.qmp library.

v3:

- Fixed FreeBSD vm test
- Fixed Cirrus macOS test (Needed setuptools as a dep, "file:///" had one too many forward slashes, which works fine for older pip/setuptools, but was incompatibly fixed recently.)
- Fixed an issue that prevented installing the local python packages in an offline, isolated build environment (need --no-isolated-build and pip environment variable flags)
- Added the python3-wheel and python3-setuptools build dependencies to lcitool, owing to the above issues
- Ensured that the $download flag (for PyPI access) from configure is carried over into pytest/meson.build invocations. This defaults to "enabled", so test dependencies should not have any issue being fetched on most developer workstations and build environments.
- Fixed several bugs in the mkvenv.py local package installation mechanism.
- Flags and workarounds added for installing local packages offline now apply *only* to local package installations, and not "normal" depspecs.
- Reordered patches into more logical "phases" for easier review (I hope...?)

Quoted 5 lines

Known issues: "make check-build" still installs all of the test dependencies to the pyvenv. I'm not sure if this is desired or not, but I ran into problems preventing it from doing this without breaking a ton of CI tests. I'll continue to investigate this, but wanted to send this v3 out.

I sussed it out. I *can* remove the pyvenv targets from "check-build", and the reason CI tests fail when I do this is because the build templates use NINJA=":", so running "make check" suppresses the meson dependencies. It can be rectified by setting eight of the twelve total occurrences of "make check-build" in our CI files to also run "make check-venv".

It's not clear if we want this or not. It depends on what "check-build" semantically means. On the one hand, it doesn't do any prefetch for the functional tests, so you could make the argument that environment setup is similar. On the other hand, I think it's used almost exclusively by and for the CI test suite, in which case it running the environment setup is likely a pretty helpful/useful thing. It's something Thomas pointed out, but I don't feel like I have a strong opinion on it currently.

--js

Quoted 80 lines

v2:

- move "make check-venv" earlier in GitLab CI/CD pipeline, to avoid re-running configure
- Fix functional tests not using PyPI to fetch pygdbmi package
- Remove pre-requisites which are now merged

--js

John Snow (15):
python/mkvenv: create timestamp file for each group "ensured" python/mkvenv: bump 'qemu.qmp' dependency for testdeps python/mkvenv: add 'checktests' and 'functests' dependency groups python/mkvenv: add mechanism to install local package(s) meson, mkvenv: add checktests and functests custom targets
tests: Use configured python to run GitLab iotests
tests: run "make check-venv" before running iotests
tests: ensure "make check-venv" is run for crash tests tests/lcitool: add python3 wheel and setuptools deps for qemu
python: add vendored qemu.qmp package
meson, mkvenv: make iotests depend on checktests group meson, mkvenv: make functional tests depend on functests group meson, mkvenv: add qemu.git/python/qemu package to pythondeps.toml
tests: replace old "check-venv" target with meson target
python: delete qemu.qmp

 meson.build                                   |    1 +
 .gitlab-ci.d/buildtest.yml                    |   11 +-
 .gitlab-ci.d/cirrus/freebsd-14.vars           |    2 +-
 .gitlab-ci.d/cirrus/macos-14.vars             |    2 +-
 python/qemu/qmp/__init__.py                   |   60 -
 python/qemu/qmp/error.py                      |   53 -
 python/qemu/qmp/events.py                     |  751 -----------
 python/qemu/qmp/legacy.py                     |  339 -----
 python/qemu/qmp/message.py                    |  217 ----
 python/qemu/qmp/models.py                     |  146 ---
 python/qemu/qmp/protocol.py                   | 1101 -----------------
 python/qemu/qmp/py.typed                      |    0
 python/qemu/qmp/qmp_client.py                 |  732 -----------
 python/qemu/qmp/qmp_shell.py                  |  689 -----------
 python/qemu/qmp/qmp_tui.py                    |  665 ----------
 python/qemu/qmp/util.py                       |  150 ---
 python/qemu/utils/qom_fuse.py                 |    1 -
 python/scripts/mkvenv.py                      |   44 +-
 python/scripts/vendor.py                      |    2 +
 python/setup.cfg                              |   31 +-
 python/tests/minreqs.txt                      |    8 +-
 python/tests/protocol.py                      |  596 ---------
 python/wheels/qemu_qmp-0.0.5-py3-none-any.whl |  Bin 0 -> 72263 bytes
 pythondeps.toml                               |   13 +-
 pyvenv/meson.build                            |   40 +
 tests/Makefile.include                        |   25 +-
 tests/docker/dockerfiles/alpine.docker        |    2 +
 tests/docker/dockerfiles/centos9.docker       |    2 +
 tests/functional/meson.build                  |    7 +-
 tests/lcitool/projects/qemu.yml               |    2 +
 tests/qemu-iotests/meson.build                |    2 +-
 tests/vm/generated/freebsd.json               |    2 +
 32 files changed, 126 insertions(+), 5570 deletions(-)
 delete mode 100644 python/qemu/qmp/__init__.py
 delete mode 100644 python/qemu/qmp/error.py
 delete mode 100644 python/qemu/qmp/events.py
 delete mode 100644 python/qemu/qmp/legacy.py
 delete mode 100644 python/qemu/qmp/message.py
 delete mode 100644 python/qemu/qmp/models.py
 delete mode 100644 python/qemu/qmp/protocol.py
 delete mode 100644 python/qemu/qmp/py.typed
 delete mode 100644 python/qemu/qmp/qmp_client.py
 delete mode 100644 python/qemu/qmp/qmp_shell.py
 delete mode 100644 python/qemu/qmp/qmp_tui.py
 delete mode 100644 python/qemu/qmp/util.py
 delete mode 100644 python/tests/protocol.py
 create mode 100644 python/wheels/qemu_qmp-0.0.5-py3-none-any.whl
 create mode 100644 pyvenv/meson.build

--
2.51.1

#22 lore raw
In reply to John Snow
Quoted 6 lines · John Snow

Hello!

This series drops the in-tree version of our python-qemu-qmp package ("qemu.qmp") in favor of the version hosted on PyPI, whose repository is located at https://gitlab.com/qemu-project/python-qemu-qmp.

Quoted 7 lines

GitLab CI: https://gitlab.com/jsnow/qemu/-/pipelines/2197613036
(FreeBSD isn't my fault...!)

The major effects of this patch series are:

1. qemu.qmp will be installed from PyPI or vendored packages instead of being utilized directly from the qemu.git tree.

This is not getting installed in enough scenarios IMHO.

My current workflow is commonly

  $ ./configure --target-list=x86_64-softmmu
  $ make
  $ ./scripts/qmp/qmp-shell-wrap 
   /var/home/berrange/src/virt/qemu/build
  Traceback (most recent call last):
    File "/var/home/berrange/src/virt/qemu/scripts/qmp/qmp-shell-wrap", line 7, in <module>
      from qemu.qmp import qmp_shell
  ModuleNotFoundError: No module named 'qemu.qmp'

Even if I add in a call to 'source build/pyvenv/bin/activate' after 'make', I'm still missing the qemu.qmp python module.

AFAICT, qemu.qmp only gets installed in the venv if you run 'make check', and IMHO that should not be expected for the above usage scenario.

Likewise I can no longer run any of the test programs directly without first having run 'make check'. eg what I would currently do is:

   $ ./configure --target-list=x86_64-softmmu
   $ make
   $ cd build/tests/qemu-iotests
   $ ./check 300

I don't generally run 'make check' as frequently as I 'configure && make' as it adds alot of time which is not needed usually.

In general I find it tedious having to remember to run 'source build/pyvenv/bin/activate' in every terminal window where I might want to run a QEMU script that relies on python. It is also fairly undesirable too, as I use the same terminal window for various purposes, that activating the QEMU venv can interfere with non-QEMU python usage.

I would find it helpful if we provided a "run" script in the root dir of the build directory that contained the following

  $ cat build/run
  #!/bin/sh

set -e

  HERE=$(realpath $(dirname $0))
  source $HERE/pyvenv/bin/activate
  exec "$@"

Which would be used as a wrapper to execute scripts with the right environment. That would let us keep the simpler workflow, and avoid polluting the global terminal environment with the qemu venv.

eg to be used as

   $ ./configure --target-list=x86_64-softmmu
   $ make
   $ cd build/tests/qemu-iotests
   $ ../../run ./check 300

or

  $ ./configure --target-list=x86_64-softmmu
  $ make
  $ ./build/run ./scripts/qmp/qmp-shell-wrap 
Quoted 20 lines

2. There are no new python dependencies checked or installed during configure. All test dependencies are installed post-hoc on an as-needed basis.
3. "make check-venv" is no longer required to be run manually before any test that is integrated with meson; this includes "make check" and "make check-functional".
4. "make check-venv" no longer installs functional test dependencies: it installs only the core suite of python test dependencies.
5. "make check-venv" is now required as a pre-requisite for running device-crash-test and manually executed iotests.
6. Unfortunately, python3-wheel and python3-setuptools are now required on the host system if tests are to be executed and >= Python 3.13 is used.
7. An awful lot of deleted lines of code, and a lot fewer headaches managing two nearly-identical copies of this source code. O:-)

Patches 1-5 are build system focused; they set up new pythondeps.toml, mkvenv, and meson systems in preparation for relying on an external qemu.qmp library, but does not yet make the switch.

Quoted 6 lines

Patches 6-9 are testing and CI focused; they add necessary preparation steps to keep tests running happily once the in-tree qemu.qmp library is removed.

Patches 10-15 are build system focused again; they implement the actual switchover to the external qemu.qmp library.

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
author
#23 lore raw
Quoted 10 lines · Daniel P. Berrangé
Quoted 9 lines · John Snow

Hello!

This series drops the in-tree version of our python-qemu-qmp package ("qemu.qmp") in favor of the version hosted on PyPI, whose repository is located at https://gitlab.com/qemu-project/python-qemu-qmp.

GitLab CI: https://gitlab.com/jsnow/qemu/-/pipelines/2197613036
(FreeBSD isn't my fault...!)

Quoted 7 lines
Quoted 4 lines

The major effects of this patch series are:

1. qemu.qmp will be installed from PyPI or vendored packages instead of being utilized directly from the qemu.git tree.

This is not getting installed in enough scenarios IMHO.

It's hard to trigger an install when you don't use the build system, though... If you bypass make/meson/ninja entirely I'm not really sure what I can do to bootstrap the test deps.

Quoted 12 lines

My current workflow is commonly

  $ ./configure --target-list=x86_64-softmmu
  $ make
  $ ./scripts/qmp/qmp-shell-wrap
   /var/home/berrange/src/virt/qemu/build
  Traceback (most recent call last):
    File "/var/home/berrange/src/virt/qemu/scripts/qmp/qmp-shell-wrap",
line 7, in <module>
      from qemu.qmp import qmp_shell
  ModuleNotFoundError: No module named 'qemu.qmp'
Quoted 7 lines

Even if I add in a call to 'source build/pyvenv/bin/activate' after 'make', I'm still missing the qemu.qmp python module.

AFAICT, qemu.qmp only gets installed in the venv if you run 'make check', and IMHO that should not be expected for the above usage scenario.

"make check-venv", to do just the minimum setup. You don't have to run check.

We could always add a flag to configure to front-load the testing environment and scripts, but I thought it was best to avoid adding new dependencies by default.

Like --with-python-tests or something? Then you'd always have it like you do with meson and sphinx (with --enable-docs)

Quoted 13 lines

Likewise I can no longer run any of the test programs directly without first having run 'make check'. eg what I would currently do is:

   $ ./configure --target-list=x86_64-softmmu
   $ make
   $ cd build/tests/qemu-iotests
   $ ./check 300

I don't generally run 'make check' as frequently as I 'configure && make' as it adds alot of time which is not needed usually.

Quoted 7 lines

In general I find it tedious having to remember to run 'source build/pyvenv/bin/activate' in every terminal window where I might want to run a QEMU script that relies on python. It is also fairly undesirable too, as I use the same terminal window for various purposes, that activating the QEMU venv can interfere with non-QEMU python usage.

You can run one-offs with build/pyvenv/bin/python3 without activating the environment,

but you're right that this does require an environment setup step (make check-venv)

Quoted 24 lines

I would find it helpful if we provided a "run" script in the root dir of the build directory that contained the following

  $ cat build/run
  #!/bin/sh

set -e

  HERE=$(realpath $(dirname $0))
  source $HERE/pyvenv/bin/activate
  exec "$@"

Which would be used as a wrapper to execute scripts with the right environment. That would let us keep the simpler workflow, and avoid polluting the global terminal environment with the qemu venv.

eg to be used as

   $ ./configure --target-list=x86_64-softmmu
   $ make
   $ cd build/tests/qemu-iotests
   $ ../../run ./check 300
Quoted 5 lines

or

  $ ./configure --target-list=x86_64-softmmu
  $ make
  $ ./build/run ./scripts/qmp/qmp-shell-wrap

Shouldn't be too hard to add, honestly. Maybe adding in a "meson compile pyvenv/pyvenv_tests_group" line at the start to trigger the dep installation if it hasn't occurred already?

Or maybe just directly invoking mkvenv ensuregroup to avoid ninja re-configuring things while you develop.

Something like that.

Quoted 41 lines
Quoted 23 lines

2. There are no new python dependencies checked or installed during configure. All test dependencies are installed post-hoc on an as-needed basis.
3. "make check-venv" is no longer required to be run manually before any test that is integrated with meson; this includes "make check" and "make check-functional".
4. "make check-venv" no longer installs functional test dependencies: it installs only the core suite of python test dependencies.
5. "make check-venv" is now required as a pre-requisite for running device-crash-test and manually executed iotests.
6. Unfortunately, python3-wheel and python3-setuptools are now required on the host system if tests are to be executed and >= Python 3.13 is used.
7. An awful lot of deleted lines of code, and a lot fewer headaches managing two nearly-identical copies of this source code. O:-)

Patches 1-5 are build system focused; they set up new pythondeps.toml, mkvenv, and meson systems in preparation for relying on an external qemu.qmp library, but does not yet make the switch.

Quoted 6 lines

Patches 6-9 are testing and CI focused; they add necessary preparation steps to keep tests running happily once the in-tree qemu.qmp library is removed.

Patches 10-15 are build system focused again; they implement the actual switchover to the external qemu.qmp library.

With regards,
Daniel
--
|: https://berrange.com -o-
https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-
https://fstop138.berrange.com :|
|: https://entangle-photo.org -o-
https://www.instagram.com/dberrange :|

author
#24 lore raw
Quoted 109 lines · John Snow
Quoted 11 lines · Daniel P. Berrangé
Quoted 9 lines · John Snow

Hello!

This series drops the in-tree version of our python-qemu-qmp package ("qemu.qmp") in favor of the version hosted on PyPI, whose repository is located at https://gitlab.com/qemu-project/python-qemu-qmp.

GitLab CI: https://gitlab.com/jsnow/qemu/-/pipelines/2197613036
(FreeBSD isn't my fault...!)

Quoted 6 lines
Quoted 4 lines

The major effects of this patch series are:

1. qemu.qmp will be installed from PyPI or vendored packages instead of being utilized directly from the qemu.git tree.

This is not getting installed in enough scenarios IMHO.

It's hard to trigger an install when you don't use the build system, though... If you bypass make/meson/ninja entirely I'm not really sure what I can do to bootstrap the test deps.

Quoted 12 lines

My current workflow is commonly

  $ ./configure --target-list=x86_64-softmmu
  $ make
  $ ./scripts/qmp/qmp-shell-wrap
   /var/home/berrange/src/virt/qemu/build
  Traceback (most recent call last):
    File "/var/home/berrange/src/virt/qemu/scripts/qmp/qmp-shell-wrap", line 7, in <module>
      from qemu.qmp import qmp_shell
  ModuleNotFoundError: No module named 'qemu.qmp'
Quoted 6 lines

Even if I add in a call to 'source build/pyvenv/bin/activate' after 'make', I'm still missing the qemu.qmp python module.

AFAICT, qemu.qmp only gets installed in the venv if you run 'make check', and IMHO that should not be expected for the above usage scenario.

"make check-venv", to do just the minimum setup. You don't have to run check.

We could always add a flag to configure to front-load the testing environment and scripts, but I thought it was best to avoid adding new dependencies by default.

Like --with-python-tests or something? Then you'd always have it like you do with meson and sphinx (with --enable-docs)

Quoted 14 lines

Likewise I can no longer run any of the test programs directly without first having run 'make check'. eg what I would currently do is:

   $ ./configure --target-list=x86_64-softmmu
   $ make
   $ cd build/tests/qemu-iotests
   $ ./check 300

I don't generally run 'make check' as frequently as I 'configure && make' as it adds alot of time which is not needed usually.

Quoted 6 lines

In general I find it tedious having to remember to run 'source build/pyvenv/bin/activate' in every terminal window where I might want to run a QEMU script that relies on python. It is also fairly undesirable too, as I use the same terminal window for various purposes, that activating the QEMU venv can interfere with non-QEMU python usage.

You can run one-offs with build/pyvenv/bin/python3 without activating the environment,

but you're right that this does require an environment setup step (make check-venv)

Quoted 25 lines

I would find it helpful if we provided a "run" script in the root dir of the build directory that contained the following

  $ cat build/run
  #!/bin/sh

set -e

  HERE=$(realpath $(dirname $0))
  source $HERE/pyvenv/bin/activate
  exec "$@"

Which would be used as a wrapper to execute scripts with the right environment. That would let us keep the simpler workflow, and avoid polluting the global terminal environment with the qemu venv.

eg to be used as

   $ ./configure --target-list=x86_64-softmmu
   $ make
   $ cd build/tests/qemu-iotests
   $ ../../run ./check 300
Quoted 5 lines

or

  $ ./configure --target-list=x86_64-softmmu
  $ make
  $ ./build/run ./scripts/qmp/qmp-shell-wrap
Quoted 5 lines

Shouldn't be too hard to add, honestly. Maybe adding in a "meson compile pyvenv/pyvenv_tests_group" line at the start to trigger the dep installation if it hasn't occurred already?

Or maybe just directly invoking mkvenv ensuregroup to avoid ninja re-configuring things while you develop.

Something like that.

How about something like this inside of your build root:

```
#!/usr/bin/env python3

import os
from pathlib import Path
import shlex
import subprocess
import sys

def main():
    venvpath = Path(__file__).parent.joinpath('pyvenv')

    groupfile = venvpath.joinpath('checktests.group')
    if not groupfile.exists():
        subprocess.run(["ninja", "pyvenv/checktests.group"])

    env = os.environ.copy()
    env['VIRTUAL_ENV'] = str(venvpath)
    env['PATH'] = str(venvpath.joinpath('bin')) + ':' + env['PATH']
    env['VIRTUAL_ENV_PROMPT'] = 'pyvenv'
    if 'PYTHONHOME' in env:
        del env['PYTHONHOME']

    command = shlex.join(sys.argv[1:])
    res = subprocess.run(command, env=env, shell=True)
    sys.exit(res.returncode)

if __name__ == '__main__':
    main()
```

Then you can run arbitrary things, like "./pyrun which python3" or whatever you fancy. It only bothers calling ninja if the timestamp file is not there to help save some startup time and avoid unnecessary reconfigures. This should work for qmp-shell, qmp-shell-wrap, qemu-ga-client, qmp-tui, qom, qom-fuse, qom-get, qom-list, qom-set, qom-tree, device-crash-test, iotests, etc.

Quoted 40 lines
Quoted 40 lines
Quoted 26 lines

2. There are no new python dependencies checked or installed during configure. All test dependencies are installed post-hoc on an as-needed basis.
3. "make check-venv" is no longer required to be run manually before any test that is integrated with meson; this includes "make check" and "make check-functional".
4. "make check-venv" no longer installs functional test dependencies: it installs only the core suite of python test dependencies.
5. "make check-venv" is now required as a pre-requisite for running device-crash-test and manually executed iotests.
6. Unfortunately, python3-wheel and python3-setuptools are now required on the host system if tests are to be executed and >= Python 3.13 is used.
7. An awful lot of deleted lines of code, and a lot fewer headaches managing two nearly-identical copies of this source code. O:-)

Patches 1-5 are build system focused; they set up new pythondeps.toml, mkvenv, and meson systems in preparation for relying on an external qemu.qmp library, but does not yet make the switch.

Quoted 6 lines

Patches 6-9 are testing and CI focused; they add necessary preparation steps to keep tests running happily once the in-tree qemu.qmp library is removed.

Patches 10-15 are build system focused again; they implement the actual switchover to the external qemu.qmp library.

With regards,
Daniel
--

|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#25 lore raw
In reply to John Snow
Quoted 15 lines · John Snow
Quoted 12 lines · Daniel P. Berrangé
Quoted 11 lines · John Snow

Hello!

This series drops the in-tree version of our python-qemu-qmp package ("qemu.qmp") in favor of the version hosted on PyPI, whose repository is located at https://gitlab.com/qemu-project/python-qemu-qmp.

GitLab CI: https://gitlab.com/jsnow/qemu/-/pipelines/2197613036
(FreeBSD isn't my fault...!)

The major effects of this patch series are:

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

1. qemu.qmp will be installed from PyPI or vendored packages instead of being utilized directly from the qemu.git tree.

This is not getting installed in enough scenarios IMHO.

It's hard to trigger an install when you don't use the build system,

Well I am using the build system in the same way that I've always used it with QEMU. IOW, the benchmark for this is the current way things work with the python stuff in tree. The ideal would be to match that behaviour with no workflow changes needed, if it is practical to achieve that without major downsides.

Quoted 2 lines

though... If you bypass make/meson/ninja entirely I'm not really sure what I can do to bootstrap the test deps.

Can we just do it unconditionally in configure / meson ? These aren't big files to download, and we're already dealing other python stuff for the build, and git submodules, and rust crates. Pulling in qemu.qmp doesn't feel like it is a burden to do by default ?

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
author
#26 lore raw
Quoted 23 lines · Daniel P. Berrangé
Quoted 21 lines · John Snow
Quoted 17 lines · Daniel P. Berrangé
Quoted 6 lines · John Snow

Hello!

This series drops the in-tree version of our python-qemu-qmp package ("qemu.qmp") in favor of the version hosted on PyPI, whose repository is located at https://gitlab.com/qemu-project/python-qemu-qmp.

Quoted 7 lines

GitLab CI: https://gitlab.com/jsnow/qemu/-/pipelines/2197613036
(FreeBSD isn't my fault...!)

The major effects of this patch series are:

1. qemu.qmp will be installed from PyPI or vendored packages instead of being utilized directly from the qemu.git tree.

This is not getting installed in enough scenarios IMHO.

Quoted 7 lines
Quoted 1 line

It's hard to trigger an install when you don't use the build system,

Well I am using the build system in the same way that I've always used it with QEMU. IOW, the benchmark for this is the current way things work with the python stuff in tree. The ideal would be to match that behaviour with no workflow changes needed, if it is practical to achieve that without major downsides.

I know, but if we add out-of-tree things, there's some fundamental things that change - we need to load that dependency somewhere, somewhen.

Quoted 8 lines
Quoted 3 lines

though... If you bypass make/meson/ninja entirely I'm not really sure what I can do to bootstrap the test deps.

Can we just do it unconditionally in configure / meson ? These aren't big files to download, and we're already dealing other python stuff for the build, and git submodules, and rust crates. Pulling in qemu.qmp doesn't feel like it is a burden to do by default ?

I definitely could, and I think it would be rather convenient; I only have some minor concerns about it:

- We don't promise tests on all platforms that we promise builds on. We have definitely broken this in the past. It might work currently, but it's a line I want to be aware we are crossing. It may necessitate python3-wheel and python3-setuptools just to build in this case. That's probably not an issue on workstations, but it's more bricks on the wall that are actually not truly needed until you run tests (or prepare to run tests).

- Configure will get slower by default. I can install the core test deps by default if people don't mind the additional delay time. It might be something like 2-4 seconds, depending. If you don't care, I don't.

- Things like functional tests are still going to require some kind of environment prep for all the extra stuff they require, I don't think it's reasonable to preload all of that stuff at configure time, and we never have. "make check-functional" is sufficient to pull those deps in, but if there are ways to engage the functional tests manually that people are using, I think another preparation step is unavoidable there.

So, in addition to the "pyrun" wrapper I mailed in a separate reply (which I think is a good idea anyway, regardless of what direction we go here), I see two main paths that address your issues in differing amounts:

(1) make configure prepare the test deps *by default*, adding a flag like --without-test-deps to disable it, or

(2) Continue not prepping the test deps, but allow --with-test-deps to pre-load them.

More or less the same solution, just with different defaults. I'm fairly ambivalent, my only personal "habit" here is "I am really reluctant to touch configure unless there is a strong consensus around it because I dislike having to make arguments at that level."

Quoted 9 lines

With regards,
Daniel
--

|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
#27 lore raw
Quoted 32 lines · John Snow
Quoted 23 lines · Daniel P. Berrangé
Quoted 21 lines · John Snow
Quoted 17 lines · Daniel P. Berrangé
Quoted 6 lines · John Snow

Hello!

This series drops the in-tree version of our python-qemu-qmp package ("qemu.qmp") in favor of the version hosted on PyPI, whose repository is located at https://gitlab.com/qemu-project/python-qemu-qmp.

Quoted 7 lines

GitLab CI: https://gitlab.com/jsnow/qemu/-/pipelines/2197613036
(FreeBSD isn't my fault...!)

The major effects of this patch series are:

1. qemu.qmp will be installed from PyPI or vendored packages instead of being utilized directly from the qemu.git tree.

This is not getting installed in enough scenarios IMHO.

Quoted 7 lines
Quoted 1 line

It's hard to trigger an install when you don't use the build system,

Well I am using the build system in the same way that I've always used it with QEMU. IOW, the benchmark for this is the current way things work with the python stuff in tree. The ideal would be to match that behaviour with no workflow changes needed, if it is practical to achieve that without major downsides.

Quoted 3 lines

I know, but if we add out-of-tree things, there's some fundamental things that change - we need to load that dependency somewhere, somewhen.

Yep, there's a tradeoff, so we have to figure out what's practical to achieve.

Quoted 11 lines
Quoted 7 lines
Quoted 2 lines

though... If you bypass make/meson/ninja entirely I'm not really sure what I can do to bootstrap the test deps.

Can we just do it unconditionally in configure / meson ? These aren't big files to download, and we're already dealing other python stuff for the build, and git submodules, and rust crates. Pulling in qemu.qmp doesn't feel like it is a burden to do by default ?

I definitely could, and I think it would be rather convenient; I only have some minor concerns about it:

Quoted 7 lines

- We don't promise tests on all platforms that we promise builds on. We have definitely broken this in the past. It might work currently, but it's a line I want to be aware we are crossing. It may necessitate python3-wheel and python3-setuptools just to build in this case. That's probably not an issue on workstations, but it's more bricks on the wall that are actually not truly needed until you run tests (or prepare to run tests).

We should focus on doing what's optimal for platforms where tests do work, since they're inherantly our most important platforms. If we proactively fetch python deps for tests that happen to be broken on a platform already, I'm not too fussed about that, as long as we don't break things more than they are already broken.

Quoted 4 lines

- Configure will get slower by default. I can install the core test deps by default if people don't mind the additional delay time. It might be something like 2-4 seconds, depending. If you don't care, I don't.

IIUC, 'pip' will have a local cache of downloads somewhere under $HOME, so presumably when we install deps, we're only going to have a download hit the very first time on a machine, or when the needed versions change ? If we're mostly just copying files out of the local cache, the time overhead should remain fairly minimal most of the time.

We have precedent for downloading stuff at configure stage from the Rust deps and git submodules. Those Rust deps are used for built code rather than tests, but if we did need some rust deps only for tests, presumably they'd still be done in configure ?

Quoted 7 lines

- Things like functional tests are still going to require some kind of environment prep for all the extra stuff they require, I don't think it's reasonable to preload all of that stuff at configure time, and we never have. "make check-functional" is sufficient to pull those deps in, but if there are ways to engage the functional tests manually that people are using, I think another preparation step is unavoidable there.

I'd we interested to know how much overhead loading the functional test deps actually is ?

As a conceptual point beyond this series, I've always tended to expect that a "configure" script (or equivalent) is responsible for validating the host OS pre-requisites and/or fetching neede pre-requisites.

Anything after that (whether builds or tests) would then (mostly) work from stuff that was already acquired by configure.

This lets devs see upfront if there are any problems with their host, instead of the host problems being hit later where the errors are mixed in with build logs.

With functional tests we of course don't want to download the assets upfront as that's GB's of data. I would tend towards suggesting that any python deps should be fetched upfront at the configure stage though, unless we see an unacceptable time hit from that.

Quoted 4 lines

So, in addition to the "pyrun" wrapper I mailed in a separate reply (which I think is a good idea anyway, regardless of what direction we go here), I see two main paths that address your issues in differing amounts:

I sent that as a formal proposal here:

https://lists.nongnu.org/archive/html/qemu-devel/2025-12/msg01351.html

For the functional test example illustrated there though, we would preferrably want the functional test deps fetched upfront.

Quoted 2 lines

(1) make configure prepare the test deps *by default*, adding a flag like --without-test-deps to disable it, or

Note, this is not just about test deps. The qemu python code is used by other misc QEMU developer tools, such as the qmp-shell command. I'm considering the python deps as more like "QEMU build env pre-requisites", which is what pushed me towards believeing they should be fetched by default

Quoted 7 lines

(2) Continue not prepping the test deps, but allow --with-test-deps to pre-load them.

More or less the same solution, just with different defaults. I'm fairly ambivalent, my only personal "habit" here is "I am really reluctant to touch configure unless there is a strong consensus around it because I dislike having to make arguments at that level."

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|