-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add blockdev
and update bios.rs
#820
Conversation
Skipping CI for Draft Pull Request. |
src/bios.rs
Outdated
let device = self.get_device()?; | ||
let device = device.trim(); | ||
self.run_grub_install("/", device)?; | ||
let sysroot = sysroot.recover_path()?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is taking us back from being file-descriptor based to path based, which is OK here, but it's usually better to find a way to continue using the fd.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense, update to use format!("/proc/self/fd/{}", sysroot.as_raw_fd())
, is this that you meant?
src/bios.rs
Outdated
self.run_grub_install("/", device)?; | ||
let sysroot = sysroot.recover_path()?; | ||
let dest_root = sysroot.to_str().unwrap_or("/"); | ||
let devices = blockdev::get_backing_devices(&dest_root)? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, one technique is doing e.g. findmnt -nv -T . -o SOURCE
and passing the file descriptor as the working directory. This would extend our bindings in findmnt.rs
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, seems this is a little confusing, findmnt
find the source of mount point, for example on RAID1 is /dev/md127
, what we want is call find_parent_devices()
to get the parent device.
src/bios.rs
Outdated
let devices = blockdev::get_backing_devices(&dest_root)? | ||
.into_iter() | ||
.next(); | ||
let dev = devices.unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use .ok_or_else(|| anyhow::anyhow!("Failed to find backing device for {dest_root}"))
or so
} | ||
|
||
/// Find all bios_boot partitions on the backing devices with mountpoint boot | ||
#[allow(dead_code)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with this as is but I think it'd be slightly cleaner if this was part of the second patch
@@ -0,0 +1,208 @@ | |||
use std::collections::HashMap; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a blocker here but maybe we should try to sync this code with https://github.com/containers/bootc/blob/main/lib/src/blockdev.rs ?
I could try to refactor that into a separate internal crate that we sync back into bootupd and coreos-installer?
Or of course we could even try to publish it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a blocker here but maybe we should try to sync this code with https://github.com/containers/bootc/blob/main/lib/src/blockdev.rs ?
I could try to refactor that into a separate internal crate that we sync back into bootupd and coreos-installer?
Or of course we could even try to publish it.
Thanks, that would be better and make this easier.
I tried to copy the bootc/blockdev.rs
, but seems there are a lot of dependencies that also need to sync, for example Task
and bootc_utils::CommandRunExt
, so I give up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea of #820 (comment) is that the Task dependency is gone. However yes, we'd need to pull in bootc-utils
too. We could even do that now.
OK I did just that in #821
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we import https://github.com/containers/bootc/blob/main/lib/src/blockdev.rs like what you did in #821 ? Or wait until it is published?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/bios.rs
Outdated
let device = device.trim(); | ||
self.run_grub_install("/", device)?; | ||
let target_root = "/"; | ||
let devices = blockdev::get_backing_devices(&target_root)? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about adding a helper function like blockdev::get_single_backing_device()
that errors out if it finds > 1 (and also errors out if we somehow get zero).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update to use blockdev::get_single_device()
.
The install code and the blockdev code call each other. Clean up blockdev to only use `bootc-utils`. Prep for splitting out the blockdev stuff into at least a separate internal crate; ref coreos/bootupd#820 Signed-off-by: Colin Walters <[email protected]>
The install code and the blockdev code call each other. Clean up blockdev to only use `bootc-utils`. Prep for splitting out the blockdev stuff into at least a separate internal crate; ref coreos/bootupd#820 Signed-off-by: Colin Walters <[email protected]>
FYI I did containers/bootc#1048 to try to prepare bootc's |
45bc80f
to
74f86fa
Compare
74f86fa
to
3bbfd45
Compare
3bbfd45
to
aeec489
Compare
Close this as did in #824 |
Prep for #132
Add
bootc-blockdev
and local crateblockdev
See containers/bootc#1050
blockdev.rs: Add
#[allow(dead_code)]
for the unused functionsbios.rs: update functions to use blockdev