source: postlfs/virtualization/qemu.xml@ 71e6ae5

10.0 10.1 11.0 7.10 7.4 7.5 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 ken/refactor-virt krejzi/svn lazarus nosym perl-modules qt5new systemd-11177 systemd-13485 trunk xry111/git-date xry111/git-date-for-trunk xry111/git-date-test
Last change on this file since 71e6ae5 was 71e6ae5, checked in by Bruce Dubbs <bdubbs@…>, 9 years ago

Fix a url and clarify qemu scripts

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

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