MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / add_user_device

Method add_user_device

vmm/src/vm.rs:2233–2255  ·  view source on GitHub ↗
(&mut self, mut device_cfg: UserDeviceConfig)

Source from the content-addressed store, hash-verified

2231 }
2232
2233 pub fn add_user_device(&mut self, mut device_cfg: UserDeviceConfig) -> Result<PciDeviceInfo> {
2234 let pci_device_info = self
2235 .device_manager
2236 .lock()
2237 .unwrap()
2238 .add_user_device(&mut device_cfg)
2239 .map_err(Error::DeviceManager)?;
2240
2241 // Update VmConfig by adding the new device. This is important to
2242 // ensure the device would be created in case of a reboot.
2243 {
2244 let mut config = self.config.lock().unwrap();
2245 add_to_config(&mut config.user_devices, device_cfg);
2246 }
2247
2248 self.device_manager
2249 .lock()
2250 .unwrap()
2251 .notify_hotplug(AcpiNotificationFlags::PCI_DEVICES_CHANGED)
2252 .map_err(Error::DeviceManager)?;
2253
2254 Ok(pci_device_info)
2255 }
2256
2257 pub fn remove_device(&mut self, id: &str) -> Result<()> {
2258 self.device_manager

Callers 1

vm_add_user_deviceMethod · 0.45

Calls 2

add_to_configFunction · 0.85
notify_hotplugMethod · 0.80

Tested by

no test coverage detected