]> git.proxmox.com Git - qemu.git/blame - qemu-doc.texi
fixed VIA irq register access
[qemu.git] / qemu-doc.texi
CommitLineData
386405f7
FB
1\input texinfo @c -*- texinfo -*-
2
0806e3f6 3@iftex
1f673135 4@settitle QEMU CPU Emulator User Documentation
386405f7
FB
5@titlepage
6@sp 7
1f673135 7@center @titlefont{QEMU CPU Emulator User Documentation}
386405f7
FB
8@sp 3
9@end titlepage
0806e3f6 10@end iftex
386405f7
FB
11
12@chapter Introduction
13
322d0c66 14@section Features
386405f7 15
1f673135
FB
16QEMU is a FAST! processor emulator using dynamic translation to
17achieve good emulation speed.
1eb20527
FB
18
19QEMU has two operating modes:
0806e3f6
FB
20
21@itemize @minus
22
23@item
1f673135 24Full system emulation. In this mode, QEMU emulates a full system (for
b671f9ed 25example a PC), including a processor and various peripherals. It can
1f673135
FB
26be used to launch different Operating Systems without rebooting the
27PC or to debug system code.
1eb20527 28
0806e3f6 29@item
1f673135
FB
30User mode emulation (Linux host only). In this mode, QEMU can launch
31Linux processes compiled for one CPU on another CPU. It can be used to
32launch the Wine Windows API emulator (@url{http://www.winehq.org}) or
33to ease cross-compilation and cross-debugging.
1eb20527
FB
34
35@end itemize
36
7c3fc84d 37QEMU can run without an host kernel driver and yet gives acceptable
6f2f2b24 38performance.
322d0c66 39
52c00a5f
FB
40For system emulation, the following hardware targets are supported:
41@itemize
9d0a8e6f 42@item PC (x86 or x86_64 processor)
52c00a5f 43@item PREP (PowerPC processor)
9d0a8e6f
FB
44@item G3 BW PowerMac (PowerPC processor)
45@item Mac99 PowerMac (PowerPC processor, in progress)
3475187d
FB
46@item Sun4m (32-bit Sparc processor)
47@item Sun4u (64-bit Sparc processor, in progress)
9d0a8e6f 48@item Malta board (32-bit MIPS processor, in progress)
52c00a5f 49@end itemize
386405f7 50
3475187d 51For user emulation, x86, PowerPC, ARM, and Sparc32/64 CPUs are supported.
0806e3f6 52
5b9f457a
FB
53@chapter Installation
54
15a34c63
FB
55If you want to compile QEMU yourself, see @ref{compilation}.
56
1f673135
FB
57@section Linux
58
7c3fc84d
FB
59If a precompiled package is available for your distribution - you just
60have to install it. Otherwise, see @ref{compilation}.
5b9f457a 61
1f673135 62@section Windows
8cd0ac2f 63
15a34c63
FB
64Download the experimental binary installer at
65@url{http://www.freeoszoo.org/download.php}.
d691f669 66
1f673135 67@section Mac OS X
d691f669 68
15a34c63
FB
69Download the experimental binary installer at
70@url{http://www.freeoszoo.org/download.php}.
df0f11a0 71
52c00a5f 72@chapter QEMU PC System emulator invocation
1eb20527 73
0806e3f6
FB
74@section Introduction
75
76@c man begin DESCRIPTION
77
7c3fc84d 78The QEMU System emulator simulates the
b671f9ed 79following PC peripherals:
0806e3f6
FB
80
81@itemize @minus
15a34c63
FB
82@item
83i440FX host PCI bridge and PIIX3 PCI to ISA bridge
0806e3f6 84@item
15a34c63
FB
85Cirrus CLGD 5446 PCI VGA card or dummy VGA card with Bochs VESA
86extensions (hardware level, including all non standard modes).
0806e3f6
FB
87@item
88PS/2 mouse and keyboard
89@item
15a34c63 902 PCI IDE interfaces with hard disk and CD-ROM support
1f673135
FB
91@item
92Floppy disk
0806e3f6 93@item
15a34c63 94NE2000 PCI network adapters
0806e3f6 95@item
05d5818c
FB
96Serial ports
97@item
181f1558 98Soundblaster 16 card
0806e3f6
FB
99@end itemize
100
15a34c63
FB
101QEMU uses the PC BIOS from the Bochs project and the Plex86/Bochs LGPL
102VGA BIOS.
103
0806e3f6
FB
104@c man end
105
1eb20527
FB
106@section Quick Start
107
285dc330 108Download and uncompress the linux image (@file{linux.img}) and type:
0806e3f6
FB
109
110@example
285dc330 111qemu linux.img
0806e3f6
FB
112@end example
113
114Linux should boot and give you a prompt.
115
ec410fc9
FB
116@section Invocation
117
118@example
0806e3f6
FB
119@c man begin SYNOPSIS
120usage: qemu [options] [disk_image]
121@c man end
ec410fc9
FB
122@end example
123
0806e3f6 124@c man begin OPTIONS
9d4520d0 125@var{disk_image} is a raw hard disk image for IDE hard disk 0.
ec410fc9
FB
126
127General options:
128@table @option
2be3bc02
FB
129@item -fda file
130@item -fdb file
be3edd95
FB
131Use @var{file} as floppy disk 0/1 image (@xref{disk_images}). You can
132use the host floppy by using @file{/dev/fd0} as filename.
2be3bc02 133
ec410fc9
FB
134@item -hda file
135@item -hdb file
181f1558
FB
136@item -hdc file
137@item -hdd file
2be3bc02 138Use @var{file} as hard disk 0, 1, 2 or 3 image (@xref{disk_images}).
1f47a922 139
181f1558
FB
140@item -cdrom file
141Use @var{file} as CD-ROM image (you cannot use @option{-hdc} and and
be3edd95
FB
142@option{-cdrom} at the same time). You can use the host CD-ROM by
143using @file{/dev/cdrom} as filename.
181f1558 144
1f673135
FB
145@item -boot [a|c|d]
146Boot on floppy (a), hard disk (c) or CD-ROM (d). Hard disk boot is
2be3bc02 147the default.
1f47a922 148
181f1558 149@item -snapshot
1f47a922
FB
150Write to temporary files instead of disk image files. In this case,
151the raw disk image you use is not written back. You can however force
152the write back by pressing @key{C-a s} (@xref{disk_images}).
ec410fc9
FB
153
154@item -m megs
15a34c63 155Set virtual RAM size to @var{megs} megabytes. Default is 128 MB.
ec410fc9 156
0806e3f6
FB
157@item -nographic
158
159Normally, QEMU uses SDL to display the VGA output. With this option,
160you can totally disable graphical output so that QEMU is a simple
161command line application. The emulated serial port is redirected on
162the console. Therefore, you can still use QEMU to debug a Linux kernel
163with a serial console.
164
3d11d0eb
FB
165@item -k language
166
167Use keyboard layout @var{language} (for example @code{fr} for
168French). This option is only needed where it is not easy to get raw PC
169keycodes (e.g. on Macs or with some X11 servers). You don't need to
170use it on PC/Linux or PC/Windows hosts.
171
172The available layouts are:
173@example
174ar de-ch es fo fr-ca hu ja mk no pt-br sv
175da en-gb et fr fr-ch is lt nl pl ru th
176de en-us fi fr-be hr it lv nl-be pt sl tr
177@end example
178
179The default is @code{en-us}.
180
a8c490cd
FB
181@item -enable-audio
182
183The SB16 emulation is disabled by default as it may give problems with
184Windows. You can enable it manually with this option.
185
15a34c63
FB
186@item -localtime
187Set the real time clock to local time (the default is to UTC
188time). This option is needed to have correct date in MS-DOS or
189Windows.
190
d63d307f
FB
191@item -full-screen
192Start in full screen.
193
f7cce898
FB
194@item -pidfile file
195Store the QEMU process PID in @var{file}. It is useful if you launch QEMU
196from a script.
197
9d0a8e6f
FB
198@item -win2k-hack
199Use it when installing Windows 2000 to avoid a disk full bug. After
200Windows 2000 is installed, you no longer need this option (this option
201slows down the IDE transfers).
202
0806e3f6
FB
203@end table
204
1f673135
FB
205Network options:
206
207@table @option
208
209@item -n script
52c00a5f
FB
210Set TUN/TAP network init script [default=/etc/qemu-ifup]. This script
211is launched to configure the host network interface (usually tun0)
1f673135
FB
212corresponding to the virtual NE2000 card.
213
3f1a88f4
FB
214@item -nics n
215
216Simulate @var{n} network cards (the default is 1).
217
1f673135
FB
218@item -macaddr addr
219
220Set the mac address of the first interface (the format is
221aa:bb:cc:dd:ee:ff in hexa). The mac address is incremented for each
222new network interface.
223
52c00a5f
FB
224@item -tun-fd fd
225Assumes @var{fd} talks to a tap/tun host network interface and use
226it. Read @url{http://bellard.org/qemu/tetrinet.html} to have an
227example of its use.
228
229@item -user-net
15a34c63
FB
230Use the user mode network stack. This is the default if no tun/tap
231network init script is found.
52c00a5f 232
9bf05444
FB
233@item -tftp prefix
234When using the user mode network stack, activate a built-in TFTP
235server. All filenames beginning with @var{prefix} can be downloaded
236from the host to the guest using a TFTP client. The TFTP client on the
237guest must be configured in binary mode (use the command @code{bin} of
238the Unix TFTP client). The host IP address on the guest is as usual
23910.0.2.2.
240
2518bd0d
FB
241@item -smb dir
242When using the user mode network stack, activate a built-in SMB
243server so that Windows OSes can access to the host files in @file{dir}
244transparently.
245
246In the guest Windows OS, the line:
247@example
24810.0.2.4 smbserver
249@end example
250must be added in the file @file{C:\WINDOWS\LMHOSTS} (for windows 9x/Me)
251or @file{C:\WINNT\SYSTEM32\DRIVERS\ETC\LMHOSTS} (Windows NT/2000).
252
253Then @file{dir} can be accessed in @file{\\smbserver\qemu}.
254
255Note that a SAMBA server must be installed on the host OS in
256@file{/usr/sbin/smbd}. QEMU was tested succesfully with smbd version
2572.2.7a from the Red Hat 9.
258
9bf05444
FB
259@item -redir [tcp|udp]:host-port:[guest-host]:guest-port
260
261When using the user mode network stack, redirect incoming TCP or UDP
262connections to the host port @var{host-port} to the guest
263@var{guest-host} on guest port @var{guest-port}. If @var{guest-host}
264is not specified, its value is 10.0.2.15 (default address given by the
265built-in DHCP server).
266
267For example, to redirect host X11 connection from screen 1 to guest
268screen 0, use the following:
269
270@example
271# on the host
272qemu -redir tcp:6001::6000 [...]
273# this host xterm should open in the guest X11 server
274xterm -display :1
275@end example
276
277To redirect telnet connections from host port 5555 to telnet port on
278the guest, use the following:
279
280@example
281# on the host
282qemu -redir tcp:5555::23 [...]
283telnet localhost 5555
284@end example
285
286Then when you use on the host @code{telnet localhost 5555}, you
287connect to the guest telnet server.
288
52c00a5f 289@item -dummy-net
15a34c63 290Use the dummy network stack: no packet will be received by the network
52c00a5f 291cards.
1f673135
FB
292
293@end table
294
295Linux boot specific. When using this options, you can use a given
296Linux kernel without installing it in the disk image. It can be useful
297for easier testing of various kernels.
298
0806e3f6
FB
299@table @option
300
301@item -kernel bzImage
302Use @var{bzImage} as kernel image.
303
304@item -append cmdline
305Use @var{cmdline} as kernel command line
306
307@item -initrd file
308Use @var{file} as initial ram disk.
309
ec410fc9
FB
310@end table
311
15a34c63 312Debug/Expert options:
ec410fc9 313@table @option
a0a821a4
FB
314
315@item -serial dev
316Redirect the virtual serial port to host device @var{dev}. Available
317devices are:
318@table @code
319@item vc
320Virtual console
321@item pty
322[Linux only] Pseudo TTY (a new PTY is automatically allocated)
323@item null
324void device
325@item stdio
326[Unix only] standard input/output
327@end table
328The default device is @code{vc} in graphical mode and @code{stdio} in
329non graphical mode.
330
05d5818c
FB
331This option can be used several times to simulate up to 4 serials
332ports.
333
a0a821a4
FB
334@item -monitor dev
335Redirect the monitor to host device @var{dev} (same devices as the
336serial port).
337The default device is @code{vc} in graphical mode and @code{stdio} in
338non graphical mode.
339
ec410fc9 340@item -s
0806e3f6 341Wait gdb connection to port 1234 (@xref{gdb_usage}).
ec410fc9
FB
342@item -p port
343Change gdb connection port.
52c00a5f
FB
344@item -S
345Do not start CPU at startup (you must type 'c' in the monitor).
ec410fc9 346@item -d
9d4520d0 347Output log in /tmp/qemu.log
46d4767d
FB
348@item -hdachs c,h,s,[,t]
349Force hard disk 0 physical geometry (1 <= @var{c} <= 16383, 1 <=
350@var{h} <= 16, 1 <= @var{s} <= 63) and optionally force the BIOS
351translation mode (@var{t}=none, lba or auto). Usually QEMU can guess
352all thoses parameters. This option is useful for old MS-DOS disk
353images.
7c3fc84d 354
15a34c63
FB
355@item -isa
356Simulate an ISA-only system (default is PCI system).
357@item -std-vga
358Simulate a standard VGA card with Bochs VBE extensions (default is
359Cirrus Logic GD5446 PCI VGA)
d63d307f
FB
360@item -loadvm file
361Start right away with a saved state (@code{loadvm} in monitor)
ec410fc9
FB
362@end table
363
3e11db9a
FB
364@c man end
365
366@section Keys
367
368@c man begin OPTIONS
369
a1b74fe8
FB
370During the graphical emulation, you can use the following keys:
371@table @key
f9859310 372@item Ctrl-Alt-f
a1b74fe8 373Toggle full screen
a0a821a4 374
f9859310 375@item Ctrl-Alt-n
a0a821a4
FB
376Switch to virtual console 'n'. Standard console mappings are:
377@table @emph
378@item 1
379Target system display
380@item 2
381Monitor
382@item 3
383Serial port
a1b74fe8
FB
384@end table
385
f9859310 386@item Ctrl-Alt
a0a821a4
FB
387Toggle mouse and keyboard grab.
388@end table
389
3e11db9a
FB
390In the virtual consoles, you can use @key{Ctrl-Up}, @key{Ctrl-Down},
391@key{Ctrl-PageUp} and @key{Ctrl-PageDown} to move in the back log.
392
a0a821a4
FB
393During emulation, if you are using the @option{-nographic} option, use
394@key{Ctrl-a h} to get terminal commands:
ec410fc9
FB
395
396@table @key
a1b74fe8 397@item Ctrl-a h
ec410fc9 398Print this help
a1b74fe8 399@item Ctrl-a x
ec410fc9 400Exit emulatior
a1b74fe8 401@item Ctrl-a s
1f47a922 402Save disk data back to file (if -snapshot)
a1b74fe8 403@item Ctrl-a b
1f673135 404Send break (magic sysrq in Linux)
a1b74fe8 405@item Ctrl-a c
1f673135 406Switch between console and monitor
a1b74fe8
FB
407@item Ctrl-a Ctrl-a
408Send Ctrl-a
ec410fc9 409@end table
0806e3f6
FB
410@c man end
411
412@ignore
413
414@setfilename qemu
415@settitle QEMU System Emulator
416
1f673135
FB
417@c man begin SEEALSO
418The HTML documentation of QEMU for more precise information and Linux
419user mode emulator invocation.
420@c man end
421
422@c man begin AUTHOR
423Fabrice Bellard
424@c man end
425
426@end ignore
427
428@end ignore
429
1f673135
FB
430@section QEMU Monitor
431
432The QEMU monitor is used to give complex commands to the QEMU
433emulator. You can use it to:
434
435@itemize @minus
436
437@item
438Remove or insert removable medias images
439(such as CD-ROM or floppies)
440
441@item
442Freeze/unfreeze the Virtual Machine (VM) and save or restore its state
443from a disk file.
444
445@item Inspect the VM state without an external debugger.
446
447@end itemize
448
449@subsection Commands
450
451The following commands are available:
452
453@table @option
454
455@item help or ? [cmd]
456Show the help for all commands or just for command @var{cmd}.
457
458@item commit
459Commit changes to the disk images (if -snapshot is used)
460
461@item info subcommand
462show various information about the system state
463
464@table @option
465@item info network
466show the network state
467@item info block
468show the block devices
469@item info registers
470show the cpu registers
471@item info history
472show the command line history
473@end table
474
475@item q or quit
476Quit the emulator.
477
478@item eject [-f] device
479Eject a removable media (use -f to force it).
480
481@item change device filename
482Change a removable media.
483
484@item screendump filename
485Save screen into PPM image @var{filename}.
486
487@item log item1[,...]
488Activate logging of the specified items to @file{/tmp/qemu.log}.
489
490@item savevm filename
491Save the whole virtual machine state to @var{filename}.
492
493@item loadvm filename
494Restore the whole virtual machine state from @var{filename}.
495
496@item stop
497Stop emulation.
498
499@item c or cont
500Resume emulation.
501
502@item gdbserver [port]
503Start gdbserver session (default port=1234)
504
505@item x/fmt addr
506Virtual memory dump starting at @var{addr}.
507
508@item xp /fmt addr
509Physical memory dump starting at @var{addr}.
510
511@var{fmt} is a format which tells the command how to format the
512data. Its syntax is: @option{/@{count@}@{format@}@{size@}}
513
514@table @var
515@item count
516is the number of items to be dumped.
517
518@item format
519can be x (hexa), d (signed decimal), u (unsigned decimal), o (octal),
520c (char) or i (asm instruction).
521
522@item size
52c00a5f
FB
523can be b (8 bits), h (16 bits), w (32 bits) or g (64 bits). On x86,
524@code{h} or @code{w} can be specified with the @code{i} format to
525respectively select 16 or 32 bit code instruction size.
1f673135
FB
526
527@end table
528
529Examples:
530@itemize
531@item
532Dump 10 instructions at the current instruction pointer:
533@example
534(qemu) x/10i $eip
5350x90107063: ret
5360x90107064: sti
5370x90107065: lea 0x0(%esi,1),%esi
5380x90107069: lea 0x0(%edi,1),%edi
5390x90107070: ret
5400x90107071: jmp 0x90107080
5410x90107073: nop
5420x90107074: nop
5430x90107075: nop
5440x90107076: nop
545@end example
546
547@item
548Dump 80 16 bit values at the start of the video memory.
549@example
550(qemu) xp/80hx 0xb8000
5510x000b8000: 0x0b50 0x0b6c 0x0b65 0x0b78 0x0b38 0x0b36 0x0b2f 0x0b42
5520x000b8010: 0x0b6f 0x0b63 0x0b68 0x0b73 0x0b20 0x0b56 0x0b47 0x0b41
5530x000b8020: 0x0b42 0x0b69 0x0b6f 0x0b73 0x0b20 0x0b63 0x0b75 0x0b72
5540x000b8030: 0x0b72 0x0b65 0x0b6e 0x0b74 0x0b2d 0x0b63 0x0b76 0x0b73
5550x000b8040: 0x0b20 0x0b30 0x0b35 0x0b20 0x0b4e 0x0b6f 0x0b76 0x0b20
5560x000b8050: 0x0b32 0x0b30 0x0b30 0x0b33 0x0720 0x0720 0x0720 0x0720
5570x000b8060: 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720
5580x000b8070: 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720
5590x000b8080: 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720
5600x000b8090: 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720
561@end example
562@end itemize
563
564@item p or print/fmt expr
565
566Print expression value. Only the @var{format} part of @var{fmt} is
567used.
0806e3f6 568
a3a91a35
FB
569@item sendkey keys
570
571Send @var{keys} to the emulator. Use @code{-} to press several keys
572simultaneously. Example:
573@example
574sendkey ctrl-alt-f1
575@end example
576
577This command is useful to send keys that your graphical user interface
578intercepts at low level, such as @code{ctrl-alt-f1} in X Window.
579
15a34c63
FB
580@item system_reset
581
582Reset the system.
583
1f673135 584@end table
0806e3f6 585
1f673135
FB
586@subsection Integer expressions
587
588The monitor understands integers expressions for every integer
589argument. You can use register names to get the value of specifics
590CPU registers by prefixing them with @emph{$}.
ec410fc9 591
1f47a922
FB
592@node disk_images
593@section Disk Images
594
acd935ef
FB
595Since version 0.6.1, QEMU supports many disk image formats, including
596growable disk images (their size increase as non empty sectors are
597written), compressed and encrypted disk images.
1f47a922 598
acd935ef
FB
599@subsection Quick start for disk image creation
600
601You can create a disk image with the command:
1f47a922 602@example
acd935ef 603qemu-img create myimage.img mysize
1f47a922 604@end example
acd935ef
FB
605where @var{myimage.img} is the disk image filename and @var{mysize} is its
606size in kilobytes. You can add an @code{M} suffix to give the size in
607megabytes and a @code{G} suffix for gigabytes.
608
609@xref{qemu_img_invocation} for more information.
1f47a922
FB
610
611@subsection Snapshot mode
612
613If you use the option @option{-snapshot}, all disk images are
614considered as read only. When sectors in written, they are written in
615a temporary file created in @file{/tmp}. You can however force the
acd935ef
FB
616write back to the raw disk images by using the @code{commit} monitor
617command (or @key{C-a s} in the serial console).
1f47a922 618
acd935ef
FB
619@node qemu_img_invocation
620@subsection @code{qemu-img} Invocation
1f47a922 621
acd935ef 622@include qemu-img.texi
05efe46e 623
9d4fb82e
FB
624@section Network emulation
625
626QEMU simulates up to 6 networks cards (NE2000 boards). Each card can
627be connected to a specific host network interface.
628
629@subsection Using tun/tap network interface
630
631This is the standard way to emulate network. QEMU adds a virtual
632network device on your host (called @code{tun0}), and you can then
633configure it as if it was a real ethernet card.
634
635As an example, you can download the @file{linux-test-xxx.tar.gz}
636archive and copy the script @file{qemu-ifup} in @file{/etc} and
637configure properly @code{sudo} so that the command @code{ifconfig}
638contained in @file{qemu-ifup} can be executed as root. You must verify
639that your host kernel supports the TUN/TAP network interfaces: the
640device @file{/dev/net/tun} must be present.
641
642See @ref{direct_linux_boot} to have an example of network use with a
643Linux distribution.
644
645@subsection Using the user mode network stack
646
443f1376
FB
647By using the option @option{-user-net} or if you have no tun/tap init
648script, QEMU uses a completely user mode network stack (you don't need
649root priviledge to use the virtual network). The virtual network
650configuration is the following:
9d4fb82e
FB
651
652@example
653
654QEMU Virtual Machine <------> Firewall/DHCP server <-----> Internet
655 (10.0.2.x) | (10.0.2.2)
656 |
2518bd0d
FB
657 ----> DNS server (10.0.2.3)
658 |
659 ----> SMB server (10.0.2.4)
9d4fb82e
FB
660@end example
661
662The QEMU VM behaves as if it was behind a firewall which blocks all
663incoming connections. You can use a DHCP client to automatically
664configure the network in the QEMU VM.
665
666In order to check that the user mode network is working, you can ping
667the address 10.0.2.2 and verify that you got an address in the range
66810.0.2.x from the QEMU virtual DHCP server.
669
b415a407
FB
670Note that @code{ping} is not supported reliably to the internet as it
671would require root priviledges. It means you can only ping the local
672router (10.0.2.2).
673
9bf05444
FB
674When using the built-in TFTP server, the router is also the TFTP
675server.
676
677When using the @option{-redir} option, TCP or UDP connections can be
678redirected from the host to the guest. It allows for example to
679redirect X11, telnet or SSH connections.
443f1376 680
9d4fb82e
FB
681@node direct_linux_boot
682@section Direct Linux Boot
1f673135
FB
683
684This section explains how to launch a Linux kernel inside QEMU without
685having to make a full bootable image. It is very useful for fast Linux
686kernel testing. The QEMU network configuration is also explained.
687
688@enumerate
689@item
690Download the archive @file{linux-test-xxx.tar.gz} containing a Linux
691kernel and a disk image.
692
693@item Optional: If you want network support (for example to launch X11 examples), you
694must copy the script @file{qemu-ifup} in @file{/etc} and configure
695properly @code{sudo} so that the command @code{ifconfig} contained in
696@file{qemu-ifup} can be executed as root. You must verify that your host
697kernel supports the TUN/TAP network interfaces: the device
698@file{/dev/net/tun} must be present.
699
700When network is enabled, there is a virtual network connection between
701the host kernel and the emulated kernel. The emulated kernel is seen
702from the host kernel at IP address 172.20.0.2 and the host kernel is
703seen from the emulated kernel at IP address 172.20.0.1.
704
705@item Launch @code{qemu.sh}. You should have the following output:
706
707@example
708> ./qemu.sh
709Connected to host network interface: tun0
710Linux 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
711BIOS-provided physical RAM map:
712 BIOS-e801: 0000000000000000 - 000000000009f000 (usable)
713 BIOS-e801: 0000000000100000 - 0000000002000000 (usable)
71432MB LOWMEM available.
715On node 0 totalpages: 8192
716zone(0): 4096 pages.
717zone(1): 4096 pages.
718zone(2): 0 pages.
719Kernel command line: root=/dev/hda sb=0x220,5,1,5 ide2=noprobe ide3=noprobe ide4=noprobe ide5=noprobe console=ttyS0
720ide_setup: ide2=noprobe
721ide_setup: ide3=noprobe
722ide_setup: ide4=noprobe
723ide_setup: ide5=noprobe
724Initializing CPU#0
725Detected 2399.621 MHz processor.
726Console: colour EGA 80x25
727Calibrating delay loop... 4744.80 BogoMIPS
728Memory: 28872k/32768k available (1210k kernel code, 3508k reserved, 266k data, 64k init, 0k highmem)
729Dentry cache hash table entries: 4096 (order: 3, 32768 bytes)
730Inode cache hash table entries: 2048 (order: 2, 16384 bytes)
731Mount cache hash table entries: 512 (order: 0, 4096 bytes)
732Buffer-cache hash table entries: 1024 (order: 0, 4096 bytes)
733Page-cache hash table entries: 8192 (order: 3, 32768 bytes)
734CPU: Intel Pentium Pro stepping 03
735Checking 'hlt' instruction... OK.
736POSIX conformance testing by UNIFIX
737Linux NET4.0 for Linux 2.4
738Based upon Swansea University Computer Society NET3.039
739Initializing RT netlink socket
740apm: BIOS not found.
741Starting kswapd
742Journalled Block Device driver loaded
743Detected PS/2 Mouse Port.
744pty: 256 Unix98 ptys configured
745Serial driver version 5.05c (2001-07-08) with no serial options enabled
746ttyS00 at 0x03f8 (irq = 4) is a 16450
747ne.c:v1.10 9/23/94 Donald Becker (becker@scyld.com)
748Last modified Nov 1, 2000 by Paul Gortmaker
749NE*000 ethercard probe at 0x300: 52 54 00 12 34 56
750eth0: NE2000 found at 0x300, using IRQ 9.
751RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
752Uniform Multi-Platform E-IDE driver Revision: 7.00beta4-2.4
753ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx
754hda: QEMU HARDDISK, ATA DISK drive
755ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
756hda: attached ide-disk driver.
757hda: 20480 sectors (10 MB) w/256KiB Cache, CHS=20/16/63
758Partition check:
759 hda:
760Soundblaster audio driver Copyright (C) by Hannu Savolainen 1993-1996
761NET4: Linux TCP/IP 1.0 for NET4.0
762IP Protocols: ICMP, UDP, TCP, IGMP
763IP: routing cache hash table of 512 buckets, 4Kbytes
764TCP: Hash tables configured (established 2048 bind 4096)
765NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
766EXT2-fs warning: mounting unchecked fs, running e2fsck is recommended
767VFS: Mounted root (ext2 filesystem).
768Freeing unused kernel memory: 64k freed
769
770Linux 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
771
772QEMU Linux test distribution (based on Redhat 9)
773
774Type 'exit' to halt the system
775
776sh-2.05b#
777@end example
778
779@item
780Then you can play with the kernel inside the virtual serial console. You
781can launch @code{ls} for example. Type @key{Ctrl-a h} to have an help
782about the keys you can type inside the virtual serial console. In
783particular, use @key{Ctrl-a x} to exit QEMU and use @key{Ctrl-a b} as
784the Magic SysRq key.
785
786@item
787If the network is enabled, launch the script @file{/etc/linuxrc} in the
788emulator (don't forget the leading dot):
789@example
790. /etc/linuxrc
791@end example
792
793Then enable X11 connections on your PC from the emulated Linux:
794@example
795xhost +172.20.0.2
796@end example
797
798You can now launch @file{xterm} or @file{xlogo} and verify that you have
799a real Virtual Linux system !
800
801@end enumerate
802
803NOTES:
804@enumerate
805@item
806A 2.5.74 kernel is also included in the archive. Just
807replace the bzImage in qemu.sh to try it.
808
1f673135
FB
809@item
810In order to exit cleanly from qemu, you can do a @emph{shutdown} inside
811qemu. qemu will automatically exit when the Linux shutdown is done.
812
813@item
814You can boot slightly faster by disabling the probe of non present IDE
815interfaces. To do so, add the following options on the kernel command
816line:
817@example
818ide1=noprobe ide2=noprobe ide3=noprobe ide4=noprobe ide5=noprobe
819@end example
820
821@item
822The example disk image is a modified version of the one made by Kevin
823Lawton for the plex86 Project (@url{www.plex86.org}).
824
825@end enumerate
826
0806e3f6 827@node gdb_usage
da415d54
FB
828@section GDB usage
829
830QEMU has a primitive support to work with gdb, so that you can do
0806e3f6 831'Ctrl-C' while the virtual machine is running and inspect its state.
da415d54 832
9d4520d0 833In order to use gdb, launch qemu with the '-s' option. It will wait for a
da415d54
FB
834gdb connection:
835@example
6c9bf893 836> qemu -s -kernel arch/i386/boot/bzImage -hda root-2.4.20.img -append "root=/dev/hda"
da415d54
FB
837Connected to host network interface: tun0
838Waiting gdb connection on port 1234
839@end example
840
841Then launch gdb on the 'vmlinux' executable:
842@example
843> gdb vmlinux
844@end example
845
846In gdb, connect to QEMU:
847@example
6c9bf893 848(gdb) target remote localhost:1234
da415d54
FB
849@end example
850
851Then you can use gdb normally. For example, type 'c' to launch the kernel:
852@example
853(gdb) c
854@end example
855
0806e3f6
FB
856Here are some useful tips in order to use gdb on system code:
857
858@enumerate
859@item
860Use @code{info reg} to display all the CPU registers.
861@item
862Use @code{x/10i $eip} to display the code at the PC position.
863@item
864Use @code{set architecture i8086} to dump 16 bit code. Then use
865@code{x/10i $cs*16+*eip} to dump the code at the PC position.
866@end enumerate
867
1a084f3d
FB
868@section Target OS specific information
869
870@subsection Linux
871
15a34c63
FB
872To have access to SVGA graphic modes under X11, use the @code{vesa} or
873the @code{cirrus} X11 driver. For optimal performances, use 16 bit
874color depth in the guest and the host OS.
1a084f3d 875
e3371e62
FB
876When using a 2.6 guest Linux kernel, you should add the option
877@code{clock=pit} on the kernel command line because the 2.6 Linux
878kernels make very strict real time clock checks by default that QEMU
879cannot simulate exactly.
880
7c3fc84d
FB
881When using a 2.6 guest Linux kernel, verify that the 4G/4G patch is
882not activated because QEMU is slower with this patch. The QEMU
883Accelerator Module is also much slower in this case. Earlier Fedora
884Core 3 Linux kernel (< 2.6.9-1.724_FC3) were known to incorporte this
885patch by default. Newer kernels don't have it.
886
1a084f3d
FB
887@subsection Windows
888
889If you have a slow host, using Windows 95 is better as it gives the
890best speed. Windows 2000 is also a good choice.
891
e3371e62
FB
892@subsubsection SVGA graphic modes support
893
894QEMU emulates a Cirrus Logic GD5446 Video
15a34c63
FB
895card. All Windows versions starting from Windows 95 should recognize
896and use this graphic card. For optimal performances, use 16 bit color
897depth in the guest and the host OS.
1a084f3d 898
e3371e62
FB
899@subsubsection CPU usage reduction
900
901Windows 9x does not correctly use the CPU HLT
15a34c63
FB
902instruction. The result is that it takes host CPU cycles even when
903idle. You can install the utility from
904@url{http://www.user.cityline.ru/~maxamn/amnhltm.zip} to solve this
905problem. Note that no such tool is needed for NT, 2000 or XP.
1a084f3d 906
9d0a8e6f 907@subsubsection Windows 2000 disk full problem
e3371e62 908
9d0a8e6f
FB
909Windows 2000 has a bug which gives a disk full problem during its
910installation. When installing it, use the @option{-win2k-hack} QEMU
911option to enable a specific workaround. After Windows 2000 is
912installed, you no longer need this option (this option slows down the
913IDE transfers).
e3371e62
FB
914
915@subsubsection Windows XP security problems
916
917Some releases of Windows XP install correctly but give a security
918error when booting:
919@example
920A problem is preventing Windows from accurately checking the
921license for this computer. Error code: 0x800703e6.
922@end example
923The only known workaround is to boot in Safe mode
924without networking support.
925
926Future QEMU releases are likely to correct this bug.
927
a0a821a4
FB
928@subsection MS-DOS and FreeDOS
929
930@subsubsection CPU usage reduction
931
932DOS does not correctly use the CPU HLT instruction. The result is that
933it takes host CPU cycles even when idle. You can install the utility
934from @url{http://www.vmware.com/software/dosidle210.zip} to solve this
935problem.
936
15a34c63 937@chapter QEMU PowerPC System emulator invocation
1a084f3d 938
15a34c63
FB
939Use the executable @file{qemu-system-ppc} to simulate a complete PREP
940or PowerMac PowerPC system.
1a084f3d 941
b671f9ed 942QEMU emulates the following PowerMac peripherals:
1a084f3d 943
15a34c63
FB
944@itemize @minus
945@item
946UniNorth PCI Bridge
947@item
948PCI VGA compatible card with VESA Bochs Extensions
949@item
9502 PMAC IDE interfaces with hard disk and CD-ROM support
951@item
952NE2000 PCI adapters
953@item
954Non Volatile RAM
955@item
956VIA-CUDA with ADB keyboard and mouse.
1a084f3d
FB
957@end itemize
958
b671f9ed 959QEMU emulates the following PREP peripherals:
52c00a5f
FB
960
961@itemize @minus
962@item
15a34c63
FB
963PCI Bridge
964@item
965PCI VGA compatible card with VESA Bochs Extensions
966@item
52c00a5f
FB
9672 IDE interfaces with hard disk and CD-ROM support
968@item
969Floppy disk
970@item
15a34c63 971NE2000 network adapters
52c00a5f
FB
972@item
973Serial port
974@item
975PREP Non Volatile RAM
15a34c63
FB
976@item
977PC compatible keyboard and mouse.
52c00a5f
FB
978@end itemize
979
15a34c63
FB
980QEMU uses the Open Hack'Ware Open Firmware Compatible BIOS available at
981@url{http://site.voila.fr/jmayer/OpenHackWare/index.htm}.
982
52c00a5f
FB
983You can read the qemu PC system emulation chapter to have more
984informations about QEMU usage.
985
15a34c63
FB
986@c man begin OPTIONS
987
988The following options are specific to the PowerPC emulation:
989
990@table @option
991
992@item -prep
993Simulate a PREP system (default is PowerMAC)
994
995@item -g WxH[xDEPTH]
996
997Set the initial VGA graphic mode. The default is 800x600x15.
998
999@end table
1000
1001@c man end
1002
1003
52c00a5f
FB
1004More information is available at
1005@url{http://jocelyn.mayer.free.fr/qemu-ppc/}.
1006
3475187d 1007@chapter Sparc32 System emulator invocation
e80cfcfc
FB
1008
1009Use the executable @file{qemu-system-sparc} to simulate a JavaStation
3475187d 1010(sun4m architecture). The emulation is somewhat complete.
e80cfcfc 1011
b671f9ed 1012QEMU emulates the following sun4m peripherals:
e80cfcfc
FB
1013
1014@itemize @minus
3475187d 1015@item
e80cfcfc
FB
1016IOMMU
1017@item
1018TCX Frame buffer
1019@item
1020Lance (Am7990) Ethernet
1021@item
1022Non Volatile RAM M48T08
1023@item
3475187d
FB
1024Slave I/O: timers, interrupt controllers, Zilog serial ports, keyboard
1025and power/reset logic
1026@item
1027ESP SCSI controller with hard disk and CD-ROM support
1028@item
1029Floppy drive
e80cfcfc
FB
1030@end itemize
1031
3475187d
FB
1032The number of peripherals is fixed in the architecture.
1033
e80cfcfc 1034QEMU uses the Proll, a PROM replacement available at
3475187d
FB
1035@url{http://people.redhat.com/zaitcev/linux/}. The required
1036QEMU-specific patches are included with the sources.
1037
1038A sample Linux 2.6 series kernel and ram disk image are available on
1039the QEMU web site. Please note that currently neither Linux 2.4
1040series, NetBSD, nor OpenBSD kernels work.
1041
1042@c man begin OPTIONS
1043
1044The following options are specific to the Sparc emulation:
1045
1046@table @option
1047
1048@item -g WxH
1049
1050Set the initial TCX graphic mode. The default is 1024x768.
1051
1052@end table
1053
1054@c man end
1055
1056@chapter Sparc64 System emulator invocation
e80cfcfc 1057
3475187d
FB
1058Use the executable @file{qemu-system-sparc64} to simulate a Sun4u machine.
1059The emulator is not usable for anything yet.
b756921a 1060
9d0a8e6f
FB
1061@chapter MIPS System emulator invocation
1062
1063Use the executable @file{qemu-system-mips} to simulate a MIPS machine.
1064The emulator begins to launch a Linux kernel.
1065
1f673135 1066@chapter QEMU User space emulator invocation
386405f7 1067
1f673135 1068@section Quick Start
df0f11a0 1069
1f673135
FB
1070In order to launch a Linux process, QEMU needs the process executable
1071itself and all the target (x86) dynamic libraries used by it.
386405f7 1072
1f673135 1073@itemize
386405f7 1074
1f673135
FB
1075@item On x86, you can just try to launch any process by using the native
1076libraries:
386405f7 1077
1f673135
FB
1078@example
1079qemu-i386 -L / /bin/ls
1080@end example
386405f7 1081
1f673135
FB
1082@code{-L /} tells that the x86 dynamic linker must be searched with a
1083@file{/} prefix.
386405f7 1084
1f673135 1085@item Since QEMU is also a linux process, you can launch qemu with qemu (NOTE: you can only do that if you compiled QEMU from the sources):
386405f7 1086
1f673135
FB
1087@example
1088qemu-i386 -L / qemu-i386 -L / /bin/ls
1089@end example
386405f7 1090
1f673135
FB
1091@item On non x86 CPUs, you need first to download at least an x86 glibc
1092(@file{qemu-runtime-i386-XXX-.tar.gz} on the QEMU web page). Ensure that
1093@code{LD_LIBRARY_PATH} is not set:
df0f11a0 1094
1f673135
FB
1095@example
1096unset LD_LIBRARY_PATH
1097@end example
1eb87257 1098
1f673135 1099Then you can launch the precompiled @file{ls} x86 executable:
1eb87257 1100
1f673135
FB
1101@example
1102qemu-i386 tests/i386/ls
1103@end example
1104You can look at @file{qemu-binfmt-conf.sh} so that
1105QEMU is automatically launched by the Linux kernel when you try to
1106launch x86 executables. It requires the @code{binfmt_misc} module in the
1107Linux kernel.
1eb87257 1108
1f673135
FB
1109@item The x86 version of QEMU is also included. You can try weird things such as:
1110@example
1111qemu-i386 /usr/local/qemu-i386/bin/qemu-i386 /usr/local/qemu-i386/bin/ls-i386
1112@end example
1eb20527 1113
1f673135 1114@end itemize
1eb20527 1115
1f673135 1116@section Wine launch
1eb20527 1117
1f673135 1118@itemize
386405f7 1119
1f673135
FB
1120@item Ensure that you have a working QEMU with the x86 glibc
1121distribution (see previous section). In order to verify it, you must be
1122able to do:
386405f7 1123
1f673135
FB
1124@example
1125qemu-i386 /usr/local/qemu-i386/bin/ls-i386
1126@end example
386405f7 1127
1f673135
FB
1128@item Download the binary x86 Wine install
1129(@file{qemu-XXX-i386-wine.tar.gz} on the QEMU web page).
386405f7 1130
1f673135
FB
1131@item Configure Wine on your account. Look at the provided script
1132@file{/usr/local/qemu-i386/bin/wine-conf.sh}. Your previous
1133@code{$@{HOME@}/.wine} directory is saved to @code{$@{HOME@}/.wine.org}.
386405f7 1134
1f673135 1135@item Then you can try the example @file{putty.exe}:
386405f7 1136
1f673135
FB
1137@example
1138qemu-i386 /usr/local/qemu-i386/wine/bin/wine /usr/local/qemu-i386/wine/c/Program\ Files/putty.exe
1139@end example
386405f7 1140
1f673135 1141@end itemize
fd429f2f 1142
1f673135 1143@section Command line options
1eb20527 1144
1f673135
FB
1145@example
1146usage: qemu-i386 [-h] [-d] [-L path] [-s size] program [arguments...]
1147@end example
1eb20527 1148
1f673135
FB
1149@table @option
1150@item -h
1151Print the help
1152@item -L path
1153Set the x86 elf interpreter prefix (default=/usr/local/qemu-i386)
1154@item -s size
1155Set the x86 stack size in bytes (default=524288)
386405f7
FB
1156@end table
1157
1f673135 1158Debug options:
386405f7 1159
1f673135
FB
1160@table @option
1161@item -d
1162Activate log (logfile=/tmp/qemu.log)
1163@item -p pagesize
1164Act as if the host page size was 'pagesize' bytes
1165@end table
386405f7 1166
15a34c63
FB
1167@node compilation
1168@chapter Compilation from the sources
1169
7c3fc84d
FB
1170@section Linux/Unix
1171
1172@subsection Compilation
1173
1174First you must decompress the sources:
1175@example
1176cd /tmp
1177tar zxvf qemu-x.y.z.tar.gz
1178cd qemu-x.y.z
1179@end example
1180
1181Then you configure QEMU and build it (usually no options are needed):
1182@example
1183./configure
1184make
1185@end example
1186
1187Then type as root user:
1188@example
1189make install
1190@end example
1191to install QEMU in @file{/usr/local}.
1192
7c3fc84d
FB
1193@subsection Tested tool versions
1194
1195In order to compile QEMU succesfully, it is very important that you
1196have the right tools. The most important one is gcc. I cannot guaranty
1197that QEMU works if you do not use a tested gcc version. Look at
1198'configure' and 'Makefile' if you want to make a different gcc
1199version work.
1200
1201@example
1202host gcc binutils glibc linux distribution
1203----------------------------------------------------------------------
1204x86 3.2 2.13.2 2.1.3 2.4.18
1205 2.96 2.11.93.0.2 2.2.5 2.4.18 Red Hat 7.3
1206 3.2.2 2.13.90.0.18 2.3.2 2.4.20 Red Hat 9
1207
1208PowerPC 3.3 [4] 2.13.90.0.18 2.3.1 2.4.20briq
1209 3.2
1210
1211Alpha 3.3 [1] 2.14.90.0.4 2.2.5 2.2.20 [2] Debian 3.0
1212
1213Sparc32 2.95.4 2.12.90.0.1 2.2.5 2.4.18 Debian 3.0
1214
1215ARM 2.95.4 2.12.90.0.1 2.2.5 2.4.9 [3] Debian 3.0
1216
1217[1] On Alpha, QEMU needs the gcc 'visibility' attribute only available
1218 for gcc version >= 3.3.
1219[2] Linux >= 2.4.20 is necessary for precise exception support
1220 (untested).
1221[3] 2.4.9-ac10-rmk2-np1-cerf2
1222
1223[4] gcc 2.95.x generates invalid code when using too many register
1224variables. You must use gcc 3.x on PowerPC.
1225@end example
15a34c63
FB
1226
1227@section Windows
1228
1229@itemize
1230@item Install the current versions of MSYS and MinGW from
1231@url{http://www.mingw.org/}. You can find detailed installation
1232instructions in the download section and the FAQ.
1233
1234@item Download
1235the MinGW development library of SDL 1.2.x
1236(@file{SDL-devel-1.2.x-mingw32.tar.gz}) from
1237@url{http://www.libsdl.org}. Unpack it in a temporary place, and
1238unpack the archive @file{i386-mingw32msvc.tar.gz} in the MinGW tool
1239directory. Edit the @file{sdl-config} script so that it gives the
1240correct SDL directory when invoked.
1241
1242@item Extract the current version of QEMU.
1243
1244@item Start the MSYS shell (file @file{msys.bat}).
1245
1246@item Change to the QEMU directory. Launch @file{./configure} and
1247@file{make}. If you have problems using SDL, verify that
1248@file{sdl-config} can be launched from the MSYS command line.
1249
1250@item You can install QEMU in @file{Program Files/Qemu} by typing
1251@file{make install}. Don't forget to copy @file{SDL.dll} in
1252@file{Program Files/Qemu}.
1253
1254@end itemize
1255
1256@section Cross compilation for Windows with Linux
1257
1258@itemize
1259@item
1260Install the MinGW cross compilation tools available at
1261@url{http://www.mingw.org/}.
1262
1263@item
1264Install the Win32 version of SDL (@url{http://www.libsdl.org}) by
1265unpacking @file{i386-mingw32msvc.tar.gz}. Set up the PATH environment
1266variable so that @file{i386-mingw32msvc-sdl-config} can be launched by
1267the QEMU configuration script.
1268
1269@item
1270Configure QEMU for Windows cross compilation:
1271@example
1272./configure --enable-mingw32
1273@end example
1274If necessary, you can change the cross-prefix according to the prefix
1275choosen for the MinGW tools with --cross-prefix. You can also use
1276--prefix to set the Win32 install path.
1277
1278@item You can install QEMU in the installation directory by typing
1279@file{make install}. Don't forget to copy @file{SDL.dll} in the
1280installation directory.
1281
1282@end itemize
1283
1284Note: Currently, Wine does not seem able to launch
1285QEMU for Win32.
1286
1287@section Mac OS X
1288
1289The Mac OS X patches are not fully merged in QEMU, so you should look
1290at the QEMU mailing list archive to have all the necessary
1291information.
1292