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:
@@ -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