📄 qemu-doc.texi
字号:
every disk image. The size of a snapshot in a disk image is difficultto evaluate and is not shown by @code{info snapshots} because theassociated disk sectors are shared among all the snapshots to savedisk space (otherwise each snapshot would need a full copy of all thedisk images).When using the (unrelated) @code{-snapshot} option(@ref{disk_images_snapshot_mode}), you can always make VM snapshots,but they are deleted as soon as you exit QEMU.VM snapshots currently have the following known limitations:@itemize@item They cannot cope with removable devices if they are removed orinserted after a snapshot is done.@item A few device drivers still have incomplete snapshot support so theirstate is not saved or restored properly (in particular USB).@end itemize@node qemu_img_invocation@subsection @code{qemu-img} Invocation@include qemu-img.texi@node host_drives@subsection Using host drivesIn addition to disk image files, QEMU can directly access hostdevices. We describe here the usage for QEMU version >= 0.8.3.@subsubsection LinuxOn Linux, you can directly use the host device filename instead of adisk image filename provided you have enough proviledge to accessit. For example, use @file{/dev/cdrom} to access to the CDROM or@file{/dev/fd0} for the floppy.@table @code@item CDYou can specify a CDROM device even if no CDROM is loaded. QEMU hasspecific code to detect CDROM insertion or removal. CDROM ejection bythe guest OS is supported. Currently only data CDs are supported.@item FloppyYou can specify a floppy device even if no floppy is loaded. Floppyremoval is currently not detected accurately (if you change floppywithout doing floppy access while the floppy is not loaded, the guestOS will think that the same floppy is loaded).@item Hard disksHard disks can be used. Normally you must specify the whole disk(@file{/dev/hdb} instead of @file{/dev/hdb1}) so that the guest OS cansee it as a partitioned disk. WARNING: unless you know what you do, itis better to only make READ-ONLY accesses to the hard disk otherwiseyou may corrupt your host data (use the @option{-snapshot} commandline option or modify the device permissions accordingly).@end table@subsubsection Windows@table @code@item CDThe prefered syntax is the drive letter (e.g. @file{d:}). Thealternate syntax @file{\\.\d:} is supported. @file{/dev/cdrom} issupported as an alias to the first CDROM drive.Currently there is no specific code to handle removable medias, so itis better to use the @code{change} or @code{eject} monitor commands tochange or eject media.@item Hard disksHard disks can be used with the syntax: @file{\\.\PhysicalDriveN}where @var{N} is the drive number (0 is the first hard disk).WARNING: unless you know what you do, it is better to only makeREAD-ONLY accesses to the hard disk otherwise you may corrupt yourhost data (use the @option{-snapshot} command line so that themodifications are written in a temporary file).@end table@subsubsection Mac OS X@file{/dev/cdrom} is an alias to the first CDROM. Currently there is no specific code to handle removable medias, so itis better to use the @code{change} or @code{eject} monitor commands tochange or eject media.@node disk_images_fat_images@subsection Virtual FAT disk imagesQEMU can automatically create a virtual FAT disk image from adirectory tree. In order to use it, just type:@example qemu linux.img -hdb fat:/my_directory@end exampleThen you access access to all the files in the @file{/my_directory}directory without having to copy them in a disk image or to exportthem via SAMBA or NFS. The default access is @emph{read-only}.Floppies can be emulated with the @code{:floppy:} option:@example qemu linux.img -fda fat:floppy:/my_directory@end exampleA read/write support is available for testing (beta stage) with the@code{:rw:} option:@example qemu linux.img -fda fat:floppy:rw:/my_directory@end exampleWhat you should @emph{never} do:@itemize@item use non-ASCII filenames ;@item use "-snapshot" together with ":rw:" ;@item expect it to work when loadvm'ing ;@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.@subsubsection Linux hostAs 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{sec_invocation} to have examples of command lines using theTAP network interfaces.@subsubsection Windows hostThere is a virtual ethernet driver for Windows 2000/XP systems, calledTAP-Win32. But it is not included in standard QEMU for Windows,so you will need to get it separately. It is part of OpenVPN package,so download OpenVPN from : @url{http://openvpn.net/}.@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 syntax is:@exampleqemu -kernel arch/i386/boot/bzImage -hda root-2.4.20.img -append "root=/dev/hda"@end exampleUse @option{-kernel} to provide the Linux kernel image and@option{-append} to give the kernel command line arguments. The@option{-initrd} option can be used to provide an INITRD image.When using the direct Linux boot, a disk image for the first hard disk@file{hda} is required because its boot sector is used to launch theLinux kernel.If you do not need graphical output, you can disable it and redirectthe virtual serial port and the QEMU monitor to the console with the@option{-nographic} option. The typical command line is:@exampleqemu -kernel arch/i386/boot/bzImage -hda root-2.4.20.img \ -append "root=/dev/hda console=ttyS0" -nographic@end exampleUse @key{Ctrl-a c} to switch between the serial console and themonitor (@pxref{pcsys_keys}).@node pcsys_usb@section USB emulationQEMU emulates a PCI UHCI USB controller. You can virtually plugvirtual USB devices or real host USB devices (experimental, works onlyon Linux hosts). Qemu will automatically create and connect virtual USB hubsas necessary to connect multiple USB devices.@menu* usb_devices::* host_usb_devices::@end menu@node usb_devices@subsection Connecting USB devicesUSB devices can be connected with the @option{-usbdevice} commandline optionor the @code{usb_add} monitor command. Available devices are:@table @var@item @code{mouse}Virtual Mouse. This will override the PS/2 mouse emulation when activated.@item @code{tablet}Pointer device that uses absolute coordinates (like a touchscreen).This means qemu is able to report the mouse position without havingto grab the mouse. Also overrides the PS/2 mouse emulation when activated.@item @code{disk:file}Mass storage device based on @var{file} (@pxref{disk_images})@item @code{host:bus.addr}Pass through the host device identified by @var{bus.addr}(Linux only)@item @code{host:vendor_id:product_id}Pass through the host device identified by @var{vendor_id:product_id}(Linux only)@end table@node host_usb_devices@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.If you are using Windows XP as guest OS and if you want to use highresolution modes which the Cirrus Logic BIOS does not support (i.e. >=1280x1024x16), then you should use the VESA VBE virtual graphic card(option @option{-std-vga}).@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 problemSome 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 workaround is to install a service pack for XP after a boot in safemode. Then reboot, and the problem should go away. Since there is nonetwork while in safe mode, its recommended to download the fullinstallation of SP1 or SP2 and transfer that via an ISO or using thevvfat block device ("-hdb fat:directory_which_holds_the_SP").@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.@menu* QEMU PowerPC System emulator::* Sparc32 System emulator invocation::* Sparc64 System emulator invocation::* MIPS System emulator invocation::* ARM System emulator invocation::@end menu@node QEMU PowerPC System emulator@section QEMU PowerPC System emulatorUse the executable @file{qemu-system-ppc} to simulate a complete PREPor PowerMac PowerPC system.QEMU emulates the following PowerMac peripherals:@itemize @minus@item UniNorth PCI Bridge @itemPCI VGA compatible card with VESA Bochs Extensions@item 2 PMAC IDE interfaces with hard disk and CD-ROM support@item NE2000 PCI adapters@itemNon Volatile RAM@itemVIA-CUDA with ADB keyboard and mouse.@end itemizeQEMU emulates the following PREP peripherals:@itemize @minus@item PCI Bridge@itemPCI VGA compatible card with VESA Bochs Extensions@item 2 IDE interfaces with hard disk and CD-ROM support@itemFloppy disk@item NE2000 network adapters@itemSerial port@itemPREP Non Volatile RAM@itemPC compatible keyboard and mouse.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -