source: postlfs/virtualization/qemu.xml@ 1cc5345

10.0 10.1 11.0 11.1 11.2 11.3 12.0 12.1 7.10 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 1cc5345 was 577d43d, checked in by Fernando de Oliveira <fernando@…>, 8 years ago
  • qemu-2.5.0: minor substitution and minor reformat.

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

  • Property mode set to 100644
File size: 19.4 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 "f469f2330bbe76e3e39db10e9ac4f8db">
10 <!ENTITY qemu-size "25 MB">
11 <!ENTITY qemu-buildsize "419 MB (with tests)">
12 <!ENTITY qemu-time "2.4 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 &lfs78_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 &amp;&amp;
190[ -e /usr/lib/libcacard.so ] &amp;&amp;
191chmod -v 755 /usr/lib/libcacard.so</userinput></screen>
192
193 <para>
194 You will need a dedicated group that will contain users (other than root)
195 allowed to access the KVM device. Create this group by running the
196 following command as the
197 <systemitem class="username">root</systemitem> user:
198 </para>
199
200<screen role="root"><userinput>groupadd -g 61 kvm</userinput></screen>
201
202 <para>
203 Add any users that might use the KVM device to that group:
204 </para>
205
206<screen role="root"><userinput>usermod -a -G kvm <replaceable>&lt;username&gt;</replaceable></userinput></screen>
207
208 <para>
209 You will also need to add a Udev rule so that the KVM device gets correct
210 permissions:
211 </para>
212
213<screen role="root"><userinput>cat > /lib/udev/rules.d/65-kvm.rules &lt;&lt; "EOF"
214<literal>KERNEL=="kvm", GROUP="kvm", MODE="0660"</literal>
215EOF</userinput></screen>
216
217 <note><!--<para>The main program <command>qemu-system-x86_64</command> doesn't
218 make a distinction between i386 and x86_64 so even on an i386 system you
219 should use <emphasis>qemu-system-x86_64</emphasis></para>
220 -->
221
222 <para>For convenience you may want to create a symbolic link to run
223 the installed program. For instance:</para>
224
225<screen role="root"><userinput>ln -sv qemu-system-`uname -m` /usr/bin/qemu</userinput></screen>
226 </note>
227
228 </sect2>
229
230 <sect2 role="commands">
231 <title>Command Explanations</title>
232
233 <para>
234 <parameter>--audio-drv-list=alsa</parameter>: This switch sets the audio
235 driver to ALSA. For other drivers see the --audio-drv-list list in
236 <command>configure</command>'s help output. The default audio driver is
237 OSS.
238 </para>
239
240 </sect2>
241
242 <sect2 role="configuration">
243 <title>Configuring qemu</title>
244
245 <para>To generate an image, run:</para>
246
247 <screen><userinput>qemu-img create -f qcow2 vdisk.img 10G</userinput></screen>
248
249 <para>Adjust the virtual disk size and image filename as desired. The
250 actual size of the file will be less than specified, but will expand as it
251 is used.</para>
252
253 <note><para>The following instructions assume you have created the optional
254 symbolic link, <userinput>qemu</userinput>. Additionally, you must run
255 <userinput>qemu</userinput> from an X Window System based terminal
256 (either locally or over ssh).</para></note>
257
258 <para>To install an operating system, download an iso of your choice or use
259 a pre-installed cdrom device. For the purposes of this example, use
260 Fedora 16 that is downloaded as
261 <filename>Fedora-16-x86_64-Live-LXDE.iso</filename> in the current
262 directory. Run the following:</para>
263
264<screen><userinput>qemu -enable-kvm -hda vdisk.img \
265 -cdrom Fedora-16-x86_64-Live-LXDE.iso \
266 -boot d \
267 -m 384</userinput></screen>
268
269 <para>Follow the normal installation procedures for the chosen
270 distribution. The -boot option specifies the boot order of drives as a
271 string of drive letters. Valid drive letters are: a, b (floppy 1 and 2), c
272 (first hard disk), d (first CD-ROM). The -m option is the amount of memory
273 to use for the virtual machine. If you have sufficient memory (2G or
274 more), 1G is a reasonable value. For computers with 512MB of RAM it's safe
275 to use -m 192, or even -m 128 (the default). The -enable-kvm option allows
276 for hardware acceleration. Without this switch, the emulation is
277 relatively slow.</para>
278
279 <para>To run the newly installed operating system, run:</para>
280
281<screen><userinput>qemu -enable-kvm vdisk.img -m 384</userinput></screen>
282
283 <para>You may have problem with <parameter>-enable-kvm</parameter>. Also,
284 you may want to define audio and video drivers, number of cpu cores and
285 threads. An alternative command to install the operating system is (see qemu
286 man page for the parameters definitions):</para>
287
288<screen><userinput>qemu -enable-kvm \
289 -cdrom /home/fernando/ISO/linuxmint-17.1-mate-32bit.iso \
290 -boot order=d \
291 -m 1G,slots=3,maxmem=4G \
292 -machine smm=off \
293 -soundhw es1370 \
294 -cpu host \
295 -smp cores=4,threads=2 \
296 -vga std \
297 vdisk.img</userinput></screen>
298
299 <para>One parameter not appearing in the qemu man page is
300 <parameter>-machine smm=off</parameter>, and is used to allow
301 <parameter>-enable-kvm</parameter> in some systems. In order to run the
302 machine, you can alternatively issue:</para>
303
304<screen><userinput>qemu -enable-kvm \
305 -machine smm=off \
306 -boot order=d \
307 -m 1G,slots=3,maxmem=4G \
308 -soundhw es1370 \
309 -cpu host \
310 -smp cores=4,threads=2 \
311 -vga vmware \
312 -hda vdisk.img</userinput></screen>
313
314 <para>Sometimes, you want the machine to have different screen sizes than
315 the ones natively offered by the virtual grahics card. The example below is
316 for qemu vmware graphics card, which uses <xref
317 linkend="xorg-vmmouse-driver"/> and is set to give maximum screen size of
318 1600x900. As the <systemitem class="username">root</systemitem> user,
319 issue:</para>
320
321<screen role="root"><userinput>cat &gt; /usr/share/X11/xorg.conf.d/20-vmware.conf &lt;&lt; "EOF"
322<literal>Section "Monitor"
323 Identifier "Monitor0"
324 # cvt 1600 900
325 # 1600x900 59.95 Hz (CVT 1.44M9) hsync: 55.99 kHz; pclk: 118.25 MHz
326 Modeline "1600x900" 118.25 1600 1696 1856 2112 900 903 908 934 -hsync +vsync
327 Option "PreferredMode" "1600x900"
328 HorizSync 1-200
329 VertRefresh 1-200
330EndSection
331
332Section "Device"
333 Identifier "VMware SVGA II Adapter"
334 Option "Monitor" "default"
335 Driver "vmware"
336EndSection
337
338Section "Screen"
339 Identifier "Default Screen"
340 Device "VMware SVGA II Adapter"
341 Monitor "Monitor0"
342
343 SubSection "Display"
344 Depth 24
345 Modes "1600x900" "1440x900" "1366x768" "1280x720" "800x480"
346 EndSubSection
347
348EndSection</literal>
349EOF</userinput></screen>
350
351 <para>New sizes will be available besides the native ones. You need to
352 restart X in order to have the new sizes available.</para>
353
354 <para><!--To add networking to the instance add "-net nic -net user" to the
355 command above. -->qemu provides a DHCP server for the VM and, depending on
356 the client system, sets up networking though the host.</para>
357
358 <para>One problem with the above networking solution is that it does not
359 provide the ability to connect with the local network. To do that, there are
360 several additional steps that need to be done, all as the <systemitem
361 class="username">root</systemitem> user:</para>
362
363 <itemizedlist spacing="compact">
364 <listitem>
365 <para>Set up bridging with <xref linkend='bridgeutils'/>.</para>
366 </listitem>
367
368 <listitem>
369 <para>Allow the host system to forward IP packets.</para>
370
371<screen role="root"><userinput>sysctl -w net.ipv4.ip_forward=1</userinput></screen>
372
373 <para>To make this permanent, add the command to
374 <filename>/etc/sysctl.conf:</filename></para>
375
376<screen role="root"><userinput>cat &gt;&gt; /etc/sysctl.conf &lt;&lt; EOF
377net.ipv4.ip_forward=1
378EOF</userinput></screen>
379
380 </listitem>
381
382 <listitem>
383 <para>Allow the network connection when running as a part of the
384 kvm group:</para>
385
386<screen role="root"><userinput>chgrp kvm /usr/libexec/qemu-bridge-helper &amp;&amp;
387chmod 4750 /usr/libexec/qemu-bridge-helper</userinput></screen>
388
389 </listitem>
390
391 <listitem>
392 <para>Set up a required configuration file:</para>
393
394<screen role="root"><userinput>echo 'allow br0' &gt; /etc/qemu/bridge.conf</userinput></screen>
395
396 </listitem>
397
398<!--
399 <listitem>
400 <para>Create scripts for qemu to attach the client network
401 device, usually visible as tap0, to the host bridge.</para>
402
403<screen role="root"><userinput>cat &gt; /etc/qemu-ifup &lt;&lt; EOF
404#!/bin/bash
405
406switch=br0
407
408if [ -n "\$1" ]; then
409 # Add new tap0 interface to bridge
410 /sbin/ip link set \$1 up
411 sleep 0.5s
412 /usr/sbin/brctl addif \$switch \$1
413else
414 echo "Error: no interface specified"
415 exit 1
416fi
417
418exit 0
419EOF
420
421chmod +x /etc/qemu-ifup</userinput></screen>
422
423<screen role="root"><userinput>cat &gt; /etc/qemu-ifdown &lt;&lt; EOF
424#!/bin/bash
425
426switch=br0
427
428if [ -n "\$1" ]; then
429 # Remove tap0 interface from bridge
430 /usr/sbin/brctl delif \$switch \$1
431else
432 echo "Error: no interface specified"
433 exit 1
434fi
435
436exit 0
437EOF
438
439chmod +x /etc/qemu-ifdown</userinput></screen>
440
441 </listitem>
442 </itemizedlist>
443
444 <note><para>The backslashes in the above script are for convenience
445 for cut/paste operations. The backslashes should <emphasis>not</emphasis>
446 appear in the final scripts.</para></note>
447
448 <itemizedlist spacing="compact"> -->
449 <listitem>
450 <!--<para>Start qemu with "-net nic -net tap" options. </para>-->
451 <para>Start qemu with "-net nic -net bridge" options. </para>
452 </listitem>
453
454 <listitem>
455 <para>If a connection, such as ssh, from the local network to the
456 client VM is desired, the client should be configured
457 with a static IP address.</para>
458 </listitem>
459
460 </itemizedlist>
461
462 </sect2>
463
464 <sect2 role="content">
465 <title>Contents</title>
466
467 <segmentedlist>
468 <segtitle>Installed Programs</segtitle>
469 <segtitle>Installed Library</segtitle>
470 <segtitle>Installed Directories</segtitle>
471
472 <seglistitem>
473 <seg>
474 ivshmem-client,
475 ivshmem-server,
476 qemu (symlink),
477 qemu-ga,
478 qemu-img,
479 qemu-io,
480 qemu-nbd,
481 qemu-system-&lt;arch&gt;,
482 virtfs-proxy-helper, and
483 vscclient
484 </seg>
485 <seg>libcacard.so</seg>
486 <seg>
487 /etc/qemu and
488 /usr/share/doc/qemu-&qemu-version;
489 </seg>
490 </seglistitem>
491 </segmentedlist>
492
493 <variablelist>
494 <bridgehead renderas="sect3">Short Description</bridgehead>
495 <?dbfo list-presentation="list"?>
496 <?dbhtml list-presentation="table"?>
497
498 <varlistentry id="qemu-ga">
499 <term><command>qemu-ga</command></term>
500 <listitem>
501 <para>implements support for QMP (QEMU Monitor Protocol) commands and
502 events that terminate and originate respectively within the guest
503 using an agent built as part of QEMU.</para>
504 <indexterm zone="qemu qemu-ga">
505 <primary sortas="b-qemu-ga">qemu-ga</primary>
506 </indexterm>
507 </listitem>
508 </varlistentry>
509
510 <varlistentry id="qemu-img">
511 <term><command>qemu-img</command></term>
512 <listitem>
513 <para>provides commands to manage QEMU disk images.</para>
514 <indexterm zone="qemu qemu-img">
515 <primary sortas="b-qemu-img">qemu-img</primary>
516 </indexterm>
517 </listitem>
518 </varlistentry>
519
520 <varlistentry id="qemu-io">
521 <term><command>qemu-io</command></term>
522 <listitem>
523 <para>is a diagnostic and manipulation program for (virtual) memory
524 media. It is still at an early stage of development.</para>
525 <indexterm zone="qemu qemu-io">
526 <primary sortas="b-qemu-io">qemu-io</primary>
527 </indexterm>
528 </listitem>
529 </varlistentry>
530
531 <varlistentry id="qemu-nbd">
532 <term><command>qemu-nbd</command></term>
533 <listitem>
534 <para>exports Qemu disk images using the QEMU Disk Network Block
535 Device (NBD) protocol.</para>
536 <indexterm zone="qemu qemu-nbd">
537 <primary sortas="b-qemu-nbd">qemu-nbd</primary>
538 </indexterm>
539 </listitem>
540 </varlistentry>
541
542 <varlistentry id="qemu-system">
543 <term><command>qemu-system-x86_64</command></term>
544 <listitem>
545 <para>is the QEMU PC System emulator.</para>
546 <indexterm zone="qemu qemu-system">
547 <primary sortas="b-qemu-system">qemu-system-x86_64</primary>
548 </indexterm>
549 </listitem>
550 </varlistentry>
551
552 <varlistentry id="virtfs-proxy-helper">
553 <term><command>virtfs-proxy-helper</command></term>
554 <listitem>
555 <para>creates a socket pair or a named socket. QEMU and proxy helper
556 communicate using this socket. QEMU proxy fs driver sends
557 filesystem request to proxy helper and receives the response
558 from it.</para>
559 <indexterm zone="qemu virtfs-proxy-helper">
560 <primary sortas="b-virtfs-proxy-helper">virtfs-proxy-helper</primary>
561 </indexterm>
562 </listitem>
563 </varlistentry>
564
565 <varlistentry id="vscclient">
566 <term><command>vscclient</command></term>
567 <listitem>
568 <para>implements a sockets interface to the virtual CCID reader
569 on the guest.</para>
570 <indexterm zone="qemu vscclient">
571 <primary sortas="b-vscclient">vscclient</primary>
572 </indexterm>
573 </listitem>
574 </varlistentry>
575
576 <varlistentry id="libcacard">
577 <term><filename class="libraryfile">libcacard.so</filename></term>
578 <listitem>
579 <para>is the Virtual Smart Card Emulator library.</para>
580 <indexterm zone="qemu libcacard">
581 <primary sortas="c-libcacard">libcacard.so</primary>
582 </indexterm>
583 </listitem>
584 </varlistentry>
585
586 </variablelist>
587
588 </sect2>
589
590</sect1>
Note: See TracBrowser for help on using the repository browser.