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/vcpu.rs.html | 63 ++++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 30 deletions(-) (limited to 'src/kvm_rs/vcpu.rs.html') diff --git a/src/kvm_rs/vcpu.rs.html b/src/kvm_rs/vcpu.rs.html index 1efd836..9c0da9c 100644 --- a/src/kvm_rs/vcpu.rs.html +++ b/src/kvm_rs/vcpu.rs.html @@ -1,6 +1,9 @@ -vcpu.rs - source - -
  1
+vcpu.rs - source
+    
+    
  1
   2
   3
   4
@@ -136,15 +139,14 @@
 134
 135
 136
-
-//! VCPU system ioctls.
+
//! VCPU system ioctls.
 
 use std::fs;
 use std::io;
 
 use crate::{ioctl, kvm_sys, KvmRun};
 
-/// Exit reasons for the [`Vcpu::kvm_run`][crate::vcpu::Vcpu::kvm_run] function.
+/// Exit reasons for the [`Vcpu::run`][crate::vcpu::Vcpu::run] function.
 ///
 /// Details for the different exit reasons can be found in the [`kvm_run`
 /// structure][kvm-run-struct] description.
@@ -172,7 +174,7 @@
 }
 
 impl Vcpu {
-    pub(crate) fn new(vcpu: fs::File, kvm_run: KvmRun) -> Vcpu {
+    pub(crate) fn new(vcpu: fs::File, kvm_run: KvmRun) -> Vcpu {
         Vcpu { vcpu, kvm_run }
     }
 
@@ -180,12 +182,12 @@
     /// [`kvm_regs`](crate::kvm_sys::kvm_regs).
     ///
     /// [kvm-get-regs]: https://www.kernel.org/doc/html/latest/virt/kvm/api.html#kvm-get-regs
-    pub fn get_regs(&self) -> io::Result<kvm_sys::kvm_regs> {
+    pub fn get_regs(&self) -> io::Result<kvm_sys::kvm_regs> {
         let mut regs = kvm_sys::kvm_regs::default();
         ioctl(
             &self.vcpu,
             kvm_sys::KVM_GET_REGS,
-            &mut regs as *mut _ as u64,
+            &mut regs as *mut _ as u64,
         )?;
         Ok(regs)
     }
@@ -194,20 +196,20 @@
     /// [`kvm_regs`](crate::kvm_sys::kvm_regs).
     ///
     /// [kvm-set-regs]: https://www.kernel.org/doc/html/latest/virt/kvm/api.html#kvm-set-regs
-    pub fn set_regs(&self, regs: kvm_sys::kvm_regs) -> io::Result<()> {
-        ioctl(&self.vcpu, kvm_sys::KVM_SET_REGS, &regs as *const _ as u64).map(|_| ())
+    pub fn set_regs(&self, regs: kvm_sys::kvm_regs) -> io::Result<()> {
+        ioctl(&self.vcpu, kvm_sys::KVM_SET_REGS, &regs as *const _ as u64).map(|_| ())
     }
 
     /// Get the special registers with the [`KVM_GET_SREGS`][kvm-get-sregs] ioctl in form of
     /// [`kvm_sregs`](crate::kvm_sys::kvm_sregs).
     ///
     /// [kvm-get-sregs]: https://www.kernel.org/doc/html/latest/virt/kvm/api.html#kvm-get-sregs
-    pub fn get_sregs(&self) -> io::Result<kvm_sys::kvm_sregs> {
+    pub fn get_sregs(&self) -> io::Result<kvm_sys::kvm_sregs> {
         let mut sregs = kvm_sys::kvm_sregs::default();
         ioctl(
             &self.vcpu,
             kvm_sys::KVM_GET_SREGS,
-            &mut sregs as *mut _ as u64,
+            &mut sregs as *mut _ as u64,
         )?;
         Ok(sregs)
     }
@@ -216,11 +218,11 @@
     /// [`kvm_sregs`](crate::kvm_sys::kvm_sregs).
     ///
     /// [kvm-set-sregs]: https://www.kernel.org/doc/html/latest/virt/kvm/api.html#kvm-set-sregs
-    pub fn set_sregs(&self, sregs: kvm_sys::kvm_sregs) -> io::Result<()> {
+    pub fn set_sregs(&self, sregs: kvm_sys::kvm_sregs) -> io::Result<()> {
         ioctl(
             &self.vcpu,
             kvm_sys::KVM_SET_SREGS,
-            &sregs as *const _ as u64,
+            &sregs as *const _ as u64,
         )
         .map(|_| ())
     }
@@ -229,18 +231,18 @@
     /// reasons described in [`KvmExit`](crate::vcpu::KvmExit).
     ///
     /// [kvm-run]: https://www.kernel.org/doc/html/latest/virt/kvm/api.html#kvm-run
-    pub fn run(&mut self) -> io::Result<KvmExit<'_>> {
+    pub fn run(&mut self) -> io::Result<KvmExit<'_>> {
         ioctl(&self.vcpu, kvm_sys::KVM_RUN, 0)?;
 
         let kvm_run = self.kvm_run.as_mut();
 
         match kvm_run.exit_reason as u64 {
-            kvm_sys::KVM_EXIT_HLT => Ok(KvmExit::Halt),
-            kvm_sys::KVM_EXIT_IO => {
+            kvm_sys::KVM_EXIT_HLT => Ok(KvmExit::Halt),
+            kvm_sys::KVM_EXIT_IO => {
                 // Safe to use union `io` field, as Kernel instructed us to.
                 let io = unsafe { kvm_run.inner.io };
 
-                let kvm_run_ptr = kvm_run as *mut kvm_sys::kvm_run as *mut u8;
+                let kvm_run_ptr = kvm_run as *mut kvm_sys::kvm_run as *mut u8;
 
                 // Create IO buffer located at `kvm_run + io.offset`.
                 let data = unsafe {
@@ -251,27 +253,28 @@
                 };
 
                 match io.direction as u64 {
-                    kvm_sys::KVM_EXIT_IO_IN => Ok(KvmExit::IoIn(io.port, data)),
-                    kvm_sys::KVM_EXIT_IO_OUT => Ok(KvmExit::IoOut(io.port, data)),
-                    _ => unreachable!(),
+                    kvm_sys::KVM_EXIT_IO_IN => Ok(KvmExit::IoIn(io.port, data)),
+                    kvm_sys::KVM_EXIT_IO_OUT => Ok(KvmExit::IoOut(io.port, data)),
+                    _ => unreachable!(),
                 }
             }
-            kvm_sys::KVM_EXIT_MMIO => {
+            kvm_sys::KVM_EXIT_MMIO => {
                 // Safe to use union `mmio` filed, as Kernel instructed us to.
-                let mmio = unsafe { &mut kvm_run.inner.mmio };
+                let mmio = unsafe { &mut kvm_run.inner.mmio };
                 let len = mmio.len as usize;
 
                 match mmio.is_write {
-                    0 => Ok(KvmExit::MmioRead(mmio.phys_addr, &mut mmio.data[..len])),
-                    1 => Ok(KvmExit::MmioWrite(mmio.phys_addr, &mmio.data[..len])),
-                    _ => unreachable!(),
+                    0 => Ok(KvmExit::MmioRead(mmio.phys_addr, &mut mmio.data[..len])),
+                    1 => Ok(KvmExit::MmioWrite(mmio.phys_addr, &mmio.data[..len])),
+                    _ => unreachable!(),
                 }
             }
-            r @ _ => {
+            r @ _ => {
                 todo!("KVM_EXIT_... (exit_reason={}) not implemented!", r)
             }
         }
     }
 }
-
-
\ No newline at end of file +
+
+ \ No newline at end of file -- cgit v1.2.3