Skip to content
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/sysroot: Support /usr/lib/modules/$kver for kernel/initramfs #1079

Closed
wants to merge 1 commit into from

Conversation

cgwalters
Copy link
Member

This is the new Fedora kernel standard layout; it has the advantage
of being in /usr like /usr/lib/ostree-boot, but it's not OSTree
specific.

Further, I think in practice forcing tree builders to compute the checksum is an
annoying stumbling block; since we already switched to e.g. computing checksums
always when doing pulls, the cost of doing another checksum for the
kernel/initramfs is tiny. The "bootcsum" becomes more of an internal
implementation detail.

Now, there is a transition; my current thought for this is that rpm-ostree will
change to default to injecting into both /usr/lib/ostree-boot and
/usr/lib/modules, and stop doing /boot, then maybe next year say we drop the
/usr/lib/ostree-boot by default.

@cgwalters
Copy link
Member Author

Oh ug, the uboot code looks in /usr/lib/ostree-boot explicitly.

@cgwalters
Copy link
Member Author

Reworked this.

First, the tree must include a kernel stored as
`vmlinuz(-.*)?-$checksum` in either `/boot` or `/usr/lib/ostree-boot`.
First, the tree must include a kernel (and optionally an initramfs). The
current standard locations for this is `/usr/lib/modules/$kver/vmlinuz` and
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: s/this is/these are/ ?

* with rpm-ostree with Fedora today, until rpm-ostree learns the new layout.
*/
g_autoptr(OstreeKernelLayout) legacy_layout = g_new0 (OstreeKernelLayout, 1);
legacy_layout->boot_dfd = -1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/me puts on Coverity hat
This feels like it deserves an _ostree_kernel_layout_new () to be safe, though up to you!

}
}

/* ret_boot_dfd will point to either /usr/lib/ostree-boot or /boot, let's
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/ret_boot_dfd/legacy_layout->boot_dfd/

g_auto(GLnxDirFdIterator) dfditer = { 0, };
if (!glnx_dirfd_iterator_init_at (ret_boot_dfd, ".", FALSE, &dfditer, error))
if (!glnx_dirfd_iterator_init_at (legacy_layout->boot_dfd, ".", FALSE, &dfditer, error))
return FALSE;

while (TRUE)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we factor this out as well into a separate function similar to get_kernel_from_tree_usrlib_modules that spits out the legacy_layout? Would make this function much nicer to read if it just has the business logic.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, definitely looks nicer. Update ⬇️

This is the new Fedora kernel standard layout; it has the advantage
of being in `/usr` like `/usr/lib/ostree-boot`, but it's not OSTree
specific.

Further, I think in practice forcing tree builders to compute the checksum is an
annoying stumbling block; since we already switched to e.g. computing checksums
always when doing pulls, the cost of doing another checksum for the
kernel/initramfs is tiny. The "bootcsum" becomes more of an internal
implementation detail.

Now, there is a transition; my current thought for this is that rpm-ostree will
change to default to injecting into both `/usr/lib/ostree-boot` and
`/usr/lib/modules`, and stop doing `/boot`, then maybe next year say we drop the
`/usr/lib/ostree-boot` by default.

A twist here is that the default Fedora kernel RPM layout (and what's in
rpm-ostree today) includes a kernel but *not* an initramfs in
`/usr/lib/modules`. If we looked only there, we'd just find the kernel. So we
need to look in both, and then special case this - pick the legacy layout if we
have `/usr/lib/modules` but not an initramfs.

While here, rework the code to have an `OstreeKernelLayout` struct which makes
dealing with all of the variables nicer.
@jlebon
Copy link
Member

jlebon commented Aug 18, 2017

Nice! @rh-atomic-bot r+ ae00359

@rh-atomic-bot
Copy link

⌛ Testing commit ae00359 with merge 3ab0d5e...

@rh-atomic-bot
Copy link

☀️ Test successful - status-atomicjenkins
Approved by: jlebon
Pushing 3ab0d5e to master...

cgwalters added a commit to cgwalters/ostree that referenced this pull request Aug 19, 2017
Follow up to <ostreedev#1079>; I was working on
the rpm-ostree updates for this, and I think it's more consistent if we have
`.img` here, since that's a closer match to the "remove $kver" that results in
`vmlinuz`. Also just best practice to have file suffix types where they make
sense.

The astute reader might notice this sneaks in a change where we'd crash if the
legacy bootdir didn't have an initramfs...yeah, should probably have test
coverage of that.
rh-atomic-bot pushed a commit that referenced this pull request Aug 21, 2017
Follow up to <#1079>; I was working on
the rpm-ostree updates for this, and I think it's more consistent if we have
`.img` here, since that's a closer match to the "remove $kver" that results in
`vmlinuz`. Also just best practice to have file suffix types where they make
sense.

The astute reader might notice this sneaks in a change where we'd crash if the
legacy bootdir didn't have an initramfs...yeah, should probably have test
coverage of that.

Closes: #1095
Approved by: jlebon
rh-atomic-bot pushed a commit that referenced this pull request Aug 21, 2017
Follow up to <#1079>; I was working on
the rpm-ostree updates for this, and I think it's more consistent if we have
`.img` here, since that's a closer match to the "remove $kver" that results in
`vmlinuz`. Also just best practice to have file suffix types where they make
sense.

The astute reader might notice this sneaks in a change where we'd crash if the
legacy bootdir didn't have an initramfs...yeah, should probably have test
coverage of that.

Closes: #1095
Approved by: jlebon
cgwalters added a commit to cgwalters/fedora-coreos-config that referenced this pull request Sep 16, 2019
This is the new default; we end up with the kernel data in
only once place.  See the treefile docs as well as
ostreedev/ostree#1079
and discussion in
ostreedev/ostree#1873
cgwalters added a commit to cgwalters/fedora-coreos-config that referenced this pull request Sep 16, 2019
This is the new default; we end up with the kernel data in
only once place.  See the treefile docs as well as
ostreedev/ostree#1079
and discussion in
ostreedev/ostree#1873
jlebon pushed a commit to coreos/fedora-coreos-config that referenced this pull request Sep 16, 2019
This is the new default; we end up with the kernel data in
only once place.  See the treefile docs as well as
ostreedev/ostree#1079
and discussion in
ostreedev/ostree#1873
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants