mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: Fix --platform syntax with optional feature flags
The `--platform` help string was hardcoded and did not reflect which optional features (tdx, sev_snp) were actually enabled in. Build the syntax string dynamically as `PlatformConfig::syntax()`, conditionally appending feature-gated options so the CLI help stays accurate. Signed-off-by: Bo Chen <bchen@crusoe.ai>
This commit is contained in:
@@ -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=<num_pci_segments>,iommu_segments=<list_of_segments>,iommu_address_width=<bits>,serial_number=<dmi_device_serial_number>,uuid=<dmi_device_uuid>,oem_strings=<list_of_strings>"
|
||||
PlatformConfig::syntax()
|
||||
)
|
||||
.num_args(1)
|
||||
.group("vm-config"),
|
||||
|
||||
@@ -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<String> = LazyLock::new(|| {
|
||||
let mut syntax = "Platform configuration parameters \
|
||||
\"num_pci_segments=<num_pci_segments>,iommu_segments=<list_of_segments>,\
|
||||
iommu_address_width=<bits>,serial_number=<dmi_device_serial_number>,\
|
||||
uuid=<dmi_device_uuid>,oem_strings=<list_of_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<Self> {
|
||||
let mut parser = OptionParser::new();
|
||||
parser
|
||||
|
||||
Reference in New Issue
Block a user