From 50413c2c7d0da95e10d6cab204fe86e85f3724db Mon Sep 17 00:00:00 2001 From: Vojtech Horky Date: Mon, 27 Aug 2018 14:04:31 +0200 Subject: [PATCH] Add support for arm32/integratorcp --- htest/vm/controller.py | 6 ++++++ htest/vm/qemu.py | 43 +++++++++++++++++++++++++++++-------------- vm-test.py | 14 +++++++------- 3 files changed, 42 insertions(+), 21 deletions(-) diff --git a/htest/vm/controller.py b/htest/vm/controller.py index 72232c6..1b2c0a2 100755 --- a/htest/vm/controller.py +++ b/htest/vm/controller.py @@ -86,6 +86,12 @@ class VMController: self.vterm = [] pass + def is_supported(self, arch): + """ + Tells whether this controller supports given architecture. + """ + return False + def boot(self, **kwargs): """ Bring the machine up. diff --git a/htest/vm/qemu.py b/htest/vm/qemu.py index 55a5697..f28c33a 100755 --- a/htest/vm/qemu.py +++ b/htest/vm/qemu.py @@ -42,10 +42,29 @@ class QemuVMController(VMController): QEMU VM controller. """ - def __init__(self, arch, name, boot_image): - if not arch in ['ia32', 'amd64']: - raise Exception("Unsupported architecture {}.".format(arch)) + config = { + 'amd64': [ + 'qemu-system-x86_64', + '-cdrom', '{BOOT}', + '-m', '256', + '-usb', + ], + 'arm32/integratorcp': [ + 'qemu-system-arm', + '-M', 'integratorcp', + '-usb', + '-kernel', '{BOOT}', + '-m', '256', + ], + 'ia32': [ + 'qemu-system-i386', + '-cdrom', '{BOOT}', + '-m', '256', + '-usb', + ], + } + def __init__(self, arch, name, boot_image): VMController.__init__(self, 'QEMU-' + arch) self.arch = arch self.booted = False @@ -53,6 +72,9 @@ class QemuVMController(VMController): self.boot_image = boot_image self.logger = logging.getLogger('qemu-{}'.format(name)) + def is_supported(arch): + return arch in QemuVMController.config + def _get_image_dimensions(self, filename): im = Image.open(filename) width, height = im.size @@ -90,17 +112,10 @@ class QemuVMController(VMController): def boot(self, **kwargs): self.monitor_file = self.get_temp('monitor') cmd = [] - cmd.append({ - 'amd64': 'qemu-system-x86_64', - 'ia32': 'qemu-system-i386', - }[self.arch]) - cmd.append('-usb') - cmd.append('-m') - cmd.append('256') - cmd.append('-enable-kvm') - cmd.append('-cdrom') - cmd.append(self.boot_image) - #cmd.append('-daemonize') + for opt in QemuVMController.config[self.arch]: + if opt == '{BOOT}': + opt = self.boot_image + cmd.append(opt) cmd.append('-monitor') cmd.append('unix:{},server,nowait'.format(self.monitor_file)) self.logger.debug("Starting QEMU: {}".format(format_command(cmd))) diff --git a/vm-test.py b/vm-test.py index 69c3f79..6885578 100755 --- a/vm-test.py +++ b/vm-test.py @@ -38,11 +38,6 @@ from htest.vm.controller import VMManager from htest.vm.qemu import QemuVMController from htest.tasks import * -controllers_by_architecture = { - 'amd64': QemuVMController, - 'ia32': QemuVMController, -} - args = argparse.ArgumentParser(description='HelenOS VM tests') args.add_argument('--scenario', metavar='FILENAME.yml', @@ -96,11 +91,16 @@ with open(config.scenario, 'r') as f: logger.error(ex) sys.exit(1) +controller = None +for ctl in [ QemuVMController ]: + if ctl.is_supported(config.architecture): + controller = ctl -if not config.architecture in controllers_by_architecture: +if controller is None: logger.error("Unsupported architecture {}.".format(config.architecture)) + sys.exit(1) -vmm = VMManager(controllers_by_architecture[config.architecture], config.architecture, config.boot_image) +vmm = VMManager(controller, config.architecture, config.boot_image) scenario_tasks = [] for t in scenario['tasks']: -- 2.11.4.GIT