hypervisor: Define a VM-Exit abstraction

In order to move the hypervisor specific parts of the VM exit handling
path, we're defining a generic, hypervisor agnostic VM exit enum.

This is what the hypervisor's Vcpu run() call should return when the VM
exit can not be completely handled through the hypervisor specific bits.
For KVM based hypervisors, this means directly forwarding the IO related
exits back to the VMM itself. For other hypervisors that e.g. rely on the
VMM to decode and emulate instructions, this means the decoding itself
would happen in the hypervisor crate exclusively, and the rest of the VM
exit handling would be handled through the VMM device model implementation.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>

Fix test_vm unit test by using the new abstraction and dropping some
dead code.

Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
Wei Liu
2020-07-03 16:27:53 +02:00
committed by Rob Bradford
parent cfa758fbb1
commit a4f484bc5e
5 changed files with 83 additions and 88 deletions

View File

@@ -22,6 +22,8 @@ extern crate serde;
extern crate serde_derive;
extern crate serde_json;
extern crate thiserror;
#[macro_use]
extern crate anyhow;
/// KVM implementation module
pub mod kvm;
@@ -39,6 +41,6 @@ pub mod arch;
mod cpu;
pub use crate::hypervisor::{Hypervisor, HypervisorError};
pub use cpu::{HypervisorCpuError, Vcpu};
pub use cpu::{HypervisorCpuError, Vcpu, VmExit};
pub use kvm::*;
pub use vm::{DataMatch, HypervisorVmError, Vm};