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