Preparing to use KVM
What do I need to use KVM?
You will need an x86 machine running a recent Linux kernel on an Intel processor with VT (virtualization technology) extensions, or an AMD processor with SVM extensions (also called AMD-V). Xen has a complete list of compatible processors. For Intel processors, see also the Intel® Virtualization Technology List.
Are 64bits processors supported under KVM?
Yes they are supported and will allow you to run 32bits and 64 bits guests.
See also Can KVM run a 32-bit guest on a 64-bit host? What about PAE? below.
What is Intel VT / AMD-V / hvm?
Intel VT and AMD's AMD-V are instruction set extensions that provide hardware assistance to virtual machine monitors. They enable running fully isolated virtual machines at native hardware speeds, for some workloads.
HVM (for Hardware Virtual Machine) is a vendor-neutral term often used to designate the x86 instruction set extensions.
Where do I get my kvm kernel modules from?
See the Getting the kvm kernel modules page.
How can I tell if I have Intel VT or AMD-V?
With a recent enough Linux kernel, run the command:
. egrep '^flags.*(vmx|svm)' /proc/cpuinfo
If something shows up, you have VT. You can also check the processor model name (in `/proc/cpuinfo`) in the vendor's web site.
- You'll never see (vmx|svm) in /proc/cpuinfo if you're currently running in in a dom0 or domU.
The Xen hypervisor suppresses these flags in order to prevent hijacking.
- Some manufacturers disable VT in the machine's BIOS, in such a way that it cannot be re-enabled.
- `/proc/cpuinfo` only shows virtualization capabilities starting with Linux 2.6.15 (Intel) and Linux 2.6.16 (AMD). Use the `uname -r` command to query your kernel version.
In case of doubt, contact your hardware vendor.
"KVM: disabled by BIOS" error
Check if there is an option to enable it in the BIOS. If not, look for a more recent BIOS on the vendor's web site.
- On some hardware (e-g HP nx6320), you need to power-off/power-on the machine after enabling virtualization in the BIOS.
- Enabling some BIOS features may break VT support on some hardware (e-g Enabling Intel AMT on a Thinkpad T500 will prevent kvm-intel from loading with "disabled by bios")
- On some Dell hardware, you also need to disable "Trusted Execution", otherwise VT will not be enabled.
How can I use AMD-V extension?
What user space tools does KVM use?
KVM uses a slightly modified QEMU program to instantiate the virtual machine. Once running, a virtual machine is just a regular process. You can use `top(1), kill(1), taskset(1)` and similar tools to manage virtual machines.
What virtual disk formats can KVM use?
KVM inherits a wealth of disk formats support from QEMU; it supports raw images, the native QEMU format (qcow2), VMware format, and many more.
Are there management tools available to help me manage my virtual machines?
Yes. Please see the Management Tools page for some links.
How can I use KVM with a non-privileged user?
The cleanest way is probably to create a group, say kvm, and add the user(s) to that group. Then you will need change /dev/kvm to owned by group kvm.
On a system that runs udev, you will probably need to add the following line somewhere in your udev configuration so it will automatically give the right group to the newly created device (i-e for ubuntu add a line to /etc/udev/rules.d/40-permissions.rules).
How can I get the most performance out of KVM?
See the Tuning KVM page.
Is KVM stable?
KVM is stable and used in production. As with most open source projects, development snapshots are less stable than the stable release series.
If your name is Andreas Mohr, you're reporting bugs in the wrong place.
That's alright, but can I really use it for my daily use?
Sure. We continuously run the most often-used OSes and configurations and if anything breaks for the developers, it's fixed as soon as it was broken. See the Guest Support Status and Host Support Status pages to find out more. Please update them with success stories so that new users would benefit from the experience of the community.
How about production use?
For production use, it's recommended you use the KVM modules shipped by the distribution you're using to ensure stability. As mentioned above, it's tempting to use new features, but you never know of (unwanted) surprises hidden away. It'll be best if you can run the development snapshots with non-critical production load, so that the latest releases are stable for you when you decide to deploy them.
What happens if I kill -9 a VM process?
From the guest's perspective, it is as if you yanked the power cord out. From the host's perspective, the process is killed and all resources it uses are reclaimed.
I need help to setup the network for my guest
You can have a look to the Networking page of this wiki for informations on the most classical networking setup for the guests. You can also refer to the QEMU documentation.
Where can I find more documention...
How can I check that I'm not falling back to QEMU with no hardware acceleration?
If you think that you might no be using the hardware acceleration provided by the KVM module, here are a few steps to help you check this.
First of all, check that you don't have messages such as:
qemu-system-x86_64 -hda myvm.qcow2 open /dev/kvm: No such file or directory Could not initialize KVM, will disable KVM support
In that case, you can check that:
- the modules are correctly loaded
- you don't have a "KVM: disabled by BIOS" line in the output of dmesg
- /dev/kvm exists and you have the correct rights to use it
Other ways to do the diagnostic:
- if you have access to the QEMU monitor (Ctrl-Alt-2, use Ctrl-Alt-1 to get back to the VM display), enter the "info kvm" command and it should respond with "KVM support: enabled"
- the right-end columns of the output from <code>lsmod|grep kvm on the host system, once the VM is started should show only non zero values. The value on the line corresponding to the architecture specific module (e-g kvm_intel, kvm_amd) show the number of VM using the module. For instance, if I have 2 VM running using the KVM module on a machine with vt, it will report:
lsmod|grep kvm kvm_intel 44896 2 kvm 159656 1 kvm_intel
"rect too big" Message when using VNC Display
When connection to a VNC Terminal, a "rect too big" message appears, and the VNC Session disconnects.
This happens because of a VNC protocol flaw on the way on-the-fly pixel format changes are handled (more info at this thread). If you are using TigerVNC, you can avoid this problem by disabling on-the-fly selection of pixel encoding, using the -AutoSelect=0 command-line option of vncviewer. You may also want to check the encoding options on the vncviewer man page, as this will disable automatic selection of encoding based on connection speed.
How do I set up the network such that my guest is accessible from other machines? or
My guest network is stuck what should I do?
KVM uses QEMU for its device emulation. Consult the QEMU network wiki page for detailed network setup instructions.
One would probably be interested in the Root Networking Mode page and the Network Bridge page.
Guest-side network lockups (fortunately restartable) may be happening due to tun/tap bridging erroneous MAC address reconfiguration on host side, see RHEL bug #571991 and others.
I'm experiencing timer drift issues in my VM guests, what to do?
Especially in case of networked systems (e.g. via NFS or Samba) it is very important to ensure stable operation of timing (both system timer and RTC). Tell-tale signs of related trouble in VMs (apparently qemu/KVM/VMWare etc. are all affected) are e.g. "make: Warning: File `XXXXX/cmakelists_rebuilder.stamp' has modification time 0.37 s in the future" "Clock skew detected. Your build may be incomplete."
Maemo docs state that it's important to disable UTC and set the correct time zone, however I don't really see how that would help in case of diverging host/guest clocks. IMHO much more useful and important is to configure properly working NTP server (chrony recommended, or ntpd) on both host and guest. The single most decisive trick IMHO is to specify the host NTP server as the main entry within guest VM instead of "foreign" NTP servers, to make sure to achieve the most precise coupling between these two related systems (timing drift vs. other systems does not matter nearly as much as a tight time precision for inner host/guest system interaction e.g. in the case of NFS/Samba shares etc.). For verification, see chronyc "sources -v", "tracking" ("System time" row) commands.
After having applied this very tight NTP coupling, this seems to finally have gotten rid of make's time drift warnings.
Perhaps qemu's -tdf (timing drift fix) option magically manages to help in your case, too.
I get "rtc interrupts lost" messages, and the guest is very slow?
CONFIG_HPET_EMULATE_RTC=y in your host
I get an "Exception 13" or "Exception 12" message while booting a guest OS on my Intel host
See the Intel Real Mode Emulation Problems page.
I have VMware/Parallels/VirtualBox installed and when I modprobe KVM, my system deadlocks.
Neither Intel VT nor AMD-V provide a mechanism to determine whether software is currently using the hardware virtualization extensions. This means that if you have two kernel modules loaded attempting to use hardware virtualization extensions, very bad things will happen. If you are using another type of virtualization software and experience any sort of weirdness with KVM, make sure you can reproduce the problem without the kernel modules for that software loaded before you report a bug in KVM.
There's nothing on QEMU/KVM screen, but it's not hanged! I'm trying to install Kubuntu.
Try to run kvm with -std-vga option. It helps if guest operating system uses framebuffer mode like Kubuntu/Ubuntu.
When I click the guest operating system window, mouse is grabbed. How can I get mouse to not to do that? OR Mouse doesn't show up / doesn't work in the guest. What do I do?
From #qemu wiki, try to run kvm/qemu with
-usb -usbdevice tablet
If that doesn't work, try this:
$ export SDL_VIDEO_X11_DGAMOUSE=0
General KVM information
What is the difference between KVM and Xen?
Xen is an external hypervisor; it assumes control of the machine and divides resources among guests. On the other hand, KVM is part of Linux and uses the regular Linux scheduler and memory management. This means that KVM is much smaller and simpler to use; it is also more featureful; for example KVM can swap guests to disk in order to free RAM.
KVM only run on processors that supports x86 hvm (vt/svm instructions set) whereas Xen also allows running modified operating systems on non-hvm x86 processors using a technique called paravirtualization. KVM does not support paravirtualization for CPU but may support paravirtualization for device drivers to improve I/O performance.
What is the difference between KVM and VMware?
VMware is a proprietary product. KVM is Free Software released under the GPL.
What is the difference between KVM and QEMU?
QEMU uses emulation; KVM uses processor extensions (HVM) for virtualization.
Do you have a port of KVM for Windows?
Kazushi Takahashi has been working on an experimental version though, called WinKVM, available here.
What kernel version does it work with?
It depends on what version of KVM you are using. The last release of KVM should work with any recent kernel (2.6.17 and above), older releases even older kernels.
How much RAM do I need?
You will need enough memory to let the guest run comfortably while keeping enough for the host. 1GB is probably a minimum configuration for the host OS.
Is dynamic memory management for guests supported?
This is a broad topic covering a few areas.
A. KVM only allocates memory as the guest tries to use it. Once it's allocated, KVM keeps it. Some guests (namely Microsoft guests) zero all memory at boot time. So they will use all memory.
B. Certain guests (only Linux at the moment) have a balloon driver, so the host can have the guest allocate a certain amount of memory which the guest won't be able to use anymore and it can then be freed on the host. Ballooning is controlled in the host via the balloon monitor command.
C. Some hosts (presently only RHEL5.4 / CentOS 5.4) have a feature called KSM (Kernel Sharedpage Merging), which collapses together identical pages; this requires kernel support on the host, as well as a kvm new enough to opt in to the behavior. As some guest platforms (most notably Windows) zero out free'd memory, such pages are trivially collapsed. The ksmctl command needs to be used to enable KSM; alternately, the ksmtuned service found in Fedora 12 can be run to dynamically adjust KSM's aggressiveness based on the amount of free memory available
What OSs can I run inside KVM VM?
Several. See the Guest Support Status page for details. Note that several Linux flavors are known to hang on Intel processors during startup. Workaround is to disable splash screens in grub.
Does KVM support a live migration feature to move virtual machines from one host to another without downtime?
Yes. See the Migration page for details.
Does KVM support live migration from an AMD host to an Intel host and back?
Yes. There may be issues on 32-bit Intel hosts which don't support NX (or XD), but for 64-bit hosts back and forth migration should work well. Migration of 32-bit guests should work between 32-bit hosts and 64-bit hosts. If one of your hosts does not support NX, you may consider disabling NX when starting the guest on a NX-capable system. You can do it by passing "-cpu qemu64,-nx" parameter to the guest.
Can KVM run a 32-bit guest on a 64-bit host? What about PAE?
KVM supports 32-bit guests on 64-bit hosts, and any combination of PAE and non-PAE guests and hosts. The only unsupported combination is a 64-bit guest on a 32-bit host.
If you are running a Windows Virtual Machine and have problems enabling PAE in your guest see the Windows PAE Workaround page.
Is it possible to use USB devices with a guest OS?
Yes, look up how to do it with QEMU, it's the same way.
Can I have higher or widescreen resolutions (eg 1680 x 1050) in KVM?
Use the -vga std parameter while starting the VM to allow high resolution and widescreen displays.
If the resolution you want to use is not available, you can patch the corresponding source files (see http://article.gmane.org/gmane.comp.emulators.kvm.devel/13557 as a reference), or send a mail to the KVM mailing list if you are not able to patch the source yourself.
When using Windows as guest OS and not having issues with people violating the GPL you might want to use the driver from the VBEMP x86 project (http://www.bearwindows.boot-land.net/vbemp.htm) which is based on ReactOS code.
Does KVM support SMP hosts?
Does KVM support SMP guests?
Yes. Up to 16 CPUs can be specified using the -smp option.
Is the name 'KVM' trademarked?