diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 6c5c2350..fefa59ca 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -53,7 +53,7 @@ jobs: toolchain: ${{ env.RUST_STABLE }} - uses: Swatinem/rust-cache@v2 - name: build(Arm64/hvp) - run: cargo build --no-default-features --features hvp --verbose + run: cargo build --verbose fmt: name: Fmt @@ -113,7 +113,7 @@ jobs: override: true - uses: Swatinem/rust-cache@v2 - name: clippy - run: cargo clippy --all-targets --no-default-features --features hvp + run: cargo clippy --all-targets udeps-x86_64_kvm: name: Udeps(x86_64/Kvm) @@ -164,7 +164,7 @@ jobs: with: tool: cargo-udeps - name: udeps - run: cargo udeps --all-targets --no-default-features --features hvp + run: cargo udeps --all-targets test: name: Test diff --git a/Cargo.lock b/Cargo.lock index 0a65666d..1f903cde 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1462,7 +1462,6 @@ dependencies = [ "rangemap", "serde", "serde_json", - "strum", "strum_macros", "tempfile", "thiserror", diff --git a/crates/vm-cli/Cargo.toml b/crates/vm-cli/Cargo.toml index dffa3b6a..0748bfba 100644 --- a/crates/vm-cli/Cargo.toml +++ b/crates/vm-cli/Cargo.toml @@ -17,8 +17,3 @@ vm-bootloader.workspace = true vm-core.workspace = true vm-device.workspace = true vm-vmm.workspace = true - -[features] -default = ["kvm"] -kvm = ["vm-core/kvm", "vm-vmm/kvm"] -hvp = ["vm-core/hvp", "vm-vmm/hvp"] diff --git a/crates/vm-cli/src/main.rs b/crates/vm-cli/src/main.rs index df235146..ceed6c14 100644 --- a/crates/vm-cli/src/main.rs +++ b/crates/vm-cli/src/main.rs @@ -19,10 +19,10 @@ mod term; fn build_hypervisor() -> anyhow::Result> { cfg_select! { - all(target_arch = "aarch64", feature = "hvp") => { + target_os = "macos" => { Ok(Box::new(vm_core::virtualization::hvp::AppleHypervisor)) } - feature = "kvm" => { + target_os = "linux" => { Ok(Box::new(vm_core::virtualization::kvm::KvmHypervisor::new()?)) } _ => panic!(), diff --git a/crates/vm-core/Cargo.toml b/crates/vm-core/Cargo.toml index c747229d..705f4240 100644 --- a/crates/vm-core/Cargo.toml +++ b/crates/vm-core/Cargo.toml @@ -5,13 +5,9 @@ edition = "2024" [dependencies] acpi_tables = { workspace = true } -applevisor = { workspace = true, optional = true } -applevisor-sys = { workspace = true, optional = true } async-trait = { workspace = true } bitflags = { workspace = true } gdbstub_arch = { workspace = true } -kvm-bindings = { workspace = true, optional = true } -kvm-ioctls = { workspace = true, optional = true } serde = { workspace = true } serde_json = { workspace = true } static_assertions = { workspace = true } @@ -25,16 +21,18 @@ vm-utils = { workspace = true } [target.'cfg(target_arch = "aarch64")'.dependencies] anyhow = { workspace = true } futures = { workspace = true } -vm-aarch64 = { workspace = true } -strum = { workspace = true, optional = true } strum_macros = { workspace = true } +vm-aarch64 = { workspace = true } [target.'cfg(target_arch = "x86_64")'.dependencies] vm-firmware = { workspace = true } [target.'cfg(target_os = "linux")'.dependencies] +kvm-bindings = { workspace = true } +kvm-ioctls = { workspace = true } vmm-sys-util = { workspace = true } -[features] -kvm = ["kvm-bindings", "kvm-ioctls"] -hvp = ["applevisor", "applevisor-sys", "strum"] +[target.'cfg(target_os = "macos")'.dependencies] +applevisor = { workspace = true } +applevisor-sys = { workspace = true } +strum = { workspace = true } diff --git a/crates/vm-core/src/virtualization.rs b/crates/vm-core/src/virtualization.rs index 60aa0479..260236ba 100644 --- a/crates/vm-core/src/virtualization.rs +++ b/crates/vm-core/src/virtualization.rs @@ -1,7 +1,7 @@ -#[cfg(feature = "hvp")] +#[cfg(target_os = "macos")] pub mod hvp; -#[cfg(feature = "kvm")] +#[cfg(target_os = "linux")] pub mod kvm; pub mod hypervisor; diff --git a/crates/vm-core/src/virtualization/hypervisor/error.rs b/crates/vm-core/src/virtualization/hypervisor/error.rs index 7da50510..e3d03855 100644 --- a/crates/vm-core/src/virtualization/hypervisor/error.rs +++ b/crates/vm-core/src/virtualization/hypervisor/error.rs @@ -5,7 +5,7 @@ pub enum HypervisorError { #[error("Failed to create vm: {0}")] CreateVm(String), - #[cfg(feature = "kvm")] + #[cfg(target_os = "linux")] #[error("Kvm error: {0}")] Kvm(#[from] kvm_ioctls::Error), } diff --git a/crates/vm-core/src/virtualization/vcpu/error.rs b/crates/vm-core/src/virtualization/vcpu/error.rs index 048da057..5e6816f0 100644 --- a/crates/vm-core/src/virtualization/vcpu/error.rs +++ b/crates/vm-core/src/virtualization/vcpu/error.rs @@ -10,11 +10,11 @@ pub enum VcpuError { #[error("Vcpu command channel disconnected")] VcpuCommandDisconnected, - #[cfg(feature = "hvp")] + #[cfg(target_os = "macos")] #[error("{0}")] ApplevisorError(#[from] applevisor::error::HypervisorError), - #[cfg(feature = "kvm")] + #[cfg(target_os = "linux")] #[error("{0}")] KvmError(#[from] kvm_ioctls::Error), diff --git a/crates/vm-core/src/virtualization/vm/error.rs b/crates/vm-core/src/virtualization/vm/error.rs index 19f6ab6c..77fe50a8 100644 --- a/crates/vm-core/src/virtualization/vm/error.rs +++ b/crates/vm-core/src/virtualization/vm/error.rs @@ -24,11 +24,11 @@ pub enum VmError { #[error("Failed to create memory region")] MemoryRegionOverlap, - #[cfg(feature = "hvp")] + #[cfg(target_os = "macos")] #[error("Applevisor error: {0}")] ApplevisorError(#[from] applevisor::error::HypervisorError), - #[cfg(feature = "kvm")] + #[cfg(target_os = "linux")] #[error("Kvm error: {0}")] Kvm(#[from] kvm_ioctls::Error), diff --git a/crates/vm-vmm/Cargo.toml b/crates/vm-vmm/Cargo.toml index 98703c8c..5575451e 100644 --- a/crates/vm-vmm/Cargo.toml +++ b/crates/vm-vmm/Cargo.toml @@ -29,12 +29,5 @@ vm-utils = { workspace = true } vm-virtio = { workspace = true } winnow = { workspace = true } -[target.'cfg(target_arch = "aarch64")'.dependencies] -strum = { workspace = true, optional = true } - [target.'cfg(target_os = "linux")'.dependencies] vm-vfio = { workspace = true } - -[features] -kvm = [] -hvp = ["strum"] diff --git a/scripts/run_hvp.sh b/scripts/run_hvp.sh index b632c060..ac45c87f 100755 --- a/scripts/run_hvp.sh +++ b/scripts/run_hvp.sh @@ -5,7 +5,7 @@ set -x rm -f /tmp/vm.sock -cargo build --release --no-default-features --features hvp +cargo build --release codesign --force --sign - \ --entitlements entitlements.plist \ target/release/vm-cli