Category Archives: Virtualisierung

KVM with kvmtool on ARMv7

In this third part about KVM on ARMv7 I use kvmtool as the user-space part of the hypervisor. This lightweight hypervisor allowed me to run up to 72 virtual machines…  This does not really serves any purpose other than demonstrating what is possible :-). See the video in the end how that looked like.

In 2011 Pekka Enberg announced kvmtool (native Linux KVM tool). Initially it was meant to live within the Linux kernel source tree, but it ended up in a separate git repository on kernel.og.. In between it has been ported to several architectures too, including ARM and ARM64. Its binary usually goes with the name lkvm. It strictly depends on KVM and is otherwise kept rather lean.

Similar to the previous blog post, I used a host root file system based on Ångströms development image. kvmtool was not yet available in any OpenEmbedded layer, hence I had to write a new recipe (it should turn up in the meta-virtualization layer mailing list soon). Read more »

Using KVM with Qemu on ARM

This is part two of my blog post about Kernel-Virtual Machine (KVM) on a 32-Bit ARM architecture. The post is meant as a starting point for those who want to play with KVM and provide a useful collection of Qemu commands for virtualization.

Virtualization host setup

The Kernel configuration I used for my platforms Host kernel can be found here. Since I run my experiments on a Toradex Colibri iMX7D module, I started with the v4.1 configuration of the BSP kernel and updated that to v4.8 plus enabled KVM as well as KSM (Kernel same-page merging).

As root file system I use a slightly modified version of the Ångström distributions “development-image”, version 2015.12 (built from scratch with OpenEmbedded). Any recent ARM root file system should do it. I let Qemu v2.6.0 preinstall (by just adding “qemu” to the image and specifying ANGSTROM_QEMU_VERSION = “2.6.0” in conf/distro/angstrom-v2015.12.conf).

Virtualization guest setup

For the virtualization guest setup I was looking for something minimalistic. I uploaded the compiled binary of the Kernel (as tared zImage) and initramfs (as cpio.gz).

I built a custom kernel directly using v4.7 sources and a modified/stripped down version of the vexpress_defconfig (virt_guest_defconfig). I found it useful to look into Qemu’s “virt” machine setup code (hw/arm/virt.c) to understand what peripherals are actually emulated (and hence what drivers are actually required). Read more »

U-Boot/Linux and HYP mode on ARMv7

The newer ARMv7 Cortex-A class cores such Cortex-A7, A15 and A17 come with a virtualization extensions which allow to use KVM (kernel virtual machine). The NXP i.MX 7Dual SoC which I worked with lately includes the ARM Cortex-A7 CPU. I went ahead and tried to bring up KVM on i.MX 7. I was not really familiar with the ARMv7 virtualization architecture, so I had to read up on some concepts. This post summarizes what I learned and gives a big picture of software support.

The Hypervisor mode

To provide hardware support for full CPU virtualization an additional privilege level is required. User-space (PL0) uses the SVC (Supervisor) instruction to switch to kernel-space (PL1, SVC mode). A similar separation between Kernel and hypervisor is required. The ARMv7 architecture with virtualization extension calls this privilege level PL2 or HYP mode.

Linux with KVM for ARM uses this mode to provide CPU virtualization. The CPU needs to be in HYP mode when Linux is booting so KVM can make use of the extension. How KVM uses the HYP mode in detail is explained in this excellent LWN article. After building a kernel with KVM support, I encountered this problem first: By default, the system did boot in SVC mode.

Brought up 2 CPUs
CPU: All CPU(s) started in SVC mode.
kvm [1]: HYP mode not available

Secure and Non-Secure world

ARMv7 privilege levels

ARMv7 privilege levels

To understand how to switch into Hypervisor mode, one needs to understand the whole privilege level architecture first. Notable here is that on ARMv7 CPU’s the HYP mode is only available in non-secure mode, by design. Any hypervisor needs to operate in non-secure mode, there is no virtualization extension in secure mode. Read more »

Convert VMware growable, splitted and snapshoted disks

In the last weeks I started to migrate my virtual machines to KVM. Until now, I used on two Servers VMware Server 2.0 on Ubuntu, which caused many problems with Disk I/O’s and performance problems. Either way, I prefer Open Source software whenever possible. KVM and libvirt, which I use to manage KVM, is in a quite mature state nowadays.

To convert the VMware images I used this How-To. This worked quite well for most of my Virtual Machines. But several had snapshots or were split into 2GB files. This cant be handled by qemu-img. I converted the files to single, flat disk file first using vmware-vdiskmanager. In the end, I wanted to have pre-allocated (single file) anyway, because it provides best performance:

$ vmware-vdiskmanager -r Ubuntu.vmdk -t 0 Ubuntu-copy.vmdk

Read more »

VirtualBox 3.1 Performancevergleich

Gestern wurde VirtualBox 3.1 freigegeben. Im ChangeLog steht, dass die Performance erheblich verbessert wurde. Dies wollte ich einmal auf den Prüfstand stellen, und habe ein paar Messungen auf meinem Notebook gemacht (HP EliteBook 8530w, Core 2 Duo T9400, 4 GB Ram mit Ubuntu Karmic 64-Bit). Dazu habe ich die Boot-Zeit zweier virtuellen Maschinen gemessen. Dafür habe ich die Maschine zuerst einmal gestartet, so dass alle Daten im Ram vorhanden sein sollten. Dannach habe ich zwei Durchläufe gestoppt, jeweils vom Startklick bis zum Login-Bildschirm. Die erste Maschine im Test war Windows 7 Ultimate 64-Bit von meiner SSD (Intel SSD 80GB X18-M G2), die zweite Maschine Windows XP Professional 32-Bit von meiner Magnetplatte (Seagate Momentus 320GB 7200upm). Beiden Maschinen sind mit S-ATA und Hardwarevirtualisierung konfiguriert. Die Resultate finden Sie nach dem Sprung. Read more »