qemu-2.5.0
Introduction to qemu
qemu is a full virtualization
solution for Linux on x86 hardware containing virtualization
extensions (Intel VT or AMD-V).
This package is known to build and work properly using an LFS-7.9
platform.
Package Information
Qemu Dependencies
Required
GLib-2.46.2, Python-2.7.11,
and X Window
System
Recommended
SDL-1.2.15
Optional
ALSA-1.1.0, BlueZ-5.37,
Check-0.10.0, cURL-7.47.1,
Cyrus SASL-2.1.26, GnuTLS-3.4.9, GTK+-2.24.29,
GTK+-3.18.7, libusb-1.0.20,
libgcrypt-1.6.5, LZO-2.09, Nettle-3.2,
NSS-3.23 (for
libcacard.so), Mesa-11.1.2, SDL-1.2.15,
VTE-0.42.4, libssh2
Note
This optional dependencies list is not comprehensive. See the
output of ./configure
--help for a more complete list.
User Notes: http://wiki.linuxfromscratch.org/blfs/wiki/qemu
KVM Prerequisites
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.
Kernel Configuration
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
following commands:
Note
Qemu is capable of running many targets. The build process is
also capable of building multiple targets at one time in a comma
delimited list assigned to --target-list
. Run ./configure --help to get a
complete list of available targets.
if [ $(uname -m) = i686 ]; then
QEMU_ARCH=i386-softmmu
else
QEMU_ARCH=x86_64-softmmu
fi
mkdir -vp build &&
cd build &&
../configure --prefix=/usr \
--sysconfdir=/etc \
--target-list=$QEMU_ARCH \
--audio-drv-list=alsa \
--docdir=/usr/share/doc/qemu-2.5.0 &&
unset QEMU_ARCH &&
make
To run the built in tests, run make
V=1 -k check. One test is known to fail.
Now, as the root
user:
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 root
user:
groupadd -g 61 kvm
Add any users that might use the KVM device to that group:
usermod -a -G kvm <username>
You will also need to add a Udev rule so that the KVM device gets
correct permissions:
cat > /lib/udev/rules.d/65-kvm.rules << "EOF"
KERNEL=="kvm", GROUP="kvm", MODE="0660"
EOF
Note
For convenience you may want to create a symbolic link to run the
installed program. For instance:
ln -sv qemu-system-`uname -m` /usr/bin/qemu
Command Explanations
--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.
Configuring qemu
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.
Note
The following instructions assume you have created the optional
symbolic link, qemu
. Additionally, you must
run qemu
from an
X Window System based terminal (either locally or over ssh).
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 \
-m 384
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
acceleration. Without this switch, the emulation is relatively
slow.
To run the newly installed operating system, run:
qemu -enable-kvm vdisk.img -m 384
You may have problem with -enable-kvm
. Also, you may want to
define audio and video drivers, number of cpu cores and threads. An
alternative command to install the operating system is (see qemu
man page for the parameters definitions):
qemu -enable-kvm \
-cdrom /home/fernando/ISO/linuxmint-17.1-mate-32bit.iso \
-boot order=d \
-m 1G,slots=3,maxmem=4G \
-machine smm=off \
-soundhw es1370 \
-cpu host \
-smp cores=4,threads=2 \
-vga std \
vdisk.img
One parameter not appearing in the qemu man page is -machine smm=off
, and is used to
allow -enable-kvm
in some
systems. In order to run the machine, you can alternatively issue:
qemu -enable-kvm \
-machine smm=off \
-boot order=d \
-m 1G,slots=3,maxmem=4G \
-soundhw es1370 \
-cpu host \
-smp cores=4,threads=2 \
-vga vmware \
-hda vdisk.img
Sometimes, you want the machine to have different screen sizes than
the ones natively offered by the virtual grahics card. The example
below is for qemu vmware graphics card, which uses Xorg VMMouse Driver-13.1.0 and is
set to give maximum screen size of 1600x900. As the root
user, issue:
cat > /usr/share/X11/xorg.conf.d/20-vmware.conf << "EOF"
Section "Monitor"
Identifier "Monitor0"
# cvt 1600 900
# 1600x900 59.95 Hz (CVT 1.44M9) hsync: 55.99 kHz; pclk: 118.25 MHz
Modeline "1600x900" 118.25 1600 1696 1856 2112 900 903 908 934 -hsync +vsync
Option "PreferredMode" "1600x900"
HorizSync 1-200
VertRefresh 1-200
EndSection
Section "Device"
Identifier "VMware SVGA II Adapter"
Option "Monitor" "default"
Driver "vmware"
EndSection
Section "Screen"
Identifier "Default Screen"
Device "VMware SVGA II Adapter"
Monitor "Monitor0"
SubSection "Display"
Depth 24
Modes "1600x900" "1440x900" "1366x768" "1280x720" "800x480"
EndSubSection
EndSection
EOF
New sizes will be available besides the native ones. You need to
restart X in order to have the new sizes available.
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
root
user:
-
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 /etc/sysctl.conf:
cat >> /etc/sysctl.conf << EOF
net.ipv4.ip_forward=1
EOF
-
Allow the network connection when running as a part of the
kvm group:
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.
Contents
Installed Programs:
ivshmem-client, ivshmem-server, qemu
(symlink), qemu-ga, qemu-img, qemu-io, qemu-nbd,
qemu-system-<arch>, virtfs-proxy-helper, and
vscclient
Installed Library:
libcacard.so
Installed Directories:
/etc/qemu and
/usr/share/doc/qemu-2.5.0
Short Description
qemu-ga
|
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.
|
qemu-img
|
provides commands to manage QEMU disk images.
|
qemu-io
|
is a diagnostic and manipulation program for (virtual)
memory media. It is still at an early stage of
development.
|
qemu-nbd
|
exports Qemu disk images using the QEMU Disk Network
Block Device (NBD) protocol.
|
qemu-system-x86_64
|
is the QEMU PC System emulator.
|
virtfs-proxy-helper
|
creates a socket pair or a named socket. QEMU and proxy
helper communicate using this socket. QEMU proxy fs
driver sends filesystem request to proxy helper and
receives the response from it.
|
vscclient
|
implements a sockets interface to the virtual CCID reader
on the guest.
|
libcacard.so
|
is the Virtual Smart Card Emulator library.
|
Last updated on 2016-03-02 18:22:08 -0800