From patchwork Thu Nov 15 22:14:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Doan X-Patchwork-Id: 12877 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id DB03823FC1 for ; Thu, 15 Nov 2012 22:14:15 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id C1FD2A1923A for ; Thu, 15 Nov 2012 22:14:14 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so2623285iej.11 for ; Thu, 15 Nov 2012 14:14:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :content-type:mime-version:x-launchpad-project:x-launchpad-branch :x-launchpad-message-rationale:x-launchpad-branch-revision-number :x-launchpad-notification-type:to:from:subject:message-id:date :reply-to:sender:errors-to:precedence:x-generated-by :x-launchpad-hash:x-gm-message-state; bh=mpLLmPKs8Y0Cc7XoGGBHB/ngj3a6mbbZHAitVzcrxSI=; b=BotAlFb67uw6ULKaz0p6RUVzac1rhltLhHKD2isPUXCJiF1dRoKVyraqJl3xMDvTtk J5fJPq5u2dla+cO1kpLiftQJLW1LFgZPC8iPF4YsnlRQt++kWQdtaghkaTjEvSx9zh8u 2Auw3/5pSnkyamKkzE4WFb4sGgE4A98uJsxAgvC8+H/jUvaRUM+xENmex/S/djVwphO2 9PdPi5l/ITiA/ufKtOIupZSza7tFUEoB6IPHhzJOqiNarWqoaYvFtra8vOw9S7IZAxhh humuLJ14koEMIvUOZhiZsgcuak0gVb+uSaVgQ8wfWU1/Zf7uUcmHHplk7LqF6LblWz4w FNdQ== Received: by 10.50.161.169 with SMTP id xt9mr1267455igb.62.1353017654111; Thu, 15 Nov 2012 14:14:14 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.67.148 with SMTP id n20csp862381igt; Thu, 15 Nov 2012 14:14:13 -0800 (PST) Received: by 10.180.90.78 with SMTP id bu14mr2125144wib.21.1353017652410; Thu, 15 Nov 2012 14:14:12 -0800 (PST) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id em5si5946296wib.24.2012.11.15.14.14.11 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 15 Nov 2012 14:14:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) smtp.mail=bounces@canonical.com Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1TZ7hL-0003J7-O2 for ; Thu, 15 Nov 2012 22:14:11 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id A5FB3E0648 for ; Thu, 15 Nov 2012 22:14:11 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: lava-dispatcher X-Launchpad-Branch: ~linaro-validation/lava-dispatcher/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 449 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-dispatcher/trunk] Rev 449: fix boot_options support Message-Id: <20121115221411.3101.88385.launchpad@ackee.canonical.com> Date: Thu, 15 Nov 2012 22:14:11 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="16272"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 24839b56edc9dc27048298f8acc787178cf73cef X-Gm-Message-State: ALoCoQnpFi3iPKgqDP1TH4w+H02Cklchc1HPL4k/FK5rVGE6WWPznhkq8Z9AAC2ZH+NBDXK6AoDs Merge authors: Andy Doan (doanac) Related merge proposals: https://code.launchpad.net/~doanac/lava-dispatcher/boot_options_improvement/+merge/134364 proposed by: Andy Doan (doanac) review: Approve - Michael Hudson-Doyle (mwhudson) ------------------------------------------------------------ revno: 449 [merge] committer: Andy Doan branch nick: lava-dispatcher timestamp: Thu 2012-11-15 16:07:29 -0600 message: fix boot_options support added: lava_dispatcher/device/boot_options.py modified: lava_dispatcher/actions/boot_control.py lava_dispatcher/config.py lava_dispatcher/default-config/lava-dispatcher/device-types/fastmodel.conf lava_dispatcher/device/fastmodel.py lava_dispatcher/device/master.py --- lp:lava-dispatcher https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk You are subscribed to branch lp:lava-dispatcher. To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk/+edit-subscription === modified file 'lava_dispatcher/actions/boot_control.py' --- lava_dispatcher/actions/boot_control.py 2012-07-27 16:49:32 +0000 +++ lava_dispatcher/actions/boot_control.py 2012-11-14 16:31:18 +0000 @@ -42,7 +42,7 @@ def run(self, options=[]): client = self.client - client.boot_options = options + client.target_device.boot_options = options try: client.boot_linaro_android_image() except Exception as e: @@ -57,7 +57,7 @@ def run(self, options=[]): client = self.client - client.boot_options = options + client.target_device.boot_options = options status = 'pass' try: client.boot_linaro_image() === modified file 'lava_dispatcher/config.py' --- lava_dispatcher/config.py 2012-10-23 08:54:22 +0000 +++ lava_dispatcher/config.py 2012-11-14 16:34:06 +0000 @@ -32,6 +32,7 @@ boot_cmds = schema.StringOption(fatal=True) # Can do better here boot_cmds_android = schema.StringOption(fatal=True) # And here boot_cmds_oe = schema.StringOption(fatal=True) # And here? + boot_options = schema.ListOption() boot_linaro_timeout = schema.IntOption(default=300) boot_part = schema.IntOption(fatal=True) boot_part_android_org = schema.IntOption() === modified file 'lava_dispatcher/default-config/lava-dispatcher/device-types/fastmodel.conf' --- lava_dispatcher/default-config/lava-dispatcher/device-types/fastmodel.conf 2012-10-17 16:51:09 +0000 +++ lava_dispatcher/default-config/lava-dispatcher/device-types/fastmodel.conf 2012-11-14 16:34:06 +0000 @@ -19,3 +19,28 @@ # we do usermode networking over the loopback default_network_interface = lo + +boot_options = + motherboard.smsc_91c111.enabled + motherboard.hostbridge.userNetworking + coretile.cache_state_modelled + coretile.cluster0.cpu0.semihosting-enable + coretile.cluster0.cpu0.semihosting-cmd_line + +[motherboard.smsc_91c111.enabled] +default = 1 +allowed = 0,1 + +[motherboard.hostbridge.userNetworking] +default = 1 +allowed = 0,1 + +[coretile.cache_state_modelled] +default = 0 +allowed = 0,1 + +[coretile.cluster0.cpu0.semihosting-enable] +default = 1 +allowed = 0,1 + +[coretile.cluster0.cpu0.semihosting-cmd_line] === added file 'lava_dispatcher/device/boot_options.py' --- lava_dispatcher/device/boot_options.py 1970-01-01 00:00:00 +0000 +++ lava_dispatcher/device/boot_options.py 2012-11-14 19:37:35 +0000 @@ -0,0 +1,81 @@ +# Copyright (C) 2012 Linaro Limited +# +# Author: Andy Doan +# +# This file is part of LAVA Dispatcher. +# +# LAVA Dispatcher is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# LAVA Dispatcher is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along +# with this program; if not, see . + +import logging + + +class BootOption(object): + """ + Parses items from a config ini section into an options object. + """ + def __init__(self, section, items): + self.name = section + self.value = None + self.allowed = None + for item in items: + if item[0] == 'default': + self.value = item[1] + elif item[0] == 'allowed': + self.allowed = [x.strip() for x in item[1].split(',')] + else: + logging.warn('section(%s) contains unknown item: %s' % + (section, item)) + + def valid(self, option): + if self.allowed: + return option in self.allowed + # if no "allowed" value is set, then we can accept anything + return True + + +def as_dict(target): + options = {} + for opt in target.config.boot_options: + if opt in target.config.cp.sections(): + options[opt] = BootOption(opt, target.config.cp.items(opt)) + else: + logging.warn('no boot option config section for: %s' % opt) + + for opt in target.boot_options: + keyval = opt.split('=') + if len(keyval) != 2: + logging.warn("Invalid boot option format: %s" % opt) + elif keyval[0] not in options: + logging.warn("Invalid boot option: %s" % keyval[0]) + elif not options[keyval[0]].valid(keyval[1]): + logging.warn("Invalid boot option value: %s" % opt) + else: + options[keyval[0]].value = keyval[1] + + return options + + +def as_string(target, join_pattern): + """ + pulls the options into a string via the join_pattern. The join pattern + can be something like "%s=%s" + """ + options = as_dict(target) + + cmd = '' + for option in options.values(): + if option.value: + cmd += join_pattern % (option.name, option.value) + return cmd === modified file 'lava_dispatcher/device/fastmodel.py' --- lava_dispatcher/device/fastmodel.py 2012-11-09 20:25:51 +0000 +++ lava_dispatcher/device/fastmodel.py 2012-11-15 22:07:29 +0000 @@ -29,6 +29,8 @@ import re import subprocess +import lava_dispatcher.device.boot_options as boot_options + from lava_dispatcher.device.target import ( Target ) @@ -62,16 +64,6 @@ FASTMODELS = {'ve': FM_VE, 'foundation': FM_FOUNDATION} AXF_IMAGES = {FM_VE: 'img.axf', FM_FOUNDATION: 'img-foundation.axf'} - BOOT_OPTIONS_VE = { - 'motherboard.smsc_91c111.enabled': '1', - 'motherboard.hostbridge.userNetworking': '1', - 'coretile.cache_state_modelled': '0', - 'coretile.cluster0.cpu0.semihosting-enable': '1', - } - - # a list of allowable values for BOOT_OPTIONS_VE - BOOT_VALS = ['0', '1'] - def __init__(self, context, config): super(FastModelTarget, self).__init__(context, config) self._sim_binary = config.simulator_binary @@ -182,31 +174,16 @@ os.chown(self._axf, st.st_uid, st.st_gid) os.chown(self._sd_image, st.st_uid, st.st_gid) - def _boot_options_ve(self): - options = dict(self.BOOT_OPTIONS_VE) - for option in self.boot_options: - keyval = option.split('=') - if len(keyval) != 2: - logging.warn("Invalid boot option format: %s" % option) - elif keyval[0] not in self.BOOT_OPTIONS_VE: - logging.warn("Invalid boot option: %s" % keyval[0]) - elif keyval[1] not in self.BOOT_VALS: - logging.warn("Invalid boot option value: %s" % option) - else: - options[keyval[0]] = keyval[1] - - return ' '.join(['-C %s=%s' % (k, v) for k, v in options.iteritems()]) - def _get_sim_cmd(self): + options = boot_options.as_string(self, join_pattern=' -C %s=%s') if self._fastmodel_type == self.FM_VE: - options = self._boot_options_ve() return ("%s -a coretile.cluster0.*=%s " "-C motherboard.mmc.p_mmc_file=%s " "-C motherboard.hostbridge.userNetPorts='5555=5555' %s") % ( self._sim_binary, self._axf, self._sd_image, options) elif self._fastmodel_type == self.FM_FOUNDATION: - return ("%s --image=%s --block-device=%s --network=nat") % ( - self._sim_binary, self._axf, self._sd_image) + return ("%s --image=%s --block-device=%s --network=nat %s") % ( + self._sim_binary, self._axf, self._sd_image, options) def _power_off(self, proc): if proc is not None: === modified file 'lava_dispatcher/device/master.py' --- lava_dispatcher/device/master.py 2012-11-15 04:54:00 +0000 +++ lava_dispatcher/device/master.py 2012-11-15 22:07:29 +0000 @@ -29,6 +29,7 @@ import pexpect +import lava_dispatcher.device.boot_options as boot_options import lava_dispatcher.tarballcache as tarballcache from lava_dispatcher.device.target import ( @@ -66,6 +67,7 @@ Target.android_deployment_data['boot_cmds'] = 'boot_cmds_android' Target.ubuntu_deployment_data['boot_cmds'] = 'boot_cmds' + Target.oe_deployment_data['boot_cmds'] = 'boot_cmds_oe' # used for tarballcache logic to get proper boot_cmds Target.ubuntu_deployment_data['data_type'] = 'ubuntu' @@ -457,14 +459,9 @@ def _boot_linaro_image(self): boot_cmds = self.deployment_data['boot_cmds'] - for option in self.boot_options: - keyval = option.split('=') - if len(keyval) != 2: - logging.warn("Invalid boot option format: %s" % option) - elif keyval[0] != 'boot_cmds': - logging.warn("Invalid boot option: %s" % keyval[0]) - else: - boot_cmds = keyval[1].strip() + options = boot_options.as_dict(self) + if 'boot_cmds' in options: + boot_cmds = options['boot_cmds'].value boot_cmds = getattr(self.config, boot_cmds) self._boot(string_to_list(boot_cmds.encode('ascii')))