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 "https://download.qemu.org/qemu-&qemu-version;.tar.xz">
|
---|
8 | <!ENTITY qemu-download-ftp " ">
|
---|
9 | <!ENTITY qemu-md5sum "7dd9ff5a92cf81cfce6cda1f6e271f3a">
|
---|
10 | <!ENTITY qemu-size "118 MB">
|
---|
11 | <!ENTITY qemu-buildsize "2.1 GB (366 MB installed)">
|
---|
12 | <!ENTITY qemu-time "1.2 SBU (add 0.8 SBU for tests, both using parallelism=4)">
|
---|
13 | ]>
|
---|
14 |
|
---|
15 | <sect1 id="qemu" xreflabel="qemu-&qemu-version;">
|
---|
16 | <?dbhtml filename="qemu.html"?>
|
---|
17 |
|
---|
18 |
|
---|
19 | <title>qemu-&qemu-version;</title>
|
---|
20 |
|
---|
21 | <indexterm zone="qemu">
|
---|
22 | <primary sortas="a-qemu">qemu</primary>
|
---|
23 | </indexterm>
|
---|
24 |
|
---|
25 | <sect2 role="package">
|
---|
26 | <title>Introduction to qemu</title>
|
---|
27 |
|
---|
28 | <para>
|
---|
29 | <application>qemu</application> is a full virtualization solution for
|
---|
30 | Linux on x86 hardware containing virtualization extensions (Intel VT or
|
---|
31 | AMD-V).
|
---|
32 | </para>
|
---|
33 |
|
---|
34 | &lfs120_checked;
|
---|
35 |
|
---|
36 | <bridgehead renderas="sect3">Package Information</bridgehead>
|
---|
37 | <itemizedlist spacing="compact">
|
---|
38 | <listitem>
|
---|
39 | <para>
|
---|
40 | Download (HTTP): <ulink url="&qemu-download-http;"/>
|
---|
41 | </para>
|
---|
42 | </listitem>
|
---|
43 | <listitem>
|
---|
44 | <para>
|
---|
45 | Download (FTP): <ulink url="&qemu-download-ftp;"/>
|
---|
46 | </para>
|
---|
47 | </listitem>
|
---|
48 | <listitem>
|
---|
49 | <para>
|
---|
50 | Download MD5 sum: &qemu-md5sum;
|
---|
51 | </para>
|
---|
52 | </listitem>
|
---|
53 | <listitem>
|
---|
54 | <para>
|
---|
55 | Download size: &qemu-size;
|
---|
56 | </para>
|
---|
57 | </listitem>
|
---|
58 | <listitem>
|
---|
59 | <para>
|
---|
60 | Estimated disk space required: &qemu-buildsize;
|
---|
61 | </para>
|
---|
62 | </listitem>
|
---|
63 | <listitem>
|
---|
64 | <para>
|
---|
65 | Estimated build time: &qemu-time;
|
---|
66 | </para>
|
---|
67 | </listitem>
|
---|
68 | </itemizedlist>
|
---|
69 |
|
---|
70 | <bridgehead renderas="sect3">Qemu Dependencies</bridgehead>
|
---|
71 |
|
---|
72 | <bridgehead renderas="sect4">Required</bridgehead>
|
---|
73 | <para role="required">
|
---|
74 | <xref linkend="glib2"/>
|
---|
75 | </para>
|
---|
76 |
|
---|
77 | <bridgehead renderas="sect4">Recommended</bridgehead>
|
---|
78 | <para role="recommended">
|
---|
79 | <xref linkend="alsa-lib"/>,
|
---|
80 | <xref linkend="libslirp"/>, and
|
---|
81 | <xref linkend="sdl2"/>
|
---|
82 | </para>
|
---|
83 |
|
---|
84 | <bridgehead renderas="sect4">Optional</bridgehead>
|
---|
85 | <para role="optional">
|
---|
86 | Depending on the sound system, various packages in <xref linkend="alsa"/>,
|
---|
87 | <xref linkend="python3"/>,
|
---|
88 | <xref linkend="pulseaudio"/>,
|
---|
89 | <xref linkend="bluez"/>,
|
---|
90 | <xref linkend="curl"/>,
|
---|
91 | <xref linkend="cyrus-sasl"/>,
|
---|
92 | <xref linkend="gnutls"/>,
|
---|
93 | <xref linkend="gtk2"/>,
|
---|
94 | <xref linkend="gtk3"/>,
|
---|
95 | <xref linkend="libusb"/>,
|
---|
96 | <xref linkend="libgcrypt"/>,
|
---|
97 | <xref linkend="libssh2"/>,
|
---|
98 | <xref linkend="lzo"/>,
|
---|
99 | <xref linkend="nettle"/>,
|
---|
100 | <xref linkend="mesa"/>,
|
---|
101 | <xref role="nodep" linkend="vte"/> or <xref linkend="vte2"/>, and
|
---|
102 | <!-- libcacard has been a standalone project since qemu-2.5.-->
|
---|
103 | <ulink url="https://gitlab.freedesktop.org/spice/libcacard">libcacard</ulink>
|
---|
104 | </para>
|
---|
105 |
|
---|
106 | <bridgehead renderas="sect4">Optional (Runtime)</bridgehead>
|
---|
107 | <para role="runtime">
|
---|
108 | &logind;
|
---|
109 | </para>
|
---|
110 |
|
---|
111 | <bridgehead renderas="sect4">Optional (for building the documentation)</bridgehead>
|
---|
112 | <para role="optional">
|
---|
113 | <xref linkend="sphinx_rtd_theme"/>
|
---|
114 | </para>
|
---|
115 |
|
---|
116 | <note>
|
---|
117 | <para>
|
---|
118 | This optional dependencies list is not comprehensive. See the output of
|
---|
119 | <command>./configure --help</command> for a more complete list.
|
---|
120 | </para>
|
---|
121 | </note>
|
---|
122 |
|
---|
123 | <para condition="html" role="usernotes">Editor Notes:
|
---|
124 | <ulink url="&blfs-wiki;/qemu"/></para>
|
---|
125 |
|
---|
126 | </sect2>
|
---|
127 |
|
---|
128 | <sect2 id='qemu-prereq'>
|
---|
129 | <title>KVM Prerequisites</title>
|
---|
130 |
|
---|
131 | <para>
|
---|
132 | Before building <application>qemu</application>, check to see if
|
---|
133 | your processor supports Virtualization Technology (VT):
|
---|
134 | </para>
|
---|
135 |
|
---|
136 | <screen><userinput>grep -E '^flags.*(vmx|svm)' /proc/cpuinfo</userinput></screen>
|
---|
137 |
|
---|
138 | <para>
|
---|
139 | If you get any output, you have VT technology (vmx for Intel
|
---|
140 | processors and svm for AMD processors). You then need to go into your
|
---|
141 | system BIOS and ensure it is enabled. After enabling, reboot back to your
|
---|
142 | LFS instance.
|
---|
143 | </para>
|
---|
144 |
|
---|
145 | </sect2>
|
---|
146 |
|
---|
147 | <sect2 role="kernel" id='qemu-kernel'>
|
---|
148 | <title>Kernel Configuration</title>
|
---|
149 |
|
---|
150 | <para>
|
---|
151 | Enable the following options in the kernel configuration and
|
---|
152 | recompile the kernel if necessary:
|
---|
153 | </para>
|
---|
154 |
|
---|
155 | <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
|
---|
156 | href="qemu-kvm-kernel.xml"/>
|
---|
157 |
|
---|
158 | <indexterm zone="qemu qemu-kernel">
|
---|
159 | <primary sortas="d-qemu">qemu</primary>
|
---|
160 | </indexterm>
|
---|
161 |
|
---|
162 | <para>
|
---|
163 | The Intel or AMD settings are not both required, but the one matching
|
---|
164 | your system processor is required.
|
---|
165 | </para>
|
---|
166 |
|
---|
167 | <para>
|
---|
168 | To use the <quote>bridge</quote> network device, as explained below,
|
---|
169 | check that <xref linkend='bridgeutils'/> is installed
|
---|
170 | and the following options in the kernel configuration are enabled:
|
---|
171 | </para>
|
---|
172 |
|
---|
173 | <xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
|
---|
174 | href="qemu-bridge-kernel.xml"/>
|
---|
175 |
|
---|
176 | </sect2>
|
---|
177 |
|
---|
178 | <sect2 role="installation">
|
---|
179 | <title>Installation of qemu</title>
|
---|
180 | <!-- group kvm is created in lfs chapter 7 even for sysv
|
---|
181 | <para revision="sysv">
|
---|
182 | You will need a dedicated group that will contain users (other than root)
|
---|
183 | allowed to access the KVM device. Create this group by running the
|
---|
184 | following command as the
|
---|
185 | <systemitem class="username">root</systemitem> user:
|
---|
186 | </para>
|
---|
187 |
|
---|
188 | <screen role="root" revision="sysv"><userinput>groupadd -g 61 kvm</userinput></screen>
|
---|
189 | -->
|
---|
190 | <para>
|
---|
191 | The udev rule of LFS only allows the &root; user, the users owning
|
---|
192 | a local login session supported by the optional runtime dependency
|
---|
193 | &logind;, or the users in the
|
---|
194 | <systemitem class="groupname">kvm</systemitem> group to use the KVM
|
---|
195 | device. As the &root; user, add any non-&root; users that might use
|
---|
196 | the KVM device either without &logind; installed or remotely (via a
|
---|
197 | SSH connection) to the
|
---|
198 | <systemitem class="groupname">kvm</systemitem> group:
|
---|
199 | </para>
|
---|
200 |
|
---|
201 | <screen role="root"><userinput>usermod -a -G kvm <replaceable><username></replaceable></userinput></screen>
|
---|
202 |
|
---|
203 | <para>
|
---|
204 | Install <application>qemu</application> by running the following
|
---|
205 | commands:
|
---|
206 | </para>
|
---|
207 |
|
---|
208 | <note>
|
---|
209 | <para>
|
---|
210 | Qemu is capable of running many targets. The build process
|
---|
211 | is also capable of building multiple targets at one time in a
|
---|
212 | comma delimited list assigned to <option>--target-list</option>. Run
|
---|
213 | <command>./configure --help</command> to get a complete list of
|
---|
214 | available targets.
|
---|
215 | </para>
|
---|
216 | </note>
|
---|
217 |
|
---|
218 |
|
---|
219 | <screen><userinput>if [ $(uname -m) = i686 ]; then
|
---|
220 | QEMU_ARCH=i386-softmmu
|
---|
221 | else
|
---|
222 | QEMU_ARCH=x86_64-softmmu
|
---|
223 | fi
|
---|
224 |
|
---|
225 |
|
---|
226 | mkdir -vp build &&
|
---|
227 | cd build &&
|
---|
228 |
|
---|
229 | ../configure --prefix=/usr \
|
---|
230 | --sysconfdir=/etc \
|
---|
231 | --localstatedir=/var \
|
---|
232 | --target-list=$QEMU_ARCH \
|
---|
233 | --audio-drv-list=alsa \
|
---|
234 | --disable-pa \
|
---|
235 | --enable-slirp \
|
---|
236 | --docdir=/usr/share/doc/qemu-&qemu-version; &&
|
---|
237 |
|
---|
238 | unset QEMU_ARCH &&
|
---|
239 |
|
---|
240 | make</userinput></screen>
|
---|
241 |
|
---|
242 | <para>
|
---|
243 | <application>qemu</application> uses <command>ninja</command> as
|
---|
244 | a subprocess when building. To run the tests, issue:
|
---|
245 | <command>ninja test</command>. One test, bios-tables-test, is
|
---|
246 | known to fail.
|
---|
247 | </para>
|
---|
248 |
|
---|
249 | <para>
|
---|
250 | Now, as the &root; user:
|
---|
251 | </para>
|
---|
252 |
|
---|
253 | <screen role="root"><userinput>make install</userinput></screen>
|
---|
254 |
|
---|
255 | <para>
|
---|
256 | Change the permissions and ownership of a helper script, which is needed
|
---|
257 | when using the <quote>bridge</quote> network device (see below). Again
|
---|
258 | as the &root; user, issue:
|
---|
259 | </para>
|
---|
260 |
|
---|
261 | <note>
|
---|
262 | <para>
|
---|
263 | You need to add any users who might use the <quote>bridge</quote>
|
---|
264 | network device into the
|
---|
265 | <systemitem class="groupname">kvm</systemitem> group even if
|
---|
266 | &logind; is installed.
|
---|
267 | </para>
|
---|
268 | </note>
|
---|
269 |
|
---|
270 | <screen role="root"><userinput>chgrp kvm /usr/libexec/qemu-bridge-helper &&
|
---|
271 | chmod 4750 /usr/libexec/qemu-bridge-helper</userinput></screen>
|
---|
272 |
|
---|
273 | <note>
|
---|
274 | <para>
|
---|
275 | For convenience you may want to create a symbolic link to run
|
---|
276 | the installed program. For instance (as the &root; user):
|
---|
277 | </para>
|
---|
278 |
|
---|
279 | <screen role="root"><userinput>ln -sv qemu-system-`uname -m` /usr/bin/qemu</userinput></screen>
|
---|
280 | </note>
|
---|
281 |
|
---|
282 | </sect2>
|
---|
283 |
|
---|
284 | <sect2 role="commands">
|
---|
285 | <title>Command Explanations</title>
|
---|
286 |
|
---|
287 | <para>
|
---|
288 | <parameter>--audio-drv-list=alsa --disable-pa</parameter>: This switch
|
---|
289 | sets the audio driver to ALSA. See below for enabling other audio drivers.
|
---|
290 | </para>
|
---|
291 |
|
---|
292 | <para>
|
---|
293 | <parameter>--enable-slirp</parameter>: This switch forces the building
|
---|
294 | system to check for <xref linkend='libslirp'/>. Remove it if you
|
---|
295 | don't need the <option>-netdev user</option> support.
|
---|
296 | </para>
|
---|
297 |
|
---|
298 | <para>
|
---|
299 | <option>--audio-drv-list=pa --disable-alsa</option>: This switch sets
|
---|
300 | the audio driver to pulseaudio. For other drivers see the
|
---|
301 | --audio-drv-list choices in the output of
|
---|
302 | <command>./configure --help</command>. The default audio driver is OSS.
|
---|
303 | To enable support for both alsa and pulseaudio, use
|
---|
304 | <option>--audio-drv-list=alsa,pa</option>.
|
---|
305 | </para>
|
---|
306 |
|
---|
307 | </sect2>
|
---|
308 |
|
---|
309 | <sect2 role="using">
|
---|
310 | <title>Using Qemu</title>
|
---|
311 |
|
---|
312 | <para>
|
---|
313 | Since using qemu means using a virtual computer, the steps to set up
|
---|
314 | the virtual machine are in close analogy with those to set up a real
|
---|
315 | computer. You'll need to decide about CPU, memory, disk, USB devices,
|
---|
316 | network card(s), screen size, etc. Once the <quote>hardware</quote> is
|
---|
317 | decided, you'll have for example to choose how to connect the machine
|
---|
318 | to internet, and/or to install an OS. In the following, we show basic
|
---|
319 | ways of performing those steps. But qemu is much more than this, and it
|
---|
320 | is strongly advised to read the qemu documentation in
|
---|
321 | <filename>/usr/share/doc/qemu-&qemu-version;/qemu-doc.html</filename>.
|
---|
322 | </para>
|
---|
323 |
|
---|
324 | <note>
|
---|
325 | <para>
|
---|
326 | It is standard practice to name the computer running qemu
|
---|
327 | <quote>host</quote> and the emulated machine running under qemu the
|
---|
328 | <quote>guest</quote>. We'll use those notations in the following.
|
---|
329 | </para>
|
---|
330 | </note>
|
---|
331 |
|
---|
332 | <note>
|
---|
333 | <para>
|
---|
334 | The following instructions assume the optional symbolic link,
|
---|
335 | <filename>qemu</filename>, has been created. Additionally,
|
---|
336 | <command>qemu</command> should be run in a graphical environment.
|
---|
337 | But it is possible to use qemu <quote>headless</quote> or through
|
---|
338 | SSH. See the documentation for the various possibilities.
|
---|
339 | </para>
|
---|
340 | </note>
|
---|
341 |
|
---|
342 | <bridgehead renderas="sect3">Disk</bridgehead>
|
---|
343 | <para>
|
---|
344 | A virtual disk may be set up in the following way:
|
---|
345 | </para>
|
---|
346 |
|
---|
347 | <screen><userinput>VDISK_SIZE=<replaceable>50G</replaceable>
|
---|
348 | VDISK_FILENAME=<replaceable>vdisk.img</replaceable>
|
---|
349 | qemu-img create -f qcow2 $VDISK_FILENAME $VDISK_SIZE</userinput></screen>
|
---|
350 |
|
---|
351 | <para>
|
---|
352 | The virtual disk size and filename should be adjusted as desired. The
|
---|
353 | actual size of the file will be less than specified, but will expand as
|
---|
354 | needed, so it is safe to put a high value.
|
---|
355 | </para>
|
---|
356 |
|
---|
357 | <bridgehead renderas="sect3">Operating System</bridgehead>
|
---|
358 | <para>
|
---|
359 | To install an operating system, download an iso image from your preferred
|
---|
360 | Linux distribution. For the purposes of this example, we'll use
|
---|
361 | <filename>Fedora-16-x86_64-Live-LXDE.iso</filename> in the current
|
---|
362 | directory. Run the following:
|
---|
363 | </para>
|
---|
364 |
|
---|
365 | <screen><userinput>qemu -enable-kvm \
|
---|
366 | -drive file=$VDISK_FILENAME \
|
---|
367 | -cdrom Fedora-16-x86_64-Live-LXDE.iso \
|
---|
368 | -boot d \
|
---|
369 | -m <replaceable>1G</replaceable></userinput></screen>
|
---|
370 |
|
---|
371 | <para>
|
---|
372 | Follow the normal installation procedures for the chosen distribution.
|
---|
373 | The <parameter>-boot</parameter> option specifies the boot order of
|
---|
374 | drives as a string of drive letters. Valid drive letters are: a, b
|
---|
375 | (floppy 1 and 2), c (first hard disk), d (first CD-ROM). The
|
---|
376 | <parameter>-m</parameter> option is the amount of memory to use for the
|
---|
377 | virtual machine. The choice depends on the load of the host. Modern
|
---|
378 | distributions should be comfortable with 1GB.
|
---|
379 | The <parameter>-enable-kvm</parameter> option allows hardware
|
---|
380 | acceleration. Without this switch, the emulation is much slower.
|
---|
381 | </para>
|
---|
382 |
|
---|
383 | <bridgehead renderas="sect3">Defining the virtual hardware</bridgehead>
|
---|
384 | <para>
|
---|
385 | The virtual machine hardware is defined by the qemu command line.
|
---|
386 | An example command is given below:
|
---|
387 | </para>
|
---|
388 |
|
---|
389 | <screen><userinput>qemu -enable-kvm \
|
---|
390 | -smp 4 \
|
---|
391 | -cpu host \
|
---|
392 | -m 1G \
|
---|
393 | -drive file=$VDISK_FILENAME \
|
---|
394 | -cdrom grub-img.iso \
|
---|
395 | -boot order=c,once=d,menu=on \
|
---|
396 | -net nic,netdev=net0 \
|
---|
397 | -netdev user,id=net0 \
|
---|
398 | -device ac97 \
|
---|
399 | -vga std \
|
---|
400 | -serial mon:stdio \
|
---|
401 | -name "fedora-16"</userinput></screen>
|
---|
402 |
|
---|
403 | <bridgehead renderas="sect3">Meaning of the command line options</bridgehead>
|
---|
404 | <para>
|
---|
405 | <parameter>-enable-kvm</parameter>: enable full KVM virtualization
|
---|
406 | support. On some hardware, it may be necessary to add the undocumented
|
---|
407 | <option>-machine smm=off</option> option in order to enable KVM.
|
---|
408 | </para>
|
---|
409 |
|
---|
410 | <para>
|
---|
411 | <parameter>-smp <N></parameter>: enable symmetric multiprocessing
|
---|
412 | with <N> CPUs.
|
---|
413 | </para>
|
---|
414 |
|
---|
415 | <para>
|
---|
416 | <parameter>-cpu <model></parameter>: simulate CPU <model>.
|
---|
417 | the list of supported models can be obtained with <option>-cpu
|
---|
418 | help</option>.
|
---|
419 | </para>
|
---|
420 |
|
---|
421 | <para>
|
---|
422 | <parameter>-drive file=<filename></parameter>: defines a virtual
|
---|
423 | disk whose image is stored in <filename><filename></filename>.
|
---|
424 | </para>
|
---|
425 |
|
---|
426 | <para>
|
---|
427 | <parameter>-cdrom grub-img.iso</parameter>: defines an iso formatted file
|
---|
428 | to use as a cdrom. Here we use a grub rescue disk, which may turn handy
|
---|
429 | when something goes wrong at boot time.
|
---|
430 | </para>
|
---|
431 |
|
---|
432 | <para>
|
---|
433 | <parameter>-boot order=c,once=d,menu=on</parameter>: defines the boot
|
---|
434 | order for the virtual BIOS.
|
---|
435 | </para>
|
---|
436 |
|
---|
437 | <para>
|
---|
438 | <parameter>-net nic,netdev=<netid></parameter>: defines a network
|
---|
439 | card connected to the network device with id <netid>.
|
---|
440 | </para>
|
---|
441 |
|
---|
442 | <para>
|
---|
443 | <parameter>-netdev user,id=<netid></parameter>: defines the
|
---|
444 | network <quote>user</quote> device. This is a virtual local network
|
---|
445 | with addresses 10.0.2.0/24, where the host has address 10.0.2.2 and
|
---|
446 | acts as a gateway to internet, and with a name server at address
|
---|
447 | 10.0.2.3, and an smb server at address 10.0.2.4. A builtin DHCP server
|
---|
448 | can allocate addresses between 10.0.2.15 and 10.0.2.31.
|
---|
449 | </para>
|
---|
450 |
|
---|
451 | <para>
|
---|
452 | <parameter>-soundhw <model></parameter>: defines the soundcard
|
---|
453 | model. The list may be obtained with <option>-soundhw help</option>.
|
---|
454 | </para>
|
---|
455 |
|
---|
456 | <para>
|
---|
457 | <parameter>-vga <type></parameter>: defines the type of VGA card
|
---|
458 | to emulate. For <parameter>-vga std</parameter>, if you are building
|
---|
459 | a Linux kernel for the guest, it's recommended to enable
|
---|
460 | <option>CONFIG_DRM_BOCHS</option> (as a part of the kernel or a kernel
|
---|
461 | module) to drive all the features of the emulated VGA card, and
|
---|
462 | <option>CONFIG_FB</option> to display the Linux console on it. The
|
---|
463 | other <option><type></option> values are not tested by the
|
---|
464 | editors and may require additional dependencies.
|
---|
465 | </para>
|
---|
466 |
|
---|
467 | <para>
|
---|
468 | <parameter>-serial mon:stdio</parameter>: sends the serial port of the
|
---|
469 | guest (<filename>/dev/ttyS0</filename> on linux guests), multiplexed with
|
---|
470 | the qemu monitor, to the standard input and output of the qemu
|
---|
471 | process.
|
---|
472 | </para>
|
---|
473 |
|
---|
474 | <para>
|
---|
475 | <parameter>-name <name></parameter>: sets the name of the guest.
|
---|
476 | This name is displayed in the guest window caption. It may be useful
|
---|
477 | if you run several guests at the same time.
|
---|
478 | </para>
|
---|
479 |
|
---|
480 | <para>
|
---|
481 | <option>-drive if=pflash,format=raw,readonly=on,file=/usr/share/qemu/edk2-x86_64-code.fd</option>: Load a
|
---|
482 | pre-built EDK2 UEFI firmware, instead of the default PC BIOS. Use
|
---|
483 | this option if you want to boot the guest OS with UEFI.
|
---|
484 | </para>
|
---|
485 |
|
---|
486 | <para>
|
---|
487 | <option>-drive file=<filename>,if=virtio</option>: Provide
|
---|
488 | Virtio interface to the guest kernel for accessing the disk image,
|
---|
489 | instead of simulating a real disk hardware. This can improve disk I/O
|
---|
490 | performance, but it requires a Virtio driver in guest kernel. Use
|
---|
491 | it instead of a plain <option>-drive</option> if the guest kernel
|
---|
492 | supports Virtio. To build a Linux kernel with Virtio support for the
|
---|
493 | guest, use
|
---|
494 | <command>make defconfig && make kvm_guest.config</command> to
|
---|
495 | create an initial kernel configuration with the Virtio drives enabled,
|
---|
496 | then make your customization. And, if the guest kernel is Linux, the
|
---|
497 | virtual disks using Virtio interface will be named
|
---|
498 | <filename>vdx</filename> in the devtmpfs, instead of
|
---|
499 | <filename>sdx</filename>.
|
---|
500 | </para>
|
---|
501 |
|
---|
502 | <para>
|
---|
503 | <option>-net nic,netdev=net0,model=virtio-net-pci</option>: Provide
|
---|
504 | Virtio interface to the guest kernel for accessing the network
|
---|
505 | interface, instead of simulating a real network interface card. This
|
---|
506 | can improve network I/O performance, but it requires a Virtio driver
|
---|
507 | in guest kernel. Use it instead of a plain <option>-net</option> if
|
---|
508 | the guest kernel supports Virtio.
|
---|
509 | </para>
|
---|
510 |
|
---|
511 | <bridgehead renderas="sect3">Controlling the Emulated Display</bridgehead>
|
---|
512 | <para>
|
---|
513 | To set the resolution of the emulated display for a Xorg server
|
---|
514 | running in the guest Linux system, read <xref linkend='xdisplay'/>.
|
---|
515 | </para>
|
---|
516 |
|
---|
517 | <bridgehead renderas="sect3">Networking</bridgehead>
|
---|
518 | <para>
|
---|
519 | The above solution for networking allows the guest to access the local
|
---|
520 | network through the host (and possibly to access internet through the
|
---|
521 | local routers), but the converse is not true. Not even the host can
|
---|
522 | access the guest, unless port forwarding is enabled. And in the case
|
---|
523 | several guests are running, they cannot communicate with each other.
|
---|
524 | Other network devices can be used for this purpose. For example, there
|
---|
525 | is the <quote>socket</quote> device, which allows several guests to
|
---|
526 | share a common virtual network. In the following, we describe in more
|
---|
527 | details how to set up the <quote>bridge</quote> device, which allows
|
---|
528 | the guests to appear as if connected to the local network. All the
|
---|
529 | commands below should be run as the <systemitem
|
---|
530 | class="username">root</systemitem> user.
|
---|
531 | </para>
|
---|
532 |
|
---|
533 | <para revision="sysv">
|
---|
534 | Set up bridging with <xref linkend="bridgeutils"/>. Only the physical
|
---|
535 | interface(s) should be set up at boot. The virtual interface(s) will be
|
---|
536 | added as needed when qemu is started.
|
---|
537 | </para>
|
---|
538 |
|
---|
539 | <para revision="systemd">
|
---|
540 | <!-- On SYS-V, IP_FORWARD is enabled by the bridge script. -->
|
---|
541 | Allow the host to forward IP packets:
|
---|
542 | </para>
|
---|
543 |
|
---|
544 | <screen role="root"
|
---|
545 | revision="systemd"><userinput>sysctl -w net.ipv4.ip_forward=1</userinput></screen>
|
---|
546 |
|
---|
547 | <para revision="systemd">
|
---|
548 | To make this permanent, add the command to
|
---|
549 | <filename>/etc/sysctl.d/60-net-forward.conf:</filename>
|
---|
550 | </para>
|
---|
551 |
|
---|
552 | <screen role="root"
|
---|
553 | revision="systemd"><userinput>cat >> /etc/sysctl.d/60-net-forward.conf << EOF
|
---|
554 | <literal>net.ipv4.ip_forward=1</literal>
|
---|
555 | EOF</userinput></screen>
|
---|
556 |
|
---|
557 | <para>
|
---|
558 | Set up a required configuration file:
|
---|
559 | </para>
|
---|
560 |
|
---|
561 | <!-- /etc/qemu has not been installed by "make install" since version 2.4 -->
|
---|
562 | <screen role="root"><userinput>install -vdm 755 /etc/qemu &&
|
---|
563 | echo allow br0 > /etc/qemu/bridge.conf</userinput></screen>
|
---|
564 |
|
---|
565 | <para>
|
---|
566 | In the qemu command line above, replace the switch
|
---|
567 | <parameter>-netdev user,...</parameter> with
|
---|
568 | <parameter>-netdev bridge,...</parameter>.
|
---|
569 | </para>
|
---|
570 |
|
---|
571 | </sect2>
|
---|
572 |
|
---|
573 | <sect2 role="content">
|
---|
574 | <title>Contents</title>
|
---|
575 |
|
---|
576 | <segmentedlist>
|
---|
577 | <segtitle>Installed Programs</segtitle>
|
---|
578 | <segtitle>Installed Library</segtitle>
|
---|
579 | <segtitle>Installed Directories</segtitle>
|
---|
580 |
|
---|
581 | <seglistitem>
|
---|
582 | <seg>
|
---|
583 | elf2dmp,
|
---|
584 | qemu (symlink),
|
---|
585 | qemu-edid,
|
---|
586 | qemu-ga,
|
---|
587 | qemu-img,
|
---|
588 | qemu-io,
|
---|
589 | qemu-keymap,
|
---|
590 | qemu-nbd,
|
---|
591 | qemu-pr-helper,
|
---|
592 | qemu-storage-daemon, and
|
---|
593 | qemu-system-<arch>
|
---|
594 | </seg>
|
---|
595 | <seg>None</seg>
|
---|
596 | <seg>
|
---|
597 | /usr/share/qemu and
|
---|
598 | /usr/share/doc/qemu-&qemu-version; (optional)
|
---|
599 | </seg>
|
---|
600 | </seglistitem>
|
---|
601 | </segmentedlist>
|
---|
602 |
|
---|
603 | <variablelist>
|
---|
604 | <bridgehead renderas="sect3">Short Description</bridgehead>
|
---|
605 | <?dbfo list-presentation="list"?>
|
---|
606 | <?dbhtml list-presentation="table"?>
|
---|
607 |
|
---|
608 | <varlistentry id="elf2dmp">
|
---|
609 | <term><command>elf2dmp</command></term>
|
---|
610 | <listitem>
|
---|
611 | <para>
|
---|
612 | Converts files from elf to dmp format
|
---|
613 | </para>
|
---|
614 | <indexterm zone="qemu elf2dmp">
|
---|
615 | <primary sortas="b-elf2dmp">elf2dmp</primary>
|
---|
616 | </indexterm>
|
---|
617 | </listitem>
|
---|
618 | </varlistentry>
|
---|
619 |
|
---|
620 | <varlistentry id="qemu-edid">
|
---|
621 | <term><command>qemu-edid</command></term>
|
---|
622 | <listitem>
|
---|
623 | <para>
|
---|
624 | is a test tool for the qemu EDID generator
|
---|
625 | </para>
|
---|
626 | <indexterm zone="qemu qemu-edid">
|
---|
627 | <primary sortas="b-qemu-edid">qemu-edid</primary>
|
---|
628 | </indexterm>
|
---|
629 | </listitem>
|
---|
630 | </varlistentry>
|
---|
631 |
|
---|
632 | <varlistentry id="qemu-ga">
|
---|
633 | <term><command>qemu-ga</command></term>
|
---|
634 | <listitem>
|
---|
635 | <para>
|
---|
636 | implements support for QMP (QEMU Monitor Protocol) commands and
|
---|
637 | events that terminate and originate respectively within the guest
|
---|
638 | using an agent built as part of QEMU
|
---|
639 | </para>
|
---|
640 | <indexterm zone="qemu qemu-ga">
|
---|
641 | <primary sortas="b-qemu-ga">qemu-ga</primary>
|
---|
642 | </indexterm>
|
---|
643 | </listitem>
|
---|
644 | </varlistentry>
|
---|
645 |
|
---|
646 | <varlistentry id="qemu-img">
|
---|
647 | <term><command>qemu-img</command></term>
|
---|
648 | <listitem>
|
---|
649 | <para>
|
---|
650 | provides commands to manage QEMU disk images
|
---|
651 | </para>
|
---|
652 | <indexterm zone="qemu qemu-img">
|
---|
653 | <primary sortas="b-qemu-img">qemu-img</primary>
|
---|
654 | </indexterm>
|
---|
655 | </listitem>
|
---|
656 | </varlistentry>
|
---|
657 |
|
---|
658 | <varlistentry id="qemu-io">
|
---|
659 | <term><command>qemu-io</command></term>
|
---|
660 | <listitem>
|
---|
661 | <para>
|
---|
662 | is a diagnostic and manipulation program for (virtual) memory
|
---|
663 | media. It is still at an early stage of development
|
---|
664 | </para>
|
---|
665 | <indexterm zone="qemu qemu-io">
|
---|
666 | <primary sortas="b-qemu-io">qemu-io</primary>
|
---|
667 | </indexterm>
|
---|
668 | </listitem>
|
---|
669 | </varlistentry>
|
---|
670 |
|
---|
671 | <varlistentry id="qemu-keymap">
|
---|
672 | <term><command>qemu-keymap</command></term>
|
---|
673 | <listitem>
|
---|
674 | <para>
|
---|
675 | generates qemu reverse keymaps from xkb keymaps,
|
---|
676 | which can be used with the qemu "-k" command line switch
|
---|
677 | </para>
|
---|
678 | <indexterm zone="qemu qemu-keymap">
|
---|
679 | <primary sortas="b-qemu-keymap">qemu-keymap</primary>
|
---|
680 | </indexterm>
|
---|
681 | </listitem>
|
---|
682 | </varlistentry>
|
---|
683 |
|
---|
684 |
|
---|
685 | <varlistentry id="qemu-nbd">
|
---|
686 | <term><command>qemu-nbd</command></term>
|
---|
687 | <listitem>
|
---|
688 | <para>
|
---|
689 | exports Qemu disk images using the QEMU Disk Network Block
|
---|
690 | Device (NBD) protocol
|
---|
691 | </para>
|
---|
692 | <indexterm zone="qemu qemu-nbd">
|
---|
693 | <primary sortas="b-qemu-nbd">qemu-nbd</primary>
|
---|
694 | </indexterm>
|
---|
695 | </listitem>
|
---|
696 | </varlistentry>
|
---|
697 |
|
---|
698 | <varlistentry id="qemu-pr-helper">
|
---|
699 | <term><command>qemu-pr-helper</command></term>
|
---|
700 | <listitem>
|
---|
701 | <para>
|
---|
702 | Implements the persistent reservation helper for QEMU
|
---|
703 | </para>
|
---|
704 | <indexterm zone="qemu qemu-pr-helper">
|
---|
705 | <primary sortas="b-qemu-pr-helper">qemu-pr-helper</primary>
|
---|
706 | </indexterm>
|
---|
707 | </listitem>
|
---|
708 | </varlistentry>
|
---|
709 |
|
---|
710 | <varlistentry id="qemu-storage-daemon">
|
---|
711 | <term><command>qemu-storage-daemon</command></term>
|
---|
712 | <listitem>
|
---|
713 | <para>
|
---|
714 | allows to modify disk images using the QEMU Monitor Protocol (QMP)
|
---|
715 | without running a VM
|
---|
716 | </para>
|
---|
717 | <indexterm zone="qemu qemu-storage-daemon">
|
---|
718 | <primary sortas="b-qemu-storage-daemon">qemu-storage-daemon</primary>
|
---|
719 | </indexterm>
|
---|
720 | </listitem>
|
---|
721 | </varlistentry>
|
---|
722 |
|
---|
723 | <varlistentry id="qemu-system">
|
---|
724 | <term><command>qemu-system-x86_64</command></term>
|
---|
725 | <listitem>
|
---|
726 | <para>
|
---|
727 | is the QEMU PC System emulator
|
---|
728 | </para>
|
---|
729 | <indexterm zone="qemu qemu-system">
|
---|
730 | <primary sortas="b-qemu-system">qemu-system-x86_64</primary>
|
---|
731 | </indexterm>
|
---|
732 | </listitem>
|
---|
733 | </varlistentry>
|
---|
734 |
|
---|
735 | </variablelist>
|
---|
736 |
|
---|
737 | </sect2>
|
---|
738 |
|
---|
739 | </sect1>
|
---|