QEMU, the FAST! processor emulator

Board description

QEMU (short for Quick Emulator ) is a free and open-source emulator that performs hardware virtualization.

QEMU is a hosted virtual machine monitor, it emulates the machine’s processor through dynamic and provides a set of different hardware and device models for the machine, enabling it to run a variety of guest operating systems. It also can be used with KVM to run virtual machines at near-native speed (by taking advantage of hardware extensions such as Intel VT-x).

QEMU machines are something that we at Mender use heavily during development and this is also the primary target for our integration tests.

URL: https://qemu.weilnetz.de/doc/qemu-doc.html
Wiki: https://wiki.qemu.org/Documentation

Test results

The Yocto Project releases in the table below have been tested by the Mender community. Please update it if you have tested this integration on other Yocto Project releases:

Yocto Project Build Runtime
thud (2.6) :test_works: :test_works:
sumo (2.5) :test_works: :test_works:
rocko (2.4) :test_works: :test_works:

Build Means that the Yocto Project build using this Mender integration completes without errors and outputs images.
Runtime Means that Mender has been verified to work on the board. For U-Boot-based boards, the integration checklist has been verified.

Getting started

Prerequisites

  • A supported Linux distribution and dependencies installed on your workstation/laptop as described in the Yocto Mega Manual
    • NOTE. Instructions depend on which Yocto version you intend to use.
  • Google repo tool installed and in your PATH.

Configuring the build

Setup Yocto environment

Set the Yocto Project branch you are building for:

# set to your branch, make sure it is supported (see table above)
export BRANCH="thud"

Create a directory for your mender-qemu setup to live in and clone the
meta information.

mkdir mender-qemu && cd mender-qemu

Initialize repo manifest:

repo init -u https://github.com/mendersoftware/meta-mender-community \
           -m meta-mender-qemu/scripts/manifest-qemu.xml \
           -b ${BRANCH}

Fetch layers in manifest:

repo sync

Setup build environment

Initialize the build environment:

source setup-environment qemu

Configure Mender server URL (optional)

This section is not required for a successful build but images that are generated by default are only suitable for usage with the Mender client in Standalone deployments, due to lack of server configuration.

You can edit the conf/local.conf file to provide your Mender server configuration, ensuring the generated images and Mender Artifacts are connecting to the Mender server that you are using. There should already be a commented section in the generated conf/local.conf file and you can simply uncomment the relevant configuration options and assign appropriate values to them.

Build for Hosted Mender:

# To get your tenant token:
#    - log in to https://hosted.mender.io
#    - click your email at the top right and then "My organization"
#    - press the "COPY TO CLIPBOARD"
#    - assign content of clipboard to MENDER_TENANT_TOKEN
#
MENDER_SERVER_URL = "https://hosted.mender.io"
MENDER_TENANT_TOKEN = "<copy token here>"

Build for Mender demo server:

# https://docs.mender.io/getting-started/create-a-test-environment
#
# Update IP address to match the machine running the Mender demo server
MENDER_DEMO_HOST_IP_ADDRESS = "192.168.0.100"

Building the image

You can now proceed with building an image:

MACHINE=qemux86-64 bitbake core-image-base

Replace core-image-base with your desired image target.

NOTE. Other supported targets are vexpress-qemu and vexpress-qemu-flash but it is recommend to run the qemux86-64 as this is the only one that is able to utilize hardware accelerated emulation resulting in a near-native experience. The vexpress targets which emulates ARM machines are slow due to not being able to utilize e.g KVM.

Using the build output

After a successful build, the images and build artifacts are:

  • tmp/deploy/images/qemux86-64/core-image-base-qemux86-64.uefiimg.gz
  • tmp/deploy/images/qemux86-64/core-image-base-qemux86-64.mender

The disk image .uefiimg.gz is used to provision the device storage for devices without Mender running already. Please proceed to the official documentation on provisioning a new device for steps to do this.

On the other hand, if you already have Mender running on your device and want to deploy a rootfs update using this build, you should use the Mender Artifact files, which have .mender suffix. You can either deploy this Artifact in managed mode with the Mender server as described in Deploy to physical devices or by using the Mender client only in Standalone deployments.

Using the virtual environment

To start the virtual environment simply run,

 ../sources/meta-mender/meta-mender-qemu/scripts/mender-qemu core-image-base

References

  • The official Mender documentation explains how Mender works. This is simply a board-specific complement to the official documentation.

If this post was useful to you, please press like, or leave a thank you note to the contributor who put valuable time into this and made it available to you. It will be much appreciated!

4 Likes