From 74d1b6fd9991d1fb7dc19f09b06f7b2277874ece Mon Sep 17 00:00:00 2001 From: johannst Date: Sat, 16 Apr 2022 20:25:59 +0000 Subject: deploy: 38cd31ed203999122c500d389de38bb051ce979e --- src/kvm_rs/lib.rs.html | 53 ++++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 25 deletions(-) (limited to 'src/kvm_rs/lib.rs.html') diff --git a/src/kvm_rs/lib.rs.html b/src/kvm_rs/lib.rs.html index da6a425..7124c68 100644 --- a/src/kvm_rs/lib.rs.html +++ b/src/kvm_rs/lib.rs.html @@ -1,6 +1,9 @@ -lib.rs - source - -
  1
+lib.rs - source
+    
+    
  1
   2
   3
   4
@@ -166,8 +169,7 @@
 164
 165
 166
-
-use std::convert::{AsMut, AsRef};
+
use std::convert::{AsMut, AsRef};
 use std::io;
 use std::ops;
 use std::os::unix::io::AsRawFd;
@@ -185,7 +187,7 @@
 
 /// Helper to turn libc return values into an [io::Result](std::io::Result). Returns
 /// [`Error::last_os_error`](std::io::Error::last_os_error) if `ret < 0`.
-fn libcret(ret: libc::c_int) -> io::Result<libc::c_int> {
+fn libcret(ret: libc::c_int) -> io::Result<libc::c_int> {
     if ret < 0 {
         Err(io::Error::last_os_error())
     } else {
@@ -195,7 +197,7 @@
 
 /// Wrapper of `libc::ioctl` for KVM ioctls with one argument and returning an
 /// [`io::Result`](std::io::Result).
-fn ioctl<F: AsRawFd>(fd: &F, cmd: u64, arg: u64) -> io::Result<libc::c_int> {
+fn ioctl<F: AsRawFd>(fd: &F, cmd: u64, arg: u64) -> io::Result<libc::c_int> {
     libcret(unsafe { libc::ioctl(fd.as_raw_fd(), cmd, arg) })
 }
 
@@ -206,13 +208,13 @@
 /// Memory can be mapped into a guest VM with
 /// [`Vm::set_user_memory_region`](crate::vm::Vm::set_user_memory_region).
 pub struct UserMem {
-    ptr: *mut u8,
+    ptr: *mut u8,
     len: usize,
 }
 
 impl UserMem {
     /// Allocate a zero-initialized memory region of `len` bytes.
-    pub fn new(len: usize) -> io::Result<UserMem> {
+    pub fn new(len: usize) -> io::Result<UserMem> {
         let ptr = unsafe {
             libc::mmap(
                 std::ptr::null_mut(),
@@ -224,7 +226,7 @@
             )
         };
 
-        if ptr == libc::MAP_FAILED {
+        if ptr == libc::MAP_FAILED {
             Err(io::Error::last_os_error())
         } else {
             Ok(UserMem {
@@ -240,7 +242,7 @@
     /// # Panics
     ///
     /// Panics if `init_from` is larger than the memory size `len`.
-    pub fn with_init(len: usize, init_from: &[u8]) -> io::Result<UserMem> {
+    pub fn with_init(len: usize, init_from: &[u8]) -> io::Result<UserMem> {
         assert!(len >= init_from.len());
 
         let mut m = UserMem::new(len)?;
@@ -253,7 +255,7 @@
     /// # Panics
     ///
     /// Panics if `addr + data.len` is larger than the memory size `len`.
-    pub fn load(&mut self, addr: PhysAddr, data: &[u8]) {
+    pub fn load(&mut self, addr: PhysAddr, data: &[u8]) {
         assert!(self.len >= addr.0 as usize + data.len());
 
         let addr = addr.0 as usize;
@@ -263,19 +265,19 @@
 
 impl ops::Drop for UserMem {
     /// Free underlying memory.
-    fn drop(&mut self) {
+    fn drop(&mut self) {
         unsafe { libc::munmap(self.ptr.cast(), self.len) };
     }
 }
 
 impl AsRef<[u8]> for UserMem {
-    fn as_ref(&self) -> &[u8] {
+    fn as_ref(&self) -> &[u8] {
         unsafe { std::slice::from_raw_parts(self.ptr, self.len) }
     }
 }
 
 impl AsMut<[u8]> for UserMem {
-    fn as_mut(&mut self) -> &mut [u8] {
+    fn as_mut(&mut self) -> &mut [u8] {
         unsafe { std::slice::from_raw_parts_mut(self.ptr, self.len) }
     }
 }
@@ -285,14 +287,14 @@
 ///
 /// [kvm_run]: https://www.kernel.org/doc/html/latest/virt/kvm/api.html#the-kvm-run-structure
 struct KvmRun {
-    ptr: *mut kvm_sys::kvm_run,
+    ptr: *mut kvm_sys::kvm_run,
     len: usize,
 }
 
 impl KvmRun {
     /// Mmap the `struct kvm_run` for a given `VCPU` referenced by the argument file descriptor
     /// `vcpu`.
-    fn new<F: AsRawFd>(vcpu: &F, len: usize) -> io::Result<KvmRun> {
+    fn new<F: AsRawFd>(vcpu: &F, len: usize) -> io::Result<KvmRun> {
         let ptr = unsafe {
             libc::mmap(
                 std::ptr::null_mut(),
@@ -304,7 +306,7 @@
             )
         };
 
-        if ptr == libc::MAP_FAILED {
+        if ptr == libc::MAP_FAILED {
             Err(io::Error::last_os_error())
         } else {
             Ok(KvmRun {
@@ -317,21 +319,22 @@
 
 impl ops::Drop for KvmRun {
     /// Munmap the mmaped `struct kvm_run`.
-    fn drop(&mut self) {
+    fn drop(&mut self) {
         unsafe { libc::munmap(self.ptr.cast(), self.len) };
     }
 }
 
 impl AsRef<kvm_sys::kvm_run> for KvmRun {
-    fn as_ref(&self) -> &kvm_sys::kvm_run {
-        unsafe { &*(self.ptr as *const kvm_sys::kvm_run) }
+    fn as_ref(&self) -> &kvm_sys::kvm_run {
+        unsafe { &*(self.ptr as *const kvm_sys::kvm_run) }
     }
 }
 
 impl AsMut<kvm_sys::kvm_run> for KvmRun {
-    fn as_mut(&mut self) -> &mut kvm_sys::kvm_run {
-        unsafe { &mut *(self.ptr as *mut kvm_sys::kvm_run) }
+    fn as_mut(&mut self) -> &mut kvm_sys::kvm_run {
+        unsafe { &mut *(self.ptr as *mut kvm_sys::kvm_run) }
     }
 }
-
-
\ No newline at end of file +
+
+ \ No newline at end of file -- cgit v1.2.3