Skip to content

Commit 3be47ba

Browse files
committed
install: Gather blockdev info early in filesystem phase
The bootloader logic in general is going to need to query the block layout. But especially for ppc64le and s390x we'll need this data. Gather it early on as global state so it's accessible to the entire `install to-filesystem` phase. Note that we shouldn't be mutating the blockdev setup in `to-filesystem`. Signed-off-by: Colin Walters <walters@verbum.org>
1 parent b9dcd45 commit 3be47ba

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

lib/src/bootloader.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,27 @@ use anyhow::Result;
22
use camino::Utf8Path;
33
use fn_error_context::context;
44

5+
use crate::blockdev::Device;
56
use crate::task::Task;
67

78
/// The name of the mountpoint for efi (as a subdirectory of /boot, or at the toplevel)
89
pub(crate) const EFI_DIR: &str = "efi";
910

1011
#[context("Installing bootloader")]
1112
pub(crate) fn install_via_bootupd(
12-
device: &Utf8Path,
13+
device: &Device,
1314
rootfs: &Utf8Path,
1415
configopts: &crate::install::InstallConfigOpts,
1516
) -> Result<()> {
1617
let verbose = std::env::var_os("BOOTC_BOOTLOADER_DEBUG").map(|_| "-vvvv");
1718
// bootc defaults to only targeting the platform boot method.
1819
let bootupd_opts = (!configopts.generic_image).then_some(["--update-firmware", "--auto"]);
20+
let devpath = device.path();
1921
let args = ["backend", "install", "--write-uuid"]
2022
.into_iter()
2123
.chain(verbose)
2224
.chain(bootupd_opts.iter().copied().flatten())
23-
.chain(["--device", device.as_str(), rootfs.as_str()]);
25+
.chain(["--device", devpath.as_str(), rootfs.as_str()]);
2426
Task::new("Running bootupctl to install bootloader", "bootupctl")
2527
.args(args)
2628
.verbose()

lib/src/install.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ fn require_skopeo_with_containers_storage() -> Result<()> {
812812

813813
pub(crate) struct RootSetup {
814814
luks_device: Option<String>,
815-
device: Utf8PathBuf,
815+
device_info: crate::blockdev::Device,
816816
rootfs: Utf8PathBuf,
817817
rootfs_fd: Dir,
818818
rootfs_uuid: Option<String>,
@@ -1229,7 +1229,11 @@ async fn install_to_filesystem_impl(state: &State, rootfs: &mut RootSetup) -> Re
12291229
.context("Writing aleph version")?;
12301230
}
12311231

1232-
crate::bootloader::install_via_bootupd(&rootfs.device, &rootfs.rootfs, &state.config_opts)?;
1232+
crate::bootloader::install_via_bootupd(
1233+
&rootfs.device_info,
1234+
&rootfs.rootfs,
1235+
&state.config_opts,
1236+
)?;
12331237
tracing::debug!("Installed bootloader");
12341238

12351239
// Finalize mounted filesystems
@@ -1583,6 +1587,7 @@ pub(crate) async fn install_to_filesystem(
15831587
dev
15841588
};
15851589
tracing::debug!("Backing device: {backing_device}");
1590+
let device_info = crate::blockdev::list_dev(Utf8Path::new(&backing_device))?;
15861591

15871592
let rootarg = format!("root={}", root_info.mount_spec);
15881593
let mut boot = if let Some(spec) = fsopts.boot_mount_spec {
@@ -1611,7 +1616,7 @@ pub(crate) async fn install_to_filesystem(
16111616
matches!(fsopts.replace, Some(ReplaceMode::Alongside)) || fsopts.skip_finalize;
16121617
let mut rootfs = RootSetup {
16131618
luks_device: None,
1614-
device: backing_device.into(),
1619+
device_info,
16151620
rootfs: fsopts.root_path,
16161621
rootfs_fd,
16171622
rootfs_uuid: inspect.uuid.clone(),

lib/src/install/baseline.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,9 +439,10 @@ pub(crate) fn install_create_rootfs(
439439
BlockSetup::Direct => None,
440440
BlockSetup::Tpm2Luks => Some(luks_name.to_string()),
441441
};
442+
let device_info = crate::blockdev::list_dev(&devpath)?;
442443
Ok(RootSetup {
443444
luks_device,
444-
device: devpath,
445+
device_info,
445446
rootfs,
446447
rootfs_fd,
447448
rootfs_uuid: Some(root_uuid.to_string()),

0 commit comments

Comments
 (0)