mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
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 <rbradford@meta.com>
This commit is contained in:
@@ -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<Arc<dyn AccessPlatform>> {
|
||||
if self.feature_acked(VIRTIO_F_ACCESS_PLATFORM as u64) {
|
||||
self.access_platform.clone()
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Pausable for VirtioCommon {
|
||||
|
||||
Reference in New Issue
Block a user