Struct kvm::RunnableVcpu

source ·
pub struct RunnableVcpu {
    pub(crate) vcpu: Vcpu,
    pub(crate) phantom: PhantomData<*mut u8>,
}
Expand description

A Vcpu that has a thread and can be run. Created by calling to_runnable on a Vcpu. Implements Deref to a Vcpu so all Vcpu methods are usable, with the addition of the run function to execute the guest.

Fields§

§vcpu: Vcpu§phantom: PhantomData<*mut u8>

Implementations§

source§

impl RunnableVcpu

source

pub fn run(&self) -> Result<VcpuExit>

Runs the VCPU until it exits, returning the reason for the exit.

Note that the state of the VCPU and associated VM must be setup first for this to do anything useful.

Methods from Deref<Target = Vcpu>§

source

pub fn set_data(&self, data: &[u8]) -> Result<()>

Sets the data received by a mmio read, ioport in, or hypercall instruction.

This function should be called after Vcpu::run returns an VcpuExit::IoIn, VcpuExit::MmioRead, or ’VcpuExit::HypervHcall`.

source

pub fn set_immediate_exit(&self, exit: bool)

Sets the bit that requests an immediate exit.

source

pub fn get_regs(&self) -> Result<kvm_regs>

Gets the VCPU registers.

source

pub fn set_regs(&self, regs: &kvm_regs) -> Result<()>

Sets the VCPU registers.

source

pub fn get_sregs(&self) -> Result<kvm_sregs>

Gets the VCPU special registers.

source

pub fn set_sregs(&self, sregs: &kvm_sregs) -> Result<()>

Sets the VCPU special registers.

source

pub fn get_fpu(&self) -> Result<kvm_fpu>

Gets the VCPU FPU registers.

source

pub fn set_fpu(&self, fpu: &kvm_fpu) -> Result<()>

X86 specific call to setup the FPU

See the documentation for KVM_SET_FPU.

source

pub fn get_debugregs(&self) -> Result<kvm_debugregs>

Gets the VCPU debug registers.

source

pub fn set_debugregs(&self, dregs: &kvm_debugregs) -> Result<()>

Sets the VCPU debug registers

source

pub fn get_xcrs(&self) -> Result<kvm_xcrs>

Gets the VCPU extended control registers

source

pub fn set_xcrs(&self, xcrs: &kvm_xcrs) -> Result<()>

Sets the VCPU extended control registers

source

pub fn get_msrs(&self, msr_entries: &mut Vec<kvm_msr_entry>) -> Result<()>

X86 specific call to get the MSRS

See the documentation for KVM_SET_MSRS.

source

pub fn set_msrs(&self, msrs: &kvm_msrs) -> Result<()>

X86 specific call to setup the MSRS

See the documentation for KVM_SET_MSRS.

source

pub fn set_cpuid2(&self, cpuid: &CpuId) -> Result<()>

X86 specific call to setup the CPUID registers

See the documentation for KVM_SET_CPUID2.

source

pub fn get_hyperv_cpuid(&self) -> Result<CpuId>

X86 specific call to get the system emulated hyper-v CPUID values

source

pub fn get_lapic(&self) -> Result<kvm_lapic_state>

X86 specific call to get the state of the “Local Advanced Programmable Interrupt Controller”.

See the documentation for KVM_GET_LAPIC.

source

pub fn set_lapic(&self, klapic: &kvm_lapic_state) -> Result<()>

X86 specific call to set the state of the “Local Advanced Programmable Interrupt Controller”.

See the documentation for KVM_SET_LAPIC.

source

pub fn get_mp_state(&self) -> Result<kvm_mp_state>

Gets the vcpu’s current “multiprocessing state”.

See the documentation for KVM_GET_MP_STATE. This call can only succeed after a call to Vm::create_irq_chip.

Note that KVM defines the call for both x86 and s390 but we do not expect anyone to run crosvm on s390.

source

pub fn set_mp_state(&self, state: &kvm_mp_state) -> Result<()>

Sets the vcpu’s current “multiprocessing state”.

See the documentation for KVM_SET_MP_STATE. This call can only succeed after a call to Vm::create_irq_chip.

Note that KVM defines the call for both x86 and s390 but we do not expect anyone to run crosvm on s390.

source

pub fn get_vcpu_events(&self) -> Result<kvm_vcpu_events>

Gets the vcpu’s currently pending exceptions, interrupts, NMIs, etc

See the documentation for KVM_GET_VCPU_EVENTS.

source

pub fn set_vcpu_events(&self, events: &kvm_vcpu_events) -> Result<()>

Sets the vcpu’s currently pending exceptions, interrupts, NMIs, etc

See the documentation for KVM_SET_VCPU_EVENTS.

source

pub unsafe fn kvm_enable_cap(&self, cap: &kvm_enable_cap) -> Result<()>

Enable the specified capability. See documentation for KVM_ENABLE_CAP.

Safety

This function is marked as unsafe because cap may contain values which are interpreted as pointers by the kernel.

source

pub fn set_signal_mask(&self, signals: &[c_int]) -> Result<()>

Specifies set of signals that are blocked during execution of KVM_RUN. Signals that are not blocked will cause KVM_RUN to return with -EINTR.

See the documentation for KVM_SET_SIGNAL_MASK

Trait Implementations§

source§

impl AsRawDescriptor for RunnableVcpu

source§

fn as_raw_descriptor(&self) -> RawDescriptor

Returns the underlying raw descriptor. Read more
source§

impl Deref for RunnableVcpu

§

type Target = Vcpu

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl DerefMut for RunnableVcpu

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl Drop for RunnableVcpu

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> AsRawDescriptors for Twhere T: AsRawDescriptor,

§

fn as_raw_descriptors(&self) -> Vec<i32, Global>

Returns the underlying raw descriptors. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.