KVM virtualization

Installation REQUIRED for KVM: Intel VT or AMD-V extensions (vmx or svm in /proc/cpuinfo)

yum groupinstall kvm

Kickstarting When kickstarting a KVM, you may have occasion to start over if you've made a typo or forgot to setup the VLAN network or something. Simply perform a “virsh destroy {guest_name}” followed by a “virsh undefine {guestname}”. Voila, clean slate to try and kickstart again.

Notes

Para-virt = Xen, Full-virt = KVM

Xen guests require Xen kernel

Migration between hypervisors only (Xen-to-Xen, KVM-to-KVM)

Folders:

Config = /etc/libvirt/qemu/

Logs = /var/log/libvirt/qemu/

How-To: Hot-Add Disk Device to Running KVM Virtual Guest:

Login to virtual machine and run:

modprobe acpiphp

Login to physical host chassis OS and run command (vd? is equal to the next virtual disk name available, vda typically being the root disk):

virsh attach-disk domainname /path/to/source/disk/or/vg vd?

Back on virtual machine, run parted or fdisk on newly attached disk

To make addition of disk permanent upon reboot, back on physical chassis run command:

virsh dumpxml domainname > /tmp/domainname.tmp.xml
sdiff /etc/libvirt/qemu/domainname.xml /tmp/domainname.tmp.xml

Note the differences for the disk (disregard the rest). From the /tmp/domainname.tmp.xml file, copy the XML text that shows your newly added disk and open up /etc/libvirt/qemu/domainname.xml and paste this XML code in underneath the entry for your virtual machine OS disk.

How-To: Boot Rescue Mode

Edit the machine configuration file: /etc/libvirt/qemu/{server}.xml

Change boot dev to cdrom

Add the following lines (change the RHEL version to match VM or update as needed):

<disk type='file' device='cdrom'>
<source file='/net/kickstart/kickstart/iso/rhel-server-5.5-x86_64-dvd.iso'/>
<target dev='hdc' bus='ide'/>
<readonly/>
</disk>

At the boot prompt, enter linux rescue

How-To: Live Migrate KVM Virtual Machine to Different Chassis

virsh migrate --live {guest} qemu+ssh://{remote_host}/system

Editing the Attributes of a Virtual Machine

libvirt stores it's configuration as xml in '/etc/libvirt/qemu'. The xml is easy to understand, and is similar to VMware *.vmx files. While it is possible to edit these files in place and restart libvirt-bin for the changes to take affect, the recommended method for modifying the attributes of a virtual machine is via virsh (or virt-manager, if it supports changing the hardware you want to change). The concept is simple:

export (aka 'dump') the xml of the virtual machine you want to edit

edit the xml

import (aka 'define') the xml

For example, to edit the machine named 'foo' (you can get a list of your machines with 'virsh list --all'), do:

$ virsh dumpxml foo > /tmp/foo.xml
(edit /tmp/foo.xml as needed)
$ virsh define /tmp/foo.xml