Commit 27ef067f authored by Wez's avatar Wez Committed by Commit Bot

[Fuchsia] Dump the kernel serial log output, by default, if SSH fails.

Always log kernel serial output to a temporary file on the host, so that
if we're unable to establish connectivity to the QEMU guest then we can
dump the contents of that file for diagnostic use.

Bug: 909936, 869753
Change-Id: Ie44ea6f6d0ccaedbae6994651ec13568ad241a40
Reviewed-on: https://chromium-review.googlesource.com/c/1359483Reviewed-by: default avatarSergey Ulanov <sergeyu@chromium.org>
Commit-Queue: Wez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#613393}
parent 99980056
...@@ -12,6 +12,7 @@ import platform ...@@ -12,6 +12,7 @@ import platform
import socket import socket
import subprocess import subprocess
import sys import sys
import tempfile
import time import time
from common import GetQemuRootForPlatform, EnsurePathExists from common import GetQemuRootForPlatform, EnsurePathExists
...@@ -146,18 +147,27 @@ class QemuTarget(target.Target): ...@@ -146,18 +147,27 @@ class QemuTarget(target.Target):
# Zircon sends debug logs to serial port (see kernel.serial=legacy flag # Zircon sends debug logs to serial port (see kernel.serial=legacy flag
# above). Serial port is redirected to a file through QEMU stdout. # above). Serial port is redirected to a file through QEMU stdout.
# This approach is used instead of loglistener to debug # Unless a |_system_log_file| is explicitly set, we output the kernel serial
# https://crbug.com/86975 . # log to a temporary file, and print that out if we are unable to connect to
# the QEMU guest, to make it easier to diagnose connectivity issues.
temporary_system_log_file = None
if self._system_log_file: if self._system_log_file:
stdout = self._system_log_file stdout = self._system_log_file
stderr = subprocess.STDOUT stderr = subprocess.STDOUT
else: else:
stdout = open(os.devnull) temporary_system_log_file = tempfile.NamedTemporaryFile('w')
stdout = temporary_system_log_file
stderr = sys.stderr stderr = sys.stderr
self._qemu_process = subprocess.Popen(qemu_command, stdin=open(os.devnull), self._qemu_process = subprocess.Popen(qemu_command, stdin=open(os.devnull),
stdout=stdout, stderr=stderr) stdout=stdout, stderr=stderr)
self._WaitUntilReady(); try:
self._WaitUntilReady();
except target.FuchsiaTargetException:
if temporary_system_log_file:
logging.info("Kernel logs:\n" +
open(temporary_system_log_file.name, 'r').read())
raise
def _IsQemuStillRunning(self): def _IsQemuStillRunning(self):
if not self._qemu_process: if not self._qemu_process:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment