Functional testing patches
Subsystems (2)
Hi Stefan!
The following changes since commit 7f2007d1924565c7a38b2c6ba01ebc1a85db0a49:
Merge tag 'pull-qobject-2026-07-02' of https://repo.or.cz/qemu/armbru into staging (2026-07-03 07:42:51 +0200)
are available in the Git repository at:
https://gitlab.com/huth/qemu.git tags/pull-request-2026-07-07
for you to fetch changes up to 0e7aa78b0bee50b076785d4cf4a1b7546b3bed31:
tests/functional: use QMP to query available machines (2026-07-05 21:29:32 +0200)
----------------------------------------------------------------
* Add test for hotplugging a virtio-scsi disk
* Improve boot completion detection in aspeed tests
* Use QMP to query available machines in functional tests
----------------------------------------------------------------
Cédric Le Goater (1):
tests/functional/aspeed: unify boot completion detection on 'login:' prompt
Ganesh Harshan (1):
tests/functional: use QMP to query available machines
Siddhi Katage (1):
tests/functional: Add hotplug_scsi test to hotplug virtio-scsi disk
MAINTAINERS | 1 + tests/functional/arm/test_aspeed_anacapa.py | 6 +- tests/functional/arm/test_aspeed_bletchley.py | 6 +- tests/functional/arm/test_aspeed_catalina.py | 6 +- tests/functional/arm/test_aspeed_gb200nvl_bmc.py | 3 +- tests/functional/aspeed.py | 21 ++---- tests/functional/qemu_test/testcase.py | 31 +++++++-- tests/functional/x86_64/meson.build | 1 + tests/functional/x86_64/test_hotplug_scsi.py | 86 ++++++++++++++++++++++++ 9 files changed, 127 insertions(+), 34 deletions(-) create mode 100755 tests/functional/x86_64/test_hotplug_scsi.py
[PULL 3/3] tests/functional: use QMP to query available machines
From: Ganesh Harshan <[email protected]>
Replace parsing of "qemu -M help" in set_machine() with QMP "query-machines".
The previous approach relied on parsing human-readable CLI output and substring matching, which is fragile and prone to incorrect matches. It is also sensitive to output format changes.
Use QMP instead to retrieve structured machine information, ensuring accurate matching and better maintainability.
Cache the result at the class level to avoid repeated QEMU startup overhead.
Message-ID: <[email protected]>
--- tests/functional/qemu_test/testcase.py | 31 +++++++++++++++++++++----- 1 file changed, 25 insertions(+), 6 deletions(-)
tests/functional/qemu_test/testcase.py +25 -6
@@ -314,13 +314,32 @@ def setUp(self): console_log.addHandler(self._console_log_fh) def set_machine(self, machinename): - # TODO: We should use QMP to get the list of available machines - if not self._machinehelp: - self._machinehelp = run( - [self.qemu_bin, '-M', 'help'], - capture_output=True, check=True, encoding='utf8').stdout - if self._machinehelp.find(machinename) < 0: + cls = type(self) + + if not hasattr(cls, "_machines"): + tmp_vm = QEMUMachine(self.qemu_bin) + tmp_vm.set_machine('none') + + try: + tmp_vm.launch() + resp = tmp_vm.qmp('query-machines') + + machines = resp.get('return', []) + cls._machines = [ + m.get('name') for m in machines if 'name' in m + ] + + finally: + try: + tmp_vm.shutdown() + except Exception: + pass + + self._machines = cls._machines + + if machinename not in self._machines: self.skipTest('no support for machine ' + machinename) + self.machine = machinename def require_accelerator(self, accelerator):
Signature · 1 line
2.54.0
Re: [PULL 3/3] tests/functional: use QMP to query available machines
Quoted 41 lines · Thomas Huth
From: Ganesh Harshan <[email protected]>
Replace parsing of "qemu -M help" in
set_machine()with QMP "query-machines".The previous approach relied on parsing human-readable CLI output and substring matching, which is fragile and prone to incorrect matches. It is also sensitive to output format changes.
Use QMP instead to retrieve structured machine information, ensuring accurate matching and better maintainability.
Cache the result at the class level to avoid repeated QEMU startup overhead.
Signed-off-by Ganesh Harshan <[email protected]>Reviewed-by Daniel P. Berrangé <[email protected]>Message-ID: <[email protected]>
[thuth: Drop problematic self.vm.set_machine() statement]Signed-off-by Thomas Huth <[email protected]>--- tests/functional/qemu_test/testcase.py | 31 +++++++++++++++++++++----- 1 file changed, 25 insertions(+), 6 deletions(-)tests/functional/qemu_test/testcase.py +3
-6@@ -314,13 +314,32 @@ def setUp(self): console_log.addHandler(self._console_log_fh) def set_machine(self, machinename): - # TODO: We should use QMP to get the list of available machines - if not self._machinehelp: - self._machinehelp = run( - [self.qemu_bin, '-M', 'help'], - capture_output=True, check=True, encoding='utf8').stdout - if self._machinehelp.find(machinename) < 0: + cls = type(self) + + if not hasattr(cls, "_machines"):
tests/functional/qemu_test/testcase.py def setUp(self): · line 329
Quoted 10 lines
tests/functional/qemu_test/testcase.py +10
-0+ tmp_vm = QEMUMachine(self.qemu_bin) + tmp_vm.set_machine('none') + + try: + tmp_vm.launch() + resp = tmp_vm.qmp('query-machines') + + machines = resp.get('return', []) + cls._machines = [ + m.get('name') for m in machines if 'name' in m
This doesn't cover aliases, now tests using "q35" are skipped. I'm sending a patch..
Quoted 16 lines
tests/functional/qemu_test/testcase.py +12
-0+ ] + + finally: + try: + tmp_vm.shutdown() + except Exception: + pass + + self._machines = cls._machines + + if machinename not in self._machines: self.skipTest('no support for machine ' + machinename) + self.machine = machinename def require_accelerator(self, accelerator):
Signature · 2 lines
Best regards, Vladimir
[PULL 1/3] tests/functional: Add hotplug_scsi test to hotplug virtio-scsi disk
In reply to Thomas HuthFrom: Siddhi Katage <[email protected]>
Message-ID: <[email protected]>
--- MAINTAINERS | 1 + tests/functional/x86_64/meson.build | 1 + tests/functional/x86_64/test_hotplug_scsi.py | 86 ++++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100755 tests/functional/x86_64/test_hotplug_scsi.py
MAINTAINERS +1 -0
@@ -2338,6 +2338,7 @@ F: tests/qtest/virtio-scsi-test.c F: tests/qtest/fuzz-virtio-scsi-test.c F: tests/qtest/am53c974-test.c F: tests/qtest/fuzz-lsi53c895a-test.c +F: tests/functional/x86_64/test_hotplug_scsi.py T: git https://github.com/bonzini/qemu.git scsi-next SSI
tests/functional/x86_64/meson.build +1 -0
@@ -31,6 +31,7 @@ endif tests_x86_64_system_thorough = [ 'acpi_bits', 'hotplug_blk', + 'hotplug_scsi', 'hotplug_cpu', 'intel_iommu', 'kvm_xen',
tests/functional/x86_64/test_hotplug_scsi.py new file +86 -0
86 lines not on this page · raw message
Signature · 1 line
2.54.0
[PULL 2/3] tests/functional/aspeed: unify boot completion detection on 'login:' prompt
In reply to Thomas HuthFrom: Cédric Le Goater <[email protected]>
The boot completion check in AspeedTest waits for the systemd "Hostname set to" message, which occasionally causes intermittent test timeouts, e.g. on ast2500 SoC machines. The root cause seems to be console output interleaving of both systemd and the getty login process. This results in the expected pattern string being broken up.
Unify and simplify all boot completion checks by looking for the generic 'login:' substring in AspeedTest.wait_for_boot_complete(). With the override gone, remove the redundant FacebookAspeedTest class and update the Anacapa, Bletchley, and Catalina tests to inherit directly from AspeedTest. Also drop the now-dead image_hostname parameter from do_test_arm_aspeed_openbmc().
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3117
Message-ID: <[email protected]>
--- tests/functional/arm/test_aspeed_anacapa.py | 6 +++--- tests/functional/arm/test_aspeed_bletchley.py | 6 +++--- tests/functional/arm/test_aspeed_catalina.py | 6 +++--- .../arm/test_aspeed_gb200nvl_bmc.py | 3 +-- tests/functional/aspeed.py | 21 ++++--------------- 5 files changed, 14 insertions(+), 28 deletions(-)
tests/functional/arm/test_aspeed_anacapa.py +3 -3
@@ -5,10 +5,10 @@ # SPDX-License-Identifier: GPL-2.0-or-later from qemu_test import Asset -from aspeed import FacebookAspeedTest +from aspeed import AspeedTest -class AnacapaMachine(FacebookAspeedTest): +class AnacapaMachine(AspeedTest): ASSET_ANACAPA_FLASH = Asset( 'https://github.com/legoater/qemu-aspeed-boot/raw/3fa3212827b04be4034d43b5adeef57c27d6ab18/images/anacapa-bmc/openbmc-20260512025228/obmc-phosphor-image-anacapa-20260512025228.static.mtd.xz',
@@ -22,4 +22,4 @@ def test_arm_ast2600_anacapa_openbmc(self): soc='AST2600 rev A3') if __name__ == '__main__': - FacebookAspeedTest.main() + AspeedTest.main()
tests/functional/arm/test_aspeed_bletchley.py +3 -3
@@ -5,10 +5,10 @@ # SPDX-License-Identifier: GPL-2.0-or-later from qemu_test import Asset -from aspeed import FacebookAspeedTest +from aspeed import AspeedTest -class BletchleyMachine(FacebookAspeedTest): +class BletchleyMachine(AspeedTest): ASSET_BLETCHLEY_FLASH = Asset( 'https://github.com/legoater/qemu-aspeed-boot/raw/master/images/bletchley-bmc/openbmc-20250128071329/obmc-phosphor-image-bletchley-20250128071329.static.mtd.xz',
@@ -22,4 +22,4 @@ def test_arm_ast2600_bletchley_openbmc(self): soc='AST2600 rev A3') if __name__ == '__main__': - FacebookAspeedTest.main() + AspeedTest.main()
tests/functional/arm/test_aspeed_catalina.py +3 -3
@@ -5,10 +5,10 @@ # SPDX-License-Identifier: GPL-2.0-or-later from qemu_test import Asset -from aspeed import FacebookAspeedTest +from aspeed import AspeedTest -class CatalinaMachine(FacebookAspeedTest): +class CatalinaMachine(AspeedTest): ASSET_CATALINA_FLASH = Asset( 'https://github.com/legoater/qemu-aspeed-boot/raw/a866feb5ef81245b4827a214584bf6bcc72939f6/images/catalina-bmc/obmc-phosphor-image-catalina-20250619123021.static.mtd.xz',
@@ -22,4 +22,4 @@ def test_arm_ast2600_catalina_openbmc(self): soc='AST2600 rev A3') if __name__ == '__main__': - FacebookAspeedTest.main() + AspeedTest.main()
tests/functional/arm/test_aspeed_gb200nvl_bmc.py +1 -2
@@ -19,8 +19,7 @@ def test_arm_aspeed_gb200_openbmc(self): self.do_test_arm_aspeed_openbmc('gb200nvl-bmc', image=image_path, uboot='2019.04', cpu_id='0xf00', - soc='AST2600 rev A3', - image_hostname='gb200nvl-obmc') + soc='AST2600 rev A3') if __name__ == '__main__': AspeedTest.main()
tests/functional/aspeed.py +4 -17
@@ -8,14 +8,7 @@ class AspeedTest(LinuxKernelTest): def do_test_arm_aspeed_openbmc(self, machine, image, uboot='2019.04', - cpu_id='0x0', soc='AST2500 rev A1', - image_hostname=None): - # Allow for the image hostname to not end in "-bmc" - if image_hostname is not None: - hostname = image_hostname - else: - hostname = machine.removesuffix('-bmc') - + cpu_id='0x0', soc='AST2500 rev A1'): self.set_machine(machine) self.vm.set_console() self.vm.add_args('-drive', f'file={image},if=mtd,format=raw',
@@ -28,10 +21,10 @@ def do_test_arm_aspeed_openbmc(self, machine, image, uboot='2019.04', self.wait_for_console_pattern(f'Booting Linux on physical CPU {cpu_id}') self.wait_for_console_pattern(f'ASPEED {soc}') self.wait_for_console_pattern('/init as init process') - self.wait_for_boot_complete(hostname) + self.wait_for_boot_complete() - def wait_for_boot_complete(self, hostname): - self.wait_for_console_pattern(f'systemd[1]: Hostname set to <{hostname}>.') + def wait_for_boot_complete(self): + self.wait_for_console_pattern('login:') def do_test_arm_aspeed_buildroot_start(self, image, cpu_id, pattern='Aspeed EVB'): self.require_netdev('user')
@@ -71,9 +64,3 @@ def generate_otpmem_image(self): with open(path, "wb") as f: f.write(pattern) return path - - -class FacebookAspeedTest(AspeedTest): - - def wait_for_boot_complete(self, hostname): - self.wait_for_console_pattern(f'{hostname} login:')
Signature · 1 line
2.54.0
Stefan Hajnoczi
AppliedApplied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/11.1 for any user-visible changes.