Virtio device with features#3445
Open
asherkariv wants to merge 7 commits intomicrosoft:mainfrom
Open
Conversation
The missing reply may have caused the crash in the guest, during unmount of a virtiofs mount, since the guest is waiting indefinitely for the fuse_destroy request reply, such as demonstrated by the captured stack below. Process: 1583 (parent: 1569) cmd: stat: 1583 (weston) Z 1569 1 1 58624 1 4228364 5042 0 0 0 12 2 0 0 20 0 2 0 16448 0 0 18446744073709551615 0 0 0 0 0 0 84480 0 2 0 0 0 17 6 0 0 0 0 0 0 0 0 0 0 0 0 9 tid: 1583 - weston tid: 1585 - weston [<0>] request_wait_answer+0x138/0x220 [<0>] fuse_simple_request+0x189/0x2d0 [<0>] fuse_send_destroy+0x66/0x70 [<0>] fuse_conn_destroy+0xae/0xc0 [<0>] virtio_kill_sb+0xc2/0x180 [<0>] deactivate_locked_super+0x39/0xb0 [<0>] deactivate_super+0x44/0x50 [<0>] cleanup_mnt+0xc3/0x160 [<0>] __cleanup_mnt+0x16/0x20 [<0>] task_work_run+0x65/0xa0 [<0>] do_exit+0x37a/0xb30 [<0>] do_group_exit+0x39/0x90 [<0>] get_signal+0xa9a/0xaa0
Update the backend fuse protocol to version 7.39, and use FUSE_DIRECT_IO_ALLOW_MMAP to enable memory backed files with VirtioFS. Related work items: https://microsoft.visualstudio.com/OS/_workitems/edit/61002501
Add the ability to customize VirtIO device features based on host configuration. For example, this is required for environments utilizing SWIOTLB, where the device must advertise VIRTIO_F_ACCESS_PLATFORM to ensure proper memory access through the IOMMU/bounce buffers.
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds support for specifying transport-level VirtIO feature bits at device creation time, enabling host-driven configuration like advertising VIRTIO_F_ACCESS_PLATFORM (e.g., for SWIOTLB/IOMMU environments).
Changes:
- Introduces
new_with_transport_featuresconstructors for MMIO and PCI transports, while keepingnew()as a default (VIRTIO_F_VERSION_1) wrapper. - Extends
VirtioTransportCorecreation to merge caller-supplied transport features with device-specific features. - Adds MMIO-focused tests to validate
VIRTIO_F_ACCESS_PLATFORMpropagation (and absence by default).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| vm/devices/virtio/virtio/src/transport/pci.rs | Adds PCI constructor that accepts transport feature bits and wires them into the core. |
| vm/devices/virtio/virtio/src/transport/mmio.rs | Adds MMIO constructor that accepts transport feature bits and wires them into the core. |
| vm/devices/virtio/virtio/src/transport/core.rs | Implements merging of transport features into device-advertised feature bits. |
| vm/devices/virtio/virtio/src/tests.rs | Adds tests validating VIRTIO_F_ACCESS_PLATFORM behavior for MMIO. |
Comments suppressed due to low confidence (1)
vm/devices/virtio/virtio/src/transport/core.rs:1
- The new
new_with_transport_featurespath no longer guaranteesVIRTIO_F_VERSION_1is set (previously it was forced viawith_version_1(true)), so a caller passing an “empty”transport_featurescan accidentally create a device that doesn’t advertise VERSION_1. If the implementation requires modern VirtIO, consider enforcingVERSION_1inside the core (e.g., always OR it in regardless of caller input), or validating and returning an error when VERSION_1 is absent. This avoids a footgun and keepsnew_with_transport_featuressafe-by-default.
// Copyright (c) Microsoft Corporation.
|
This PR modifies files containing For more on why we check whole files, instead of just diffs, check out the Rustonomicon |
feature VIRTIO_F_VERSION_1, and fix tests.
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: allow specifying device features at creation.
Add the ability to customize VirtIO device features based on host configuration.
For example, this is required for environments utilizing SWIOTLB, where the device
must advertise VIRTIO_F_ACCESS_PLATFORM to ensure proper memory access through
the IOMMU/bounce buffers.