This commit is contained in:
@ -22,10 +22,13 @@ pub struct DomainMetadataXML {
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
#[serde(rename = "os")]
|
||||
pub struct OSXML {
|
||||
#[serde(rename = "@firmware", default)]
|
||||
pub firmware: String,
|
||||
#[serde(rename = "@firmware", default, skip_serializing_if = "Option::is_none")]
|
||||
pub firmware: Option<String>,
|
||||
pub r#type: OSTypeXML,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub loader: Option<OSLoaderXML>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub bootmenu: Option<OSBootMenuXML>,
|
||||
pub smbios: Option<OSSMBiosXML>,
|
||||
}
|
||||
|
||||
@ -49,6 +52,16 @@ pub struct OSLoaderXML {
|
||||
pub secure: String,
|
||||
}
|
||||
|
||||
/// Legacy boot menu information
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
#[serde(rename = "bootmenu")]
|
||||
pub struct OSBootMenuXML {
|
||||
#[serde(rename = "@enable")]
|
||||
pub enable: String,
|
||||
#[serde(rename = "@timeout")]
|
||||
pub timeout: usize,
|
||||
}
|
||||
|
||||
/// SMBIOS System information
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
#[serde(rename = "smbios")]
|
||||
|
@ -17,6 +17,7 @@ pub struct VMGroupId(pub String);
|
||||
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
pub enum BootType {
|
||||
Legacy,
|
||||
UEFI,
|
||||
UEFISecureBoot,
|
||||
}
|
||||
@ -351,13 +352,26 @@ impl VMInfo {
|
||||
machine: "q35".to_string(),
|
||||
body: "hvm".to_string(),
|
||||
},
|
||||
firmware: "efi".to_string(),
|
||||
loader: Some(OSLoaderXML {
|
||||
secure: match self.boot_type {
|
||||
BootType::UEFI => "no".to_string(),
|
||||
BootType::UEFISecureBoot => "yes".to_string(),
|
||||
},
|
||||
}),
|
||||
firmware: match self.boot_type {
|
||||
BootType::Legacy => None,
|
||||
_ => Some("efi".to_string()),
|
||||
},
|
||||
loader: match self.boot_type {
|
||||
BootType::Legacy => None,
|
||||
_ => Some(OSLoaderXML {
|
||||
secure: match self.boot_type {
|
||||
BootType::UEFISecureBoot => "yes".to_string(),
|
||||
_ => "no".to_string(),
|
||||
},
|
||||
}),
|
||||
},
|
||||
bootmenu: match self.boot_type {
|
||||
BootType::Legacy => Some(OSBootMenuXML {
|
||||
enable: "yes".to_string(),
|
||||
timeout: 3000,
|
||||
}),
|
||||
_ => None,
|
||||
},
|
||||
smbios: Some(OSSMBiosXML {
|
||||
mode: "sysinfo".to_string(),
|
||||
}),
|
||||
@ -449,9 +463,10 @@ impl VMInfo {
|
||||
.virtweb
|
||||
.group
|
||||
.map(VMGroupId),
|
||||
boot_type: match domain.os.loader {
|
||||
None => BootType::UEFI,
|
||||
Some(l) => match l.secure.as_str() {
|
||||
boot_type: match (domain.os.loader, domain.os.bootmenu) {
|
||||
(_, Some(_)) => BootType::Legacy,
|
||||
(None, _) => BootType::UEFI,
|
||||
(Some(l), _) => match l.secure.as_str() {
|
||||
"yes" => BootType::UEFISecureBoot,
|
||||
_ => BootType::UEFI,
|
||||
},
|
||||
|
Reference in New Issue
Block a user