QEMU

QEMU (Quick EMUlator) is a generic and open source machine emulator and virtualizer. Often it is used in conjunction with acceleration in the form of a Type-I hypervisor such as KVM (Kernel-based Virtual Machine) or Xen. If no accelerator is used, QEMU will run entirely in user-space using its built in binary translator TCG (Tiny Code Generator). Using QEMU without an accelerator is relatively inefficient and slow.

BIOS
In order to utilize KVM either Vt-x or AMD-V must be supported by the processor. Vt-x or AMD-V are Intel and AMD's respective technologies for permitting multiple operating systems to concurrently execute operations on the processors.

To inspect hardware for visualization support issue the following command:

For a period manufacturers were shipping with virtualization turned off by default in the system BIOS. Note that changing this feature in the BIOS may actually require full removal of power from the system to take effect. If restarting the system does not work try shutting down, unplugging the system and pressing the power button in an unplugged state to discharge any residual energy from the power supply unit (PSU). Reapply power to the system to verify success.

If KVM support is available there should be a "kvm" device listed at

Kernel
Activate the following kernel options:

For Intel processors enable the appropriate Intel option. Search for.

For AMD processors enable to appropriate AMD option. Search for.

Needed for  USE flag (recommend):

Needed for 802.1d Ethernet Bridging:

USE flag is needed for file capabilities support:

When using the ext4 filesystem, enable the  USE flag if stats support is needed:

Software
Review the possible USE flags for QEMU:

Misc USE flags
After reviewing and adding desired USE flags, emerge :

Permissions
In order to run a KVM accelerated virtual machine without logging as root, add normal users to the kvm group. Replace in the example command below with the appropriate user(s).

Front ends
To make life easier, there are multiple user-friendly front ends to QEMU:

Usage

 * See QEMU options page for common options
 * Setup a Linux guest
 * Setup a Windows guest
 * Setup a OS2WarpV3 guest

"kvm: already loaded the other module"
Sometimes during the early boot splash the error message "kvm: already loaded the other module" can be seen. This message indicates both the Intel and the AMD kernel virtual machine settings have been enabled in the kernel. To fix this, disable either the Intel or AMD KVM option specific to the system's processor in the kernel configuration. Example: if the system has an Intel processor use only the Intel KVM. The relevant options can be found in the kernel's file via   and   variables.

External resources

 * The Gentoo article on the KVM wiki


 * The Official QEMU wiki