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