[][src]Struct kvm_ioctls::CpuId

pub struct CpuId { /* fields omitted */ }

Wrapper over the kvm_cpuid2 structure.

The structure has a zero length array at the end, hidden behind bounds check.

Methods

impl CpuId[src]

pub fn new(array_len: usize) -> CpuId[src]

Creates a new CpuId structure that contains at most array_len KVM CPUID entries.

Arguments

  • array_len - Maximum number of CPUID entries.

Example

use kvm_ioctls::CpuId;
let cpu_id = CpuId::new(32);

pub fn from_entries(entries: &[kvm_cpuid_entry2]) -> CpuId[src]

Creates a new CpuId structure based on a supplied vector of kvm_cpuid_entry2.

Arguments

  • entries - The vector of kvm_cpuid_entry2 entries.

Example

extern crate kvm_bindings;

use kvm_bindings::kvm_cpuid_entry2;
use kvm_ioctls::CpuId;
// Create a Cpuid to hold one entry.
let mut cpuid = CpuId::new(1);
let mut entries = cpuid.mut_entries_slice().to_vec();
let new_entry = kvm_cpuid_entry2 {
    function: 0x4,
    index: 0,
    flags: 1,
    eax: 0b1100000,
    ebx: 0,
    ecx: 0,
    edx: 0,
    padding: [0, 0, 0],
};
entries.insert(0, new_entry);
cpuid = CpuId::from_entries(&entries);

pub fn mut_entries_slice(&mut self) -> &mut [kvm_cpuid_entry2][src]

Returns the mutable entries slice so they can be modified before passing to the VCPU.

Example

use kvm_ioctls::{CpuId, Kvm, MAX_KVM_CPUID_ENTRIES};
let kvm = Kvm::new().unwrap();
let mut cpuid = kvm.get_supported_cpuid(MAX_KVM_CPUID_ENTRIES).unwrap();
let cpuid_entries = cpuid.mut_entries_slice();

pub fn as_ptr(&self) -> *const kvm_cpuid2[src]

Get a pointer so it can be passed to the kernel. Using this pointer is unsafe.

pub fn as_mut_ptr(&mut self) -> *mut kvm_cpuid2[src]

Get a mutable pointer so it can be passed to the kernel. Using this pointer is unsafe.

Trait Implementations

impl Clone for CpuId[src]

default fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl Send for CpuId

impl Sync for CpuId

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.