mirror of
https://github.com/rancher/os.git
synced 2025-07-31 14:41:14 +00:00
Merge pull request #820 from imikushin/kexec-kernel-args
Add --append to `ros os upgrade` to pass kernel args for --kexec
This commit is contained in:
commit
07faa92c7f
@ -54,6 +54,10 @@ func osSubcommands() []cli.Command {
|
||||
Name: "kexec",
|
||||
Usage: "reboot using kexec",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "append",
|
||||
Usage: "kernel args to append by kexec",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -153,7 +157,7 @@ func osUpgrade(c *cli.Context) {
|
||||
if c.Args().Present() {
|
||||
log.Fatalf("invalid arguments %v", c.Args())
|
||||
}
|
||||
if err := startUpgradeContainer(image, c.Bool("stage"), c.Bool("force"), !c.Bool("no-reboot"), c.Bool("kexec")); err != nil {
|
||||
if err := startUpgradeContainer(image, c.Bool("stage"), c.Bool("force"), !c.Bool("no-reboot"), c.Bool("kexec"), c.String("append")); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
@ -172,7 +176,7 @@ func yes(in *bufio.Reader, question string) bool {
|
||||
return strings.ToLower(line[0:1]) == "y"
|
||||
}
|
||||
|
||||
func startUpgradeContainer(image string, stage, force, reboot, kexec bool) error {
|
||||
func startUpgradeContainer(image string, stage, force, reboot, kexec bool, kernelArgs string) error {
|
||||
in := bufio.NewReader(os.Stdin)
|
||||
|
||||
command := []string{
|
||||
@ -182,6 +186,11 @@ func startUpgradeContainer(image string, stage, force, reboot, kexec bool) error
|
||||
|
||||
if kexec {
|
||||
command = append(command, "-k")
|
||||
|
||||
kernelArgs = strings.TrimSpace(kernelArgs)
|
||||
if kernelArgs != "" {
|
||||
command = append(command, "-a", kernelArgs)
|
||||
}
|
||||
}
|
||||
|
||||
container, err := compose.CreateService(nil, "os-upgrade", &project.ServiceConfig{
|
||||
|
@ -6,7 +6,7 @@ SCRIPTS_DIR=$(dirname ${0})
|
||||
. "${SCRIPTS_DIR}/build.conf"
|
||||
VERSION=${VERSION:?"VERSION not set"}
|
||||
|
||||
while getopts "i:f:c:d:t:r:o:p:k" OPTION
|
||||
while getopts "i:f:c:d:t:r:o:p:k:a" OPTION
|
||||
do
|
||||
case ${OPTION} in
|
||||
i) DIST="$OPTARG" ;;
|
||||
@ -17,6 +17,7 @@ do
|
||||
p) PARTITION="$OPTARG" ;;
|
||||
r) ROLLBACK_VERSION="$OPTARG" ;;
|
||||
k) KEXEC=y ;;
|
||||
a) APPEND="$OPTARG" ;;
|
||||
t) ENV="$OPTARG" ;;
|
||||
*) exit 1 ;;
|
||||
esac
|
||||
@ -195,5 +196,8 @@ pvgrub_config "${KERNEL_ARGS}"
|
||||
install_rancher
|
||||
|
||||
if [ "$KEXEC" = "y" ]; then
|
||||
kexec -l ${DIST}/vmlinuz --initrd=${DIST}/initrd -f
|
||||
if [ "$APPEND" = "" ]; then
|
||||
APPEND=$(cat /proc/cmdline)
|
||||
fi
|
||||
kexec -l ${DIST}/vmlinuz --initrd=${DIST}/initrd --append="$APPEND" -f
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user