[arch-releng] WIP: qemu-kvm helper for testing VM's

Dieter Plaetinck dieter at plaetinck.be
Sat Dec 24 10:12:11 EST 2011


Hi, i created a simple script to run test/install VM's based on qemu-kvm.
i started off with http://blog.falconindy.com/articles/build-a-virtual-army.html
i didn't test the networking yet (in fact, i have networking disabled for now)
but the useful thing about this script is it automatically adds the right serial/console parameters to the kernel args,
when booting archiso, using xdotool (for this to work, ttyS0 needs to be setup in inittab).

two problems:
1) i can't do the same xdotool trick yet when booting the actual system, because syslinux doesn't appear in the terminal when booting the system, whereas it does appear when booting archiso. (this is why for now you get to see both the terminal and a vga window in vm_run())
2) when booting the target system, the kernel doesn't seem to find the blockdevice at all. (whereas it just works when booting archiso).

here's what I have so far, maybe somebody finds it useful:
feedback very welcome.

#!/bin/bash

mem=1024
cpus=2
net='nic,model=virtio'
drive='file=arch-testbox,if=virtio'
cdrom=$HOME/downloads/archlinux-2011.12.24_10-40-01-core-i686.iso

vm_install () {
        (sleep 2; xdotool key Tab ; sleep 1; xdotool type --delay 30 " serial=tty0 console=ttyS0,115200n8"; xdotool key Return) &
        qemu-kvm -m $mem -smp $cpus -net $net -drive $drive -cdrom $cdrom -boot d -serial /dev/tty -nographic
}
vm_run () {
        # TODO: fix this, syslinux doesn't appear on tty (whereas it does appear when booting archiso)
        #(sleep 2; xdotool key Tab ; sleep 1; xdotool type --delay 30 " serial=tty0 console=ttyS0,115200n8"; xdotool key Return) &
        qemu-kvm -m $mem -smp $cpus -net $net -drive $drive -cdrom $cdrom -serial /dev/tty
}

#vm_install
vm_run


More information about the arch-releng mailing list