From 091d408a87d0f73f1c4e0166849ca9a566f005e0 Mon Sep 17 00:00:00 2001 From: johannst Date: Wed, 15 Nov 2023 21:40:27 +0000 Subject: deploy: f52d556e0e1bf2350b3b42cff198550a267ceb0b --- src/kvm_rs/kvm.rs.html | 256 ++++++++++++++++++++++++------------------------- 1 file changed, 124 insertions(+), 132 deletions(-) (limited to 'src/kvm_rs/kvm.rs.html') diff --git a/src/kvm_rs/kvm.rs.html b/src/kvm_rs/kvm.rs.html index 91ed733..557c8d0 100644 --- a/src/kvm_rs/kvm.rs.html +++ b/src/kvm_rs/kvm.rs.html @@ -1,155 +1,147 @@ -kvm.rs - source -
1
-2
-3
-4
-5
-6
-7
-8
-9
-10
-11
-12
-13
-14
-15
-16
-17
-18
-19
-20
-21
-22
-23
-24
-25
-26
-27
-28
-29
-30
-31
-32
-33
-34
-35
-36
-37
-38
-39
-40
-41
-42
-43
-44
-45
-46
-47
-48
-49
-50
-51
-52
-53
-54
-55
-56
-57
-58
-59
-60
-61
-62
-63
-64
-65
-66
-67
-68
-69
-70
-71
-72
-73
-
//! KVM system ioctls.
+kvm.rs - source
1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+
//! KVM system ioctls.
 
-use std::fs;
-use std::io;
-use std::os::unix::io::FromRawFd;
+use std::fs;
+use std::io;
+use std::os::unix::io::FromRawFd;
 
-use crate::cap::{CapBool, CapInt};
-use crate::vm::Vm;
-use crate::{ioctl, kvm_sys, libcret};
+use crate::cap::{CapBool, CapInt};
+use crate::vm::Vm;
+use crate::{ioctl, kvm_sys, libcret};
 
-/// Wrapper for `/dev/kvm` ioctls.
-///
-/// Representation of the file descriptor obtained by opening `/dev/kvm`.
-/// This wrapper provides access to the `system ioctls` as described in [KVM API][kvm].
-///
-/// [kvm]: https://www.kernel.org/doc/html/latest/virt/kvm/api.html#general-description
-pub struct Kvm {
-    kvm: fs::File,
+/// Wrapper for `/dev/kvm` ioctls.
+///
+/// Representation of the file descriptor obtained by opening `/dev/kvm`.
+/// This wrapper provides access to the `system ioctls` as described in [KVM API][kvm].
+///
+/// [kvm]: https://www.kernel.org/doc/html/latest/virt/kvm/api.html#general-description
+pub struct Kvm {
+    kvm: fs::File,
 }
 
-impl Kvm {
-    /// Open the `/dev/kvm` device.
-    pub fn new() -> io::Result<Kvm> {
-        let kvm = libcret(unsafe {
-            libc::open("/dev/kvm\0".as_ptr().cast(), libc::O_RDWR | libc::O_CLOEXEC)
+impl Kvm {
+    /// Open the `/dev/kvm` device.
+    pub fn new() -> io::Result<Kvm> {
+        let kvm = libcret(unsafe {
+            libc::open("/dev/kvm\0".as_ptr().cast(), libc::O_RDWR | libc::O_CLOEXEC)
         })
-        .map(|fd| unsafe { fs::File::from_raw_fd(fd) })?;
+        .map(|fd| unsafe { fs::File::from_raw_fd(fd) })?;
 
         assert_eq!(
-            kvm_sys::KVM_API_VERSION,
-            ioctl(&kvm, kvm_sys::KVM_GET_API_VERSION, 0)?
-        );
+            kvm_sys::KVM_API_VERSION,
+            ioctl(&kvm, kvm_sys::KVM_GET_API_VERSION, 0)?
+        );
 
-        Ok(Kvm { kvm })
+        Ok(Kvm { kvm })
     }
 
-    fn get_vpcu_mmap_size(&self) -> io::Result<usize> {
-        ioctl(&self.kvm, kvm_sys::KVM_GET_VCPU_MMAP_SIZE, 0).map(|size| size as usize)
+    fn get_vpcu_mmap_size(&self) -> io::Result<usize> {
+        ioctl(&self.kvm, kvm_sys::KVM_GET_VCPU_MMAP_SIZE, 0).map(|size| size as usize)
     }
 
-    /// Create a new virtual machine with the [`KVM_CREATE_VM`][kvm-create-vm] ioctl.
-    /// Returns a wrapper [`vm::Vm`][crate::vm::Vm] representing the VM.
-    ///
-    /// [kvm-create-vm]: https://www.kernel.org/doc/html/latest/virt/kvm/api.html#kvm-create-vm
-    pub fn create_vm(&self) -> io::Result<Vm> {
-        let vm = ioctl(&self.kvm, kvm_sys::KVM_CREATE_VM, 0 /* machine id */)
-            .map(|fd| unsafe { fs::File::from_raw_fd(fd) })?;
+    /// Create a new virtual machine with the [`KVM_CREATE_VM`][kvm-create-vm] ioctl.
+    /// Returns a wrapper [`vm::Vm`][crate::vm::Vm] representing the VM.
+    ///
+    /// [kvm-create-vm]: https://www.kernel.org/doc/html/latest/virt/kvm/api.html#kvm-create-vm
+    pub fn create_vm(&self) -> io::Result<Vm> {
+        let vm = ioctl(&self.kvm, kvm_sys::KVM_CREATE_VM, 0 /* machine id */)
+            .map(|fd| unsafe { fs::File::from_raw_fd(fd) })?;
 
-        let vcpu_mmap_size = self.get_vpcu_mmap_size()?;
+        let vcpu_mmap_size = self.get_vpcu_mmap_size()?;
 
-        Ok(Vm::new(vm, vcpu_mmap_size))
+        Ok(Vm::new(vm, vcpu_mmap_size))
     }
 
-    /// Check availability of an extension with the [`KVM_CHECK_EXTENSION`][kvm-check-extension]
-    /// ioctl.
-    ///
-    /// [kvm-check-extension]: https://www.kernel.org/doc/html/latest/virt/kvm/api.html#kvm-check-extension
-    pub fn check_extenstion(&self, cap: CapBool) -> bool {
-        let ret = ioctl(&self.kvm, kvm_sys::KVM_CHECK_EXTENSION, cap.into());
+    /// Check availability of an extension with the [`KVM_CHECK_EXTENSION`][kvm-check-extension]
+    /// ioctl.
+    ///
+    /// [kvm-check-extension]: https://www.kernel.org/doc/html/latest/virt/kvm/api.html#kvm-check-extension
+    pub fn check_extenstion(&self, cap: CapBool) -> bool {
+        let ret = ioctl(&self.kvm, kvm_sys::KVM_CHECK_EXTENSION, cap.into());
 
-        matches!(ret, Ok(ret) if ret > 0)
+        matches!(ret, Ok(ret) if ret > 0)
     }
 
-    /// Check availability of an extension with the [`KVM_CHECK_EXTENSION`][kvm-check-extension]
-    /// ioctl.
-    ///
-    /// [kvm-check-extension]: https://www.kernel.org/doc/html/latest/virt/kvm/api.html#kvm-check-extension
-    pub fn check_extenstion_int(&self, cap: CapInt) -> i32 {
-        let ret = ioctl(&self.kvm, kvm_sys::KVM_CHECK_EXTENSION, cap.into());
+    /// Check availability of an extension with the [`KVM_CHECK_EXTENSION`][kvm-check-extension]
+    /// ioctl.
+    ///
+    /// [kvm-check-extension]: https://www.kernel.org/doc/html/latest/virt/kvm/api.html#kvm-check-extension
+    pub fn check_extenstion_int(&self, cap: CapInt) -> i32 {
+        let ret = ioctl(&self.kvm, kvm_sys::KVM_CHECK_EXTENSION, cap.into());
 
-        ret.unwrap_or(0)
+        ret.unwrap_or(0)
     }
 }
-
-
- \ No newline at end of file + \ No newline at end of file -- cgit v1.2.3