summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2015-09-22 17:21:40 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-09-23 09:53:20 +0100
commit0613301c88dcb5fde293015aadc0bf85b7d4d266 (patch)
tree9a99946fa0f6a05a3b5a925a83ea753e4e18abef
parentc4181c6e7ec9626f58e5eeddc8b94c442f19a235 (diff)
downloadpoky-0613301c88dcb5fde293015aadc0bf85b7d4d266.tar.gz
devtool: add basic means of running runqemu within the extensible SDK
We ship the runqemu script and if we build QEMU itself within the extensible SDK, then it would be nice to be able to run it. This is a very thin wrapper around runqemu, supplying the machine and image name so the user doesn't need to. (This subcommand is only available within the extensible SDK since it only really makes sense there where it is otherwise hard to run runqemu directly.) Implements [YOCTO #6657]. (From OE-Core rev: abca7a0cac7068ffe6a6b873d0842f804388b621) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--scripts/lib/devtool/runqemu.py64
1 files changed, 64 insertions, 0 deletions
diff --git a/scripts/lib/devtool/runqemu.py b/scripts/lib/devtool/runqemu.py
new file mode 100644
index 0000000000..e7f26ab6d8
--- /dev/null
+++ b/scripts/lib/devtool/runqemu.py
@@ -0,0 +1,64 @@
1# Development tool - runqemu command plugin
2#
3# Copyright (C) 2015 Intel Corporation
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 2 as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License along
15# with this program; if not, write to the Free Software Foundation, Inc.,
16# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18"""Devtool runqemu plugin"""
19
20import os
21import bb
22import logging
23import argparse
24import glob
25from devtool import exec_build_env_command, setup_tinfoil, DevtoolError
26
27logger = logging.getLogger('devtool')
28
29def runqemu(args, config, basepath, workspace):
30 """Entry point for the devtool 'runqemu' subcommand"""
31
32 tinfoil = setup_tinfoil()
33 machine = tinfoil.config_data.getVar('MACHINE', True)
34 bindir_native = tinfoil.config_data.getVar('STAGING_BINDIR_NATIVE', True)
35 tinfoil.shutdown()
36
37 if not glob.glob(os.path.join(bindir_native, 'qemu-system-*')):
38 raise DevtoolError('QEMU is not available within this SDK')
39
40 imagename = args.imagename
41 if not imagename:
42 sdk_targets = config.get('SDK', 'sdk_targets', '').split()
43 if sdk_targets:
44 imagename = sdk_targets[0]
45 if not imagename:
46 raise DevtoolError('Unable to determine image name to run, please specify one')
47
48 try:
49 exec_build_env_command(config.init_path, basepath, 'runqemu %s %s %s' % (machine, imagename, " ".join(args.args)), watch=True)
50 except bb.process.ExecutionError as e:
51 # We've already seen the output since watch=True, so just ensure we return something to the user
52 return e.exitcode
53
54 return 0
55
56def register_commands(subparsers, context):
57 """Register devtool subcommands from this plugin"""
58 if context.fixed_setup:
59 parser_runqemu = subparsers.add_parser('runqemu', help='Run QEMU on the specified image',
60 description='Runs QEMU to boot the specified image')
61 parser_runqemu.add_argument('imagename', help='Name of built image to boot within QEMU', nargs='?')
62 parser_runqemu.add_argument('args', help='Any remaining arguments are passed to the runqemu script (pass --help after imagename to see what these are)',
63 nargs=argparse.REMAINDER)
64 parser_runqemu.set_defaults(func=runqemu)