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