feat(qemu): make Qemu class extensible and QemuProcess injectable#122
Open
Rahul-Sutariya wants to merge 1 commit into
Open
feat(qemu): make Qemu class extensible and QemuProcess injectable#122Rahul-Sutariya wants to merge 1 commit into
Rahul-Sutariya wants to merge 1 commit into
Conversation
Replace double-underscore name mangling with single-underscore
("protected") on all internal methods and attributes of the Qemu class,
enabling subclasses to override command assembly without duplicating the
entire launcher.
Add two overridable hooks:
- _extra_qemu_args(): inject additional -object/-device flags
- _serial_args(): customize serial output redirection
Add an optional `qemu` parameter to QemuProcess.__init__ for dependency
injection: when a pre-configured Qemu (or subclass) instance is passed,
it is used directly instead of constructing a default one. This allows
downstream plugins (e.g. dual_qemu with ivshmem) to provide a custom
launcher without duplicating QemuProcess.
Both changes are fully backward-compatible:
- All public APIs (start/stop/__enter__/__exit__) are unchanged.
- QemuProcess constructor signature is additive (new kwarg with default None).
- No external code could reference the mangled __names, so __ -> _ is invisible.
dff9347 to
14ea215
Compare
Contributor
|
@Rahul-Sutariya What a coincidence. I am also working on extending the QEMU code: #123 |
lurtz
reviewed
Jul 15, 2026
lurtz
left a comment
Contributor
There was a problem hiding this comment.
Changes look ok to me, but I am not really a code owner of ITF, thus not approving.
We should have a discussion what features the QEMU plugin should have and how its extension points look like.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Make the
Qemuclass andQemuProcessextensible so downstream pluginscan add custom QEMU devices (e.g. ivshmem) via inheritance/DI instead of
copy command assembly.
Changes
qemu.py__method→_method(all internal methods and attributes)_extra_qemu_args()hook — called during command assembly,returns
[]by default; subclasses override to inject flags._serial_args()hook — returns["-serial", "mon:stdio"]bydefault; overridable for per-VM serial log files.
qemu_process.pyqemu=Nonekeyword argument to__init__.Qemuinstance is used directly (DI);otherwise a default
Qemu(...)is constructed as before.Impact on existing users
None. All changes are additive/internal:
have referenced the double-underscore mangled names.
Motivation
The
communicationrepo'sdual_qemuplugin needs to launch QEMU withan
ivshmem-plainshared-memory device. Without these hooks, it had toduplicate the entire
Qemuclass because inheritance wasblocked by name mangling and there was no extension point for extra args.
With this change, the ivshmem launcher becomes a thin subclass
overriding
_extra_qemu_args()and_serial_args().