build: decouple igvm and sev_snp from mshv

igvm and sev_snp only need the MSHV backend when a caller selects that
backend. Stop enabling mshv implicitly from those top-level features so
KVM SEV-SNP builds do not compile unused MSHV backend code.

Require igvm and sev_snp to be built with kvm or mshv. Backend-less
configurations having no runtime hypervisor are not supported.

Assisted-by: Copilot:GPT-5.5
Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
Wei Liu
2026-07-06 13:43:44 -07:00
parent 8f38928757
commit 47e88d26e5
2 changed files with 6 additions and 2 deletions

View File

@@ -48,13 +48,13 @@ default = ["io_uring", "kvm"]
dhat-heap = ["dhat", "vmm/dhat-heap"] # For heap profiling
fw_cfg = ["vmm/fw_cfg"]
guest_debug = ["vmm/guest_debug"]
igvm = ["mshv", "vmm/igvm"]
igvm = ["vmm/igvm"]
io_uring = ["vmm/io_uring"]
ivshmem = ["vmm/ivshmem"]
kvm = ["vmm/kvm"]
mshv = ["vmm/mshv"]
pvmemcontrol = ["vmm/pvmemcontrol"]
sev_snp = ["igvm", "mshv", "vmm/sev_snp"]
sev_snp = ["igvm", "vmm/sev_snp"]
tdx = ["vmm/tdx"]
tracing = ["tracer/tracing", "vmm/tracing"]

View File

@@ -900,6 +900,10 @@ fn main() {
compile_error!("Feature 'sev_snp' needs target 'x86_64'");
#[cfg(all(feature = "fw_cfg", target_arch = "riscv64"))]
compile_error!("Feature 'fw_cfg' needs targets 'x86_64' or 'aarch64'");
#[cfg(all(feature = "igvm", not(any(feature = "kvm", feature = "mshv"))))]
compile_error!("Feature 'igvm' needs feature 'kvm' or 'mshv'");
#[cfg(all(feature = "sev_snp", not(any(feature = "kvm", feature = "mshv"))))]
compile_error!("Feature 'sev_snp' needs feature 'kvm' or 'mshv'");
#[cfg(feature = "dhat-heap")]
let _profiler = dhat::Profiler::new_heap();