Skip to content

Add support for virtio device reset#5891

Merged
ilstam merged 28 commits into
firecracker-microvm:mainfrom
ilstam:device-reset
Jul 3, 2026
Merged

Add support for virtio device reset#5891
ilstam merged 28 commits into
firecracker-microvm:mainfrom
ilstam:device-reset

Conversation

@ilstam

@ilstam ilstam commented May 15, 2026

Copy link
Copy Markdown
Contributor

Add support for virtio device reset

License Acceptance

By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license. For more information on following Developer
Certificate of Origin and signing off your commits, please check
CONTRIBUTING.md.

PR Checklist

  • I have read and understand CONTRIBUTING.md.
  • I have run tools/devtool checkbuild --all to verify that the PR passes
    build checks on all supported architectures.
  • I have run tools/devtool checkstyle to verify that the PR passes the
    automated style checks.
  • I have described what is done in these changes, why they are needed, and
    how they are solving the problem in a clear and encompassing way.
  • I have updated any relevant documentation (both in code and in the docs)
    in the PR.
  • I have mentioned all user-facing changes in CHANGELOG.md.
  • If a specific issue led to this PR, this PR closes the issue.
  • When making API changes, I have followed the
    Runbook for Firecracker API changes.
  • I have tested all new and changed functionalities in unit tests and/or
    integration tests.
  • I have linked an issue to every new TODO.

  • This functionality cannot be added in rust-vmm.

ilstam added a commit to ilstam/firecracker that referenced this pull request May 15, 2026
firecracker-microvm#5891

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
@ilstam ilstam requested review from Manciukic and micz010 as code owners May 15, 2026 16:40
@codecov

codecov Bot commented May 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 45.56962% with 129 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.88%. Comparing base (a0d635b) to head (fa12003).

Files with missing lines Patch % Lines
src/vmm/src/devices/virtio/vsock/unix/muxer.rs 26.31% 14 Missing ⚠️
src/vmm/src/devices/virtio/vsock/device.rs 7.14% 13 Missing ⚠️
src/vmm/src/devices/virtio/balloon/device.rs 0.00% 12 Missing ⚠️
src/vmm/src/devices/virtio/block/virtio/device.rs 0.00% 11 Missing ⚠️
src/vmm/src/devices/virtio/block/device.rs 0.00% 10 Missing ⚠️
...m/src/devices/virtio/block/virtio/event_handler.rs 0.00% 9 Missing ⚠️
src/vmm/src/devices/virtio/net/event_handler.rs 0.00% 9 Missing ⚠️
src/vmm/src/devices/virtio/vsock/packet.rs 0.00% 8 Missing ⚠️
.../vmm/src/devices/virtio/block/vhost_user/device.rs 0.00% 6 Missing ⚠️
src/vmm/src/devices/virtio/mem/device.rs 0.00% 6 Missing ⚠️
... and 8 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5891      +/-   ##
==========================================
- Coverage   83.12%   82.88%   -0.25%     
==========================================
  Files         277      277              
  Lines       30259    30441     +182     
==========================================
+ Hits        25154    25230      +76     
- Misses       5105     5211     +106     
Flag Coverage Δ
5.10-m5n.metal 83.16% <45.56%> (-0.28%) ⬇️
5.10-m6a.metal 82.50% <45.56%> (-0.29%) ⬇️
5.10-m6g.metal 79.89% <45.56%> (-0.22%) ⬇️
5.10-m6i.metal 83.16% <45.56%> (-0.28%) ⬇️
5.10-m7a.metal-48xl 82.49% <45.56%> (-0.29%) ⬇️
5.10-m7g.metal 79.90% <45.56%> (-0.22%) ⬇️
5.10-m7i.metal-24xl 83.12% <45.56%> (-0.28%) ⬇️
5.10-m7i.metal-48xl 83.12% <45.56%> (-0.28%) ⬇️
5.10-m8g.metal-24xl 79.89% <45.56%> (-0.22%) ⬇️
5.10-m8g.metal-48xl 79.90% <45.56%> (-0.21%) ⬇️
5.10-m8i.metal-48xl 83.12% <45.56%> (-0.28%) ⬇️
5.10-m8i.metal-96xl 83.13% <45.56%> (-0.28%) ⬇️
6.1-m5n.metal 83.18% <45.56%> (-0.28%) ⬇️
6.1-m6a.metal 82.53% <45.56%> (-0.28%) ⬇️
6.1-m6g.metal 79.90% <45.56%> (-0.22%) ⬇️
6.1-m6i.metal 83.18% <45.56%> (-0.28%) ⬇️
6.1-m7a.metal-48xl 82.51% <45.56%> (-0.29%) ⬇️
6.1-m7g.metal 79.89% <45.56%> (-0.22%) ⬇️
6.1-m7i.metal-24xl 83.19% <45.56%> (-0.27%) ⬇️
6.1-m7i.metal-48xl 83.19% <45.56%> (-0.28%) ⬇️
6.1-m8g.metal-24xl 79.89% <45.56%> (-0.22%) ⬇️
6.1-m8g.metal-48xl 79.90% <45.56%> (-0.21%) ⬇️
6.1-m8i.metal-48xl 83.19% <45.56%> (-0.28%) ⬇️
6.1-m8i.metal-96xl 83.20% <45.56%> (-0.28%) ⬇️
6.18-m5n.metal 83.17% <45.56%> (-0.28%) ⬇️
6.18-m6a.metal 82.53% <45.56%> (-0.29%) ⬇️
6.18-m6g.metal 79.90% <45.56%> (-0.22%) ⬇️
6.18-m6i.metal 83.18% <45.56%> (-0.27%) ⬇️
6.18-m7a.metal-48xl 82.51% <45.56%> (-0.29%) ⬇️
6.18-m7g.metal 79.90% <45.56%> (-0.21%) ⬇️
6.18-m7i.metal-24xl 83.19% <45.56%> (-0.28%) ⬇️
6.18-m7i.metal-48xl 83.20% <45.56%> (-0.27%) ⬇️
6.18-m8g.metal-24xl 79.89% <45.56%> (-0.22%) ⬇️
6.18-m8g.metal-48xl 79.89% <45.56%> (-0.22%) ⬇️
6.18-m8i.metal-48xl 83.19% <45.56%> (-0.28%) ⬇️
6.18-m8i.metal-96xl 83.19% <45.56%> (-0.28%) ⬇️

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

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/vmm/src/devices/virtio/transport/pci/device.rs Outdated
Comment thread src/vmm/src/devices/virtio/block/device.rs Outdated
Comment thread src/vmm/src/devices/virtio/vsock/device.rs
Comment thread tests/integration_tests/functional/test_vsock.py Outdated
Comment thread src/vmm/src/devices/virtio/mem/device.rs
Comment thread src/vmm/src/devices/virtio/device.rs Outdated
Comment thread src/vmm/src/devices/virtio/balloon/device.rs
Comment thread src/vmm/src/devices/virtio/block/virtio/device.rs
Comment thread tests/integration_tests/functional/test_balloon.py
Comment thread tests/integration_tests/functional/test_pmem.py Outdated
Comment thread src/vmm/src/devices/virtio/device.rs Outdated
Comment thread src/vmm/src/devices/virtio/block/device.rs Outdated
ilstam added a commit to ilstam/firecracker that referenced this pull request May 21, 2026
firecracker-microvm#5891

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
ilstam added a commit to ilstam/firecracker that referenced this pull request May 21, 2026
firecracker-microvm#5891

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
ilstam added a commit to ilstam/firecracker that referenced this pull request May 21, 2026
firecracker-microvm#5891

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
ilstam added a commit to ilstam/firecracker that referenced this pull request May 21, 2026
firecracker-microvm#5891

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
ilstam added a commit to ilstam/firecracker that referenced this pull request May 21, 2026
firecracker-microvm#5891

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
ilstam added a commit to ilstam/firecracker that referenced this pull request May 21, 2026
firecracker-microvm#5891

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
ilstam added a commit to ilstam/firecracker that referenced this pull request May 26, 2026
firecracker-microvm#5891

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
@ilstam ilstam added the Status: Awaiting review Indicates that a pull request is ready to be reviewed label May 26, 2026
Comment thread src/vmm/src/devices/virtio/block/virtio/device.rs
ilstam added a commit to ilstam/firecracker that referenced this pull request Jun 8, 2026
firecracker-microvm#5891

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
ilstam added a commit to ilstam/firecracker that referenced this pull request Jun 8, 2026
firecracker-microvm#5891

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
ilstam added a commit to ilstam/firecracker that referenced this pull request Jun 9, 2026
firecracker-microvm#5891

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
Comment thread src/vmm/src/devices/virtio/device.rs Outdated
Comment thread src/vmm/src/devices/virtio/block/vhost_user/device.rs
Comment thread src/vmm/src/devices/virtio/transport/mmio.rs
Comment thread src/vmm/src/devices/virtio/device.rs
ilstam added a commit to ilstam/firecracker that referenced this pull request Jun 10, 2026
firecracker-microvm#5891

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
ilstam added 2 commits July 3, 2026 13:10
Implement the _reset() method for the virtio-net device, resetting the
net specific state in-place.

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
Add a test that verifies virtio-net device reset works end-to-end by
unbinding and rebinding the guest driver and checking the device
remains functional and MMDS is still reachable.

Suggested-by: Adam Jensen <adam@acj.sh>
Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
ilstam added a commit to ilstam/firecracker that referenced this pull request Jul 3, 2026
firecracker-microvm#5891

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
Manciukic
Manciukic previously approved these changes Jul 3, 2026
Comment thread src/vmm/src/devices/virtio/block/virtio/io/mod.rs Outdated
ilstam added 14 commits July 3, 2026 15:07
Implement the _reset() method for the virtio-block device, resetting the
device-specific state in-place. For the async io_uring engine drain the
ring so that any in-flight operations complete. Adjust the seccomp
filter such that vCPU threads can call io_uring_enter.

This only adds support for the Virtio backend for now and not VhostUser.

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
Add a test that verifies virtio-block device reset works end-to-end by
unbinding and rebinding the guest driver for a scratch block device
and checking the device remains functional.

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
Pmem does not have any backend specific state that needs resetting so
implement the _reset() method by simply returning true. The rest of the
state is handled by the generic reset().

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
Add a test that verifies virtio-pmem device reset works end-to-end by
unbinding and rebinding the guest driver and checking the device
remains functional.

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
Implement the _reset() method for the virtio-balloon device, resetting
the balloon specific state in-place. Do not deflate the balloon on
reset.

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
Add a test that verifies virtio-balloon device reset works end-to-end
by unbinding and rebinding the guest driver and checking the device
remains functional.

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
The entropy device does not have any backend specific state that needs
resetting so implement the _reset() method by simply returning true.

The test_failed_reset_blocks_reinitialization() test used an entropy
device assuming it doesn't support reset. Since it now does, adjust the
test to check that the device is first deactivated after a reset and
then the driver can perform the initialization sequence again.

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
Add a test that verifies virtio-rng device reset works end-to-end by
unbinding and rebinding the guest driver and checking the device
remains functional.

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
Register the muxer's host socket epoll listener when the device is
activated rather than when the muxer is constructed, by adding an
activate() method to the VsockBackend trait and calling it from
Vsock::activate().

This ties the listener's lifetime to device activation instead of muxer
construction. This lays the groundwork for device reset, which needs the
listener set to be re-established on each activation.

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
Implement the _reset() method for the virtio-vsock device, resetting the
vsock specific state in-place. Add epoll_ctl to the vCPU seccomp filter,
since it's needed to remove the vsock muxer's connection and listener
epoll listeners when the device is reset.

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
Add a test that verifies virtio-vsock device reset works end-to-end by
unbinding and rebinding the guest driver and checking the device
remains functional.

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
The virtio-mem device does not have any backend specific state that
needs resetting so implement the _reset() method by simply returning
true. Plugged memory regions remain intact.

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
Add a test that verifies virtio-mem device reset works end-to-end by
unbinding and rebinding the guest driver and checking the device remains
functional.

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
firecracker-microvm#5891

Signed-off-by: Ilias Stamatis <ilstam@amazon.com>
@ilstam ilstam enabled auto-merge July 3, 2026 14:32
@ilstam ilstam added this pull request to the merge queue Jul 3, 2026
Merged via the queue into firecracker-microvm:main with commit 4027850 Jul 3, 2026
6 of 7 checks passed
@ilstam ilstam deleted the device-reset branch July 3, 2026 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Awaiting review Indicates that a pull request is ready to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants