[d28198d3] | 1 | <?xml version="1.0" encoding="ISO-8859-1"?>
|
---|
| 2 | <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
---|
| 3 | "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
---|
| 4 | <!ENTITY % general-entities SYSTEM "../../general.ent">
|
---|
| 5 | %general-entities;
|
---|
| 6 |
|
---|
[2f6053d] | 7 | <!ENTITY qemu-download-http "http://wiki.qemu.org/download/qemu-&qemu-version;.tar.bz2">
|
---|
| 8 | <!ENTITY qemu-download-ftp " ">
|
---|
| 9 | <!ENTITY qemu-md5sum "78f13b774814b6b7ebcaf4f9b9204318">
|
---|
| 10 | <!ENTITY qemu-size "10 MB">
|
---|
| 11 | <!ENTITY qemu-buildsize "188 MB">
|
---|
| 12 | <!ENTITY qemu-time "1.5 SBU">
|
---|
[d28198d3] | 13 | ]>
|
---|
| 14 |
|
---|
[2f6053d] | 15 | <sect1 id="qemu" xreflabel="qemu-&qemu-version;">
|
---|
| 16 | <?dbhtml filename="qemu.html"?>
|
---|
[d28198d3] | 17 |
|
---|
| 18 | <sect1info>
|
---|
[c4a1934a] | 19 | <othername>$LastChangedBy$</othername>
|
---|
| 20 | <date>$Date$</date>
|
---|
[d28198d3] | 21 | </sect1info>
|
---|
| 22 |
|
---|
[2f6053d] | 23 | <title>qemu-&qemu-version;</title>
|
---|
[d28198d3] | 24 |
|
---|
[2f6053d] | 25 | <indexterm zone="qemu">
|
---|
| 26 | <primary sortas="a-qemu">qemu</primary>
|
---|
[d28198d3] | 27 | </indexterm>
|
---|
| 28 |
|
---|
| 29 | <sect2 role="package">
|
---|
[2f6053d] | 30 | <title>Introduction to qemu</title>
|
---|
[d28198d3] | 31 |
|
---|
[2f6053d] | 32 | <para><application>qemu</application> is a full virtualization solution
|
---|
[d28198d3] | 33 | for Linux on x86 hardware containing virtualization extensions (Intel VT or
|
---|
| 34 | AMD-V).</para>
|
---|
| 35 |
|
---|
[6a54383] | 36 | &lfs73_checked;
|
---|
[27643d0f] | 37 |
|
---|
[d28198d3] | 38 | <bridgehead renderas="sect3">Package Information</bridgehead>
|
---|
| 39 | <itemizedlist spacing="compact">
|
---|
| 40 | <listitem>
|
---|
[2f6053d] | 41 | <para>Download (HTTP): <ulink url="&qemu-download-http;"/></para>
|
---|
[d28198d3] | 42 | </listitem>
|
---|
| 43 | <listitem>
|
---|
[2f6053d] | 44 | <para>Download (FTP): <ulink url="&qemu-download-ftp;"/></para>
|
---|
[d28198d3] | 45 | </listitem>
|
---|
| 46 | <listitem>
|
---|
[2f6053d] | 47 | <para>Download MD5 sum: &qemu-md5sum;</para>
|
---|
[d28198d3] | 48 | </listitem>
|
---|
| 49 | <listitem>
|
---|
[2f6053d] | 50 | <para>Download size: &qemu-size;</para>
|
---|
[d28198d3] | 51 | </listitem>
|
---|
| 52 | <listitem>
|
---|
[2f6053d] | 53 | <para>Estimated disk space required: &qemu-buildsize;</para>
|
---|
[d28198d3] | 54 | </listitem>
|
---|
| 55 | <listitem>
|
---|
[2f6053d] | 56 | <para>Estimated build time: &qemu-time;</para>
|
---|
[d28198d3] | 57 | </listitem>
|
---|
| 58 | </itemizedlist>
|
---|
| 59 |
|
---|
[6a54383] | 60 | <bridgehead renderas="sect3">Additional Downloads</bridgehead>
|
---|
| 61 | <itemizedlist spacing='compact'>
|
---|
| 62 | <listitem>
|
---|
| 63 | <para>Required Patch: <ulink
|
---|
[2f6053d] | 64 | url="&patch-root;/qemu-&qemu-version;-fixes-1.patch"/></para>
|
---|
[6a54383] | 65 | </listitem>
|
---|
| 66 | </itemizedlist>
|
---|
| 67 |
|
---|
[2f6053d] | 68 | <bridgehead renderas="sect3">Qemu Dependencies</bridgehead>
|
---|
[d28198d3] | 69 |
|
---|
| 70 | <bridgehead renderas="sect4">Required</bridgehead>
|
---|
| 71 | <para role="required">
|
---|
[aa4778c4] | 72 | <xref linkend="glib2"/>,
|
---|
[4716d52] | 73 | <xref linkend="python2"/>,
|
---|
[d28198d3] | 74 | <xref linkend="sdl"/>, and
|
---|
| 75 | <xref linkend="x-window-system"/>
|
---|
| 76 | </para>
|
---|
| 77 |
|
---|
| 78 | <bridgehead renderas="sect4">Optional</bridgehead>
|
---|
| 79 | <para role="optional">
|
---|
| 80 | <xref linkend="alsa"/>,
|
---|
| 81 | <xref linkend="attr"/>,
|
---|
| 82 | <xref linkend="check"/>,
|
---|
| 83 | <xref linkend="curl"/>,
|
---|
| 84 | <xref linkend="esound"/>,
|
---|
| 85 | <xref linkend="mesalib"/>, and
|
---|
| 86 | <xref linkend="cyrus-sasl"/>.
|
---|
| 87 | Note that this optional dependencies list is not comprehensive. See the
|
---|
| 88 | output of <command>./configure --help</command> for a more complete list.
|
---|
| 89 | </para>
|
---|
| 90 |
|
---|
| 91 | <para condition="html" role="usernotes">User Notes:
|
---|
[2f6053d] | 92 | <ulink url="&blfs-wiki;/qemu"/></para>
|
---|
[d28198d3] | 93 |
|
---|
| 94 | </sect2>
|
---|
| 95 |
|
---|
[2f6053d] | 96 | <sect2 id='qemu-prereq'>
|
---|
[d28198d3] | 97 | <title>KVM Prerequsites</title>
|
---|
| 98 |
|
---|
[2f6053d] | 99 | <para>Before building <application>qemu</application>, check to see if
|
---|
[d28198d3] | 100 | your processor supports Virtualization Technology (VT):</para>
|
---|
| 101 |
|
---|
| 102 | <screen><userinput>egrep '^flags.*(vmx|svm)' /proc/cpuinfo</userinput></screen>
|
---|
| 103 |
|
---|
| 104 | <para>If you get any output, you have VT technology (vmx for Intel
|
---|
| 105 | processors and svm for AMD processors). You then need to go into your
|
---|
| 106 | system BIOS and ensure it is enabled. After enabing, reboot back to your
|
---|
| 107 | LFS instance.</para>
|
---|
| 108 |
|
---|
| 109 | </sect2>
|
---|
| 110 |
|
---|
[2f6053d] | 111 | <sect2 role="kernel" id='qemu-kernel'>
|
---|
[d28198d3] | 112 | <title>Kernel Configuration</title>
|
---|
| 113 |
|
---|
| 114 | <para>Enable the following options in the kernel configuration
|
---|
| 115 | and recompile the kernel if necessary:</para>
|
---|
| 116 |
|
---|
| 117 | <screen><literal>Virtualization: Y
|
---|
| 118 | Kernel-based Virtual Machine (KVM) support: M or Y
|
---|
| 119 | KVM for Intel processors support: M or Y
|
---|
| 120 | KVM for AMD processors support: M or Y</literal></screen>
|
---|
| 121 |
|
---|
[2f6053d] | 122 | <indexterm zone="qemu qemu-kernel">
|
---|
| 123 | <primary sortas="d-qemu">qemu</primary>
|
---|
[d28198d3] | 124 | </indexterm>
|
---|
| 125 |
|
---|
| 126 | <para>The Intel or AMD settings are not both required, but the one matching
|
---|
| 127 | your system processor is required.</para>
|
---|
| 128 |
|
---|
| 129 | <para>For networking, check that the settings CONFIG_BRIDGE, CONFIG_STP,
|
---|
| 130 | CONFIG_TUN are enabled and <xref linkend='bridgeutils'/> is
|
---|
| 131 | installed.</para>
|
---|
| 132 |
|
---|
| 133 | </sect2>
|
---|
| 134 |
|
---|
| 135 | <sect2 role="installation">
|
---|
[2f6053d] | 136 | <title>Installation of qemu</title>
|
---|
[0d7900a] | 137 |
|
---|
[d28198d3] | 138 | <para>If <application>xorg</application> is not installed in
|
---|
| 139 | <filename class='directory'>/usr</filename>, then the linker needs to
|
---|
| 140 | be told where it is. For example:</para>
|
---|
| 141 |
|
---|
| 142 | <screen><userinput>export LIBRARY_PATH=/opt/xorg/lib</userinput></screen>
|
---|
| 143 |
|
---|
[2f6053d] | 144 | <para>Install <application>qemu</application> by running the following
|
---|
[d28198d3] | 145 | commands:</para>
|
---|
| 146 |
|
---|
[2f6053d] | 147 | <screen><userinput>patch -Np1 -i ../qemu-&qemu-version;-fixes-1.patch
|
---|
| 148 | ./configure --prefix=/usr \
|
---|
| 149 | --sysconfdir=/etc \
|
---|
| 150 | --target-list=x86_64-softmmu &&
|
---|
| 151 | make</userinput></screen>
|
---|
[d28198d3] | 152 |
|
---|
[2f6053d] | 153 | <para>To run the built in tests, run <command>make V=1 check</command>.</para>
|
---|
[d28198d3] | 154 |
|
---|
| 155 | <para>Now, as the <systemitem class="username">root</systemitem> user:</para>
|
---|
| 156 |
|
---|
| 157 | <screen role="root"><userinput>make install</userinput></screen>
|
---|
[2f6053d] | 158 |
|
---|
| 159 | <note><!--<para>The main program <command>qemu-system-x86_64</command> doesn't
|
---|
[d28198d3] | 160 | make a distinction between i386 and x86_64 so even on an i386 system you
|
---|
| 161 | should use <emphasis>qemu-system-x86_64</emphasis></para>
|
---|
[2f6053d] | 162 | -->
|
---|
[0d7900a] | 163 |
|
---|
[d28198d3] | 164 | <para>For convenience you may want to create a symbolic link to run
|
---|
| 165 | <command>qemu-system-x86_64</command>:</para>
|
---|
| 166 |
|
---|
| 167 | <screen><userinput>ln -sv qemu-system-x86_64 /usr/bin/qemu</userinput></screen>
|
---|
| 168 | </note>
|
---|
| 169 |
|
---|
| 170 | </sect2>
|
---|
| 171 |
|
---|
[6a54383] | 172 | <sect2 role="commands">
|
---|
| 173 | <title>Command Explanations</title>
|
---|
| 174 |
|
---|
[2f6053d] | 175 | <para><parameter>--target-list=x86_64-softmmu</parameter>: This option
|
---|
| 176 | limits the build target to the x86_64 architecture. For other
|
---|
| 177 | hardware emulation see the --target-list list in <command>configure</command>'s
|
---|
| 178 | help output. Omitting this option will build all architectures.</para>
|
---|
[6a54383] | 179 |
|
---|
| 180 | </sect2>
|
---|
| 181 |
|
---|
| 182 |
|
---|
| 183 |
|
---|
[d28198d3] | 184 | <sect2 role="configuration">
|
---|
[2f6053d] | 185 | <title>Configuring qemu</title>
|
---|
[d28198d3] | 186 |
|
---|
| 187 | <para>To generate an image, run:</para>
|
---|
| 188 |
|
---|
| 189 | <screen><userinput>qemu-img create -f qcow2 vdisk.img 10G</userinput></screen>
|
---|
| 190 |
|
---|
| 191 | <para>Adjust the virtual disk size and image filename as desired. The
|
---|
| 192 | actual size of the file will be less than specified, but will expand as it
|
---|
| 193 | is used.</para>
|
---|
| 194 |
|
---|
| 195 | <note><para>The following instructions assume you have created the optional
|
---|
| 196 | symbolic link, <userinput>qemu</userinput>. Additionally, you must run
|
---|
[2f6053d] | 197 | <userinput>qemu</userinput> from an X-Windows based terminal.</para></note>
|
---|
[d28198d3] | 198 |
|
---|
| 199 | <para>To install an operating system, download an iso of your choice or use
|
---|
[ec64d28] | 200 | a pre-intalled cdrom device. For the purposes of this example, use
|
---|
[d28198d3] | 201 | Fedora 16 that is downloaded as
|
---|
| 202 | <filename>Fedora-16-x86_64-Live-LXDE.iso</filename> in the current
|
---|
| 203 | directory. Run the following:</para>
|
---|
| 204 |
|
---|
[2f6053d] | 205 | <screen><userinput>qemu -enable-kvm -hda vdisk.img \
|
---|
[0d7900a] | 206 | -cdrom Fedora-16-x86_64-Live-LXDE.iso \
|
---|
[d28198d3] | 207 | -boot d \
|
---|
| 208 | -m 384</userinput></screen>
|
---|
| 209 |
|
---|
| 210 | <para>Follow the normal installation procedures for the chosen
|
---|
[2f6053d] | 211 | distribution. The -boot option specifies the boot order of drives as a
|
---|
| 212 | string of drive letters. Valid drive letters are: a, b (floppy 1 and 2), c
|
---|
| 213 | (first hard disk), d (first CD-ROM). The -m option is the amount of memory
|
---|
| 214 | to use for the virtual machine. If you have sufficient memory (2G or
|
---|
| 215 | more), 1G is a reasonable value. For computers with 512MB of RAM it's safe
|
---|
| 216 | to use -m 192, or even -m 128 (the default). The -enable-kvm option allows
|
---|
| 217 | for hardware acceleeration. Without this switch, the emulation is
|
---|
| 218 | relatively slow.</para>
|
---|
[d28198d3] | 219 |
|
---|
| 220 | <para>To run the newly installed operating system, run:</para>
|
---|
| 221 |
|
---|
[2f6053d] | 222 | <screen><userinput>qemu -enable-kvm vdisk.img -m 384</userinput></screen>
|
---|
[d28198d3] | 223 |
|
---|
| 224 | <para>To add networking to the instance add "-net nic -net user" to the
|
---|
| 225 | command above. qemu provides a DHCP server for the VM and, depending on
|
---|
| 226 | the client system, sets up networking though the host.</para>
|
---|
| 227 |
|
---|
| 228 | <para>One problem with the above networking solution is that it does not
|
---|
[0d7900a] | 229 | provide the ability to connect with the local network. To do that, there are
|
---|
[d28198d3] | 230 | several additional steps that need to be done, all as the <systemitem
|
---|
| 231 | class="username">root</systemitem> user:</para>
|
---|
| 232 |
|
---|
| 233 | <itemizedlist spacing="compact">
|
---|
| 234 | <listitem>
|
---|
| 235 | <para>Set up bridging with <xref linkend='bridgeutils'/>.</para>
|
---|
| 236 | </listitem>
|
---|
| 237 |
|
---|
| 238 | <listitem>
|
---|
| 239 | <para>Allow the host system to forward IP packets.</para>
|
---|
| 240 |
|
---|
| 241 | <screen><userinput>sysctl -w net.ipv4.ip_forward=1</userinput></screen>
|
---|
[0d7900a] | 242 |
|
---|
| 243 | <para>To make this permanent, add the command to
|
---|
[d28198d3] | 244 | <filename>/etc/syssysctl.conf:</filename></para>
|
---|
| 245 |
|
---|
| 246 | <screen><userinput>cat >> /etc/sysctl.conf << EOF
|
---|
[0d7900a] | 247 | net.ipv4.ip_forward=1
|
---|
[d28198d3] | 248 | EOF</userinput></screen>
|
---|
| 249 |
|
---|
| 250 | </listitem>
|
---|
| 251 |
|
---|
| 252 | <listitem>
|
---|
[0d7900a] | 253 | <para>Create scripts for qemu to attach the client network
|
---|
[d28198d3] | 254 | device, usually visible as tap0, to the host bridge.</para>
|
---|
| 255 |
|
---|
| 256 | <screen><userinput>cat >> /etc/qemu-ifup << EOF
|
---|
| 257 | #!/bin/bash
|
---|
| 258 |
|
---|
| 259 | switch=br0
|
---|
| 260 |
|
---|
[71e6ae5] | 261 | if [ -n "\$1" ]; then
|
---|
[d28198d3] | 262 | # Add new tap0 interface to bridge
|
---|
[71e6ae5] | 263 | /sbin/ip link set \$1 up
|
---|
[d28198d3] | 264 | sleep 0.5s
|
---|
[71e6ae5] | 265 | /usr/sbin/brctl addif \$switch \$1
|
---|
[d28198d3] | 266 | else
|
---|
| 267 | echo "Error: no interface specified"
|
---|
| 268 | exit 1
|
---|
| 269 | fi
|
---|
| 270 |
|
---|
[0d7900a] | 271 | exit 0
|
---|
[71e6ae5] | 272 | EOF
|
---|
| 273 |
|
---|
| 274 | chmod +x /etc/qemu-ifup</userinput></screen>
|
---|
[d28198d3] | 275 |
|
---|
| 276 | <screen><userinput>cat >> /etc/qemu-ifdown << EOF
|
---|
| 277 | #!/bin/bash
|
---|
| 278 |
|
---|
| 279 | switch=br0
|
---|
| 280 |
|
---|
[71e6ae5] | 281 | if [ -n "\$1" ]; then
|
---|
[d28198d3] | 282 | # Remove tap0 interface from bridge
|
---|
[71e6ae5] | 283 | /usr/sbin/brctl delif \$switch \$1
|
---|
[d28198d3] | 284 | else
|
---|
| 285 | echo "Error: no interface specified"
|
---|
| 286 | exit 1
|
---|
| 287 | fi
|
---|
| 288 |
|
---|
[0d7900a] | 289 | exit 0
|
---|
[71e6ae5] | 290 | EOF
|
---|
| 291 |
|
---|
| 292 | chmod +x /etc/qemu-ifdown</userinput></screen>
|
---|
[d28198d3] | 293 |
|
---|
| 294 | </listitem>
|
---|
[71e6ae5] | 295 | </itemizedlist>
|
---|
| 296 |
|
---|
| 297 | <note><para>The backslashes in the abouve script are for convenience
|
---|
| 298 | for cut/paste operations. The backslashes should <emphasis>not</emphasis>
|
---|
| 299 | appear in the final scripts.</para></note>
|
---|
[d28198d3] | 300 |
|
---|
[71e6ae5] | 301 | <itemizedlist spacing="compact">
|
---|
[d28198d3] | 302 | <listitem>
|
---|
| 303 | <para>Start qemu with "-net nic -net tap" options. </para>
|
---|
| 304 | </listitem>
|
---|
| 305 |
|
---|
| 306 | <listitem>
|
---|
[0d7900a] | 307 | <para>If a connection, such as ssh, from the local network to the
|
---|
[d28198d3] | 308 | client VM is desired, the client should probably be configured
|
---|
| 309 | with a static IP address.</para>
|
---|
| 310 | </listitem>
|
---|
| 311 |
|
---|
| 312 | </itemizedlist>
|
---|
| 313 |
|
---|
| 314 | </sect2>
|
---|
| 315 |
|
---|
| 316 | <sect2 role="content">
|
---|
| 317 | <title>Contents</title>
|
---|
| 318 |
|
---|
| 319 | <segmentedlist>
|
---|
| 320 | <segtitle>Installed Program</segtitle>
|
---|
| 321 | <segtitle>Installed Libraries</segtitle>
|
---|
| 322 | <segtitle>Installed Directories</segtitle>
|
---|
| 323 |
|
---|
| 324 | <seglistitem>
|
---|
| 325 | <seg>qemu-ga, qemu-img, qemu-io, qemu-nbd, qemu-system-x86_64</seg>
|
---|
| 326 | <seg>None</seg>
|
---|
| 327 | <seg>/etc/qemu, /usr/share/qemu, /usr/share/doc/qemu</seg>
|
---|
| 328 | </seglistitem>
|
---|
| 329 | </segmentedlist>
|
---|
| 330 |
|
---|
| 331 | <variablelist>
|
---|
| 332 | <bridgehead renderas="sect3">Short Description</bridgehead>
|
---|
| 333 | <?dbfo list-presentation="list"?>
|
---|
| 334 | <?dbhtml list-presentation="table"?>
|
---|
| 335 |
|
---|
| 336 | <varlistentry id="qemu-ga">
|
---|
| 337 | <term><command>qemu-ga</command></term>
|
---|
| 338 | <listitem>
|
---|
| 339 | <para>implements support for QMP (QEMU Monitor Protocol) commands and
|
---|
| 340 | events that terminate and originate respectively within the guest
|
---|
| 341 | using an agent built as part of QEMU.</para>
|
---|
[2f6053d] | 342 | <indexterm zone="qemu qemu-ga">
|
---|
[d28198d3] | 343 | <primary sortas="b-qemu-ga">qemu-ga</primary>
|
---|
| 344 | </indexterm>
|
---|
| 345 | </listitem>
|
---|
| 346 | </varlistentry>
|
---|
| 347 |
|
---|
| 348 | <varlistentry id="qemu-img">
|
---|
| 349 | <term><command>qemu-img</command></term>
|
---|
| 350 | <listitem>
|
---|
| 351 | <para>provides commands to manage QEMU disk images.</para>
|
---|
[2f6053d] | 352 | <indexterm zone="qemu qemu-img">
|
---|
[d28198d3] | 353 | <primary sortas="b-qemu-img">qemu-img</primary>
|
---|
| 354 | </indexterm>
|
---|
| 355 | </listitem>
|
---|
| 356 | </varlistentry>
|
---|
| 357 |
|
---|
| 358 | <varlistentry id="qemu-io">
|
---|
| 359 | <term><command>qemu-io</command></term>
|
---|
| 360 | <listitem>
|
---|
| 361 | <para>is a diagnostic and manipulation program for (virtual) memory
|
---|
| 362 | media. It is still at an early stage of development.</para>
|
---|
[2f6053d] | 363 | <indexterm zone="qemu qemu-io">
|
---|
[d28198d3] | 364 | <primary sortas="b-qemu-io">qemu-io</primary>
|
---|
| 365 | </indexterm>
|
---|
| 366 | </listitem>
|
---|
| 367 | </varlistentry>
|
---|
| 368 |
|
---|
| 369 | <varlistentry id="qemu-nbd">
|
---|
| 370 | <term><command>qemu-nbd</command></term>
|
---|
| 371 | <listitem>
|
---|
| 372 | <para>exports Qemu disk images using the QEMU Disk Network Block
|
---|
| 373 | Device (NBD) protocol.</para>
|
---|
[2f6053d] | 374 | <indexterm zone="qemu qemu-nbd">
|
---|
[d28198d3] | 375 | <primary sortas="b-qemu-nbd">qemu-nbd</primary>
|
---|
| 376 | </indexterm>
|
---|
| 377 | </listitem>
|
---|
| 378 | </varlistentry>
|
---|
| 379 |
|
---|
| 380 | <varlistentry id="qemu-system">
|
---|
| 381 | <term><command>qemu-system-x86_64</command></term>
|
---|
| 382 | <listitem>
|
---|
| 383 | <para>is the QEMU PC System emulator.</para>
|
---|
[2f6053d] | 384 | <indexterm zone="qemu qemu-system">
|
---|
[d28198d3] | 385 | <primary sortas="b-qemu-system">qemu-system-x86_64</primary>
|
---|
| 386 | </indexterm>
|
---|
| 387 | </listitem>
|
---|
| 388 | </varlistentry>
|
---|
| 389 |
|
---|
| 390 | </variablelist>
|
---|
| 391 |
|
---|
| 392 | </sect2>
|
---|
| 393 |
|
---|
| 394 | </sect1>
|
---|