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