source: postlfs/virtualization/qemu.xml@ 92cd4cad

10.0 10.1 11.0 11.1 11.2 11.3 12.0 12.1 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 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 92cd4cad was 92cd4cad, checked in by Bruce Dubbs <bdubbs@…>, 9 years ago

Clean up for qemu

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

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