-
Notifications
You must be signed in to change notification settings - Fork 617
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
feat: support kexec from uki
Support kexec from UKI for non-secureboot by extracting kernel, initramfs and cmdline from UKI Fixes: #10189 Signed-off-by: Noel Georgi <[email protected]>
Showing
5 changed files
with
249 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
internal/app/machined/pkg/runtime/v1alpha1/bootloader/kexec/kexec.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
// Package kexec call unix.KexecFileLoad with error handling. | ||
package kexec | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"log" | ||
|
||
"golang.org/x/sys/unix" | ||
|
||
"github.com/siderolabs/talos/internal/app/machined/pkg/runtime" | ||
) | ||
|
||
// Load calls unix.KexecFileLoad with error handling and sets the machine state to kexec prepared. | ||
func Load(r runtime.Runtime, kernelFD, initrdFD int, cmdline string) error { | ||
if err := unix.KexecFileLoad(kernelFD, initrdFD, cmdline, 0); err != nil { | ||
switch { | ||
case errors.Is(err, unix.ENOSYS): | ||
log.Printf("kexec support is disabled in the kernel") | ||
|
||
return nil | ||
case errors.Is(err, unix.EPERM): | ||
log.Printf("kexec support is disabled via sysctl") | ||
|
||
return nil | ||
case errors.Is(err, unix.EBUSY): | ||
log.Printf("kexec is busy") | ||
|
||
return nil | ||
default: | ||
return fmt.Errorf("error loading kernel for kexec: %w", err) | ||
} | ||
} | ||
|
||
r.State().Machine().KexecPrepared(true) | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters