source: postlfs/virtualization/qemu-systemd.xml@ 407a1cf

7.6-blfs 7.6-systemd kde5-14269 kde5-14686 systemd-13485
Last change on this file since 407a1cf was a7b13539, checked in by Krejzi <krejzi@…>, 10 years ago

Add advanced network configuration page which describes setting up bridge with systemd networkd (and in future probably vlan and bonding) and adjust qemu to use it.

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

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