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

Method read_at

block/src/qcow/backing.rs:30–43  ·  view source on GitHub ↗
(&self, address: u64, buf: &mut [u8])

Source from the content-addressed store, hash-verified

28
29impl BackingRead for RawBacking {
30 fn read_at(&self, address: u64, buf: &mut [u8]) -> io::Result<()> {
31 if address >= self.virtual_size {
32 buf.fill(0);
33 return Ok(());
34 }
35 let available = (self.virtual_size - address) as usize;
36 if available >= buf.len() {
37 pread_exact(self.fd.as_raw_fd(), buf, address)
38 } else {
39 pread_exact(self.fd.as_raw_fd(), &mut buf[..available], address)?;
40 buf[available..].fill(0);
41 Ok(())
42 }
43 }
44}
45
46/// QCOW2 image used as a backing file for another QCOW2 image.

Callers 1

read_clustersMethod · 0.45

Calls 5

pread_exactFunction · 0.85
read_clustersMethod · 0.80
lenMethod · 0.45
as_raw_fdMethod · 0.45
virtual_sizeMethod · 0.45

Tested by

no test coverage detected