Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions crates/kit/src/libvirt/domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,12 @@ impl DomainBuilder {
&& (self.firmware == Some(FirmwareType::UefiSecure) || self.ovmf_code_path.is_some());
let insecure_boot = self.firmware == Some(FirmwareType::UefiInsecure);

if use_uefi {
writer.start_element("os", &[("firmware", "efi")])?;
} else {
writer.start_element("os", &[])?;
}
// Don't use firmware="efi" when we have custom OVMF paths (secure boot with custom keys)
// because firmware="efi" and explicit <loader> paths are mutually exclusive
let os_attributes = (use_uefi && self.ovmf_code_path.is_none())
.then_some([("firmware", "efi")].as_slice())
.unwrap_or_default();
writer.start_element("os", os_attributes)?;

// For secure boot on x86_64, we may need a specific machine type with SMM
let machine_type = if secure_boot && arch_config.arch == "x86_64" {
Expand All @@ -231,7 +232,8 @@ impl DomainBuilder {
if use_uefi {
if let Some(ref ovmf_code) = self.ovmf_code_path {
// Use custom OVMF_CODE path for secure boot
let mut loader_attrs = vec![("readonly", "yes"), ("type", "pflash")];
let mut loader_attrs =
vec![("readonly", "yes"), ("type", "pflash"), ("format", "raw")];
if secure_boot {
loader_attrs.push(("secure", "yes"));
}
Expand All @@ -242,7 +244,11 @@ impl DomainBuilder {
writer.write_text_element_with_attrs(
"nvram",
"", // Empty content, template attr provides the source
&[("template", nvram_template)],
&[
("template", nvram_template),
("templateFormat", "raw"),
("format", "raw"),
],
)?;
}
} else if secure_boot {
Expand Down
6 changes: 5 additions & 1 deletion crates/kit/src/libvirt/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1129,9 +1129,13 @@ fn create_libvirt_domain_from_disk(
if let Some(ref sb_config) = secure_boot_config {
let ovmf_code = crate::libvirt::secureboot::find_ovmf_code_secboot()
.context("Failed to find OVMF_CODE.secboot.fd")?;
let sb_vars_path = sb_config
.vars_template
.canonicalize_utf8()
.context("Canonicalizing secureboot vars path")?;
domain_builder = domain_builder
.with_ovmf_code_path(ovmf_code.as_str())
.with_nvram_template(sb_config.vars_template.as_str());
.with_nvram_template(sb_vars_path.as_str());

// Add secure boot keys path to metadata for reference
domain_builder =
Expand Down