diff --git a/vm-virtio/src/rng.rs b/vm-virtio/src/rng.rs index 5af6916ad..aa0d8ab10 100755 --- a/vm-virtio/src/rng.rs +++ b/vm-virtio/src/rng.rs @@ -15,7 +15,7 @@ use std::thread; use super::Error as DeviceError; use super::{ ActivateError, ActivateResult, DeviceEventT, Queue, VirtioDevice, VirtioDeviceType, - VIRTIO_F_VERSION_1, + VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_VERSION_1, }; use crate::{VirtioInterrupt, VirtioInterruptType}; use vm_memory::{Bytes, GuestMemoryMmap}; @@ -164,9 +164,13 @@ pub struct Rng { impl Rng { /// Create a new virtio rng device that gets random data from /dev/urandom. - pub fn new(path: &str) -> io::Result { + pub fn new(path: &str, iommu: bool) -> io::Result { let random_file = File::open(path)?; - let avail_features = 1u64 << VIRTIO_F_VERSION_1; + let mut avail_features = 1u64 << VIRTIO_F_VERSION_1; + + if iommu { + avail_features |= 1u64 << VIRTIO_F_IOMMU_PLATFORM; + } Ok(Rng { kill_evt: None, diff --git a/vmm/src/device_manager.rs b/vmm/src/device_manager.rs index 5120cfdbc..9855fb846 100644 --- a/vmm/src/device_manager.rs +++ b/vmm/src/device_manager.rs @@ -634,8 +634,8 @@ impl DeviceManager { // Add virtio-rng if required if let Some(rng_path) = vm_info.vm_cfg.rng.src.to_str() { - let virtio_rng_device = - vm_virtio::Rng::new(rng_path).map_err(DeviceManagerError::CreateVirtioRng)?; + let virtio_rng_device = vm_virtio::Rng::new(rng_path, false) + .map_err(DeviceManagerError::CreateVirtioRng)?; devices.push(Box::new(virtio_rng_device) as Box); }