mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-22 11:22:26 +00:00
vm-virtio: iommu: Expect an identifier upon device creation
This identifier is chosen from the DeviceManager so that it will manage all identifiers across the VM, which will ensure uniqueness. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
052eff1ca7
commit
556871570e
@ -793,6 +793,7 @@ impl DmaRemapping for IommuMapping {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct Iommu {
|
pub struct Iommu {
|
||||||
|
id: String,
|
||||||
kill_evt: Option<EventFd>,
|
kill_evt: Option<EventFd>,
|
||||||
pause_evt: Option<EventFd>,
|
pause_evt: Option<EventFd>,
|
||||||
avail_features: u64,
|
avail_features: u64,
|
||||||
@ -808,7 +809,7 @@ pub struct Iommu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Iommu {
|
impl Iommu {
|
||||||
pub fn new() -> io::Result<(Self, Arc<IommuMapping>)> {
|
pub fn new(id: String) -> io::Result<(Self, Arc<IommuMapping>)> {
|
||||||
let config = VirtioIommuConfig {
|
let config = VirtioIommuConfig {
|
||||||
page_size_mask: VIRTIO_IOMMU_PAGE_SIZE_MASK,
|
page_size_mask: VIRTIO_IOMMU_PAGE_SIZE_MASK,
|
||||||
probe_size: PROBE_PROP_SIZE,
|
probe_size: PROBE_PROP_SIZE,
|
||||||
@ -822,6 +823,7 @@ impl Iommu {
|
|||||||
|
|
||||||
Ok((
|
Ok((
|
||||||
Iommu {
|
Iommu {
|
||||||
|
id,
|
||||||
kill_evt: None,
|
kill_evt: None,
|
||||||
pause_evt: None,
|
pause_evt: None,
|
||||||
avail_features: 1u64 << VIRTIO_F_VERSION_1
|
avail_features: 1u64 << VIRTIO_F_VERSION_1
|
||||||
@ -1039,6 +1041,10 @@ impl VirtioDevice for Iommu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtio_pausable!(Iommu);
|
virtio_pausable!(Iommu);
|
||||||
impl Snapshottable for Iommu {}
|
impl Snapshottable for Iommu {
|
||||||
|
fn id(&self) -> String {
|
||||||
|
self.id.clone()
|
||||||
|
}
|
||||||
|
}
|
||||||
impl Transportable for Iommu {}
|
impl Transportable for Iommu {}
|
||||||
impl Migratable for Iommu {}
|
impl Migratable for Iommu {}
|
||||||
|
@ -788,9 +788,11 @@ impl DeviceManager {
|
|||||||
Arc::clone(&self.address_manager) as Arc<dyn DeviceRelocation>,
|
Arc::clone(&self.address_manager) as Arc<dyn DeviceRelocation>,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let iommu_id = String::from(IOMMU_DEVICE_NAME);
|
||||||
|
|
||||||
let (iommu_device, iommu_mapping) = if self.config.lock().unwrap().iommu {
|
let (iommu_device, iommu_mapping) = if self.config.lock().unwrap().iommu {
|
||||||
let (device, mapping) =
|
let (device, mapping) = vm_virtio::Iommu::new(iommu_id.clone())
|
||||||
vm_virtio::Iommu::new().map_err(DeviceManagerError::CreateVirtioIommu)?;
|
.map_err(DeviceManagerError::CreateVirtioIommu)?;
|
||||||
let device = Arc::new(Mutex::new(device));
|
let device = Arc::new(Mutex::new(device));
|
||||||
self.iommu_device = Some(Arc::clone(&device));
|
self.iommu_device = Some(Arc::clone(&device));
|
||||||
(Some(device), Some(mapping))
|
(Some(device), Some(mapping))
|
||||||
@ -841,7 +843,7 @@ impl DeviceManager {
|
|||||||
&mut pci_bus,
|
&mut pci_bus,
|
||||||
&None,
|
&None,
|
||||||
&interrupt_manager,
|
&interrupt_manager,
|
||||||
Some(String::from(IOMMU_DEVICE_NAME)),
|
Some(iommu_id),
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user