python: drop qemu.qmp from qemu.git tree
v5 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/2272170300
This version reflects Dan's suggestion to always install the in-tree Python packages by default.
The major effects of this patch series are:
1. qemu.qmp and the python/ directory will be installed to the configure-time venv (build/pyvenv) by default.
2. qemu.qmp will be installed from PyPI or vendored packages instead of being utilized directly from the qemu.git tree.
3. "make check-venv" is removed as it is no longer needed.
4. functional test dependencies are installed as-needed when running those tests.
5. 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.
6. An awful lot of deleted lines of code, and a lot fewer headaches managing two nearly-identical copies of this source code. O:-)
v5:
- Changed the local package install mechanism as per Paolo's advice
- Changed "file://" mechanism for local installs, following the msys2 test fixes upstream that did the same
- Fix typo in cover letter (thuth)
- Fixed comments around mkvenv invocations; functests group will *always* use the --online flag, whether or not it was configured. (danpb)
- Please, let this nightmare be over
v4:
- Rename "checktests" group to "tooling", install it by default alongside meson at configure-time.
- Remove "check-venv" entirely.
- Update python/README.rst to reflect the new paradigm
- Update many scripts that import qemu.qmp to give new errors when they are run outside of the configure venv
KNOWN ISSUES IN V4:
- The last patch is an RFC based on Thomas' observations, I don't have a strong opinion on if we want it or not.
- Removing "make check-venv" causes the VM tests to rebuild more often; I was not sure how to replace the old conditional behavior in an equivalent manner. Suggestions, anyone...?
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 (16):
python/mkvenv: create timestamp file for each group "ensured" python/mkvenv: bump 'qemu.qmp' dependency for testdeps python/mkvenv: add 'tooling' and 'functests' dependency groups python/mkvenv: add mechanism to install local package(s) meson, mkvenv: add functests custom target
tests: Use configured python to run GitLab iotests
tests: use "run" script to execute device-crash-test tests/lcitool: add python3 wheel and setuptools deps for qemu
python: add vendored qemu.qmp package
meson, mkvenv: make functional tests depend on functests group meson, mkvenv: add qemu.git/python/qemu package to pythondeps.toml
configure: unconditionally install "tooling" group
tests: remove "make check-venv" target
scripts: nudge users to use 'run' script for scripts that import
qemu.qmp
python: delete qemu.qmp
python: update README.rst to reflect qemu.qmp's removal
python/README.rst | 50 +- configure | 2 +- meson.build | 1 + .gitlab-ci.d/buildtest.yml | 26 +- .gitlab-ci.d/cirrus/freebsd-14.vars | 2 +- .gitlab-ci.d/cirrus/macos-14.vars | 2 +- .gitlab-ci.d/windows.yml | 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 | 43 +- 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 | 27 + scripts/compare-machine-types.py | 7 +- scripts/device-crash-test | 5 +- scripts/qmp/qemu-ga-client | 13 +- scripts/qmp/qmp-shell | 13 +- scripts/qmp/qmp-shell-wrap | 13 +- scripts/qmp/qom-fuse | 13 +- scripts/qmp/qom-get | 13 +- scripts/qmp/qom-list | 13 +- scripts/qmp/qom-set | 13 +- scripts/qmp/qom-tree | 13 +- scripts/qmp_helper.py | 9 +- scripts/render_block_graph.py | 10 +- scripts/simplebench/bench_block_job.py | 10 +- tests/Makefile.include | 22 +- tests/docker/dockerfiles/alpine.docker | 2 + tests/docker/dockerfiles/centos9.docker | 2 + tests/functional/meson.build | 5 +- tests/lcitool/projects/qemu.yml | 2 + tests/migration-stress/guestperf/engine.py | 15 +- tests/vm/Makefile.include | 24 +- tests/vm/generated/freebsd.json | 2 + 49 files changed, 245 insertions(+), 5683 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.52.0
PATCH v5 1/16 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
@@ -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.52.0
PATCH v5 2/16 python/mkvenv: bump 'qemu.qmp' dependency for testdeps
In reply to John SnowFirst 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
@@ -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.52.0
PATCH v5 3/16 python/mkvenv: add 'tooling' and 'functests' dependency groups
In reply to John Snow'tooling' contains depedencies required to run various tools (like qmp-shell) as well as dependencies 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. By the end of this series, however, "check-venv" will be eliminated in favor of always installing "tooling" at configure time and allowing "functests" to be installed on-demand as needed by meson/ninja.
--- pythondeps.toml | 10 +++++++++- tests/Makefile.include | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-)
pythondeps.toml +9 -1
@@ -31,6 +31,14 @@ meson = { accepted = ">=1.10.0", installed = "1.10.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 various tooling +# and tests that should always be installed at configure time. It should +# only include dependencies that can be guaranteed via configure from +# system packages, or python packages we vendor. +[tooling] "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
@@ -107,7 +107,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) $< tooling functests $(call quiet-command, touch $@) check-venv: $(TESTS_VENV_TOKEN)
Signature · 1 line
2.52.0
PATCH v5 4/16 python/mkvenv: add mechanism to install local package(s)
In reply to John SnowCurrently, 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.
--- python/scripts/mkvenv.py | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-)
python/scripts/mkvenv.py +31 -6
@@ -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,14 @@ 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 "path" in info: + pkgpath = Path(__file__).parents[2].joinpath(info["path"]) + local_packages.append(str(pkgpath)) + continue constraint = _make_version_constraint(info, False) matcher = Matcher(name + constraint) print(f"mkvenv: checking for {matcher}", file=sys.stderr)
@@ -770,15 +777,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.52.0
Re: [PATCH v5 04/16] python/mkvenv: add mechanism to install local package(s)
Quoted 27 lines · 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.
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.
Quoted 4 lines
Signed-off-by John Snow <[email protected]>--- python/scripts/mkvenv.py | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-)
PATCH v5 5/16 meson, mkvenv: add functests custom target
In reply to John Snowadd the "pyvenv_functests_group" target to meson. This target will invoke mkvenv.py to install the associated dependency group to the build/pyvenv directory.
A "pyvenv_tooling_group" is not included here as it is the plan to always install this group by default, so it will not need an on-demand trigger.
--- meson.build | 1 + pyvenv/meson.build | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 pyvenv/meson.build
meson.build +1 -0
@@ -4556,6 +4556,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 +27 -0
@@ -0,0 +1,27 @@ +# Note that this file only controls "optional" dependency groups; groups +# unconditionally installed at configure time are handled in configure +# instead; namely: meson, sphinx, and the tooling groups. + +# Note that this command may or may not include the "--online" flag +# based on configuration. +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 is allowed to (and must) rely on internet to fetch from +# PyPI. Force the use of the --online flag here. +pyvenv_functests_group = custom_target( + 'pyvenv_functests_group', + output: 'functests.group', + input: pyvenv_common_deps, + command: ensuregroup_cmd + [ + '--online', + '--dir', pyvenv_wheel_dir, + '@INPUT0@', + 'functests', + ], +)
Signature · 1 line
2.52.0
Re: [PATCH v5 05/16] meson, mkvenv: add functests custom target
Quoted 8 lines · John Snow
add the "
pyvenv_functests_group" target to meson. This target will invokemkvenv.pyto install the associated dependency group to the build/pyvenv directory.A "
pyvenv_tooling_group" is not included here as it is the plan to always install this group by default, so it will not need an on-demand trigger.
Quoted 6 lines
Signed-off-by John Snow <[email protected]>--- meson.build | 1 + pyvenv/meson.build | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+)create mode 100644 pyvenv/meson.build
PATCH v5 6/16 tests: Use configured python to run GitLab iotests
In reply to John Snowuse the configured python (and the pyvenv) to run iotests instead of the system default python3 interpreter. Use the new "run" script in the build directory to execute the command inside the meson developer environment, templated in qemu.git/run.in.
--- .gitlab-ci.d/buildtest.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
.gitlab-ci.d/buildtest.yml +9 -9
@@ -350,15 +350,15 @@ build-tcg-disabled: - make -j"$JOBS" - 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 - 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 - 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 - - cd ../.. + - ./run tests/qemu-iotests/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 + - ./run tests/qemu-iotests/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 - make distclean build-user:
Signature · 1 line
2.52.0
PATCH v5 7/16 tests: use "run" script to execute device-crash-test
In reply to John SnowInstead of invoking python from the configure venv manually, instruct developers to use the "run" script instead. Change the test invocation to be a good example going forward.
--- .gitlab-ci.d/buildtest.yml | 6 +++--- scripts/device-crash-test | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
.gitlab-ci.d/buildtest.yml +3 -3
@@ -102,7 +102,7 @@ crash-test-debian: script: - cd build - make NINJA=":" check-venv - - pyvenv/bin/python3 scripts/device-crash-test -q --tcg-only ./qemu-system-i386 + - ./run scripts/device-crash-test -q --tcg-only ./qemu-system-i386 build-system-fedora: extends:
@@ -159,8 +159,8 @@ crash-test-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 + - ./run scripts/device-crash-test -q ./qemu-system-ppc + - ./run scripts/device-crash-test -q ./qemu-system-riscv32 build-system-centos: extends:
scripts/device-crash-test +1 -1
@@ -42,7 +42,7 @@ except ModuleNotFoundError as exc: print(f"Module '{exc.name}' not found.") print(" Try 'make check-venv' from your build directory,") print(" and then one way to run this script is like so:") - print(f' > $builddir/pyvenv/bin/python3 "{path}"') + print(f' > $builddir/run "{path}"') sys.exit(1) logger = logging.getLogger('device-crash-test')
Signature · 1 line
2.52.0
PATCH v5 8/16 tests/lcitool: add python3 wheel and setuptools deps for qemu
In reply to John SnowInstalling 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 +- .gitlab-ci.d/windows.yml | 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 ++ 7 files changed, 12 insertions(+), 2 deletions(-)
.gitlab-ci.d/cirrus/freebsd-14.vars +1 -1
@@ -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
@@ -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'
.gitlab-ci.d/windows.yml +2 -0
@@ -89,6 +89,8 @@ msys2-64bit: mingw-w64-x86_64-pkgconf mingw-w64-x86_64-python mingw-w64-x86_64-python-certifi + mingw-w64-x86_64-python-setuptools + mingw-w64-x86_64-python-wheel mingw-w64-x86_64-rust mingw-w64-x86_64-rust-bindgen mingw-w64-x86_64-zstd"
tests/docker/dockerfiles/alpine.docker +2 -0
@@ -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
@@ -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
@@ -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
@@ -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.52.0
PATCH v5 9/16 python: add vendored qemu.qmp package
In reply to John SnowIn 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
@@ -43,6 +43,8 @@ def main() -> int: packages = { "meson==1.10.0": "4b27aafce281e652dcb437b28007457411245d975c48b5db3a797d3e93ae1585", + "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
Signature · 1 line
2.52.0
PATCH v5 10/16 meson, mkvenv: make functional tests depend on functests group
In reply to John SnowNote that only the thorough group requires the extra testing dependencies; the quick group will run with just the "tooling" group, which we intend to install by default at configure time in a forthcoming commit.
--- tests/functional/meson.build | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tests/functional/meson.build +4 -1
@@ -57,6 +57,8 @@ 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', []) \
@@ -64,9 +66,9 @@ foreach speed : ['quick', 'thorough'] 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 +101,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.52.0
PATCH v5 11/16 meson, mkvenv: add qemu.git/python/qemu package to pythondeps.toml
In reply to John SnowAdd the local python package group into pythondeps.toml for the tooling This makes qemu.qmp, qemu.machine and qemu.utils packages unconditionally available for tests and scripts.
--- pythondeps.toml | 1 + 1 file changed, 1 insertion(+)
pythondeps.toml +1 -0
@@ -37,6 +37,7 @@ sphinx_rtd_theme = { accepted = ">=0.5", installed = "1.2.2" } # system packages, or python packages we vendor. [tooling] "qemu.qmp" = { accepted = ">=0.0.5", installed = "0.0.5" } +"qemu" = { path = "python/" } # This test group is for functional tests, and can include dependencies # fetched from PyPI.
Signature · 1 line
2.52.0
Re: [PATCH v5 11/16] meson, mkvenv: add qemu.git/python/qemu package to pythondeps.toml
Il mar 3 feb 2026, 21:36 John Snow <[email protected]> ha scritto:
Quoted 4 lines
Add the local python package group into pythondeps.toml for the tooling This makes qemu.qmp, qemu.machine and qemu.utils packages unconditionally available for tests and scripts.
Out of curiosity why not add setuptools and wheel to the group, at this point? Can be done on top of course.
Paolo
Quoted 22 lines
Signed-off-by John Snow <[email protected]>--- pythondeps.toml | 1 + 1 file changed, 1 insertion(+)pythondeps.toml +1
-0@@ -37,6 +37,7 @@ sphinx_rtd_theme = { accepted = ">=0.5", installed = "1.2.2" } # system packages, or python packages we vendor. [tooling] "qemu.qmp" = { accepted = ">=0.0.5", installed = "0.0.5" } +"qemu" = { path = "python/" } # This test group is for functional tests, and can include dependencies# fetched from PyPI. -- 2.52.0
Re: [PATCH v5 11/16] meson, mkvenv: add qemu.git/python/qemu package to pythondeps.toml
Quoted 11 lines · Paolo Bonzini
Il mar 3 feb 2026, 21:36 John Snow <[email protected]> ha scritto:
Quoted 4 lines
Add the local python package group into pythondeps.toml for the tooling This makes qemu.qmp, qemu.machine and qemu.utils packages unconditionally available for tests and scripts.
Out of curiosity why not add setuptools and wheel to the group, at this point? Can be done on top of course.
Hm. If we're operating offline, it would only really serve as a configure check. Online it might actually be a help. I'll do it as a follow up, I just need to figure out which versions meet our needs and do testing to choose the accepted values.
Quoted 24 lines
Paolo
Quoted 21 lines
Signed-off-by John Snow <[email protected]>--- pythondeps.toml | 1 + 1 file changed, 1 insertion(+)pythondeps.toml +1
-1@@ -37,6 +37,7 @@ sphinx_rtd_theme = { accepted = ">=0.5", installed = "1.2.2" } # system packages, or python packages we vendor. [tooling] "qemu.qmp" = { accepted = ">=0.0.5", installed = "0.0.5" } +"qemu" = { path = "python/" } # This test group is for functional tests, and can include dependencies # fetched from PyPI. --2.52.0
Re: [PATCH v5 11/16] meson, mkvenv: add qemu.git/python/qemu package to pythondeps.toml
Quoted 7 lines · John Snow
Quoted 5 lines · Paolo Bonzini
Il mar 3 feb 2026, 21:36 John Snow <[email protected]> ha scritto:
Quoted 1 line
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Add the local python package group into pythondeps.toml for the tooling This makes qemu.qmp, qemu.machine and qemu.utils packages unconditionally available for tests and scripts.
Out of curiosity why not add setuptools and wheel to the group, at this point? Can be done on top of course.
Hm. If we're operating offline, it would only really serve as a
s/only/also/ :)
Quoted 3 lines
configure check. Online it might actually be a help. I'll do it as a follow up, I just need to figure out which versions meet our needs and do testing to choose the accepted values.
Use whatever is in bookworm or 22.04?
Paolo
Re: [PATCH v5 11/16] meson, mkvenv: add qemu.git/python/qemu package to pythondeps.toml
Quoted 21 lines · Paolo Bonzini
Quoted 2 lines · John Snow
On Tue, Feb 3, 2026 at 4:08 PM Paolo Bonzini <[email protected]>
Quoted 11 lines · wrote:
Quoted 11 lines
Il mar 3 feb 2026, 21:36 John Snow <[email protected]> ha scritto:
Quoted 4 lines
Add the local python package group into pythondeps.toml for the tooling This makes qemu.qmp, qemu.machine and qemu.utils packages unconditionally available for tests and scripts.
Out of curiosity why not add setuptools and wheel to the group, at
this point? Can be done on top of course.
Quoted 2 lines
Hm. If we're operating offline, it would only really serve as a
s/only/also/ :)
Quoted 8 lines
Quoted 3 lines
configure check. Online it might actually be a help. I'll do it as a follow up, I just need to figure out which versions meet our needs and do testing to choose the accepted values.
Use whatever is in bookworm or 22.04?
Paolo
OpenSUSE Leap 15.6 and 22.04 until April
https://gitlab.com/jsnow/repology-dashboard
44.x
--js
Quoted 1 line
Re: [PATCH v5 11/16] meson, mkvenv: add qemu.git/python/qemu package to pythondeps.toml
Quoted 4 lines · John Snow
Quoted 2 lines
Use whatever is in bookworm or 22.04?
OpenSUSE Leap 15.6 and 22.04 until April
Technically for OpenSUSE we would use py3XX-setuptools; py310-setuptools in particular is 67.6. But yeah, 22.04 is the oldest at this point and we might as well pick that one for our accepted version.
Quoted 3 lines
https://gitlab.com/jsnow/repology-dashboard
44.x
And 0.42.0 for wheel.
Paolo
Re: [PATCH v5 11/16] meson, mkvenv: add qemu.git/python/qemu package to pythondeps.toml
Quoted 5 lines · Paolo Bonzini
Quoted 4 lines · John Snow
Quoted 2 lines
Use whatever is in bookworm or 22.04?
OpenSUSE Leap 15.6 and 22.04 until April
I don't think we really really have to support OpenSUSE 15 anymore, do we? 16.0 has been released since a while, and we state that "The project aims to support the most recent major version at all times for up to five years after its initial release." - and OpenSUSE 15.0 has been released more than 5 years ago.
Quoted 4 lines
Technically for OpenSUSE we would use py3XX-setuptools; py310-setuptools in particular is 67.6. But yeah, 22.04 is the oldest at this point and we might as well pick that one for our accepted version.
Sounds reasonable. But in case it's causing trouble, 22.04 goes EOL on 2026-04-25 and the next QEMU release is planned for 2026-04-14, so IMHO that's close enough to at least consider to ignore it?
Thomas
Re: [PATCH v5 11/16] meson, mkvenv: add qemu.git/python/qemu package to pythondeps.toml
Quoted 6 lines · Thomas Huth
Quoted 4 lines · Paolo Bonzini
Quoted 3 lines · John Snow
Quoted 2 lines
Use whatever is in bookworm or 22.04?
Quoted 8 lines
Quoted 1 line
Quoted 1 line
OpenSUSE Leap 15.6 and 22.04 until April
I don't think we really really have to support OpenSUSE 15 anymore, do we? 16.0 has been released since a while, and we state that "The project aims to support the most recent major version at all times for up to five years after its initial release." - and OpenSUSE 15.0 has been released more than 5 years ago.
15.6 was released much more recently, and 16.0 only came out recently, so I think we are still on the hook. However, 15.6 does have a full set of Python 3.11 packages, so it doesn't matter. 22.04 is the blocker until April.
Quoted 7 lines
Quoted 4 lines
Technically for OpenSUSE we would use py3XX-setuptools; py310-setuptools in particular is 67.6. But yeah, 22.04 is the oldest at this point and we might as well pick that one for our accepted version.
Sounds reasonable. But in case it's causing trouble, 22.04 goes EOL on 2026-04-25 and the next QEMU release is planned for 2026-04-14, so IMHO that's close enough to at least consider to ignore it?
Not causing enough trouble to drop it early, we can give it one more release IMHO.
The real problem with mandating certain levels of Python ecosystem packages right now is actually the large number of cross compiler containers we are still using that are running Debian 11, I have since learned, so I am dropping the suggestion for the time being until that can be addressed.
Quoted 3 lines
Thomas
Re: [PATCH v5 11/16] meson, mkvenv: add qemu.git/python/qemu package to pythondeps.toml
In reply to John SnowQuoted 8 lines · John Snow
Add the local python package group into pythondeps.toml for the tooling This makes qemu.qmp, qemu.machine and qemu.utils packages unconditionally available for tests and scripts.
Signed-off-by John Snow <[email protected]>--- pythondeps.toml | 1 + 1 file changed, 1 insertion(+)
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 :|
Re: [PATCH v5 11/16] meson, mkvenv: add qemu.git/python/qemu package to pythondeps.toml
In reply to John SnowQuoted 14 lines · John Snow
Add the local python package group into pythondeps.toml for the tooling This makes qemu.qmp, qemu.machine and qemu.utils packages unconditionally available for tests and scripts.
Signed-off-by John Snow <[email protected]>--- pythondeps.toml | 1 + 1 file changed, 1 insertion(+)pythondeps.toml +0
-0
pythondeps.toml sphinx_rtd_theme = { accepted = ">=0.5", installed = "1.2.2" } · line 40
Quoted 4 lines
pythondeps.toml +1
-0@@ -37,6 +37,7 @@ sphinx_rtd_theme = { accepted = ">=0.5", installed = "1.2.2" } # system packages, or python packages we vendor. [tooling] "qemu.qmp" = { accepted = ">=0.0.5", installed = "0.0.5" } +"qemu" = { path = "python/" }
PATCH v5 12/16 configure: unconditionally install "tooling" group
In reply to John SnowAlongside meson, always ensure our in-tree tooling group and its out-of-tree dependency, qemu.qmp, is always installed.
As a result, several "check-venv" invocations can be removed from various testing scripts.
--- configure | 2 +- .gitlab-ci.d/buildtest.yml | 2 -- scripts/device-crash-test | 3 +-- 3 files changed, 2 insertions(+), 5 deletions(-)
configure +1 -1
@@ -966,7 +966,7 @@ mkvenv="$python ${source_path}/python/scripts/mkvenv.py" # Finish preparing the virtual environment using vendored .whl files $mkvenv ensuregroup --dir "${source_path}/python/wheels" \ - ${source_path}/pythondeps.toml meson || exit 1 + ${source_path}/pythondeps.toml meson tooling || exit 1 # At this point, we expect Meson to be installed and available. # We expect mkvenv or pip to have created pyvenv/bin/meson for us.
.gitlab-ci.d/buildtest.yml +0 -2
@@ -101,7 +101,6 @@ crash-test-debian: IMAGE: debian script: - cd build - - make NINJA=":" check-venv - ./run scripts/device-crash-test -q --tcg-only ./qemu-system-i386 build-system-fedora:
@@ -158,7 +157,6 @@ crash-test-fedora: IMAGE: fedora script: - cd build - - make NINJA=":" check-venv - ./run scripts/device-crash-test -q ./qemu-system-ppc - ./run scripts/device-crash-test -q ./qemu-system-riscv32
scripts/device-crash-test +1 -2
@@ -40,8 +40,7 @@ try: except ModuleNotFoundError as exc: path = Path(__file__).resolve() print(f"Module '{exc.name}' not found.") - print(" Try 'make check-venv' from your build directory,") - print(" and then one way to run this script is like so:") + print(" Try running this script like so:") print(f' > $builddir/run "{path}"') sys.exit(1)
Signature · 1 line
2.52.0
PATCH v5 13/16 tests: remove "make check-venv" target
In reply to John SnowWith the qemu.qmp and qemu.machine dependencies now installed by default at configure time and additional dependencies required by functional testing installed on demand, there is no longer any reason to have an explicit target.
FIXME: This forces image regeneration for vm tests whenever Make determines that the image needs to be rebuilt; which is a regression over the previous behavior.
--- tests/Makefile.include | 22 ++-------------------- tests/vm/Makefile.include | 24 +++++++----------------- 2 files changed, 9 insertions(+), 37 deletions(-)
tests/Makefile.include +2 -20
@@ -21,7 +21,6 @@ ifneq ($(filter $(all-check-targets), check-softfloat),) endif @echo @echo " $(MAKE) check-report.junit.xml Generates an aggregated XML test report" - @echo " $(MAKE) check-venv Creates a Python venv for tests" @echo " $(MAKE) check-clean Clean the tests and related data" @echo @echo "The following are useful for CI builds"
@@ -92,33 +91,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) $< tooling 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
tests/vm/Makefile.include +7 -17
@@ -1,14 +1,5 @@ # Makefile for VM tests -# Hack to allow running in an unconfigured build tree -ifeq ($(realpath $(SRC_PATH)),$(realpath .)) -VM_PYTHON = PYTHONPATH=$(SRC_PATH)/python /usr/bin/env python3 -VM_VENV = -else -VM_PYTHON = $(PYTHON) -VM_VENV = check-venv -endif - .PHONY: vm-build-all vm-clean-all EFI_AARCH64 = $(wildcard $(BUILD_DIR)/pc-bios/edk2-aarch64-code.fd)
@@ -90,11 +81,10 @@ vm-clean-all: $(IMAGES_DIR)/%.img: $(SRC_PATH)/tests/vm/% \ $(SRC_PATH)/tests/vm/basevm.py \ - $(SRC_PATH)/tests/vm/Makefile.include \ - $(VM_VENV) + $(SRC_PATH)/tests/vm/Makefile.include @mkdir -p $(IMAGES_DIR) $(call quiet-command, \ - $(VM_PYTHON) $< \ + $(PYTHON) $< \ $(if $(V)$(DEBUG), --debug) \ $(if $(GENISOIMAGE),--genisoimage $(GENISOIMAGE)) \ $(if $(QEMU_LOCAL),--build-path $(BUILD_DIR)) \
@@ -102,14 +92,14 @@ $(IMAGES_DIR)/%.img: $(SRC_PATH)/tests/vm/% \ $(if $(LOG_CONSOLE),--log-console) \ --source-path $(SRC_PATH) \ --image "$@" \ - $(if $(filter-out check-venv, $?), --force) \ + --force \ --build-image $@, \ " VM-IMAGE $*") # Build in VM $(IMAGE) -vm-build-%: $(IMAGES_DIR)/%.img $(VM_VENV) +vm-build-%: $(IMAGES_DIR)/%.img $(call quiet-command, \ - $(VM_PYTHON) $(SRC_PATH)/tests/vm/$* \ + $(PYTHON) $(SRC_PATH)/tests/vm/$* \ $(if $(V)$(DEBUG), --debug) \ $(if $(DEBUG), --interactive) \ $(if $(J),--jobs $(J)) \
@@ -133,9 +123,9 @@ vm-boot-serial-%: $(IMAGES_DIR)/%.img -device virtio-net-pci,netdev=vnet \ || true -vm-boot-ssh-%: $(IMAGES_DIR)/%.img $(VM_VENV) +vm-boot-ssh-%: $(IMAGES_DIR)/%.img $(call quiet-command, \ - $(VM_PYTHON) $(SRC_PATH)/tests/vm/$* \ + $(PYTHON) $(SRC_PATH)/tests/vm/$* \ $(if $(J),--jobs $(J)) \ $(if $(V)$(DEBUG), --debug) \ $(if $(QEMU_LOCAL),--build-path $(BUILD_DIR)) \
Signature · 1 line
2.52.0
Re: [PATCH v5 13/16] tests: remove "make check-venv" target
Quoted 8 lines · John Snow
With the qemu.qmp and qemu.machine dependencies now installed by default at configure time and additional dependencies required by functional testing installed on demand, there is no longer any reason to have an explicit target.
FIXME: This forces image regeneration for vm tests whenever Make determines that the image needs to be rebuilt; which is a regression over the previous behavior.
IIUC because you always pass the '--force' flag now. If the deps show it is dirty though, this seems right ? Is it a regression or was previous code incorrectly NOT forcing rebuild in all needed cases ? It is pretty confusing logic there.
Quoted 6 lines
Signed-off-by John Snow <[email protected]>--- tests/Makefile.include | 22 ++-------------------- tests/vm/Makefile.include | 24 +++++++----------------- 2 files changed, 9 insertions(+), 37 deletions(-)
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 :|
Re: [PATCH v5 13/16] tests: remove "make check-venv" target
Quoted 6 lines · Daniel P. Berrangé
Quoted 5 lines · John Snow
With the qemu.qmp and qemu.machine dependencies now installed by default at configure time and additional dependencies required by functional testing installed on demand, there is no longer any reason to have an explicit target.
Quoted 9 lines
Quoted 3 lines
FIXME: This forces image regeneration for vm tests whenever Make determines that the image needs to be rebuilt; which is a regression over the previous behavior.
IIUC because you always pass the '--force' flag now. If the deps show it is dirty though, this seems right ? Is it a regression or was previous code incorrectly NOT forcing rebuild in all needed cases ? It is pretty confusing logic there.
Yeah, admittedly I don't understand what the old conditional was even doing... I forgot I still had this fixme in here, mea culpa.
I suppose I kind of figured that if someone complained, I'd fix it then...? because I'm not sure exactly what regressed or in what cases, or how to even roll back and test the behavior pre-fix.
*loud shrugging*
Quoted 21 lines
Quoted 6 lines
Signed-off-by John Snow <[email protected]>--- tests/Makefile.include | 22 ++-------------------- tests/vm/Makefile.include | 24 +++++++----------------- 2 files changed, 9 insertions(+), 37 deletions(-)Reviewed-by Daniel P. Berrangé <[email protected]>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 :|
Re: [PATCH v5 13/16] tests: remove "make check-venv" target
In reply to John SnowQuoted 8 lines · John Snow
With the qemu.qmp and qemu.machine dependencies now installed by default at configure time and additional dependencies required by functional testing installed on demand, there is no longer any reason to have an explicit target.
FIXME: This forces image regeneration for vm tests whenever Make determines that the image needs to be rebuilt; which is a regression over the previous behavior.
Maybe elaborate on that (and then replace the "FIXME:" with a "Note:") - in which cases does Make think that the image needs to be regenerated? Hopefully not on every invocation?
Quoted 5 lines
Signed-off-by John Snow <[email protected]>--- tests/Makefile.include | 22 ++-------------------- tests/vm/Makefile.include | 24 +++++++----------------- 2 files changed, 9 insertions(+), 37 deletions(-)
Re: [PATCH v5 13/16] tests: remove "make check-venv" target
In reply to John SnowQuoted 69 lines · John Snow
With the qemu.qmp and qemu.machine dependencies now installed by default at configure time and additional dependencies required by functional testing installed on demand, there is no longer any reason to have an explicit target.
FIXME: This forces image regeneration for vm tests whenever Make determines that the image needs to be rebuilt; which is a regression over the previous behavior.
Signed-off-by John Snow <[email protected]>--- tests/Makefile.include | 22 ++-------------------- tests/vm/Makefile.include | 24 +++++++----------------- 2 files changed, 9 insertions(+), 37 deletions(-)tests/Makefile.include +2
-20@@ -21,7 +21,6 @@ ifneq ($(filter $(all-check-targets), check-softfloat),) endif @echo @echo " $(MAKE) check-report.junit.xml Generates an aggregated XML test report" - @echo " $(MAKE) check-venv Creates a Python venv for tests" @echo " $(MAKE) check-clean Clean the tests and related data" @echo @echo "The following are useful for CI builds"@@ -92,33 +91,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) $< tooling 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-quicktests/vm/Makefile.include +0
-0@@ -1,14 +1,5 @@ # Makefile for VM tests
tests/vm/Makefile.include line 11
Quoted 10 lines
tests/vm/Makefile.include +0
-9-# Hack to allow running in an unconfigured build tree -ifeq ($(realpath $(SRC_PATH)),$(realpath .)) -VM_PYTHON = PYTHONPATH=$(SRC_PATH)/python /usr/bin/env python3 -VM_VENV = -else -VM_PYTHON = $(PYTHON) -VM_VENV = check-venv -endif -
It's a shame to loose this because the build directory should have no influence on what we build in the VM. Surely if we have qmp installed on the system (and therefor its deps) we should still want the ability to build in the src dir. Currently I get:
➜ make vm-build-netbsd V=1
tests/vm/netbsd --debug --source-path . --image "/home/alex/.cache/qemu-vm/images/netbsd.img" --force --build-image /home/alex/.cache/qemu-vm/images/netbsd.img
Traceback (most recent call last):
File "/home/alex/lsrc/qemu.git/tests/vm/netbsd", line 19, in <module>
import basevm
File "/home/alex/lsrc/qemu.git/tests/vm/basevm.py", line 32, in <module>
from qemu.machine import QEMUMachine
ModuleNotFoundError: No module named 'qemu'
make: *** [tests/vm/Makefile.include:86: /home/alex/.cache/qemu-vm/images/netbsd.img] Error 1
Quoted 18 lines
tests/vm/Makefile.include +2
-3.PHONY: vm-build-all vm-clean-all EFI_AARCH64 = $(wildcard $(BUILD_DIR)/pc-bios/edk2-aarch64-code.fd)@@ -90,11 +81,10 @@ vm-clean-all: $(IMAGES_DIR)/%.img: $(SRC_PATH)/tests/vm/% \ $(SRC_PATH)/tests/vm/basevm.py \ - $(SRC_PATH)/tests/vm/Makefile.include \ - $(VM_VENV) + $(SRC_PATH)/tests/vm/Makefile.include @mkdir -p $(IMAGES_DIR) $(call quiet-command, \ - $(VM_PYTHON) $< \ + $(PYTHON) $< \ $(if $(V)$(DEBUG), --debug) \ $(if $(GENISOIMAGE),--genisoimage $(GENISOIMAGE)) \ $(if $(QEMU_LOCAL),--build-path $(BUILD_DIR)) \
tests/vm/Makefile.include $(IMAGES_DIR)/%.img: $(SRC_PATH)/tests/vm/% \ · line 95
Quoted 5 lines
tests/vm/Makefile.include +1
-1@@ -102,14 +92,14 @@ $(IMAGES_DIR)/%.img: $(SRC_PATH)/tests/vm/% \ $(if $(LOG_CONSOLE),--log-console) \ --source-path $(SRC_PATH) \ --image "$@" \ - $(if $(filter-out check-venv, $?), --force) \ + --force \
I think this is fine, as danp says if the deps are touched we should re-build the VM.
Quoted 24 lines
tests/vm/Makefile.include +4
-4--build-image $@, \ " VM-IMAGE $*") # Build in VM $(IMAGE) -vm-build-%: $(IMAGES_DIR)/%.img $(VM_VENV) +vm-build-%: $(IMAGES_DIR)/%.img $(call quiet-command, \ - $(VM_PYTHON) $(SRC_PATH)/tests/vm/$* \ + $(PYTHON) $(SRC_PATH)/tests/vm/$* \ $(if $(V)$(DEBUG), --debug) \ $(if $(DEBUG), --interactive) \ $(if $(J),--jobs $(J)) \@@ -133,9 +123,9 @@ vm-boot-serial-%: $(IMAGES_DIR)/%.img -device virtio-net-pci,netdev=vnet \ || true -vm-boot-ssh-%: $(IMAGES_DIR)/%.img $(VM_VENV) +vm-boot-ssh-%: $(IMAGES_DIR)/%.img $(call quiet-command, \ - $(VM_PYTHON) $(SRC_PATH)/tests/vm/$* \ + $(PYTHON) $(SRC_PATH)/tests/vm/$* \ $(if $(J),--jobs $(J)) \ $(if $(V)$(DEBUG), --debug) \ $(if $(QEMU_LOCAL),--build-path $(BUILD_DIR)) \
Signature · 2 lines
Alex Bennée Virtualisation Tech Lead @ Linaro
Re: [PATCH v5 13/16] tests: remove "make check-venv" target
Quoted 88 lines · Alex Bennée
Quoted 69 lines · John Snow
With the qemu.qmp and qemu.machine dependencies now installed by default at configure time and additional dependencies required by functional testing installed on demand, there is no longer any reason to have an explicit target.
FIXME: This forces image regeneration for vm tests whenever Make determines that the image needs to be rebuilt; which is a regression over the previous behavior.
Signed-off-by John Snow <[email protected]>--- tests/Makefile.include | 22 ++-------------------- tests/vm/Makefile.include | 24 +++++++----------------- 2 files changed, 9 insertions(+), 37 deletions(-)tests/Makefile.include +2
-20@@ -21,7 +21,6 @@ ifneq ($(filter $(all-check-targets), check-softfloat),) endif @echo @echo " $(MAKE) check-report.junit.xml Generates an aggregated XML test report" - @echo " $(MAKE) check-venv Creates a Python venv for tests" @echo " $(MAKE) check-clean Clean the tests and related data" @echo @echo "The following are useful for CI builds"@@ -92,33 +91,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) $< tooling 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-quicktests/vm/Makefile.include +0
-0@@ -1,14 +1,5 @@ # Makefile for VM teststests/vm/Makefile.include line 11
Quoted 10 lines
tests/vm/Makefile.include +0
-9-# Hack to allow running in an unconfigured build tree -ifeq ($(realpath $(SRC_PATH)),$(realpath .)) -VM_PYTHON = PYTHONPATH=$(SRC_PATH)/python /usr/bin/env python3 -VM_VENV = -else -VM_PYTHON = $(PYTHON) -VM_VENV = check-venv -endif -It's a shame to loose this because the build directory should have no influence on what we build in the VM. Surely if we have qmp installed on the system (and therefor its deps) we should still want the ability to build in the src dir. Currently I get:
Quoted 9 lines
➜ make vm-build-netbsd V=1
tests/vm/netbsd --debug --source-path . --image "/home/alex/.cache/qemu-vm/images/netbsd.img" --force --build-image/home/alex/.cache/qemu-vm/images/netbsd.img
Traceback (most recent call last):
File "/home/alex/lsrc/qemu.git/tests/vm/netbsd", line 19, in <module>
import basevm
File "/home/alex/lsrc/qemu.git/tests/vm/basevm.py", line 32, in <module>
from qemu.machine import QEMUMachine
ModuleNotFoundError: No module named 'qemu'
make: *** [tests/vm/Makefile.include:86:/home/alex/.cache/qemu-vm/images/netbsd.img] Error 1
Ah, I see.... it used to be possible to run the VM tests *without a build directory at all*.
So, this used to work because of this bit in tests/vm/Makefile.include:
# Hack to allow running in an unconfigured build tree ifeq ($(realpath $(SRC_PATH)),$(realpath .)) VM_PYTHON = PYTHONPATH=$(SRC_PATH)/python /usr/bin/env python3 VM_VENV =
elseVM_PYTHON = $(PYTHON)VM_VENV = check-venv
endif
What this did was effectively treat qemu.git/python/ as an installed package directory and picked the most likely culprit for your actual python interpreter location. (Note that the configure script is a bit more thorough in picking a python interpreter to use that is bypassed here.) It's possible we can continue to do this, however, it will begin requiring that you just-so-happen to have qemu.qmp available in your python environment. The list of dependencies you might need for this to work successfully may increase as the years go by, so this is a little bit "porcelain". I'm not sure I like this, just because I don't wanna be on the hook for mysterious failures down the line.
Otherwise, to get all of the dependencies and python configuration managed for you, you have to do this:
mkdir build && pushd build && ../configure && make vm-test-netbsd
... But you don't actually have to build, and in fact you don't even really need to actually run configure either, so, hm.... yeah, how about this, using a new "vm-venv" folder in the source tree as the virtual environment location, using a dependency hook like check-venv but now localized specifically for VM tests benefit and only when it is run from the source tree:
jsnow@jsnow-thinkpadp16vgen1 ~/s/qemu (python_drop_qmp_pyvenv)> make vm-build-netbsd/usr/bin/env python3 ./python/scripts/mkvenv.py create vm-venv
mkvenv: Creating non-isolated virtual environment at 'vm-venv' /home/jsnow/src/qemu/vm-venv/bin/python3 ./vm-venv/bin/python3 ./python/scripts/mkvenv.py ensuregroup --online ./pythondeps.toml tooling functests
mkvenv: checking for qemu.qmp>=0.0.5
mkvenv: checking for pip>=21.3.1
mkvenv: checking for setuptools>=53.0.0
mkvenv: checking for wheel>=0.36.2
mkvenv: checking for pygdbmi>=0.11.0.0
mkvenv: installing qemu.qmp==0.0.5
mkvenv: installing /home/jsnow/src/qemu/python
VM-IMAGE netbsd
### Preparing iso and disk image ...
Formatting '/home/jsnow/.cache/qemu-vm/images/netbsd.img.tmp', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=21474836480 lazy_refcounts=off refcount_bits=16
This will take care of dependencies and everything for you and won't interfere with normal configured builds at all. Only downside is a new temporary folder that clutters up the source root that you'll have to delete now and then. Otherwise it uses the same dependency resolution as a normal full-blooded configure. Only difference is that it uses a simpler heuristic for which python to use (/usr/bin/env python3).
Sound good?
--js
Quoted 57 lines
Quoted 19 lines
tests/vm/Makefile.include +2
-3.PHONY: vm-build-all vm-clean-all EFI_AARCH64 = $(wildcard $(BUILD_DIR)/pc-bios/edk2-aarch64-code.fd)@@ -90,11 +81,10 @@ vm-clean-all: $(IMAGES_DIR)/%.img: $(SRC_PATH)/tests/vm/% \ $(SRC_PATH)/tests/vm/basevm.py \ - $(SRC_PATH)/tests/vm/Makefile.include \ - $(VM_VENV) + $(SRC_PATH)/tests/vm/Makefile.include @mkdir -p $(IMAGES_DIR) $(call quiet-command, \ - $(VM_PYTHON) $< \ + $(PYTHON) $< \ $(if $(V)$(DEBUG), --debug) \ $(if $(GENISOIMAGE),--genisoimage $(GENISOIMAGE)) \ $(if $(QEMU_LOCAL),--build-path $(BUILD_DIR)) \tests/vm/Makefile.include $(IMAGES_DIR)/%.img: $(SRC_PATH)/tests/vm/% \ · line 95
Quoted 5 lines
tests/vm/Makefile.include +1
-1@@ -102,14 +92,14 @@ $(IMAGES_DIR)/%.img: $(SRC_PATH)/tests/vm/% \ $(if $(LOG_CONSOLE),--log-console) \ --source-path $(SRC_PATH) \ --image "$@" \ - $(if $(filter-out check-venv, $?), --force) \ + --force \I think this is fine, as danp says if the deps are touched we should re-build the VM.
Quoted 14 lines
tests/vm/Makefile.include +2
-2--build-image $@, \ " VM-IMAGE $*") # Build in VM $(IMAGE) -vm-build-%: $(IMAGES_DIR)/%.img $(VM_VENV) +vm-build-%: $(IMAGES_DIR)/%.img $(call quiet-command, \ - $(VM_PYTHON) $(SRC_PATH)/tests/vm/$* \ + $(PYTHON) $(SRC_PATH)/tests/vm/$* \ $(if $(V)$(DEBUG), --debug) \ $(if $(DEBUG), --interactive) \ $(if $(J),--jobs $(J)) \@@ -133,9 +123,9 @@ vm-boot-serial-%: $(IMAGES_DIR)/%.img -device virtio-net-pci,netdev=vnet \tests/vm/Makefile.include vm-boot-serial-%: $(IMAGES_DIR)/%.img · line 131
Quoted 10 lines
tests/vm/Makefile.include +2
-2|| true -vm-boot-ssh-%: $(IMAGES_DIR)/%.img $(VM_VENV) +vm-boot-ssh-%: $(IMAGES_DIR)/%.img $(call quiet-command, \ - $(VM_PYTHON) $(SRC_PATH)/tests/vm/$* \ + $(PYTHON) $(SRC_PATH)/tests/vm/$* \ $(if $(J),--jobs $(J)) \ $(if $(V)$(DEBUG), --debug) \ $(if $(QEMU_LOCAL),--build-path $(BUILD_DIR)) \--
Alex Bennée
Virtualisation Tech Lead @ Linaro
Re: [PATCH v5 13/16] tests: remove "make check-venv" target
Quoted 156 lines · John Snow
Quoted 88 lines · Alex Bennée
Quoted 69 lines · John Snow
With the qemu.qmp and qemu.machine dependencies now installed by default at configure time and additional dependencies required by functional testing installed on demand, there is no longer any reason to have an explicit target.
FIXME: This forces image regeneration for vm tests whenever Make determines that the image needs to be rebuilt; which is a regression over the previous behavior.
Signed-off-by John Snow <[email protected]>--- tests/Makefile.include | 22 ++-------------------- tests/vm/Makefile.include | 24 +++++++----------------- 2 files changed, 9 insertions(+), 37 deletions(-)tests/Makefile.include +2
-20@@ -21,7 +21,6 @@ ifneq ($(filter $(all-check-targets), check-softfloat),) endif @echo @echo " $(MAKE) check-report.junit.xml Generates an aggregated XML test report" - @echo " $(MAKE) check-venv Creates a Python venv for tests" @echo " $(MAKE) check-clean Clean the tests and related data" @echo @echo "The following are useful for CI builds"@@ -92,33 +91,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) $< tooling 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-quicktests/vm/Makefile.include +0
-0@@ -1,14 +1,5 @@ # Makefile for VM teststests/vm/Makefile.include line 11
Quoted 10 lines
tests/vm/Makefile.include +0
-9-# Hack to allow running in an unconfigured build tree -ifeq ($(realpath $(SRC_PATH)),$(realpath .)) -VM_PYTHON = PYTHONPATH=$(SRC_PATH)/python /usr/bin/env python3 -VM_VENV = -else -VM_PYTHON = $(PYTHON) -VM_VENV = check-venv -endif -It's a shame to loose this because the build directory should have no influence on what we build in the VM. Surely if we have qmp installed on the system (and therefor its deps) we should still want the ability to build in the src dir. Currently I get:
Quoted 9 lines
➜ make vm-build-netbsd V=1
tests/vm/netbsd --debug --source-path . --image "/home/alex/.cache/qemu-vm/images/netbsd.img" --force --build-image/home/alex/.cache/qemu-vm/images/netbsd.img
Traceback (most recent call last):
File "/home/alex/lsrc/qemu.git/tests/vm/netbsd", line 19, in <module>
import basevm
File "/home/alex/lsrc/qemu.git/tests/vm/basevm.py", line 32, in <module>
from qemu.machine import QEMUMachine
ModuleNotFoundError: No module named 'qemu'
make: *** [tests/vm/Makefile.include:86:/home/alex/.cache/qemu-vm/images/netbsd.img] Error 1Ah, I see.... it used to be possible to run the VM tests *without a build directory at all*.
So, this used to work because of this bit in tests/vm/Makefile.include:
# Hack to allow running in an unconfigured build tree ifeq ($(realpath $(SRC_PATH)),$(realpath .))
VM_PYTHON= PYTHONPATH=$(SRC_PATH)/python/usr/bin/envpython3VM_VENV=
elseVM_PYTHON= $(PYTHON)VM_VENV= check-venv
endifWhat this did was effectively treat qemu.git/python/ as an installed package directory and picked the most likely culprit for your actual python interpreter location. (Note that the configure script is a bit more thorough in picking a python interpreter to use that is bypassed here.) It's possible we can continue to do this, however, it will begin requiring that you just-so-happen to have qemu.qmp available in your python environment. The list of dependencies you might need for this to work successfully may increase as the years go by, so this is a little bit "porcelain". I'm not sure I like this, just because I don't wanna be on the hook for mysterious failures down the line.
Otherwise, to get all of the dependencies and python configuration managed for you, you have to do this:
mkdir build && pushd build && ../configure && make vm-test-netbsd
... But you don't actually have to build, and in fact you don't even really need to actually run configure either, so, hm.... yeah, how about this, using a new "vm-venv" folder in the source tree as the virtual environment location, using a dependency hook like check-venv but now localized specifically for VM tests benefit and only when it is run from the source tree:
jsnow@jsnow-thinkpadp16vgen1 ~/s/qemu (
python_drop_qmp_pyvenv)> make vm-build-netbsd/usr/bin/envpython3./python/scripts/mkvenv.pycreate vm-venv
mkvenv: Creating non-isolated virtual environment at 'vm-venv'/home/jsnow/src/qemu/vm-venv/bin/python3./vm-venv/bin/python3./python/scripts/mkvenv.pyensuregroup --online ./pythondeps.toml tooling functests
mkvenv: checking for qemu.qmp>=0.0.5
mkvenv: checking for pip>=21.3.1
mkvenv: checking for setuptools>=53.0.0
mkvenv: checking for wheel>=0.36.2
mkvenv: checking for pygdbmi>=0.11.0.0
mkvenv: installing qemu.qmp==0.0.5
mkvenv: installing/home/jsnow/src/qemu/python
VM-IMAGE netbsd
### Preparing iso and disk image ...
Formatting '/home/jsnow/.cache/qemu-vm/images/netbsd.img.tmp', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=21474836480 lazy_refcounts=off refcount_bits=16
Quoted 4 lines
This will take care of dependencies and everything for you and won't interfere with normal configured builds at all. Only downside is a new temporary folder that clutters up the source root that you'll have to delete now and then.
Can we just add it to .gitignore or do we want it to be visible so users don't forget?
Quoted 5 lines
Otherwise it uses the same dependency resolution
as a normal full-blooded configure. Only difference is that it uses a simpler heuristic for which python to use (/usr/bin/envpython3).Sound good?
Yes that sounds good.
Quoted 59 lines
--js
Quoted 57 lines
Quoted 19 lines
tests/vm/Makefile.include +2
-3.PHONY: vm-build-all vm-clean-all EFI_AARCH64 = $(wildcard $(BUILD_DIR)/pc-bios/edk2-aarch64-code.fd)@@ -90,11 +81,10 @@ vm-clean-all: $(IMAGES_DIR)/%.img: $(SRC_PATH)/tests/vm/% \ $(SRC_PATH)/tests/vm/basevm.py \ - $(SRC_PATH)/tests/vm/Makefile.include \ - $(VM_VENV) + $(SRC_PATH)/tests/vm/Makefile.include @mkdir -p $(IMAGES_DIR) $(call quiet-command, \ - $(VM_PYTHON) $< \ + $(PYTHON) $< \ $(if $(V)$(DEBUG), --debug) \ $(if $(GENISOIMAGE),--genisoimage $(GENISOIMAGE)) \ $(if $(QEMU_LOCAL),--build-path $(BUILD_DIR)) \tests/vm/Makefile.include $(IMAGES_DIR)/%.img: $(SRC_PATH)/tests/vm/% \ · line 95
Quoted 5 lines
tests/vm/Makefile.include +1
-1@@ -102,14 +92,14 @@ $(IMAGES_DIR)/%.img: $(SRC_PATH)/tests/vm/% \ $(if $(LOG_CONSOLE),--log-console) \ --source-path $(SRC_PATH) \ --image "$@" \ - $(if $(filter-out check-venv, $?), --force) \ + --force \I think this is fine, as danp says if the deps are touched we should re-build the VM.
Quoted 14 lines
tests/vm/Makefile.include +2
-2--build-image $@, \ " VM-IMAGE $*") # Build in VM $(IMAGE) -vm-build-%: $(IMAGES_DIR)/%.img $(VM_VENV) +vm-build-%: $(IMAGES_DIR)/%.img $(call quiet-command, \ - $(VM_PYTHON) $(SRC_PATH)/tests/vm/$* \ + $(PYTHON) $(SRC_PATH)/tests/vm/$* \ $(if $(V)$(DEBUG), --debug) \ $(if $(DEBUG), --interactive) \ $(if $(J),--jobs $(J)) \@@ -133,9 +123,9 @@ vm-boot-serial-%: $(IMAGES_DIR)/%.img -device virtio-net-pci,netdev=vnet \tests/vm/Makefile.include vm-boot-serial-%: $(IMAGES_DIR)/%.img · line 131
Quoted 10 lines
tests/vm/Makefile.include +2
-2|| true -vm-boot-ssh-%: $(IMAGES_DIR)/%.img $(VM_VENV) +vm-boot-ssh-%: $(IMAGES_DIR)/%.img $(call quiet-command, \ - $(VM_PYTHON) $(SRC_PATH)/tests/vm/$* \ + $(PYTHON) $(SRC_PATH)/tests/vm/$* \ $(if $(J),--jobs $(J)) \ $(if $(V)$(DEBUG), --debug) \ $(if $(QEMU_LOCAL),--build-path $(BUILD_DIR)) \--
Alex Bennée
Virtualisation Tech Lead @ Linaro
Signature · 2 lines
Alex Bennée Virtualisation Tech Lead @ Linaro
Re: [PATCH v5 13/16] tests: remove "make check-venv" target
In reply to John SnowQuoted 127 lines · John Snow
Quoted 88 lines · Alex Bennée
Quoted 69 lines · John Snow
With the qemu.qmp and qemu.machine dependencies now installed by default at configure time and additional dependencies required by functional testing installed on demand, there is no longer any reason to have an explicit target.
FIXME: This forces image regeneration for vm tests whenever Make determines that the image needs to be rebuilt; which is a regression over the previous behavior.
Signed-off-by John Snow <[email protected]>--- tests/Makefile.include | 22 ++-------------------- tests/vm/Makefile.include | 24 +++++++----------------- 2 files changed, 9 insertions(+), 37 deletions(-)tests/Makefile.include +2
-20@@ -21,7 +21,6 @@ ifneq ($(filter $(all-check-targets), check-softfloat),) endif @echo @echo " $(MAKE) check-report.junit.xml Generates an aggregated XML test report" - @echo " $(MAKE) check-venv Creates a Python venv for tests" @echo " $(MAKE) check-clean Clean the tests and related data" @echo @echo "The following are useful for CI builds"@@ -92,33 +91,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) $< tooling 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-quicktests/vm/Makefile.include +0
-0@@ -1,14 +1,5 @@ # Makefile for VM teststests/vm/Makefile.include line 11
Quoted 10 lines
tests/vm/Makefile.include +0
-9-# Hack to allow running in an unconfigured build tree -ifeq ($(realpath $(SRC_PATH)),$(realpath .)) -VM_PYTHON = PYTHONPATH=$(SRC_PATH)/python /usr/bin/env python3 -VM_VENV = -else -VM_PYTHON = $(PYTHON) -VM_VENV = check-venv -endif -It's a shame to loose this because the build directory should have no influence on what we build in the VM. Surely if we have qmp installed on the system (and therefor its deps) we should still want the ability to build in the src dir. Currently I get:
Quoted 9 lines
➜ make vm-build-netbsd V=1
tests/vm/netbsd --debug --source-path . --image "/home/alex/.cache/qemu-vm/images/netbsd.img" --force --build-image/home/alex/.cache/qemu-vm/images/netbsd.img
Traceback (most recent call last):
File "/home/alex/lsrc/qemu.git/tests/vm/netbsd", line 19, in <module>
import basevm
File "/home/alex/lsrc/qemu.git/tests/vm/basevm.py", line 32, in <module>
from qemu.machine import QEMUMachine
ModuleNotFoundError: No module named 'qemu'
make: *** [tests/vm/Makefile.include:86:/home/alex/.cache/qemu-vm/images/netbsd.img] Error 1Ah, I see.... it used to be possible to run the VM tests *without a build directory at all*.
So, this used to work because of this bit in tests/vm/Makefile.include:
# Hack to allow running in an unconfigured build tree ifeq ($(realpath $(SRC_PATH)),$(realpath .))
VM_PYTHON= PYTHONPATH=$(SRC_PATH)/python/usr/bin/envpython3VM_VENV=
elseVM_PYTHON= $(PYTHON)VM_VENV= check-venv
endifWhat this did was effectively treat qemu.git/python/ as an installed package directory and picked the most likely culprit for your actual python interpreter location. (Note that the configure script is a bit more thorough in picking a python interpreter to use that is bypassed here.) It's possible we can continue to do this, however, it will begin requiring that you just-so-happen to have qemu.qmp available in your python environment. The list of dependencies you might need for this to work successfully may increase as the years go by, so this is a little bit "porcelain". I'm not sure I like this, just because I don't wanna be on the hook for mysterious failures down the line.
Otherwise, to get all of the dependencies and python configuration managed for you, you have to do this:
Quoted 8 lines
mkdir build && pushd build && ../configure && make vm-test-netbsd
... But you don't actually have to build, and in fact you don't even really need to actually run configure either, so, hm.... yeah, how about this, using a new "vm-venv" folder in the source tree as the virtual environment location, using a dependency hook like check-venv but now localized specifically for VM tests benefit and only when it is run from the source tree:
IMHO just keep life simple and expect configure to be run so we have the regular venv setup.
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 :|
Re: [PATCH v5 13/16] tests: remove "make check-venv" target
Quoted 138 lines · Daniel P. Berrangé
Quoted 127 lines · John Snow
Quoted 88 lines · Alex Bennée
Quoted 69 lines · John Snow
With the qemu.qmp and qemu.machine dependencies now installed by default at configure time and additional dependencies required by functional testing installed on demand, there is no longer any reason to have an explicit target.
FIXME: This forces image regeneration for vm tests whenever Make determines that the image needs to be rebuilt; which is a regression over the previous behavior.
Signed-off-by John Snow <[email protected]>--- tests/Makefile.include | 22 ++-------------------- tests/vm/Makefile.include | 24 +++++++----------------- 2 files changed, 9 insertions(+), 37 deletions(-)tests/Makefile.include +2
-20@@ -21,7 +21,6 @@ ifneq ($(filter $(all-check-targets), check-softfloat),) endif @echo @echo " $(MAKE) check-report.junit.xml Generates an aggregated XML test report" - @echo " $(MAKE) check-venv Creates a Python venv for tests" @echo " $(MAKE) check-clean Clean the tests and related data" @echo @echo "The following are useful for CI builds"@@ -92,33 +91,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) $< tooling 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-quicktests/vm/Makefile.include +0
-0@@ -1,14 +1,5 @@ # Makefile for VM teststests/vm/Makefile.include line 11
Quoted 10 lines
tests/vm/Makefile.include +0
-9-# Hack to allow running in an unconfigured build tree -ifeq ($(realpath $(SRC_PATH)),$(realpath .)) -VM_PYTHON = PYTHONPATH=$(SRC_PATH)/python /usr/bin/env python3 -VM_VENV = -else -VM_PYTHON = $(PYTHON) -VM_VENV = check-venv -endif -It's a shame to loose this because the build directory should have no influence on what we build in the VM. Surely if we have qmp installed on the system (and therefor its deps) we should still want the ability to build in the src dir. Currently I get:
Quoted 9 lines
➜ make vm-build-netbsd V=1
tests/vm/netbsd --debug --source-path . --image "/home/alex/.cache/qemu-vm/images/netbsd.img" --force --build-image/home/alex/.cache/qemu-vm/images/netbsd.img
Traceback (most recent call last):
File "/home/alex/lsrc/qemu.git/tests/vm/netbsd", line 19, in <module>
import basevm
File "/home/alex/lsrc/qemu.git/tests/vm/basevm.py", line 32, in <module>
from qemu.machine import QEMUMachine
ModuleNotFoundError: No module named 'qemu'
make: *** [tests/vm/Makefile.include:86:/home/alex/.cache/qemu-vm/images/netbsd.img] Error 1Ah, I see.... it used to be possible to run the VM tests *without a build directory at all*.
So, this used to work because of this bit in tests/vm/Makefile.include:
# Hack to allow running in an unconfigured build tree ifeq ($(realpath $(SRC_PATH)),$(realpath .))
VM_PYTHON= PYTHONPATH=$(SRC_PATH)/python/usr/bin/envpython3VM_VENV=
elseVM_PYTHON= $(PYTHON)VM_VENV= check-venv
endifWhat this did was effectively treat qemu.git/python/ as an installed package directory and picked the most likely culprit for your actual python interpreter location. (Note that the configure script is a bit more thorough in picking a python interpreter to use that is bypassed here.) It's possible we can continue to do this, however, it will begin requiring that you just-so-happen to have qemu.qmp available in your python environment. The list of dependencies you might need for this to work successfully may increase as the years go by, so this is a little bit "porcelain". I'm not sure I like this, just because I don't wanna be on the hook for mysterious failures down the line.
Otherwise, to get all of the dependencies and python configuration managed for you, you have to do this:
Quoted 8 lines
mkdir build && pushd build && ../configure && make vm-test-netbsd
... But you don't actually have to build, and in fact you don't even really need to actually run configure either, so, hm.... yeah, how about this, using a new "vm-venv" folder in the source tree as the virtual environment location, using a dependency hook like check-venv but now localized specifically for VM tests benefit and only when it is run from the source tree:
Quoted 3 lines
IMHO just keep life simple and expect configure to be run so we have the regular venv setup.
I'm sending a version that reflects Alex's desires, but it'd be nice if the two of you could reach a consensus. The "no-configure" venv is perhaps a little hacky, but it does otherwise use the same exact pathways as the normal configure venv uses, so I am OK with it as a convenience - and it is easy to remove in the future if it becomes a hassle.
PATCH v5 14/16 scripts: nudge users to use 'run' script for scripts that import qemu.qmp
In reply to John SnowNow that qmp has to be installed and isn't local, we can no longer offer a simple forwarder for these scripts (nor path hacks) and hope that it works. Encourage users to use the 'run' script to use these scripts instead.
--- scripts/compare-machine-types.py | 7 ++----- scripts/qmp/qemu-ga-client | 13 ++++++------- scripts/qmp/qmp-shell | 13 ++++++------- scripts/qmp/qmp-shell-wrap | 13 ++++++------- scripts/qmp/qom-fuse | 13 ++++++------- scripts/qmp/qom-get | 13 ++++++------- scripts/qmp/qom-list | 13 ++++++------- scripts/qmp/qom-set | 13 ++++++------- scripts/qmp/qom-tree | 13 ++++++------- scripts/qmp_helper.py | 9 ++------- scripts/render_block_graph.py | 10 +++++++--- scripts/simplebench/bench_block_job.py | 10 +++++++--- tests/migration-stress/guestperf/engine.py | 15 ++++++++++++--- 13 files changed, 78 insertions(+), 77 deletions(-)
scripts/compare-machine-types.py +2 -5
@@ -27,19 +27,16 @@ # along with this program; if not, see <http://www.gnu.org/licenses/>. import sys -from os import path from argparse import ArgumentParser, RawTextHelpFormatter, Namespace import pandas as pd from contextlib import ExitStack from typing import Optional, List, Dict, Generator, Tuple, Union, Any, Set try: - qemu_dir = path.abspath(path.dirname(path.dirname(__file__))) - sys.path.append(path.join(qemu_dir, 'python')) from qemu.machine import QEMUMachine except ModuleNotFoundError as exc: - print(f"Module '{exc.name}' not found.") - print("Try export PYTHONPATH=top-qemu-dir/python or run from top-qemu-dir") + print(f"Module '{exc.name}' not found.", file=sys.stderr) + print(f"Try $builddir/run {' '.join(sys.argv)}", file=sys.stderr) sys.exit(1)
scripts/qmp/qemu-ga-client +6 -7
@@ -1,11 +1,10 @@ #!/usr/bin/env python3 -import os import sys -sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) -from qemu.utils import qemu_ga_client - - -if __name__ == '__main__': - sys.exit(qemu_ga_client.main()) +print( + "This script has moved; after running configure," + " please use '$builddir/run qemu-ga-client [...]' instead.", + file=sys.stderr +) +sys.exit(1)
scripts/qmp/qmp-shell +6 -7
@@ -1,11 +1,10 @@ #!/usr/bin/env python3 -import os import sys -sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) -from qemu.qmp import qmp_shell - - -if __name__ == '__main__': - qmp_shell.main() +print( + "This script has moved; after running configure," + " please use '$builddir/run qmp-shell [...]' instead.", + file=sys.stderr +) +sys.exit(1)
scripts/qmp/qmp-shell-wrap +6 -7
@@ -1,11 +1,10 @@ #!/usr/bin/env python3 -import os import sys -sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) -from qemu.qmp import qmp_shell - - -if __name__ == '__main__': - qmp_shell.main_wrap() +print( + "This script has moved; after running configure," + " please use '$builddir/run qmp-shell-wrap [...]' instead.", + file=sys.stderr +) +sys.exit(1)
scripts/qmp/qom-fuse +6 -7
@@ -1,11 +1,10 @@ #!/usr/bin/env python3 -import os import sys -sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) -from qemu.utils.qom_fuse import QOMFuse - - -if __name__ == '__main__': - sys.exit(QOMFuse.entry_point()) +print( + "This script has moved; after running configure," + " please use '$builddir/run qom-fuse [...]' instead.", + file=sys.stderr +) +sys.exit(1)
scripts/qmp/qom-get +6 -7
@@ -1,11 +1,10 @@ #!/usr/bin/env python3 -import os import sys -sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) -from qemu.utils.qom import QOMGet - - -if __name__ == '__main__': - sys.exit(QOMGet.entry_point()) +print( + "This script has moved; after running configure," + " please use '$builddir/run qom-get [...]' instead.", + file=sys.stderr +) +sys.exit(1)
scripts/qmp/qom-list +6 -7
@@ -1,11 +1,10 @@ #!/usr/bin/env python3 -import os import sys -sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) -from qemu.utils.qom import QOMList - - -if __name__ == '__main__': - sys.exit(QOMList.entry_point()) +print( + "This script has moved; after running configure," + " please use '$builddir/run qom-list [...]' instead.", + file=sys.stderr +) +sys.exit(1)
scripts/qmp/qom-set +6 -7
@@ -1,11 +1,10 @@ #!/usr/bin/env python3 -import os import sys -sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) -from qemu.utils.qom import QOMSet - - -if __name__ == '__main__': - sys.exit(QOMSet.entry_point()) +print( + "This script has moved; after running configure," + " please use '$builddir/run qom-set [...]' instead.", + file=sys.stderr +) +sys.exit(1)
scripts/qmp/qom-tree +6 -7
@@ -1,11 +1,10 @@ #!/usr/bin/env python3 -import os import sys -sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) -from qemu.utils.qom import QOMTree - - -if __name__ == '__main__': - sys.exit(QOMTree.entry_point()) +print( + "This script has moved; after running configure," + " please use '$builddir/run qom-tree [...]' instead.", + file=sys.stderr +) +sys.exit(1)
scripts/qmp_helper.py +2 -7
@@ -13,17 +13,12 @@ import sys from datetime import datetime -from os import path as os_path try: - qemu_dir = os_path.abspath(os_path.dirname(os_path.dirname(__file__))) - sys.path.append(os_path.join(qemu_dir, 'python')) - from qemu.qmp.legacy import QEMUMonitorProtocol - except ModuleNotFoundError as exc: - print(f"Module '{exc.name}' not found.") - print("Try export PYTHONPATH=top-qemu-dir/python or run from top-qemu-dir") + print(f"Module '{exc.name}' not found.", file=sys.stderr) + print(f"Try $builddir/run {' '.join(sys.argv)}", file=sys.stderr) sys.exit(1) from base64 import b64encode
scripts/render_block_graph.py +7 -3
@@ -24,9 +24,13 @@ import json from graphviz import Digraph -sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'python')) -from qemu.qmp import QMPError -from qemu.qmp.legacy import QEMUMonitorProtocol +try: + from qemu.qmp import QMPError + from qemu.qmp.legacy import QEMUMonitorProtocol +except ModuleNotFoundError as exc: + print(f"Module '{exc.name}' not found.", file=sys.stderr) + print(f"Try $builddir/run {' '.join(sys.argv)}", file=sys.stderr) + sys.exit(1) def perm(arr):
scripts/simplebench/bench_block_job.py +7 -3
@@ -25,9 +25,13 @@ import socket import json -sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', 'python')) -from qemu.machine import QEMUMachine -from qemu.qmp import ConnectError +try: + from qemu.machine import QEMUMachine + from qemu.qmp import ConnectError +except ModuleNotFoundError as exc: + print(f"Module '{exc.name}' not found.", file=sys.stderr) + print(f"Try $builddir/run {' '.join(sys.argv)}", file=sys.stderr) + sys.exit(1) def bench_block_job(cmd, cmd_args, qemu_args):
tests/migration-stress/guestperf/engine.py +12 -3
@@ -27,9 +27,18 @@ from guestperf.report import Report, ReportResult from guestperf.timings import TimingRecord, Timings -sys.path.append(os.path.join(os.path.dirname(__file__), - '..', '..', '..', 'python')) -from qemu.machine import QEMUMachine +try: + from qemu.machine import QEMUMachine +except ModuleNotFoundError as exc: + print( + f"Module '{exc.name}' not found.\n" + "It should be installed as part of the configure-time " + "virtual environment in $builddir/pyvenv.\n" + "Try re-running this script as:\n" + f"> $builddir/run {' '.join(sys.argv)}", + file=sys.stderr + ) + sys.exit(1) # multifd supported compression algorithms MULTIFD_CMP_ALGS = ("zlib", "zstd", "qpl", "uadk")
Signature · 1 line
2.52.0
PATCH v5 15/16 python: delete qemu.qmp
In reply to John SnowStart 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
@@ -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
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/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.52.0
Part of the diff is not shown here. View the raw message.
PATCH v5 16/16 python: update README.rst to reflect qemu.qmp's removal
In reply to John SnowIt 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.
--- python/README.rst | 50 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 7 deletions(-)
python/README.rst +43 -7
@@ -3,7 +3,17 @@ QEMU Python Tooling This directory houses Python tooling used by the QEMU project to build, configure, and test QEMU. It is organized by namespace (``qemu``), and -then by package (e.g. ``qemu/machine``, ``qemu/qmp``, etc). +then by package (e.g. ``qemu/machine``, ``qemu/utils``, etc). + +These tools and libraries are installed to the QEMU configure-time +Python virtual environment by default (see qemu.git/pythondeps.toml +"tooling" group), and are available for use by any Python script +executed by the build system. To have these libraries available for +manual invocations of scripts, use of the "run" script in your build +directory is recommended. + +General structure +----------------- ``setup.py`` is used by ``pip`` to install this tooling to the current environment. ``setup.cfg`` provides the packaging configuration used by
@@ -20,9 +30,9 @@ environment. ``setup.cfg`` provides the packaging configuration used by If you append the ``--editable`` or ``-e`` argument to either invocation above, pip will install in "editable" mode. This installs the package as -a forwarder ("qemu.egg-link") that points to the source tree. In so -doing, the installed package always reflects the latest version in your -source tree. +a forwarder that points to the source tree. In so doing, the installed +package always reflects the latest version in your source tree. This is +the mode used to install these packages at configure time. Installing ".[devel]" instead of "." will additionally pull in required packages for testing this package. They are not runtime requirements,
@@ -40,8 +50,18 @@ for more information. Using these packages without installing them -------------------------------------------- -These packages may be used without installing them first, by using one -of two tricks: +It is no longer recommended to try to use these packages without +installing them to a virtual environment, but depending on your use +case, it may still be possible to do. + +The "qemu.qmp" library is now hosted outside of the qemu.git repository, +and the "qemu.machine" library that remains in-tree here has qemu.qmp as +a dependency. It is possible to install "qemu.qmp" independently and +then use the rest of these packages without installing them, but be +advised that if future dependencies are introduced, bypassing the +installation phase may introduce breakages to your script in the future. + +That said, you can use these packages without installing them by either: 1. Set your PYTHONPATH environment variable to include this source directory, e.g. ``~/src/qemu/python``. See
@@ -61,8 +81,24 @@ invoke them without installation, you can invoke e.g.: ``> PYTHONPATH=~/src/qemu/python python3 -m qemu.qmp.qmp_shell`` +Or, with the run script available in the QEMU build directory, simply: + +``> $builddir/run qmp-shell`` + The mappings between console script name and python module path can be -found in ``setup.cfg``. +found in ``setup.cfg``, but the console scripts available are listed +here for reference: + +* ``qemu-ga-client`` +* ``qmp-shell`` +* ``qmp-shell-wrap`` +* ``qmp-tui`` (prototype urwid interface for async QMP) +* ``qom`` +* ``qom-fuse`` (requires fusepy to be installed!) +* ``qom-get`` +* ``qom-list`` +* ``qom-set`` +* ``qom-tree`` Files in this directory
Signature · 1 line
2.52.0
Re: [PATCH v5 16/16] python: update README.rst to reflect qemu.qmp's removal
Quoted 8 lines · John Snow
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.
Signed-off-by John Snow <[email protected]>--- python/README.rst | 50 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 7 deletions(-)
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 :|
Re: [PATCH v5 16/16] python: update README.rst to reflect qemu.qmp's removal
In reply to John SnowQuoted 8 lines · John Snow
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.
Signed-off-by John Snow <[email protected]>--- python/README.rst | 50 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 43 insertions(+), 7 deletions(-)