User Tools

Site Tools


Sidebar

software:virtualization:kvm

pxe-booting kvm virtualmachines

Newer kvm has pxe-support build in. Just use '-boot n' as kvm parameter when starting the vm. There is also a bootmenu reachable with 'F12'. Older kvm-versions need floppies from rom-o-matic to be booted, i.e. the one for rtl8139 nics works for me.

Note: in my setup here one vm can supply another vm with an ip via dhcp, but tftp-get doesnt seem to work. I supply tftp-services from my host to the vms, this works.

mac os x running on kvm

  • http://alex.csgraf.de - Alexander created the patches to provide the kvm-environment macosx expects
  • http://vu1tur.eu.org/tools/ - dmg2img converts dmg-files to images that can be run by kvm
  • what runs: macosx, network, installing/running software etc.
  • what doesnt work: 3d, sound
compiling on debian amd64
  • better use the complete howto from the link above
mkdir -p /mnt/store/kvm/images_mac/
cd /mnt/store/kvm/images_mac/
wget http://download.opensuse.org/repositories/Virtualization:/KVM/openSUSE_Factory/src/kvm-84-7.2.src.rpm
mkdir kvm-src
cd kvm-src
rpm2cpio ../kvm-*.src.rpm | cpio -id
tar xvvjf kvm-*.tar.bz2
cp kvm.spec kvm_nosuse.spec
cat kvm.spec | sed '/Name:/ i\
%define suse_version 1100
'| sed 's/%suse_kernel_module_package/#%suse_kernel_module_package/' > kvm_nosuse.spec
quilt -v setup kvm_nosuse.spec
cd kvm-*/
cp -a bios bios-mac
quilt push -a -v
./configure --prefix=/mnt/store/kvm/images_mac/kvm_installed_kvm-84-7.2 \
  --audio-drv-list="oss alsa sdl" --audio-card-list="ac97 es1370 sb16 cs4231a adlib gus"
make -j4

cd bios-mac/
make
cd ..
sudo make install
sudo modprobe kvm_intel
sudo cp bios-mac/BIOS-bochs-latest /mnt/store/kvm/images_mac/kvm_installed_kvm-84-7.2/share/qemu-kvm/bios-mac.bin
wget -O /mnt/store/kvm/images_mac/kvm-osx-bootloader http://alex.csgraf.de/qemu/boot

files

  • qemu_add_tap_to_kvm0
#!/bin/sh
set -x
 
switch=kvm0
# switch=br0
 
if [ -n "$1" ];then
        /sbin/ifconfig $1 >&/dev/null || /usr/bin/sudo /usr/sbin/tunctl -u `whoami` -t $1
        /usr/bin/sudo /sbin/ip link set $1 up
        sleep 0.5s
        /usr/bin/sudo /usr/sbin/brctl addif $switch $1
        ifconfig $1 0.0.0.0 promisc up
        exit 0
else
        echo "Error: no interface specified"
        exit 1
fi
  • start_all_bridges.sh
#!/bin/bash

br="kvm0"
brctl addbr $br
ifconfig $br 10.0.22.1 netmask 255.255.255.0 broadcast 10.0.22.255

#br="kvm1"
#brctl addbr $br
#ifconfig $br 10.0.23.1 netmask 255.255.255.0 broadcast 10.0.23.255

#br="kvm2"
#brctl addbr $br
#ifconfig $br 10.0.24.1 netmask 255.255.255.0 broadcast 10.0.24.255
  • starting emulation of a vm: cmaster.sh
kvm \
    -hda cmaster.img \
    -cdrom /mnt/store/isos/centos-5.3-x86_64-dvd.iso \
    -boot d \
    -m 512 \
    -k de \
    -name cmaster \
    -net nic,vlan=1,macaddr=de:ad:be:ef:00:06,model=rtl8139 \
    -net tap,vlan=1,ifname=tap0,script=/mnt/store/kvm/qemu_add_tap_to_kvm0
#    -fda /mnt/store/kvm/kvm-pxe/usr/share/kvm/pxe-rtl8139.bin \
software/virtualization/kvm.txt ยท Last modified: 2021/03/23 12:22 (external edit)