| based Virtual Machine (KVM) has been around for | | | | (some of the output is truncated) |
| sometime and now is integrated with the linux kernel | | | | There are two sets of flags because the system has |
| as of version 2.6.20. This new marriage makes it | | | | two processors (which isn’t uncommon on |
| possible to run other operating systems, such as | | | | newer systems). You would be looking for the |
| Windows XP and others within your Linux system. | | | | vmx flag for an Intel-VT and the svm |
| KVM takes advantages of the hardware support | | | | flag for an AMD-V processor. |
| provided by the Intel-VT and the AMD-V processor. | | | | With the KVM module installed, you can now start |
| Under KVM’s model, every virtual machine is a | | | | your guest operating system in user-space. For |
| regular Linux process scheduled by the standard Linux | | | | starters you could test KVM by initiating a KVM |
| scheduler. A normal Linux process has two modes of | | | | session using a bootable CDROM or DVD (ISO or |
| execution: kernel and user. KVM adds a guest | | | | physical media). If you need a permanent virtual |
| mode which has its own kernel and user modes. | | | | server then first you would have to create a disk |
| Running Windows XP over KVM/Linux compares | | | | image and then start a KVM session with your |
| favorably to the native execution of Windows XP. In | | | | installable media attached to the session. Here is the |
| comparison to its predecessor QEMU, KVM clearly | | | | quickest way to do that:vlab-host01:/vm/winxp $ |
| out performs it in most cases more than 10:1 | | | | qemu-img create -f qcow virtual-disk.img 5G |
| according to Linux Insight. However QEMU and | | | | Formatting virtual-disk.img’, fmt=qcow, |
| KQEMU coupled together will still give KVM a run for | | | | size=5242880 kBvlab-host01:/vm/winxp $ ls -l |
| the money without the need for virtualization support | | | | virtual-disk.img |
| built into the processor. | | | | -rw-r—r— 1 root root 20528 Dec 10 |
| The KVM Hypervisor | | | | 22:19 virtual-disk.img |
| The KVM code simply turns a Linux kernel into a | | | | This creates a 5GB disk image in qcow format. This |
| hypervisor simply by loading a kernel module. The | | | | dynamic disk image is a little bit less that 20KB initially |
| kernel module exports a device called /dev/kvm, | | | | when created, but will expand as-needed up to 5GB. |
| which enables a guest mode of the kernel (in addition | | | | You could make an image that starts out at 5GB as |
| to the traditional kernel and user modes). With /dev | | | | well, but this way saves space. |
| kvm, a VM has its own address space separate from | | | | Next you can either create an ISO image of your |
| that of the kernel or any other VM that’s | | | | installation media (generally faster) or you can just |
| running. Devices in the device tree (/dev) are | | | | use the physical device link to install your guest |
| common to all user-space processes. But /dev/kvm is | | | | operating system from. |
| different in that each process sees a different device | | | | In linux you can use a command like dd to create an |
| map (to support isolation of the VMs). With the | | | | ISO image from a CDROM or DVD:vlab-host01:/vm |
| kernel acting as a hypervisor, you can then start | | | | winxp $ dd=if=/dev/cdrom of=winxp-sp2.iso |
| other operating systems, such as another Linux | | | | bs=1024K |
| kernel, Windows, or another operating system. | | | | Make sure that you are in a windowing environment |
| Using KVM | | | | like GNOME or KDE (others work too). Now you can |
| Using KVM is really quite simple assuming that you | | | | initiate a KVM session like this:vlab-host01:~ $ kvm |
| have the hardware to support it, and all of the | | | | -no-acpi -m 512 -smp 2 -cdrom winxp-sp2.iso -hda |
| necessary KVM packages installed on your system. | | | | virtual-disk.img -boot d |
| Enter this command at a shell prompt If you need to | | | | In this case, the kvm command initializes a session |
| check to see if your processor supports hardware | | | | that has 512MB of memory, attaches our installation |
| virtualization (works with bash, but should also work | | | | image winxp-sp2.iso to the cdrom device ( |
| with other shells):vlab-host01:~ $ egrep | | | | dev/hdc), and the qcow image virtual-disk.img |
| (vmx|svm)’ /proc/cpuinfoflags : fpu vme | | | | to the first hard disk (/dev/hda), boots from the |
| de pse tsc msr pae mce cx8
vmx
flags : fpu | | | | CDROM, emulates 2 processors, and turns off ACPI |
| vme de pse tsc msr pae mce cx8
vmx
| | | | (still a few bugs). |