Skip to content

Conversation

@Bastian-Krause
Copy link
Member

Description
Until now the QEMU process and QMP monitor start was tied to the on()/off() methods. This feels unnatural, preventing the user from interacting with the QEMU process via monitor commands before the emulation starts and meant starting a new process on each power cycle.

Rework the driver to start QEMU and the QMP monitor in on_activate(), allowing interaction via monitor_command() after activation. The on() and off() methods interact only via QMP now.

All methods relying on a started QEMU and QMP monitor instance are decorated with @Driver.check_active now.

The atexit handling is no longer required since the target's atexit handler already calls the driver's on_deactivate().

While at it, restructure the QEMU mock fixtures in the QEMUDriver tests.

Checklist

  • PR has been tested

Alternative to one aspect of #1753

Bastian-Krause and others added 3 commits November 14, 2025 17:27
Since `qemu_version_mock` is required for all tests using `qemu_mock`,
move its functionality into `qemu_mock`.

Since `qemu_driver` will fixture will soon need `qemu_mock` always, add
it as its dependency now, thus minimizing the direct fixtures required
by the tests.

Signed-off-by: Bastian Krause <bst@pengutronix.de>
…e()/on_deactivate()

Until now the QEMU process and QMP monitor start was tied to the
on()/off() methods. This feels unnatural, preventing the user from
interacting with the QEMU process via monitor commands before the
emulation starts and meant starting a new process on each power cycle.

Rework the driver to start QEMU and the QMP monitor in on_activate(),
allowing interaction via monitor_command after activation. The on() and
off() methods interact only via QMP now.

All methods relying on a started QEMU and QMP monitor instance are
decorated with @Driver.check_active now.

The atexit handling is no longer required since the target's atexit
handler already calls the driver's on_deactivate().

Signed-off-by: Joschka Seydell <joschka@seydell.org>
Signed-off-by: Bastian Krause <bst@pengutronix.de>
Now that the QEMU invocation is not only prepared, but also started in
on_activate(), there is no need to keep the command around. Turn it into
a local variable instead.

Signed-off-by: Bastian Krause <bst@pengutronix.de>
@codecov
Copy link

codecov bot commented Nov 14, 2025

Codecov Report

❌ Patch coverage is 79.06977% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 45.2%. Comparing base (f63dfd7) to head (227eb60).
⚠️ Report is 7 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
labgrid/driver/qemudriver.py 79.0% 9 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           master   #1771     +/-   ##
========================================
- Coverage    45.3%   45.2%   -0.1%     
========================================
  Files         172     172             
  Lines       13517   13556     +39     
========================================
+ Hits         6130    6140     +10     
- Misses       7387    7416     +29     
Flag Coverage Δ
3.10 45.2% <79.0%> (-0.1%) ⬇️
3.11 45.2% <79.0%> (-0.1%) ⬇️
3.12 45.2% <79.0%> (-0.1%) ⬇️
3.13 45.2% <79.0%> (-0.1%) ⬇️
3.14 ?
3.9 45.3% <79.0%> (-0.1%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@JSydll
Copy link

JSydll commented Nov 14, 2025

Thanks for addressing this, @Bastian-Krause ! Seems indeed more adherent to the common design/usage patterns. I'll give it a closer look as soon as time permits.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants