diff --git a/src/actions/chainload.rs b/src/actions/chainload.rs index 00a0f93..830552d 100644 --- a/src/actions/chainload.rs +++ b/src/actions/chainload.rs @@ -3,11 +3,10 @@ use crate::utils; use crate::utils::media_loader::MediaLoaderHandle; use crate::utils::media_loader::constants::LINUX_EFI_INITRD_MEDIA_GUID; use anyhow::{Context, Result, bail}; -use log::info; +use log::{error, info}; use serde::{Deserialize, Serialize}; use std::rc::Rc; use uefi::CString16; -use uefi::proto::device_path::LoadedImageDevicePath; use uefi::proto::loaded_image::LoadedImage; #[derive(Serialize, Deserialize, Default, Clone)] @@ -21,9 +20,6 @@ pub struct ChainloadConfiguration { pub fn chainload(context: Rc, configuration: &ChainloadConfiguration) -> Result<()> { let sprout_image = uefi::boot::image_handle(); - let _image_device_path_protocol = - uefi::boot::open_protocol_exclusive::(sprout_image) - .context("unable to open loaded image device path protocol")?; let resolved = utils::resolve_path( context.root().loaded_image_path()?, @@ -87,10 +83,10 @@ pub fn chainload(context: Rc, configuration: &ChainloadConfigurat let (base, size) = loaded_image_protocol.info(); info!("loaded image: base={:#x} size={:#x}", base.addr(), size); let result = uefi::boot::start_image(image).context("unable to start image"); - if let Some(initrd_handle) = initrd_handle { - initrd_handle - .unregister() - .context("unable to unregister linux initrd")?; + if let Some(initrd_handle) = initrd_handle + && let Err(error) = initrd_handle.unregister() + { + error!("unable to unregister linux initrd: {}", error); } result.context("unable to start image")?; drop(options_holder); diff --git a/src/actions/edera.rs b/src/actions/edera.rs index f308584..0aa50c5 100644 --- a/src/actions/edera.rs +++ b/src/actions/edera.rs @@ -1,6 +1,7 @@ use std::rc::Rc; use anyhow::{Context, Result}; +use log::error; use serde::{Deserialize, Serialize}; use uefi::Guid; @@ -63,19 +64,22 @@ fn register_media_loader_file( pub fn edera(context: Rc, configuration: &EderaConfiguration) -> Result<()> { let config = build_xen_config(configuration); - let config = register_media_loader_text(XEN_EFI_CONFIG_MEDIA_GUID, "config", config)?; + let config = register_media_loader_text(XEN_EFI_CONFIG_MEDIA_GUID, "config", config) + .context("unable to register config media loader")?; let kernel = register_media_loader_file( &context, XEN_EFI_KERNEL_MEDIA_GUID, "kernel", &configuration.kernel, - )?; + ) + .context("unable to register kernel media loader")?; let mut media_loaders = vec![config, kernel]; if let Some(ref initrd) = configuration.initrd { let initrd = - register_media_loader_file(&context, XEN_EFI_RAMDISK_MEDIA_GUID, "initrd", initrd)?; + register_media_loader_file(&context, XEN_EFI_RAMDISK_MEDIA_GUID, "initrd", initrd) + .context("unable to register initrd media loader")?; media_loaders.push(initrd); } @@ -90,7 +94,9 @@ pub fn edera(context: Rc, configuration: &EderaConfiguration) -> .context("unable to chainload to xen"); for media_loader in media_loaders { - media_loader.unregister()?; + if let Err(error) = media_loader.unregister() { + error!("unable to unregister media loader: {}", error); + } } result