source: postlfs/virtualization/qemu.xml@ e88d7000

10.0 10.1 11.0 11.1 11.2 11.3 12.0 12.1 7.10 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 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 e88d7000 was e88d7000, checked in by Ken Moffat <ken@…>, 11 years ago

Allow qemu to build with make-4.0, and fix one typo.

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

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