run: add --background option

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2018-11-06 00:00:00 +00:00
parent 753cbe68ff
commit d39d5b8154
3 changed files with 20 additions and 3 deletions

View File

@@ -17,7 +17,7 @@ toc::[]
== Getting started == 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 <<qemu-buildroot-setup-getting-started>>. If you don't know which one to go for, start with <<qemu-buildroot-setup-getting-started>>.

View File

@@ -875,6 +875,7 @@ def setup(parser):
this_module.qemu_gdb_port = this_module.qemu_base_port + 3 this_module.qemu_gdb_port = this_module.qemu_base_port + 3
this_module.extra_serial_port = this_module.qemu_base_port + 4 this_module.extra_serial_port = this_module.qemu_base_port + 4
this_module.gdb_port = this_module.qemu_gdb_port 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. # Baremetal.
this_module.baremetal = args.baremetal this_module.baremetal = args.baremetal

20
run
View File

@@ -10,6 +10,7 @@ import time
import common import common
defaults = { defaults = {
'background': False,
'cpus': 1, 'cpus': 1,
'wait_gdb': False, 'wait_gdb': False,
'debug_vm': None, 'debug_vm': None,
@@ -251,7 +252,10 @@ def main(args, extra_args=None):
if args.debug_vm: if args.debug_vm:
serial_monitor = [] serial_monitor = []
else: 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: if args.kvm:
extra_emulator_args.extend(['-enable-kvm', common.Newline]) extra_emulator_args.extend(['-enable-kvm', common.Newline])
extra_emulator_args.extend(['-serial', 'tcp::{},server,nowait'.format(common.extra_serial_port), 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'}) parser = common.get_argparse(argparse_args={'description':'Run Linux on an emulator'})
init_group = parser.add_mutually_exclusive_group() init_group = parser.add_mutually_exclusive_group()
kvm_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( parser.add_argument(
'-c', '--cpus', default=defaults['cpus'], type=int, '-c', '--cpus', default=defaults['cpus'], type=int,
help='Number of guest CPUs to emulate. Default: %(default)s' 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( init_group.add_argument(
'--terminal', default=defaults['terminal'], action='store_true', '--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. 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 Set automatically by --debug-vm, but you still need this option to debug
gem5 Python scripts. gem5 Python scripts.