virtio: support dynamic device add#103
Open
Jaxtonmax wants to merge 7 commits into
Open
Conversation
added 7 commits
June 9, 2026 23:29
…clean # Conflicts: # tools/virtio/virtio.c
Author
|
@Inquisitor-201 @ForeverYolo Could you help review this PR when you have time? This PR mainly addresses #57 by adding dynamic Virtio device add support. Thanks! |
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.
virtio: support dynamic device add
Summary
Closes #57.
This PR adds a
virtio addflow so new Virtio device configurations can be sent to an already running hvisor-tool Virtio backend daemon.Main changes:
hvisor virtio add <virtio.json>CLI support./run/hvisor-virtio.sock.virtio addact as a client while the running daemon performs the actual state mutation.virtio startJSON parsing, memory mapping, validation, and device creation path for later add requests.vdevs[].README.mdandREADME-zh.md.New Workflow
The existing one-shot startup flow is still supported:
nohup ./hvisor virtio start virtio_cfg.json & ./hvisor zone start zone1_linux.jsonThe new flow can add another Virtio configuration to the running daemon:
nohup ./hvisor virtio start virtio_start_empty.json & ./hvisor virtio add virtio_add_console_blk.json ./hvisor zone start zone1_linux.jsonFor MMIO Virtio devices,
virtio addshould be run before starting the zone that will use the newly added devices, unless full guest runtime hotplug is separately verified.Implementation Notes
virtio addconnects to the daemon through/run/hvisor-virtio.sock.vdevs[],zone_mem[], event monitor state, and device-specific resources.VDEV_MUTEXprotects global device table publication and MMIO address publication.ZONE_MEM_MUTEXprotects zone memory mapping records.vdevs[]togetherValidation
Runtime validation performed on QEMU AArch64 with QEMU 9.0.1:
virtio addwithconsole + wrong blk:virtio add failed/dev/ptsvirtio addwithconsole + valid blk:virtio add succeededvirtio startstyle flow after updating the hvisor side.Static/local checks performed during the branch work:
Notes