Skip to main content

VirtualCpu

Struct VirtualCpu 

Source
pub struct VirtualCpu { /* private fields */ }
Expand description

vCPU for a Virtual Machine.

Implementations§

Source§

impl VirtualCpu

Source

pub fn get_handle(&self) -> hv_vcpu_t

Gets vCPU handle.

Source

pub fn get_register(&mut self, register: Register) -> Result<u64>

Gets a register value.

This should be called in the thread that will run the vCPU as it’s resident inside it.

Source

pub fn set_register(&mut self, register: Register, value: u64) -> Result<()>

Sets a register value.

This should be called in the thread that will run the vCPU as it’s resident inside it.

Source

pub fn get_system_register(&mut self, register: SystemRegister) -> Result<u64>

Gets a system register value.

This should be called in the thread that will run the vCPU as it’s resident inside it.

Source

pub fn set_system_register( &mut self, register: SystemRegister, value: u64, ) -> Result<()>

Sets a system register value.

This should be called in the thread that will run the vCPU as it’s resident inside it.

Source

pub fn get_pending_interrupt( &mut self, interrupt_type: InterruptType, ) -> Result<bool>

Gets pending interrupts.

This should be called in the thread that will run the vCPU as it’s resident inside it.

Source

pub fn set_pending_interrupt( &mut self, interrupt_type: InterruptType, value: bool, ) -> Result<()>

Sets pending interrupts.

This should be called in the thread that will run the vCPU as it’s resident inside it. Pending interrupts automatically get cleared after vCPU run and must be resetup before every call to run.

Source

pub fn get_trap_debug_exceptions(&mut self) -> Result<bool>

Gets whether debug exceptions exit the vCPU.

This should be called in the thread that will run the vCPU as it’s resident inside it.

Source

pub fn set_trap_debug_exceptions(&mut self, value: bool) -> Result<()>

Gets whether debug exceptions exit the vCPU.

This should be called in the thread that will run the vCPU as it’s resident inside it.

Source

pub fn get_trap_debug_reg_accesses(&mut self) -> Result<bool>

Gets whether debug-register accesses exit the vCPU.

This should be called in the thread that will run the vCPU as it’s resident inside it.

Source

pub fn set_trap_debug_reg_accesses(&mut self, value: bool) -> Result<()>

Gets whether debug-register accesses exit the vCPU.

This should be called in the thread that will run the vCPU as it’s resident inside it.

Source

pub fn run(&mut self) -> Result<VirtualCpuExitReason>

Runs the vCPU.

This should be called in the thread that will run the vCPU as it’s resident inside it.

Source

pub fn exit(&mut self) -> Result<()>

Forces exit the vCPU.

Source

pub fn get_exec_time(&mut self) -> Result<u64>

Gets cumulative execution time of a vCPU in mach_absolute_time().

This should be called in the thread that will run the vCPU as it’s resident inside it.

Source

pub fn get_vtimer_mask(&mut self) -> Result<bool>

Gets Virtual Timer mask.

Source

pub fn set_vtimer_mask(&mut self, value: bool) -> Result<()>

Sets Virtual Timer mask.

Source

pub fn get_vtimer_offset(&mut self) -> Result<u64>

Gets Virtual Timer offset (CNTVOFF_EL2).

Source

pub fn set_vtimer_offset(&mut self, value: u64) -> Result<()>

Sets Virtual Timer offset (CNTVOFF_EL2).

Trait Implementations§

Source§

impl Debug for VirtualCpu

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for VirtualCpu

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.