source: postlfs/virtualization/qemu-kvm.xml@ 7bcbd6f9

10.0 10.1 11.0 11.1 11.2 11.3 12.0 12.1 12.2 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 gimp3 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/for-12.3 xry111/intltool xry111/llvm18 xry111/soup3 xry111/spidermonkey128 xry111/test-20220226 xry111/xf86-video-removal
Last change on this file since 7bcbd6f9 was 6a54383, checked in by Bruce Dubbs <bdubbs@…>, 12 years ago

Added qemu-kvm patch to correct .texi error exposed by texinfo-5.0.
Also added environment variables to correctly link executables in LFS-7.3.

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

  • Property mode set to 100644
File size: 12.6 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-kvm-download-http " ">
8 <!ENTITY qemu-kvm-download-ftp "&sourceforge-repo2;/projects/kvm/files/qemu-kvm/&qemu-kvm-version;/qemu-kvm-&qemu-kvm-version;.tar.gz">
9 <!ENTITY qemu-kvm-md5sum "d7b18b673c48abfee65a9c0245df0415">
10 <!ENTITY qemu-kvm-size "6.5 MB">
11 <!ENTITY qemu-kvm-buildsize "151 MB">
12 <!ENTITY qemu-kvm-time "1.6 SBU">
13]>
14
15<sect1 id="qemu-kvm" xreflabel="qemu-kvm-&qemu-kvm-version;">
16 <?dbhtml filename="qemu-kvm.html"?>
17
18 <sect1info>
19 <othername>$LastChangedBy$</othername>
20 <date>$Date$</date>
21 </sect1info>
22
23 <title>qemu-kvm-&qemu-kvm-version;</title>
24
25 <indexterm zone="qemu-kvm">
26 <primary sortas="a-qemu-kvm">qemu-kvm</primary>
27 </indexterm>
28
29 <sect2 role="package">
30 <title>Introduction to qemu-kvm</title>
31
32 <para><application>qemu-kvm</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-kvm-download-http;"/></para>
42 </listitem>
43 <listitem>
44 <para>Download (FTP): <ulink url="&qemu-kvm-download-ftp;"/></para>
45 </listitem>
46 <listitem>
47 <para>Download MD5 sum: &qemu-kvm-md5sum;</para>
48 </listitem>
49 <listitem>
50 <para>Download size: &qemu-kvm-size;</para>
51 </listitem>
52 <listitem>
53 <para>Estimated disk space required: &qemu-kvm-buildsize;</para>
54 </listitem>
55 <listitem>
56 <para>Estimated build time: &qemu-kvm-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-kvm-&qemu-kvm-version;-fixes-1.patch"/></para>
65 </listitem>
66 </itemizedlist>
67
68 <bridgehead renderas="sect3">Qemu-kvm 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-kvm"/></para>
93
94 </sect2>
95
96 <sect2 id='qemu-kvm-prereq'>
97 <title>KVM Prerequsites</title>
98
99 <para>Before building <application>qemu-kvm</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-kvm-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-kvm qemu-kvm-kernel">
123 <primary sortas="d-qemu-kvm">kvm-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-kvm</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-kvm</application> by running the following
145 commands:</para>
146
147<screen><userinput>patch -Np1 -i ../qemu-kvm-&qemu-kvm-version;-fixes-1.patch
148./configure --prefix=/usr &amp;&amp;
149LIBS_QGA=-lrt LIBS=-lrt make</userinput></screen>
150
151 <para>Testing the results is not automated. To run individual tests, change
152 to the <filename class='directory'>tests/</filename> directory, and examine
153 the <filename>Makefile</filename>. Each test may be run individually with
154 <command>make run-&lt;test name&gt;</command>.</para>
155
156 <para>Now, as the <systemitem class="username">root</systemitem> user:</para>
157
158<screen role="root"><userinput>make install</userinput></screen>
159
160 <note><para>The main program <command>qemu-system-x86_64</command> doesn't
161 make a distinction between i386 and x86_64 so even on an i386 system you
162 should use <emphasis>qemu-system-x86_64</emphasis></para>
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>LIBS_QGA=-lrt LIBS=-lrt make</parameter>: Ensure that
176 the link process searches the correct libraries for needed functions.</para>
177
178 </sect2>
179
180
181
182 <sect2 role="configuration">
183 <title>Configuring qemu-kvm</title>
184
185 <para>To generate an image, run:</para>
186
187 <screen><userinput>qemu-img create -f qcow2 vdisk.img 10G</userinput></screen>
188
189 <para>Adjust the virtual disk size and image filename as desired. The
190 actual size of the file will be less than specified, but will expand as it
191 is used.</para>
192
193 <note><para>The following instructions assume you have created the optional
194 symbolic link, <userinput>qemu</userinput>. Additionally, you must run
195 <userinput>qemu</userinput> as the <systemitem
196 class="username">root</systemitem> user command from an X-Windows based
197 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 -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 string
212 of drive letters. Valid drive letters are: a, b (floppy 1 and 2), c (first
213 hard disk), d (first CD-ROM). The -m option is the amount of memory to use
214 for the virtual machine. If you have sufficient memory (2G or more), 1G is
215 a reasonable value. For computers with 512MB of RAM it's safe to use -m
216 192, or even -m 128 (the default).</para>
217
218 <para>To run the newly installed operating system, run:</para>
219
220<screen><userinput>qemu vdisk.img -m 384</userinput></screen>
221
222 <para>To add networking to the instance add "-net nic -net user" to the
223 command above. qemu provides a DHCP server for the VM and, depending on
224 the client system, sets up networking though the host.</para>
225
226 <para>One problem with the above networking solution is that it does not
227 provide the ability to connect with the local network. To do that, there are
228 several additional steps that need to be done, all as the <systemitem
229 class="username">root</systemitem> user:</para>
230
231 <itemizedlist spacing="compact">
232 <listitem>
233 <para>Set up bridging with <xref linkend='bridgeutils'/>.</para>
234 </listitem>
235
236 <listitem>
237 <para>Allow the host system to forward IP packets.</para>
238
239<screen><userinput>sysctl -w net.ipv4.ip_forward=1</userinput></screen>
240
241 <para>To make this permanent, add the command to
242 <filename>/etc/syssysctl.conf:</filename></para>
243
244<screen><userinput>cat &gt;&gt; /etc/sysctl.conf &lt;&lt; EOF
245net.ipv4.ip_forward=1
246EOF</userinput></screen>
247
248 </listitem>
249
250 <listitem>
251 <para>Create scripts for qemu to attach the client network
252 device, usually visible as tap0, to the host bridge.</para>
253
254<screen><userinput>cat &gt;&gt; /etc/qemu-ifup &lt;&lt; EOF
255#!/bin/bash
256
257switch=br0
258
259if [ -n "$1" ]; then
260 # Add new tap0 interface to bridge
261 /sbin/ip link set $1 up
262 sleep 0.5s
263 /usr/sbin/brctl addif $switch $1
264else
265 echo "Error: no interface specified"
266 exit 1
267fi
268
269exit 0
270EOF</userinput></screen>
271
272<screen><userinput>cat &gt;&gt; /etc/qemu-ifdown &lt;&lt; EOF
273#!/bin/bash
274
275switch=br0
276
277if [ -n "$1" ]; then
278 # Remove tap0 interface from bridge
279 /usr/sbin/brctl delif $switch $1
280else
281 echo "Error: no interface specified"
282 exit 1
283fi
284
285exit 0
286EOF</userinput></screen>
287
288 </listitem>
289
290 <listitem>
291 <para>Start qemu with "-net nic -net tap" options. </para>
292 </listitem>
293
294 <listitem>
295 <para>If a connection, such as ssh, from the local network to the
296 client VM is desired, the client should probably be configured
297 with a static IP address.</para>
298 </listitem>
299
300 </itemizedlist>
301
302 </sect2>
303
304 <sect2 role="content">
305 <title>Contents</title>
306
307 <segmentedlist>
308 <segtitle>Installed Program</segtitle>
309 <segtitle>Installed Libraries</segtitle>
310 <segtitle>Installed Directories</segtitle>
311
312 <seglistitem>
313 <seg>qemu-ga, qemu-img, qemu-io, qemu-nbd, qemu-system-x86_64</seg>
314 <seg>None</seg>
315 <seg>/etc/qemu, /usr/share/qemu, /usr/share/doc/qemu</seg>
316 </seglistitem>
317 </segmentedlist>
318
319 <variablelist>
320 <bridgehead renderas="sect3">Short Description</bridgehead>
321 <?dbfo list-presentation="list"?>
322 <?dbhtml list-presentation="table"?>
323
324 <varlistentry id="qemu-ga">
325 <term><command>qemu-ga</command></term>
326 <listitem>
327 <para>implements support for QMP (QEMU Monitor Protocol) commands and
328 events that terminate and originate respectively within the guest
329 using an agent built as part of QEMU.</para>
330 <indexterm zone="qemu-kvm qemu-ga">
331 <primary sortas="b-qemu-ga">qemu-ga</primary>
332 </indexterm>
333 </listitem>
334 </varlistentry>
335
336 <varlistentry id="qemu-img">
337 <term><command>qemu-img</command></term>
338 <listitem>
339 <para>provides commands to manage QEMU disk images.</para>
340 <indexterm zone="qemu-kvm qemu-img">
341 <primary sortas="b-qemu-img">qemu-img</primary>
342 </indexterm>
343 </listitem>
344 </varlistentry>
345
346 <varlistentry id="qemu-io">
347 <term><command>qemu-io</command></term>
348 <listitem>
349 <para>is a diagnostic and manipulation program for (virtual) memory
350 media. It is still at an early stage of development.</para>
351 <indexterm zone="qemu-kvm qemu-io">
352 <primary sortas="b-qemu-io">qemu-io</primary>
353 </indexterm>
354 </listitem>
355 </varlistentry>
356
357 <varlistentry id="qemu-nbd">
358 <term><command>qemu-nbd</command></term>
359 <listitem>
360 <para>exports Qemu disk images using the QEMU Disk Network Block
361 Device (NBD) protocol.</para>
362 <indexterm zone="qemu-kvm qemu-nbd">
363 <primary sortas="b-qemu-nbd">qemu-nbd</primary>
364 </indexterm>
365 </listitem>
366 </varlistentry>
367
368 <varlistentry id="qemu-system">
369 <term><command>qemu-system-x86_64</command></term>
370 <listitem>
371 <para>is the QEMU PC System emulator.</para>
372 <indexterm zone="qemu-kvm qemu-system">
373 <primary sortas="b-qemu-system">qemu-system-x86_64</primary>
374 </indexterm>
375 </listitem>
376 </varlistentry>
377
378 </variablelist>
379
380 </sect2>
381
382</sect1>
Note: See TracBrowser for help on using the repository browser.