nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

KVM: Integrated Hypervisor in Kernel 2.6.20+

This is a discussion on KVM: Integrated Hypervisor in Kernel 2.6.20+ within the XEN forums, part of the Linux virtualization category; Kernel-based Virtual Machine (KVM) has been around for sometime and now is integrated with the linux kernel as of version ...

Register free or login to your existing account and remove all advertisements.


Go Back   nixCraft Linux Forum > Linux virtualization > XEN

Linux answers from nixCraft.


XEN Discussion about Xen virtual machine monitor (VPS)

View Poll Results: What virtualization technology do you use?

Hardware Assisted - VMware ESX, Virtual Iron, KVM, MS Hyper-V 1 50.00%
Full Virtualization - VMware Server, Virtual Box, Parallels, 0 0%
ParaVirtualization - User Mode Linux, XEN 1 50.00%
OS Virtualization - OpenVZ, Linux Vserver, Virtuozzo 0 0%
Multi-server virtualization - ScaleMP 0 0%
Multiple Choice Poll. Voters: 2. You may not vote on this poll

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-15-2008, 01:26 AM
Junior Member
User
 
Join Date: Oct 2008
OS: Mepis / SuSE
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
intelliginix is on a distinguished road
Default KVM: Integrated Hypervisor in Kernel 2.6.20+

Kernel-based Virtual Machine (KVM) has been around for sometime and now is integrated with the linux kernel as of version 2.6.20. This new marriage makes it possible to run other operating systems, such as Windows XP and others within your Linux system. KVM takes advantages of the hardware support provided by the Intel-VT and the AMD-V processor.

Under KVM’s model, every virtual machine is a regular Linux process scheduled by the standard Linux scheduler. A normal Linux process has two modes of execution: kernel and user. KVM adds a “guest” mode which has its own kernel and user modes.

Running Windows XP over KVM/Linux compares favorably to the native execution of Windows XP. In comparison to its predecessor QEMU, KVM clearly out performs it in most cases more than 10:1 according to Linux Insight. However QEMU and KQEMU coupled together will still give KVM a run for the money without the need for virtualization support built into the processor.


The KVM Hypervisor

The KVM code simply turns a Linux kernel into a hypervisor simply by loading a kernel module. The kernel module exports a device called /dev/kvm, which enables a guest mode of the kernel (in addition to the traditional kernel and user modes). With /dev/kvm, a VM has its own address space separate from that of the kernel or any other VM that’s running. Devices in the device tree (/dev) are common to all user-space processes. But /dev/kvm is different in that each process sees a different device map (to support isolation of the VMs). With the kernel acting as a hypervisor, you can then start other operating systems, such as another Linux kernel, Windows, or another operating system.



Using KVM

Using KVM is really quite simple assuming that you have the hardware to support it, and all of the necessary KVM packages installed on your system. Enter this command at a shell prompt If you need to check to see if your processor supports hardware virtualization (works with bash, but should also work with other shells):

Code:
vlab-host01:~ $ egrep ‘(vmx|svm)’ /proc/cpuinfo
flags           : fpu vme de pse tsc msr pae … vmx …
flags           : fpu vme de pse tsc msr pae … vmx …
(some of the output is truncated)


There are two sets of flags because the system has two processors (which isn’t uncommon on newer systems). You would be looking for the “vmx” flag for an Intel-VT and the “svm” flag for an AMD-V processor.

With the KVM module installed, you can now start your guest operating system in user-space. For starters you could test KVM by initiating a KVM session using a bootable CDROM or DVD (ISO or physical media). If you need a permanent virtual server then first you would have to create a disk image and then start a KVM session with your installable media attached to the session. Here is the quickest way to do that:

Code:
vlab-host01:/vm/winxp $ qemu-img create -f qcow virtual-disk.img 5G
Formatting ‘virtual-disk.img’, fmt=qcow, size=5242880 kB

vlab-host01:/vm/winxp $ ls -l virtual-disk.img
-rw-r–r– 1 root root 20528 Dec 10 22:19 virtual-disk.img

This creates a 5GB disk image in qcow format. This dynamic disk image is a little bit less that 20KB initially when created, but will expand as-needed up to 5GB. You could make an image that starts out at 5GB as well, but this way saves space.

Next you can either create an ISO image of your installation media (generally faster) or you can just use the physical device link to install your guest operating system from.

In linux you can use a command like dd to create an ISO image from a CDROM or DVD:

Code:
vlab-host01:/vm/winxp $ dd=if=/dev/cdrom of=winxp-sp2.iso bs=1024K

Make sure that you are in a windowing environment like GNOME or KDE (others work too). Now you can initiate a KVM session like this:

Code:
vlab-host01:~ $ kvm -no-acpi -m 512 -smp 2 -cdrom winxp-sp2.iso -hda virtual-disk.img -boot d

In this case, the kvm command initializes a session that has 512MB of memory, attaches our installation image “winxp-sp2.iso” to the cdrom device (/dev/hdc), and the qcow image “virtual-disk.img” to the first hard disk (/dev/hda), boots from the CDROM, emulates 2 processors, and turns off ACPI (still a few bugs).

Voila! Hit enter and your KVM guest will boot up!

If you think this post was helpful please feel free to visit my site @ http://virtualize-it.highspeed-data.net!

Last edited by intelliginix; 12-15-2008 at 01:40 AM. Reason: Forgot the trackback
Reply With Quote
Reply

Tags
hardware-assisted-vm , hypervisor , kernel , kvm , virtualization


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Is Linux kernel is monolithic or modular kernel? chiku Linux software 3 08-27-2009 03:56 AM
Linux kernel deleted from /boot - how do I resinstall the kernel vaibhav.kanchan Getting started tutorials 2 03-25-2008 01:31 AM
Yum install kernel debuginfo packages kernel-debuginfo repo rockdalinux Getting started tutorials 0 06-15-2007 10:59 PM
Kernel Compile mannrj45 Linux software 1 12-02-2006 09:32 PM
What are the advances of Kernel 2.6 over Kernel 2.4 ricc Linux software 3 03-14-2006 01:42 PM


All times are GMT +5.5. The time now is 12:59 PM.


Powered by vBulletin® Version 3.8.4 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2009 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38