mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-03-20 07:58:55 +00:00
vm-virtio: Add IOMMU support to virtio-pmem
Adding virtio feature VIRTIO_F_IOMMU_PLATFORM when explicitly asked by the user. The need for this feature is to be able to attach the virtio device to a virtual IOMMU. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
392f1ec155
commit
ee1899c6f6
@ -21,7 +21,7 @@ use std::thread;
|
||||
use super::Error as DeviceError;
|
||||
use super::{
|
||||
ActivateError, ActivateResult, DescriptorChain, DeviceEventT, Queue, VirtioDevice,
|
||||
VirtioDeviceType, VIRTIO_F_VERSION_1,
|
||||
VirtioDeviceType, VIRTIO_F_IOMMU_PLATFORM, VIRTIO_F_VERSION_1,
|
||||
};
|
||||
use crate::{VirtioInterrupt, VirtioInterruptType};
|
||||
use vm_memory::{
|
||||
@ -296,16 +296,22 @@ pub struct Pmem {
|
||||
}
|
||||
|
||||
impl Pmem {
|
||||
pub fn new(disk: File, addr: GuestAddress, size: GuestUsize) -> io::Result<Pmem> {
|
||||
pub fn new(disk: File, addr: GuestAddress, size: GuestUsize, iommu: bool) -> io::Result<Pmem> {
|
||||
let config = VirtioPmemConfig {
|
||||
start: addr.raw_value().to_le(),
|
||||
size: size.to_le(),
|
||||
};
|
||||
|
||||
let mut avail_features = 1u64 << VIRTIO_F_VERSION_1;
|
||||
|
||||
if iommu {
|
||||
avail_features |= 1u64 << VIRTIO_F_IOMMU_PLATFORM;
|
||||
}
|
||||
|
||||
Ok(Pmem {
|
||||
kill_evt: None,
|
||||
disk: Some(disk),
|
||||
avail_features: 1u64 << VIRTIO_F_VERSION_1,
|
||||
avail_features,
|
||||
acked_features: 0u64,
|
||||
config,
|
||||
queue_evts: None,
|
||||
|
@ -789,7 +789,7 @@ impl DeviceManager {
|
||||
*mem_slots += 1;
|
||||
|
||||
let virtio_pmem_device =
|
||||
vm_virtio::Pmem::new(file, pmem_guest_addr, size as GuestUsize)
|
||||
vm_virtio::Pmem::new(file, pmem_guest_addr, size as GuestUsize, false)
|
||||
.map_err(DeviceManagerError::CreateVirtioPmem)?;
|
||||
|
||||
devices.push(Box::new(virtio_pmem_device) as Box<dyn vm_virtio::VirtioDevice>);
|
||||
|
Loading…
x
Reference in New Issue
Block a user