source: postlfs/virtualization/qemu.xml@ 30b0f081

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

Update to qemu-2.7.0

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

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