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