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