Getting Up and Running with KVM-Autotest

In anticipation of the upcoming KVM Autotest Install Fest I thought I’d get a bit of a head start on the basic autotest install so I can spend the day doing fun things like actually writing some new tests!

In this post I will be documenting my own experiences/procedures in the basic setup for getting up and running with autotest. In a follow-up post I will be documenting my experiences in writing my own kvm-autotest tests.

For this installation we’ll be doing the basic autotest client install, which is simple setup for running autotest tests on single host. There’s also a server installation, which we won’t go into here. My host is Ubuntu 10.04 Lucid, so I’ll be focusing on that. Your results may vary, but hopefully most of these items will be generally applicable.


For the install, we’ll be following the instructions here fairly closely:

– Install git:

sudo apt-get install git

– Install supporting packages.

This will differ depending on your distro/configuration. A reasonable initial stab would be:

sudo apt-get install qemu-kvm qemu-img syslinux gvncviewer

– Clone the autotest git repo.

It’s about 111MB, so this may take a while depending on your connection

git clone git:// ~/dev/kvm/autotest.git


There’s a script that will handle basic setup for you. This consists mainly of creating required directories in /tmp, copying the sample config files over to expected config locations, verifying qemu-kvm and qemu-img are at the expected locations, and confirming that a Fedora 14 ISO (the guest used for default installs) can be obtained via web. Unfortunately it was written specifically for Fedora and will break on Ubuntu. But there’s not a whole lot going on here, so we’ll walk through the steps manually.

– Create required folders.

You can change these, but unlike most configuration directives, these aren’t very easy to overwrite since they’re declared in multiple config/control files.

mkdir /tmp/kvm_autotest_root/images
mkdir -p /tmp/kvm_autotest_root/isos/linux
mkdir -p /tmp/kvm_autotest_root/isos/windows

As an alternative, I use a set of symlinks to shoehorn this into to something that fits my setup a little better.

mdroth@illuin:~$ ls -l /tmp/kvm_autotest_root
lrwxrwxrwx 1 mdroth mdroth 34 2011-04-13 00:01 /tmp/kvm_autotest_root -> /home/mdroth/vm/kvm_autotest_root/
mdroth@illuin:~$ ls -l /tmp/kvm_autotest_root/
total 8
drwxr-xr-x 3 mdroth mdroth 4096 2011-04-13 08:08 images
drwxr-xr-x 2 mdroth mdroth 4096 2011-04-13 00:16 isos
mdroth@illuin:~$ ls -l /tmp/kvm_autotest_root/isos/
total 0
lrwxrwxrwx 1 mdroth mdroth 10 2011-04-13 00:16 linux -> ../../iso/
lrwxrwxrwx 1 mdroth mdroth 10 2011-04-13 00:16 windows -> ../../iso/

– (optional) Create a new git branch.

Before you start, I’d recommend creating a new branch in autotest.git…autotest is a complex framework, and you may find yourself needing to tweak the source here and there for your particular setup, so tracking these changes in your own branch will ensure you don’t end up with a Frankenstein you can no longer keep in sync with upstream. Creating your own branches for any tests/control files you add will be useful in this regard as well, making it easier to track your local changes and get your tests upstream if you think they’ll be generally useful.

cd ~/dev/kvm/autotest.git/client/tests/kvm
git checkout -b local1

– build.cfg

This file specifies parameters for the kvm build/install test. There are templates here for doing builds/installs from git, release tarballs, yum, etc. This is useful if you’re testing modifications to qemu (build/source code changes, regression testing, etc). By default this test is skipped, so if that’s sufficient you just need to copy over the template:

cp build.cfg.sample build.cfg

For our simple example, I don’t actually need to build a modified qemu binary. But I may want to if I need to test changes to qemu, and Ubuntu 10.04 uses a fairly outdated version of qemu-kvm (0.12.3), so I’d prefer pointing to a fresh build anyway. Autotest actually supports building from local source, or a git repo, as part of the test procedure, but I ended up needing to modify the autotest.git source code to actually get it working, and beyond that there are a few annoying quirks. And after working through those, I was somewhat dismayed to find that there was no way to pass configure options in to the build procedure without further source code modification. This might not be a huge deal with qemu-kvm.git since it has KVM-centric default config options, but, with qemu.git, being able to specify –target-list=x86_64-softmmu to avoid building a bajillion emulated target platforms, and specifying –enable-io-thread, are really important. I may work through these issues and get some patches to the autotest folks in the future, but for now I’ve resorted to pointing autotest to the binaries sitting in my local git repo and handling the build process myself. So the default build.cfg is sufficient for now, and we’ll set the paths to our binaries elsewhere.

– cdkeys.cfg

This file specifies CD keys that may be required for automated installs of your ISOs. Not needed in my case but we’ll go ahead copy over the sample:

cp cdkeys.cfg.sample cdkeys.cfg

– tests_base.cfg

Again, mostly defaults here. You shouldn’t need to mess with these too much as the more important parameters can be overwritten in tests.cfg. Eventually you should set some sane defaults here as the requirements for your setup become clearer however. I did need to modify the default path to my RHEL6 ISO:

mdroth@illuin:~/dev/kvm/autotest.git/client/tests/kvm$ diff -u tests_base.cfg.sample tests_base.cfg
--- tests_base.cfg.sample	2011-04-07 21:19:45.000000000 -0500
+++ tests_base.cfg	2011-04-13 00:07:30.000000000 -0500
@@ -1790,7 +1790,8 @@
                             kernel = images/rhel60-64/vmlinuz
                             initrd = images/rhel60-64/initrd.img
-                            cdrom_cd1 = isos/linux/RHEL-6.0-x86_64-DVD.iso
+                            #cdrom_cd1 = isos/linux/RHEL-6.0-x86_64-DVD.iso
+                            cdrom_cd1 = isos/linux/RHEL6.0-20100922.1-Server-x86_64-DVD1.iso
                             md5sum_cd1 = f7141396c6a19399d63e8c195354317d
                             md5sum_1m_cd1 = b060eeef63e2c8700db54ae02056e80c

– tests.cfg

Now to the heart of it: defining an actual test. You’ll see some examples in tests.cfg.sample which include some default tests for install/boot/shutdown for Fedora, as well as a deceptively simple looking “@full:” entry will will basically run all tests for all permutations of guest/guest setup. At least it would seems that’s the case, perhaps some heuristics (only ISOs you actually have present, etc) are used to cull things down somewhat. Not gonna try it, personally, but be my guest!

In our case we just want to do a simple install/boot/shutdown test of RHEL6 to make sure everything is set up properly (feel free to plug in the distro of your choice, the Fedora 14 default is probably a good choice for most). The default “@qemu_kvm_f14_quick” entry serves as a good starting point. Poking around in tests_base.cfg we see there’s a “RHEL” variant of the “Linux” guest type, and a “6.x86_64” variant of that, so in place of “only Fedora.14.64” we’ll use “only RHEL.6.x86_64”. Since in this case we’re using binaries from a local qemu.git repo, we’ll also modify qemu_binary, qemu_img_binary, and add some extra params to pass to qemu to enable kvm and specify a bios image from the repo.

Here’s the diff between tests.cfg.sample and the tests.cfg I ended up with:

mdroth@illuin:~/dev/kvm/autotest.git/client/tests/kvm$ diff -u tests.cfg.sample tests.cfg
--- tests.cfg.sample    2011-04-13 08:34:59.000000000 -0500
+++ tests.cfg   2011-04-13 09:32:07.000000000 -0500
@@ -82,6 +82,22 @@
         only Fedora.14.64
         only unattended_install.cdrom, boot, shutdown
+    # Run qemu built from qemu.git, install rhel6 guest OS, boot
+    # run our hello world test, then shutdown
+    - @qemu_rhel6_install_test:
+        qemu_binary = /home/mdroth/dev/kvm/qemu.git/x86_64-softmmu/qemu-system-x86_64
+        qemu_img_binary = /home/mdroth/dev/kvm/qemu.git/qemu-img
+        only raw
+        only virtio_net
+        only virtio_blk
+        only smp2
+        only smallpages
+        only no_pci_assignable
+        only RHEL.6.0.x86_64
+        only unattended_install.cdrom, boot, shutdown
+        extra_params += ' -enable-kvm'
+        extra_params += ' -bios /home/mdroth/dev/kvm/qemu.git/pc-bios/bios.bin'
# You may provide information about the DTM server for WHQL tests here:
#    server_address =
@@ -96,4 +112,5 @@
#kill_unresponsive_vms.* ?= no
# Choose your test list from the testsets defined
-only qemu_kvm_f14_quick
+#only qemu_kvm_f14_quick
+only qemu_rhel6_install_test


Now we should be ready to kick off our RHEL6 install/boot/shutdown test:

cd ~/dev/kvm/autotest.git/client/tests/kvm
sudo ../../bin/autotest control

This may take a while. Since we’re impatient we’ll poke around a bit to make sure there’s some work getting done:

mdroth@illuin:~$ ps aux | grep qemu
root     22352  0.0  0.0   4096   584 pts/15   Ss+  09:39   0:00 /bin/sh -c /home/mdroth/dev/kvm/qemu.git/x86_64-softmmu/qemu-system-x86_64 -name 'vm1' -monitor unix:'/tmp/monitor-humanmonitor1-20110413-080805-uEV0',server,nowait -serial unix:'/tmp/serial-20110413-080805-uEV0',server,nowait -drive file='/tmp/kvm_autotest_root/images/rhel6-64.raw',index=0,if=virtio,cache=none -device virtio-net-pci,netdev=idC9g3qc,mac='9a:e4:c7:8b:af:5c',id='idnJZA6O' -netdev user,id=idC9g3qc,hostfwd=tcp::5000-:22,hostfwd=tcp::5001-:12323 -m 512 -smp 2 -drive file='/tmp/kvm_autotest_root/isos/linux/RHEL6.0-20100922.1-Server-x86_64-DVD1.iso',media=cdrom,index=2 -drive file='/tmp/kvm_autotest_root/images/rhel60-64/ks.iso',media=cdrom,index=1 -kernel '/tmp/kvm_autotest_root/images/rhel60-64/vmlinuz' -initrd '/tmp/kvm_autotest_root/images/rhel60-64/initrd.img' -vnc :0  -boot d --append 'ks=cdrom nicdelay=60 console=ttyS0,115200 console=tty0' -enable-kvm -bios /home/mdroth/dev/kvm/qemu.git/pc-bios/bios.bin && echo ryq6B4tB > /dev/null
root     22354 64.2  7.4 1018384 297480 pts/15 Rl+  09:39   0:12 /home/mdroth/dev/kvm/qemu.git/x86_64-softmmu/qemu-system-x86_64 -name vm1 -monitor unix:/tmp/monitor-humanmonitor1-20110413-080805-uEV0,server,nowait -serial unix:/tmp/serial-20110413-080805-uEV0,server,nowait -drive file=/tmp/kvm_autotest_root/images/rhel6-64.raw,index=0,if=virtio,cache=none -device virtio-net-pci,netdev=idC9g3qc,mac=9a:e4:c7:8b:af:5c,id=idnJZA6O -netdev user,id=idC9g3qc,hostfwd=tcp::5000-:22,hostfwd=tcp::5001-:12323 -m 512 -smp 2 -drive file=/tmp/kvm_autotest_root/isos/linux/RHEL6.0-20100922.1-Server-x86_64-DVD1.iso,media=cdrom,index=2 -drive file=/tmp/kvm_autotest_root/images/rhel60-64/ks.iso,media=cdrom,index=1 -kernel /tmp/kvm_autotest_root/images/rhel60-64/vmlinuz -initrd /tmp/kvm_autotest_root/images/rhel60-64/initrd.img -vnc :0 -boot d --append ks=cdrom nicdelay=60 console=ttyS0,115200 console=tty0 -enable-kvm -bios /home/mdroth/dev/kvm/qemu.git/pc-bios/bios.bin
mdroth   22380  0.0  0.0   7628   940 pts/12   S+   09:40   0:00 grep qemu

That’s the good stuff.  Feel free to open up a vnc session to keep an eye on things as the install progresses:

gvncviewer :0

And that’s it!

In a follow-up post I’ll be going through procedure for actually adding in your own custom kvm-autotest tests.


About Mike Roth

Mike Roth is a long time linux enthusiast, and currently a member of IBM's Linux Technology Center working on virtualization with QEMU/KVM
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s