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

krejzi/svn
Last change on this file since 4945458 was 032be17, checked in by Krejzi <krejzi@…>, 10 years ago

Convert networking/connect, bridge-utils and qemu to systemd.

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

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