Before building qemu, check to see
if your processor supports Virtualization Technology (VT):
egrep '^flags.*(vmx|svm)' /proc/cpuinfo
If you get any output, you have VT technology (vmx for Intel
processors and svm for AMD processors). You then need to go into
your system BIOS and ensure it is enabled. After enabing, reboot
back to your LFS instance.
Enable the following options in the kernel configuration and
recompile the kernel if necessary:
[*] Virtualization: ---> [CONFIG_VIRTUALIZATION]
<*/M> Kernel-based Virtual Machine (KVM) support [CONFIG_KVM]
<*/M> KVM for Intel processors support [CONFIG_KVM_INTEL]
<*/M> KVM for AMD processors support [CONFIG_KVM_AMD]
The Intel or AMD settings are not both required, but the one
matching your system processor is required.
For networking, check that bridge-utils-1.5 is installed and the
following options in the kernel configuration are enabled:
[*] Networking support ---> [CONFIG_NET]
Networking options --->
<*/M> 802.1d Ethernet Bridging [CONFIG_BRIDGE]
Device Drivers --->
[*] Network device support ---> [CONFIG_NETDEVICES]
<*/M> Universal TUN/TAP device driver support [CONFIG_TUN]
Installation of qemu
Install qemu by running the
sed -i '/resource/ i#include <sys/xattr.h>' fsdev/virtfs-proxy-helper.c &&
./configure --prefix=/usr \
To run the built in tests, run make
Now, as the
make install &&
[ -e /usr/lib/libcacard.so ] && chmod -v 755 /usr/lib/libcacard.so
You will need a dedicated group that will contain users (other than
root) allowed to access the KVM device. Create this group by
running the following command as the
groupadd -g 61 kvm
Add any users that might use the KVM device to that group:
usermod -a -G kvm
You will also need to add a Udev rule so that the KVM device gets
cat > /lib/udev/rules.d/65-kvm.rules << "EOF"
KERNEL=="kvm", GROUP="kvm", MODE="0660"
For convenience you may want to create a symbolic link to run
ln -sv qemu-system-x86_64 /usr/bin/qemu
virtfs-proxy-helper.c: Fix a build problem due to
changes in some versions of the glibc include file sys/xattr.h.
switch limits the build target to the x86_64 architecture. For
other hardware emulation see the --target-list list in configure's help output. Omitting
this option will build all architectures.
--audio-drv-list=alsa: This switch sets
the audio driver to ALSA. For other drivers see the
--audio-drv-list list in configure's help output. The
default audio driver is OSS.
To generate an image, run:
qemu-img create -f qcow2 vdisk.img 10G
Adjust the virtual disk size and image filename as desired. The
actual size of the file will be less than specified, but will
expand as it is used.
The following instructions assume you have created the optional
qemu. Additionally, you must
qemu from an
X Window System based terminal.
To install an operating system, download an iso of your choice or
use a pre-installed cdrom device. For the purposes of this example,
use Fedora 16 that is downloaded as
Fedora-16-x86_64-Live-LXDE.iso in the current
directory. Run the following:
qemu -enable-kvm -hda vdisk.img \
-cdrom Fedora-16-x86_64-Live-LXDE.iso \
-boot d \
Follow the normal installation procedures for the chosen
distribution. The -boot option specifies the boot order of drives
as a string of drive letters. Valid drive letters are: a, b (floppy
1 and 2), c (first hard disk), d (first CD-ROM). The -m option is
the amount of memory to use for the virtual machine. If you have
sufficient memory (2G or more), 1G is a reasonable value. For
computers with 512MB of RAM it's safe to use -m 192, or even -m 128
(the default). The -enable-kvm option allows for hardware
acceleeration. Without this switch, the emulation is relatively
To run the newly installed operating system, run:
qemu -enable-kvm vdisk.img -m 384
To add networking to the instance add "-net nic -net user" to the
command above. qemu provides a DHCP server for the VM and,
depending on the client system, sets up networking though the host.
One problem with the above networking solution is that it does not
provide the ability to connect with the local network. To do that,
there are several additional steps that need to be done, all as the
Set up bridging with bridge-utils-1.5.
Allow the host system to forward IP packets.
sysctl -w net.ipv4.ip_forward=1
To make this permanent, add the command to
cat >> /etc/sysctl.conf << EOF
Allow the network connection when running as a part of the
chgrp kvm /usr/libexec/qemu-bridge-helper &&
chmod 4750 /usr/libexec/qemu-bridge-helper
Set up a required configuration file:
echo 'allow br0' > /etc/qemu/bridge.conf
Start qemu with "-net nic -net bridge" options.
If a connection, such as ssh, from the local network to the
client VM is desired, the client should be configured with a
static IP address.
qemu-ga, qemu-img, qemu-io, qemu-nbd,
qemu-system-x86_64, virtfs-proxy-helper, and vscclient
/usr/lib/qemu, /usr/share/qemu, and
implements support for QMP (QEMU Monitor Protocol)
commands and events that terminate and originate
respectively within the guest using an agent built as
part of QEMU.
provides commands to manage QEMU disk images.
is a diagnostic and manipulation program for (virtual)
memory media. It is still at an early stage of
exports Qemu disk images using the QEMU Disk Network
Block Device (NBD) protocol.
is the QEMU PC System emulator.
is the Virtual Smart Card Emulator library.
Last updated on 2015-02-26 20:16:43 -0800