labgrid icon indicating copy to clipboard operation
labgrid copied to clipboard

labgrid/qemudriver: tie QEMU and QMP monitor start/stop to on_activate()/on_deactivate()

Open Bastian-Krause opened this issue 2 months ago • 3 comments

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

  • [x] PR has been tested

Alternative to one aspect of #1753

Bastian-Krause avatar Nov 14 '25 17:11 Bastian-Krause

Codecov Report

:x: Patch coverage is 79.06977% with 9 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 45.2%. Comparing base (70f6150) to head (b9b4489). :white_check_mark: All tests successful. No failed tests found.

Files with missing lines Patch % Lines
labgrid/driver/qemudriver.py 79.0% 9 Missing :warning:
Additional details and impacted files
@@          Coverage Diff           @@
##           master   #1771   +/-   ##
======================================
  Coverage    45.2%   45.2%           
======================================
  Files         172     172           
  Lines       13569   13570    +1     
======================================
+ Hits         6136    6140    +4     
+ Misses       7433    7430    -3     
Flag Coverage Δ
3.10 45.2% <79.0%> (+<0.1%) :arrow_up:
3.11 45.2% <79.0%> (+<0.1%) :arrow_up:
3.12 45.2% <79.0%> (+<0.1%) :arrow_up:
3.13 45.2% <79.0%> (+<0.1%) :arrow_up:
3.14 45.2% <79.0%> (+<0.1%) :arrow_up:
3.9 45.2% <79.0%> (+<0.1%) :arrow_up:

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

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Nov 14 '25 17:11 codecov[bot]

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.

JSydll avatar Nov 14 '25 20:11 JSydll

Rebased on latest master.

Bastian-Krause avatar Nov 19 '25 09:11 Bastian-Krause