📄 qemu-doc.texi
字号:
@item write to the FAT directory on the host system while accessing it with the guest system.@end itemize@node pcsys_network@section Network emulationQEMU can simulate several networks cards (NE2000 boards on the PCtarget) and can connect them to an arbitrary number of Virtual LocalArea Networks (VLANs). Host TAP devices can be connected to any QEMUVLAN. VLAN can be connected between separate instances of QEMU tosimulate large networks. For simpler usage, a non priviledged user modenetwork stack can replace the TAP device to have a basic networkconnection.@subsection VLANsQEMU simulates several VLANs. A VLAN can be symbolised as a virtualconnection between several network devices. These devices can be forexample QEMU virtual Ethernet cards or virtual Host ethernet devices(TAP devices).@subsection Using TAP network interfacesThis is the standard way to connect QEMU to a real network. QEMU addsa virtual network device on your host (called @code{tapN}), and youcan then configure it as if it was a real ethernet card.As an example, you can download the @file{linux-test-xxx.tar.gz}archive and copy the script @file{qemu-ifup} in @file{/etc} andconfigure properly @code{sudo} so that the command @code{ifconfig}contained in @file{qemu-ifup} can be executed as root. You must verifythat your host kernel supports the TAP network interfaces: thedevice @file{/dev/net/tun} must be present.See @ref{direct_linux_boot} to have an example of network use with aLinux distribution and @ref{sec_invocation} to have examples ofcommand lines using the TAP network interfaces.@subsection Using the user mode network stackBy using the option @option{-net user} (default configuration if no@option{-net} option is specified), QEMU uses a completely user modenetwork stack (you don't need root priviledge to use the virtualnetwork). The virtual network configuration is the following:@example QEMU VLAN <------> Firewall/DHCP server <-----> Internet | (10.0.2.2) | ----> DNS server (10.0.2.3) | ----> SMB server (10.0.2.4)@end exampleThe QEMU VM behaves as if it was behind a firewall which blocks allincoming connections. You can use a DHCP client to automaticallyconfigure the network in the QEMU VM. The DHCP server assign addressesto the hosts starting from 10.0.2.15.In order to check that the user mode network is working, you can pingthe address 10.0.2.2 and verify that you got an address in the range10.0.2.x from the QEMU virtual DHCP server.Note that @code{ping} is not supported reliably to the internet as itwould require root priviledges. It means you can only ping the localrouter (10.0.2.2).When using the built-in TFTP server, the router is also the TFTPserver.When using the @option{-redir} option, TCP or UDP connections can beredirected from the host to the guest. It allows for example toredirect X11, telnet or SSH connections.@subsection Connecting VLANs between QEMU instancesUsing the @option{-net socket} option, it is possible to make VLANsthat span several QEMU instances. See @ref{sec_invocation} to have abasic example.@node direct_linux_boot@section Direct Linux BootThis section explains how to launch a Linux kernel inside QEMU withouthaving to make a full bootable image. It is very useful for fast Linuxkernel testing. The QEMU network configuration is also explained.@enumerate@itemDownload the archive @file{linux-test-xxx.tar.gz} containing a Linuxkernel and a disk image. @item Optional: If you want network support (for example to launch X11 examples), youmust copy the script @file{qemu-ifup} in @file{/etc} and configureproperly @code{sudo} so that the command @code{ifconfig} contained in@file{qemu-ifup} can be executed as root. You must verify that your hostkernel supports the TUN/TAP network interfaces: the device@file{/dev/net/tun} must be present.When network is enabled, there is a virtual network connection betweenthe host kernel and the emulated kernel. The emulated kernel is seenfrom the host kernel at IP address 172.20.0.2 and the host kernel isseen from the emulated kernel at IP address 172.20.0.1.@item Launch @code{qemu.sh}. You should have the following output:@smallexample> ./qemu.sh Connected to host network interface: tun0Linux version 2.4.21 (bellard@@voyager.localdomain) (gcc version 3.2.2 20030222 @/(Red Hat @/Linux 3.2.2-5)) #5 Tue Nov 11 18:18:53 CET 2003BIOS-provided physical RAM map: BIOS-e801: 0000000000000000 - 000000000009f000 (usable) BIOS-e801: 0000000000100000 - 0000000002000000 (usable)32MB LOWMEM available.On node 0 totalpages: 8192zone(0): 4096 pages.zone(1): 4096 pages.zone(2): 0 pages.Kernel command line: root=/dev/hda sb=0x220,5,1,5 ide2=noprobe ide3=noprobe ide4=noprobe @/ide5=noprobe console=ttyS0ide_setup: ide2=noprobeide_setup: ide3=noprobeide_setup: ide4=noprobeide_setup: ide5=noprobeInitializing CPU#0Detected 2399.621 MHz processor.Console: colour EGA 80x25Calibrating delay loop... 4744.80 BogoMIPSMemory: 28872k/32768k available (1210k kernel code, 3508k reserved, 266k data, 64k init, @/0k highmem)Dentry cache hash table entries: 4096 (order: 3, 32768 bytes)Inode cache hash table entries: 2048 (order: 2, 16384 bytes)Mount cache hash table entries: 512 (order: 0, 4096 bytes)Buffer-cache hash table entries: 1024 (order: 0, 4096 bytes)Page-cache hash table entries: 8192 (order: 3, 32768 bytes)CPU: Intel Pentium Pro stepping 03Checking 'hlt' instruction... OK.POSIX conformance testing by UNIFIXLinux NET4.0 for Linux 2.4Based upon Swansea University Computer Society NET3.039Initializing RT netlink socketapm: BIOS not found.Starting kswapdJournalled Block Device driver loadedDetected PS/2 Mouse Port.pty: 256 Unix98 ptys configuredSerial driver version 5.05c (2001-07-08) with no serial options enabledttyS00 at 0x03f8 (irq = 4) is a 16450ne.c:v1.10 9/23/94 Donald Becker (becker@@scyld.com)Last modified Nov 1, 2000 by Paul GortmakerNE*000 ethercard probe at 0x300: 52 54 00 12 34 56eth0: NE2000 found at 0x300, using IRQ 9.RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksizeUniform Multi-Platform E-IDE driver Revision: 7.00beta4-2.4ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xxhda: QEMU HARDDISK, ATA DISK driveide0 at 0x1f0-0x1f7,0x3f6 on irq 14hda: attached ide-disk driver.hda: 20480 sectors (10 MB) w/256KiB Cache, CHS=20/16/63Partition check: hda:Soundblaster audio driver Copyright (C) by Hannu Savolainen 1993-1996NET4: Linux TCP/IP 1.0 for NET4.0IP Protocols: ICMP, UDP, TCP, IGMPIP: routing cache hash table of 512 buckets, 4KbytesTCP: Hash tables configured (established 2048 bind 4096)NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.EXT2-fs warning: mounting unchecked fs, running e2fsck is recommendedVFS: Mounted root (ext2 filesystem).Freeing unused kernel memory: 64k freed Linux version 2.4.21 (bellard@@voyager.localdomain) (gcc version 3.2.2 20030222 @/(Red Hat @/Linux 3.2.2-5)) #5 Tue Nov 11 18:18:53 CET 2003 QEMU Linux test distribution (based on Redhat 9) Type 'exit' to halt the system sh-2.05b# @end smallexample@itemThen you can play with the kernel inside the virtual serial console. Youcan launch @code{ls} for example. Type @key{Ctrl-a h} to have an helpabout the keys you can type inside the virtual serial console. Inparticular, use @key{Ctrl-a x} to exit QEMU and use @key{Ctrl-a b} asthe Magic SysRq key.@item If the network is enabled, launch the script @file{/etc/linuxrc} in theemulator (don't forget the leading dot):@example. /etc/linuxrc@end exampleThen enable X11 connections on your PC from the emulated Linux: @examplexhost +172.20.0.2@end exampleYou can now launch @file{xterm} or @file{xlogo} and verify that you havea real Virtual Linux system !@end enumerateNOTES:@enumerate@item A 2.5.74 kernel is also included in the archive. Justreplace the bzImage in qemu.sh to try it.@item In order to exit cleanly from qemu, you can do a @emph{shutdown} insideqemu. qemu will automatically exit when the Linux shutdown is done.@item You can boot slightly faster by disabling the probe of non present IDEinterfaces. To do so, add the following options on the kernel commandline:@exampleide1=noprobe ide2=noprobe ide3=noprobe ide4=noprobe ide5=noprobe@end example@item The example disk image is a modified version of the one made by KevinLawton for the plex86 Project (@url{www.plex86.org}).@end enumerate@node pcsys_usb@section USB emulationQEMU emulates a PCI UHCI USB controller and a 8 port USB hub connectedto it. You can virtually plug to the hub virtual USB devices or realhost USB devices (experimental, works only on Linux hosts).@subsection Using virtual USB devicesA virtual USB mouse device is available for testing in QEMU.You can try it with the following monitor commands:@example# add the mouse device(qemu) usb_add mouse # show the virtual USB devices plugged on the QEMU Virtual USB hub(qemu) info usb Device 0.3, speed 12 Mb/s# after some time you can try to remove the mouse(qemu) usb_del 0.3@end exampleThe option @option{-usbdevice} is similar to the monitor command@code{usb_add}.@subsection Using host USB devices on a Linux hostWARNING: this is an experimental feature. QEMU will slow down whenusing it. USB devices requiring real time streaming (i.e. USB VideoCameras) are not supported yet.@enumerate@item If you use an early Linux 2.4 kernel, verify that no Linux driver is actually using the USB device. A simple way to do that is simply todisable the corresponding kernel module by renaming it from @file{mydriver.o}to @file{mydriver.o.disabled}.@item Verify that @file{/proc/bus/usb} is working (most Linux distributions should enable it by default). You should see something like that:@examplels /proc/bus/usb001 devices drivers@end example@item Since only root can access to the USB devices directly, you can either launch QEMU as root or change the permissions of the USB devices you want to use. For testing, the following suffices:@examplechown -R myuid /proc/bus/usb@end example@item Launch QEMU and do in the monitor:@example info usbhost Device 1.2, speed 480 Mb/s Class 00: USB device 1234:5678, USB DISK@end exampleYou should see the list of the devices you can use (Never try to usehubs, it won't work).@item Add the device in QEMU by using:@example usb_add host:1234:5678@end exampleNormally the guest OS should report that a new USB device isplugged. You can use the option @option{-usbdevice} to do the same.@item Now you can try to use the host USB device in QEMU.@end enumerateWhen relaunching QEMU, you may have to unplug and plug again the USBdevice to make it work again (this is a bug).@node gdb_usage@section GDB usageQEMU has a primitive support to work with gdb, so that you can do'Ctrl-C' while the virtual machine is running and inspect its state.In order to use gdb, launch qemu with the '-s' option. It will wait for agdb connection:@example> qemu -s -kernel arch/i386/boot/bzImage -hda root-2.4.20.img \ -append "root=/dev/hda"Connected to host network interface: tun0Waiting gdb connection on port 1234@end exampleThen launch gdb on the 'vmlinux' executable:@example> gdb vmlinux@end exampleIn gdb, connect to QEMU:@example(gdb) target remote localhost:1234@end exampleThen you can use gdb normally. For example, type 'c' to launch the kernel:@example(gdb) c@end exampleHere are some useful tips in order to use gdb on system code:@enumerate@itemUse @code{info reg} to display all the CPU registers.@itemUse @code{x/10i $eip} to display the code at the PC position.@itemUse @code{set architecture i8086} to dump 16 bit code. Then use@code{x/10i $cs*16+*eip} to dump the code at the PC position.@end enumerate@node pcsys_os_specific@section Target OS specific information@subsection LinuxTo have access to SVGA graphic modes under X11, use the @code{vesa} orthe @code{cirrus} X11 driver. For optimal performances, use 16 bitcolor depth in the guest and the host OS.When using a 2.6 guest Linux kernel, you should add the option@code{clock=pit} on the kernel command line because the 2.6 Linuxkernels make very strict real time clock checks by default that QEMUcannot simulate exactly.When using a 2.6 guest Linux kernel, verify that the 4G/4G patch isnot activated because QEMU is slower with this patch. The QEMUAccelerator Module is also much slower in this case. Earlier FedoraCore 3 Linux kernel (< 2.6.9-1.724_FC3) were known to incorporte thispatch by default. Newer kernels don't have it.@subsection WindowsIf you have a slow host, using Windows 95 is better as it gives thebest speed. Windows 2000 is also a good choice.@subsubsection SVGA graphic modes supportQEMU emulates a Cirrus Logic GD5446 Videocard. All Windows versions starting from Windows 95 should recognizeand use this graphic card. For optimal performances, use 16 bit colordepth in the guest and the host OS.@subsubsection CPU usage reductionWindows 9x does not correctly use the CPU HLTinstruction. The result is that it takes host CPU cycles even whenidle. You can install the utility from@url{http://www.user.cityline.ru/~maxamn/amnhltm.zip} to solve thisproblem. Note that no such tool is needed for NT, 2000 or XP.@subsubsection Windows 2000 disk full problemWindows 2000 has a bug which gives a disk full problem during itsinstallation. When installing it, use the @option{-win2k-hack} QEMUoption to enable a specific workaround. After Windows 2000 isinstalled, you no longer need this option (this option slows down theIDE transfers).@subsubsection Windows 2000 shutdownWindows 2000 cannot automatically shutdown in QEMU although Windows 98can. It comes from the fact that Windows 2000 does not automaticallyuse the APM driver provided by the BIOS.In order to correct that, do the following (thanks to StruanBartlett): go to the Control Panel => Add/Remove Hardware & Next =>Add/Troubleshoot a device => Add a new device & Next => No, select thehardware from a list & Next => NT Apm/Legacy Support & Next => Next(again) a few times. Now the driver is installed and Windows 2000 nowcorrectly instructs QEMU to shutdown at the appropriate moment. @subsubsection Share a directory between Unix and WindowsSee @ref{sec_invocation} about the help of the option @option{-smb}.@subsubsection Windows XP security problemsSome releases of Windows XP install correctly but give a securityerror when booting:@exampleA problem is preventing Windows from accurately checking thelicense for this computer. Error code: 0x800703e6.@end exampleThe only known workaround is to boot in Safe modewithout networking support. Future QEMU releases are likely to correct this bug.@subsection MS-DOS and FreeDOS@subsubsection CPU usage reductionDOS does not correctly use the CPU HLT instruction. The result is thatit takes host CPU cycles even when idle. You can install the utilityfrom @url{http://www.vmware.com/software/dosidle210.zip} to solve thisproblem.@node QEMU System emulator for non PC targets@chapter QEMU System emulator for non PC targetsQEMU is a generic emulator and it emulates many non PCmachines. Most of the options are similar to the PC emulator. Thedifferences are mentionned in the following sections.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -