From ea64d109c72da739590135042ab9b609c9b3814a Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Fri, 17 Apr 2026 08:51:28 +0100 Subject: [PATCH] virtio-devices: Add feature acked gated accessor for AccessPlatform Add VirtioCommon::access_platform() method. The virtio spec requires that only if the feature is acked should the accesses be transformed via the access platform implementation. This will enable that filtering. Signed-off-by: Rob Bradford --- virtio-devices/src/device.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/virtio-devices/src/device.rs b/virtio-devices/src/device.rs index 3e6b30e79..ca2e5834e 100644 --- a/virtio-devices/src/device.rs +++ b/virtio-devices/src/device.rs @@ -16,6 +16,7 @@ use std::thread; use anyhow::anyhow; use libc::EFD_NONBLOCK; use log::{error, info, warn}; +use virtio_bindings::virtio_config::VIRTIO_F_ACCESS_PLATFORM; use virtio_queue::Queue; use vm_device::UserspaceMapping; use vm_memory::{GuestAddress, GuestMemoryAtomic}; @@ -332,6 +333,15 @@ impl VirtioCommon { // requires the addresses held by the descriptors to be translated. self.avail_features &= !(1 << VIRTIO_F_RING_INDIRECT_DESC); } + + /// Returns the access platform only if the feature has been acked. + pub fn access_platform(&self) -> Option> { + if self.feature_acked(VIRTIO_F_ACCESS_PLATFORM as u64) { + self.access_platform.clone() + } else { + None + } + } } impl Pausable for VirtioCommon {