Skip to content

Commit a08801b

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 <[email protected]>
1 parent e5a94c6 commit a08801b

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
@@ -823,7 +823,7 @@ fn require_skopeo_with_containers_storage() -> Result<()> {
823823

824824
pub(crate) struct RootSetup {
825825
luks_device: Option<String>,
826-
device: Utf8PathBuf,
826+
device_info: crate::blockdev::Device,
827827
rootfs: Utf8PathBuf,
828828
rootfs_fd: Dir,
829829
rootfs_uuid: Option<String>,
@@ -1240,7 +1240,11 @@ async fn install_to_filesystem_impl(state: &State, rootfs: &mut RootSetup) -> Re
12401240
.context("Writing aleph version")?;
12411241
}
12421242

1243-
crate::bootloader::install_via_bootupd(&rootfs.device, &rootfs.rootfs, &state.config_opts)?;
1243+
crate::bootloader::install_via_bootupd(
1244+
&rootfs.device_info,
1245+
&rootfs.rootfs,
1246+
&state.config_opts,
1247+
)?;
12441248
tracing::debug!("Installed bootloader");
12451249

12461250
// Finalize mounted filesystems
@@ -1594,6 +1598,7 @@ pub(crate) async fn install_to_filesystem(
15941598
dev
15951599
};
15961600
tracing::debug!("Backing device: {backing_device}");
1601+
let device_info = crate::blockdev::list_dev(Utf8Path::new(&backing_device))?;
15971602

15981603
let rootarg = format!("root={}", root_info.mount_spec);
15991604
let mut boot = if let Some(spec) = fsopts.boot_mount_spec {
@@ -1622,7 +1627,7 @@ pub(crate) async fn install_to_filesystem(
16221627
matches!(fsopts.replace, Some(ReplaceMode::Alongside)) || fsopts.skip_finalize;
16231628
let mut rootfs = RootSetup {
16241629
luks_device: None,
1625-
device: backing_device.into(),
1630+
device_info,
16261631
rootfs: fsopts.root_path,
16271632
rootfs_fd,
16281633
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)