]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
qemurunner: Hide kernel messages on first non-raw run_serial() call
authorYoann Congal <yoann.congal@smile.fr>
Sat, 14 Mar 2026 16:57:41 +0000 (17:57 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 16 Mar 2026 17:05:37 +0000 (17:05 +0000)
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>
meta/lib/oeqa/utils/qemurunner.py

index 57f86970fec8f4c58c057c73fda0bcbf9e950053..1ceeeff96a460f7d93f80d92a50ee23effc47aab 100644 (file)
@@ -77,6 +77,7 @@ class QemuRunner:
         self.boot_patterns = boot_patterns
         self.tmpfsdir = tmpfsdir
         self.native_sysroot = native_sysroot
+        self.kernel_messages_disabled = False
 
         self.runqemutime = 300
         if not workdir:
@@ -659,6 +660,11 @@ class QemuRunner:
     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