pub struct MiniVm {
pub kvm: Kvm,
pub vm: VmFd,
pub mem: Arc<MappedMemory>,
pub vcpus: Vec<VcpuFd>,
/* private fields */
}Expand description
A minimal long-mode VM.
Fields§
§kvm: KvmThe /dev/kvm handle.
vm: VmFdThe VM.
mem: Arc<MappedMemory>Guest RAM.
vcpus: Vec<VcpuFd>The vCPUs.
Implementations§
Source§impl MiniVm
impl MiniVm
Sourcepub fn new(mem_mib: usize, vcpus: u32) -> Result<MiniVm>
pub fn new(mem_mib: usize, vcpus: u32) -> Result<MiniVm>
Creates a VM with mem_mib MiB of RAM and vcpus vCPUs, all in
64-bit mode at MiniVm::CODE with interrupts disabled.
Sourcepub fn reset_vcpu(&mut self, idx: usize, rip: u64, rsp: u64) -> Result<()>
pub fn reset_vcpu(&mut self, idx: usize, rip: u64, rsp: u64) -> Result<()>
Puts vCPU idx in 64-bit mode at rip with stack rsp.
Sourcepub fn set_gate(&self, vector: u8, handler: u64)
pub fn set_gate(&self, vector: u8, handler: u64)
Points IDT vector vector at handler (a 64-bit interrupt gate).
Sourcepub fn unmap_page(&self, la: u64)
pub fn unmap_page(&self, la: u64)
Marks the 4 KiB page at la (which must be in 0x20_0000..0x40_0000)
not present.
Sourcepub fn set_msrs(&self, entries: &[(u32, u64)]) -> Result<()>
pub fn set_msrs(&self, entries: &[(u32, u64)]) -> Result<()>
Sets MSRs on every vCPU (for example LSTAR for SYSCALL).
Sourcepub fn memory(&self) -> Arc<dyn GuestMemory> ⓘ
pub fn memory(&self) -> Arc<dyn GuestMemory> ⓘ
Guest RAM as a shareable GuestMemory.
Trait Implementations§
Auto Trait Implementations§
impl !Sync for MiniVm
impl Freeze for MiniVm
impl RefUnwindSafe for MiniVm
impl Unpin for MiniVm
impl UnsafeUnpin for MiniVm
impl UnwindSafe for MiniVm
Blanket Implementations§
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
Mutably borrows from an owned value. Read more