Linux + KVM + libvirt is pretty cool!

home | blog | Teh Internet | guest blog |rants | placeholder | political | projects | Gwen and Liam | Citadel patched | Tools | Scouts


- Careful Chrome users, this search box might be "Not secure"


On Slackware 13.0 64 bit:

modprobe kvm
modprobe kvm-intel
modprobe virtio

git clone git://git.kernel.org/pub/scm/virt/kvm/qemu-kvm.git
cd qemu-kvm
./configure && make && make install

Fetch some libvirt:

http://slackbuilds.org/repository/13.0/libraries/libvirt/

After installing your libvirt, don't forget to symlink your
/usr/bin/kvm to qemu-system-x86_64

And stub out some xml for you guest like this in:
/etc/libvirt/qemu/hostxp.xml:

<domain type='kvm'>
  <name>hostxp</name>
  <uuid>8bb72357-06d4-e5cb-8c9c-e7bb6379fe95</uuid>
  <memory>1048576</memory>
  <currentMemory>1048576</currentMemory>
  <vcpu>2</vcpu>
  <os>
    <type arch='i686'>hvm</type>
  </os>
  <features>
    <acpi/>
  </features>
  <clock offset='localtime'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <emulator>/usr/bin/kvm</emulator>
    <disk type='file' device='disk'>
      <source file='/root/vms/winxp-registered-and-base-installed-clean-sp3'/>
      <target dev='hda' bus='ide'/>
    </disk>
    <interface type='network'>
      <source network='default'/>
    </interface>
    <input type='tablet' bus='usb'/>
    <input type='mouse' bus='ps2'/>
    <graphics type='vnc' port='5902' autoport='no' listen=''/>
    <sound model='sb16'/>
    <video>
      <model type='vga' vram='9216' heads='1'/>
    </video>
  </devices>
</domain>

Start the daemon libvirtd in a startup script

Crank it up from the virsh:

virsh
start hostxp
start a vncviewer :2 on localhost and you are off the the races!

And even take the Python module for a ride as well!


import libvirt
import sys

conn = libvirt.openReadOnly(None)
if conn == None:
    print 'Failed to open connection to the hypervisor'
    sys.exit(1)

try:
    dom0 = conn.lookupByName("hostxp")
except:
    print 'Failed to find the main domain'
    sys.exit(1)

print "Domain 0: id %d running %s" % (dom0.ID(), dom0.OSType())
print dom0.info()

Monitor that set of vm's!:

http://et.redhat.com/~rjones/nagios-virt/




[æ]