From d39d5b81543ed2f7b8ed52adca129cb381fab019 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciro=20Santilli=20=E5=85=AD=E5=9B=9B=E4=BA=8B=E4=BB=B6=20?= =?UTF-8?q?=E6=B3=95=E8=BD=AE=E5=8A=9F?= Date: Tue, 6 Nov 2018 00:00:00 +0000 Subject: [PATCH] run: add --background option --- README.adoc | 2 +- common.py | 1 + run | 20 ++++++++++++++++++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/README.adoc b/README.adoc index dff6c77..56c11a7 100644 --- a/README.adoc +++ b/README.adoc @@ -17,7 +17,7 @@ toc::[] == Getting started -Each child section describes a possible different setups for this repo. +Each child section describes a possible different setup for this repo. If you don't know which one to go for, start with <>. diff --git a/common.py b/common.py index 1ea6da0..b221d47 100644 --- a/common.py +++ b/common.py @@ -875,6 +875,7 @@ def setup(parser): this_module.qemu_gdb_port = this_module.qemu_base_port + 3 this_module.extra_serial_port = this_module.qemu_base_port + 4 this_module.gdb_port = this_module.qemu_gdb_port + this_module.qemu_background_serial_file = os.path.join(this_module.qemu_run_dir, 'background.log') # Baremetal. this_module.baremetal = args.baremetal diff --git a/run b/run index ab0fb45..f04930a 100755 --- a/run +++ b/run @@ -10,6 +10,7 @@ import time import common defaults = { + 'background': False, 'cpus': 1, 'wait_gdb': False, 'debug_vm': None, @@ -251,7 +252,10 @@ def main(args, extra_args=None): if args.debug_vm: serial_monitor = [] else: - serial_monitor = ['-serial', 'mon:stdio', common.Newline] + if args.background: + serial_monitor = ['-serial', 'file:{}'.format(common.qemu_background_serial_file), common.Newline] + else: + serial_monitor = ['-serial', 'mon:stdio', common.Newline] if args.kvm: extra_emulator_args.extend(['-enable-kvm', common.Newline]) extra_emulator_args.extend(['-serial', 'tcp::{},server,nowait'.format(common.extra_serial_port), common.Newline]) @@ -397,6 +401,17 @@ def get_argparse(): parser = common.get_argparse(argparse_args={'description':'Run Linux on an emulator'}) init_group = parser.add_mutually_exclusive_group() kvm_group = parser.add_mutually_exclusive_group() + parser.add_argument( + '--background', default=defaults['background'], action='store_true', + help='''\ +Send QEMU output to a file instead of the terminal so it does not require a +terminal attached to run on the background. Interactive input cannot be given. +TODO: use a port instead. If only there was a way to redirect a serial to multiple +places, both to a port and a file? We use the file currently to be able to have +any output at all. +https://superuser.com/questions/1373226/how-to-redirect-qemu-serial-output-to-both-a-file-and-the-terminal-or-a-port +''' + ) parser.add_argument( '-c', '--cpus', default=defaults['cpus'], type=int, help='Number of guest CPUs to emulate. Default: %(default)s' @@ -513,7 +528,8 @@ rare and don't affect performance, because `./configure ) init_group.add_argument( '--terminal', default=defaults['terminal'], action='store_true', - help='''Output to the terminal, don't pipe to tee as the default. + help='''\ +Output to the terminal, don't pipe to tee as the default. Does not save the output to a file, but allows you to use debuggers. Set automatically by --debug-vm, but you still need this option to debug gem5 Python scripts.