Changeset b4c31a6 for postlfs/virtualization/qemu.xml
- Timestamp:
- 12/28/2016 10:12:33 AM (7 years ago)
- Branches:
- 10.0, 10.1, 11.0, 11.1, 11.2, 11.3, 12.0, 12.1, 8.0, 8.1, 8.2, 8.3, 8.4, 9.0, 9.1, basic, bdubbs/svn, elogind, kea, ken/TL2024, ken/inkscape-core-mods, ken/tuningfonts, lazarus, lxqt, perl-modules, plabs/newcss, plabs/python-mods, python3.11, qt5new, rahul/power-profiles-daemon, renodr/vulkan-addition, trunk, upgradedb, xry111/intltool, xry111/llvm18, xry111/soup3, xry111/test-20220226, xry111/xf86-video-removal
- Children:
- 3add494
- Parents:
- bb9afa84
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
postlfs/virtualization/qemu.xml
rbb9afa84 rb4c31a6 7 7 <!ENTITY qemu-download-http "http://wiki.qemu.org/download/qemu-&qemu-version;.tar.bz2"> 8 8 <!ENTITY qemu-download-ftp " "> 9 <!ENTITY qemu-md5sum " 08d4d06d1cb598efecd796137f4844ab">10 <!ENTITY qemu-size "2 6MB">11 <!ENTITY qemu-buildsize " 579 MB (withtests)">12 <!ENTITY qemu-time " 3.5 SBU (withtests)">9 <!ENTITY qemu-md5sum "17940dce063b6ce450a12e719a6c9c43"> 10 <!ENTITY qemu-size "27 MB"> 11 <!ENTITY qemu-buildsize "435 MB (add 315 MB for tests)"> 12 <!ENTITY qemu-time "2.1 SBU (add 1.6 SBU for tests)"> 13 13 ]> 14 14 … … 69 69 <bridgehead renderas="sect4">Recommended</bridgehead> 70 70 <para role="recommended"> 71 <xref linkend="sdl "/>71 <xref linkend="sdl2"/> 72 72 </para> 73 73 … … 86 86 <xref linkend="lzo"/>, 87 87 <xref linkend="nettle"/>, 88 <xref linkend="nss"/> (for libcacard.so),89 88 <xref linkend="mesa"/>, 90 89 <xref linkend="sdl"/>, 91 <xref linkend="vte"/>, and 92 <ulink url="http://www.libssh2.org">libssh2</ulink> 90 <xref linkend="vte"/> or <xref linkend="vte2"/>, 91 <!-- libcacard has been a standalone project since qemu-2.5.--> 92 <ulink url="https://www.spice-space.org/page/Libcacard">libcacard</ulink>, 93 and <ulink url="http://www.libssh2.org">libssh2</ulink> 93 94 </para> 94 95 … … 138 139 your system processor is required.</para> 139 140 140 <para>For networking, check that <xref linkend='bridgeutils'/> is installed 141 and the following options in the kernel configuration are enabled:</para> 141 <para> 142 To use the <quote>bridge</quote> network device, as explained below, 143 check that <xref linkend='bridgeutils'/> is installed 144 and the following options in the kernel configuration are enabled: 145 </para> 142 146 143 147 <screen><literal>[*] Networking support ---> [CONFIG_NET] … … 153 157 <title>Installation of qemu</title> 154 158 159 <para> 160 You will need a dedicated group that will contain users (other than root) 161 allowed to access the KVM device. Create this group by running the 162 following command as the 163 <systemitem class="username">root</systemitem> user: 164 </para> 165 166 <screen role="root"><userinput>groupadd -g 61 kvm</userinput></screen> 167 168 <para> 169 Add any users that might use the KVM device to that group: 170 </para> 171 172 <screen role="root"><userinput>usermod -a -G kvm <replaceable><username></replaceable></userinput></screen> 173 155 174 <para>Install <application>qemu</application> by running the following 156 175 commands:</para> … … 176 195 --target-list=$QEMU_ARCH \ 177 196 --audio-drv-list=alsa \ 197 --with-sdlabi=2.0 \ 178 198 --docdir=/usr/share/doc/qemu-&qemu-version; && 179 199 … … 186 206 </para> 187 207 188 <para>Now, as the <systemitem class="username">root</systemitem> user:</para> 208 <para> 209 Now, as the <systemitem class="username">root</systemitem> user: 210 </para> 189 211 190 212 <screen role="root"><userinput>make install</userinput></screen> 191 213 192 214 <para> 193 You will need a dedicated group that will contain users (other than root) 194 allowed to access the KVM device. Create this group by running the 195 following command as the 196 <systemitem class="username">root</systemitem> user: 197 </para> 198 199 <screen role="root"><userinput>groupadd -g 61 kvm</userinput></screen> 200 201 <para> 202 Add any users that might use the KVM device to that group: 203 </para> 204 205 <screen role="root"><userinput>usermod -a -G kvm <replaceable><username></replaceable></userinput></screen> 206 207 <para> 208 You will also need to add a Udev rule so that the KVM device gets correct 215 You will also need to add an Udev rule so that the KVM device gets correct 209 216 permissions: 210 217 </para> … … 213 220 <literal>KERNEL=="kvm", GROUP="kvm", MODE="0660"</literal> 214 221 EOF</userinput></screen> 222 223 <para> 224 Change the permissions and ownership of a helper script, which is needed 225 when using the <quote>bridge</quote> network device (see below): 226 </para> 227 228 <screen role="root"><userinput>chgrp kvm /usr/libexec/qemu-bridge-helper && 229 chmod 4750 /usr/libexec/qemu-bridge-helper</userinput></screen> 215 230 216 231 <note> … … 233 248 </para> 234 249 250 <para> 251 <parameter>--with-sdlabi=2.0</parameter>: Chooses to build with SDL-2 if 252 both SDL and SDL-2 are installed. 253 </para> 254 255 <para> 256 <option>--with-gtkabi=3.0</option>: builds with GTK+-3 if both GTK+-2 257 and GTK+-3 are installed. 258 </para> 259 235 260 </sect2> 236 261 237 <sect2 role="configuration"> 238 <title>Configuring qemu</title> 239 240 <para>To generate an image, run:</para> 241 242 <screen><userinput>qemu-img create -f qcow2 vdisk.img 10G</userinput></screen> 243 244 <para>Adjust the virtual disk size and image filename as desired. The 245 actual size of the file will be less than specified, but will expand as it 246 is used.</para> 247 248 <note><para>The following instructions assume you have created the optional 249 symbolic link, <userinput>qemu</userinput>. Additionally, you must run 250 <userinput>qemu</userinput> from an X Window System based terminal 251 (either locally or over ssh).</para></note> 252 253 <para>To install an operating system, download an iso of your choice or use 254 a pre-installed cdrom device. For the purposes of this example, use 255 Fedora 16 that is downloaded as 256 <filename>Fedora-16-x86_64-Live-LXDE.iso</filename> in the current 257 directory. Run the following:</para> 258 259 <screen><userinput>qemu -enable-kvm -hda vdisk.img \ 262 <sect2 role="using"> 263 <title>Using Qemu</title> 264 265 <para> 266 Since using qemu means using a virtual computer, the steps to set up 267 the virtual machine are in close analogy with those to set up a real 268 computer. You'll need to decide about CPU, memory, disk, USB devices, 269 network card(s), screen size, etc. Once the <quote>hardware</quote> is 270 decided, you'll have for example to choose how to connect the machine 271 to internet, and/or to install an OS. In the following, we show basic 272 ways of performing those steps. But qemu is much more than this, and it 273 is strongly advised to read the qemu documentation in 274 <filename>/usr/share/doc/qemu-&qemu-version;/qemu-doc.html</filename>. 275 </para> 276 277 <note> 278 <para> 279 It is standard practice to name the computer running qemu 280 <quote>host</quote> and the emulated machine running under qemu the 281 <quote>guest</quote>. We'll use those notations in the following. 282 </para> 283 </note> 284 285 <note> 286 <para> 287 The following instructions assume the optional symbolic link, 288 <filename>qemu</filename>, has been created. Additionally, 289 <command>qemu</command> must be run from an X Window System based 290 terminal (either locally or over ssh). 291 </para> 292 </note> 293 294 <bridgehead renderas="sect3">Disk</bridgehead> 295 <para> 296 A virtual disk may be set up in the following way: 297 </para> 298 299 <screen><userinput>VDISK_SIZE=<replaceable>50G</replaceable> 300 VDISK_FILENAME=<replaceable>vdisk.img</replaceable> 301 qemu-img create -f qcow2 $VDISK_FILENAME $VDISK_SIZE</userinput></screen> 302 303 <para> 304 The virtual disk size and filename should be ajusted as desired. The 305 actual size of the file will be less than specified, but will expand as 306 needed, so it is safe to put a high value. 307 </para> 308 309 <bridgehead renderas="sect3">Operating System</bridgehead> 310 <para> 311 To install an operating system, download an iso image from your prefered 312 Linux distribution. For the purposes of this example, we'll use 313 <filename>Fedora-16-x86_64-Live-LXDE.iso</filename> in the current 314 directory. Run the following: 315 </para> 316 317 <screen><userinput>qemu -enable-kvm \ 318 -drive file=$VDISK_FILENAME \ 260 319 -cdrom Fedora-16-x86_64-Live-LXDE.iso \ 261 320 -boot d \ 262 -m 384</userinput></screen> 263 264 <para>Follow the normal installation procedures for the chosen 265 distribution. The -boot option specifies the boot order of drives as a 266 string of drive letters. Valid drive letters are: a, b (floppy 1 and 2), c 267 (first hard disk), d (first CD-ROM). The -m option is the amount of memory 268 to use for the virtual machine. If you have sufficient memory (2G or 269 more), 1G is a reasonable value. For computers with 512MB of RAM it's safe 270 to use -m 192, or even -m 128 (the default). The -enable-kvm option allows 271 for hardware acceleration. Without this switch, the emulation is 272 relatively slow.</para> 273 274 <para>To run the newly installed operating system, run:</para> 275 276 <screen><userinput>qemu -enable-kvm vdisk.img -m 384</userinput></screen> 277 278 <para>You may have problem with <parameter>-enable-kvm</parameter>. Also, 279 you may want to define audio and video drivers, number of cpu cores and 280 threads. An alternative command to install the operating system is (see qemu 281 man page for the parameters definitions):</para> 282 283 <screen><userinput>qemu -enable-kvm \ 284 -cdrom /home/fernando/ISO/linuxmint-17.1-mate-32bit.iso \ 285 -boot order=d \ 286 -m 1G,slots=3,maxmem=4G \ 287 -machine smm=off \ 288 -soundhw es1370 \ 289 -cpu host \ 290 -smp cores=4,threads=2 \ 291 -vga std \ 292 vdisk.img</userinput></screen> 293 294 <para>One parameter not appearing in the qemu man page is 295 <parameter>-machine smm=off</parameter>, and is used to allow 296 <parameter>-enable-kvm</parameter> in some systems. In order to run the 297 machine, you can alternatively issue:</para> 298 299 <screen><userinput>qemu -enable-kvm \ 300 -machine smm=off \ 301 -boot order=d \ 302 -m 1G,slots=3,maxmem=4G \ 303 -soundhw es1370 \ 304 -cpu host \ 305 -smp cores=4,threads=2 \ 306 -vga vmware \ 307 -hda vdisk.img</userinput></screen> 308 309 <para>Sometimes, you want the machine to have different screen sizes than 310 the ones natively offered by the virtual grahics card. The example below is 311 for qemu vmware graphics card, which uses <xref 312 linkend="xorg-vmmouse-driver"/> and is set to give maximum screen size of 313 1600x900. As the <systemitem class="username">root</systemitem> user, 314 issue:</para> 321 -m <replaceable>1G</replaceable></userinput></screen> 322 323 <para> 324 Follow the normal installation procedures for the chosen distribution. 325 The <parameter>-boot</parameter> option specifies the boot order of 326 drives as a string of drive letters. Valid drive letters are: a, b 327 (floppy 1 and 2), c (first hard disk), d (first CD-ROM). The 328 <parameter>-m</parameter> option is the amount of memory to use for the 329 virtual machine. The choice depends on the load of the host. Modern 330 distributions should be comfortable with 1GB. 331 The <parameter>-enable-kvm</parameter> option allows hardware 332 acceleration. Without this switch, the emulation is much slower. 333 </para> 334 335 <bridgehead renderas="sect3">Defining the virtual hardware</bridgehead> 336 <para> 337 The virtual machine hardware is defined by the qemu command line. 338 An example command is given below: 339 </para> 340 341 <screen><userinput>qemu -enable-kvm \ 342 -smp 4 \ 343 -cpu host \ 344 -m 1G \ 345 -drive file=$VDISK_FILENAME \ 346 -cdrom grub-img.iso \ 347 -boot order=c,once=d,menu=on \ 348 -net nic,netdev=net0 \ 349 -netdev user,id=net0 \ 350 -soundhw ac97 \ 351 -vga std \ 352 -serial mon:stdio \ 353 -name "fedora-16"</userinput></screen> 354 355 <bridgehead renderas="sect3">Meaning of the command line options</bridgehead> 356 <para> 357 <parameter>-enable-kvm</parameter>: enable full KVM virtualization 358 support. On some hardware, it may be necessary to add the undocumented 359 <option>-machine smm=off</option> option in order to enable KVM. 360 </para> 361 362 <para> 363 <parameter>-smp <N></parameter>: enable symmetric multiprocessing 364 with <N> CPUs. 365 </para> 366 367 <para> 368 <parameter>-cpu <model></parameter>: simulate CPU <model>. 369 the list of supported models can be obtained with <option>-cpu 370 help</option>. 371 </para> 372 373 <para> 374 <parameter>-drive file=<filename></parameter>: defines a virtual 375 disk whose image is stored in <filename><filename></filename>. 376 </para> 377 378 <para> 379 <parameter>-cdrom grub-img.iso</parameter>: defines an iso formated file 380 to use as a cdrom. Here we use a grub rescue disk, which may turn handy 381 when something goes wrong at boot time. 382 </para> 383 384 <para> 385 <parameter>-boot order=c,once=d,menu=on</parameter>: defines the boot 386 order for the virtual BIOS. 387 </para> 388 389 <para> 390 <parameter>-net nic,netdev=<netid></parameter>: defines a network 391 card connected to the network device with id <netid>. 392 </para> 393 394 <para> 395 <parameter>-netdev user,id=<netid></parameter>: defines the 396 network <quote>user</quote> device. This is a virtual local network 397 with addresses 10.0.2.0/24, where the host has address 10.0.2.2 and 398 acts as a gateway to internet, and with a name server at address 399 10.0.2.3, and an smb server at address 10.0.2.4. A builtin DHCP server 400 can allocate addresses between 10.0.2.15 and 10.0.2.31. 401 </para> 402 403 <para> 404 <parameter>-soundhw <model></parameter>: defines the soundcard 405 model. The list may be obtained with <option>-soundhw help</option>. 406 </para> 407 408 <para> 409 <parameter>-vga <type></parameter>: defines the type of vga card 410 to emulate. 411 </para> 412 413 <para> 414 <parameter>-serial mon:stdio</parameter>: sends the serial port of the 415 guest (<filename>/dev/ttyS0</filename> on linux guests), multiplexed with 416 the qemu monitor, to the standard input and output of the qemu 417 process. 418 </para> 419 420 <para> 421 <parameter>-name <name></parameter>: sets the name of the guest. 422 This name is displayed in the guest window caption. It may be useful 423 if you run several guests at the same time. 424 </para> 425 426 <bridgehead renderas="sect3">Controling the Emulated Display</bridgehead> 427 <para> 428 It may happen that the guest window displayed by qemu does not correspond 429 to the full capability of the emulated vga card. For example, the vmware 430 card is 1600x900 capable, but only 1024x768 is displayed by default. 431 A suitable Xorg configuration on the guest allows to use the full size 432 (Note that the Xorg video driver to use is <xref 433 linkend="xorg-vmware-driver"/>): 434 </para> 315 435 316 436 <screen role="root"><userinput>cat > /usr/share/X11/xorg.conf.d/20-vmware.conf << "EOF" … … 344 464 EOF</userinput></screen> 345 465 346 <para>New sizes will be available besides the native ones. You need to 347 restart X in order to have the new sizes available.</para> 348 349 <para><!--To add networking to the instance add "-net nic -net user" to the 350 command above. -->qemu provides a DHCP server for the VM and, depending on 351 the client system, sets up networking though the host.</para> 352 353 <para>One problem with the above networking solution is that it does not 354 provide the ability to connect with the local network. To do that, there are 355 several additional steps that need to be done, all as the <systemitem 356 class="username">root</systemitem> user:</para> 357 358 <itemizedlist spacing="compact"> 359 <listitem> 360 <para>Set up bridging with <xref linkend='bridgeutils'/>.</para> 361 </listitem> 362 363 <listitem> 364 <para>Allow the host system to forward IP packets.</para> 365 366 <screen role="root"><userinput>sysctl -w net.ipv4.ip_forward=1</userinput></screen> 367 368 <para revision="sysv">To make this permanent, add the command to 369 <filename>/etc/sysctl.conf:</filename></para> 370 371 <screen role="root" revision="sysv"><userinput>cat >> /etc/sysctl.conf << EOF 466 <para> 467 New sizes will be available besides the native ones. You need to 468 restart X in order to have the new sizes available. 469 </para> 470 471 <bridgehead renderas="sect3">Networking</bridgehead> 472 <para> 473 The above solution for networking allows the guest to access the local 474 network through the host (and possibly to access internet through the 475 local routers), but the converse is not true. Not even the host can 476 access the guest, unless port forwarding is enabled. And in the case 477 several guests are running, they cannot communicate with each other. 478 Other network devices can be used for this purpose. For example, there 479 is the <quote>socket</quote> device, which allows several guests to 480 share a common virtual network. In the following, we describe in more 481 details how to set up the <quote>bridge</quote> device, which allows 482 the guests to appear as if connected to the local network. All the 483 commands below should be run as the <systemitem 484 class="username">root</systemitem> user. 485 </para> 486 487 <para revision="sysv"> 488 Set up bridging with <xref linkend="bridgeutils"/>. Only the physical 489 interface(s) should be set up at boot. The virtual interface(s) will be 490 added as needed when qemu is started. 491 </para> 492 <!-- Place holder for systemd: bridgeutils page does not have configuration 493 information for systemd: 494 <para revision="systemd"> 495 TODO 496 </para>--> 497 498 <para revision="systemd"><!-- On SYS-V, IP_FORWARD is enabled by the 499 bridge script. --> 500 Allow the host to forward IP packets: 501 </para> 502 503 <screen role="root" 504 revision="systemd"><userinput>sysctl -w net.ipv4.ip_forward=1</userinput></screen> 505 506 <para revision="systemd"> 507 To make this permanent, add the command to 508 <filename>/etc/sysctl.d/60-net-forward.conf:</filename> 509 </para> 510 511 <screen role="root" 512 revision="systemd"><userinput>cat >> /etc/sysctl.d/60-net-forward.conf << EOF 372 513 net.ipv4.ip_forward=1 373 514 EOF</userinput></screen> 374 515 375 <para revision="systemd">To make this permanent, add the command to 376 <filename>/etc/sysctl.d/60-net-forward.conf:</filename></para> 377 378 <screen role="root" revision="systemd"><userinput>cat >> /etc/sysctl.d/60-net-forward.conf << EOF 379 net.ipv4.ip_forward=1 380 EOF</userinput></screen> 381 382 383 </listitem> 384 385 <listitem> 386 <para>Allow the network connection when running as a part of the 387 kvm group:</para> 388 389 <screen role="root"><userinput>chgrp kvm /usr/libexec/qemu-bridge-helper && 390 chmod 4750 /usr/libexec/qemu-bridge-helper</userinput></screen> 391 392 </listitem> 393 394 <listitem> 395 <para>Set up a required configuration file:</para> 516 <para> 517 Set up a required configuration file: 518 </para> 396 519 397 520 <!-- /etc/qemu has not been installed by "make install" since version 2.4 --> … … 399 522 echo allow br0 > /etc/qemu/bridge.conf</userinput></screen> 400 523 401 </listitem> 402 403 <!-- 404 <listitem> 405 <para>Create scripts for qemu to attach the client network 406 device, usually visible as tap0, to the host bridge.</para> 407 408 <screen role="root"><userinput>cat > /etc/qemu-ifup << EOF 409 #!/bin/bash 410 411 switch=br0 412 413 if [ -n "\$1" ]; then 414 # Add new tap0 interface to bridge 415 /sbin/ip link set \$1 up 416 sleep 0.5s 417 /usr/sbin/brctl addif \$switch \$1 418 else 419 echo "Error: no interface specified" 420 exit 1 421 fi 422 423 exit 0 424 EOF 425 426 chmod +x /etc/qemu-ifup</userinput></screen> 427 428 <screen role="root"><userinput>cat > /etc/qemu-ifdown << EOF 429 #!/bin/bash 430 431 switch=br0 432 433 if [ -n "\$1" ]; then 434 # Remove tap0 interface from bridge 435 /usr/sbin/brctl delif \$switch \$1 436 else 437 echo "Error: no interface specified" 438 exit 1 439 fi 440 441 exit 0 442 EOF 443 444 chmod +x /etc/qemu-ifdown</userinput></screen> 445 446 </listitem> 447 </itemizedlist> 448 449 <note><para>The backslashes in the above script are for convenience 450 for cut/paste operations. The backslashes should <emphasis>not</emphasis> 451 appear in the final scripts.</para></note> 452 453 <itemizedlist spacing="compact"> --> 454 <listitem> 455 <!--<para>Start qemu with "-net nic -net tap" options. </para>--> 456 <para>Start qemu with "-net nic -net bridge" options. </para> 457 </listitem> 458 459 <listitem> 460 <para>If a connection, such as ssh, from the local network to the 461 client VM is desired, the client should be configured 462 with a static IP address.</para> 463 </listitem> 464 465 </itemizedlist> 524 <para> 525 In the command above, replace the switch <parameter>-netdev user,... 526 </parameter> with <parameter>-netdev bridge,id=net0</parameter>. 527 </para> 466 528 467 529 </sect2> … … 484 546 qemu-io, 485 547 qemu-nbd, 486 qemu-system-<arch>, 487 virtfs-proxy-helper, and 488 vscclient 548 qemu-system-<arch>, and 549 virtfs-proxy-helper 489 550 </seg> 490 <seg> libcacard.so</seg>551 <seg>None</seg> 491 552 <seg> 492 / etc/qemu and553 /usr/share/qemu and 493 554 /usr/share/doc/qemu-&qemu-version; 494 555 </seg> … … 500 561 <?dbfo list-presentation="list"?> 501 562 <?dbhtml list-presentation="table"?> 563 564 <varlistentry id="ivshmem-client"> 565 <term><command>ivshmem-client</command></term> 566 <listitem> 567 <para>is a standalone client for using the ivshmem device.</para> 568 <indexterm zone="qemu ivshmem-client"> 569 <primary sortas="b-ivshmem-client">ivshmem-client</primary> 570 </indexterm> 571 </listitem> 572 </varlistentry> 573 574 <varlistentry id="ivshmem-server"> 575 <term><command>ivshmem-server</command></term> 576 <listitem> 577 <para>is an example server for the ivshmem device.</para> 578 <indexterm zone="qemu ivshmem-server"> 579 <primary sortas="b-ivshmem-server">ivshmem-server</primary> 580 </indexterm> 581 </listitem> 582 </varlistentry> 502 583 503 584 <varlistentry id="qemu-ga"> … … 567 648 </listitem> 568 649 </varlistentry> 569 650 <!-- libcacard has been a standalone project since qemu-2.5 570 651 <varlistentry id="vscclient"> 571 652 <term><command>vscclient</command></term> … … 587 668 </indexterm> 588 669 </listitem> 589 </varlistentry> 670 </varlistentry>--> 590 671 591 672 </variablelist>
Note:
See TracChangeset
for help on using the changeset viewer.