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

Method new

pci/src/vfio_user.rs:76–117  ·  view source on GitHub ↗
(
        id: String,
        vm: Arc<dyn hypervisor::Vm>,
        client: Arc<Mutex<Client>>,
        msi_interrupt_manager: Arc<dyn InterruptManager<GroupConfig = MsiIrqGroupConfig>>,
        legacy

Source from the content-addressed store, hash-verified

74impl VfioUserPciDevice {
75 #[allow(clippy::too_many_arguments)]
76 pub fn new(
77 id: String,
78 vm: Arc<dyn hypervisor::Vm>,
79 client: Arc<Mutex<Client>>,
80 msi_interrupt_manager: Arc<dyn InterruptManager<GroupConfig = MsiIrqGroupConfig>>,
81 legacy_interrupt_group: Option<Arc<dyn InterruptSourceGroup>>,
82 bdf: PciBdf,
83 memory_slot_allocator: MemorySlotAllocator,
84 snapshot: Option<&Snapshot>,
85 ) -> Result<Self, VfioUserPciDeviceError> {
86 let resettable = client.lock().unwrap().resettable();
87 if resettable {
88 client
89 .lock()
90 .unwrap()
91 .reset()
92 .map_err(VfioUserPciDeviceError::Client)?;
93 }
94
95 let vfio_wrapper = VfioUserClientWrapper {
96 client: client.clone(),
97 };
98
99 let common = VfioCommon::new(
100 msi_interrupt_manager,
101 legacy_interrupt_group,
102 Arc::new(vfio_wrapper) as Arc<dyn Vfio>,
103 &PciVfioUserSubclass::VfioUserSubclass,
104 bdf,
105 vm_migration::snapshot_from_id(snapshot, VFIO_COMMON_ID),
106 VfioCommonConfig::default(),
107 )
108 .map_err(VfioUserPciDeviceError::CreateVfioCommon)?;
109
110 Ok(Self {
111 id,
112 vm,
113 client,
114 common,
115 memory_slot_allocator,
116 })
117 }
118
119 /// Map all of the MMIO regions.
120 pub fn map_mmio_regions(&mut self) -> Result<(), VfioUserPciDeviceError> {

Callers

nothing calls this directly

Calls 4

newFunction · 0.85
snapshot_from_idFunction · 0.85
resetMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected