vmm: device_manager: use generic names for passthrough device

Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
Wei Liu 2020-07-17 15:20:47 +00:00 committed by Samuel Ortiz
parent ff8d7bfe83
commit 821892419c

View File

@ -235,8 +235,8 @@ pub enum DeviceManagerError {
#[cfg(feature = "pci_support")] #[cfg(feature = "pci_support")]
VfioMapRegion(pci::VfioPciError), VfioMapRegion(pci::VfioPciError),
/// Failed to create the KVM device. /// Failed to create the passthrough device.
CreateKvmDevice(anyhow::Error), CreatePassthroughDevice(anyhow::Error),
/// Failed to memory map. /// Failed to memory map.
Mmap(io::Error), Mmap(io::Error),
@ -740,9 +740,9 @@ pub struct DeviceManager {
// MSI Interrupt Manager // MSI Interrupt Manager
msi_interrupt_manager: Arc<dyn InterruptManager<GroupConfig = MsiIrqGroupConfig>>, msi_interrupt_manager: Arc<dyn InterruptManager<GroupConfig = MsiIrqGroupConfig>>,
// VFIO KVM device // Passthrough device handle
#[cfg(feature = "pci_support")] #[cfg(feature = "pci_support")]
kvm_device_fd: Option<Arc<DeviceFd>>, passthrough_device: Option<Arc<DeviceFd>>,
// Paravirtualized IOMMU // Paravirtualized IOMMU
#[cfg(feature = "pci_support")] #[cfg(feature = "pci_support")]
@ -831,7 +831,7 @@ impl DeviceManager {
pci_bus: None, pci_bus: None,
msi_interrupt_manager, msi_interrupt_manager,
#[cfg(feature = "pci_support")] #[cfg(feature = "pci_support")]
kvm_device_fd: None, passthrough_device: None,
#[cfg(feature = "pci_support")] #[cfg(feature = "pci_support")]
iommu_device: None, iommu_device: None,
#[cfg(feature = "pci_support")] #[cfg(feature = "pci_support")]
@ -2492,14 +2492,14 @@ impl DeviceManager {
let mut devices = self.config.lock().unwrap().devices.clone(); let mut devices = self.config.lock().unwrap().devices.clone();
if let Some(device_list_cfg) = &mut devices { if let Some(device_list_cfg) = &mut devices {
// Create the KVM VFIO device // Create the passthrough device handle
let device_fd = self let device_fd = self
.address_manager .address_manager
.vm .vm
.create_passthrough_device() .create_passthrough_device()
.map_err(|e| DeviceManagerError::CreateKvmDevice(e.into()))?; .map_err(|e| DeviceManagerError::CreatePassthroughDevice(e.into()))?;
let device_fd = Arc::new(device_fd); let device_fd = Arc::new(device_fd);
self.kvm_device_fd = Some(Arc::clone(&device_fd)); self.passthrough_device = Some(Arc::clone(&device_fd));
for device_cfg in device_list_cfg.iter_mut() { for device_cfg in device_list_cfg.iter_mut() {
let (device_id, _) = let (device_id, _) =
@ -2918,19 +2918,19 @@ impl DeviceManager {
let interrupt_manager = Arc::clone(&self.msi_interrupt_manager); let interrupt_manager = Arc::clone(&self.msi_interrupt_manager);
let device_fd = if let Some(device_fd) = &self.kvm_device_fd { let device_fd = if let Some(device_fd) = &self.passthrough_device {
Arc::clone(&device_fd) Arc::clone(&device_fd)
} else { } else {
// If the VFIO KVM device file descriptor has not been created yet, // If the passthrough device file descriptor has not been created yet,
// it is created here and stored in the DeviceManager structure for // it is created here and stored in the DeviceManager structure for
// future needs. // future needs.
let device_fd = self let device_fd = self
.address_manager .address_manager
.vm .vm
.create_passthrough_device() .create_passthrough_device()
.map_err(|e| DeviceManagerError::CreateKvmDevice(e.into()))?; .map_err(|e| DeviceManagerError::CreatePassthroughDevice(e.into()))?;
let device_fd = Arc::new(device_fd); let device_fd = Arc::new(device_fd);
self.kvm_device_fd = Some(Arc::clone(&device_fd)); self.passthrough_device = Some(Arc::clone(&device_fd));
device_fd device_fd
}; };