source: postlfs/virtualization/qemu.xml@ 44adaf64

10.0 10.1 11.0 11.1 11.2 11.3 12.0 12.1 7.10 7.6 7.6-blfs 7.6-systemd 7.7 7.8 7.9 8.0 8.1 8.2 8.3 8.4 9.0 9.1 basic bdubbs/svn elogind gnome kde5-13430 kde5-14269 kde5-14686 kea ken/TL2024 ken/inkscape-core-mods ken/tuningfonts krejzi/svn lazarus lxqt nosym perl-modules plabs/newcss plabs/python-mods python3.11 qt5new rahul/power-profiles-daemon renodr/vulkan-addition systemd-11177 systemd-13485 trunk upgradedb xry111/intltool xry111/llvm18 xry111/soup3 xry111/test-20220226 xry111/xf86-video-removal
Last change on this file since 44adaf64 was 44adaf64, checked in by Bruce Dubbs <bdubbs@…>, 10 years ago

Update to qemu-1.7.1

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

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