mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-02 01:45:21 +00:00
vmm: Make add_vfio_device mutable
The method add_vfio_device() from the DeviceManager needs to be mutable if we want later to be able to update some internal fields from the DeviceManager from this same function. This commit simply takes care of making the necessary changes to change this function as mutable. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
parent
948f808da6
commit
d0820cc026
@ -1387,7 +1387,7 @@ impl DeviceManager {
|
||||
|
||||
#[cfg(feature = "pci_support")]
|
||||
fn add_vfio_device(
|
||||
&self,
|
||||
&mut self,
|
||||
pci: &mut PciBus,
|
||||
interrupt_manager: &Arc<dyn InterruptManager<GroupConfig = MsiIrqGroupConfig>>,
|
||||
device_fd: &Arc<DeviceFd>,
|
||||
@ -1461,8 +1461,9 @@ impl DeviceManager {
|
||||
interrupt_manager: &Arc<dyn InterruptManager<GroupConfig = MsiIrqGroupConfig>>,
|
||||
) -> DeviceManagerResult<Vec<u32>> {
|
||||
let mut iommu_attached_device_ids = Vec::new();
|
||||
let devices = self.config.lock().unwrap().devices.clone();
|
||||
|
||||
if let Some(device_list_cfg) = &self.config.lock().unwrap().devices {
|
||||
if let Some(device_list_cfg) = &devices {
|
||||
// Create the KVM VFIO device
|
||||
let device_fd = DeviceManager::create_kvm_device(&self.address_manager.vm_fd)?;
|
||||
let device_fd = Arc::new(device_fd);
|
||||
@ -1670,8 +1671,8 @@ impl DeviceManager {
|
||||
iommu: false,
|
||||
};
|
||||
|
||||
let mut pci = if let Some(pci_bus) = &self.pci_bus {
|
||||
pci_bus.lock().unwrap()
|
||||
let pci = if let Some(pci_bus) = &self.pci_bus {
|
||||
Arc::clone(&pci_bus)
|
||||
} else {
|
||||
return Err(DeviceManagerError::NoPciBus);
|
||||
};
|
||||
@ -1690,8 +1691,12 @@ impl DeviceManager {
|
||||
device_fd
|
||||
};
|
||||
|
||||
let device_id =
|
||||
self.add_vfio_device(&mut pci, &interrupt_manager, &device_fd, &device_cfg)?;
|
||||
let device_id = self.add_vfio_device(
|
||||
&mut pci.lock().unwrap(),
|
||||
&interrupt_manager,
|
||||
&device_fd,
|
||||
&device_cfg,
|
||||
)?;
|
||||
|
||||
// Update the PCIU bitmap
|
||||
self.pci_devices_up |= 1 << (device_id >> 3);
|
||||
|
@ -621,7 +621,13 @@ impl Vm {
|
||||
.start_boot_vcpus(entry_addr)
|
||||
.map_err(Error::CpuManager)?;
|
||||
|
||||
if self.device_manager.lock().unwrap().console().input_enabled() {
|
||||
if self
|
||||
.device_manager
|
||||
.lock()
|
||||
.unwrap()
|
||||
.console()
|
||||
.input_enabled()
|
||||
{
|
||||
let console = self.device_manager.lock().unwrap().console().clone();
|
||||
let signals = Signals::new(&[SIGWINCH, SIGINT, SIGTERM]);
|
||||
match signals {
|
||||
@ -660,7 +666,13 @@ impl Vm {
|
||||
.read_raw(&mut out)
|
||||
.map_err(Error::Console)?;
|
||||
|
||||
if self.device_manager.lock().unwrap().console().input_enabled() {
|
||||
if self
|
||||
.device_manager
|
||||
.lock()
|
||||
.unwrap()
|
||||
.console()
|
||||
.input_enabled()
|
||||
{
|
||||
self.device_manager
|
||||
.lock()
|
||||
.unwrap()
|
||||
|
Loading…
x
Reference in New Issue
Block a user