Virtualization on CentOS
1. An overview
Currently, there are two major virtualization technologies available through the CentOS repositories, namely Xen and KVM (the older 'qemu' emulation technology is not considered here). This page provides a basic introduction to these technologies, as well as some additional concepts. To understand these virtualization technologies, you have to be aware that there are some different approaches to virtualization. For the discussion of KVM and Xen, two approaches are relevant:
Full-virtualization: hardware is emulated to the extent that unmodified guest operating systems can run on the virtualization platform. Normally, this means that various hardware devices are emulated. Normally, such virtualization platform attempts to run as many instructions on the native CPU (which is a lot faster than CPU emulation), catching and handling privileged instructions appropriately. Some virtualization platforms support or require CPU extensions to assist virtualization. On some new x86 and x86_64 CPUs these are provided through the VT-X (Intel) and AMD-V (AMD) extensions. This is usually called hardware-assisted virtualization.
Paravirtualization: in paravirtualization the guest operating system is ported to the hypervisor, a layer sitting between the hardware and virtualized systems. Because this normally doesn't require full device emulation or dynamic recompiling to catch privileged instructions, paravirtualization often performs at a near-native speed.
In most situations paravirtualization is preferable over full-virtualization, because it is faster.
2. Who does what?
- Xen supports paravirtualization and hardware-assisted full-virtualization. Both paravirtualized virtual machines (PVMs) and hardware-assisted fully virtualized machines (HVMs) can run at the same time. Xen requires a hypervisor that booted before any Linux kernel. The hypervisor then boots a CentOS that is named the administrative or privileged domain, meaning that it is used to launch additional virtual machines and has defacto access to many real hardware devices. This administrative is usually called dom0. Additional unprivileged domains can be started via dom0. These unprivileged domains are usually called domUs. Both dom0 and paravirtualized domUs have to run the CentOS Xen kernel, rather than the default kernel.
KVM currently only supports hardware-assisted full-virtualization (although paravirtualization support is being worked on). KVM is a kernel module, and works with the default (non-Xen) kernel. Virtual machines are created through the /dev/kvm device by the qemu-kvm command, which is a version of qemu that is modified for KVM.
3. CentOS support
3.1. CentOS 4
Since CentOS 4.5, CentOS 4 can be used as a domU system through the kernel-xen kernel.
3.2. CentOS 5
- CentOS 5 includes the Xen hypervisor, and can be used as a dom0 and domU system. CentOS 5 also includes
comfortable management tools like virt-install and virt-manager.
- Packages for KVM are included in the distribution as of CentOS 5.4 (x86_64 only).
For detailed information, please see the Virtualization manual (html and pdf). There is a KVM howto as well.