mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-01 02:55:45 +00:00
0921cfb8f8
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
34 lines
565 B
Rust
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(())
|
|
}
|