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

Function copy

vmm/src/uffd.rs:154–174  ·  view source on GitHub ↗

Resolve a page fault by copying data into the faulted address.

(fd: BorrowedFd<'_>, dst: u64, src: *const u8, len: u64)

Source from the content-addressed store, hash-verified

152
153/// Resolve a page fault by copying data into the faulted address.
154pub(crate) fn copy(fd: BorrowedFd<'_>, dst: u64, src: *const u8, len: u64) -> Result<(), Error> {
155 let mut cp = UffdioCopy {
156 dst,
157 src: src as u64,
158 len,
159 mode: 0,
160 copy: 0,
161 };
162 // SAFETY: `cp` is a valid, correctly-sized struct for this ioctl.
163 let ret = unsafe {
164 libc::ioctl(
165 fd.as_raw_fd(),
166 userfaultfd::UFFDIO_COPY as libc::Ioctl,
167 &mut cp,
168 )
169 };
170 if ret < 0 {
171 return Err(Error::last_os_error());
172 }
173 Ok(())
174}
175
176#[repr(C)]
177struct UffdioRange {

Calls 1

as_raw_fdMethod · 0.45