source: postlfs/virtualization/qemu.xml@ 252e5bf

10.0 10.1 11.0 11.1 11.2 11.3 12.0 12.1 7.10 7.9 8.0 8.1 8.2 8.3 8.4 9.0 9.1 basic bdubbs/svn elogind kea ken/TL2024 ken/inkscape-core-mods ken/tuningfonts lazarus lxqt nosym perl-modules plabs/newcss plabs/python-mods python3.11 qt5new rahul/power-profiles-daemon renodr/vulkan-addition trunk upgradedb xry111/intltool xry111/llvm18 xry111/soup3 xry111/test-20220226 xry111/xf86-video-removal
Last change on this file since 252e5bf was 252e5bf, checked in by Fernando de Oliveira <fernando@…>, 8 years ago
  • unixODBC-2.3.4: minor reformat.
  • qemu-2.5.0: forgot one "dot".

git-svn-id: svn://svn.linuxfromscratch.org/BLFS/trunk/BOOK@16774 af4574ff-66df-0310-9fd7-8a98e5e911e0

  • Property mode set to 100644
File size: 16.9 KB
RevLine 
[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 " ">
[10f9bb45]9 <!ENTITY qemu-md5sum "f469f2330bbe76e3e39db10e9ac4f8db">
10 <!ENTITY qemu-size "25 MB">
11 <!ENTITY qemu-buildsize "419 MB (with tests)">
12 <!ENTITY qemu-time "2.4 SBU (with tests)">
[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
[90cb5d6]36 &lfs78_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>
[54f740f]59
[2f6053d]60 <bridgehead renderas="sect3">Qemu Dependencies</bridgehead>
[d28198d3]61
62 <bridgehead renderas="sect4">Required</bridgehead>
63 <para role="required">
[aa4778c4]64 <xref linkend="glib2"/>,
[c41b38f]65 <xref linkend="python2"/>, and
[d28198d3]66 <xref linkend="x-window-system"/>
67 </para>
68
[c41b38f]69 <bridgehead renderas="sect4">Recommended</bridgehead>
70 <para role="recommended">
71 <xref linkend="sdl"/>
72 </para>
73
[d28198d3]74 <bridgehead renderas="sect4">Optional</bridgehead>
75 <para role="optional">
76 <xref linkend="alsa"/>,
[8ade43b]77 <xref linkend="bluez"/>,
[d28198d3]78 <xref linkend="check"/>,
79 <xref linkend="curl"/>,
[8ade43b]80 <xref linkend="cyrus-sasl"/>,
[10f9bb45]81 <xref linkend="gnutls"/>,
[8ade43b]82 <xref linkend="gtk2"/>,
83 <xref linkend="gtk3"/>,
84 <xref linkend="libusb"/>,
[10f9bb45]85 <xref linkend="libgcrypt"/>,
[8ade43b]86 <xref linkend="lzo"/>,
[10f9bb45]87 <xref linkend="nettle"/>,
[8ade43b]88 <xref linkend="nss"/> (for libcacard.so),
[10f9bb45]89 <xref linkend="mesa"/>,
90 <xref linkend="sdl"/>,
91 <xref linkend="vte"/>,
92 <ulink url="http://www.libssh2.org">libssh2</ulink>
[d28198d3]93 </para>
94
[9b13441]95 <note>
96 <para>
97 This optional dependencies list is not comprehensive. See the output of
98 <command>./configure --help</command> for a more complete list.
99 </para>
100 </note>
101
[d28198d3]102 <para condition="html" role="usernotes">User Notes:
[2f6053d]103 <ulink url="&blfs-wiki;/qemu"/></para>
[d28198d3]104
105 </sect2>
106
[2f6053d]107 <sect2 id='qemu-prereq'>
[1eb4fcf]108 <title>KVM Prerequisites</title>
[d28198d3]109
[2f6053d]110 <para>Before building <application>qemu</application>, check to see if
[d28198d3]111 your processor supports Virtualization Technology (VT):</para>
112
113 <screen><userinput>egrep '^flags.*(vmx|svm)' /proc/cpuinfo</userinput></screen>
114
115 <para>If you get any output, you have VT technology (vmx for Intel
116 processors and svm for AMD processors). You then need to go into your
117 system BIOS and ensure it is enabled. After enabing, reboot back to your
118 LFS instance.</para>
119
120 </sect2>
121
[2f6053d]122 <sect2 role="kernel" id='qemu-kernel'>
[d28198d3]123 <title>Kernel Configuration</title>
124
[421128a1]125 <para>Enable the following options in the kernel configuration and
126 recompile the kernel if necessary:</para>
[d28198d3]127
[421128a1]128<screen><literal>[*] Virtualization: ---&gt; [CONFIG_VIRTUALIZATION]
129 &lt;*/M&gt; Kernel-based Virtual Machine (KVM) support [CONFIG_KVM]
130 &lt;*/M&gt; KVM for Intel processors support [CONFIG_KVM_INTEL]
131 &lt;*/M&gt; KVM for AMD processors support [CONFIG_KVM_AMD]</literal></screen>
[d28198d3]132
[2f6053d]133 <indexterm zone="qemu qemu-kernel">
134 <primary sortas="d-qemu">qemu</primary>
[d28198d3]135 </indexterm>
136
137 <para>The Intel or AMD settings are not both required, but the one matching
138 your system processor is required.</para>
139
[9b13441]140 <para>For networking, check that <xref linkend='bridgeutils'/> is installed
141 and the following options in the kernel configuration are enabled:</para>
142
[421128a1]143<screen><literal>[*] Networking support ---&gt; [CONFIG_NET]
[9b13441]144 Networking options ---&gt;
[421128a1]145 &lt;*/M&gt; 802.1d Ethernet Bridging [CONFIG_BRIDGE]
[9b13441]146Device Drivers ---&gt;
[421128a1]147 [*] Network device support ---&gt; [CONFIG_NETDEVICES]
148 &lt;*/M&gt; Universal TUN/TAP device driver support [CONFIG_TUN]</literal></screen>
[d28198d3]149
150 </sect2>
151
152 <sect2 role="installation">
[2f6053d]153 <title>Installation of qemu</title>
[0d7900a]154
[2f6053d]155 <para>Install <application>qemu</application> by running the following
[d28198d3]156 commands:</para>
157
[aa9028e]158 <note><para>Qemu is capable of running many targets. The build process
[10f9bb45]159 is also capable of building multiple targets at one time in a
[aa9028e]160 comma delimited list assigned to <option>--target-list</option>. Run
161 <command>./configure --help</command> to get a complete list of
162 available targets.</para></note>
163
164
165<screen><userinput>if [ $(uname -m) = i686 ]; then
166 QEMU_ARCH=i386-softmmu
167else
168 QEMU_ARCH=x86_64-softmmu
169fi
170
[10f9bb45]171mkdir -vp build &amp;&amp;
172cd build &amp;&amp;
173
[252e5bf]174../configure --prefix=/usr \
175 --sysconfdir=/etc \
176 --target-list=$QEMU_ARCH \
177 --audio-drv-list=alsa \
178 --docdir=/usr/share/doc/qemu-&qemu-version; &amp;&amp;
179
[aa9028e]180unset QEMU_ARCH &amp;&amp;
181
[9b13441]182make</userinput></screen>
[d28198d3]183
[bfdd32ae]184 <para>To run the built in tests, run <command>make V=1 -k check</command>.
185 One test is known to fail.</para>
[d28198d3]186
187 <para>Now, as the <systemitem class="username">root</systemitem> user:</para>
188
[9b13441]189<screen role="root"><userinput>make install &amp;&amp;
[5ee1266]190[ -e /usr/lib/libcacard.so ] &amp;&amp;
191chmod -v 755 /usr/lib/libcacard.so</userinput></screen>
[9a04a8e9]192
193 <para>
194 You will need a dedicated group that will contain users (other than root)
[5ee1266]195 allowed to access the KVM device. Create this group by running the
196 following command as the
197 <systemitem class="username">root</systemitem> user:
[9a04a8e9]198 </para>
199
[92cd4cad]200<screen role="root"><userinput>groupadd -g 61 kvm</userinput></screen>
[9a04a8e9]201
202 <para>
203 Add any users that might use the KVM device to that group:
204 </para>
205
206<screen role="root"><userinput>usermod -a -G kvm <replaceable>&lt;username&gt;</replaceable></userinput></screen>
207
208 <para>
[6463c3c]209 You will also need to add a Udev rule so that the KVM device gets correct
[9a04a8e9]210 permissions:
211 </para>
212
213<screen role="root"><userinput>cat > /lib/udev/rules.d/65-kvm.rules &lt;&lt; "EOF"
[009eb04]214<literal>KERNEL=="kvm", GROUP="kvm", MODE="0660"</literal>
[9a04a8e9]215EOF</userinput></screen>
216
[2f6053d]217 <note><!--<para>The main program <command>qemu-system-x86_64</command> doesn't
[d28198d3]218 make a distinction between i386 and x86_64 so even on an i386 system you
219 should use <emphasis>qemu-system-x86_64</emphasis></para>
[2f6053d]220 -->
[0d7900a]221
[d28198d3]222 <para>For convenience you may want to create a symbolic link to run
[aa9028e]223 the installed program. For instance:</para>
[d28198d3]224
[10f9bb45]225<screen role="root"><userinput>ln -sv qemu-system-`uname -m` /usr/bin/qemu</userinput></screen>
[d28198d3]226 </note>
227
228 </sect2>
229
[6a54383]230 <sect2 role="commands">
231 <title>Command Explanations</title>
232
[9b13441]233 <para>
[10f9bb45]234 <parameter>--audio-drv-list=alsa</parameter>: This switch sets the audio
235 driver to ALSA. For other drivers see the --audio-drv-list list in
[9b13441]236 <command>configure</command>'s help output. The default audio driver is
237 OSS.
238 </para>
[6a54383]239
[9b13441]240 </sect2>
[6a54383]241
[d28198d3]242 <sect2 role="configuration">
[2f6053d]243 <title>Configuring qemu</title>
[d28198d3]244
245 <para>To generate an image, run:</para>
246
247 <screen><userinput>qemu-img create -f qcow2 vdisk.img 10G</userinput></screen>
248
249 <para>Adjust the virtual disk size and image filename as desired. The
250 actual size of the file will be less than specified, but will expand as it
251 is used.</para>
252
253 <note><para>The following instructions assume you have created the optional
254 symbolic link, <userinput>qemu</userinput>. Additionally, you must run
[10f9bb45]255 <userinput>qemu</userinput> from an X Window System based terminal
[aa9028e]256 (either locally or over ssh).</para></note>
[d28198d3]257
258 <para>To install an operating system, download an iso of your choice or use
[1659792]259 a pre-installed cdrom device. For the purposes of this example, use
[d28198d3]260 Fedora 16 that is downloaded as
261 <filename>Fedora-16-x86_64-Live-LXDE.iso</filename> in the current
262 directory. Run the following:</para>
263
[2f6053d]264<screen><userinput>qemu -enable-kvm -hda vdisk.img \
[0d7900a]265 -cdrom Fedora-16-x86_64-Live-LXDE.iso \
[d28198d3]266 -boot d \
267 -m 384</userinput></screen>
268
269 <para>Follow the normal installation procedures for the chosen
[2f6053d]270 distribution. The -boot option specifies the boot order of drives as a
271 string of drive letters. Valid drive letters are: a, b (floppy 1 and 2), c
272 (first hard disk), d (first CD-ROM). The -m option is the amount of memory
273 to use for the virtual machine. If you have sufficient memory (2G or
274 more), 1G is a reasonable value. For computers with 512MB of RAM it's safe
275 to use -m 192, or even -m 128 (the default). The -enable-kvm option allows
[f584e7c]276 for hardware acceleration. Without this switch, the emulation is
[2f6053d]277 relatively slow.</para>
[d28198d3]278
279 <para>To run the newly installed operating system, run:</para>
280
[2f6053d]281<screen><userinput>qemu -enable-kvm vdisk.img -m 384</userinput></screen>
[d28198d3]282
283 <para>To add networking to the instance add "-net nic -net user" to the
284 command above. qemu provides a DHCP server for the VM and, depending on
285 the client system, sets up networking though the host.</para>
286
287 <para>One problem with the above networking solution is that it does not
[0d7900a]288 provide the ability to connect with the local network. To do that, there are
[d28198d3]289 several additional steps that need to be done, all as the <systemitem
290 class="username">root</systemitem> user:</para>
291
292 <itemizedlist spacing="compact">
293 <listitem>
294 <para>Set up bridging with <xref linkend='bridgeutils'/>.</para>
295 </listitem>
296
297 <listitem>
298 <para>Allow the host system to forward IP packets.</para>
299
[58196bbf]300<screen role="root"><userinput>sysctl -w net.ipv4.ip_forward=1</userinput></screen>
[0d7900a]301
302 <para>To make this permanent, add the command to
[f584e7c]303 <filename>/etc/sysctl.conf:</filename></para>
[d28198d3]304
[58196bbf]305<screen role="root"><userinput>cat &gt;&gt; /etc/sysctl.conf &lt;&lt; EOF
[0d7900a]306net.ipv4.ip_forward=1
[d28198d3]307EOF</userinput></screen>
308
309 </listitem>
310
[670f775]311 <listitem>
[5ee1266]312 <para>Allow the network connection when running as a part of the
[670f775]313 kvm group:</para>
314
315<screen role="root"><userinput>chgrp kvm /usr/libexec/qemu-bridge-helper &amp;&amp;
316chmod 4750 /usr/libexec/qemu-bridge-helper</userinput></screen>
317
318 </listitem>
319
320 <listitem>
321 <para>Set up a required configuration file:</para>
322
323<screen role="root"><userinput>echo 'allow br0' &gt; /etc/qemu/bridge.conf</userinput></screen>
324
325 </listitem>
326
327<!--
[d28198d3]328 <listitem>
[0d7900a]329 <para>Create scripts for qemu to attach the client network
[d28198d3]330 device, usually visible as tap0, to the host bridge.</para>
331
[58196bbf]332<screen role="root"><userinput>cat &gt; /etc/qemu-ifup &lt;&lt; EOF
[d28198d3]333#!/bin/bash
334
335switch=br0
336
[71e6ae5]337if [ -n "\$1" ]; then
[d28198d3]338 # Add new tap0 interface to bridge
[71e6ae5]339 /sbin/ip link set \$1 up
[d28198d3]340 sleep 0.5s
[71e6ae5]341 /usr/sbin/brctl addif \$switch \$1
[d28198d3]342else
343 echo "Error: no interface specified"
344 exit 1
345fi
346
[0d7900a]347exit 0
[71e6ae5]348EOF
349
350chmod +x /etc/qemu-ifup</userinput></screen>
[d28198d3]351
[58196bbf]352<screen role="root"><userinput>cat &gt; /etc/qemu-ifdown &lt;&lt; EOF
[d28198d3]353#!/bin/bash
354
355switch=br0
356
[71e6ae5]357if [ -n "\$1" ]; then
[d28198d3]358 # Remove tap0 interface from bridge
[71e6ae5]359 /usr/sbin/brctl delif \$switch \$1
[d28198d3]360else
361 echo "Error: no interface specified"
362 exit 1
363fi
364
[0d7900a]365exit 0
[71e6ae5]366EOF
367
368chmod +x /etc/qemu-ifdown</userinput></screen>
[d28198d3]369
370 </listitem>
[71e6ae5]371 </itemizedlist>
372
[e88d7000]373 <note><para>The backslashes in the above script are for convenience
[71e6ae5]374 for cut/paste operations. The backslashes should <emphasis>not</emphasis>
375 appear in the final scripts.</para></note>
[d28198d3]376
[670f775]377 <itemizedlist spacing="compact"> -->
[d28198d3]378 <listitem>
[670f775]379 <!--<para>Start qemu with "-net nic -net tap" options. </para>-->
380 <para>Start qemu with "-net nic -net bridge" options. </para>
[d28198d3]381 </listitem>
382
383 <listitem>
[0d7900a]384 <para>If a connection, such as ssh, from the local network to the
[670f775]385 client VM is desired, the client should be configured
[d28198d3]386 with a static IP address.</para>
387 </listitem>
388
389 </itemizedlist>
390
391 </sect2>
392
393 <sect2 role="content">
394 <title>Contents</title>
395
396 <segmentedlist>
[9b13441]397 <segtitle>Installed Programs</segtitle>
398 <segtitle>Installed Library</segtitle>
[d28198d3]399 <segtitle>Installed Directories</segtitle>
400
401 <seglistitem>
[9b13441]402 <seg>
[10f9bb45]403 ivshmem-client,
404 ivshmem-server,
405 qemu (symlink),
[9b13441]406 qemu-ga,
407 qemu-img,
408 qemu-io,
409 qemu-nbd,
[10f9bb45]410 qemu-system-&lt;arch&gt;,
[9b13441]411 virtfs-proxy-helper, and
412 vscclient
413 </seg>
[8ade43b]414 <seg>libcacard.so</seg>
[9b13441]415 <seg>
[10f9bb45]416 /etc/qemu and
[9b13441]417 /usr/share/doc/qemu-&qemu-version;
418 </seg>
[d28198d3]419 </seglistitem>
420 </segmentedlist>
421
422 <variablelist>
423 <bridgehead renderas="sect3">Short Description</bridgehead>
424 <?dbfo list-presentation="list"?>
425 <?dbhtml list-presentation="table"?>
426
427 <varlistentry id="qemu-ga">
428 <term><command>qemu-ga</command></term>
429 <listitem>
430 <para>implements support for QMP (QEMU Monitor Protocol) commands and
431 events that terminate and originate respectively within the guest
432 using an agent built as part of QEMU.</para>
[2f6053d]433 <indexterm zone="qemu qemu-ga">
[d28198d3]434 <primary sortas="b-qemu-ga">qemu-ga</primary>
435 </indexterm>
436 </listitem>
437 </varlistentry>
438
439 <varlistentry id="qemu-img">
440 <term><command>qemu-img</command></term>
441 <listitem>
442 <para>provides commands to manage QEMU disk images.</para>
[2f6053d]443 <indexterm zone="qemu qemu-img">
[d28198d3]444 <primary sortas="b-qemu-img">qemu-img</primary>
445 </indexterm>
446 </listitem>
447 </varlistentry>
448
449 <varlistentry id="qemu-io">
450 <term><command>qemu-io</command></term>
451 <listitem>
452 <para>is a diagnostic and manipulation program for (virtual) memory
453 media. It is still at an early stage of development.</para>
[2f6053d]454 <indexterm zone="qemu qemu-io">
[d28198d3]455 <primary sortas="b-qemu-io">qemu-io</primary>
456 </indexterm>
457 </listitem>
458 </varlistentry>
459
460 <varlistentry id="qemu-nbd">
461 <term><command>qemu-nbd</command></term>
462 <listitem>
463 <para>exports Qemu disk images using the QEMU Disk Network Block
464 Device (NBD) protocol.</para>
[2f6053d]465 <indexterm zone="qemu qemu-nbd">
[d28198d3]466 <primary sortas="b-qemu-nbd">qemu-nbd</primary>
467 </indexterm>
468 </listitem>
469 </varlistentry>
470
471 <varlistentry id="qemu-system">
472 <term><command>qemu-system-x86_64</command></term>
473 <listitem>
474 <para>is the QEMU PC System emulator.</para>
[2f6053d]475 <indexterm zone="qemu qemu-system">
[d28198d3]476 <primary sortas="b-qemu-system">qemu-system-x86_64</primary>
477 </indexterm>
478 </listitem>
479 </varlistentry>
[8ade43b]480
[72d90b67]481 <varlistentry id="virtfs-proxy-helper">
482 <term><command>virtfs-proxy-helper</command></term>
483 <listitem>
484 <para>creates a socket pair or a named socket. QEMU and proxy helper
485 communicate using this socket. QEMU proxy fs driver sends
486 filesystem request to proxy helper and receives the response
487 from it.</para>
488 <indexterm zone="qemu virtfs-proxy-helper">
489 <primary sortas="b-virtfs-proxy-helper">virtfs-proxy-helper</primary>
490 </indexterm>
491 </listitem>
492 </varlistentry>
493
494 <varlistentry id="vscclient">
495 <term><command>vscclient</command></term>
496 <listitem>
497 <para>implements a sockets interface to the virtual CCID reader
498 on the guest.</para>
499 <indexterm zone="qemu vscclient">
500 <primary sortas="b-vscclient">vscclient</primary>
501 </indexterm>
502 </listitem>
503 </varlistentry>
504
[9b13441]505 <varlistentry id="libcacard">
506 <term><filename class="libraryfile">libcacard.so</filename></term>
507 <listitem>
508 <para>is the Virtual Smart Card Emulator library.</para>
509 <indexterm zone="qemu libcacard">
510 <primary sortas="c-libcacard">libcacard.so</primary>
511 </indexterm>
512 </listitem>
513 </varlistentry>
[8ade43b]514
[d28198d3]515 </variablelist>
516
517 </sect2>
518
519</sect1>
Note: See TracBrowser for help on using the repository browser.