Hardcore Linux

Anything about Ubuntu, Centos, openSuSe and Fedora

Category Archives: KVM

KVM guest not automatically starting at boot sequence

I don’t know but I encountered this problem using Ubuntu 12.04 as KVM host, even though I already added the guest VM in the /etc/libvirt/qemu/autostart as symlink  but during the host boot sequence it is still not automatically started (the guest machine).

Here’s a quickfix that works for me:

1. Modify the /etc/init/libvirt-bin.conf and look for the line with:

start on runlevel [2345]

2. Replace that with:

start on (runlevel [2345] and net-device-up IFACE=br0)

3. Done.

Please note that use your current bridge network device, in my example it is br0.



Installing KVM with OpenVSwitch on Ubuntu 12.04

Here’s a good article from http://blog.allanglesit.com/, I myself tried it my in test server and it’s working great, though I’m still new with OpenVSwitch.

The article has been released for Ubuntu 12.04 system. I also found out that the KVM version currently available in Ubuntu 12.04 has better performance compare to 10.04, which I think is a good sign when planning to deploy KVM host for your VMs.

The actual URL: http://blog.allanglesit.com/2012/03/linux-kvm-ubuntu-12-04-with-openvswitch/


Automatically shutdown KVM Virtual Machines

Currently, there’s no built-in tool to properly shutdown VMs  when the KVM host does. So after couple of hour “googling” it I got some idea from this link, made some changes to make simplier. Here’s my version:


LIST_VM=`virsh list | grep running | awk '{print $2}'`
DATE=`date -R`

if [ "x$activevm" =  "x" ]
 exit 0

for activevm in $LIST_VM
 PIDNO=`ps ax | grep $activevm | grep kvm | cut -c 1-6 | head -n1`
 echo "$DATE : Shutdown : $activevm : $PIDNO" >> $LOGFILE
 virsh shutdown $activevm > /dev/null
 while [ "$COUNT" -lt "$TIMEOUT" ]
ps --pid $PIDNO > /dev/null
if [ "$?" -eq "1" ]
sleep 5
if [ $COUNT -lt 110 ]
echo "$DATE : $activevm not successful force shutdown" >> $LOGFILE
virsh destroy $activevm > /dev/null
  1. Save the code in /etc/init.d/shutdownvm
  2. Then make it an executable file
    chmod 755 /etc/init.d/shutdownvm
  3. Create links to both rc0.d and rc6.d
    cd /etc/rc0.d ln -s ../init.d/shutdownvm K18shutdownvm cd /etc/rc6.d ln -s ../init.d/shutdownvm K18shutdownvm
  4. Done.

Installing Virt Manager for Ubuntu 10.04

After establishing my KVM host from other machine, now it’s the time you need to configure your remote kvm guest manager, if you prefer the GUI management. Here’s the quickest way to do:

  1. Execute this in the console:
    $> sudo apt-get install ubuntu-virt-mgmt
  2. After that you can now add remote KVM host and  manage your vms.
  3. Done.
%d bloggers like this: