KVM stands for Kernel based Virtual Machine, is the official virtualization system to Linux kernel, it is implemented as a Linux kernel module and becomes the running Linux in an hypervisor.
Without going deep, the virtualization systems can be divided in some groups:
-Emulation: VM simulates the full hardware, you can manage new hardware but you get low performance (qemu)
-Full virtualization: similar to the first one but OS's in guess machines will have to be from the same architecture (VirtualBox, KVM, XEN + VT, VMWare, Hyper-V)
-Paravirtualization: VM has the same architecture, high performance, no VT required. Cons: you need to modify host machine (with a Linux kernel module) (XEN, KVM, Hyper-V)
-OS level virtualization: there are some examples LXC, OpenVZ, FreeBSD Jails, ... (thanks to @JavierCelaya)
FreeBSD Jails allows to split a FreeBSD box into virtual environments running on the host machine called jails.
INSTALL WINDOWS7 (a perfectly legal one, of course )
As use case to introduce KVM I'm going to explain the installation process from virt-manager tool of Windows 7, feel free to use virt-install command to make the same process.
Before starting to install Windows 7 it's necessary install some packages to be able to use KVM on Debian GNU/Linux, here is the command used:
# aptitude install qemu-kvm libvirt-bin virt-manager virt-viewer
Let start with the set up process: Select Create a new virtual machine option.
Install from local ISO (in my case)
Use ISO image
OS Type: Windows
CPUs: 2 (up to 4)
Enable storage for this virtual machine
Create disk image on the computer's HD 15 GB
Allocate the entire disk now (check this option it depends on your needs)
NOTE: If virt-manager detects that there is created img files with the same name of the new virtual machine it shows a message: The following storage already exists, but is not in use by any virtual machine:
Would you like to reuse this storage? No (in my case)
IMPORTANT: Check customize configuration before install option
Just as simple advice it would be fine check Advanced options, here we could play with network settings (perhaps I'll talk about this in a future blog entry)
When you press Finish button a window appears to setup new hardware or remove the existing one, in our case I want to add other ISO image with libvirtio drivers to Windows7 see Virtio.
NOTE: In add hardware window if you select a hardware you'll get the following error, I don't know why but it seems that XML properties related to the virtual machine are not completely written. Error refreshing hardware page: unsupported operand type(s) for /: 'NoneType' and 'int'
Press add hardware option, select managed or other existing storage
Device type: IDE CDROM
Why install these drivers? Para-virtualized drivers enhance the performance of fully virtualized guests. With the para-virtualized drivers guest I/O latency decreases and throughput increases to near bare-metal levels. It is recommended to use the para-virtualized drivers for fully virtualized guests running I/O heavy tasks and applications. From here. You could download drivers file from here.
Now we can press Begin Installation button. Just remember that you will have to select the virtio drivers from the extra storage that previously it has created, when Windows7 install process let you do it Custom Advanced > Load Driver > Browser.
Some useful commands (thanks @FranLopez):
Mount the CD-ROM iso (taking into account CD-ROM as IDE device):
virsh # attach-disk your_domain_name /path/to/your.iso hdc --type cdrom --mode readonly
1. Assigning Host USB device to a Guest VM take a look to this URL.
2. You could improve disk I/O permance reading links like this.
3. And last but not worst if you need make a snapshop or convert an img storage file you could read this page.
REMOVE PREVIOUS WINDOWS7 INSTALLATION
I include this point in my entry because it could useful to know how remove virtual machines when you are doing tests with KVM. $ virsh --connect qemu:///system undefine windows7
Domain windows7 has been undefined
If you have virt-manager opened you will see as after executing the previous command the virtual machine windows7 disapears from the list of managed virtual machines.
It's not necessary to say that I'm not a virtualization expert, with this post I only want to collect some information about KVM that I've used installing some Windows virtual machines.