cloud-hypervisor/vmm/src/lib.rs
Samuel Ortiz 0921cfb8f8 vmm: Basic Vcpu implementation
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-05-08 08:40:38 +02:00

34 lines
565 B
Rust

// Copyright © 2019 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
//
extern crate kvm_ioctls;
use kvm_ioctls::*;
use std::path::Path;
pub mod vm;
use self::vm::{Result, Vm};
struct Vmm {
kvm: Kvm,
}
impl Vmm {
fn new() -> Result<Self> {
let kvm = Kvm::new().expect("new KVM instance creation failed");
Ok(Vmm { kvm })
}
}
pub fn boot_kernel(kernel: &Path) -> Result<()> {
let vmm = Vmm::new()?;
let mut vm = Vm::new(&vmm.kvm, kernel)?;
let entry = vm.load_kernel()?;
vm.start(entry)?;
Ok(())
}