source: postlfs/virtualization/qemu.xml@ 8ee3e19c

10.0 10.1 11.0 11.1 11.2 11.3 12.0 12.1 7.10 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 8ee3e19c was 8ee3e19c, checked in by Bruce Dubbs <bdubbs@…>, 8 years ago

Update to gtk+-3.20.2.
Update to xapian-core-1.2.23.
Update to Archive-Zip-1.57.
Update to qemu-2.5.1.
Update to audacious-{,plugins)-3.7.1.

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

  • Property mode set to 100644
File size: 19.1 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 "42e73182dea8b9213fa7050e168a4615">
10 <!ENTITY qemu-size "24 MB">
11 <!ENTITY qemu-buildsize "397 MB (with tests)">
12 <!ENTITY qemu-time "2.8 SBU (with tests)">
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 &lfs79_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"/>, and
66 <xref linkend="x-window-system"/>
67 </para>
68
69 <bridgehead renderas="sect4">Recommended</bridgehead>
70 <para role="recommended">
71 <xref linkend="sdl"/>
72 </para>
73
74 <bridgehead renderas="sect4">Optional</bridgehead>
75 <para role="optional">
76 <xref linkend="alsa"/>,
77 <xref linkend="bluez"/>,
78 <xref linkend="check"/>,
79 <xref linkend="curl"/>,
80 <xref linkend="cyrus-sasl"/>,
81 <xref linkend="gnutls"/>,
82 <xref linkend="gtk2"/>,
83 <xref linkend="gtk3"/>,
84 <xref linkend="libusb"/>,
85 <xref linkend="libgcrypt"/>,
86 <xref linkend="lzo"/>,
87 <xref linkend="nettle"/>,
88 <xref linkend="nss"/> (for libcacard.so),
89 <xref linkend="mesa"/>,
90 <xref linkend="sdl"/>,
91 <xref linkend="vte"/>,
92 <ulink url="http://www.libssh2.org">libssh2</ulink>
93 </para>
94
95 <note>
96 <para>
97 This optional dependencies list is not comprehensive. See the output of
98 <command>./configure --help</command> for a more complete list.
99 </para>
100 </note>
101
102 <para condition="html" role="usernotes">User Notes:
103 <ulink url="&blfs-wiki;/qemu"/></para>
104
105 </sect2>
106
107 <sect2 id='qemu-prereq'>
108 <title>KVM Prerequisites</title>
109
110 <para>Before building <application>qemu</application>, check to see if
111 your processor supports Virtualization Technology (VT):</para>
112
113 <screen><userinput>egrep '^flags.*(vmx|svm)' /proc/cpuinfo</userinput></screen>
114
115 <para>If you get any output, you have VT technology (vmx for Intel
116 processors and svm for AMD processors). You then need to go into your
117 system BIOS and ensure it is enabled. After enabing, reboot back to your
118 LFS instance.</para>
119
120 </sect2>
121
122 <sect2 role="kernel" id='qemu-kernel'>
123 <title>Kernel Configuration</title>
124
125 <para>Enable the following options in the kernel configuration and
126 recompile the kernel if necessary:</para>
127
128<screen><literal>[*] Virtualization: ---&gt; [CONFIG_VIRTUALIZATION]
129 &lt;*/M&gt; Kernel-based Virtual Machine (KVM) support [CONFIG_KVM]
130 &lt;*/M&gt; KVM for Intel processors support [CONFIG_KVM_INTEL]
131 &lt;*/M&gt; KVM for AMD processors support [CONFIG_KVM_AMD]</literal></screen>
132
133 <indexterm zone="qemu qemu-kernel">
134 <primary sortas="d-qemu">qemu</primary>
135 </indexterm>
136
137 <para>The Intel or AMD settings are not both required, but the one matching
138 your system processor is required.</para>
139
140 <para>For networking, check that <xref linkend='bridgeutils'/> is installed
141 and the following options in the kernel configuration are enabled:</para>
142
143<screen><literal>[*] Networking support ---&gt; [CONFIG_NET]
144 Networking options ---&gt;
145 &lt;*/M&gt; 802.1d Ethernet Bridging [CONFIG_BRIDGE]
146Device Drivers ---&gt;
147 [*] Network device support ---&gt; [CONFIG_NETDEVICES]
148 &lt;*/M&gt; Universal TUN/TAP device driver support [CONFIG_TUN]</literal></screen>
149
150 </sect2>
151
152 <sect2 role="installation">
153 <title>Installation of qemu</title>
154
155 <para>Install <application>qemu</application> by running the following
156 commands:</para>
157
158 <note><para>Qemu is capable of running many targets. The build process
159 is also capable of building multiple targets at one time in a
160 comma delimited list assigned to <option>--target-list</option>. Run
161 <command>./configure --help</command> to get a complete list of
162 available targets.</para></note>
163
164
165<screen><userinput>if [ $(uname -m) = i686 ]; then
166 QEMU_ARCH=i386-softmmu
167else
168 QEMU_ARCH=x86_64-softmmu
169fi
170
171mkdir -vp build &amp;&amp;
172cd build &amp;&amp;
173
174../configure --prefix=/usr \
175 --sysconfdir=/etc \
176 --target-list=$QEMU_ARCH \
177 --audio-drv-list=alsa \
178 --docdir=/usr/share/doc/qemu-&qemu-version; &amp;&amp;
179
180unset QEMU_ARCH &amp;&amp;
181
182make</userinput></screen>
183
184 <para>To run the built in tests, run <command>make V=1 -k check</command>.
185 One test is known to fail.</para>
186
187 <para>Now, as the <systemitem class="username">root</systemitem> user:</para>
188
189<screen role="root"><userinput>make install</userinput></screen>
190
191 <para>
192 You will need a dedicated group that will contain users (other than root)
193 allowed to access the KVM device. Create this group by running the
194 following command as the
195 <systemitem class="username">root</systemitem> user:
196 </para>
197
198<screen role="root"><userinput>groupadd -g 61 kvm</userinput></screen>
199
200 <para>
201 Add any users that might use the KVM device to that group:
202 </para>
203
204<screen role="root"><userinput>usermod -a -G kvm <replaceable>&lt;username&gt;</replaceable></userinput></screen>
205
206 <para>
207 You will also need to add a Udev rule so that the KVM device gets correct
208 permissions:
209 </para>
210
211<screen role="root"><userinput>cat > /lib/udev/rules.d/65-kvm.rules &lt;&lt; "EOF"
212<literal>KERNEL=="kvm", GROUP="kvm", MODE="0660"</literal>
213EOF</userinput></screen>
214
215 <note>
216 <para>For convenience you may want to create a symbolic link to run
217 the installed program. For instance:</para>
218
219<screen role="root"><userinput>ln -sv qemu-system-`uname -m` /usr/bin/qemu</userinput></screen>
220 </note>
221
222 </sect2>
223
224 <sect2 role="commands">
225 <title>Command Explanations</title>
226
227 <para>
228 <parameter>--audio-drv-list=alsa</parameter>: This switch sets the audio
229 driver to ALSA. For other drivers see the --audio-drv-list list in
230 <command>configure</command>'s help output. The default audio driver is
231 OSS.
232 </para>
233
234 </sect2>
235
236 <sect2 role="configuration">
237 <title>Configuring qemu</title>
238
239 <para>To generate an image, run:</para>
240
241 <screen><userinput>qemu-img create -f qcow2 vdisk.img 10G</userinput></screen>
242
243 <para>Adjust the virtual disk size and image filename as desired. The
244 actual size of the file will be less than specified, but will expand as it
245 is used.</para>
246
247 <note><para>The following instructions assume you have created the optional
248 symbolic link, <userinput>qemu</userinput>. Additionally, you must run
249 <userinput>qemu</userinput> from an X Window System based terminal
250 (either locally or over ssh).</para></note>
251
252 <para>To install an operating system, download an iso of your choice or use
253 a pre-installed cdrom device. For the purposes of this example, use
254 Fedora 16 that is downloaded as
255 <filename>Fedora-16-x86_64-Live-LXDE.iso</filename> in the current
256 directory. Run the following:</para>
257
258<screen><userinput>qemu -enable-kvm -hda vdisk.img \
259 -cdrom Fedora-16-x86_64-Live-LXDE.iso \
260 -boot d \
261 -m 384</userinput></screen>
262
263 <para>Follow the normal installation procedures for the chosen
264 distribution. The -boot option specifies the boot order of drives as a
265 string of drive letters. Valid drive letters are: a, b (floppy 1 and 2), c
266 (first hard disk), d (first CD-ROM). The -m option is the amount of memory
267 to use for the virtual machine. If you have sufficient memory (2G or
268 more), 1G is a reasonable value. For computers with 512MB of RAM it's safe
269 to use -m 192, or even -m 128 (the default). The -enable-kvm option allows
270 for hardware acceleration. Without this switch, the emulation is
271 relatively slow.</para>
272
273 <para>To run the newly installed operating system, run:</para>
274
275<screen><userinput>qemu -enable-kvm vdisk.img -m 384</userinput></screen>
276
277 <para>You may have problem with <parameter>-enable-kvm</parameter>. Also,
278 you may want to define audio and video drivers, number of cpu cores and
279 threads. An alternative command to install the operating system is (see qemu
280 man page for the parameters definitions):</para>
281
282<screen><userinput>qemu -enable-kvm \
283 -cdrom /home/fernando/ISO/linuxmint-17.1-mate-32bit.iso \
284 -boot order=d \
285 -m 1G,slots=3,maxmem=4G \
286 -machine smm=off \
287 -soundhw es1370 \
288 -cpu host \
289 -smp cores=4,threads=2 \
290 -vga std \
291 vdisk.img</userinput></screen>
292
293 <para>One parameter not appearing in the qemu man page is
294 <parameter>-machine smm=off</parameter>, and is used to allow
295 <parameter>-enable-kvm</parameter> in some systems. In order to run the
296 machine, you can alternatively issue:</para>
297
298<screen><userinput>qemu -enable-kvm \
299 -machine smm=off \
300 -boot order=d \
301 -m 1G,slots=3,maxmem=4G \
302 -soundhw es1370 \
303 -cpu host \
304 -smp cores=4,threads=2 \
305 -vga vmware \
306 -hda vdisk.img</userinput></screen>
307
308 <para>Sometimes, you want the machine to have different screen sizes than
309 the ones natively offered by the virtual grahics card. The example below is
310 for qemu vmware graphics card, which uses <xref
311 linkend="xorg-vmmouse-driver"/> and is set to give maximum screen size of
312 1600x900. As the <systemitem class="username">root</systemitem> user,
313 issue:</para>
314
315<screen role="root"><userinput>cat &gt; /usr/share/X11/xorg.conf.d/20-vmware.conf &lt;&lt; "EOF"
316<literal>Section "Monitor"
317 Identifier "Monitor0"
318 # cvt 1600 900
319 # 1600x900 59.95 Hz (CVT 1.44M9) hsync: 55.99 kHz; pclk: 118.25 MHz
320 Modeline "1600x900" 118.25 1600 1696 1856 2112 900 903 908 934 -hsync +vsync
321 Option "PreferredMode" "1600x900"
322 HorizSync 1-200
323 VertRefresh 1-200
324EndSection
325
326Section "Device"
327 Identifier "VMware SVGA II Adapter"
328 Option "Monitor" "default"
329 Driver "vmware"
330EndSection
331
332Section "Screen"
333 Identifier "Default Screen"
334 Device "VMware SVGA II Adapter"
335 Monitor "Monitor0"
336
337 SubSection "Display"
338 Depth 24
339 Modes "1600x900" "1440x900" "1366x768" "1280x720" "800x480"
340 EndSubSection
341
342EndSection</literal>
343EOF</userinput></screen>
344
345 <para>New sizes will be available besides the native ones. You need to
346 restart X in order to have the new sizes available.</para>
347
348 <para><!--To add networking to the instance add "-net nic -net user" to the
349 command above. -->qemu provides a DHCP server for the VM and, depending on
350 the client system, sets up networking though the host.</para>
351
352 <para>One problem with the above networking solution is that it does not
353 provide the ability to connect with the local network. To do that, there are
354 several additional steps that need to be done, all as the <systemitem
355 class="username">root</systemitem> user:</para>
356
357 <itemizedlist spacing="compact">
358 <listitem>
359 <para>Set up bridging with <xref linkend='bridgeutils'/>.</para>
360 </listitem>
361
362 <listitem>
363 <para>Allow the host system to forward IP packets.</para>
364
365<screen role="root"><userinput>sysctl -w net.ipv4.ip_forward=1</userinput></screen>
366
367 <para>To make this permanent, add the command to
368 <filename>/etc/sysctl.conf:</filename></para>
369
370<screen role="root"><userinput>cat &gt;&gt; /etc/sysctl.conf &lt;&lt; EOF
371net.ipv4.ip_forward=1
372EOF</userinput></screen>
373
374 </listitem>
375
376 <listitem>
377 <para>Allow the network connection when running as a part of the
378 kvm group:</para>
379
380<screen role="root"><userinput>chgrp kvm /usr/libexec/qemu-bridge-helper &amp;&amp;
381chmod 4750 /usr/libexec/qemu-bridge-helper</userinput></screen>
382
383 </listitem>
384
385 <listitem>
386 <para>Set up a required configuration file:</para>
387
388<screen role="root"><userinput>echo 'allow br0' &gt; /etc/qemu/bridge.conf</userinput></screen>
389
390 </listitem>
391
392<!--
393 <listitem>
394 <para>Create scripts for qemu to attach the client network
395 device, usually visible as tap0, to the host bridge.</para>
396
397<screen role="root"><userinput>cat &gt; /etc/qemu-ifup &lt;&lt; EOF
398#!/bin/bash
399
400switch=br0
401
402if [ -n "\$1" ]; then
403 # Add new tap0 interface to bridge
404 /sbin/ip link set \$1 up
405 sleep 0.5s
406 /usr/sbin/brctl addif \$switch \$1
407else
408 echo "Error: no interface specified"
409 exit 1
410fi
411
412exit 0
413EOF
414
415chmod +x /etc/qemu-ifup</userinput></screen>
416
417<screen role="root"><userinput>cat &gt; /etc/qemu-ifdown &lt;&lt; EOF
418#!/bin/bash
419
420switch=br0
421
422if [ -n "\$1" ]; then
423 # Remove tap0 interface from bridge
424 /usr/sbin/brctl delif \$switch \$1
425else
426 echo "Error: no interface specified"
427 exit 1
428fi
429
430exit 0
431EOF
432
433chmod +x /etc/qemu-ifdown</userinput></screen>
434
435 </listitem>
436 </itemizedlist>
437
438 <note><para>The backslashes in the above script are for convenience
439 for cut/paste operations. The backslashes should <emphasis>not</emphasis>
440 appear in the final scripts.</para></note>
441
442 <itemizedlist spacing="compact"> -->
443 <listitem>
444 <!--<para>Start qemu with "-net nic -net tap" options. </para>-->
445 <para>Start qemu with "-net nic -net bridge" options. </para>
446 </listitem>
447
448 <listitem>
449 <para>If a connection, such as ssh, from the local network to the
450 client VM is desired, the client should be configured
451 with a static IP address.</para>
452 </listitem>
453
454 </itemizedlist>
455
456 </sect2>
457
458 <sect2 role="content">
459 <title>Contents</title>
460
461 <segmentedlist>
462 <segtitle>Installed Programs</segtitle>
463 <segtitle>Installed Library</segtitle>
464 <segtitle>Installed Directories</segtitle>
465
466 <seglistitem>
467 <seg>
468 ivshmem-client,
469 ivshmem-server,
470 qemu (symlink),
471 qemu-ga,
472 qemu-img,
473 qemu-io,
474 qemu-nbd,
475 qemu-system-&lt;arch&gt;,
476 virtfs-proxy-helper, and
477 vscclient
478 </seg>
479 <seg>libcacard.so</seg>
480 <seg>
481 /etc/qemu and
482 /usr/share/doc/qemu-&qemu-version;
483 </seg>
484 </seglistitem>
485 </segmentedlist>
486
487 <variablelist>
488 <bridgehead renderas="sect3">Short Description</bridgehead>
489 <?dbfo list-presentation="list"?>
490 <?dbhtml list-presentation="table"?>
491
492 <varlistentry id="qemu-ga">
493 <term><command>qemu-ga</command></term>
494 <listitem>
495 <para>implements support for QMP (QEMU Monitor Protocol) commands and
496 events that terminate and originate respectively within the guest
497 using an agent built as part of QEMU.</para>
498 <indexterm zone="qemu qemu-ga">
499 <primary sortas="b-qemu-ga">qemu-ga</primary>
500 </indexterm>
501 </listitem>
502 </varlistentry>
503
504 <varlistentry id="qemu-img">
505 <term><command>qemu-img</command></term>
506 <listitem>
507 <para>provides commands to manage QEMU disk images.</para>
508 <indexterm zone="qemu qemu-img">
509 <primary sortas="b-qemu-img">qemu-img</primary>
510 </indexterm>
511 </listitem>
512 </varlistentry>
513
514 <varlistentry id="qemu-io">
515 <term><command>qemu-io</command></term>
516 <listitem>
517 <para>is a diagnostic and manipulation program for (virtual) memory
518 media. It is still at an early stage of development.</para>
519 <indexterm zone="qemu qemu-io">
520 <primary sortas="b-qemu-io">qemu-io</primary>
521 </indexterm>
522 </listitem>
523 </varlistentry>
524
525 <varlistentry id="qemu-nbd">
526 <term><command>qemu-nbd</command></term>
527 <listitem>
528 <para>exports Qemu disk images using the QEMU Disk Network Block
529 Device (NBD) protocol.</para>
530 <indexterm zone="qemu qemu-nbd">
531 <primary sortas="b-qemu-nbd">qemu-nbd</primary>
532 </indexterm>
533 </listitem>
534 </varlistentry>
535
536 <varlistentry id="qemu-system">
537 <term><command>qemu-system-x86_64</command></term>
538 <listitem>
539 <para>is the QEMU PC System emulator.</para>
540 <indexterm zone="qemu qemu-system">
541 <primary sortas="b-qemu-system">qemu-system-x86_64</primary>
542 </indexterm>
543 </listitem>
544 </varlistentry>
545
546 <varlistentry id="virtfs-proxy-helper">
547 <term><command>virtfs-proxy-helper</command></term>
548 <listitem>
549 <para>creates a socket pair or a named socket. QEMU and proxy helper
550 communicate using this socket. QEMU proxy fs driver sends
551 filesystem request to proxy helper and receives the response
552 from it.</para>
553 <indexterm zone="qemu virtfs-proxy-helper">
554 <primary sortas="b-virtfs-proxy-helper">virtfs-proxy-helper</primary>
555 </indexterm>
556 </listitem>
557 </varlistentry>
558
559 <varlistentry id="vscclient">
560 <term><command>vscclient</command></term>
561 <listitem>
562 <para>implements a sockets interface to the virtual CCID reader
563 on the guest.</para>
564 <indexterm zone="qemu vscclient">
565 <primary sortas="b-vscclient">vscclient</primary>
566 </indexterm>
567 </listitem>
568 </varlistentry>
569
570 <varlistentry id="libcacard">
571 <term><filename class="libraryfile">libcacard.so</filename></term>
572 <listitem>
573 <para>is the Virtual Smart Card Emulator library.</para>
574 <indexterm zone="qemu libcacard">
575 <primary sortas="c-libcacard">libcacard.so</primary>
576 </indexterm>
577 </listitem>
578 </varlistentry>
579
580 </variablelist>
581
582 </sect2>
583
584</sect1>
Note: See TracBrowser for help on using the repository browser.