ktest: Add workaround to avoid unexpected power cycle
PATCH 1/1 ktest: Add workaround to avoid unexpected power cycle
From: Masayoshi Mizuma <[email protected]>
Unexpected power cycle occurs while the installation of the kernel.
That is because the default reboot command, "ssh $SSH_USER@$MACHINE reboot" exits as 255 even if the reboot is successfully done, like as:
]# ssh root@Test reboot
Connection to Test closed by remote host.
]# echo $?
255
]#
To avoid the unexpected power cycle, the reboot is considered as successfully done if the reboot is the default command and the return code is 255.
--- tools/testing/ktest/ktest.pl | 9 +++++++++ 1 file changed, 9 insertions(+)
tools/testing/ktest/ktest.pl +9 -0
@@ -1737,6 +1737,11 @@ sub run_command { my $dord = 0; my $dostdout = 0; my $pid; + my $is_default_reboot = 0; + + if ($command eq $default{REBOOT}) { + $is_default_reboot = 1; + } $command =~ s/\$SSH_USER/$ssh_user/g; $command =~ s/\$MACHINE/$machine/g;
@@ -1791,6 +1796,10 @@ sub run_command { # shift 8 for real exit status $run_command_status = $? >> 8; + if ($run_command_status == 255 && $is_default_reboot) { + $run_command_status = 0; + } + close(CMD); close(LOG) if ($dolog); close(RD) if ($dord);
Signature · 1 line
2.20.1
Steven Rostedt
maintainerQuoted 15 lines · On Wed, 17 Apr 2019 16:14:42 -0400 Masayoshi Mizuma <[email protected]>…
From: Masayoshi Mizuma <[email protected]>
Unexpected power cycle occurs while the installation of the kernel.
That is because the default reboot command, "ssh $SSH_USER@$MACHINE reboot" exits as 255 even if the reboot is successfully done, like as:
]# ssh root@Test reboot
Connection to Test closed by remote host.
]# echo $?
255
]#
Quoted 4 lines
To avoid the unexpected power cycle, the reboot is considered as successfully done if the reboot is the default command and the return code is 255.
Ah that explains why I've been seeing this :-)
Can we add a config modifying variable called:
REBOOT_RETURN_CODE
that is by default 255 and can be changed by the config file?
You just need to add in %default:
"REBOOT_RETURN_CODE" => 255,
my $reboot_return_code;
and in %option_map:
"REBOOT_RETURN_CODE" => \$reboot_return_code,
Quoted 10 lines
Signed-off-by Masayoshi Mizuma <[email protected]>--- tools/testing/ktest/ktest.pl | 9 +++++++++ 1 file changed, 9 insertions(+)tools/testing/ktest/ktest.pl +0
-0
tools/testing/ktest/ktest.pl sub run_command { · line 1744
Quoted 8 lines
tools/testing/ktest/ktest.pl +5
-0@@ -1737,6 +1737,11 @@ sub run_command { my $dord = 0; my $dostdout = 0; my $pid; + my $is_default_reboot = 0; + + if ($command eq $default{REBOOT}) { + $is_default_reboot = 1; + }
Do we really need to add this variable?
tools/testing/ktest/ktest.pl sub run_command { · line 1799
Quoted 8 lines
tools/testing/ktest/ktest.pl +1
-0$command =~ s/\$SSH_USER/$ssh_user/g; $command =~ s/\$MACHINE/$machine/g;@@ -1791,6 +1796,10 @@ sub run_command { # shift 8 for real exit status $run_command_status = $? >> 8; + if ($run_command_status == 255 && $is_default_reboot) {
Instead can we have:
if ($command eq $default{REBOOT} &&
$run_command_status == $reboot_return_code) {?
Thanks for these patches!
-- Steve
Quoted 6 lines
tools/testing/ktest/ktest.pl +3
-0+ $run_command_status = 0; + } + close(CMD); close(LOG) if ($dolog); close(RD) if ($dord);
Quoted 33 lines · Steven Rostedt
Quoted 15 lines · On Wed, 17 Apr 2019 16:14:42 -0400 Masayoshi Mizuma <[email protected]>…
From: Masayoshi Mizuma <[email protected]>
Unexpected power cycle occurs while the installation of the kernel.
That is because the default reboot command, "ssh $SSH_USER@$MACHINE reboot" exits as 255 even if the reboot is successfully done, like as:
]# ssh root@Test reboot
Connection to Test closed by remote host.
]# echo $?
255
]#Quoted 4 lines
To avoid the unexpected power cycle, the reboot is considered as successfully done if the reboot is the default command and the return code is 255.
Ah that explains why I've been seeing this :-)
Can we add a config modifying variable called:
REBOOT_RETURN_CODEthat is by default 255 and can be changed by the config file?
You just need to add in %default:
Quoted 8 lines
"REBOOT_RETURN_CODE" => 255,my $reboot_return_code;
and in %option_map:
"REBOOT_RETURN_CODE" => \$reboot_return_code,
Great idea, thanks! I'll add thease.
Quoted 7 lines
Quoted 7 lines
Signed-off-by Masayoshi Mizuma <[email protected]>--- tools/testing/ktest/ktest.pl | 9 +++++++++ 1 file changed, 9 insertions(+)
Quoted 20 lines
tools/testing/ktest/ktest.pl sub run_command { · line 1744
Quoted 13 lines
tools/testing/ktest/ktest.pl +5
-0@@ -1737,6 +1737,11 @@ sub run_command { my $dord = 0; my $dostdout = 0; my $pid; + my $is_default_reboot = 0; + + if ($command eq $default{REBOOT}) { + $is_default_reboot = 1; + }Do we really need to add this variable?
Quoted 3 lines
tools/testing/ktest/ktest.pl +0
-0$command =~ s/\$SSH_USER/$ssh_user/g; $command =~ s/\$MACHINE/$machine/g;
$command is modified here, so...
Quoted 4 lines
Quoted 4 lines
tools/testing/ktest/ktest.pl +0
-0@@ -1791,6 +1796,10 @@ sub run_command { # shift 8 for real exit status $run_command_status = $? >> 8;
Quoted 8 lines
tools/testing/ktest/ktest.pl sub run_command { · line 1799
Quoted 1 line
tools/testing/ktest/ktest.pl +1
-0+ if ($run_command_status == 255 && $is_default_reboot) {Instead can we have:
if ($command eq $default{REBOOT} && $run_command_status == $reboot_return_code) {?
How about the following?
@@ -1737,6 +1740,7 @@ sub run_command {
my $dord = 0;
my $dostdout = 0;
my $pid;+ my $command_orig = $command;
$command =~ s/\$SSH_USER/$ssh_user/g;
$command =~ s/\$MACHINE/$machine/g;
@@ -1791,6 +1795,11 @@ sub run_command {
# shift 8 for real exit status
$run_command_status = $? >> 8;+ if ($command_orig eq $default{REBOOT} &&
+ $run_command_status == $reboot_return_code) {
+ $run_command_status = 0;
+ }
+
close(CMD);
close(LOG) if ($dolog);
close(RD) if ($dord);Thanks!
Masa
Steven Rostedt
maintainerQuoted 18 lines · On Wed, 17 Apr 2019 16:59:13 -0400 Masayoshi Mizuma <[email protected]>…
Quoted 18 lines
tools/testing/ktest/ktest.pl sub run_command { · line 1744
Quoted 13 lines
tools/testing/ktest/ktest.pl +5
-0@@ -1737,6 +1737,11 @@ sub run_command { my $dord = 0; my $dostdout = 0; my $pid; + my $is_default_reboot = 0; + + if ($command eq $default{REBOOT}) { + $is_default_reboot = 1; + }Do we really need to add this variable?
Quoted 1 line
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
$command =~ s/\$SSH_USER/$ssh_user/g; $command =~ s/\$MACHINE/$machine/g;$command is modified here, so...
Ah thanks. This is what I get for reviewing patches without looking at the code it touches ;-)
Quoted 25 lines
Quoted 5 lines
Quoted 5 lines
tools/testing/ktest/ktest.pl +0
-0@@ -1791,6 +1796,10 @@ sub run_command { # shift 8 for real exit status $run_command_status = $? >> 8;Quoted 8 lines
tools/testing/ktest/ktest.pl sub run_command { · line 1799
Quoted 1 line
tools/testing/ktest/ktest.pl +1
-0+ if ($run_command_status == 255 && $is_default_reboot) {Instead can we have:
if ($command eq $default{REBOOT} && $run_command_status == $reboot_return_code) {?
How about the following?
tools/testing/ktest/ktest.pl +1
-0@@ -1737,6 +1740,7 @@ sub run_command { my $dord = 0; my $dostdout = 0; my $pid; + my $command_orig = $command; $command =~ s/\$SSH_USER/$ssh_user/g; $command =~ s/\$MACHINE/$machine/g;
tools/testing/ktest/ktest.pl sub run_command { · line 1802
Quoted 8 lines
tools/testing/ktest/ktest.pl +5
-0@@ -1791,6 +1795,11 @@ sub run_command { # shift 8 for real exit status $run_command_status = $? >> 8; + if ($command_orig eq $default{REBOOT} && + $run_command_status == $reboot_return_code) { + $run_command_status = 0; + } +
Looks fine to me.
Thanks!
-- Steve
Quoted 6 lines
tools/testing/ktest/ktest.pl +0
-0close(CMD); close(LOG) if ($dolog); close(RD) if ($dord);Thanks!
Masa