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