source: postlfs/virtualization/qemu.xml@ 10f9bb45

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 10f9bb45 was 10f9bb45, checked in by Fernando de Oliveira <fernando@…>, 8 years ago
  • summ-blfs-test.php: fix to reflect changes to summ-blfs.php.
  • Qt-5.5.1 and gobject-introspection-1.46.0: add Python-2.7.11 as required.
  • Update to iso-codes-3.63.
  • Update to unixODBC-2.3.4.
  • Update to swig-3.0.8.
  • Update to qemu-2.5.0.

git-svn-id: svn://svn.linuxfromscratch.org/BLFS/trunk/BOOK@16773 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;
179unset QEMU_ARCH &amp;&amp;
180
181make</userinput></screen>
182
183 <para>To run the built in tests, run <command>make V=1 -k check</command>.
184 One test is known to fail.</para>
185
186 <para>Now, as the <systemitem class="username">root</systemitem> user:</para>
187
188<screen role="root"><userinput>make install &amp;&amp;
189[ -e /usr/lib/libcacard.so ] &amp;&amp;
190chmod -v 755 /usr/lib/libcacard.so</userinput></screen>
191
192 <para>
193 You will need a dedicated group that will contain users (other than root)
194 allowed to access the KVM device. Create this group by running the
195 following command as the
196 <systemitem class="username">root</systemitem> user:
197 </para>
198
199<screen role="root"><userinput>groupadd -g 61 kvm</userinput></screen>
200
201 <para>
202 Add any users that might use the KVM device to that group:
203 </para>
204
205<screen role="root"><userinput>usermod -a -G kvm <replaceable>&lt;username&gt;</replaceable></userinput></screen>
206
207 <para>
208 You will also need to add a Udev rule so that the KVM device gets correct
209 permissions:
210 </para>
211
212<screen role="root"><userinput>cat > /lib/udev/rules.d/65-kvm.rules &lt;&lt; "EOF"
213<literal>KERNEL=="kvm", GROUP="kvm", MODE="0660"</literal>
214EOF</userinput></screen>
215
216 <note><!--<para>The main program <command>qemu-system-x86_64</command> doesn't
217 make a distinction between i386 and x86_64 so even on an i386 system you
218 should use <emphasis>qemu-system-x86_64</emphasis></para>
219 -->
220
221 <para>For convenience you may want to create a symbolic link to run
222 the installed program. For instance:</para>
223
224<screen role="root"><userinput>ln -sv qemu-system-`uname -m` /usr/bin/qemu</userinput></screen>
225 </note>
226
227 </sect2>
228
229 <sect2 role="commands">
230 <title>Command Explanations</title>
231
232 <para>
233 <parameter>--audio-drv-list=alsa</parameter>: This switch sets the audio
234 driver to ALSA. For other drivers see the --audio-drv-list list in
235 <command>configure</command>'s help output. The default audio driver is
236 OSS.
237 </para>
238
239 </sect2>
240
241 <sect2 role="configuration">
242 <title>Configuring qemu</title>
243
244 <para>To generate an image, run:</para>
245
246 <screen><userinput>qemu-img create -f qcow2 vdisk.img 10G</userinput></screen>
247
248 <para>Adjust the virtual disk size and image filename as desired. The
249 actual size of the file will be less than specified, but will expand as it
250 is used.</para>
251
252 <note><para>The following instructions assume you have created the optional
253 symbolic link, <userinput>qemu</userinput>. Additionally, you must run
254 <userinput>qemu</userinput> from an X Window System based terminal
255 (either locally or over ssh).</para></note>
256
257 <para>To install an operating system, download an iso of your choice or use
258 a pre-installed cdrom device. For the purposes of this example, use
259 Fedora 16 that is downloaded as
260 <filename>Fedora-16-x86_64-Live-LXDE.iso</filename> in the current
261 directory. Run the following:</para>
262
263<screen><userinput>qemu -enable-kvm -hda vdisk.img \
264 -cdrom Fedora-16-x86_64-Live-LXDE.iso \
265 -boot d \
266 -m 384</userinput></screen>
267
268 <para>Follow the normal installation procedures for the chosen
269 distribution. The -boot option specifies the boot order of drives as a
270 string of drive letters. Valid drive letters are: a, b (floppy 1 and 2), c
271 (first hard disk), d (first CD-ROM). The -m option is the amount of memory
272 to use for the virtual machine. If you have sufficient memory (2G or
273 more), 1G is a reasonable value. For computers with 512MB of RAM it's safe
274 to use -m 192, or even -m 128 (the default). The -enable-kvm option allows
275 for hardware acceleration. Without this switch, the emulation is
276 relatively slow.</para>
277
278 <para>To run the newly installed operating system, run:</para>
279
280<screen><userinput>qemu -enable-kvm vdisk.img -m 384</userinput></screen>
281
282 <para>To add networking to the instance add "-net nic -net user" to the
283 command above. qemu provides a DHCP server for the VM and, depending on
284 the client system, sets up networking though the host.</para>
285
286 <para>One problem with the above networking solution is that it does not
287 provide the ability to connect with the local network. To do that, there are
288 several additional steps that need to be done, all as the <systemitem
289 class="username">root</systemitem> user:</para>
290
291 <itemizedlist spacing="compact">
292 <listitem>
293 <para>Set up bridging with <xref linkend='bridgeutils'/>.</para>
294 </listitem>
295
296 <listitem>
297 <para>Allow the host system to forward IP packets.</para>
298
299<screen role="root"><userinput>sysctl -w net.ipv4.ip_forward=1</userinput></screen>
300
301 <para>To make this permanent, add the command to
302 <filename>/etc/sysctl.conf:</filename></para>
303
304<screen role="root"><userinput>cat &gt;&gt; /etc/sysctl.conf &lt;&lt; EOF
305net.ipv4.ip_forward=1
306EOF</userinput></screen>
307
308 </listitem>
309
310 <listitem>
311 <para>Allow the network connection when running as a part of the
312 kvm group:</para>
313
314<screen role="root"><userinput>chgrp kvm /usr/libexec/qemu-bridge-helper &amp;&amp;
315chmod 4750 /usr/libexec/qemu-bridge-helper</userinput></screen>
316
317 </listitem>
318
319 <listitem>
320 <para>Set up a required configuration file:</para>
321
322<screen role="root"><userinput>echo 'allow br0' &gt; /etc/qemu/bridge.conf</userinput></screen>
323
324 </listitem>
325
326<!--
327 <listitem>
328 <para>Create scripts for qemu to attach the client network
329 device, usually visible as tap0, to the host bridge.</para>
330
331<screen role="root"><userinput>cat &gt; /etc/qemu-ifup &lt;&lt; EOF
332#!/bin/bash
333
334switch=br0
335
336if [ -n "\$1" ]; then
337 # Add new tap0 interface to bridge
338 /sbin/ip link set \$1 up
339 sleep 0.5s
340 /usr/sbin/brctl addif \$switch \$1
341else
342 echo "Error: no interface specified"
343 exit 1
344fi
345
346exit 0
347EOF
348
349chmod +x /etc/qemu-ifup</userinput></screen>
350
351<screen role="root"><userinput>cat &gt; /etc/qemu-ifdown &lt;&lt; EOF
352#!/bin/bash
353
354switch=br0
355
356if [ -n "\$1" ]; then
357 # Remove tap0 interface from bridge
358 /usr/sbin/brctl delif \$switch \$1
359else
360 echo "Error: no interface specified"
361 exit 1
362fi
363
364exit 0
365EOF
366
367chmod +x /etc/qemu-ifdown</userinput></screen>
368
369 </listitem>
370 </itemizedlist>
371
372 <note><para>The backslashes in the above script are for convenience
373 for cut/paste operations. The backslashes should <emphasis>not</emphasis>
374 appear in the final scripts.</para></note>
375
376 <itemizedlist spacing="compact"> -->
377 <listitem>
378 <!--<para>Start qemu with "-net nic -net tap" options. </para>-->
379 <para>Start qemu with "-net nic -net bridge" options. </para>
380 </listitem>
381
382 <listitem>
383 <para>If a connection, such as ssh, from the local network to the
384 client VM is desired, the client should be configured
385 with a static IP address.</para>
386 </listitem>
387
388 </itemizedlist>
389
390 </sect2>
391
392 <sect2 role="content">
393 <title>Contents</title>
394
395 <segmentedlist>
396 <segtitle>Installed Programs</segtitle>
397 <segtitle>Installed Library</segtitle>
398 <segtitle>Installed Directories</segtitle>
399
400 <seglistitem>
401 <seg>
402 ivshmem-client,
403 ivshmem-server,
404 qemu (symlink),
405 qemu-ga,
406 qemu-img,
407 qemu-io,
408 qemu-nbd,
409 qemu-system-&lt;arch&gt;,
410 virtfs-proxy-helper, and
411 vscclient
412 </seg>
413 <seg>libcacard.so</seg>
414 <seg>
415 /etc/qemu and
416 /usr/share/doc/qemu-&qemu-version;
417 </seg>
418 </seglistitem>
419 </segmentedlist>
420
421 <variablelist>
422 <bridgehead renderas="sect3">Short Description</bridgehead>
423 <?dbfo list-presentation="list"?>
424 <?dbhtml list-presentation="table"?>
425
426 <varlistentry id="qemu-ga">
427 <term><command>qemu-ga</command></term>
428 <listitem>
429 <para>implements support for QMP (QEMU Monitor Protocol) commands and
430 events that terminate and originate respectively within the guest
431 using an agent built as part of QEMU.</para>
432 <indexterm zone="qemu qemu-ga">
433 <primary sortas="b-qemu-ga">qemu-ga</primary>
434 </indexterm>
435 </listitem>
436 </varlistentry>
437
438 <varlistentry id="qemu-img">
439 <term><command>qemu-img</command></term>
440 <listitem>
441 <para>provides commands to manage QEMU disk images.</para>
442 <indexterm zone="qemu qemu-img">
443 <primary sortas="b-qemu-img">qemu-img</primary>
444 </indexterm>
445 </listitem>
446 </varlistentry>
447
448 <varlistentry id="qemu-io">
449 <term><command>qemu-io</command></term>
450 <listitem>
451 <para>is a diagnostic and manipulation program for (virtual) memory
452 media. It is still at an early stage of development.</para>
453 <indexterm zone="qemu qemu-io">
454 <primary sortas="b-qemu-io">qemu-io</primary>
455 </indexterm>
456 </listitem>
457 </varlistentry>
458
459 <varlistentry id="qemu-nbd">
460 <term><command>qemu-nbd</command></term>
461 <listitem>
462 <para>exports Qemu disk images using the QEMU Disk Network Block
463 Device (NBD) protocol.</para>
464 <indexterm zone="qemu qemu-nbd">
465 <primary sortas="b-qemu-nbd">qemu-nbd</primary>
466 </indexterm>
467 </listitem>
468 </varlistentry>
469
470 <varlistentry id="qemu-system">
471 <term><command>qemu-system-x86_64</command></term>
472 <listitem>
473 <para>is the QEMU PC System emulator.</para>
474 <indexterm zone="qemu qemu-system">
475 <primary sortas="b-qemu-system">qemu-system-x86_64</primary>
476 </indexterm>
477 </listitem>
478 </varlistentry>
479
480 <varlistentry id="virtfs-proxy-helper">
481 <term><command>virtfs-proxy-helper</command></term>
482 <listitem>
483 <para>creates a socket pair or a named socket. QEMU and proxy helper
484 communicate using this socket. QEMU proxy fs driver sends
485 filesystem request to proxy helper and receives the response
486 from it.</para>
487 <indexterm zone="qemu virtfs-proxy-helper">
488 <primary sortas="b-virtfs-proxy-helper">virtfs-proxy-helper</primary>
489 </indexterm>
490 </listitem>
491 </varlistentry>
492
493 <varlistentry id="vscclient">
494 <term><command>vscclient</command></term>
495 <listitem>
496 <para>implements a sockets interface to the virtual CCID reader
497 on the guest.</para>
498 <indexterm zone="qemu vscclient">
499 <primary sortas="b-vscclient">vscclient</primary>
500 </indexterm>
501 </listitem>
502 </varlistentry>
503
504 <varlistentry id="libcacard">
505 <term><filename class="libraryfile">libcacard.so</filename></term>
506 <listitem>
507 <para>is the Virtual Smart Card Emulator library.</para>
508 <indexterm zone="qemu libcacard">
509 <primary sortas="c-libcacard">libcacard.so</primary>
510 </indexterm>
511 </listitem>
512 </varlistentry>
513
514 </variablelist>
515
516 </sect2>
517
518</sect1>
Note: See TracBrowser for help on using the repository browser.