vmm: Add id option to VFIO hotplug

Add a new id option to the VFIO hotplug command so that it matches the
VFIO coldplug semantic.

This is done by refactoring the existing code for VFIO hotplug, where
VmAddDeviceData structure is replaced by DeviceConfig. This structure is
the one used whenever a VFIO device is coldplugged, which is why it
makes sense to reuse it for the hotplug codepath.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2020-03-11 16:17:51 +01:00
parent 18dc916380
commit 34412c9b41
6 changed files with 21 additions and 35 deletions

View File

@@ -1796,13 +1796,7 @@ impl DeviceManager {
}
#[cfg(feature = "pci_support")]
pub fn add_device(&mut self, path: String) -> DeviceManagerResult<DeviceConfig> {
let mut device_cfg = DeviceConfig {
path: PathBuf::from(path),
iommu: false,
id: None,
};
pub fn add_device(&mut self, device_cfg: &mut DeviceConfig) -> DeviceManagerResult<()> {
let pci = if let Some(pci_bus) = &self.pci_bus {
Arc::clone(&pci_bus)
} else {
@@ -1827,13 +1821,13 @@ impl DeviceManager {
&mut pci.lock().unwrap(),
&interrupt_manager,
&device_fd,
&mut device_cfg,
device_cfg,
)?;
// Update the PCIU bitmap
self.pci_devices_up |= 1 << (device_id >> 3);
Ok(device_cfg)
Ok(())
}
#[cfg(feature = "pci_support")]