[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 " ">
|
---|
[27ed278] | 9 | <!ENTITY qemu-md5sum "d41853bffb18878dd1ff7afc2eb41f1a">
|
---|
[d5c360b4] | 10 | <!ENTITY qemu-size "121 MB">
|
---|
[27ed278] | 11 | <!ENTITY qemu-buildsize "2.5 GB (365 MB installed)">
|
---|
| 12 | <!ENTITY qemu-time "1.6 SBU (add 2.4 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">
|
---|
[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 \
|
---|
[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:
|
---|
[ca19f43] | 244 | <command>ninja test</command>. Two migration tests are known to fail.
|
---|
[43ef29db] | 245 | </para>
|
---|
[d28198d3] | 246 |
|
---|
[9a04a8e9] | 247 | <para>
|
---|
[ca19f43] | 248 | Now, as the &root; user:
|
---|
[9a04a8e9] | 249 | </para>
|
---|
| 250 |
|
---|
[b4c31a6] | 251 | <screen role="root"><userinput>make install</userinput></screen>
|
---|
[d129835c] | 252 | <!-- now in LFS
|
---|
[9a04a8e9] | 253 | <para>
|
---|
[b4c31a6] | 254 | You will also need to add an Udev rule so that the KVM device gets correct
|
---|
[1f1f2230] | 255 | permissions. As the &root; user, issue:
|
---|
[9a04a8e9] | 256 | </para>
|
---|
| 257 |
|
---|
[b1643e3] | 258 | <screen role="root"><userinput>cat > /etc/udev/rules.d/65-kvm.rules << "EOF"
|
---|
[009eb04] | 259 | <literal>KERNEL=="kvm", GROUP="kvm", MODE="0660"</literal>
|
---|
[9a04a8e9] | 260 | EOF</userinput></screen>
|
---|
[d129835c] | 261 | -->
|
---|
[b4c31a6] | 262 | <para>
|
---|
| 263 | Change the permissions and ownership of a helper script, which is needed
|
---|
[1f1f2230] | 264 | when using the <quote>bridge</quote> network device (see below). Again
|
---|
| 265 | as the &root; user, issue:
|
---|
[b4c31a6] | 266 | </para>
|
---|
| 267 |
|
---|
[d129835c] | 268 | <note>
|
---|
| 269 | <para>
|
---|
| 270 | You need to add any users who might use the <quote>bridge</quote>
|
---|
| 271 | network device into the
|
---|
| 272 | <systemitem class="groupname">kvm</systemitem> group even if
|
---|
| 273 | &logind; is installed.
|
---|
| 274 | </para>
|
---|
| 275 | </note>
|
---|
| 276 |
|
---|
[b4c31a6] | 277 | <screen role="root"><userinput>chgrp kvm /usr/libexec/qemu-bridge-helper &&
|
---|
| 278 | chmod 4750 /usr/libexec/qemu-bridge-helper</userinput></screen>
|
---|
| 279 |
|
---|
[8ee3e19c] | 280 | <note>
|
---|
[47274444] | 281 | <para>
|
---|
[542bb708] | 282 | For convenience you may want to create a symbolic link to run
|
---|
[1f1f2230] | 283 | the installed program. For instance (as the &root; user):
|
---|
[542bb708] | 284 | </para>
|
---|
[d28198d3] | 285 |
|
---|
[10f9bb45] | 286 | <screen role="root"><userinput>ln -sv qemu-system-`uname -m` /usr/bin/qemu</userinput></screen>
|
---|
[d28198d3] | 287 | </note>
|
---|
| 288 |
|
---|
| 289 | </sect2>
|
---|
| 290 |
|
---|
[6a54383] | 291 | <sect2 role="commands">
|
---|
| 292 | <title>Command Explanations</title>
|
---|
| 293 |
|
---|
[a29d9e0] | 294 | <para>
|
---|
[1f1f2230] | 295 | <parameter>--audio-drv-list=alsa --disable-pa</parameter>: This switch
|
---|
| 296 | sets the audio driver to ALSA. See below for enabling other audio drivers.
|
---|
[9b13441] | 297 | </para>
|
---|
[6a54383] | 298 |
|
---|
[f9865e2] | 299 | <para>
|
---|
[1f1f2230] | 300 | <option>--audio-drv-list=pa --disable-alsa</option>: This switch sets
|
---|
| 301 | the audio driver to pulseaudio. For other drivers see the
|
---|
| 302 | --audio-drv-list choices in the output of
|
---|
| 303 | <command>./configure --help</command>. The default audio driver is OSS.
|
---|
| 304 | To enable support for both alsa and pulseaudio, use
|
---|
[f9865e2] | 305 | <option>--audio-drv-list=alsa,pa</option>.
|
---|
| 306 | </para>
|
---|
| 307 |
|
---|
[9b13441] | 308 | </sect2>
|
---|
[6a54383] | 309 |
|
---|
[b4c31a6] | 310 | <sect2 role="using">
|
---|
| 311 | <title>Using Qemu</title>
|
---|
| 312 |
|
---|
| 313 | <para>
|
---|
| 314 | Since using qemu means using a virtual computer, the steps to set up
|
---|
| 315 | the virtual machine are in close analogy with those to set up a real
|
---|
| 316 | computer. You'll need to decide about CPU, memory, disk, USB devices,
|
---|
| 317 | network card(s), screen size, etc. Once the <quote>hardware</quote> is
|
---|
| 318 | decided, you'll have for example to choose how to connect the machine
|
---|
| 319 | to internet, and/or to install an OS. In the following, we show basic
|
---|
| 320 | ways of performing those steps. But qemu is much more than this, and it
|
---|
| 321 | is strongly advised to read the qemu documentation in
|
---|
| 322 | <filename>/usr/share/doc/qemu-&qemu-version;/qemu-doc.html</filename>.
|
---|
| 323 | </para>
|
---|
[d28198d3] | 324 |
|
---|
[b4c31a6] | 325 | <note>
|
---|
| 326 | <para>
|
---|
| 327 | It is standard practice to name the computer running qemu
|
---|
| 328 | <quote>host</quote> and the emulated machine running under qemu the
|
---|
| 329 | <quote>guest</quote>. We'll use those notations in the following.
|
---|
| 330 | </para>
|
---|
| 331 | </note>
|
---|
[d28198d3] | 332 |
|
---|
[b4c31a6] | 333 | <note>
|
---|
| 334 | <para>
|
---|
| 335 | The following instructions assume the optional symbolic link,
|
---|
| 336 | <filename>qemu</filename>, has been created. Additionally,
|
---|
[1f1f2230] | 337 | <command>qemu</command> should be run in a graphical environment.
|
---|
| 338 | But it is possible to use qemu <quote>headless</quote> or through
|
---|
| 339 | SSH. See the documentation for the various possibilities.
|
---|
[b4c31a6] | 340 | </para>
|
---|
| 341 | </note>
|
---|
[d28198d3] | 342 |
|
---|
[b4c31a6] | 343 | <bridgehead renderas="sect3">Disk</bridgehead>
|
---|
| 344 | <para>
|
---|
| 345 | A virtual disk may be set up in the following way:
|
---|
| 346 | </para>
|
---|
[d28198d3] | 347 |
|
---|
[b4c31a6] | 348 | <screen><userinput>VDISK_SIZE=<replaceable>50G</replaceable>
|
---|
| 349 | VDISK_FILENAME=<replaceable>vdisk.img</replaceable>
|
---|
| 350 | qemu-img create -f qcow2 $VDISK_FILENAME $VDISK_SIZE</userinput></screen>
|
---|
[d28198d3] | 351 |
|
---|
[b4c31a6] | 352 | <para>
|
---|
[9d6565bf] | 353 | The virtual disk size and filename should be adjusted as desired. The
|
---|
[b4c31a6] | 354 | actual size of the file will be less than specified, but will expand as
|
---|
| 355 | needed, so it is safe to put a high value.
|
---|
| 356 | </para>
|
---|
| 357 |
|
---|
| 358 | <bridgehead renderas="sect3">Operating System</bridgehead>
|
---|
| 359 | <para>
|
---|
[0639bb6] | 360 | To install an operating system, download an iso image from your preferred
|
---|
[b4c31a6] | 361 | Linux distribution. For the purposes of this example, we'll use
|
---|
| 362 | <filename>Fedora-16-x86_64-Live-LXDE.iso</filename> in the current
|
---|
| 363 | directory. Run the following:
|
---|
| 364 | </para>
|
---|
[d28198d3] | 365 |
|
---|
[b4c31a6] | 366 | <screen><userinput>qemu -enable-kvm \
|
---|
| 367 | -drive file=$VDISK_FILENAME \
|
---|
[0d7900a] | 368 | -cdrom Fedora-16-x86_64-Live-LXDE.iso \
|
---|
[d28198d3] | 369 | -boot d \
|
---|
[b4c31a6] | 370 | -m <replaceable>1G</replaceable></userinput></screen>
|
---|
| 371 |
|
---|
| 372 | <para>
|
---|
| 373 | Follow the normal installation procedures for the chosen distribution.
|
---|
| 374 | The <parameter>-boot</parameter> option specifies the boot order of
|
---|
| 375 | drives as a string of drive letters. Valid drive letters are: a, b
|
---|
| 376 | (floppy 1 and 2), c (first hard disk), d (first CD-ROM). The
|
---|
| 377 | <parameter>-m</parameter> option is the amount of memory to use for the
|
---|
| 378 | virtual machine. The choice depends on the load of the host. Modern
|
---|
| 379 | distributions should be comfortable with 1GB.
|
---|
| 380 | The <parameter>-enable-kvm</parameter> option allows hardware
|
---|
| 381 | acceleration. Without this switch, the emulation is much slower.
|
---|
| 382 | </para>
|
---|
| 383 |
|
---|
| 384 | <bridgehead renderas="sect3">Defining the virtual hardware</bridgehead>
|
---|
| 385 | <para>
|
---|
| 386 | The virtual machine hardware is defined by the qemu command line.
|
---|
| 387 | An example command is given below:
|
---|
| 388 | </para>
|
---|
| 389 |
|
---|
| 390 | <screen><userinput>qemu -enable-kvm \
|
---|
| 391 | -smp 4 \
|
---|
| 392 | -cpu host \
|
---|
| 393 | -m 1G \
|
---|
| 394 | -drive file=$VDISK_FILENAME \
|
---|
| 395 | -cdrom grub-img.iso \
|
---|
| 396 | -boot order=c,once=d,menu=on \
|
---|
| 397 | -net nic,netdev=net0 \
|
---|
| 398 | -netdev user,id=net0 \
|
---|
[42326ce] | 399 | -device ac97 \
|
---|
[b4c31a6] | 400 | -vga std \
|
---|
| 401 | -serial mon:stdio \
|
---|
| 402 | -name "fedora-16"</userinput></screen>
|
---|
| 403 |
|
---|
| 404 | <bridgehead renderas="sect3">Meaning of the command line options</bridgehead>
|
---|
| 405 | <para>
|
---|
| 406 | <parameter>-enable-kvm</parameter>: enable full KVM virtualization
|
---|
| 407 | support. On some hardware, it may be necessary to add the undocumented
|
---|
| 408 | <option>-machine smm=off</option> option in order to enable KVM.
|
---|
| 409 | </para>
|
---|
| 410 |
|
---|
| 411 | <para>
|
---|
| 412 | <parameter>-smp <N></parameter>: enable symmetric multiprocessing
|
---|
| 413 | with <N> CPUs.
|
---|
| 414 | </para>
|
---|
| 415 |
|
---|
| 416 | <para>
|
---|
| 417 | <parameter>-cpu <model></parameter>: simulate CPU <model>.
|
---|
| 418 | the list of supported models can be obtained with <option>-cpu
|
---|
| 419 | help</option>.
|
---|
| 420 | </para>
|
---|
| 421 |
|
---|
| 422 | <para>
|
---|
| 423 | <parameter>-drive file=<filename></parameter>: defines a virtual
|
---|
| 424 | disk whose image is stored in <filename><filename></filename>.
|
---|
| 425 | </para>
|
---|
| 426 |
|
---|
| 427 | <para>
|
---|
[b9c353b] | 428 | <parameter>-cdrom grub-img.iso</parameter>: defines an iso formatted file
|
---|
[b4c31a6] | 429 | to use as a cdrom. Here we use a grub rescue disk, which may turn handy
|
---|
| 430 | when something goes wrong at boot time.
|
---|
| 431 | </para>
|
---|
| 432 |
|
---|
| 433 | <para>
|
---|
| 434 | <parameter>-boot order=c,once=d,menu=on</parameter>: defines the boot
|
---|
| 435 | order for the virtual BIOS.
|
---|
| 436 | </para>
|
---|
| 437 |
|
---|
| 438 | <para>
|
---|
| 439 | <parameter>-net nic,netdev=<netid></parameter>: defines a network
|
---|
| 440 | card connected to the network device with id <netid>.
|
---|
| 441 | </para>
|
---|
| 442 |
|
---|
| 443 | <para>
|
---|
| 444 | <parameter>-netdev user,id=<netid></parameter>: defines the
|
---|
| 445 | network <quote>user</quote> device. This is a virtual local network
|
---|
| 446 | with addresses 10.0.2.0/24, where the host has address 10.0.2.2 and
|
---|
| 447 | acts as a gateway to internet, and with a name server at address
|
---|
| 448 | 10.0.2.3, and an smb server at address 10.0.2.4. A builtin DHCP server
|
---|
| 449 | can allocate addresses between 10.0.2.15 and 10.0.2.31.
|
---|
| 450 | </para>
|
---|
| 451 |
|
---|
| 452 | <para>
|
---|
| 453 | <parameter>-soundhw <model></parameter>: defines the soundcard
|
---|
| 454 | model. The list may be obtained with <option>-soundhw help</option>.
|
---|
| 455 | </para>
|
---|
| 456 |
|
---|
| 457 | <para>
|
---|
[f1f1519] | 458 | <parameter>-vga <type></parameter>: defines the type of VGA card
|
---|
| 459 | to emulate. For <parameter>-vga std</parameter>, if you are building
|
---|
| 460 | a Linux kernel for the guest, it's recommended to enable
|
---|
| 461 | <option>CONFIG_DRM_BOCHS</option> (as a part of the kernel or a kernel
|
---|
| 462 | module) to drive all the features of the emulated VGA card, and
|
---|
| 463 | <option>CONFIG_FB</option> to display the Linux console on it. The
|
---|
| 464 | other <option><type></option> values are not tested by the
|
---|
| 465 | editors and may require additional dependencies.
|
---|
[b4c31a6] | 466 | </para>
|
---|
| 467 |
|
---|
| 468 | <para>
|
---|
| 469 | <parameter>-serial mon:stdio</parameter>: sends the serial port of the
|
---|
| 470 | guest (<filename>/dev/ttyS0</filename> on linux guests), multiplexed with
|
---|
| 471 | the qemu monitor, to the standard input and output of the qemu
|
---|
| 472 | process.
|
---|
| 473 | </para>
|
---|
| 474 |
|
---|
| 475 | <para>
|
---|
| 476 | <parameter>-name <name></parameter>: sets the name of the guest.
|
---|
| 477 | This name is displayed in the guest window caption. It may be useful
|
---|
| 478 | if you run several guests at the same time.
|
---|
| 479 | </para>
|
---|
| 480 |
|
---|
[46a8304] | 481 | <para>
|
---|
| 482 | <option>-pflash /usr/share/qemu/edk2-x86_64-code.fd</option>: Load a
|
---|
[b38aed5] | 483 | pre-built EDK2 UEFI firmware, instead of the default PC BIOS. Use
|
---|
[46a8304] | 484 | this option if you want to boot the guest OS with UEFI.
|
---|
| 485 | </para>
|
---|
| 486 |
|
---|
[10311fa] | 487 | <para>
|
---|
| 488 | <option>-drive file=<filename>,if=virtio</option>: Provide
|
---|
| 489 | Virtio interface to the guest kernel for accessing the disk image,
|
---|
| 490 | instead of simulating a real disk hardware. This can improve disk I/O
|
---|
| 491 | performance, but it requires a Virtio driver in guest kernel. Use
|
---|
| 492 | it instead of a plain <option>-drive</option> if the guest kernel
|
---|
[8cffdfa] | 493 | supports Virtio. To build a Linux kernel with Virtio support for the
|
---|
| 494 | guest, use
|
---|
| 495 | <command>make defconfig && make kvm_guest.config</command> to
|
---|
| 496 | create an initial kernel configuration with the Virtio drives enabled,
|
---|
| 497 | then make your customization. And, if the guest kernel is Linux, the
|
---|
| 498 | virtual disks using Virtio interface will be named
|
---|
| 499 | <filename>vdx</filename> in the devtmpfs, instead of
|
---|
| 500 | <filename>sdx</filename>.
|
---|
[10311fa] | 501 | </para>
|
---|
| 502 |
|
---|
| 503 | <para>
|
---|
| 504 | <option>-net nic,netdev=net0,model=virtio-net-pci</option>: Provide
|
---|
| 505 | Virtio interface to the guest kernel for accessing the network
|
---|
| 506 | interface, instead of simulating a real network interface card. This
|
---|
| 507 | can improve network I/O performance, but it requires a Virtio driver
|
---|
| 508 | in guest kernel. Use it instead of a plain <option>-net</option> if
|
---|
| 509 | the guest kernel supports Virtio.
|
---|
| 510 | </para>
|
---|
| 511 |
|
---|
[0639bb6] | 512 | <bridgehead renderas="sect3">Controlling the Emulated Display</bridgehead>
|
---|
[b4c31a6] | 513 | <para>
|
---|
[5c7ad04] | 514 | To set the resolution of the emulated display for a Xorg server
|
---|
| 515 | running in the guest Linux system, read <xref linkend='xdisplay'/>.
|
---|
[b4c31a6] | 516 | </para>
|
---|
[d28198d3] | 517 |
|
---|
[b4c31a6] | 518 | <bridgehead renderas="sect3">Networking</bridgehead>
|
---|
| 519 | <para>
|
---|
[449c552] | 520 | The above solution for networking allows the guest to access the local
|
---|
[b4c31a6] | 521 | network through the host (and possibly to access internet through the
|
---|
| 522 | local routers), but the converse is not true. Not even the host can
|
---|
| 523 | access the guest, unless port forwarding is enabled. And in the case
|
---|
| 524 | several guests are running, they cannot communicate with each other.
|
---|
| 525 | Other network devices can be used for this purpose. For example, there
|
---|
| 526 | is the <quote>socket</quote> device, which allows several guests to
|
---|
| 527 | share a common virtual network. In the following, we describe in more
|
---|
| 528 | details how to set up the <quote>bridge</quote> device, which allows
|
---|
| 529 | the guests to appear as if connected to the local network. All the
|
---|
| 530 | commands below should be run as the <systemitem
|
---|
| 531 | class="username">root</systemitem> user.
|
---|
| 532 | </para>
|
---|
[0d7900a] | 533 |
|
---|
[b4c31a6] | 534 | <para revision="sysv">
|
---|
| 535 | Set up bridging with <xref linkend="bridgeutils"/>. Only the physical
|
---|
| 536 | interface(s) should be set up at boot. The virtual interface(s) will be
|
---|
| 537 | added as needed when qemu is started.
|
---|
| 538 | </para>
|
---|
| 539 |
|
---|
[47274444] | 540 | <para revision="systemd">
|
---|
| 541 | <!-- On SYS-V, IP_FORWARD is enabled by the bridge script. -->
|
---|
[b4c31a6] | 542 | Allow the host to forward IP packets:
|
---|
| 543 | </para>
|
---|
[d28198d3] | 544 |
|
---|
[b4c31a6] | 545 | <screen role="root"
|
---|
| 546 | revision="systemd"><userinput>sysctl -w net.ipv4.ip_forward=1</userinput></screen>
|
---|
[d28198d3] | 547 |
|
---|
[b4c31a6] | 548 | <para revision="systemd">
|
---|
| 549 | To make this permanent, add the command to
|
---|
| 550 | <filename>/etc/sysctl.d/60-net-forward.conf:</filename>
|
---|
| 551 | </para>
|
---|
[6e5e4d2] | 552 |
|
---|
[b4c31a6] | 553 | <screen role="root"
|
---|
| 554 | revision="systemd"><userinput>cat >> /etc/sysctl.d/60-net-forward.conf << EOF
|
---|
[51dfb3e] | 555 | <literal>net.ipv4.ip_forward=1</literal>
|
---|
[6e5e4d2] | 556 | EOF</userinput></screen>
|
---|
| 557 |
|
---|
[b4c31a6] | 558 | <para>
|
---|
| 559 | Set up a required configuration file:
|
---|
| 560 | </para>
|
---|
[670f775] | 561 |
|
---|
[3a87232] | 562 | <!-- /etc/qemu has not been installed by "make install" since version 2.4 -->
|
---|
| 563 | <screen role="root"><userinput>install -vdm 755 /etc/qemu &&
|
---|
| 564 | echo allow br0 > /etc/qemu/bridge.conf</userinput></screen>
|
---|
[670f775] | 565 |
|
---|
[b4c31a6] | 566 | <para>
|
---|
[1f1f2230] | 567 | In the qemu command line above, replace the switch
|
---|
| 568 | <parameter>-netdev user,...</parameter> with
|
---|
| 569 | <parameter>-netdev bridge,...</parameter>.
|
---|
[b4c31a6] | 570 | </para>
|
---|
[d28198d3] | 571 |
|
---|
| 572 | </sect2>
|
---|
| 573 |
|
---|
| 574 | <sect2 role="content">
|
---|
| 575 | <title>Contents</title>
|
---|
| 576 |
|
---|
| 577 | <segmentedlist>
|
---|
[9b13441] | 578 | <segtitle>Installed Programs</segtitle>
|
---|
| 579 | <segtitle>Installed Library</segtitle>
|
---|
[d28198d3] | 580 | <segtitle>Installed Directories</segtitle>
|
---|
| 581 |
|
---|
| 582 | <seglistitem>
|
---|
[9b13441] | 583 | <seg>
|
---|
[a541e080] | 584 | elf2dmp,
|
---|
[10f9bb45] | 585 | qemu (symlink),
|
---|
[a541e080] | 586 | qemu-edid,
|
---|
[9b13441] | 587 | qemu-ga,
|
---|
| 588 | qemu-img,
|
---|
| 589 | qemu-io,
|
---|
[a541e080] | 590 | qemu-keymap,
|
---|
[9b13441] | 591 | qemu-nbd,
|
---|
[a541e080] | 592 | qemu-pr-helper,
|
---|
| 593 | qemu-storage-daemon, and
|
---|
| 594 | qemu-system-<arch>
|
---|
[9b13441] | 595 | </seg>
|
---|
[b4c31a6] | 596 | <seg>None</seg>
|
---|
[9b13441] | 597 | <seg>
|
---|
[b4c31a6] | 598 | /usr/share/qemu and
|
---|
[a541e080] | 599 | /usr/share/doc/qemu-&qemu-version; (optional)
|
---|
[9b13441] | 600 | </seg>
|
---|
[d28198d3] | 601 | </seglistitem>
|
---|
| 602 | </segmentedlist>
|
---|
| 603 |
|
---|
| 604 | <variablelist>
|
---|
| 605 | <bridgehead renderas="sect3">Short Description</bridgehead>
|
---|
| 606 | <?dbfo list-presentation="list"?>
|
---|
| 607 | <?dbhtml list-presentation="table"?>
|
---|
| 608 |
|
---|
[a541e080] | 609 | <varlistentry id="elf2dmp">
|
---|
| 610 | <term><command>elf2dmp</command></term>
|
---|
| 611 | <listitem>
|
---|
| 612 | <para>
|
---|
| 613 | Converts files from elf to dmp format
|
---|
| 614 | </para>
|
---|
| 615 | <indexterm zone="qemu elf2dmp">
|
---|
| 616 | <primary sortas="b-elf2dmp">elf2dmp</primary>
|
---|
| 617 | </indexterm>
|
---|
| 618 | </listitem>
|
---|
| 619 | </varlistentry>
|
---|
[b4c31a6] | 620 |
|
---|
[f9865e2] | 621 | <varlistentry id="qemu-edid">
|
---|
| 622 | <term><command>qemu-edid</command></term>
|
---|
| 623 | <listitem>
|
---|
[47274444] | 624 | <para>
|
---|
[4c24eb0a] | 625 | is a test tool for the qemu EDID generator
|
---|
[47274444] | 626 | </para>
|
---|
[f9865e2] | 627 | <indexterm zone="qemu qemu-edid">
|
---|
| 628 | <primary sortas="b-qemu-edid">qemu-edid</primary>
|
---|
| 629 | </indexterm>
|
---|
| 630 | </listitem>
|
---|
| 631 | </varlistentry>
|
---|
| 632 |
|
---|
[d28198d3] | 633 | <varlistentry id="qemu-ga">
|
---|
| 634 | <term><command>qemu-ga</command></term>
|
---|
| 635 | <listitem>
|
---|
[47274444] | 636 | <para>
|
---|
| 637 | implements support for QMP (QEMU Monitor Protocol) commands and
|
---|
| 638 | events that terminate and originate respectively within the guest
|
---|
[4c24eb0a] | 639 | using an agent built as part of QEMU
|
---|
[47274444] | 640 | </para>
|
---|
[2f6053d] | 641 | <indexterm zone="qemu qemu-ga">
|
---|
[d28198d3] | 642 | <primary sortas="b-qemu-ga">qemu-ga</primary>
|
---|
| 643 | </indexterm>
|
---|
| 644 | </listitem>
|
---|
| 645 | </varlistentry>
|
---|
| 646 |
|
---|
| 647 | <varlistentry id="qemu-img">
|
---|
| 648 | <term><command>qemu-img</command></term>
|
---|
| 649 | <listitem>
|
---|
[47274444] | 650 | <para>
|
---|
[4c24eb0a] | 651 | provides commands to manage QEMU disk images
|
---|
[47274444] | 652 | </para>
|
---|
[2f6053d] | 653 | <indexterm zone="qemu qemu-img">
|
---|
[d28198d3] | 654 | <primary sortas="b-qemu-img">qemu-img</primary>
|
---|
| 655 | </indexterm>
|
---|
| 656 | </listitem>
|
---|
| 657 | </varlistentry>
|
---|
| 658 |
|
---|
| 659 | <varlistentry id="qemu-io">
|
---|
| 660 | <term><command>qemu-io</command></term>
|
---|
| 661 | <listitem>
|
---|
[47274444] | 662 | <para>
|
---|
| 663 | is a diagnostic and manipulation program for (virtual) memory
|
---|
[9d6565bf] | 664 | media. It is still at an early stage of development
|
---|
[47274444] | 665 | </para>
|
---|
[2f6053d] | 666 | <indexterm zone="qemu qemu-io">
|
---|
[d28198d3] | 667 | <primary sortas="b-qemu-io">qemu-io</primary>
|
---|
| 668 | </indexterm>
|
---|
| 669 | </listitem>
|
---|
| 670 | </varlistentry>
|
---|
| 671 |
|
---|
[a541e080] | 672 | <varlistentry id="qemu-keymap">
|
---|
| 673 | <term><command>qemu-keymap</command></term>
|
---|
| 674 | <listitem>
|
---|
| 675 | <para>
|
---|
| 676 | generates qemu reverse keymaps from xkb keymaps,
|
---|
| 677 | which can be used with the qemu "-k" command line switch
|
---|
| 678 | </para>
|
---|
| 679 | <indexterm zone="qemu qemu-keymap">
|
---|
| 680 | <primary sortas="b-qemu-keymap">qemu-keymap</primary>
|
---|
| 681 | </indexterm>
|
---|
| 682 | </listitem>
|
---|
| 683 | </varlistentry>
|
---|
| 684 |
|
---|
| 685 |
|
---|
[d28198d3] | 686 | <varlistentry id="qemu-nbd">
|
---|
| 687 | <term><command>qemu-nbd</command></term>
|
---|
| 688 | <listitem>
|
---|
[47274444] | 689 | <para>
|
---|
| 690 | exports Qemu disk images using the QEMU Disk Network Block
|
---|
[4c24eb0a] | 691 | Device (NBD) protocol
|
---|
[47274444] | 692 | </para>
|
---|
[2f6053d] | 693 | <indexterm zone="qemu qemu-nbd">
|
---|
[d28198d3] | 694 | <primary sortas="b-qemu-nbd">qemu-nbd</primary>
|
---|
| 695 | </indexterm>
|
---|
| 696 | </listitem>
|
---|
| 697 | </varlistentry>
|
---|
| 698 |
|
---|
[a541e080] | 699 | <varlistentry id="qemu-pr-helper">
|
---|
| 700 | <term><command>qemu-pr-helper</command></term>
|
---|
| 701 | <listitem>
|
---|
| 702 | <para>
|
---|
| 703 | Implements the persistent reservation helper for QEMU
|
---|
| 704 | </para>
|
---|
| 705 | <indexterm zone="qemu qemu-pr-helper">
|
---|
| 706 | <primary sortas="b-qemu-pr-helper">qemu-pr-helper</primary>
|
---|
| 707 | </indexterm>
|
---|
| 708 | </listitem>
|
---|
| 709 | </varlistentry>
|
---|
| 710 |
|
---|
| 711 | <varlistentry id="qemu-storage-daemon">
|
---|
| 712 | <term><command>qemu-storage-daemon</command></term>
|
---|
| 713 | <listitem>
|
---|
| 714 | <para>
|
---|
| 715 | allows to modify disk images using the QEMU Monitor Protocol (QMP)
|
---|
| 716 | without running a VM
|
---|
| 717 | </para>
|
---|
| 718 | <indexterm zone="qemu qemu-storage-daemon">
|
---|
| 719 | <primary sortas="b-qemu-storage-daemon">qemu-storage-daemon</primary>
|
---|
| 720 | </indexterm>
|
---|
| 721 | </listitem>
|
---|
| 722 | </varlistentry>
|
---|
| 723 |
|
---|
[d28198d3] | 724 | <varlistentry id="qemu-system">
|
---|
| 725 | <term><command>qemu-system-x86_64</command></term>
|
---|
| 726 | <listitem>
|
---|
[47274444] | 727 | <para>
|
---|
[4c24eb0a] | 728 | is the QEMU PC System emulator
|
---|
[47274444] | 729 | </para>
|
---|
[2f6053d] | 730 | <indexterm zone="qemu qemu-system">
|
---|
[d28198d3] | 731 | <primary sortas="b-qemu-system">qemu-system-x86_64</primary>
|
---|
| 732 | </indexterm>
|
---|
| 733 | </listitem>
|
---|
| 734 | </varlistentry>
|
---|
[27ed278] | 735 |
|
---|
[d28198d3] | 736 | </variablelist>
|
---|
| 737 |
|
---|
| 738 | </sect2>
|
---|
| 739 |
|
---|
| 740 | </sect1>
|
---|