mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
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:
@@ -1429,7 +1429,7 @@ mod tests {
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
#[test]
|
||||
pub fn test_vm() {
|
||||
use hypervisor::VcpuExit;
|
||||
use hypervisor::VmExit;
|
||||
use vm_memory::{GuestMemory, GuestMemoryRegion};
|
||||
// This example based on https://lwn.net/Articles/658511/
|
||||
let code = [
|
||||
@@ -1481,52 +1481,18 @@ pub fn test_vm() {
|
||||
|
||||
loop {
|
||||
match vcpu.run().expect("run failed") {
|
||||
VcpuExit::IoIn(addr, data) => {
|
||||
println!(
|
||||
"IO in -- addr: {:#x} data [{:?}]",
|
||||
addr,
|
||||
str::from_utf8(&data).unwrap()
|
||||
);
|
||||
}
|
||||
VcpuExit::IoOut(addr, data) => {
|
||||
VmExit::IoOut(addr, data) => {
|
||||
println!(
|
||||
"IO out -- addr: {:#x} data [{:?}]",
|
||||
addr,
|
||||
str::from_utf8(&data).unwrap()
|
||||
);
|
||||
}
|
||||
VcpuExit::MmioRead(_addr, _data) => {}
|
||||
VcpuExit::MmioWrite(_addr, _data) => {}
|
||||
VcpuExit::Unknown => {}
|
||||
VcpuExit::Exception => {}
|
||||
VcpuExit::Hypercall => {}
|
||||
VcpuExit::Debug => {}
|
||||
VcpuExit::Hlt => {
|
||||
VmExit::Reset => {
|
||||
println!("HLT");
|
||||
break;
|
||||
}
|
||||
VcpuExit::IrqWindowOpen => {}
|
||||
VcpuExit::Shutdown => {}
|
||||
VcpuExit::FailEntry => {}
|
||||
VcpuExit::Intr => {}
|
||||
VcpuExit::SetTpr => {}
|
||||
VcpuExit::TprAccess => {}
|
||||
VcpuExit::S390Sieic => {}
|
||||
VcpuExit::S390Reset => {}
|
||||
VcpuExit::Dcr => {}
|
||||
VcpuExit::Nmi => {}
|
||||
VcpuExit::InternalError => {}
|
||||
VcpuExit::Osi => {}
|
||||
VcpuExit::PaprHcall => {}
|
||||
VcpuExit::S390Ucontrol => {}
|
||||
VcpuExit::Watchdog => {}
|
||||
VcpuExit::S390Tsch => {}
|
||||
VcpuExit::Epr => {}
|
||||
VcpuExit::SystemEvent(_, _) => {}
|
||||
VcpuExit::S390Stsi => {}
|
||||
VcpuExit::IoapicEoi(_vector) => {}
|
||||
VcpuExit::Hyperv => {}
|
||||
r => panic!("unexpected exit reason: {:?}", r),
|
||||
}
|
||||
// r => panic!("unexpected exit reason: {:?}", r),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user