MCPcopy Index your code
hub / github.com/cloud-hypervisor/cloud-hypervisor / insert

Method insert

vm-device/src/bus.rs:154–181  ·  view source on GitHub ↗
(&self, device: Arc<dyn BusDeviceSync>, base: u64, len: u64)

Source from the content-addressed store, hash-verified

152 /// The bus will only hold a weak reference to the object.
153 #[allow(clippy::needless_pass_by_value)]
154 pub fn insert(&self, device: Arc<dyn BusDeviceSync>, base: u64, len: u64) -> Result<()> {
155 if len == 0 {
156 return Err(Error::ZeroSizedRange);
157 }
158
159 // Reject all cases where the new device's range overlaps with an existing device.
160 if self
161 .devices
162 .read()
163 .unwrap()
164 .iter()
165 .any(|(range, _dev)| range.overlaps(base, len))
166 {
167 return Err(Error::Overlap);
168 }
169
170 if self
171 .devices
172 .write()
173 .unwrap()
174 .insert(BusRange { base, len }, Arc::downgrade(&device))
175 .is_some()
176 {
177 return Err(Error::Overlap);
178 }
179
180 Ok(())
181 }
182
183 /// Removes the device at the given address space range.
184 pub fn remove(&self, base: u64, len: u64) -> Result<()> {

Callers 15

test_fdt_distance_mapFunction · 0.45
addMethod · 0.45
add_valuelessMethod · 0.45
register_percpu_bufMethod · 0.45
newMethod · 0.45
register_mappingMethod · 0.45
add_deviceMethod · 0.45
generate_sparse_areasMethod · 0.45
spawnMethod · 0.45

Calls 4

iterMethod · 0.80
overlapsMethod · 0.80
readMethod · 0.45
writeMethod · 0.45

Tested by 6

test_fdt_distance_mapFunction · 0.36
bus_insertFunction · 0.36
bus_read_writeFunction · 0.36
bus_read_write_valuesFunction · 0.36
busrange_cmpFunction · 0.36