Skip to content

virttest: fix qemu version parsing#4350

Open
bssrikanth wants to merge 1 commit intoavocado-framework:masterfrom
bssrikanth:fix_qemu_parsing
Open

virttest: fix qemu version parsing#4350
bssrikanth wants to merge 1 commit intoavocado-framework:masterfrom
bssrikanth:fix_qemu_parsing

Conversation

@bssrikanth
Copy link
Copy Markdown

Current QEMU_VERSION_RE required parenthetical,
but on custom qemu builds prints only “QEMU emulator version X.Y.Z” on the first line so requirement_checks could not read the version and canceled tests.

This commit fixes it and also adds unittest for the same

@bssrikanth
Copy link
Copy Markdown
Author

I had custom qemu built when queried on version it returned:

#qemu-system-x86_64 --version
QEMU emulator version 10.1.3
Copyright (c) 2003-2025 Fabrice Bellard and the QEMU Project developers

In above case current parsing fails:

[stdlog] 2026-03-25 04:51:40,083 virttest.test_setup.requirement_checks requirement_chec L0057 DEBUG| KVM version: 6.19.4
[stdlog] 2026-03-25 04:51:40,103 virttest.test_setup.requirement_checks requirement_chec L0118 DEBUG| KVM userspace version(qemu): Unknown
[stdlog] 2026-03-25 04:51:40,103 virttest.test_setup.requirement_checks requirement_chec L0124 INFO | Test requires qemu version: [2.12, )
..
[stdlog] 2026-03-25 04:51:40,108 avocado.test stacktrace       L0049 ERROR|   File "/usr/local/lib/python3.12/dist-packages/avocado/core/test.py", line 832, in cancel
[stdlog] 2026-03-25 04:51:40,108 avocado.test stacktrace       L0049 ERROR|     raise exceptions.TestCancel(msg)
[stdlog] 2026-03-25 04:51:40,108 avocado.test stacktrace       L0049 ERROR| avocado.core.exceptions.TestCancel: Can not get host qemu version.

After fix:

..
[stdlog] 2026-03-25 06:02:30,663 virttest.test_setup.requirement_checks requirement_chec L0118 DEBUG| KVM userspace version(qemu): 10.1.3
..

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the QEMU version parsing logic to make the parenthetical build/distro suffix optional, improving compatibility with various version string formats. Changes include regex updates in env_process.py and utils_qemu.py, logic adjustments in requirement_checks.py, and a new unit test. Feedback suggests consolidating the QEMU_VERSION_RE definitions into a single location to reduce code duplication and improve maintainability.

Comment thread virttest/env_process.py Outdated
QEMU -version output without a parenthetical build/distro suffix (e.g. some
upstream builds) did not match the old QEMU_VERSION_RE, so
requirement_checks failed to read the version and canceled tests.

This commit fixes it and also adds unittest for the same

Signed-off-by: Srikanth Aithal <srikanth.aithal@amd.com>
@bssrikanth
Copy link
Copy Markdown
Author

@smitterl @richtja @nickzhq @YongxueHong @zhencliu @cliping @nanli1 @Yingshun @dzhengfy @chloerh @PaulYuuu requesting maintainers review on this pull request.
Thank you for your time in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant