mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
Based on the way KVM_GET_MSRS and KVM_SET_MSRS work, both function are very unlikely to fail, as they simply stop looping through the list of MSRs as soon as getting or setting one fails. This is causing some issues with the snapshot/restore feature, as on some platforms, we only save a subset of the list of MSRs, leading to unproper way of saving the VM. The way to address this issue is by checking the number of MSRs get/set matches the expected amount from the list. In case it does not match, we simply ignore the failing MSR and continue getting/setting the rest of the list. By doing this by iterations, we end up getting/setting as many MSRs as the platform can support. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
61 lines
1.2 KiB
Rust
61 lines
1.2 KiB
Rust
// Copyright © 2019 Intel Corporation
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause
|
|
//
|
|
// Copyright © 2020, Microsoft Corporation
|
|
//
|
|
// Copyright 2018-2019 CrowdStrike, Inc.
|
|
//
|
|
//
|
|
|
|
//! A generic abstraction around hypervisor functionality
|
|
//!
|
|
//! This crate offers a trait abstraction for underlying hypervisors
|
|
//!
|
|
//! # Platform support
|
|
//!
|
|
//! - x86_64
|
|
//! - arm64
|
|
//!
|
|
|
|
#[macro_use]
|
|
extern crate anyhow;
|
|
#[macro_use]
|
|
extern crate log;
|
|
extern crate serde;
|
|
extern crate serde_derive;
|
|
extern crate serde_json;
|
|
extern crate thiserror;
|
|
|
|
/// KVM implementation module
|
|
pub mod kvm;
|
|
|
|
/// Hypevisor related module
|
|
pub mod hypervisor;
|
|
|
|
/// Vm related module
|
|
pub mod vm;
|
|
|
|
/// Architecture specific definitions
|
|
pub mod arch;
|
|
|
|
/// CPU related module
|
|
mod cpu;
|
|
|
|
/// Device related module
|
|
mod device;
|
|
|
|
pub use crate::hypervisor::{Hypervisor, HypervisorError};
|
|
pub use cpu::{HypervisorCpuError, Vcpu, VmExit};
|
|
pub use device::{Device, HypervisorDeviceError};
|
|
pub use kvm::*;
|
|
pub use vm::{DataMatch, HypervisorVmError, Vm};
|
|
|
|
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))
|
|
}
|