source: postlfs/virtualization/qemu.xml@ 8a6a8a40

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 8a6a8a40 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
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 "f469f2330bbe76e3e39db10e9ac4f8db">
10 <!ENTITY qemu-size "25 MB">
11 <!ENTITY qemu-buildsize "419 MB (with tests)">
12 <!ENTITY qemu-time "2.4 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 &lfs78_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="gnutls"/>,
82 <xref linkend="gtk2"/>,
83 <xref linkend="gtk3"/>,
84 <xref linkend="libusb"/>,
85 <xref linkend="libgcrypt"/>,
86 <xref linkend="lzo"/>,
87 <xref linkend="nettle"/>,
88 <xref linkend="nss"/> (for libcacard.so),
89 <xref linkend="mesa"/>,
90 <xref linkend="sdl"/>,
91 <xref linkend="vte"/>,
92 <ulink url="http://www.libssh2.org">libssh2</ulink>
93 </para>
94
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
102 <para condition="html" role="usernotes">User Notes:
103 <ulink url="&blfs-wiki;/qemu"/></para>
104
105 </sect2>
106
107 <sect2 id='qemu-prereq'>
108 <title>KVM Prerequisites</title>
109
110 <para>Before building <application>qemu</application>, check to see if
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
122 <sect2 role="kernel" id='qemu-kernel'>
123 <title>Kernel Configuration</title>
124
125 <para>Enable the following options in the kernel configuration and
126 recompile the kernel if necessary:</para>
127
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>
132
133 <indexterm zone="qemu qemu-kernel">
134 <primary sortas="d-qemu">qemu</primary>
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
140 <para>For networking, check that <xref linkend='bridgeutils'/> is installed
141 and the following options in the kernel configuration are enabled:</para>
142
143<screen><literal>[*] Networking support ---&gt; [CONFIG_NET]
144 Networking options ---&gt;
145 &lt;*/M&gt; 802.1d Ethernet Bridging [CONFIG_BRIDGE]
146Device Drivers ---&gt;
147 [*] Network device support ---&gt; [CONFIG_NETDEVICES]
148 &lt;*/M&gt; Universal TUN/TAP device driver support [CONFIG_TUN]</literal></screen>
149
150 </sect2>
151
152 <sect2 role="installation">
153 <title>Installation of qemu</title>
154
155 <para>Install <application>qemu</application> by running the following
156 commands:</para>
157
158 <note><para>Qemu is capable of running many targets. The build process
159 is also capable of building multiple targets at one time in a
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
171mkdir -vp build &amp;&amp;
172cd build &amp;&amp;
173
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
180unset QEMU_ARCH &amp;&amp;
181
182make</userinput></screen>
183
184 <para>To run the built in tests, run <command>make V=1 -k check</command>.
185 One test is known to fail.</para>
186
187 <para>Now, as the <systemitem class="username">root</systemitem> user:</para>
188
189<screen role="root"><userinput>make install &amp;&amp;
190[ -e /usr/lib/libcacard.so ] &amp;&amp;
191chmod -v 755 /usr/lib/libcacard.so</userinput></screen>
192
193 <para>
194 You will need a dedicated group that will contain users (other than root)
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:
198 </para>
199
200<screen role="root"><userinput>groupadd -g 61 kvm</userinput></screen>
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>
209 You will also need to add a Udev rule so that the KVM device gets correct
210 permissions:
211 </para>
212
213<screen role="root"><userinput>cat > /lib/udev/rules.d/65-kvm.rules &lt;&lt; "EOF"
214<literal>KERNEL=="kvm", GROUP="kvm", MODE="0660"</literal>
215EOF</userinput></screen>
216
217 <note><!--<para>The main program <command>qemu-system-x86_64</command> doesn't
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>
220 -->
221
222 <para>For convenience you may want to create a symbolic link to run
223 the installed program. For instance:</para>
224
225<screen role="root"><userinput>ln -sv qemu-system-`uname -m` /usr/bin/qemu</userinput></screen>
226 </note>
227
228 </sect2>
229
230 <sect2 role="commands">
231 <title>Command Explanations</title>
232
233 <para>
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
236 <command>configure</command>'s help output. The default audio driver is
237 OSS.
238 </para>
239
240 </sect2>
241
242 <sect2 role="configuration">
243 <title>Configuring qemu</title>
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
255 <userinput>qemu</userinput> from an X Window System based terminal
256 (either locally or over ssh).</para></note>
257
258 <para>To install an operating system, download an iso of your choice or use
259 a pre-installed cdrom device. For the purposes of this example, use
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
264<screen><userinput>qemu -enable-kvm -hda vdisk.img \
265 -cdrom Fedora-16-x86_64-Live-LXDE.iso \
266 -boot d \
267 -m 384</userinput></screen>
268
269 <para>Follow the normal installation procedures for the chosen
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
276 for hardware acceleration. Without this switch, the emulation is
277 relatively slow.</para>
278
279 <para>To run the newly installed operating system, run:</para>
280
281<screen><userinput>qemu -enable-kvm vdisk.img -m 384</userinput></screen>
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
288 provide the ability to connect with the local network. To do that, there are
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
300<screen role="root"><userinput>sysctl -w net.ipv4.ip_forward=1</userinput></screen>
301
302 <para>To make this permanent, add the command to
303 <filename>/etc/sysctl.conf:</filename></para>
304
305<screen role="root"><userinput>cat &gt;&gt; /etc/sysctl.conf &lt;&lt; EOF
306net.ipv4.ip_forward=1
307EOF</userinput></screen>
308
309 </listitem>
310
311 <listitem>
312 <para>Allow the network connection when running as a part of the
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<!--
328 <listitem>
329 <para>Create scripts for qemu to attach the client network
330 device, usually visible as tap0, to the host bridge.</para>
331
332<screen role="root"><userinput>cat &gt; /etc/qemu-ifup &lt;&lt; EOF
333#!/bin/bash
334
335switch=br0
336
337if [ -n "\$1" ]; then
338 # Add new tap0 interface to bridge
339 /sbin/ip link set \$1 up
340 sleep 0.5s
341 /usr/sbin/brctl addif \$switch \$1
342else
343 echo "Error: no interface specified"
344 exit 1
345fi
346
347exit 0
348EOF
349
350chmod +x /etc/qemu-ifup</userinput></screen>
351
352<screen role="root"><userinput>cat &gt; /etc/qemu-ifdown &lt;&lt; EOF
353#!/bin/bash
354
355switch=br0
356
357if [ -n "\$1" ]; then
358 # Remove tap0 interface from bridge
359 /usr/sbin/brctl delif \$switch \$1
360else
361 echo "Error: no interface specified"
362 exit 1
363fi
364
365exit 0
366EOF
367
368chmod +x /etc/qemu-ifdown</userinput></screen>
369
370 </listitem>
371 </itemizedlist>
372
373 <note><para>The backslashes in the above script are for convenience
374 for cut/paste operations. The backslashes should <emphasis>not</emphasis>
375 appear in the final scripts.</para></note>
376
377 <itemizedlist spacing="compact"> -->
378 <listitem>
379 <!--<para>Start qemu with "-net nic -net tap" options. </para>-->
380 <para>Start qemu with "-net nic -net bridge" options. </para>
381 </listitem>
382
383 <listitem>
384 <para>If a connection, such as ssh, from the local network to the
385 client VM is desired, the client should be configured
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>
397 <segtitle>Installed Programs</segtitle>
398 <segtitle>Installed Library</segtitle>
399 <segtitle>Installed Directories</segtitle>
400
401 <seglistitem>
402 <seg>
403 ivshmem-client,
404 ivshmem-server,
405 qemu (symlink),
406 qemu-ga,
407 qemu-img,
408 qemu-io,
409 qemu-nbd,
410 qemu-system-&lt;arch&gt;,
411 virtfs-proxy-helper, and
412 vscclient
413 </seg>
414 <seg>libcacard.so</seg>
415 <seg>
416 /etc/qemu and
417 /usr/share/doc/qemu-&qemu-version;
418 </seg>
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>
433 <indexterm zone="qemu qemu-ga">
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>
443 <indexterm zone="qemu qemu-img">
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>
454 <indexterm zone="qemu qemu-io">
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>
465 <indexterm zone="qemu qemu-nbd">
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>
475 <indexterm zone="qemu qemu-system">
476 <primary sortas="b-qemu-system">qemu-system-x86_64</primary>
477 </indexterm>
478 </listitem>
479 </varlistentry>
480
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
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>
514
515 </variablelist>
516
517 </sect2>
518
519</sect1>
Note: See TracBrowser for help on using the repository browser.