2020-06-08 00:50:38 +00:00
|
|
|
// Copyright © 2019 Intel Corporation
|
|
|
|
//
|
2020-06-26 00:06:14 +00:00
|
|
|
// SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause
|
2020-06-08 00:50:38 +00:00
|
|
|
//
|
2020-06-28 16:32:56 +00:00
|
|
|
// Copyright © 2020, Microsoft Corporation
|
2020-06-08 00:50:38 +00:00
|
|
|
//
|
|
|
|
// Copyright 2018-2019 CrowdStrike, Inc.
|
|
|
|
//
|
2020-06-03 19:23:56 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
//! A generic abstraction around hypervisor functionality
|
|
|
|
//!
|
|
|
|
//! This crate offers a trait abstraction for underlying hypervisors
|
|
|
|
//!
|
|
|
|
//! # Platform support
|
|
|
|
//!
|
|
|
|
//! - x86_64
|
|
|
|
//! - arm64
|
|
|
|
//!
|
|
|
|
|
2020-08-05 10:00:56 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate anyhow;
|
|
|
|
#[macro_use]
|
|
|
|
extern crate log;
|
2020-06-02 21:24:33 +00:00
|
|
|
extern crate serde;
|
|
|
|
extern crate serde_derive;
|
|
|
|
extern crate serde_json;
|
|
|
|
extern crate thiserror;
|
|
|
|
|
2020-06-03 19:23:56 +00:00
|
|
|
/// KVM implementation module
|
|
|
|
pub mod kvm;
|
|
|
|
|
2020-06-03 19:59:49 +00:00
|
|
|
/// Hypevisor related module
|
|
|
|
pub mod hypervisor;
|
|
|
|
|
2020-06-03 19:58:00 +00:00
|
|
|
/// Vm related module
|
|
|
|
pub mod vm;
|
|
|
|
|
2020-06-03 20:09:39 +00:00
|
|
|
/// Architecture specific definitions
|
|
|
|
pub mod arch;
|
|
|
|
|
2020-06-03 19:23:56 +00:00
|
|
|
/// CPU related module
|
|
|
|
mod cpu;
|
|
|
|
|
2020-07-16 14:50:36 +00:00
|
|
|
/// Device related module
|
|
|
|
mod device;
|
|
|
|
|
2020-06-03 19:59:49 +00:00
|
|
|
pub use crate::hypervisor::{Hypervisor, HypervisorError};
|
2020-07-03 14:27:53 +00:00
|
|
|
pub use cpu::{HypervisorCpuError, Vcpu, VmExit};
|
2020-07-16 14:50:36 +00:00
|
|
|
pub use device::{Device, HypervisorDeviceError};
|
2020-06-03 19:23:56 +00:00
|
|
|
pub use kvm::*;
|
2020-06-03 20:09:39 +00:00
|
|
|
pub use vm::{DataMatch, HypervisorVmError, Vm};
|
2020-07-14 11:34:42 +00:00
|
|
|
|
|
|
|
use std::sync::Arc;
|
|
|
|
pub fn new() -> std::result::Result<Arc<dyn Hypervisor>, HypervisorError> {
|
|
|
|
#[cfg(feature = "kvm")]
|
|
|
|
let hv = kvm::KvmHypervisor::new()?;
|
|
|
|
|
|
|
|
Ok(Arc::new(hv))
|
|
|
|
}
|