Using QEMU on Linux* for MeeGo* Application Testing

Introduction

Testing and validating an application targeting MeeGo* can be done in various different ways. If the basic UI and functionality testing that the Qt Simulator provides is not sufficient and a real target device with the appropriate form factor is not available, using a virtual machine running the full MeeGo* software stack on your development host may be the way to go.

QEMU is a component of the MeeGo SDK. It can run handset, netbook or tablet images under an emulator, so you can test your applications on a MeeGo operating system, even if you don't have a MeeGo device.

The MeeGo* SDK offers access to a set of MeeGo* OS images that can be booted inside a QEMU based virtual machine.

This article focuses on how to do the setup and configuration of QEMU on a Linux* host, so that a MeeGo* OS image can be launched inside of QEMU and the application to be tested can be downloaded and run on this image.

The default method that this article highlights is to have the application automatically downloaded and launched from within the Qt Creator development environment.

1. Prerequisites

Hardware: Intel® Architecture or compatible hardware supporting at least Intel® Streaming SIMD Extension 3 (Intel® SSE3) based instructions. The MeeGo* SDK version of QEMU relies on kqemu to provide CPU virtualization support, but on some machines with this support, images will still not run.

Known to work: Intel® Core™2 Quad CPU, Q8200; Intel® Core™ i5 and i7

Software: The Intel AppUp™ SDK Suite for MeeGo* and The MeeGo* SDK have been tested against Fedora* 12, 13, 14, and Ubuntu* 9.10 10.04 10.10 host systems.

2. Intel® Virtualization Technology (Intel® VT) and Hardware Accelerated Graphics

Using QEMU for MeeGo* development requires that your system be capable of Intel® VT support and hardware accelerated graphics. The following sections describe the steps to check for support on your platform.

2a. Virtualization (Intel® VT)

Your system must have support for virtualization to enable the QEMU virtual machine to accelerate graphics performance using the platform hardware. To check for support, run the following from a terminal. It should output something.

$ egrep '^flags.*(vmx|svm)' /proc/cpuinfo

Any output is success. Here's an example:

flags : fpu vme de pse tsc msr pae mce cx8 apic mtrr pge 
mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht 
tm pbe lm constant_tsc arch_perfmon pebs bts pni dtes64 monitor 
ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm sse4_1 lahf_lm tpr_shadow 
vnmi flexpriority

2b. KVM Module Installed

Check that the kvm_intel or kvm_amd modules are loaded:

$ lsmod | grep kvm
kvm_intel              43816  0 
kvm                   164576  1 kvm_intel

If needed, load the module.

For an Intel processor:

$ sudo modprobe kvm_intel

For an AMD processor:

$ sudo modprobe kvm_amd

2c. Virtualization Enabled in the BIOS

If the kvm modules are not available or fail to load, virtualization may not be enabled in the BIOS. Reboot your system, go into the BIOS, and enable it.

2d. Graphics Hardware Acceleration Enabled

Check that host hardware graphic acceleration is enabled:

$ glxinfo | grep "renderer string"

Desired output: OpenGL renderer string: Mesa DRI ...
Undesirable output: OpenGL renderer string: Software Rasterizer

If you get the undesirable output then acceleration is not fully enabled, your graphics driver might not be capable. You may need to check the website of your graphics card vendor and update or replace the pre-installed graphics driver that came with your operating system.

3. QEMU Setup

QEMU is a component of the MeeGo* SDK. It can run MeeGo* images under an emulator, so you can test your applications on a MeeGo operating system, even if you don't have a MeeGo* device.

Information on how to download and install the MeeGo* SDK for Linux* can be found here

The most convenient way to set up a MeeGo* OS image with QEMU is to use the MeeGo* SDK's MADDE command set. The mad-admin command can be used to download a runtime, and the mad command can be used to run it. Please follow the instructions below for how to do this.

3a. Installing a MeeGo* Runtime

You can get a list of available runtimes for your version of MADDE with:

$ mad-admin list runtimes
meego-handset-ia32-qemu-1.1.20110110.1026-runtime          (installable)
meego-handset-ia32-qemu-1.1.20110118.1010-runtime          (installable)
meego-handset-ia32-qemu-1.1.20101031.2201-sda-runtime      (installable)
meego-handset-ia32-w32-qemu-1.1.20101031.2201-sda-runtime  (installable)
meego-handset-ia32-qemu-1.1.99.5.20110503.6-runtime        (installable)
meego-netbook-ia32-qemu-1.1.20110110.1049-runtime          (installable)
meego-netbook-ia32-qemu-1.1.20110118.1020-runtime          (installable)
meego-netbook-ia32-qemu-1.1.20101031.2037-sda-runtime      (installable)
meego-netbook-ia32-w32-qemu-1.1.20101031.2037-sda-runtime  (installable)
meego-netbook-ia32-qemu-1.2.0-runtime                      (installable)
meego-netbook-ia32-qemu-1.1.99.5.20110503.6-runtime        (installable)
meego-tablet-ia32-qemu-1.2.0.90.0.20110517.1-runtime       (installable)

Run the command below. Replace <runtime> with one of

meego-handset-ia32-qemu-1.1.99.5.20110503.6-runtime: Run the MeeGo OS with handset UI.

meego-netbook-ia32-qemu-1.2.0-runtime: Run the MeeGo OS with netbook UI.

meego-tablet-ia32-qemu-1.2.0.90.0.20110517.1-runtime: Run the MeeGo OS with tablet UI.

$ sudo mad-admin create -f -e <runtime>

This will download the runtime (a ~650+ MB .bz2 file) into MADDE's cache directory and decompress it in the runtimes directory. On Linux, the default MADDE location is /usr/lib/madde/linux-i686/. If network/proxy issues prevent the image from downloading, the url for the runtime can be extracted from the MADDE's cache/madde.conf.d/<runtime>.conf file, downloaded manually, and copied into the cache directory. Rerunning the above command will now bypass the download and directly decompress the runtime.

After installing, you can check that the runtime is installed by running mad-admin list again.

$ mad-admin list runtimes
meego-handset-ia32-qemu-1.1.20110110.1026-runtime          (installable)
meego-handset-ia32-qemu-1.1.20110118.1010-runtime          (installable)
meego-handset-ia32-qemu-1.1.20101031.2201-sda-runtime      (installable)
meego-handset-ia32-w32-qemu-1.1.20101031.2201-sda-runtime  (installable)
meego-handset-ia32-qemu-1.1.99.5.20110503.6-runtime        (installable)
meego-netbook-ia32-qemu-1.1.20110110.1049-runtime          (installable)
meego-netbook-ia32-qemu-1.1.20110118.1020-runtime          (installable)
meego-netbook-ia32-qemu-1.1.20101031.2037-sda-runtime      (installable)
meego-netbook-ia32-w32-qemu-1.1.20101031.2037-sda-runtime  (installable)
meego-netbook-ia32-qemu-1.2.0-runtime                      (installed)
meego-netbook-ia32-qemu-1.1.99.5.20110503.6-runtime        (installable)
meego-tablet-ia32-qemu-1.2.0.90.0.20110517.1-runtime       (installed)

Note that installed above indicates that the handset runtime was successfully downloaded and configured for QEMU.

3b. Using the MeeGo* Runtime

To start an installed runtime, use the mad command to boot the image inside QEMU.

To start the IA32 handset runtime:

$ sudo mad remote -r meego-handset-ia32-w32-qemu-1.1.20101031.2201-sda-runtime poweron

Here's what the handset image looks like (this is the Applications zone):

To start the IA32 netbook runtime:

$ sudo mad remote -r meego-netbook-ia32-qemu-1.2.0-runtime poweron

Here's what the netbook image looks like (this is Myzone):

Alternatively, if you have Qt* Creator open and running you may also just clicking on the QEMU Launch Button in the bottom left part of Qt* Creator.This will launch the configured QEMU runtime.

You can now use this running image as a deployment target for Qt Creator, or log into it manually over SSH (see below).

When you've finished, use the power off icon in the emulator to switch it off (if available); or from the command line, do:

$ sudo mad remote -r meego-netbook-ia32-qemu-1.2.0-runtime poweroff

3c. Using a Runtime without Graphics

If you are having issues with running QEMU, you can try running the image without graphics to help isolate the problem. To do this, set QEMU_NOGRAPHIC=yes in the environment before running the emulator. For example:

$ QEMU_NOGRAPHIC=yes mad remote -r meego-netbook-ia32-qemu-1.2.0-runtime poweron

If you are then able to ssh into the running image, you can be fairly certain that your issues are graphics-related, rather than anything to do with the image itself.

4. Open an SSH Terminal for QEMU Runtime

Anytime MeeGo is running in QEMU, you can use SSH to connect to the image from another terminal on the host system.

The OpenSSH server should already be installed and started, ready to handle communication between the development host and the emulated target. If this is not the case you can install and launch sshd following these steps:

zypper install openssh-server
chkconfig --add sshd
/etc/init.d/sshd start

When MADDE starts QEMU, it sets up a redirect from port 6666 on the host to the SSH port (port 22) on the guest (MeeGo on QEMU). So you can log into the running QEMU image with:

$ ssh meego@127.0.0.1 -p 6666

Two user accounts are available:

Two user accounts are available in the MeeGo images:

User: meego, Password: meego
User: root, Password: meego

5. SFTP File Transfer into QEMU Runtime

Anytime MeeGo is running in QEMU, you can use an SFTP connection to transfer files to the image from another terminal on the host system.

sftp –P 6666 meego@127.0.0.1

Two user accounts are available in the MeeGo images:

User: meego, Password: meego
User: root, Password: meego

6. Configuring Access to an Emulated Device in Qt Creator

To configure access to an emulated device:

  1. Open Tools > Options > Projects > MeeGo Device Configurations.
  2. In the dialog box, create a new Device Configuration by clicking on Add.
  3. Give the new Device Configuration a name in the Configuration Name text field, and add the following settings in the other test fields:
    • Device type: choose MeeGo emulator
    • Authentication type: Password
    • Host name: 127.0.0.1
    • Ports, SSH: 6666
      Note that the emulator is setup with a redirect from port 6666 on localhost to the SSH port (22) of the emulated device.
    • Ports, Gdb Server: 13219 (the default)

    Note: If this port is not free, you can select another one.
    • Connection Timeout: 30
    • User Name: root
    • Password: meego

  4. Click Apply.
  5. To test the settings, ensure that the emulated device is running, then click Test.
    If successful, you'll see a dialog box with the message "Device configuration successful".
    If the message "Could not connect to host" is displayed, check your setting selections and make sure that the network is connected.
  6. Click Close and OK.

7. Launching the application from within Qt* Creator

Clicking on the QEMU Launch Button in the bottom left part of Qt* Creator.

will launch the configured QEMU runtime.

Once it is launched it changes to and the MeeGo* image comes up.

  • Handset image:


  • Netbook image:



To launch the application, click on the green arrow icon. To start a debug session, click on the green arrow icon with the small blue bug on it .

Alternatively you can also hit the F5 key.

If your application does not launch on the emulated target despite all this you may want to have a look at SSH key checking:

Application Upload Failure due to Strict SSH Key Checking:

If your application does not launch correctly and does not get downloaded to the target platform this could be due to strict SSH key checking enabled. The easiest way to get around this is to edit the global SSH configuration file (/etc/ssh/ssh_config) or the user specific SSH configuration file (~/.ssh/config) on your target device. This will help avoid access denial due to key checking.

Add the following lines to the beginning of the SSH configuration file.

Host 172.0.0.1
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null

8. Debug the Application

You can also debug the application by clicking the "Debug" icon. Setting breakpoints and stepping are the same as for local applications.

For use of the Intel® Debugger for MeeGo* with a QEMU based environment please refer to the article Debugging MeeGo* Applications with Intel® Debugger.

3
Average: 3 (1 vote)