1#![allow(clippy::ptr_as_ptr)]
31#![allow(clippy::ptr_cast_constness)]
32#![allow(clippy::ref_as_ptr)]
33#![allow(clippy::borrow_as_ptr)]
34#![allow(clippy::field_reassign_with_default)]
35#![allow(clippy::unnecessary_cast)]
36#![allow(clippy::wildcard_enum_match_arm)]
37#![allow(unused_unsafe)]
38#![allow(clippy::let_and_return)]
39#![allow(clippy::manual_div_ceil)]
40#![allow(clippy::match_wildcard_for_single_variants)]
41#![allow(clippy::redundant_closure)]
42#![allow(clippy::map_unwrap_or)]
43#![allow(clippy::comparison_chain)]
44#![allow(clippy::expect_fun_call)]
45
46pub mod config;
47pub mod error;
48pub mod memory;
49pub mod traits;
50pub mod types;
51
52#[cfg(target_os = "macos")]
53pub mod darwin;
54
55#[cfg(target_os = "linux")]
56pub mod linux;
57
58pub use config::{VmConfig, VmConfigBuilder};
59pub use error::{HypervisorError, Result};
60pub use memory::{GuestAddress, MemoryRegion};
61pub use traits::{GuestMemory, Hypervisor, Vcpu, VirtualMachine};
62pub use types::{
63 Arm64Registers, BalloonStats, CpuArch, DeviceSnapshot, DirtyPageInfo, MemoryRegionSnapshot,
64 PlatformCapabilities, Registers, VcpuExit, VcpuSnapshot, VirtioDeviceConfig, VirtioDeviceType,
65 VmSnapshot,
66};
67
68pub fn create_hypervisor() -> Result<impl Hypervisor> {
74 #[cfg(target_os = "macos")]
75 {
76 darwin::DarwinHypervisor::new()
77 }
78
79 #[cfg(target_os = "linux")]
80 {
81 linux::KvmHypervisor::new()
82 }
83
84 #[cfg(not(any(target_os = "macos", target_os = "linux")))]
85 {
86 compile_error!("Unsupported platform: only macOS and Linux are supported")
87 }
88}