QEMU device setup¶
LAVA can use qemu as a DUT and run test inside QEMU.
Create device-type¶
Create the device type using the name qemu.
Create device¶
- Add the device using the following settings:
- Device Type:
qemu - Hostname: A unique name (e.g.,
qemu-01)
- Device Type:
-
For a simple qemu job, this device dictionary would work:
{% extends "qemu.jinja2" %} {% set netdevice = "user" %} {% set memory = 1024 %}Tip
If
/dev/kvmis unavailable on the worker, add{% set no_kvm = True %}to the dictionary.
Submit a job¶
Submit this simple test job:
device_type: qemu
job_name: simple qemu job
timeouts:
job:
minutes: 20
priority: medium
visibility: public
context:
arch: amd64
actions:
- deploy:
to: tmpfs
timeout:
minutes: 20
images:
rootfs:
url: http://images.validation.linaro.org/kvm/debian-sid-2014_08_21-amd64.qcow2.xz
image_arg: -drive format=qcow2,file={rootfs}
compression: xz
os: debian
- boot:
method: qemu
media: tmpfs
timeout:
minutes: 5
prompts:
- 'root@debian:~#'
auto_login:
login_prompt: "login:"
username: root
- test:
timeout:
minutes: 5
definitions:
- repository: https://github.com/Linaro/test-definitions
from: git
path: automated/linux/smoke/smoke.yaml
parameters:
SKIP_INSTALL: true
name: smoke-tests
- repository: https://github.com/Linaro/test-definitions
from: git
path: automated/linux/meminfo/meminfo.yaml
parameters:
SKIP_INSTALL: true
name: meminfo
The job page will look like this.
Configure bridged network¶
For qemu-nfs and qemu-iso boot methods, netdevice must be set to tap
in either the job context or the device dictionary. The tap interface must be
linked to a bridged interface that provides access to the worker and maybe also
the Internet.
If the network bridge is not configured yet, follow the steps below to create one.
Note
These instructions are only validated on Debian. You may need to adjust them for other distributions.
-
Install required packages:
sudo apt install iproute2 dnsmasq -
Create the bridge:
sudo ip link add name br-lava type bridge sudo ip addr add 192.168.66.1/24 dev br-lava sudo ip link set br-lava up -
Make the bridge persistent:
sudo mkdir -p /etc/network/interfaces.d sudo tee /etc/network/interfaces.d/br-lava > /dev/null <<'EOF' auto br-lava iface br-lava inet static address 192.168.66.1 netmask 255.255.255.0 bridge_ports none bridge_stp off EOF -
Enable DHCP for the bridge:
sudo tee /etc/dnsmasq.d/br-lava.conf > /dev/null << 'EOF' interface=br-lava bind-interfaces dhcp-range=192.168.66.2,192.168.66.100,12h dhcp-option=option:router,192.168.66.1 dhcp-option=option:dns-server,8.8.8.8 except-interface=lo port=0 EOF sudo systemctl restart dnsmasq -
Configure QEMU to use the bridge:
sudo cp /etc/qemu-ifup /etc/qemu-ifup.original sudo tee /etc/qemu-ifup > /dev/null << 'EOF' #!/bin/sh -ex TAP="$1" BRIDGE=br-lava ip link set "$TAP" up ip link set "$TAP" master "$BRIDGE" EOF -
Optionally, allow the
br-lavainterface to access the Internet.Add NAT masquerading rules:
sudo iptables -t nat -A POSTROUTING -o <eth0> -j MASQUERADE sudo iptables -A FORWARD -i br-lava -o <eth0> -j ACCEPT sudo iptables -A FORWARD -i <eth0> -o br-lava -m state --state RELATED,ESTABLISHED -j ACCEPTNote
Replace
<eth0>with the name of the interface that provides Internet access.Make rules persistent:
sudo apt-get install -y iptables-persistent sudo netfilter-persistent save