Lines Matching +full:add +full:- +full:user +full:- +full:device

4 // Use of this source code is governed by a BSD-style license that can be
5 // found in the LICENSE-BSD-3-Clause file.
9 // SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
121 // Singleton devices / devices the user cannot name
137 // Devices that the user may name and for which we generate
138 // identifiers if the user doesn't give one
148 const VIRTIO_PCI_DEVICE_NAME_PREFIX: &str = "_virtio-pci";
150 /// Errors associated with device manager
161 /// Cannot create vhost-user-net device
162 #[error("Cannot create vhost-user-net device")]
165 /// Cannot create virtio-blk device
166 #[error("Cannot create virtio-blk device")]
169 /// Cannot create virtio-net device
170 #[error("Cannot create virtio-net device")]
173 /// Cannot create virtio-console device
174 #[error("Cannot create virtio-console device")]
177 /// Cannot create virtio-rng device
178 #[error("Cannot create virtio-rng device")]
181 /// Cannot create virtio-fs device
182 #[error("Cannot create virtio-fs device")]
185 /// Virtio-fs device was created without a socket.
186 #[error("Virtio-fs device was created without a socket")]
189 /// Cannot create vhost-user-blk device
190 #[error("Cannot create vhost-user-blk device")]
193 /// Cannot create virtio-pmem device
194 #[error("Cannot create virtio-pmem device")]
197 /// Cannot create vDPA device
198 #[error("Cannot create vdpa device")]
201 /// Cannot create virtio-vsock device
202 #[error("Cannot create virtio-vsock device")]
205 /// Cannot create tpm device
206 #[error("Cannot create tmp device")]
209 /// Failed to convert Path to &str for the vDPA device.
210 #[error("Failed to convert Path to &str for the vDPA device")]
213 /// Failed to convert Path to &str for the virtio-vsock device.
214 #[error("Failed to convert Path to &str for the virtio-vsock device")]
217 /// Cannot create virtio-vsock backend
218 #[error("Cannot create virtio-vsock backend")]
221 /// Cannot create virtio-iommu device
222 #[error("Cannot create virtio-iommu device")]
225 /// Cannot create virtio-balloon device
226 #[error("Cannot create virtio-balloon device")]
229 /// Cannot create pvmemcontrol device
231 #[error("Cannot create pvmemcontrol device")]
234 /// Cannot create virtio-watchdog device
235 #[error("Cannot create virtio-watchdog device")]
270 /// Could not free the BARs associated with a PCI device.
271 #[error("Could not free the BARs associated with a PCI device")]
282 /// Cannot create virtio device
283 #[error("Cannot create virtio device")]
286 /// Cannot add PCI device
287 #[error("Cannot add PCI device")]
302 /// Cannot find a memory range for virtio-fs
303 #[error("Cannot find a memory range for virtio-fs")]
310 /// Error creating debug-console output file
312 #[error("Error creating debug-console output file")]
339 /// Cannot create a VFIO device
340 #[error("Cannot create a VFIO device")]
343 /// Cannot create a VFIO PCI device
344 #[error("Cannot create a VFIO PCI device")]
351 /// Failed to DMA map VFIO device.
352 #[error("Failed to DMA map VFIO device")]
355 /// Failed to DMA unmap VFIO device.
356 #[error("Failed to DMA unmap VFIO device")]
359 /// Failed to create the passthrough device.
360 #[error("Failed to create the passthrough device")]
367 /// Cannot add legacy device to Bus.
368 #[error("Cannot add legacy device to Bus")]
423 /// Could not find an available device name.
424 #[error("Could not find an available device name")]
427 /// Missing PCI device.
428 #[error("Missing PCI device")]
431 /// Failed to remove a PCI device from the PCI bus.
432 #[error("Failed to remove a PCI device from the PCI bus")]
435 /// Failed to remove a bus device from the IO bus.
436 #[error("Failed to remove a bus device from the IO bus")]
439 /// Failed to remove a bus device from the MMIO bus.
440 #[error("Failed to remove a bus device from the MMIO bus")]
443 /// Failed to find the device corresponding to a specific PCI b/d/f.
444 #[error("Failed to find the device corresponding to a specific PCI b/d/f")]
447 /// Not allowed to remove this type of device from the VM.
448 #[error("Not allowed to remove this type of device from the VM: {0}")]
451 /// Failed to find device corresponding to the given identifier.
452 #[error("Failed to find device corresponding to the given identifier")]
455 /// Failed to find an available PCI device ID.
456 #[error("Failed to find an available PCI device ID")]
459 /// Could not reserve the PCI device ID.
460 #[error("Could not reserve the PCI device ID")]
463 /// Could not give the PCI device ID back.
464 #[error("Could not give the PCI device ID back")]
471 /// Failed to update guest memory for virtio device.
472 #[error("Failed to update guest memory for virtio device")]
475 /// Cannot create virtio-mem device
476 #[error("Cannot create virtio-mem device")]
479 /// Cannot find a memory range for virtio-mem memory
480 #[error("Cannot find a memory range for virtio-mem memory")]
483 /// Failed to update guest memory for VFIO PCI device.
484 #[error("Failed to update guest memory for VFIO PCI device")]
495 /// Could not find the node in the device tree.
496 #[error("Could not find the node in the device tree")]
503 /// Expected resources for virtio-pmem could not be found.
504 #[error("Expected resources for virtio-pmem could not be found")]
511 /// No support for device passthrough
512 #[error("No support for device passthrough")]
515 /// No socket option support for console device
516 #[error("No socket option support for console device")]
519 /// Failed to resize virtio-balloon
520 #[error("Failed to resize virtio-balloon")]
523 /// Missing virtio-balloon, can't proceed as expected.
524 #[error("Missing virtio-balloon, can't proceed as expected")]
527 /// Missing virtual IOMMU device
528 #[error("Missing virtual IOMMU device")]
560 /// Failed to add DMA mapping handler to virtio-mem device.
561 #[error("Failed to add DMA mapping handler to virtio-mem device")]
564 /// Failed to remove DMA mapping handler from virtio-mem device.
565 #[error("Failed to remove DMA mapping handler from virtio-mem device")]
568 /// Failed to create vfio-user client
569 #[error("Failed to create vfio-user client")]
572 /// Failed to create VFIO user device
573 #[error("Failed to create VFIO user device")]
576 /// Failed to map region from VFIO user device into guest
577 #[error("Failed to map region from VFIO user device into guest")]
580 /// Failed to DMA map VFIO user device.
581 #[error("Failed to DMA map VFIO user device")]
584 /// Failed to DMA unmap VFIO user device.
585 #[error("Failed to DMA unmap VFIO user device")]
588 /// Failed to update memory mappings for VFIO user device
589 #[error("Failed to update memory mappings for VFIO user device")]
596 /// Failed to DMA map virtio device.
597 #[error("Failed to DMA map virtio device")]
600 /// Failed to DMA unmap virtio device.
601 #[error("Failed to DMA unmap virtio device")]
604 /// Cannot hotplug device behind vIOMMU
605 #[error("Cannot hotplug device behind vIOMMU")]
616 /// Error activating virtio device
617 #[error("Error activating virtio device")]
620 /// Failed retrieving device state from snapshot
621 #[error("Failed retrieving device state from snapshot")]
624 /// Cannot create a PvPanic device
625 #[error("Cannot create a PvPanic device")]
659 pub fn need_resize(&self) -> bool { in need_resize()
692 ) -> std::result::Result<(), std::io::Error> { in move_bar()
747 // Update the device_tree resources associated with the device in move_bar()
763 "Couldn't find a resource with base 0x{old_base:x} for device {id}" in move_bar()
768 "Couldn't find device {id} from device tree" in move_bar()
806 io::Error::other(format!("failed to remove user memory region: {e:?}")) in move_bar()
820 io::Error::other(format!("failed to create user memory regions: {e:?}")) in move_bar()
852 fn clone(&self) -> Self { in clone()
891 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { in fmt()
898 fn new(vm: Arc<dyn hypervisor::Vm>) -> SevSnpPageAccessProxy { in new()
905 fn translate_gpa(&self, base: u64, _size: u64) -> std::result::Result<u64, std::io::Error> { in translate_gpa()
909 fn translate_gva(&self, base: u64, size: u64) -> std::result::Result<u64, std::io::Error> { in translate_gva()
945 // ACPI GED notification device
969 // Counter to keep track of the consumed device IDs.
982 // Passthrough device handle
1017 // Possible handle to the virtio-balloon device
1020 // Virtio Device activation EventFd to allow the VMM thread to trigger device
1029 // Possible handle to the virtio-mem device
1033 // GPIO device for AArch64
1042 // pvpanic device
1081 ) -> Vec<Arc<Mutex<AddressAllocator>>> { in create_mmio_allocators()
1085 let pci_segment_mmio_size = (end - start + 1) / (alignment * total_weight as u64) * alignment; in create_mmio_allocators()
1122 ) -> DeviceManagerResult<Arc<Mutex<Self>>> { in new()
1193 // later, after the IOAPIC device creation. in new()
1197 // msi_interrupt_manager <- IOAPIC <- legacy_interrupt_manager. in new()
1353 pub fn console_resize_pipe(&self) -> Option<Arc<File>> { in console_resize_pipe()
1359 ) -> DeviceManagerResult<Arc<Mutex<dyn InterruptController>>> { in create_interrupt_controller()
1369 ) -> DeviceManagerResult<()> { in create_devices()
1380 // formed IOAPIC device. in create_devices()
1445 // Add pvmemcontrol if required in create_devices()
1463 fn state(&self) -> DeviceManagerState { in state()
1470 fn get_msi_iova_space(&mut self) -> (u64, u64) { in get_msi_iova_space()
1477 vgic_config.msi_addr + vgic_config.msi_size - 1, in get_msi_iova_space()
1487 - 1, in get_msi_iova_space()
1496 pub fn get_device_info(&self) -> &HashMap<(DeviceType, String), MmioDeviceInfo> { in get_device_info()
1504 ) -> DeviceManagerResult<()> { in add_pci_devices()
1515 let (device, mapping) = virtio_devices::Iommu::new( in add_pci_devices()
1527 let device = Arc::new(Mutex::new(device)); in add_pci_devices() localVariable
1528 self.iommu_device = Some(Arc::clone(&device)); in add_pci_devices()
1531 // Fill the device tree with a new node. In case of restore, we in add_pci_devices()
1537 .insert(iommu_id.clone(), device_node!(iommu_id, device)); in add_pci_devices()
1539 Some(device) in add_pci_devices()
1572 // Add all devices from forced iommu segments in add_pci_devices()
1576 for device in 0..32 { in add_pci_devices()
1577 let bdf = PciBdf::new(*segment, 0, device, 0); in add_pci_devices()
1609 ) -> DeviceManagerResult<Arc<Mutex<dyn InterruptController>>> { in add_interrupt_controller()
1655 pub fn get_interrupt_controller(&mut self) -> Option<&Arc<Mutex<gic::Gic>>> { in get_interrupt_controller()
1662 ) -> DeviceManagerResult<Arc<Mutex<dyn InterruptController>>> { in add_interrupt_controller()
1692 pub fn get_interrupt_controller(&mut self) -> Option<&Arc<Mutex<aia::Aia>>> { in get_interrupt_controller()
1699 ) -> DeviceManagerResult<Arc<Mutex<dyn InterruptController>>> { in add_interrupt_controller()
1724 // Fill the device tree with a new node. In case of restore, we in add_interrupt_controller()
1740 ) -> DeviceManagerResult<Option<Arc<Mutex<devices::AcpiGedDevice>>>> { in add_acpi_devices()
1848 fn add_legacy_devices(&mut self, reset_evt: EventFd) -> DeviceManagerResult<()> { in add_legacy_devices()
1855 // Add a shutdown device (i8042) in add_legacy_devices()
1869 // Add a CMOS emulated device in add_legacy_devices()
1924 ) -> DeviceManagerResult<()> { in add_legacy_devices()
1925 // Add a RTC device in add_legacy_devices()
1961 // Add a GPIO device in add_legacy_devices()
2017 ) -> DeviceManagerResult<Arc<Mutex<DebugConsole>>> { in add_debug_console_device()
2049 // Fill the device tree with a new node. In case of restore, we in add_debug_console_device()
2065 ) -> DeviceManagerResult<Arc<Mutex<Serial>>> { in add_serial_device()
2100 // Fill the device tree with a new node. In case of restore, we in add_serial_device()
2116 ) -> DeviceManagerResult<Arc<Mutex<Pl011>>> { in add_serial_device()
2164 // Fill the device tree with a new node. In case of restore, we in add_serial_device()
2180 ) -> DeviceManagerResult<Arc<Mutex<Serial>>> { in add_serial_device()
2227 // Fill the device tree with a new node. In case of restore, we in add_serial_device()
2243 ) -> DeviceManagerResult<Option<Arc<virtio_devices::ConsoleResizer>>> { in add_virtio_console_device()
2261 if stdin == -1 { in add_virtio_console_device()
2305 // Fill the device tree with a new node. In case of restore, we in add_virtio_console_device()
2323 /// - debug-console
2324 /// - serial-console
2325 /// - virtio-console
2332 ) -> DeviceManagerResult<Arc<Console>> { in add_console_devices()
2406 ) -> DeviceManagerResult<Arc<Mutex<devices::tpm::Tpm>>> { in add_tpm_device()
2407 // Create TPM Device in add_tpm_device()
2409 DeviceManagerError::CreateTpmDevice(anyhow!("Failed to create TPM Device : {:?}", e)) in add_tpm_device()
2413 // Add TPM Device to mmio in add_tpm_device()
2429 /// For live-migration, the locks must be released on the destination side
2431 pub fn try_lock_disks(&self) -> DeviceManagerResult<()> { in try_lock_disks()
2446 pub fn release_disk_locks(&self) -> DeviceManagerResult<()> { in release_disk_locks()
2455 fn make_virtio_devices(&mut self) -> DeviceManagerResult<Vec<MetaVirtioDevice>> { in make_virtio_devices()
2463 // Add virtio-fs if required in make_virtio_devices()
2466 // Add virtio-pmem if required in make_virtio_devices()
2469 // Add virtio-vsock if required in make_virtio_devices()
2474 // Add virtio-balloon if required in make_virtio_devices()
2477 // Add virtio-watchdog device in make_virtio_devices()
2480 // Add vDPA devices if required in make_virtio_devices()
2486 // Cache whether aio is supported to avoid checking for very block device
2487 fn aio_is_supported(&mut self) -> bool { in aio_is_supported()
2497 // Cache whether io_uring is supported to avoid probing for very block device
2498 fn io_uring_is_supported(&mut self) -> bool { in io_uring_is_supported()
2510 /// Depending on the config, this is a [`vhost_user::Blk`] device or a [`virtio_devices::Block`]
2511 /// device.
2514 /// - `disk_cfg`: The [`DiskConfig`] used to create the block device.
2515 /// - `is_hotplug`: Whether the device is being hotplugged and the lock for the disk image
2517 /// vhost-user devices.
2522 ) -> DeviceManagerResult<MetaVirtioDevice> { in make_virtio_block_device()
2531 info!("Creating virtio-block device: {:?}", disk_cfg); in make_virtio_block_device()
2535 log::debug!("Acquiring image lock for vhost-user block device not supported"); in make_virtio_block_device()
2573 // Open block device path in make_virtio_block_device()
2718 // state save/resume, and live-migration, locking is part of the outer control flow in make_virtio_block_device()
2737 // Fill the device tree with a new node. In case of restore, we in make_virtio_block_device()
2754 fn make_virtio_block_devices(&mut self) -> DeviceManagerResult<Vec<MetaVirtioDevice>> { in make_virtio_block_devices()
2771 ) -> DeviceManagerResult<MetaVirtioDevice> { in make_virtio_net_device()
2779 info!("Creating virtio-net device: {:?}", net_cfg); in make_virtio_net_device()
2908 // Fill the device tree with a new node. In case of restore, we in make_virtio_net_device()
2925 /// Add virto-net and vhost-user-net devices
2926 fn make_virtio_net_devices(&mut self) -> DeviceManagerResult<Vec<MetaVirtioDevice>> { in make_virtio_net_devices()
2939 fn make_virtio_rng_devices(&mut self) -> DeviceManagerResult<Vec<MetaVirtioDevice>> { in make_virtio_rng_devices()
2942 // Add virtio-rng if required in make_virtio_rng_devices()
2945 info!("Creating virtio-rng device: {:?}", rng_config); in make_virtio_rng_devices()
2971 // Fill the device tree with a new node. In case of restore, we in make_virtio_rng_devices()
2986 ) -> DeviceManagerResult<MetaVirtioDevice> { in make_virtio_fs_device()
2995 info!("Creating virtio-fs device: {:?}", fs_cfg); in make_virtio_fs_device()
3019 // Update the device tree with the migratable device. in make_virtio_fs_device()
3036 fn make_virtio_fs_devices(&mut self) -> DeviceManagerResult<Vec<MetaVirtioDevice>> { in make_virtio_fs_devices()
3053 ) -> DeviceManagerResult<MetaVirtioDevice> { in make_virtio_pmem_device()
3062 info!("Creating virtio-pmem device: {:?}", pmem_cfg); in make_virtio_pmem_device()
3066 // Look for the id in the device tree. If it can be found, that means in make_virtio_pmem_device()
3067 // the device is being restored, otherwise it's created from scratch. in make_virtio_pmem_device()
3069 info!("Restoring virtio-pmem {} resources", id); in make_virtio_pmem_device()
3203 // Update the device tree with correct resource information and with in make_virtio_pmem_device()
3204 // the migratable device. in make_virtio_pmem_device()
3222 fn make_virtio_pmem_devices(&mut self) -> DeviceManagerResult<Vec<MetaVirtioDevice>> { in make_virtio_pmem_devices()
3224 // Add virtio-pmem if required in make_virtio_pmem_devices()
3239 ) -> DeviceManagerResult<MetaVirtioDevice> { in make_virtio_vsock_device()
3248 info!("Creating virtio-vsock device: {:?}", vsock_cfg); in make_virtio_vsock_device()
3275 // Fill the device tree with a new node. In case of restore, we in make_virtio_vsock_device()
3293 fn make_virtio_vsock_devices(&mut self) -> DeviceManagerResult<Vec<MetaVirtioDevice>> { in make_virtio_vsock_devices()
3305 fn make_virtio_mem_devices(&mut self) -> DeviceManagerResult<Vec<MetaVirtioDevice>> { in make_virtio_mem_devices()
3312 info!("Creating virtio-mem device: id = {}", memory_zone_id); in make_virtio_mem_devices()
3335 // Update the virtio-mem zone so that it has a handle onto the in make_virtio_mem_devices()
3336 // virtio-mem device, which will be used for triggering a resize in make_virtio_mem_devices()
3351 // Fill the device tree with a new node. In case of restore, we in make_virtio_mem_devices()
3367 ) -> DeviceManagerResult<( in make_pvmemcontrol_device()
3377 info!("Creating pvmemcontrol device: id = {}", id); in make_pvmemcontrol_device()
3406 fn make_virtio_balloon_devices(&mut self) -> DeviceManagerResult<Vec<MetaVirtioDevice>> { in make_virtio_balloon_devices()
3411 info!("Creating virtio-balloon device: id = {}", id); in make_virtio_balloon_devices()
3449 fn make_virtio_watchdog_devices(&mut self) -> DeviceManagerResult<Vec<MetaVirtioDevice>> { in make_virtio_watchdog_devices()
3457 info!("Creating virtio-watchdog device: id = {}", id); in make_virtio_watchdog_devices()
3492 ) -> DeviceManagerResult<MetaVirtioDevice> { in make_vdpa_device()
3501 info!("Creating vDPA device: {:?}", vdpa_cfg); in make_vdpa_device()
3520 // Create the DMA handler that is required by the vDPA device in make_vdpa_device()
3540 fn make_vdpa_devices(&mut self) -> DeviceManagerResult<Vec<MetaVirtioDevice>> { in make_vdpa_devices()
3542 // Add vdpa if required in make_vdpa_devices()
3554 fn next_device_name(&mut self, prefix: &str) -> DeviceManagerResult<String> { in next_device_name()
3580 ) -> DeviceManagerResult<(PciBdf, String)> { in add_passthrough_device()
3581 // If the passthrough device has not been created yet, it is created in add_passthrough_device()
3595 fn create_vfio_container(&self) -> DeviceManagerResult<Arc<VfioContainer>> { in create_vfio_container()
3613 ) -> DeviceManagerResult<(PciBdf, String)> { in add_vfio_device()
3628 // the first VFIO device, meaning we need a new VFIO container, which in add_vfio_device()
3629 // will be shared with other VFIO devices. Or the new VFIO device is in add_vfio_device()
3633 // device. That's simply because the map/unmap operations happen at the in add_vfio_device()
3669 // Do not register virtio-mem regions, as they are handled directly by in add_vfio_device()
3670 // virtio-mem device itself. in add_vfio_device()
3707 [pci_device_bdf.device() as usize] in add_vfio_device()
3756 // Update the device tree with correct resource information. in add_vfio_device()
3776 ) -> DeviceManagerResult<Vec<Resource>> { in add_pci_device()
3800 .add_device(bdf.device() as u32, pci_device) in add_pci_device()
3828 fn add_vfio_devices(&mut self) -> DeviceManagerResult<Vec<PciBdf>> { in add_vfio_devices()
3850 ) -> DeviceManagerResult<(PciBdf, String)> { in add_vfio_user_device()
3868 [pci_device_bdf.device() as usize] in add_vfio_user_device()
3903 VirtioMemMappingSource::Device(pci_device_bdf.into()), in add_vfio_user_device()
3937 // Update the device tree with correct resource information. in add_vfio_user_device()
3950 fn add_user_devices(&mut self) -> DeviceManagerResult<Vec<PciBdf>> { in add_user_devices()
3972 ) -> DeviceManagerResult<PciBdf> { in add_virtio_pci_device()
3973 let id = format!("{VIRTIO_PCI_DEVICE_NAME_PREFIX}-{virtio_device_id}"); in add_virtio_pci_device()
3975 // Add the new virtio-pci node to the device tree. in add_virtio_pci_device()
3989 // Allows support for one MSI-X vector per queue. It also adds 1 in add_virtio_pci_device()
3995 // This will provide address translation for any virtio device sitting in add_virtio_pci_device()
4006 // If SEV-SNP is enabled create the AccessPlatform from SevSnpPageAccessProxy in add_virtio_pci_device()
4016 // Map DMA ranges if a DMA handler is available and if the device is in add_virtio_pci_device()
4029 // Let every virtio-mem device handle the DMA map/unmap through the in add_virtio_pci_device()
4036 VirtioMemMappingSource::Device(pci_device_bdf.into()), in add_virtio_pci_device()
4042 // Do not register virtio-mem regions, as they are handled directly by in add_virtio_pci_device()
4043 // virtio-mem devices. in add_virtio_pci_device()
4069 // All device types *except* virtio block devices should be allocated a 64-bit bar in add_virtio_pci_device()
4070 // The block devices should be given a 32-bit BAR so that they are easily accessible in add_virtio_pci_device()
4098 // Update the device tree with correct resource information. in add_virtio_pci_device()
4110 ) -> DeviceManagerResult<Option<Arc<Mutex<devices::PvPanicDevice>>>> { in add_pvpanic_device()
4114 info!("Creating pvpanic device {}", id); in add_pvpanic_device()
4149 ) -> DeviceManagerResult<(u16, PciBdf, Option<Vec<Resource>>)> { in pci_resources()
4150 // Look for the id in the device tree. If it can be found, that means in pci_resources()
4151 // the device is being restored, otherwise it's created from scratch. in pci_resources()
4154 info!("Restoring virtio-pci {} resources", id); in pci_resources()
4170 .get_device_id(pci_device_bdf.device() as usize) in pci_resources()
4182 pub fn io_bus(&self) -> &Arc<Bus> { in io_bus()
4186 pub fn mmio_bus(&self) -> &Arc<Bus> { in mmio_bus()
4190 pub fn allocator(&self) -> &Arc<Mutex<SystemAllocator>> { in allocator()
4194 pub fn interrupt_controller(&self) -> Option<Arc<Mutex<dyn InterruptController>>> { in interrupt_controller()
4200 pub(crate) fn pci_segments(&self) -> &Vec<PciSegment> { in pci_segments()
4205 pub fn cmdline_additions(&self) -> &[String] { in cmdline_additions()
4209 pub fn update_memory(&self, new_region: &Arc<GuestRegionMmap>) -> DeviceManagerResult<()> { in update_memory()
4240 // Take care of updating the memory for vfio-user devices. in update_memory()
4261 pub fn activate_virtio_devices(&self) -> DeviceManagerResult<()> { in activate_virtio_devices()
4273 ) -> DeviceManagerResult<()> { in notify_hotplug()
4287 ) -> DeviceManagerResult<PciDeviceInfo> { in add_device()
4297 self.pci_segments[device_cfg.pci_segment as usize].pci_devices_up |= 1 << bdf.device(); in add_device()
4308 ) -> DeviceManagerResult<PciDeviceInfo> { in add_user_device()
4314 self.pci_segments[device_cfg.pci_segment as usize].pci_devices_up |= 1 << bdf.device(); in add_user_device()
4322 pub fn remove_device(&mut self, id: String) -> DeviceManagerResult<()> { in remove_device()
4324 // VFIO device or a virtio-pci one. in remove_device()
4325 // In case the 'id' refers to a virtio device, we must find the PCI in remove_device()
4392 self.pci_segments[pci_segment_id as usize].pci_devices_down |= 1 << pci_device_bdf.device(); in remove_device()
4397 pub fn eject_device(&mut self, pci_segment_id: u16, device_id: u8) -> DeviceManagerResult<()> { in eject_device()
4403 // Convert the device ID into the corresponding b/d/f. in eject_device()
4406 // Give the PCI device ID back to the PCI bus. in eject_device()
4415 // Remove the device from the device tree along with its children. in eject_device()
4421 // For VFIO and vfio-user the PCI device id is the id. in eject_device()
4423 // underlying device. in eject_device()
4429 // The virtio-pci device has a single child in eject_device()
4451 // No need to remove any virtio-mem mapping here as the container outlives all devices in eject_device()
4522 .remove_dma_mapping_handler(VirtioMemMappingSource::Device( in eject_device()
4546 // Remove the device from the PCI bus in eject_device()
4555 // Remove the device from the IO bus in eject_device()
4560 // Remove the device from the MMIO bus in eject_device()
4565 // Remove the device from the list of BusDevice held by the in eject_device()
4570 // Shutdown and remove the underlying virtio-device if present in eject_device()
4594 "device-removed", in eject_device()
4601 // At this point, the device has been removed from all the list and in eject_device()
4604 // device will be dropped. in eject_device()
4611 ) -> DeviceManagerResult<PciDeviceInfo> { in hotplug_virtio_pci_device()
4612 // Add the virtio device to the device manager list. This is important in hotplug_virtio_pci_device()
4632 self.pci_segments[handle.pci_segment as usize].pci_devices_up |= 1 << bdf.device(); in hotplug_virtio_pci_device()
4637 fn is_iommu_segment(&self, pci_segment_id: u16) -> bool { in is_iommu_segment()
4653 pub fn add_disk(&mut self, disk_cfg: &mut DiskConfig) -> DeviceManagerResult<PciDeviceInfo> { in add_disk()
4660 let device = self.make_virtio_block_device(disk_cfg, true)?; in add_disk() localVariable
4661 self.hotplug_virtio_pci_device(device) in add_disk()
4664 pub fn add_fs(&mut self, fs_cfg: &mut FsConfig) -> DeviceManagerResult<PciDeviceInfo> { in add_fs()
4667 let device = self.make_virtio_fs_device(fs_cfg)?; in add_fs() localVariable
4668 self.hotplug_virtio_pci_device(device) in add_fs()
4671 pub fn add_pmem(&mut self, pmem_cfg: &mut PmemConfig) -> DeviceManagerResult<PciDeviceInfo> { in add_pmem()
4678 let device = self.make_virtio_pmem_device(pmem_cfg)?; in add_pmem() localVariable
4679 self.hotplug_virtio_pci_device(device) in add_pmem()
4682 pub fn add_net(&mut self, net_cfg: &mut NetConfig) -> DeviceManagerResult<PciDeviceInfo> { in add_net()
4689 let device = self.make_virtio_net_device(net_cfg)?; in add_net() localVariable
4690 self.hotplug_virtio_pci_device(device) in add_net()
4693 pub fn add_vdpa(&mut self, vdpa_cfg: &mut VdpaConfig) -> DeviceManagerResult<PciDeviceInfo> { in add_vdpa()
4700 let device = self.make_vdpa_device(vdpa_cfg)?; in add_vdpa() localVariable
4701 self.hotplug_virtio_pci_device(device) in add_vdpa()
4704 pub fn add_vsock(&mut self, vsock_cfg: &mut VsockConfig) -> DeviceManagerResult<PciDeviceInfo> { in add_vsock()
4711 let device = self.make_virtio_vsock_device(vsock_cfg)?; in add_vsock() localVariable
4712 self.hotplug_virtio_pci_device(device) in add_vsock()
4715 pub fn counters(&self) -> HashMap<String, HashMap<&'static str, Wrapping<u64>>> { in counters()
4728 pub fn resize_balloon(&mut self, size: u64) -> DeviceManagerResult<()> { in resize_balloon()
4741 pub fn balloon_size(&self) -> u64 { in balloon_size()
4749 pub fn device_tree(&self) -> Arc<Mutex<DeviceTree>> { in device_tree()
4754 pub fn notify_power_button(&self) -> DeviceManagerResult<()> { in notify_power_button()
4765 pub fn notify_power_button(&self) -> DeviceManagerResult<()> { in notify_power_button()
4767 // 1. Users will use direct kernel boot with device tree. in notify_power_button()
4789 pub fn iommu_attached_devices(&self) -> &Option<(PciBdf, Vec<PciBdf>)> { in iommu_attached_devices()
4793 fn validate_identifier(&self, id: &Option<String>) -> DeviceManagerResult<()> { in validate_identifier()
4808 pub(crate) fn acpi_platform_addresses(&self) -> &AcpiPlatformAddresses { in acpi_platform_addresses()
4813 fn numa_node_id_from_memory_zone_id(numa_nodes: &NumaNodes, memory_zone_id: &str) -> Option<u32> { in numa_node_id_from_memory_zone_id()
4823 fn numa_node_id_from_pci_segment_id(numa_nodes: &NumaNodes, pci_segment_id: u16) -> u32 { in numa_node_id_from_pci_segment_id()
4839 aml::Device::new( in to_aml_bytes()
4877 aml::Device::new( in to_aml_bytes()
4890 self.acpi_address.0 + DEVICE_MANAGER_ACPI_SIZE as u64 - 1, in to_aml_bytes()
4954 aml::Device::new( in to_aml_bytes()
4964 // Serial device in to_aml_bytes()
4976 // If serial is turned off, add a fake device with invalid irq. in to_aml_bytes()
4980 aml::Device::new( in to_aml_bytes()
5013 aml::Device::new( in to_aml_bytes()
5023 // Add tpm device in to_aml_bytes()
5037 fn pause(&mut self) -> result::Result<(), MigratableError> { in pause()
5043 // On AArch64, the pause of device manager needs to trigger in pause()
5058 fn resume(&mut self) -> result::Result<(), MigratableError> { in resume()
5069 fn id(&self) -> String { in id()
5073 fn snapshot(&mut self) -> std::result::Result<Snapshot, MigratableError> { in snapshot()
5091 fn start_dirty_log(&mut self) -> std::result::Result<(), MigratableError> { in start_dirty_log()
5100 fn stop_dirty_log(&mut self) -> std::result::Result<(), MigratableError> { in stop_dirty_log()
5109 fn dirty_log(&mut self) -> std::result::Result<MemoryRangeTable, MigratableError> { in dirty_log()
5119 fn start_migration(&mut self) -> std::result::Result<(), MigratableError> { in start_migration()
5128 fn complete_migration(&mut self) -> std::result::Result<(), MigratableError> { in complete_migration()
5192 fn write(&mut self, base: u64, offset: u64, data: &[u8]) -> Option<Arc<std::sync::Barrier>> { in write()
5203 error!("Failed ejecting device {}: {:?}", slot_id, e); in write()
5240 // Wake up the DeviceManager threads (mainly virtio device workers), in drop()