Add backend SMBios support
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
94ee8f8c78
commit
644fd6f1bb
@ -26,6 +26,7 @@ pub struct OSXML {
|
||||
pub firmware: String,
|
||||
pub r#type: OSTypeXML,
|
||||
pub loader: Option<OSLoaderXML>,
|
||||
pub smbios: Option<OSSMBiosXML>,
|
||||
}
|
||||
|
||||
/// OS Type information
|
||||
@ -48,6 +49,14 @@ pub struct OSLoaderXML {
|
||||
pub secure: String,
|
||||
}
|
||||
|
||||
/// SMBIOS System information
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
#[serde(rename = "smbios")]
|
||||
pub struct OSSMBiosXML {
|
||||
#[serde(rename = "@mode")]
|
||||
pub mode: String,
|
||||
}
|
||||
|
||||
/// Hypervisor features
|
||||
#[derive(serde::Serialize, serde::Deserialize, Clone, Default, Debug)]
|
||||
#[serde(rename = "features")]
|
||||
@ -305,6 +314,29 @@ pub struct DomainCPUXML {
|
||||
pub topology: Option<DomainCPUTopology>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
#[serde(rename = "entry")]
|
||||
pub struct OEMStringEntryXML {
|
||||
#[serde(rename = "$text")]
|
||||
pub content: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
#[serde(rename = "oemStrings")]
|
||||
pub struct OEMStringsXML {
|
||||
#[serde(rename = "entry")]
|
||||
pub entries: Vec<OEMStringEntryXML>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
#[serde(rename = "sysinfo")]
|
||||
pub struct SysInfoXML {
|
||||
#[serde(rename = "@type")]
|
||||
pub r#type: String,
|
||||
#[serde(rename = "oemStrings")]
|
||||
pub oem_strings: Option<OEMStringsXML>,
|
||||
}
|
||||
|
||||
/// Domain information, see https://libvirt.org/formatdomain.html
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
#[serde(rename = "domain")]
|
||||
@ -335,6 +367,10 @@ pub struct DomainXML {
|
||||
/// CPU information
|
||||
pub cpu: DomainCPUXML,
|
||||
|
||||
/// SMBios strings
|
||||
pub sysinfo: Option<SysInfoXML>,
|
||||
|
||||
/// Behavior when guest state change
|
||||
pub on_poweroff: String,
|
||||
pub on_reboot: String,
|
||||
pub on_crash: String,
|
||||
|
@ -83,6 +83,8 @@ pub struct VMInfo {
|
||||
pub networks: Vec<Network>,
|
||||
/// Add a TPM v2.0 module
|
||||
pub tpm_module: bool,
|
||||
/// Strings injected as OEM Strings in SMBios configuration
|
||||
pub oem_strings: Vec<String>,
|
||||
}
|
||||
|
||||
impl VMInfo {
|
||||
@ -329,6 +331,9 @@ impl VMInfo {
|
||||
BootType::UEFISecureBoot => "yes".to_string(),
|
||||
},
|
||||
}),
|
||||
smbios: Some(OSSMBiosXML {
|
||||
mode: "sysinfo".to_string(),
|
||||
}),
|
||||
},
|
||||
|
||||
features: FeaturesXML { acpi: ACPIXML {} },
|
||||
@ -385,6 +390,17 @@ impl VMInfo {
|
||||
}),
|
||||
},
|
||||
|
||||
sysinfo: Some(SysInfoXML {
|
||||
r#type: "smbios".to_string(),
|
||||
oem_strings: Some(OEMStringsXML {
|
||||
entries: self
|
||||
.oem_strings
|
||||
.iter()
|
||||
.map(|s| OEMStringEntryXML { content: s.clone() })
|
||||
.collect(),
|
||||
}),
|
||||
}),
|
||||
|
||||
on_poweroff: "destroy".to_string(),
|
||||
on_reboot: "restart".to_string(),
|
||||
on_crash: "destroy".to_string(),
|
||||
@ -476,6 +492,12 @@ impl VMInfo {
|
||||
.collect::<Result<Vec<_>, _>>()?,
|
||||
|
||||
tpm_module: domain.devices.tpm.is_some(),
|
||||
|
||||
oem_strings: domain
|
||||
.sysinfo
|
||||
.and_then(|s| s.oem_strings)
|
||||
.map(|s| s.entries.iter().map(|o| o.content.to_string()).collect())
|
||||
.unwrap_or_default(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user