Struct hypervisor::kvm::KvmVcpu
source · pub struct KvmVcpu {
kvm: Kvm,
vm: SafeDescriptor,
vcpu: File,
id: usize,
cap_kvmclock_ctrl: bool,
run_mmap: Arc<MemoryMapping>,
}
Expand description
A wrapper around using a KVM Vcpu.
Fields§
§kvm: Kvm
§vm: SafeDescriptor
§vcpu: File
§id: usize
§cap_kvmclock_ctrl: bool
§run_mmap: Arc<MemoryMapping>
Implementations§
source§impl KvmVcpu
impl KvmVcpu
sourcepub fn system_event_reset(&self, _event_flags: u64) -> Result<VcpuExit>
pub fn system_event_reset(&self, _event_flags: u64) -> Result<VcpuExit>
Handles a KVM_EXIT_SYSTEM_EVENT
with event type KVM_SYSTEM_EVENT_RESET
with the given
event flags and returns the appropriate VcpuExit
value for the run loop to handle.
sourcefn xsave_size(&self) -> Result<usize>
fn xsave_size(&self) -> Result<usize>
Gets the Xsave size by checking the extension KVM_CAP_XSAVE2.
Size should always be >=0. If size is negative, an error occurred. If size <= 4096, XSAVE2 is not supported by the CPU or the kernel. KVM_XSAVE_MAX_SIZE is returned (4096). Otherwise, the size will be returned.
pub(crate) fn handle_vm_exit_arch(&self, run: &mut kvm_run) -> Option<VcpuExit>
source§impl KvmVcpu
impl KvmVcpu
sourcepub fn get_lapic(&self) -> Result<kvm_lapic_state>
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.
sourcepub fn set_lapic(&self, klapic: &kvm_lapic_state) -> Result<()>
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.
sourcepub fn get_apic_base(&self) -> Result<u64>
pub fn get_apic_base(&self) -> Result<u64>
X86 specific call to get the value of the APIC_BASE MSR.
See the documentation for The kvm_run structure, and for KVM_GET_LAPIC.
sourcepub fn set_apic_base(&self, apic_base: u64) -> Result<()>
pub fn set_apic_base(&self, apic_base: u64) -> Result<()>
X86 specific call to set the value of the APIC_BASE MSR.
See the documentation for The kvm_run structure, and for KVM_GET_LAPIC.
sourcepub fn get_interrupt_bitmap(&self) -> Result<[u64; 4]>
pub fn get_interrupt_bitmap(&self) -> Result<[u64; 4]>
Call to get pending interrupts acknowledged by the APIC but not yet injected into the CPU.
See the documentation for KVM_GET_SREGS.
sourcepub fn set_interrupt_bitmap(&self, interrupt_bitmap: [u64; 4]) -> Result<()>
pub fn set_interrupt_bitmap(&self, interrupt_bitmap: [u64; 4]) -> Result<()>
Call to set pending interrupts acknowledged by the APIC but not yet injected into the CPU.
See the documentation for KVM_GET_SREGS.
source§impl KvmVcpu
impl KvmVcpu
sourcepub fn get_mp_state(&self) -> Result<kvm_mp_state>
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.
sourcepub fn set_mp_state(&self, state: &kvm_mp_state) -> Result<()>
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.
Trait Implementations§
source§impl AsRawDescriptor for KvmVcpu
impl AsRawDescriptor for KvmVcpu
source§fn as_raw_descriptor(&self) -> RawDescriptor
fn as_raw_descriptor(&self) -> RawDescriptor
source§impl Vcpu for KvmVcpu
impl Vcpu for KvmVcpu
source§fn as_vcpu(&self) -> &dyn Vcpu
fn as_vcpu(&self) -> &dyn Vcpu
Vcpu
.source§fn set_immediate_exit(&self, exit: bool)
fn set_immediate_exit(&self, exit: bool)
source§fn signal_handle(&self) -> VcpuSignalHandle
fn signal_handle(&self) -> VcpuSignalHandle
run()
from a signal
handler.source§fn on_suspend(&self) -> Result<()>
fn on_suspend(&self) -> Result<()>
source§unsafe fn enable_raw_capability(&self, cap: u32, args: &[u64; 4]) -> Result<()>
unsafe fn enable_raw_capability(&self, cap: u32, args: &[u64; 4]) -> Result<()>
cap
is a constant defined by the
hypervisor API (e.g., kvm.h). args
are the arguments for enabling the feature, if any. Read moresource§fn run(&mut self) -> Result<VcpuExit>
fn run(&mut self) -> Result<VcpuExit>
source§impl VcpuX86_64 for KvmVcpu
impl VcpuX86_64 for KvmVcpu
source§fn interrupt(&self, irq: u8) -> Result<()>
fn interrupt(&self, irq: u8) -> Result<()>
Use the KVM_INTERRUPT ioctl to inject the specified interrupt vector.
While this ioctl exists on PPC and MIPS as well as x86, the semantics are different and ChromeOS doesn’t support PPC or MIPS.
source§fn get_xsave(&self) -> Result<Xsave>
fn get_xsave(&self) -> Result<Xsave>
If the VM reports using XSave2, the function will call XSave2.
source§fn handle_cpuid(&mut self, _entry: &CpuIdEntry) -> Result<()>
fn handle_cpuid(&mut self, _entry: &CpuIdEntry) -> Result<()>
KVM does not support the VcpuExit::Cpuid exit type.
source§fn set_interrupt_window_requested(&self, requested: bool)
fn set_interrupt_window_requested(&self, requested: bool)
source§fn ready_for_interrupt(&self) -> bool
fn ready_for_interrupt(&self) -> bool
source§fn inject_nmi(&self) -> Result<()>
fn inject_nmi(&self) -> Result<()>
source§fn set_xsave(&self, xsave: &Xsave) -> Result<()>
fn set_xsave(&self, xsave: &Xsave) -> Result<()>
source§fn get_interrupt_state(&self) -> Result<Value>
fn get_interrupt_state(&self) -> Result<Value>
source§fn set_interrupt_state(&self, data: Value) -> Result<()>
fn set_interrupt_state(&self, data: Value) -> Result<()>
source§fn get_debugregs(&self) -> Result<DebugRegs>
fn get_debugregs(&self) -> Result<DebugRegs>
source§fn set_debugregs(&self, dregs: &DebugRegs) -> Result<()>
fn set_debugregs(&self, dregs: &DebugRegs) -> Result<()>
source§fn set_xcr(&self, xcr_index: u32, value: u64) -> Result<()>
fn set_xcr(&self, xcr_index: u32, value: u64) -> Result<()>
source§fn get_msr(&self, msr_index: u32) -> Result<u64>
fn get_msr(&self, msr_index: u32) -> Result<u64>
source§fn get_all_msrs(&self) -> Result<BTreeMap<u32, u64>>
fn get_all_msrs(&self) -> Result<BTreeMap<u32, u64>>
source§fn set_msr(&self, msr_index: u32, value: u64) -> Result<()>
fn set_msr(&self, msr_index: u32, value: u64) -> Result<()>
source§fn set_cpuid(&self, cpuid: &CpuId) -> Result<()>
fn set_cpuid(&self, cpuid: &CpuId) -> Result<()>
source§fn set_guest_debug(
&self,
addrs: &[GuestAddress],
enable_singlestep: bool
) -> Result<()>
fn set_guest_debug( &self, addrs: &[GuestAddress], enable_singlestep: bool ) -> Result<()>
source§fn restore_timekeeping(
&self,
_host_tsc_reference_moment: u64,
_tsc_offset: u64
) -> Result<()>
fn restore_timekeeping( &self, _host_tsc_reference_moment: u64, _tsc_offset: u64 ) -> Result<()>
source§fn get_tsc_offset(&self) -> Result<u64>
fn get_tsc_offset(&self) -> Result<u64>
source§fn set_tsc_offset(&self, offset: u64) -> Result<()>
fn set_tsc_offset(&self, offset: u64) -> Result<()>
source§fn set_tsc_value(&self, value: u64) -> Result<()>
fn set_tsc_value(&self, value: u64) -> Result<()>
source§fn snapshot(&self) -> Result<VcpuSnapshot>
fn snapshot(&self) -> Result<VcpuSnapshot>
fn restore( &mut self, snapshot: &VcpuSnapshot, host_tsc_reference_moment: u64 ) -> Result<()>
Auto Trait Implementations§
impl RefUnwindSafe for KvmVcpu
impl Send for KvmVcpu
impl Sync for KvmVcpu
impl Unpin for KvmVcpu
impl UnwindSafe for KvmVcpu
Blanket Implementations§
§impl<T> AsRawDescriptors for Twhere
T: AsRawDescriptor,
impl<T> AsRawDescriptors for Twhere
T: AsRawDescriptor,
§fn as_raw_descriptors(&self) -> Vec<i32>
fn as_raw_descriptors(&self) -> Vec<i32>
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.