qemu の概要

qemu は Linux 上における仮想化ソリューションを提供します。 仮想化拡張 (Intel VT または AMD-V) を持つ x86 ハードウェア上にて動作します。

本パッケージは LFS-8.0 において正しくビルドでき動作することが確認されています。


  • ダウンロード (HTTP): http://download.qemu-project.org/qemu-2.9.0.tar.bz2

  • ダウンロード MD5 sum: 02781eb15b364aedef79da7a5113f5b7

  • ダウンロードサイズ: 27 MB

  • 必要ディスク容量: 404 MB (add 420 MB for tests)

  • 概算ビルド時間: 2.1 SBU (add 1.9 SBU for tests)

Qemu の依存パッケージ


GLib-2.52.3, Python-2.7.13, X ウィンドウシステム



Depending on the sound system, various packages in ALSA-1.1.4, BlueZ-5.46, Check-0.11.0, cURL-7.55.1, Cyrus SASL-2.1.26, GnuTLS-3.5.14, GTK+-2.24.31, GTK+-3.22.18, libusb-1.0.21, libgcrypt-1.8.0, LZO-2.10, Nettle-3.3, Mesa-17.1.6, SDL-1.2.15, VTE-0.48.3 or Vte-0.28.2, libcacard, libssh2



This optional dependencies list is not comprehensive. See the output of ./configure --help for a more complete list.

ユーザー情報: http://wiki.linuxfromscratch.org/blfs/wiki/qemu

KVM の利用前提

qemu をビルドするにあたっては、まずあなたのプロセッサーが仮想化技術 (Virtualization Technology; VT) をサポートしているかを確認してください。

egrep '^flags.*(vmx|svm)' /proc/cpuinfo

何かの出力が得られたら VT に対応しているということです。 (Intel プロセッサーなら vmx、AMD プロセッサーなら svm など。) 次には BIOS 設定を確認して、この機能が有効になっていることを確認してください。 有効化にした後は、再起動を行って、再度 LFS 環境を立ち上げてください。


カーネル設定における以下のオプションを有効にしてください。 もし有効でなければカーネルを再コンパイルしてください。

[*] 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]

Intel と AMD の設定を両方行う必要はありません。 自身のプロセッサーに合致するものを1つ選んでください。

bridge」ネットワークデバイスを利用する場合は bridge-utils-1.6 がインストールされていることを確認してください。 またカーネルオプションとして以下が有効であることを確認してください。

[*] 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]

qemu のインストール

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>

以下のコマンドを実行して qemu をビルドします。



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

mkdir -vp build &&
cd        build &&

../configure --prefix=/usr               \
             --sysconfdir=/etc           \
             --target-list=$QEMU_ARCH    \
             --audio-drv-list=alsa       \
             --with-sdlabi=2.0           \
             --docdir=/usr/share/doc/qemu-2.9.0 &&

unset QEMU_ARCH &&


ビルド結果をテストする場合は make V=1 check を実行します。

root ユーザーになって以下を実行します。

make install

You will also need to add an 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"

Change the permissions and ownership of a helper script, which is needed when using the 「bridge」 network device (see below):

chgrp kvm  /usr/libexec/qemu-bridge-helper &&
chmod 4750 /usr/libexec/qemu-bridge-helper


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


--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.

--with-sdlabi=2.0: Chooses to build with SDL-2 if both SDL and SDL-2 are installed.

--with-gtkabi=3.0: builds with GTK+-3 if both GTK+-2 and GTK+-3 are installed.

Using Qemu

Since using qemu means using a virtual computer, the steps to set up the virtual machine are in close analogy with those to set up a real computer. You'll need to decide about CPU, memory, disk, USB devices, network card(s), screen size, etc. Once the 「hardware」 is decided, you'll have for example to choose how to connect the machine to internet, and/or to install an OS. In the following, we show basic ways of performing those steps. But qemu is much more than this, and it is strongly advised to read the qemu documentation in /usr/share/doc/qemu-2.9.0/qemu-doc.html.



It is standard practice to name the computer running qemu 「host」 and the emulated machine running under qemu the 「guest」. We'll use those notations in the following.



The following instructions assume the optional symbolic link, qemu, has been created. Additionally, qemu must be run from an X Window System based terminal (either locally or over ssh).


A virtual disk may be set up in the following way:

qemu-img create -f qcow2 $VDISK_FILENAME $VDISK_SIZE

The virtual disk size and filename should be ajusted as desired. The actual size of the file will be less than specified, but will expand as needed, so it is safe to put a high value.

Operating System

To install an operating system, download an iso image from your preferred Linux distribution. For the purposes of this example, we'll use Fedora-16-x86_64-Live-LXDE.iso in the current directory. Run the following:

qemu -enable-kvm                           \
     -drive file=$VDISK_FILENAME           \
     -cdrom Fedora-16-x86_64-Live-LXDE.iso \
     -boot d                               \
     -m 1G

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. The choice depends on the load of the host. Modern distributions should be comfortable with 1GB. The -enable-kvm option allows hardware acceleration. Without this switch, the emulation is much slower.

Defining the virtual hardware

The virtual machine hardware is defined by the qemu command line. An example command is given below:

qemu -enable-kvm                     \
     -smp 4                          \
     -cpu host                       \
     -m 1G                           \
     -drive file=$VDISK_FILENAME     \
     -cdrom grub-img.iso             \
     -boot order=c,once=d,menu=on    \
     -net nic,netdev=net0            \
     -netdev user,id=net0            \
     -soundhw ac97                   \
     -vga std                        \
     -serial mon:stdio               \
     -name "fedora-16"

Meaning of the command line options

-enable-kvm: enable full KVM virtualization support. On some hardware, it may be necessary to add the undocumented -machine smm=off option in order to enable KVM.

-smp <N>: enable symmetric multiprocessing with <N> CPUs.

-cpu <model>: simulate CPU <model>. the list of supported models can be obtained with -cpu help.

-drive file=<filename>: defines a virtual disk whose image is stored in <filename>.

-cdrom grub-img.iso: defines an iso formated file to use as a cdrom. Here we use a grub rescue disk, which may turn handy when something goes wrong at boot time.

-boot order=c,once=d,menu=on: defines the boot order for the virtual BIOS.

-net nic,netdev=<netid>: defines a network card connected to the network device with id <netid>.

-netdev user,id=<netid>: defines the network 「user」 device. This is a virtual local network with addresses, where the host has address and acts as a gateway to internet, and with a name server at address, and an smb server at address A builtin DHCP server can allocate addresses between and

-soundhw <model>: defines the soundcard model. The list may be obtained with -soundhw help.

-vga <type>: defines the type of vga card to emulate.

-serial mon:stdio: sends the serial port of the guest (/dev/ttyS0 on linux guests), multiplexed with the qemu monitor, to the standard input and output of the qemu process.

-name <name>: sets the name of the guest. This name is displayed in the guest window caption. It may be useful if you run several guests at the same time.

Controlling the Emulated Display

It may happen that the guest window displayed by qemu does not correspond to the full capability of the emulated vga card. For example, the vmware card is 1600x900 capable, but only 1024x768 is displayed by default. A suitable Xorg configuration on the guest allows to use the full size (Note that the Xorg video driver to use is Xorg VMware Driver-13.2.1):

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

Section         "Device"
  Identifier    "VMware SVGA II Adapter"
  Option        "Monitor" "default"
  Driver        "vmware"

Section         "Screen"
  Identifier    "Default Screen"
  Device        "VMware SVGA II Adapter"
  Monitor       "Monitor0"

  SubSection    "Display"
    Depth       24
    Modes       "1600x900" "1440x900" "1366x768" "1280x720" "800x480"


New sizes will be available besides the native ones. You need to restart X in order to have the new sizes available.


The above solution for networking allows the guest to access the local network through the host (and possibly to access internet through the local routers), but the converse is not true. Not even the host can access the guest, unless port forwarding is enabled. And in the case several guests are running, they cannot communicate with each other. Other network devices can be used for this purpose. For example, there is the 「socket」 device, which allows several guests to share a common virtual network. In the following, we describe in more details how to set up the 「bridge」 device, which allows the guests to appear as if connected to the local network. All the commands below should be run as the root user.

Allow the host to forward IP packets:

sysctl -w net.ipv4.ip_forward=1

To make this permanent, add the command to /etc/sysctl.d/60-net-forward.conf:

cat >> /etc/sysctl.d/60-net-forward.conf << EOF

Set up a required configuration file:

install -vdm 755 /etc/qemu &&
echo allow br0 > /etc/qemu/bridge.conf

In the command above, replace the switch -netdev user,... with -netdev bridge,id=net0.


インストールプログラム: ivshmem-client, ivshmem-server, qemu (シンボリックリンク), qemu-ga, qemu-img, qemu-io, qemu-nbd, qemu-system-<arch>, virtfs-proxy-helper
インストールライブラリ: なし
インストールディレクトリ: /usr/share/qemu, /usr/share/doc/qemu-2.9.0



is a standalone client for using the ivshmem device.


is an example server for the ivshmem device.


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 development.


exports Qemu disk images using the QEMU Disk Network Block Device (NBD) protocol.


PC システムエミュレーターである QEMU です。


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.

最終更新日: 2017-05-14 15:08:05 +0900