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

Improve "is kernel compressed" check #60

Merged
merged 3 commits into from
Aug 29, 2023

Conversation

cfergeau
Copy link
Collaborator

ARM64 kernels must be uncompressed before they can be booted.
vfkit has a check for this to warn the user before attempting to start the VM.
However this check has both false negatives and false positives (with an
uncompressed puipui linux kernel, and with a compressed fedora kernel)

This PR should fix both situations

The code was checking for this on all arches, but it's only arm64
kernels which vfkit can't boot if they are compressed.
So far we were using `h2non/filetype` which is not a great fit for what
we want to do, as kernels do not have their own mimetypes, and there is
no nice way to convey compressed/uncompressed/arch through mime types.

This was working through heuristics so far, but the used heuristics
break for the kernel used by puipui linux
(https://github.com/Code-Hex/puipui-linux)

This commit removes the use of h2non/filetype, and reuses the patterns
from https://github.com/file/file/blob/master/magic/Magdir/linux to do
the detection we need.

This only adds a magic for uncompressed arm64 kernels.
There's also a pattern for compressed kernels, but it does not match the arm64
kernels I tested with. They are either detected as gzip files, or as EFI files,
and don't contain the magic pattern.
@openshift-ci
Copy link

openshift-ci bot commented Aug 28, 2023

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from cfergeau. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@praveenkumar
Copy link
Member

CI is failing as part of linter.

This ensures both puipui kernel and fedora/RHEL kernels are detected as
uncompressed when they are.
@cfergeau
Copy link
Collaborator Author

CI is failing as part of linter.

Fixed now!

@praveenkumar praveenkumar merged commit 09e6206 into crc-org:main Aug 29, 2023
4 of 5 checks passed
@cfergeau cfergeau deleted the uncompressed branch September 4, 2023 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants