Sunday, May 10, 2015

Preparing a test VM - Compile and run a module

Hi,

This is the final post in preparing our test environment. We will write a code piece and run it in the VM. You must have finished previous sections (filesystem, kernel and QEMU) to be able to carry out the instructions in this one. After finishing this you should be able to compile and run your own kernel level code.

Preparing a test VM - QEMU

We have our kernel and our filesystem. Now we need to utilize virtualization to run our OS.

I will not talk about how virtualization or emulation works. However you need to know a few details.

When IT people think what virtualization technology is all about, they often think how host CPUs are shared between VMs and how various memory tricks work, like ballooning or taking memory snapshots. After that storage or network infrastructure and configuration comes to mind. And of course, live migration, which looks like pure magic the first time you see it work (if you have a cluster of hosts)

For kernel development we are interested in different kind of stuff. Most of the time we need only one machine with fixed amount of memory, fixed amount of disk space and just one virtual CPU.

Preparing a test VM - Kernel

In previous post I talked about preparing a filesystem with Gentoo. Today I will talk about compiling the Linux kernel.

In normal Gentoo setup you emerge (install like "apt-get install" in Ubuntu) the kernel from Gentoo repo and compile it on the machine you are installing Gentoo.

We will be doing something different. Using virtualization, we will feed the kernel binary files from the host to the VM. The main reason is we need the compiled kernel files in our development environment to compile modules for that kernel. Kernel source and the module files should be located in the same machine.

Preparing a test VM - Filesystem

Hello,

This will be the first of a five part how-to on using virtualization to create a testing environment. We need a separate test machine because we will be crashing the kernel most of the time and rebooting your computer each time will be hazardous for your computer and frustrating for you.

We will be using QEMU for virtualization and Gentoo for the guest operating system where our kernel code will run. I assume development will be done in the same machine which is the virtualization host. I will not cover the virt host/development environment, you can use any distro capable of running QEMU (and preferably kvm).