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

Method write_config

virtio-devices/src/iommu.rs:1260–1278  ·  view source on GitHub ↗
(&mut self, offset: u64, data: &[u8])

Source from the content-addressed store, hash-verified

1258 }
1259
1260 fn write_config(&mut self, offset: u64, data: &[u8]) {
1261 // The "bypass" field is the only mutable field
1262 let bypass_offset =
1263 (&raw const self.config.bypass as u64) - (&raw const self.config as u64);
1264 if offset != bypass_offset || data.len() != std::mem::size_of_val(&self.config.bypass) {
1265 error!(
1266 "Attempt to write to read-only field: offset {:x} length {}",
1267 offset,
1268 data.len()
1269 );
1270 return;
1271 }
1272
1273 // virtio spec says ignore bits 1-7 and that the device must
1274 // never present a value other than 0 or 1.
1275 self.config.bypass = data[0] & 1;
1276
1277 self.update_bypass();
1278 }
1279
1280 fn activate(&mut self, context: crate::device::ActivationContext) -> ActivateResult {
1281 let crate::device::ActivationContext {

Callers

nothing calls this directly

Calls 2

update_bypassMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected