source: postlfs/virtualization/qemu-systemd.xml@ e31b978

systemd-11177
Last change on this file since e31b978 was e31b978, checked in by Krejzi <krejzi@…>, 10 years ago

Merged trunk.

git-svn-id: svn://svn.linuxfromscratch.org/BLFS/branches/systemd@13890 af4574ff-66df-0310-9fd7-8a98e5e911e0

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