Files
cloud-hypervisor/vmm/src/lib.rs
Samuel Ortiz 1853b350ee cloud-hypervisor: Add devices crate
Based on the Firecracker devices crate from commit 9cdb5b2.

It is a trimmed down version compared to the Firecracker one, to remove
a bunch of pulled dependencies (logger, metrics, rate limiter, etc...).

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2019-05-08 08:40:42 +02:00

34 lines
558 B
Rust

// Copyright © 2019 Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0
//
extern crate kvm_ioctls;
use kvm_ioctls::*;
pub mod vm;
use self::vm::{Result, Vm, VmConfig};
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(config: VmConfig) -> Result<()> {
let vmm = Vmm::new()?;
let mut vm = Vm::new(&vmm.kvm, config)?;
let entry = vm.load_kernel()?;
vm.start(entry)?;
Ok(())
}