diff --git a/cloud-hypervisor/src/main.rs b/cloud-hypervisor/src/main.rs index 996671182..415e7ed92 100644 --- a/cloud-hypervisor/src/main.rs +++ b/cloud-hypervisor/src/main.rs @@ -33,8 +33,8 @@ use vmm::vm_config::FwCfgConfig; use vmm::vm_config::IvshmemConfig; use vmm::vm_config::{ BalloonConfig, DeviceConfig, DiskConfig, FsConfig, GenericVhostUserConfig, LandlockConfig, - NetConfig, NumaConfig, PciSegmentConfig, PmemConfig, RateLimiterGroupConfig, TpmConfig, - UserDeviceConfig, VdpaConfig, VmConfig, VsockConfig, + NetConfig, NumaConfig, PciSegmentConfig, PlatformConfig, PmemConfig, RateLimiterGroupConfig, + TpmConfig, UserDeviceConfig, VdpaConfig, VmConfig, VsockConfig, }; use vmm_sys_util::eventfd::EventFd; use vmm_sys_util::signal::block_signal; @@ -388,7 +388,7 @@ fn get_cli_options_sorted( Arg::new("platform") .long("platform") .help( - "num_pci_segments=,iommu_segments=,iommu_address_width=,serial_number=,uuid=,oem_strings=" + PlatformConfig::syntax() ) .num_args(1) .group("vm-config"), diff --git a/vmm/src/config.rs b/vmm/src/config.rs index fc7eb1b8d..e37809745 100644 --- a/vmm/src/config.rs +++ b/vmm/src/config.rs @@ -9,6 +9,7 @@ use std::fs; use std::path::PathBuf; use std::result; use std::str::FromStr; +use std::sync::LazyLock; use block::ImageType; use clap::ArgMatches; @@ -798,6 +799,30 @@ impl PciSegmentConfig { } impl PlatformConfig { + pub fn syntax() -> &'static str { + static SYNTAX: LazyLock = LazyLock::new(|| { + let mut syntax = "Platform configuration parameters \ + \"num_pci_segments=,iommu_segments=,\ + iommu_address_width=,serial_number=,\ + uuid=,oem_strings=" + .to_string(); + + if cfg!(feature = "tdx") { + syntax.push_str(",tdx=on|off"); + } + + if cfg!(feature = "sev_snp") { + syntax.push_str(",sev_snp=on|off"); + } + + syntax.push('"'); + + syntax + }); + + &SYNTAX + } + pub fn parse(platform: &str) -> Result { let mut parser = OptionParser::new(); parser