diff options
author | Neil Williams <codehelp@debian.org> | 2015-11-04 11:48:50 +0000 |
---|---|---|
committer | Neil Williams <codehelp@debian.org> | 2015-11-04 11:48:50 +0000 |
commit | 3855370a24530cd0541519b906045c7ccb66c28e (patch) | |
tree | 382fc115e1c4e67a168fef2493dabf0e6e0bd1d1 | |
parent | 5dea8d05069f0518ddf974eef79dc576c0b4bc1e (diff) | |
download | vmdebootstrap-3855370a24530cd0541519b906045c7ccb66c28e.tar.gz |
Add qemu-wrapper and an example lava-submit script.
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | MANIFEST.in | 3 | ||||
-rwxr-xr-x | bin/qemu-wrapper.sh | 24 | ||||
-rw-r--r-- | doc/overview.rst | 5 | ||||
-rwxr-xr-x | examples/auto-serial-console | 35 | ||||
-rwxr-xr-x | examples/lava-submit.py | 92 | ||||
-rwxr-xr-x | examples/lava.sh | 7 | ||||
-rw-r--r-- | man/vmdebootstrap.rst | 5 |
8 files changed, 130 insertions, 43 deletions
@@ -5,3 +5,5 @@ *.egg-info doc/_build/ man/_build/ +dist/* +local/* diff --git a/MANIFEST.in b/MANIFEST.in index f3d15ec..f5a8dad 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,7 +1,8 @@ include NEWS include vmextract.py include vmdebootstrap.8.in -recursive-include examples *.sh *.txt +recursive-include examples *.sh *.txt *.py include common/* include doc/* include man/* +include bin/qemu-wrapper.sh diff --git a/bin/qemu-wrapper.sh b/bin/qemu-wrapper.sh new file mode 100755 index 0000000..2e6eab4 --- /dev/null +++ b/bin/qemu-wrapper.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +set -e + +if [ -z "$1" ]; then + echo "Usage: <imagefile> <arch>" + echo "For x86_64, amd64 is also supported." + exit 1 +fi + +if [ -n "$2" ]; then + if [ "$2" = 'amd64' ]; then + ARCH='x86_64' + else + ARCH="$2" + fi +else + echo "Specify the architecture of the image" + echo "Usage: <imagefile> <arch>" + echo "For x86_64, amd64 is also supported." + exit 1 +fi + +qemu-system-${ARCH} -m 1024 -enable-kvm -drive format=raw,file=./$1 diff --git a/doc/overview.rst b/doc/overview.rst index 8194666..8a5cb33 100644 --- a/doc/overview.rst +++ b/doc/overview.rst @@ -162,6 +162,11 @@ Execute using qemu, e.g. on amd64 using qemu-system-x86_64:: (This loads the image in a new window.) Note the use of ``-drive file=<img>,format=raw`` which is needed for newer versions of QEMU. +There is a ``bin/qemu-wrapper.sh <image> <arch>`` script for simple +calls where the ``--owner`` option is used, e.g.:: + + $ /usr/share/vmdebootstrap/qemu-wrapper.sh jessie.img amd64 + There is EFI firmware available to use with QEMU when testing images built using the UEFI support, but this software is in Debian non-free due to patent concerns. If you choose to install ``ovmf`` to test UEFI builds, a diff --git a/examples/auto-serial-console b/examples/auto-serial-console deleted file mode 100755 index 9304e98..0000000 --- a/examples/auto-serial-console +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -e - -[ -f /etc/default/autogetty ] && . /etc/default/autogetty - -[ 1 -gt $ENABLED ] && exit - -for arg in $(cat /proc/cmdline) -do - case $arg in - console=*) - tty=${arg#console=} - tty=${tty#/dev/} - - case $tty in - tty[a-zA-Z]* ) - PORT=${tty%%,*} - - # check for service which do something on this port - if [ -f /etc/init/$PORT.conf ];then continue;fi - - tmp=${tty##$PORT,} - SPEED=${tmp%%n*} - BITS=${tmp##${SPEED}n} - - # 8bit serial is default - [ -z $BITS ] && BITS=8 - [ 8 -eq $BITS ] && GETTY_ARGS="$GETTY_ARGS -8 " - - [ -z $SPEED ] && SPEED='115200,57600,38400,19200,9600' - - GETTY_ARGS="$AUTOGETTY_ARGS $GETTY_ARGS $SPEED $PORT" - exec /sbin/getty $GETTY_ARGS - esac - esac -done diff --git a/examples/lava-submit.py b/examples/lava-submit.py new file mode 100755 index 0000000..ae89758 --- /dev/null +++ b/examples/lava-submit.py @@ -0,0 +1,92 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# lava-submit.py +# +# Copyright 2015 Neil Williams <codehelp@debian.org> +# +# This program 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. +# +# This program 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, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1301, USA. +# +# + +""" +Example script - needs configuration (or use lava-tool). +Expects to submit a pipeline job to a QEMU device, so +ensure that the host supports these jobs. +**This script is not to be expanded with argparse or CLI options for +the username, token, hostname or image**. +It is meant to be copied into something like jenkins to do the +submission using hardcoded values, themselves hidden behind a UI. +Other details like architecture, prompt and login information may +need to come from a config file or command line. +LAVA needs a serial console to tell whether the VM booted or not. +Larger images will need the LAVA device to have more memory available. +""" + +import os +import yaml +import xmlrpclib + +# Constants for each particular script configuration. +USERNAME = "" +TOKEN = "" +HOSTNAME = "" +IMAGE = "" +ARCH = "" + + +def job(image): + """ Bare bones YAML job definition """ + job_def = { + 'actions': [{ + 'deploy': {'images': {'rootfs': { + 'image_arg': "-drive format=raw,file={rootfs}", + "url": "file://%s" % image + }}, + 'os': 'debian', + 'timeout': {'minutes': 5}, + 'to': 'tmpfs'} + }, { + 'boot': { + 'media': 'tmpfs', + 'prompts': ["root@debian:"], + 'auto_login': { + "login_prompt": "login:", + "username": "root" + }, + 'method': 'qemu'} + }], + 'device_type': 'qemu', + 'job_name': 'vmdebootstrap-test', + 'priority': 'medium', + "context": { "arch": ARCH }, + 'timeouts': {'action': {'minutes': 1}, 'job': {'minutes': 5}}, + 'visibility': 'public'} + return job_def + + +def main(): + """ submit using XMLRPC """ + image = os.path.realpath(IMAGE) + url = "http://%s:%s@%s//RPC2" % (USERNAME, TOKEN, HOSTNAME) + server = xmlrpclib.ServerProxy(url) + job_id = server.scheduler.submit_job(yaml.dump(job(image))) + print job_id + return 0 + +if __name__ == '__main__': + import sys + sys.exit(main()) diff --git a/examples/lava.sh b/examples/lava.sh deleted file mode 100755 index 06da069..0000000 --- a/examples/lava.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -set -e - -rootdir=$1 - -cp auto-serial-console $rootdir/bin/ diff --git a/man/vmdebootstrap.rst b/man/vmdebootstrap.rst index 397deaa..74bb153 100644 --- a/man/vmdebootstrap.rst +++ b/man/vmdebootstrap.rst @@ -293,6 +293,11 @@ Execute using qemu, e.g. on amd64 using qemu-system-x86_64:: (This loads the image in a new window.) Note the use of ``-drive file=<img>,format=raw`` which is needed for newer versions of QEMU. +There is a ``bin/qemu-wrapper.sh <image> <arch>`` script for simple +calls where the ``--owner`` option is used, e.g.:: + + $ /usr/share/vmdebootstrap/qemu-wrapper.sh jessie.img amd64 + There is EFI firmware available to use with QEMU when testing images built using the UEFI support, but this software is in Debian non-free due to patent concerns. If you choose to install ``ovmf`` to test UEFI builds, a |