arch: vmm: disable nested virtualization if needed

User can now disable nested virtualization for Intel and AMD
if configured by the CLI.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
This commit is contained in:
Muminul Islam
2025-10-27 16:28:21 -07:00
committed by Rob Bradford
parent d8360ddc8e
commit 658a7f9175
3 changed files with 26 additions and 0 deletions

View File

@@ -659,6 +659,14 @@ impl CpusConfig {
.map_err(Error::ParseCpus)?
.is_none_or(|toggle| toggle.0);
// Nested virtualization is always turned on for aarch64 and riscv64
// TODO: revisit this when nested support can be turned of on these architectures
#[cfg(any(target_arch = "aarch64", target_arch = "riscv64"))]
if !nested {
return Err(Error::ParseCpus(OptionParserError::InvalidValue(
"nested=off is not supported on aarch64 and riscv64 architectures".to_string(),
)));
}
Ok(CpusConfig {
boot_vcpus,
max_vcpus,

View File

@@ -455,6 +455,7 @@ impl Vcpu {
#[cfg(target_arch = "x86_64")] cpuid: Vec<CpuIdEntry>,
#[cfg(target_arch = "x86_64")] kvm_hyperv: bool,
#[cfg(target_arch = "x86_64")] topology: (u16, u16, u16, u16),
#[cfg(target_arch = "x86_64")] nested: bool,
) -> Result<()> {
#[cfg(target_arch = "aarch64")]
{
@@ -475,6 +476,7 @@ impl Vcpu {
kvm_hyperv,
self.vendor,
topology,
nested,
)
.map_err(Error::VcpuConfiguration)?;
@@ -995,6 +997,7 @@ impl CpuManager {
self.cpuid.clone(),
self.config.kvm_hyperv,
topology,
self.config.nested,
)?;
#[cfg(target_arch = "aarch64")]