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