Kernel messages on console can be mixed with run_serial() command output
and might even prevent run_serial() to read the command exit code.
To fix this, on the first non-raw run_serial() call, run "dmesg -n 1"
first to hide the kernel message from the console we use to run
commands. Note that kernel messages are still logged in dmesg buffer.
man dmesg (from util-linux):
> -n, --console-level
> level Set the level at which printing of messages is done to the
> console. The level is a level number or abbreviation of the level name.
> For all supported levels see the --help output.
>
> For example, -n 1 or -n emerg prevents all messages, except emergency (panic)
> messages, from appearing on the console. All levels of messages are still
> written to /proc/kmsg, so syslogd(8) can still be used to control exactly where
> kernel messages appear. When the -n option is used, dmesg will not print or
> clear the kernel ring buffer.
Busybox's dmesg also support the option.
Raw run_serial() calls are used during the login process when it's too
early to run the dmesg command.
Fixes [ YOCTO #16189 ]
Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
self.boot_patterns = boot_patterns
self.tmpfsdir = tmpfsdir
self.native_sysroot = native_sysroot
+ self.kernel_messages_disabled = False
self.runqemutime = 300
if not workdir:
def run_serial(self, command, raw=False, timeout=60):
# Returns (status, output) where status is 1 on success and 0 on error
+ # Disable kernel messages before running the first non-raw command
+ if not raw and not self.kernel_messages_disabled:
+ self.kernel_messages_disabled = True
+ self.run_serial("dmesg -n 1\n", raw=True)
+
# We assume target system have echo to get command status
if not raw:
command = "%s; echo $?\n" % command