From dab28bc191d5d7fadd215781601760fd70855806 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Mon, 20 Nov 2023 13:23:02 -0500 Subject: [PATCH] efi: Gracefully no-op if there's no `BootCurrent` This happens in a default virt-manager run for example. --- src/efi.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/efi.rs b/src/efi.rs index ffe4b8167..81089f4bd 100644 --- a/src/efi.rs +++ b/src/efi.rs @@ -443,12 +443,17 @@ pub(crate) fn clear_efi_current() -> Result<()> { anyhow::bail!("Failed to invoke {EFIBOOTMGR}") } let output = String::from_utf8(output.stdout)?; - let current = output + let current = if let Some(current) = output .lines() .filter_map(|l| l.split_once(':')) .filter_map(|(k, v)| (k == BOOTCURRENT).then_some(v.trim())) .next() - .ok_or_else(|| anyhow::anyhow!("Failed to find BootCurrent"))?; + { + current + } else { + log::debug!("No EFI {BOOTCURRENT} found"); + return Ok(()); + }; let output = Command::new(EFIBOOTMGR) .args(["-b", current, "-B"]) .output()?;