source: postlfs/virtualization/qemu.xml@ 73ded0c

10.0 10.1 11.0 11.1 11.2 11.3 12.0 12.1 12.2 7.10 7.7 7.8 7.9 8.0 8.1 8.2 8.3 8.4 9.0 9.1 basic bdubbs/svn elogind gimp3 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/for-12.3 xry111/intltool xry111/llvm18 xry111/soup3 xry111/spidermonkey128 xry111/test-20220226 xry111/xf86-video-removal
Last change on this file since 73ded0c was dada702, checked in by Bruce Dubbs <bdubbs@…>, 10 years ago

More cleanup

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

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