Skip to content

QEMU

LAVA provides three QEMU-based boot methods.

Boot Method Media Description
qemu tmpfs Boots downloaded image directly using QEMU
qemu-nfs nfs Boots kernel with NFS-deployed root filesystem
qemu-iso img Boots downloaded ISO installer using QEMU

These methods run the QEMU command line on the worker. Certain elements of the command line are available for modification using the job context.

The version of QEMU installed on the worker is a choice made by the admin. Generally, this will be the same as the version of QEMU available from Debian in the same suite as the rest of the packages installed on the worker. Information on the available versions of QEMU in Debian is available at tracker.debian.org/pkg/qemu.

Job context

The context section at the top level of the job definition allows customization of the QEMU command line. The available options depend on the device type template configuration. For example, many admins restrict the available memory of each QEMU device, so the memory option in the job context may be ignored.

context:
  arch: aarch64
  cpu: cortex-a57
  machine: virt
  memory: 2048
  netdevice: user
  extra_options:
  - -smp
  - 1
  - -global
  - virtio-blk-device.scsi=off
  - -device virtio-scsi-device,id=scsi
  - --append "console=ttyAMA0 root=/dev/vda rw"

Common context options:

  • arch (Required) - Target architecture (e.g., amd64, aarch64)
  • cpu - CPU model (e.g., cortex-a57)
  • machine - Machine type (e.g., virt for aarch64)
  • memory - Memory allocation in MB
  • netdevice - Network device type (e.g., tap, user)
  • extra_options - List of additional QEMU command line options

Note

The arch parameter in the context section is required for all QEMU boot methods. It is used to determine which qemu-system-<arch> binary to execute.

qemu

The qemu method is used to boot the downloaded images from the tmpfs deployment action using QEMU.

- boot:
    method: qemu
    media: tmpfs
    prompts:
    - 'root@debian:'
    auto_login:
      login_prompt: 'login:'
      username: root

media

When booting QEMU image files directly, the media needs to be specified as tmpfs.

docker

QEMU can be run inside a Docker container. This is useful when the required QEMU version or configuration is not available on the worker.

- boot:
    method: qemu
    media: tmpfs
    docker:
      image: qemu-image:latest
      binary: qemu-system-aarch64
    prompts:
    - 'root@debian:'

The docker option accepts the following parameters:

  • image (required) - the docker image to use
  • local (optional) - whether the image is local (docker pull is skipped if local: true and the image exists on the local)
  • binary (optional) - QEMU binary path inside the container

Job example

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

qemu-nfs

The qemu-nfs method is used to boot a downloaded kernel with a root filesystem deployed on the worker via NFS.

- boot:
    method: qemu-nfs
    auto_login:
      login_prompt: 'login:'
      username: 'root'
    prompts:
      - 'root@jessie:~#'

media

When booting a QEMU image using NFS, the media is implicitly nfs. The deploy action should use to: nfs.

Note

When using qemu-nfs, the hostname element of the prompt may vary according to the worker running QEMU. Use a regex pattern like 'root@(.*):' to match the prompt.

netdevice

This boot method requires access to the NFS service running on the worker to mount the root filesystem. Therefore, netdevice must be set to tap in either the job context or the device dictionary.

If no network bridge configured for the tap interface yet, see Configure bridged network.

Job example

device_type: qemu

job_name: QEMU NFS example
timeouts:
  job:
    minutes: 15

priority: medium
visibility: public

context:
  arch: arm64
  netdevice: 'tap'
  extra_options:
  - '-smp'
  - 1

actions:
- deploy:
    timeout:
      minutes: 5
    to: nfs
    images:
      nfsrootfs:
        url: https://storage.lavacloud.io/health-checks/qemu/nfs/jessie-arm64-nfs.tar.gz
        compression: gz
        image_arg: 'nfsroot={NFS_SERVER_IP}:{nfsrootfs},tcp,hard'
      kernel:
        url: https://storage.lavacloud.io/health-checks/qemu/nfs/vmlinuz-4.9.0-2-arm64
        image_arg: -kernel {kernel}
      initrd:
        url: https://storage.lavacloud.io/health-checks/qemu/nfs/initrd.img-4.9.0-2-arm64
        image_arg: -initrd {initrd}

- boot:
    timeout:
      minutes: 5
    method: qemu-nfs
    auto_login:
      login_prompt: 'login:'
      username: 'root'
    prompts:
      - 'root@jessie:~#'

- test:
    timeout:
      minutes: 5
    definitions:
    - from: inline
      repository:
        metadata:
          format: Lava-Test Test Definition 1.0
          name: test-definition-example
        run:
          steps:
          - lava-test-case kernel-info --shell uname -a
          - lava-test-case network-info --shell ip a
      name: test-definition-example
      path: inline/test-definition-example.yaml

qemu-iso

The qemu-iso method is used to boot a downloaded installer from the deployment action using QEMU. This is typically used for automated OS installations.

- boot:
    method: qemu-iso
    media: img
    auto_login:
      login_prompt: 'login:'
      username: root
      password_prompt: 'Password:'
      password: root
    prompts:
    - 'root@debian:'

media

When booting an installer using QEMU, the media needs to be specified as img. The deploy action should use to: iso-installer.

netdevice

This boot method requires access to the TFTP service running on the worker for loading the preseed file and the Internet for OS installation. Therefore, netdevice must be set to tap in either the job context or the device dictionary.

If no network bridge configured for the tap interface yet, see Configure bridged network.

Job example

device_type: qemu

job_name: Debian Trixie amd64 netinst iso installer
timeouts:
  job:
    minutes: 60
  connection:
    minutes: 30

priority: medium
visibility: public

context:
  arch: amd64
  netdevice: tap

actions:
- deploy:
    to: iso-installer
    os: debian_installer
    images:
      iso:
        image_arg: -drive file={iso},index=2,media=cdrom,readonly=on
        url: https://cdimage.debian.org/debian-cd/13.3.0/amd64/iso-cd/debian-13.3.0-amd64-netinst.iso
      preseed:
        # Note: The preseed file example is configured to install SSH server and
        # the standard utils. The SSH server can be logged in with the
        # user:passwd 'linaro:linaro'.
        url: https://storage.lavacloud.io/health-checks/qemu/iso/preseed.cfg
    iso:
      kernel: /install.amd/vmlinuz
      initrd: /install.amd/initrd.gz
      installation_size: 3G
    timeout:
      minutes: 30

- boot:
    method: qemu-iso
    media: img
    auto_login:
      login_prompt: 'login:'
      username: root
      password_prompt: 'Password:'
      password: root
    prompts:
    - 'root@debian:'
    timeout:
      minutes: 30

- test:
    definitions:
    - from: inline
      repository:
        metadata:
          format: Lava-Test Test Definition 1.0
          name: test-definition-example
        run:
          steps:
          - lava-test-case kernel-info --shell uname -a
          - lava-test-case network-info --shell ip a
      name: test-definition-example
      path: inline/test-definition-example.yaml
    timeout:
      minutes: 5