-
Notifications
You must be signed in to change notification settings - Fork 84
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
lib/bootloader: Write to PReP partition on ppc64le #667
Conversation
This is part of ppc64le enablement 578 |
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.
Thanks for working on this!
lib/src/bootloader.rs
Outdated
} else { | ||
// While writing to a disk use realpath to extract | ||
// PowerPC-PReP-boot partition | ||
let result = Command::new("realpath") |
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 don't think this will do much different from the builtin https://doc.rust-lang.org/std/fs/fn.canonicalize.html
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.
Thanks, this helps.
lib/src/bootloader.rs
Outdated
@@ -12,15 +16,44 @@ pub(crate) fn install_via_bootupd( | |||
device: &Utf8Path, | |||
rootfs: &Utf8Path, | |||
configopts: &crate::install::InstallConfigOpts, | |||
via_loopback: bool, |
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 think it'd be a bit simpler for us to inspect the target block device here and special case loopback, instead of passing down this boolean.
(But, not opposed to the bool either, it's OK)
lib/src/bootloader.rs
Outdated
// PowerPC-PReP-boot partition | ||
let result = Command::new("realpath") | ||
.arg("-L") | ||
.arg("/dev/disk/by-partlabel/PowerPC-PReP-boot") |
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 a complex topic because in the fully general case, there might already be an existing partition with this label on the system. Think about a scenario where we are trying to create a raw disk image from an already booted host.
Now, we're effectively bypassing that here because we special case the loopback path.
Backing up to a higher level here, I've been trying to drive alignment between all the different install paths we have in the Fedora-derivative ecosystem. One of those is Fedora CoreOS and derivatives, see https://github.com/coreos/coreos-assembler/blob/c426a1c34a745762a9314872212e447b9fd26488/src/osbuild-manifests/coreos.osbuild.ppc64le.mpp.yaml#L343 on this topic.
That's basically the loopback install path (generic disk image generation).
Whereas this one should more align with Anaconda...which, I suspect probably needs similar logic with bootupd.
All of this perhaps argues that we should change bootupd to handle this instead?
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.
Right, fair point.
Infact my first preference was lsblk command, not realpath. Since lsblk command takes a device as input we should be able to solve this issue of multiple devices (containing PReP boot) present on a system. For some unknown reason the command did not work as expected, although the same works outside of bootc.
$ lsblk --paths --noheadings -o NAME --filter 'PARTLABEL=="PowerPC-PReP-boot"' /dev/sdb
/dev/sdb1
I probably did not codify the logic correctly. --filter option wasn't being enforced correctly and as a result all the partitions on the device were listed in the output. I will revisit the logic again.
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 think it may be simpler to use our internal wrapper for lsblk
and then just traverse the children looking for ones with that label in Rust code instead of filtering at the lsblk level.
But I don't object either to adding support for filtering to our lsblk wrapper either.
Can you post (whether as a diff here or just force push to this PR) the code you were trying that wasn't working?
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 have pushed the latest code.
lib/src/bootloader.rs
Outdated
println!("{}", String::from_utf8_lossy(&result.stderr)); | ||
anyhow::bail!("realpath failed with {}", result.status); | ||
} | ||
prepboot_dir = String::from_utf8(result.stdout).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.
We generally avoid use of unwrap()
except for things we know "statically" can't/shouldn't fail. Non-UTF8 filesystem paths are generally in that "shouldn't happen" case but crashing the process is undesirable if we do happen to find one.
In this case it's basically equally easy to handle this as an error, just change .unwrap()
to ?
.
Will look at the bootupd code. Is it okay then to close this PR? |
The fact the CoreOS pipeline is doing something similar to this today argues for doing the same thing here to start. But I think both could likely be cleaned up by having all the logic in bootupd. And it would likely simplify a future change for bootc-image-builder to support ppc64le too. So...up to you! I would lean slightly towards landing work here to start as I think we can condense this patch into something pretty simple. |
using lsblk I was able to simply the code by restricting the change only to bootloader.rs and also ensure it will work even if more that one device is present on the system. Unfortunately lsblk command that should help implement this logic is not working as expected. // get PowerPC-PReP-boot device information --filter option doesn't seem to work and gives following o/p Running bootupctl to install bootloader
The same command with --filter option works correctly when executed manually Any idea what can be the reason for lsblk --filter command to not work as expected? |
It looks like the I encountered another version issue in my PR #665 (comment) |
Thanks. Yes --filter option is available with lsblk. The version of lsblk inside the container is 2.40.1 (lsblk from util-linux 2.40.1 ) |
lib/src/bootloader.rs
Outdated
"--noheadings", | ||
"--paths", | ||
"--filter", | ||
&(format!(r#"'PARTLABEL=="PowerPC-PReP-boot"'"#)), |
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 think the problem may be here in that you're passing an extra '
that is needed only when invoking from shell script.
I've pushed an additional commit to this PR that I think will fix the problem; I have a ppc64le machine provisioning now to try to at least test this out myself. What do you think of this updated code? Can you review/test? |
Thank You. I tried this code, but unfortunately it still fails with Deploying container image...Freed objects: 118 bytes Looking at the lsblk -J output, label string is null for all partitions. partlabel attribute contains the right string.
I extended the device structure to include partlabel as follows
and then replaced label with partlabel in bootloader code
It still fails with Going back to your comment about using ' in the string (shell vs rust), it was spot-on. I removed the ' from the string and it worked. bootc install now works with both writing image to block device as well as writing to a qcow2 file. |
OK a few things. First, I split out a PR to beef up our blockdev handling, see #680 (if you or @yoheiueda could glance at/review that'd be nice). On this specific PR I've:
What do you think? |
The first 3 patches looks good to me. With the code from commit 3be47ba included the bootupd specific changes to handle powerpc64 fails to compile.
|
Sorry about that, I had compile tested the previous code by locally changing the ifdef. Anyways the compiler is right with:
Pushed a fix. |
Thank you for the fix. With this fix the code compiles correctly. ERROR Installing to disk: Creating rootfs: Listing device /dev/sdb: invalid type: integer With tracing enabled I get
|
I think what happened here is basically I was working on #680 locally and ended up splitting it out from this PR and fixed bugs there, but I forgot to rebase this PR on the properly tested version. I've forced push an update to this PR (and I have a ppc64le system provisioning again...on Friday it took 4 hours to make one for some reason and I didn't get a chance to actually e2e test myself) |
OK yeah, testing this e2e meaning one needs to build both bib and the bootc base images is clearly an ergonomic hit, but it's all kind of circular; once we land a few enablement patches like this I think we can turn it on in the build systems by default. |
I tested this, and we still fail to find the partition. Digging in the reason is because for the stuff not in In the short term, we could run |
Another viable path is to use I may look at this tomorrow. (It's probably high time we split out a separate blockdev internal crate...) |
yes, I have already submitted ppc64le arch enablement patches to bootc-image-builder. |
Thanks. Adding -v /run/udev:/run/udev fixes the issue while writing the image to a disk. The same does not work while writing image to qcow2. |
➡️ #688 |
OK now rebased 🏄 on top of #688 - I also changed things so we have a shared constant for the GUID, which makes more sense to use than a label by default. |
@sacsant can you give this another test/review? |
Bootloader code currently writes required data to base/parent device (eg /dev/sda). This logic does not work for ppc64le architecture as bootloader configuration has to be written to PRePboot partition(typically first partition of disk). This patch adds code to identify PowerPC-PReP-boot partition (for ppc64le architecture) using lsblk command and writes bootloader data to it. Co-authored-by: Colin Walters <[email protected]> Signed-off-by: Sachin Sant <[email protected]> Signed-off-by: Colin Walters <[email protected]>
Thanks. The changes look good except for using uuid for comparison. I have pushed updated code with following change
With this change install to-disk works correctly. Without this change the command will fail with ERROR Installing to disk: Installing bootloader: Failed to find PReP partition with GUID 9E1A2D38-C612-4316-AA26-8B49521E5A8B The above mentioned change is required as uuid field of sfdisk is dynamically generated and will keep changing each time a partition is created. IMO we should rely on type field which will always point to PREP_BOOT ID string
Let me know. |
Oops yes, my bad at getting the uuids mixed up. Thanks! Queued this one to merge! |
lib: Release 0.15.1
Signed-off-by: Sachin Sant [email protected]