source: postlfs/virtualization/qemu.xml@ 6665210

10.0 10.1 11.0 11.1 11.2 11.3 12.0 12.1 7.10 7.8 7.9 8.0 8.1 8.2 8.3 8.4 9.0 9.1 basic bdubbs/svn elogind kea ken/TL2024 ken/inkscape-core-mods ken/tuningfonts lazarus lxqt nosym perl-modules plabs/newcss plabs/python-mods python3.11 qt5new rahul/power-profiles-daemon renodr/vulkan-addition trunk upgradedb xry111/intltool xry111/llvm18 xry111/soup3 xry111/test-20220226 xry111/xf86-video-removal
Last change on this file since 6665210 was 6665210, checked in by Ken Moffat <ken@…>, 9 years ago

qemu-2.4.1.0

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

  • Property mode set to 100644
File size: 17.1 KB
RevLine 
[d28198d3]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
[2f6053d]7 <!ENTITY qemu-download-http "http://wiki.qemu.org/download/qemu-&qemu-version;.tar.bz2">
8 <!ENTITY qemu-download-ftp " ">
[6665210]9 <!ENTITY qemu-md5sum "c99445164e77184a9ba2e7dbf7ed5c29">
[1ddddef]10 <!ENTITY qemu-size "24 MB">
[6665210]11 <!ENTITY qemu-buildsize "322 MB (395 MB, with tests)">
12 <!ENTITY qemu-time "1.5 SBU (3.0 SBU, with tests)">
[d28198d3]13]>
14
[2f6053d]15<sect1 id="qemu" xreflabel="qemu-&qemu-version;">
16 <?dbhtml filename="qemu.html"?>
[d28198d3]17
18 <sect1info>
[c4a1934a]19 <othername>$LastChangedBy$</othername>
20 <date>$Date$</date>
[d28198d3]21 </sect1info>
22
[2f6053d]23 <title>qemu-&qemu-version;</title>
[d28198d3]24
[2f6053d]25 <indexterm zone="qemu">
26 <primary sortas="a-qemu">qemu</primary>
[d28198d3]27 </indexterm>
28
29 <sect2 role="package">
[2f6053d]30 <title>Introduction to qemu</title>
[d28198d3]31
[2f6053d]32 <para><application>qemu</application> is a full virtualization solution
[d28198d3]33 for Linux on x86 hardware containing virtualization extensions (Intel VT or
34 AMD-V).</para>
35
[90cb5d6]36 &lfs78_checked;
[27643d0f]37
[d28198d3]38 <bridgehead renderas="sect3">Package Information</bridgehead>
39 <itemizedlist spacing="compact">
40 <listitem>
[2f6053d]41 <para>Download (HTTP): <ulink url="&qemu-download-http;"/></para>
[d28198d3]42 </listitem>
43 <listitem>
[2f6053d]44 <para>Download (FTP): <ulink url="&qemu-download-ftp;"/></para>
[d28198d3]45 </listitem>
46 <listitem>
[2f6053d]47 <para>Download MD5 sum: &qemu-md5sum;</para>
[d28198d3]48 </listitem>
49 <listitem>
[2f6053d]50 <para>Download size: &qemu-size;</para>
[d28198d3]51 </listitem>
52 <listitem>
[2f6053d]53 <para>Estimated disk space required: &qemu-buildsize;</para>
[d28198d3]54 </listitem>
55 <listitem>
[2f6053d]56 <para>Estimated build time: &qemu-time;</para>
[d28198d3]57 </listitem>
58 </itemizedlist>
[54f740f]59
[2f6053d]60 <bridgehead renderas="sect3">Qemu Dependencies</bridgehead>
[d28198d3]61
62 <bridgehead renderas="sect4">Required</bridgehead>
63 <para role="required">
[aa4778c4]64 <xref linkend="glib2"/>,
[c41b38f]65 <xref linkend="python2"/>, and
[d28198d3]66 <xref linkend="x-window-system"/>
67 </para>
68
[c41b38f]69 <bridgehead renderas="sect4">Recommended</bridgehead>
70 <para role="recommended">
71 <xref linkend="sdl"/>
72 </para>
73
[d28198d3]74 <bridgehead renderas="sect4">Optional</bridgehead>
75 <para role="optional">
76 <xref linkend="alsa"/>,
[8ade43b]77 <xref linkend="bluez"/>,
[d28198d3]78 <xref linkend="check"/>,
79 <xref linkend="curl"/>,
[8ade43b]80 <xref linkend="cyrus-sasl"/>,
81 <xref linkend="gtk2"/>,
82 <xref linkend="gtk3"/>,
83 <xref linkend="libusb"/>,
84 <xref linkend="lzo"/>,
85 <xref linkend="nss"/> (for libcacard.so),
[d28198d3]86 <xref linkend="mesalib"/>, and
[8ade43b]87 <xref linkend="vte"/>
[d28198d3]88 </para>
89
[9b13441]90 <note>
91 <para>
92 This optional dependencies list is not comprehensive. See the output of
93 <command>./configure --help</command> for a more complete list.
94 </para>
95 </note>
96
[d28198d3]97 <para condition="html" role="usernotes">User Notes:
[2f6053d]98 <ulink url="&blfs-wiki;/qemu"/></para>
[d28198d3]99
100 </sect2>
101
[2f6053d]102 <sect2 id='qemu-prereq'>
[1eb4fcf]103 <title>KVM Prerequisites</title>
[d28198d3]104
[2f6053d]105 <para>Before building <application>qemu</application>, check to see if
[d28198d3]106 your processor supports Virtualization Technology (VT):</para>
107
108 <screen><userinput>egrep '^flags.*(vmx|svm)' /proc/cpuinfo</userinput></screen>
109
110 <para>If you get any output, you have VT technology (vmx for Intel
111 processors and svm for AMD processors). You then need to go into your
112 system BIOS and ensure it is enabled. After enabing, reboot back to your
113 LFS instance.</para>
114
115 </sect2>
116
[2f6053d]117 <sect2 role="kernel" id='qemu-kernel'>
[d28198d3]118 <title>Kernel Configuration</title>
119
[421128a1]120 <para>Enable the following options in the kernel configuration and
121 recompile the kernel if necessary:</para>
[d28198d3]122
[421128a1]123<screen><literal>[*] Virtualization: ---&gt; [CONFIG_VIRTUALIZATION]
124 &lt;*/M&gt; Kernel-based Virtual Machine (KVM) support [CONFIG_KVM]
125 &lt;*/M&gt; KVM for Intel processors support [CONFIG_KVM_INTEL]
126 &lt;*/M&gt; KVM for AMD processors support [CONFIG_KVM_AMD]</literal></screen>
[d28198d3]127
[2f6053d]128 <indexterm zone="qemu qemu-kernel">
129 <primary sortas="d-qemu">qemu</primary>
[d28198d3]130 </indexterm>
131
132 <para>The Intel or AMD settings are not both required, but the one matching
133 your system processor is required.</para>
134
[9b13441]135 <para>For networking, check that <xref linkend='bridgeutils'/> is installed
136 and the following options in the kernel configuration are enabled:</para>
137
[421128a1]138<screen><literal>[*] Networking support ---&gt; [CONFIG_NET]
[9b13441]139 Networking options ---&gt;
[421128a1]140 &lt;*/M&gt; 802.1d Ethernet Bridging [CONFIG_BRIDGE]
[9b13441]141Device Drivers ---&gt;
[421128a1]142 [*] Network device support ---&gt; [CONFIG_NETDEVICES]
143 &lt;*/M&gt; Universal TUN/TAP device driver support [CONFIG_TUN]</literal></screen>
[d28198d3]144
145 </sect2>
146
147 <sect2 role="installation">
[2f6053d]148 <title>Installation of qemu</title>
[0d7900a]149
[2f6053d]150 <para>Install <application>qemu</application> by running the following
[d28198d3]151 commands:</para>
152
[5ee1266]153<screen><userinput>./configure --prefix=/usr \
154 --sysconfdir=/etc \
155 --libexecdir=/usr/lib/qemu \
156 $([ $(uname -m) = i686 ] &amp;&amp;
157 echo --target-list=i386-softmmu) \
158 $([ $(uname -m) = x86_64 ] &amp;&amp;
159 echo --target-list=x86_64-softmmu) \
160 --docdir=/usr/share/doc/qemu-&qemu-version; &amp;&amp;
[9b13441]161make</userinput></screen>
[d28198d3]162
[2f6053d]163 <para>To run the built in tests, run <command>make V=1 check</command>.</para>
[d28198d3]164
165 <para>Now, as the <systemitem class="username">root</systemitem> user:</para>
166
[9b13441]167<screen role="root"><userinput>make install &amp;&amp;
[5ee1266]168[ -e /usr/lib/libcacard.so ] &amp;&amp;
169chmod -v 755 /usr/lib/libcacard.so</userinput></screen>
[9a04a8e9]170
171 <para>
172 You will need a dedicated group that will contain users (other than root)
[5ee1266]173 allowed to access the KVM device. Create this group by running the
174 following command as the
175 <systemitem class="username">root</systemitem> user:
[9a04a8e9]176 </para>
177
[92cd4cad]178<screen role="root"><userinput>groupadd -g 61 kvm</userinput></screen>
[9a04a8e9]179
180 <para>
181 Add any users that might use the KVM device to that group:
182 </para>
183
184<screen role="root"><userinput>usermod -a -G kvm <replaceable>&lt;username&gt;</replaceable></userinput></screen>
185
186 <para>
[6463c3c]187 You will also need to add a Udev rule so that the KVM device gets correct
[9a04a8e9]188 permissions:
189 </para>
190
191<screen role="root"><userinput>cat > /lib/udev/rules.d/65-kvm.rules &lt;&lt; "EOF"
[009eb04]192<literal>KERNEL=="kvm", GROUP="kvm", MODE="0660"</literal>
[9a04a8e9]193EOF</userinput></screen>
194
[2f6053d]195 <note><!--<para>The main program <command>qemu-system-x86_64</command> doesn't
[d28198d3]196 make a distinction between i386 and x86_64 so even on an i386 system you
197 should use <emphasis>qemu-system-x86_64</emphasis></para>
[2f6053d]198 -->
[0d7900a]199
[d28198d3]200 <para>For convenience you may want to create a symbolic link to run
201 <command>qemu-system-x86_64</command>:</para>
202
[c612fc3]203 <screen role="root"><userinput>ln -sv qemu-system-x86_64 /usr/bin/qemu</userinput></screen>
[d28198d3]204 </note>
205
206 </sect2>
207
[6a54383]208 <sect2 role="commands">
209 <title>Command Explanations</title>
210
[5ee1266]211 <para><parameter>$([ $(uname -m) = i686 ] &amp;&amp;
212 echo --target-list=i386-softmmu)</parameter>: This switch
213 tests and, if true, limits the build target to the i386 architecture. For
214 other hardware emulation see the --target-list list in
215 <command>configure</command>'s help output. Omitting the target option will
216 build all architectures.</para>
217
218 <para><parameter>$([ $(uname -m) = x86_64 ] &amp;&amp;
219 echo --target-list=x86_64-softmmu)</parameter>: This switch
220 tests and, if true, limits the build target to the x86_64 architecture. For
221 other hardware emulation see the --target-list list in
222 <command>configure</command>'s help output. Omitting the target option will
223 build all architectures.</para>
[6a54383]224
[9b13441]225 <para>
226 <option>--audio-drv-list=alsa</option>: This switch sets the audio driver
227 to ALSA. For other drivers see the --audio-drv-list list in
228 <command>configure</command>'s help output. The default audio driver is
229 OSS.
230 </para>
[6a54383]231
[9b13441]232 </sect2>
[6a54383]233
[d28198d3]234 <sect2 role="configuration">
[2f6053d]235 <title>Configuring qemu</title>
[d28198d3]236
237 <para>To generate an image, run:</para>
238
239 <screen><userinput>qemu-img create -f qcow2 vdisk.img 10G</userinput></screen>
240
241 <para>Adjust the virtual disk size and image filename as desired. The
242 actual size of the file will be less than specified, but will expand as it
243 is used.</para>
244
245 <note><para>The following instructions assume you have created the optional
246 symbolic link, <userinput>qemu</userinput>. Additionally, you must run
[ef5a37b]247 <userinput>qemu</userinput> from an X Window System based terminal.</para></note>
[d28198d3]248
249 <para>To install an operating system, download an iso of your choice or use
[1659792]250 a pre-installed cdrom device. For the purposes of this example, use
[d28198d3]251 Fedora 16 that is downloaded as
252 <filename>Fedora-16-x86_64-Live-LXDE.iso</filename> in the current
253 directory. Run the following:</para>
254
[2f6053d]255<screen><userinput>qemu -enable-kvm -hda vdisk.img \
[0d7900a]256 -cdrom Fedora-16-x86_64-Live-LXDE.iso \
[d28198d3]257 -boot d \
258 -m 384</userinput></screen>
259
260 <para>Follow the normal installation procedures for the chosen
[2f6053d]261 distribution. The -boot option specifies the boot order of drives as a
262 string of drive letters. Valid drive letters are: a, b (floppy 1 and 2), c
263 (first hard disk), d (first CD-ROM). The -m option is the amount of memory
264 to use for the virtual machine. If you have sufficient memory (2G or
265 more), 1G is a reasonable value. For computers with 512MB of RAM it's safe
266 to use -m 192, or even -m 128 (the default). The -enable-kvm option allows
[f584e7c]267 for hardware acceleration. Without this switch, the emulation is
[2f6053d]268 relatively slow.</para>
[d28198d3]269
270 <para>To run the newly installed operating system, run:</para>
271
[2f6053d]272<screen><userinput>qemu -enable-kvm vdisk.img -m 384</userinput></screen>
[d28198d3]273
274 <para>To add networking to the instance add "-net nic -net user" to the
275 command above. qemu provides a DHCP server for the VM and, depending on
276 the client system, sets up networking though the host.</para>
277
278 <para>One problem with the above networking solution is that it does not
[0d7900a]279 provide the ability to connect with the local network. To do that, there are
[d28198d3]280 several additional steps that need to be done, all as the <systemitem
281 class="username">root</systemitem> user:</para>
282
283 <itemizedlist spacing="compact">
284 <listitem>
285 <para>Set up bridging with <xref linkend='bridgeutils'/>.</para>
286 </listitem>
287
288 <listitem>
289 <para>Allow the host system to forward IP packets.</para>
290
[58196bbf]291<screen role="root"><userinput>sysctl -w net.ipv4.ip_forward=1</userinput></screen>
[0d7900a]292
293 <para>To make this permanent, add the command to
[f584e7c]294 <filename>/etc/sysctl.conf:</filename></para>
[d28198d3]295
[58196bbf]296<screen role="root"><userinput>cat &gt;&gt; /etc/sysctl.conf &lt;&lt; EOF
[0d7900a]297net.ipv4.ip_forward=1
[d28198d3]298EOF</userinput></screen>
299
300 </listitem>
301
[670f775]302 <listitem>
[5ee1266]303 <para>Allow the network connection when running as a part of the
[670f775]304 kvm group:</para>
305
306<screen role="root"><userinput>chgrp kvm /usr/libexec/qemu-bridge-helper &amp;&amp;
307chmod 4750 /usr/libexec/qemu-bridge-helper</userinput></screen>
308
309 </listitem>
310
311 <listitem>
312 <para>Set up a required configuration file:</para>
313
314<screen role="root"><userinput>echo 'allow br0' &gt; /etc/qemu/bridge.conf</userinput></screen>
315
316 </listitem>
317
318<!--
[d28198d3]319 <listitem>
[0d7900a]320 <para>Create scripts for qemu to attach the client network
[d28198d3]321 device, usually visible as tap0, to the host bridge.</para>
322
[58196bbf]323<screen role="root"><userinput>cat &gt; /etc/qemu-ifup &lt;&lt; EOF
[d28198d3]324#!/bin/bash
325
326switch=br0
327
[71e6ae5]328if [ -n "\$1" ]; then
[d28198d3]329 # Add new tap0 interface to bridge
[71e6ae5]330 /sbin/ip link set \$1 up
[d28198d3]331 sleep 0.5s
[71e6ae5]332 /usr/sbin/brctl addif \$switch \$1
[d28198d3]333else
334 echo "Error: no interface specified"
335 exit 1
336fi
337
[0d7900a]338exit 0
[71e6ae5]339EOF
340
341chmod +x /etc/qemu-ifup</userinput></screen>
[d28198d3]342
[58196bbf]343<screen role="root"><userinput>cat &gt; /etc/qemu-ifdown &lt;&lt; EOF
[d28198d3]344#!/bin/bash
345
346switch=br0
347
[71e6ae5]348if [ -n "\$1" ]; then
[d28198d3]349 # Remove tap0 interface from bridge
[71e6ae5]350 /usr/sbin/brctl delif \$switch \$1
[d28198d3]351else
352 echo "Error: no interface specified"
353 exit 1
354fi
355
[0d7900a]356exit 0
[71e6ae5]357EOF
358
359chmod +x /etc/qemu-ifdown</userinput></screen>
[d28198d3]360
361 </listitem>
[71e6ae5]362 </itemizedlist>
363
[e88d7000]364 <note><para>The backslashes in the above script are for convenience
[71e6ae5]365 for cut/paste operations. The backslashes should <emphasis>not</emphasis>
366 appear in the final scripts.</para></note>
[d28198d3]367
[670f775]368 <itemizedlist spacing="compact"> -->
[d28198d3]369 <listitem>
[670f775]370 <!--<para>Start qemu with "-net nic -net tap" options. </para>-->
371 <para>Start qemu with "-net nic -net bridge" options. </para>
[d28198d3]372 </listitem>
373
374 <listitem>
[0d7900a]375 <para>If a connection, such as ssh, from the local network to the
[670f775]376 client VM is desired, the client should be configured
[d28198d3]377 with a static IP address.</para>
378 </listitem>
379
380 </itemizedlist>
381
382 </sect2>
383
384 <sect2 role="content">
385 <title>Contents</title>
386
387 <segmentedlist>
[9b13441]388 <segtitle>Installed Programs</segtitle>
389 <segtitle>Installed Library</segtitle>
[d28198d3]390 <segtitle>Installed Directories</segtitle>
391
392 <seglistitem>
[9b13441]393 <seg>
394 qemu-ga,
395 qemu-img,
396 qemu-io,
397 qemu-nbd,
398 qemu-system-x86_64,
399 virtfs-proxy-helper, and
400 vscclient
401 </seg>
[8ade43b]402 <seg>libcacard.so</seg>
[9b13441]403 <seg>
404 /etc/qemu,
405 /usr/include/cacard,
406 /usr/lib/qemu,
407 /usr/share/qemu, and
408 /usr/share/doc/qemu-&qemu-version;
409 </seg>
[d28198d3]410 </seglistitem>
411 </segmentedlist>
412
413 <variablelist>
414 <bridgehead renderas="sect3">Short Description</bridgehead>
415 <?dbfo list-presentation="list"?>
416 <?dbhtml list-presentation="table"?>
417
418 <varlistentry id="qemu-ga">
419 <term><command>qemu-ga</command></term>
420 <listitem>
421 <para>implements support for QMP (QEMU Monitor Protocol) commands and
422 events that terminate and originate respectively within the guest
423 using an agent built as part of QEMU.</para>
[2f6053d]424 <indexterm zone="qemu qemu-ga">
[d28198d3]425 <primary sortas="b-qemu-ga">qemu-ga</primary>
426 </indexterm>
427 </listitem>
428 </varlistentry>
429
430 <varlistentry id="qemu-img">
431 <term><command>qemu-img</command></term>
432 <listitem>
433 <para>provides commands to manage QEMU disk images.</para>
[2f6053d]434 <indexterm zone="qemu qemu-img">
[d28198d3]435 <primary sortas="b-qemu-img">qemu-img</primary>
436 </indexterm>
437 </listitem>
438 </varlistentry>
439
440 <varlistentry id="qemu-io">
441 <term><command>qemu-io</command></term>
442 <listitem>
443 <para>is a diagnostic and manipulation program for (virtual) memory
444 media. It is still at an early stage of development.</para>
[2f6053d]445 <indexterm zone="qemu qemu-io">
[d28198d3]446 <primary sortas="b-qemu-io">qemu-io</primary>
447 </indexterm>
448 </listitem>
449 </varlistentry>
450
451 <varlistentry id="qemu-nbd">
452 <term><command>qemu-nbd</command></term>
453 <listitem>
454 <para>exports Qemu disk images using the QEMU Disk Network Block
455 Device (NBD) protocol.</para>
[2f6053d]456 <indexterm zone="qemu qemu-nbd">
[d28198d3]457 <primary sortas="b-qemu-nbd">qemu-nbd</primary>
458 </indexterm>
459 </listitem>
460 </varlistentry>
461
462 <varlistentry id="qemu-system">
463 <term><command>qemu-system-x86_64</command></term>
464 <listitem>
465 <para>is the QEMU PC System emulator.</para>
[2f6053d]466 <indexterm zone="qemu qemu-system">
[d28198d3]467 <primary sortas="b-qemu-system">qemu-system-x86_64</primary>
468 </indexterm>
469 </listitem>
470 </varlistentry>
[8ade43b]471
[72d90b67]472 <varlistentry id="virtfs-proxy-helper">
473 <term><command>virtfs-proxy-helper</command></term>
474 <listitem>
475 <para>creates a socket pair or a named socket. QEMU and proxy helper
476 communicate using this socket. QEMU proxy fs driver sends
477 filesystem request to proxy helper and receives the response
478 from it.</para>
479 <indexterm zone="qemu virtfs-proxy-helper">
480 <primary sortas="b-virtfs-proxy-helper">virtfs-proxy-helper</primary>
481 </indexterm>
482 </listitem>
483 </varlistentry>
484
485 <varlistentry id="vscclient">
486 <term><command>vscclient</command></term>
487 <listitem>
488 <para>implements a sockets interface to the virtual CCID reader
489 on the guest.</para>
490 <indexterm zone="qemu vscclient">
491 <primary sortas="b-vscclient">vscclient</primary>
492 </indexterm>
493 </listitem>
494 </varlistentry>
495
[9b13441]496 <varlistentry id="libcacard">
497 <term><filename class="libraryfile">libcacard.so</filename></term>
498 <listitem>
499 <para>is the Virtual Smart Card Emulator library.</para>
500 <indexterm zone="qemu libcacard">
501 <primary sortas="c-libcacard">libcacard.so</primary>
502 </indexterm>
503 </listitem>
504 </varlistentry>
[8ade43b]505
[d28198d3]506 </variablelist>
507
508 </sect2>
509
510</sect1>
Note: See TracBrowser for help on using the repository browser.