mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm, devices: Add fw_cfg string item support
QEMU supports passing inline string values to the guest via fw_cfg (-fw_cfg name=...,string=...). Cloud Hypervisor previously only supported file-backed fw_cfg items. This adds the 'string' option so users can pass values like OVMF's X-PciMmio64Mb without creating a temporary file on the host. Each fw_cfg item now accepts exactly one of 'file' or 'string'. The FwCfgInvalidItem invariant is validated in PayloadConfig::validate() (via FwCfgConfig::validate()), covering both CLI and JSON API paths. The populate_fw_cfg match arm uses unreachable!() since validation guarantees the invariant holds at that point. CLI syntax: --fw-cfg-config items=[name=opt/ovmf/X-PciMmio64Mb,string=262144] Signed-off-by: Keith Adler <kadler@cloudflare.com>
This commit is contained in:
committed by
Rob Bradford
parent
e4e3375a8d
commit
926dd1e141
@@ -759,6 +759,12 @@ pub enum PayloadConfigError {
|
||||
/// FwCfg missing initramfs
|
||||
#[error("Error --fw-cfg-config: missing --initramfs")]
|
||||
FwCfgMissingInitramfs,
|
||||
#[cfg(feature = "fw_cfg")]
|
||||
/// Invalid fw_cfg item content
|
||||
#[error(
|
||||
"Error --fw-cfg-config: invalid item '{0}' (exactly one of 'file' or 'string' is required)"
|
||||
)]
|
||||
FwCfgInvalidItem(String),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
|
||||
@@ -819,7 +825,9 @@ pub struct FwCfgItem {
|
||||
#[serde(default)]
|
||||
pub name: String,
|
||||
#[serde(default)]
|
||||
pub file: PathBuf,
|
||||
pub file: Option<PathBuf>,
|
||||
#[serde(default)]
|
||||
pub string: Option<String>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "fw_cfg")]
|
||||
|
||||
Reference in New Issue
Block a user