Wednesday, November 26, 2008

KVM, VMWare and VirtualBox

I like having all three options available to me. Unfortunately, some of the virtualization vendors don't like my having these options. I want to have all three "big names" available to me whenever I want. Because VMWare Player 2.5 (and in turn, Workstation 6.5) absolutely refuses to install with KVM loaded, one must unload kernel modules for your favorite HVM utility before loading another.

This is where my rc.hvm script comes in. It loads the appropriate kernel modules for the HVM solution you wish to use at the time. This is pretty convenient on a desktop system where you may have all three installed at once.

Check it out. It requires you to make an /etc/rc.d/hvm dir, put the init scripts from VirtualBox and VMware (/etc/rc.d/rc.vboxdrv, /etc/rc.d/rc.vboxnet and /etc/init.d/vmware, respectively) into this new dir. Also, you may want to comment out the VBox portions of /etc/rc.d/rc.local so it isn't run automatically at boot time.

Check it out and let me know what you think.


#!/bin/sh
# Start/stop/restart kernel hardware virtualization support (hvm)
# This loads modules for VMWare/VirtualBox/KVM one at a time
# current default is KVM
#
# Written for Slackware Linux by Fred Richards (fredr/at/geexology.org)
# TODO: - sanity checking on functions
#

CPU_VENDOR="amd" # or intel

kvm_unload() {
if grep -q kvm /proc/modules ; then
/sbin/rmmod kvm-$CPU_VENDOR
/sbin/rmmod kvm
echo "Removed $CPU_VENDOR KVM modules."
fi
}

vmware_unload() {
if grep -q vmmon /proc/modules || grep -q vmnet /proc/modules ; then
/etc/rc.d/hvm/vmware stop
fi
}

vbox_unload() {
if grep -q vboxdrv /proc/modules ; then
/etc/rc.d/hvm/rc.vboxdrv stop
/etc/rc.d/hvm/rc.vboxnet stop
fi
}

kvm_load() {
rm /var/run/hvminfo.txt
echo "kvm" > /var/run/hvminfo.txt
vbox_unload
vmware_unload
/sbin/modprobe kvm-$CPU_VENDOR
echo "Loaded $CPU_VENDOR KVM modules."
}

vmware_load() {
rm /var/run/hvminfo.txt
echo "vmware" > /var/run/hvminfo.txt
kvm_unload
vbox_unload
/etc/rc.d/hvm/vmware start
}

vbox_load() {
rm /var/run/hvminfo.txt
echo "vbox" > /var/run/hvminfo.txt
kvm_unload
vmware_unload
/etc/rc.d/hvm/rc.vboxdrv start
/etc/rc.d/hvm/rc.vboxnet start
}

stop_all() {
rm /var/run/hvminfo.txt
echo "none" > /var/run/hvminfo.txt
vmware_unload
vbox_unload
kvm_unload

}

status() {
echo "Currently loaded modules: `cat /var/run/hvminfo.txt`"
}

case "$1" in
'start')
kvm_load
;;
'kvm')
kvm_load
;;
'vmware')
vmware_load
;;
'vbox')
vbox_load
;;
'stop')
stop_all
;;
'none')
stop_all
;;
'restart')
stop_all
kvm_load
;;
'status')
status
;;
*)
echo "usage $0 start|kvm|vmware|vbox|stop|none|restart|status"
esac

Thursday, September 04, 2008

Fauxputers and Killing Time

Today heralded the release of VirtualBox 2.0.0 so I went and grabbed it, and promptly installed it on my Slamd64 workstation/host machine. It works pretty well, and trying out several Linux distros is a good way to kill time.

Speaking of killing time, this month marks the start of the new season of one of my favorite shows on television, Dexter on Showtime.

Is This Thing On?

Seeing as I've had this account, and the coordinating domain, for a while, now is as good a time as any to begin using it.

I'm currently sitting here watching There Will Be Blood, but it might as well be called there may be boredom emanating from this movie.