source: postlfs/virtualization/qemu.xml@ bba42820

10.0 10.1 11.0 11.1 11.2 11.3 12.0 12.1 7.10 7.8 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 bba42820 was 5ee1266, checked in by Fernando de Oliveira <fernando@…>, 9 years ago
  • Update to gnupg-2.1.7.
  • Update to qemu-2.4.0.
  • nfs-utils, obconf-qt, qterminal, juffed, akonadi and sddm: typos.
  • Update to libpng-1.6.18.
  • Update to vala-0.28.1.
  • Update to mesa-10.6.4.
  • Update to curl-7.44.0.
  • OpenSSH-7.0p1 and Firefox-40.0: reformat.
  • libESMTP-1.0.6: dead URL.

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

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