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

Method write_config

virtio-devices/src/vhost_user/blk.rs:238–267  ·  view source on GitHub ↗
(&mut self, offset: u64, data: &[u8])

Source from the content-addressed store, hash-verified

236 }
237
238 fn write_config(&mut self, offset: u64, data: &[u8]) {
239 // The "writeback" field is the only mutable field
240 let writeback_offset =
241 (&raw const self.config.writeback as u64) - (&raw const self.config as u64);
242 if offset != writeback_offset || data.len() != std::mem::size_of_val(&self.config.writeback)
243 {
244 error!(
245 "Attempt to write to read-only field: offset {:x} length {}",
246 offset,
247 data.len()
248 );
249 return;
250 }
251
252 self.config.writeback = data[0];
253 if let Some(vu) = &self.vu_common.vu
254 && let Err(e) = vu
255 .lock()
256 .unwrap()
257 .socket_handle()
258 .set_config(offset as u32, VhostUserConfigFlags::WRITABLE, data)
259 .map_err(Error::VhostUserSetConfig)
260 {
261 error!(
262 "Failed setting vhost-user-blk configuration for socket {} at offset 0x{offset:x} with length {}: {e:?}",
263 self.vu_common.socket_path,
264 data.len()
265 );
266 }
267 }
268
269 fn activate(&mut self, context: crate::device::ActivationContext) -> ActivateResult {
270 let crate::device::ActivationContext {

Callers 1

test_virtio_deviceFunction · 0.45

Calls 3

set_configMethod · 0.80
socket_handleMethod · 0.80
lenMethod · 0.45

Tested by 1

test_virtio_deviceFunction · 0.36