source: postlfs/virtualization/qemu.xml@ aa9028e

10.0 10.1 11.0 7.10 7.9 8.0 8.1 8.2 8.3 8.4 9.0 9.1 basic bdubbs/svn elogind ken/refactor-virt lazarus nosym perl-modules qt5new trunk upgradedb xry111/git-date xry111/git-date-for-trunk xry111/git-date-test
Last change on this file since aa9028e was aa9028e, checked in by Bruce Dubbs <bdubbs@…>, 6 years ago

Clarified qemu install instructions

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

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