(
&mut self,
vdpa_cfg: &mut VdpaConfig,
)
| 3670 | } |
| 3671 | |
| 3672 | fn make_vdpa_device( |
| 3673 | &mut self, |
| 3674 | vdpa_cfg: &mut VdpaConfig, |
| 3675 | ) -> DeviceManagerResult<MetaVirtioDevice> { |
| 3676 | let id = match vdpa_cfg.pci_common.id.as_ref() { |
| 3677 | Some(id) => id.clone(), |
| 3678 | None => vdpa_cfg |
| 3679 | .pci_common |
| 3680 | .id |
| 3681 | .insert(self.next_device_name(VDPA_DEVICE_NAME_PREFIX)?) |
| 3682 | .clone(), |
| 3683 | }; |
| 3684 | |
| 3685 | info!("Creating vDPA device: {vdpa_cfg:?}"); |
| 3686 | |
| 3687 | let device_path = vdpa_cfg |
| 3688 | .path |
| 3689 | .to_str() |
| 3690 | .ok_or(DeviceManagerError::CreateVdpaConvertPath)?; |
| 3691 | |
| 3692 | let vdpa_device = Arc::new(Mutex::new( |
| 3693 | virtio_devices::Vdpa::new( |
| 3694 | id.clone(), |
| 3695 | device_path, |
| 3696 | self.memory_manager.lock().unwrap().guest_memory(), |
| 3697 | vdpa_cfg.num_queues as u16, |
| 3698 | state_from_id(self.snapshot.as_ref(), id.as_str()) |
| 3699 | .map_err(DeviceManagerError::RestoreGetState)?, |
| 3700 | ) |
| 3701 | .map_err(DeviceManagerError::CreateVdpa)?, |
| 3702 | )); |
| 3703 | |
| 3704 | // Create the DMA handler that is required by the vDPA device |
| 3705 | let vdpa_mapping = Arc::new(VdpaDmaMapping::new( |
| 3706 | Arc::clone(&vdpa_device), |
| 3707 | Arc::new(self.memory_manager.lock().unwrap().guest_memory()), |
| 3708 | )); |
| 3709 | |
| 3710 | self.device_tree |
| 3711 | .lock() |
| 3712 | .unwrap() |
| 3713 | .insert(id.clone(), device_node!(id, vdpa_device)); |
| 3714 | |
| 3715 | Ok(MetaVirtioDevice { |
| 3716 | virtio_device: vdpa_device as Arc<Mutex<dyn virtio_devices::VirtioDevice>>, |
| 3717 | pci_common: vdpa_cfg.pci_common.clone(), |
| 3718 | dma_handler: Some(vdpa_mapping), |
| 3719 | }) |
| 3720 | } |
| 3721 | |
| 3722 | fn make_vdpa_devices(&mut self) -> DeviceManagerResult<()> { |
| 3723 | // Add vdpa if required |
no test coverage detected