Statistics
| Branch: | Revision:

root / qemu-doc.texi @ 2c6cadd4

History | View | Annotate | Download (45.2 kB)

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
@subsection Virtual FAT disk images
759

    
760
QEMU can automatically create a virtual FAT disk image from a
761
directory tree. In order to use it, just type:
762

    
763
@example 
764
qemu linux.img -hdb fat:/my_directory
765
@end example
766

    
767
Then you access access to all the files in the @file{/my_directory}
768
directory without having to copy them in a disk image or to export
769
them via SAMBA or NFS. The default access is @emph{read-only}.
770

    
771
Floppies can be emulated with the @code{:floppy:} option:
772

    
773
@example 
774
qemu linux.img -fda fat:floppy:/my_directory
775
@end example
776

    
777
A read/write support is available for testing (beta stage) with the
778
@code{:rw:} option:
779

    
780
@example 
781
qemu linux.img -fda fat:floppy:rw:/my_directory
782
@end example
783

    
784
What you should @emph{never} do:
785
@itemize
786
@item use non-ASCII filenames ;
787
@item use "-snapshot" together with ":rw:" ;
788
@item expect it to work when loadvm'ing.
789
@end itemize
790

    
791
@section Network emulation
792

    
793
QEMU can simulate several networks cards (NE2000 boards on the PC
794
target) and can connect them to an arbitrary number of Virtual Local
795
Area Networks (VLANs). Host TAP devices can be connected to any QEMU
796
VLAN. VLAN can be connected between separate instances of QEMU to
797
simulate large networks. For simpler usage, a non priviledged user mode
798
network stack can replace the TAP device to have a basic network
799
connection.
800

    
801
@subsection VLANs
802

    
803
QEMU simulates several VLANs. A VLAN can be symbolised as a virtual
804
connection between several network devices. These devices can be for
805
example QEMU virtual Ethernet cards or virtual Host ethernet devices
806
(TAP devices).
807

    
808
@subsection Using TAP network interfaces
809

    
810
This is the standard way to connect QEMU to a real network. QEMU adds
811
a virtual network device on your host (called @code{tapN}), and you
812
can then configure it as if it was a real ethernet card.
813

    
814
As an example, you can download the @file{linux-test-xxx.tar.gz}
815
archive and copy the script @file{qemu-ifup} in @file{/etc} and
816
configure properly @code{sudo} so that the command @code{ifconfig}
817
contained in @file{qemu-ifup} can be executed as root. You must verify
818
that your host kernel supports the TAP network interfaces: the
819
device @file{/dev/net/tun} must be present.
820

    
821
See @ref{direct_linux_boot} to have an example of network use with a
822
Linux distribution and @ref{sec_invocation} to have examples of
823
command lines using the TAP network interfaces.
824

    
825
@subsection Using the user mode network stack
826

    
827
By using the option @option{-net user} (default configuration if no
828
@option{-net} option is specified), QEMU uses a completely user mode
829
network stack (you don't need root priviledge to use the virtual
830
network). The virtual network configuration is the following:
831

    
832
@example
833

    
834
         QEMU VLAN      <------>  Firewall/DHCP server <-----> Internet
835
                           |          (10.0.2.2)
836
                           |
837
                           ---->  DNS server (10.0.2.3)
838
                           |     
839
                           ---->  SMB server (10.0.2.4)
840
@end example
841

    
842
The QEMU VM behaves as if it was behind a firewall which blocks all
843
incoming connections. You can use a DHCP client to automatically
844
configure the network in the QEMU VM. The DHCP server assign addresses
845
to the hosts starting from 10.0.2.15.
846

    
847
In order to check that the user mode network is working, you can ping
848
the address 10.0.2.2 and verify that you got an address in the range
849
10.0.2.x from the QEMU virtual DHCP server.
850

    
851
Note that @code{ping} is not supported reliably to the internet as it
852
would require root priviledges. It means you can only ping the local
853
router (10.0.2.2).
854

    
855
When using the built-in TFTP server, the router is also the TFTP
856
server.
857

    
858
When using the @option{-redir} option, TCP or UDP connections can be
859
redirected from the host to the guest. It allows for example to
860
redirect X11, telnet or SSH connections.
861

    
862
@subsection Connecting VLANs between QEMU instances
863

    
864
Using the @option{-net socket} option, it is possible to make VLANs
865
that span several QEMU instances. See @ref{sec_invocation} to have a
866
basic example.
867

    
868
@node direct_linux_boot
869
@section Direct Linux Boot
870

    
871
This section explains how to launch a Linux kernel inside QEMU without
872
having to make a full bootable image. It is very useful for fast Linux
873
kernel testing. The QEMU network configuration is also explained.
874

    
875
@enumerate
876
@item
877
Download the archive @file{linux-test-xxx.tar.gz} containing a Linux
878
kernel and a disk image. 
879

    
880
@item Optional: If you want network support (for example to launch X11 examples), you
881
must copy the script @file{qemu-ifup} in @file{/etc} and configure
882
properly @code{sudo} so that the command @code{ifconfig} contained in
883
@file{qemu-ifup} can be executed as root. You must verify that your host
884
kernel supports the TUN/TAP network interfaces: the device
885
@file{/dev/net/tun} must be present.
886

    
887
When network is enabled, there is a virtual network connection between
888
the host kernel and the emulated kernel. The emulated kernel is seen
889
from the host kernel at IP address 172.20.0.2 and the host kernel is
890
seen from the emulated kernel at IP address 172.20.0.1.
891

    
892
@item Launch @code{qemu.sh}. You should have the following output:
893

    
894
@example
895
> ./qemu.sh 
896
Connected to host network interface: tun0
897
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
898
BIOS-provided physical RAM map:
899
 BIOS-e801: 0000000000000000 - 000000000009f000 (usable)
900
 BIOS-e801: 0000000000100000 - 0000000002000000 (usable)
901
32MB LOWMEM available.
902
On node 0 totalpages: 8192
903
zone(0): 4096 pages.
904
zone(1): 4096 pages.
905
zone(2): 0 pages.
906
Kernel command line: root=/dev/hda sb=0x220,5,1,5 ide2=noprobe ide3=noprobe ide4=noprobe ide5=noprobe console=ttyS0
907
ide_setup: ide2=noprobe
908
ide_setup: ide3=noprobe
909
ide_setup: ide4=noprobe
910
ide_setup: ide5=noprobe
911
Initializing CPU#0
912
Detected 2399.621 MHz processor.
913
Console: colour EGA 80x25
914
Calibrating delay loop... 4744.80 BogoMIPS
915
Memory: 28872k/32768k available (1210k kernel code, 3508k reserved, 266k data, 64k init, 0k highmem)
916
Dentry cache hash table entries: 4096 (order: 3, 32768 bytes)
917
Inode cache hash table entries: 2048 (order: 2, 16384 bytes)
918
Mount cache hash table entries: 512 (order: 0, 4096 bytes)
919
Buffer-cache hash table entries: 1024 (order: 0, 4096 bytes)
920
Page-cache hash table entries: 8192 (order: 3, 32768 bytes)
921
CPU: Intel Pentium Pro stepping 03
922
Checking 'hlt' instruction... OK.
923
POSIX conformance testing by UNIFIX
924
Linux NET4.0 for Linux 2.4
925
Based upon Swansea University Computer Society NET3.039
926
Initializing RT netlink socket
927
apm: BIOS not found.
928
Starting kswapd
929
Journalled Block Device driver loaded
930
Detected PS/2 Mouse Port.
931
pty: 256 Unix98 ptys configured
932
Serial driver version 5.05c (2001-07-08) with no serial options enabled
933
ttyS00 at 0x03f8 (irq = 4) is a 16450
934
ne.c:v1.10 9/23/94 Donald Becker (becker@scyld.com)
935
Last modified Nov 1, 2000 by Paul Gortmaker
936
NE*000 ethercard probe at 0x300: 52 54 00 12 34 56
937
eth0: NE2000 found at 0x300, using IRQ 9.
938
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
939
Uniform Multi-Platform E-IDE driver Revision: 7.00beta4-2.4
940
ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx
941
hda: QEMU HARDDISK, ATA DISK drive
942
ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
943
hda: attached ide-disk driver.
944
hda: 20480 sectors (10 MB) w/256KiB Cache, CHS=20/16/63
945
Partition check:
946
 hda:
947
Soundblaster audio driver Copyright (C) by Hannu Savolainen 1993-1996
948
NET4: Linux TCP/IP 1.0 for NET4.0
949
IP Protocols: ICMP, UDP, TCP, IGMP
950
IP: routing cache hash table of 512 buckets, 4Kbytes
951
TCP: Hash tables configured (established 2048 bind 4096)
952
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
953
EXT2-fs warning: mounting unchecked fs, running e2fsck is recommended
954
VFS: Mounted root (ext2 filesystem).
955
Freeing unused kernel memory: 64k freed
956
 
957
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
958
 
959
QEMU Linux test distribution (based on Redhat 9)
960
 
961
Type 'exit' to halt the system
962
 
963
sh-2.05b# 
964
@end example
965

    
966
@item
967
Then you can play with the kernel inside the virtual serial console. You
968
can launch @code{ls} for example. Type @key{Ctrl-a h} to have an help
969
about the keys you can type inside the virtual serial console. In
970
particular, use @key{Ctrl-a x} to exit QEMU and use @key{Ctrl-a b} as
971
the Magic SysRq key.
972

    
973
@item 
974
If the network is enabled, launch the script @file{/etc/linuxrc} in the
975
emulator (don't forget the leading dot):
976
@example
977
. /etc/linuxrc
978
@end example
979

    
980
Then enable X11 connections on your PC from the emulated Linux: 
981
@example
982
xhost +172.20.0.2
983
@end example
984

    
985
You can now launch @file{xterm} or @file{xlogo} and verify that you have
986
a real Virtual Linux system !
987

    
988
@end enumerate
989

    
990
NOTES:
991
@enumerate
992
@item 
993
A 2.5.74 kernel is also included in the archive. Just
994
replace the bzImage in qemu.sh to try it.
995

    
996
@item 
997
In order to exit cleanly from qemu, you can do a @emph{shutdown} inside
998
qemu. qemu will automatically exit when the Linux shutdown is done.
999

    
1000
@item 
1001
You can boot slightly faster by disabling the probe of non present IDE
1002
interfaces. To do so, add the following options on the kernel command
1003
line:
1004
@example
1005
ide1=noprobe ide2=noprobe ide3=noprobe ide4=noprobe ide5=noprobe
1006
@end example
1007

    
1008
@item 
1009
The example disk image is a modified version of the one made by Kevin
1010
Lawton for the plex86 Project (@url{www.plex86.org}).
1011

    
1012
@end enumerate
1013

    
1014
@section USB emulation
1015

    
1016
QEMU emulates a PCI UHCI USB controller and a 8 port USB hub connected
1017
to it. You can virtually plug to the hub virtual USB devices or real
1018
host USB devices (experimental, works only on Linux hosts).
1019

    
1020
@subsection Using virtual USB devices
1021

    
1022
A virtual USB mouse device is available for testing in QEMU.
1023

    
1024
You can try it with the following monitor commands:
1025

    
1026
@example
1027
# add the mouse device
1028
(qemu) usb_add mouse 
1029

    
1030
# show the virtual USB devices plugged on the QEMU Virtual USB hub
1031
(qemu) info usb
1032
  Device 0.3, speed 12 Mb/s
1033

    
1034
# after some time you can try to remove the mouse
1035
(qemu) usb_del 0.3
1036
@end example
1037

    
1038
The option @option{-usbdevice} is similar to the monitor command
1039
@code{usb_add}.
1040

    
1041
@subsection Using host USB devices on a Linux host
1042

    
1043
WARNING: this is an experimental feature. QEMU will slow down when
1044
using it. USB devices requiring real time streaming (i.e. USB Video
1045
Cameras) are not supported yet.
1046

    
1047
@enumerate
1048
@item If you use an early Linux 2.4 kernel, verify that no Linux driver 
1049
is actually using the USB device. A simple way to do that is simply to
1050
disable the corresponding kernel module by renaming it from @file{mydriver.o}
1051
to @file{mydriver.o.disabled}.
1052

    
1053
@item Verify that @file{/proc/bus/usb} is working (most Linux distributions should enable it by default). You should see something like that:
1054
@example
1055
ls /proc/bus/usb
1056
001  devices  drivers
1057
@end example
1058

    
1059
@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:
1060
@example
1061
chown -R myuid /proc/bus/usb
1062
@end example
1063

    
1064
@item Launch QEMU and do in the monitor:
1065
@example 
1066
info usbhost
1067
  Device 1.2, speed 480 Mb/s
1068
    Class 00: USB device 1234:5678, USB DISK
1069
@end example
1070
You should see the list of the devices you can use (Never try to use
1071
hubs, it won't work).
1072

    
1073
@item Add the device in QEMU by using:
1074
@example 
1075
usb_add host:1234:5678
1076
@end example
1077

    
1078
Normally the guest OS should report that a new USB device is
1079
plugged. You can use the option @option{-usbdevice} to do the same.
1080

    
1081
@item Now you can try to use the host USB device in QEMU.
1082

    
1083
@end enumerate
1084

    
1085
When relaunching QEMU, you may have to unplug and plug again the USB
1086
device to make it work again (this is a bug).
1087

    
1088
@node gdb_usage
1089
@section GDB usage
1090

    
1091
QEMU has a primitive support to work with gdb, so that you can do
1092
'Ctrl-C' while the virtual machine is running and inspect its state.
1093

    
1094
In order to use gdb, launch qemu with the '-s' option. It will wait for a
1095
gdb connection:
1096
@example
1097
> qemu -s -kernel arch/i386/boot/bzImage -hda root-2.4.20.img -append "root=/dev/hda"
1098
Connected to host network interface: tun0
1099
Waiting gdb connection on port 1234
1100
@end example
1101

    
1102
Then launch gdb on the 'vmlinux' executable:
1103
@example
1104
> gdb vmlinux
1105
@end example
1106

    
1107
In gdb, connect to QEMU:
1108
@example
1109
(gdb) target remote localhost:1234
1110
@end example
1111

    
1112
Then you can use gdb normally. For example, type 'c' to launch the kernel:
1113
@example
1114
(gdb) c
1115
@end example
1116

    
1117
Here are some useful tips in order to use gdb on system code:
1118

    
1119
@enumerate
1120
@item
1121
Use @code{info reg} to display all the CPU registers.
1122
@item
1123
Use @code{x/10i $eip} to display the code at the PC position.
1124
@item
1125
Use @code{set architecture i8086} to dump 16 bit code. Then use
1126
@code{x/10i $cs*16+*eip} to dump the code at the PC position.
1127
@end enumerate
1128

    
1129
@section Target OS specific information
1130

    
1131
@subsection Linux
1132

    
1133
To have access to SVGA graphic modes under X11, use the @code{vesa} or
1134
the @code{cirrus} X11 driver. For optimal performances, use 16 bit
1135
color depth in the guest and the host OS.
1136

    
1137
When using a 2.6 guest Linux kernel, you should add the option
1138
@code{clock=pit} on the kernel command line because the 2.6 Linux
1139
kernels make very strict real time clock checks by default that QEMU
1140
cannot simulate exactly.
1141

    
1142
When using a 2.6 guest Linux kernel, verify that the 4G/4G patch is
1143
not activated because QEMU is slower with this patch. The QEMU
1144
Accelerator Module is also much slower in this case. Earlier Fedora
1145
Core 3 Linux kernel (< 2.6.9-1.724_FC3) were known to incorporte this
1146
patch by default. Newer kernels don't have it.
1147

    
1148
@subsection Windows
1149

    
1150
If you have a slow host, using Windows 95 is better as it gives the
1151
best speed. Windows 2000 is also a good choice.
1152

    
1153
@subsubsection SVGA graphic modes support
1154

    
1155
QEMU emulates a Cirrus Logic GD5446 Video
1156
card. All Windows versions starting from Windows 95 should recognize
1157
and use this graphic card. For optimal performances, use 16 bit color
1158
depth in the guest and the host OS.
1159

    
1160
@subsubsection CPU usage reduction
1161

    
1162
Windows 9x does not correctly use the CPU HLT
1163
instruction. The result is that it takes host CPU cycles even when
1164
idle. You can install the utility from
1165
@url{http://www.user.cityline.ru/~maxamn/amnhltm.zip} to solve this
1166
problem. Note that no such tool is needed for NT, 2000 or XP.
1167

    
1168
@subsubsection Windows 2000 disk full problem
1169

    
1170
Windows 2000 has a bug which gives a disk full problem during its
1171
installation. When installing it, use the @option{-win2k-hack} QEMU
1172
option to enable a specific workaround. After Windows 2000 is
1173
installed, you no longer need this option (this option slows down the
1174
IDE transfers).
1175

    
1176
@subsubsection Windows 2000 shutdown
1177

    
1178
Windows 2000 cannot automatically shutdown in QEMU although Windows 98
1179
can. It comes from the fact that Windows 2000 does not automatically
1180
use the APM driver provided by the BIOS.
1181

    
1182
In order to correct that, do the following (thanks to Struan
1183
Bartlett): go to the Control Panel => Add/Remove Hardware & Next =>
1184
Add/Troubleshoot a device => Add a new device & Next => No, select the
1185
hardware from a list & Next => NT Apm/Legacy Support & Next => Next
1186
(again) a few times. Now the driver is installed and Windows 2000 now
1187
correctly instructs QEMU to shutdown at the appropriate moment. 
1188

    
1189
@subsubsection Share a directory between Unix and Windows
1190

    
1191
See @ref{sec_invocation} about the help of the option @option{-smb}.
1192

    
1193
@subsubsection Windows XP security problems
1194

    
1195
Some releases of Windows XP install correctly but give a security
1196
error when booting:
1197
@example
1198
A problem is preventing Windows from accurately checking the
1199
license for this computer. Error code: 0x800703e6.
1200
@end example
1201
The only known workaround is to boot in Safe mode
1202
without networking support. 
1203

    
1204
Future QEMU releases are likely to correct this bug.
1205

    
1206
@subsection MS-DOS and FreeDOS
1207

    
1208
@subsubsection CPU usage reduction
1209

    
1210
DOS does not correctly use the CPU HLT instruction. The result is that
1211
it takes host CPU cycles even when idle. You can install the utility
1212
from @url{http://www.vmware.com/software/dosidle210.zip} to solve this
1213
problem.
1214

    
1215
@chapter QEMU PowerPC System emulator invocation
1216

    
1217
Use the executable @file{qemu-system-ppc} to simulate a complete PREP
1218
or PowerMac PowerPC system.
1219

    
1220
QEMU emulates the following PowerMac peripherals:
1221

    
1222
@itemize @minus
1223
@item 
1224
UniNorth PCI Bridge 
1225
@item
1226
PCI VGA compatible card with VESA Bochs Extensions
1227
@item 
1228
2 PMAC IDE interfaces with hard disk and CD-ROM support
1229
@item 
1230
NE2000 PCI adapters
1231
@item
1232
Non Volatile RAM
1233
@item
1234
VIA-CUDA with ADB keyboard and mouse.
1235
@end itemize
1236

    
1237
QEMU emulates the following PREP peripherals:
1238

    
1239
@itemize @minus
1240
@item 
1241
PCI Bridge
1242
@item
1243
PCI VGA compatible card with VESA Bochs Extensions
1244
@item 
1245
2 IDE interfaces with hard disk and CD-ROM support
1246
@item
1247
Floppy disk
1248
@item 
1249
NE2000 network adapters
1250
@item
1251
Serial port
1252
@item
1253
PREP Non Volatile RAM
1254
@item
1255
PC compatible keyboard and mouse.
1256
@end itemize
1257

    
1258
QEMU uses the Open Hack'Ware Open Firmware Compatible BIOS available at
1259
@url{http://site.voila.fr/jmayer/OpenHackWare/index.htm}.
1260

    
1261
You can read the qemu PC system emulation chapter to have more
1262
informations about QEMU usage.
1263

    
1264
@c man begin OPTIONS
1265

    
1266
The following options are specific to the PowerPC emulation:
1267

    
1268
@table @option
1269

    
1270
@item -g WxH[xDEPTH]  
1271

    
1272
Set the initial VGA graphic mode. The default is 800x600x15.
1273

    
1274
@end table
1275

    
1276
@c man end 
1277

    
1278

    
1279
More information is available at
1280
@url{http://jocelyn.mayer.free.fr/qemu-ppc/}.
1281

    
1282
@chapter Sparc32 System emulator invocation
1283

    
1284
Use the executable @file{qemu-system-sparc} to simulate a JavaStation
1285
(sun4m architecture). The emulation is somewhat complete.
1286

    
1287
QEMU emulates the following sun4m peripherals:
1288

    
1289
@itemize @minus
1290
@item
1291
IOMMU
1292
@item
1293
TCX Frame buffer
1294
@item 
1295
Lance (Am7990) Ethernet
1296
@item
1297
Non Volatile RAM M48T08
1298
@item
1299
Slave I/O: timers, interrupt controllers, Zilog serial ports, keyboard
1300
and power/reset logic
1301
@item
1302
ESP SCSI controller with hard disk and CD-ROM support
1303
@item
1304
Floppy drive
1305
@end itemize
1306

    
1307
The number of peripherals is fixed in the architecture.
1308

    
1309
QEMU uses the Proll, a PROM replacement available at
1310
@url{http://people.redhat.com/zaitcev/linux/}. The required
1311
QEMU-specific patches are included with the sources.
1312

    
1313
A sample Linux 2.6 series kernel and ram disk image are available on
1314
the QEMU web site. Please note that currently neither Linux 2.4
1315
series, NetBSD, nor OpenBSD kernels work.
1316

    
1317
@c man begin OPTIONS
1318

    
1319
The following options are specific to the Sparc emulation:
1320

    
1321
@table @option
1322

    
1323
@item -g WxH
1324

    
1325
Set the initial TCX graphic mode. The default is 1024x768.
1326

    
1327
@end table
1328

    
1329
@c man end 
1330

    
1331
@chapter Sparc64 System emulator invocation
1332

    
1333
Use the executable @file{qemu-system-sparc64} to simulate a Sun4u machine.
1334
The emulator is not usable for anything yet.
1335

    
1336
QEMU emulates the following sun4u peripherals:
1337

    
1338
@itemize @minus
1339
@item
1340
UltraSparc IIi APB PCI Bridge 
1341
@item
1342
PCI VGA compatible card with VESA Bochs Extensions
1343
@item
1344
Non Volatile RAM M48T59
1345
@item
1346
PC-compatible serial ports
1347
@end itemize
1348

    
1349
@chapter MIPS System emulator invocation
1350

    
1351
Use the executable @file{qemu-system-mips} to simulate a MIPS machine.
1352
The emulator begins to launch a Linux kernel.
1353

    
1354
@chapter QEMU User space emulator invocation
1355

    
1356
@section Quick Start
1357

    
1358
In order to launch a Linux process, QEMU needs the process executable
1359
itself and all the target (x86) dynamic libraries used by it. 
1360

    
1361
@itemize
1362

    
1363
@item On x86, you can just try to launch any process by using the native
1364
libraries:
1365

    
1366
@example 
1367
qemu-i386 -L / /bin/ls
1368
@end example
1369

    
1370
@code{-L /} tells that the x86 dynamic linker must be searched with a
1371
@file{/} prefix.
1372

    
1373
@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):
1374

    
1375
@example 
1376
qemu-i386 -L / qemu-i386 -L / /bin/ls
1377
@end example
1378

    
1379
@item On non x86 CPUs, you need first to download at least an x86 glibc
1380
(@file{qemu-runtime-i386-XXX-.tar.gz} on the QEMU web page). Ensure that
1381
@code{LD_LIBRARY_PATH} is not set:
1382

    
1383
@example
1384
unset LD_LIBRARY_PATH 
1385
@end example
1386

    
1387
Then you can launch the precompiled @file{ls} x86 executable:
1388

    
1389
@example
1390
qemu-i386 tests/i386/ls
1391
@end example
1392
You can look at @file{qemu-binfmt-conf.sh} so that
1393
QEMU is automatically launched by the Linux kernel when you try to
1394
launch x86 executables. It requires the @code{binfmt_misc} module in the
1395
Linux kernel.
1396

    
1397
@item The x86 version of QEMU is also included. You can try weird things such as:
1398
@example
1399
qemu-i386 /usr/local/qemu-i386/bin/qemu-i386 /usr/local/qemu-i386/bin/ls-i386
1400
@end example
1401

    
1402
@end itemize
1403

    
1404
@section Wine launch
1405

    
1406
@itemize
1407

    
1408
@item Ensure that you have a working QEMU with the x86 glibc
1409
distribution (see previous section). In order to verify it, you must be
1410
able to do:
1411

    
1412
@example
1413
qemu-i386 /usr/local/qemu-i386/bin/ls-i386
1414
@end example
1415

    
1416
@item Download the binary x86 Wine install
1417
(@file{qemu-XXX-i386-wine.tar.gz} on the QEMU web page). 
1418

    
1419
@item Configure Wine on your account. Look at the provided script
1420
@file{/usr/local/qemu-i386/bin/wine-conf.sh}. Your previous
1421
@code{$@{HOME@}/.wine} directory is saved to @code{$@{HOME@}/.wine.org}.
1422

    
1423
@item Then you can try the example @file{putty.exe}:
1424

    
1425
@example
1426
qemu-i386 /usr/local/qemu-i386/wine/bin/wine /usr/local/qemu-i386/wine/c/Program\ Files/putty.exe
1427
@end example
1428

    
1429
@end itemize
1430

    
1431
@section Command line options
1432

    
1433
@example
1434
usage: qemu-i386 [-h] [-d] [-L path] [-s size] program [arguments...]
1435
@end example
1436

    
1437
@table @option
1438
@item -h
1439
Print the help
1440
@item -L path   
1441
Set the x86 elf interpreter prefix (default=/usr/local/qemu-i386)
1442
@item -s size
1443
Set the x86 stack size in bytes (default=524288)
1444
@end table
1445

    
1446
Debug options:
1447

    
1448
@table @option
1449
@item -d
1450
Activate log (logfile=/tmp/qemu.log)
1451
@item -p pagesize
1452
Act as if the host page size was 'pagesize' bytes
1453
@end table
1454

    
1455
@node compilation
1456
@chapter Compilation from the sources
1457

    
1458
@section Linux/Unix
1459

    
1460
@subsection Compilation
1461

    
1462
First you must decompress the sources:
1463
@example
1464
cd /tmp
1465
tar zxvf qemu-x.y.z.tar.gz
1466
cd qemu-x.y.z
1467
@end example
1468

    
1469
Then you configure QEMU and build it (usually no options are needed):
1470
@example
1471
./configure
1472
make
1473
@end example
1474

    
1475
Then type as root user:
1476
@example
1477
make install
1478
@end example
1479
to install QEMU in @file{/usr/local}.
1480

    
1481
@subsection Tested tool versions
1482

    
1483
In order to compile QEMU succesfully, it is very important that you
1484
have the right tools. The most important one is gcc. I cannot guaranty
1485
that QEMU works if you do not use a tested gcc version. Look at
1486
'configure' and 'Makefile' if you want to make a different gcc
1487
version work.
1488

    
1489
@example
1490
host      gcc      binutils      glibc    linux       distribution
1491
----------------------------------------------------------------------
1492
x86       3.2      2.13.2        2.1.3    2.4.18
1493
          2.96     2.11.93.0.2   2.2.5    2.4.18      Red Hat 7.3
1494
          3.2.2    2.13.90.0.18  2.3.2    2.4.20      Red Hat 9
1495

    
1496
PowerPC   3.3 [4]  2.13.90.0.18  2.3.1    2.4.20briq
1497
          3.2
1498

    
1499
Alpha     3.3 [1]  2.14.90.0.4   2.2.5    2.2.20 [2]  Debian 3.0
1500

    
1501
Sparc32   2.95.4   2.12.90.0.1   2.2.5    2.4.18      Debian 3.0
1502

    
1503
ARM       2.95.4   2.12.90.0.1   2.2.5    2.4.9 [3]   Debian 3.0
1504

    
1505
[1] On Alpha, QEMU needs the gcc 'visibility' attribute only available
1506
    for gcc version >= 3.3.
1507
[2] Linux >= 2.4.20 is necessary for precise exception support
1508
    (untested).
1509
[3] 2.4.9-ac10-rmk2-np1-cerf2
1510

    
1511
[4] gcc 2.95.x generates invalid code when using too many register
1512
variables. You must use gcc 3.x on PowerPC.
1513
@end example
1514

    
1515
@section Windows
1516

    
1517
@itemize
1518
@item Install the current versions of MSYS and MinGW from
1519
@url{http://www.mingw.org/}. You can find detailed installation
1520
instructions in the download section and the FAQ.
1521

    
1522
@item Download 
1523
the MinGW development library of SDL 1.2.x
1524
(@file{SDL-devel-1.2.x-mingw32.tar.gz}) from
1525
@url{http://www.libsdl.org}. Unpack it in a temporary place, and
1526
unpack the archive @file{i386-mingw32msvc.tar.gz} in the MinGW tool
1527
directory. Edit the @file{sdl-config} script so that it gives the
1528
correct SDL directory when invoked.
1529

    
1530
@item Extract the current version of QEMU.
1531
 
1532
@item Start the MSYS shell (file @file{msys.bat}).
1533

    
1534
@item Change to the QEMU directory. Launch @file{./configure} and 
1535
@file{make}.  If you have problems using SDL, verify that
1536
@file{sdl-config} can be launched from the MSYS command line.
1537

    
1538
@item You can install QEMU in @file{Program Files/Qemu} by typing 
1539
@file{make install}. Don't forget to copy @file{SDL.dll} in
1540
@file{Program Files/Qemu}.
1541

    
1542
@end itemize
1543

    
1544
@section Cross compilation for Windows with Linux
1545

    
1546
@itemize
1547
@item
1548
Install the MinGW cross compilation tools available at
1549
@url{http://www.mingw.org/}.
1550

    
1551
@item 
1552
Install the Win32 version of SDL (@url{http://www.libsdl.org}) by
1553
unpacking @file{i386-mingw32msvc.tar.gz}. Set up the PATH environment
1554
variable so that @file{i386-mingw32msvc-sdl-config} can be launched by
1555
the QEMU configuration script.
1556

    
1557
@item 
1558
Configure QEMU for Windows cross compilation:
1559
@example
1560
./configure --enable-mingw32
1561
@end example
1562
If necessary, you can change the cross-prefix according to the prefix
1563
choosen for the MinGW tools with --cross-prefix. You can also use
1564
--prefix to set the Win32 install path.
1565

    
1566
@item You can install QEMU in the installation directory by typing 
1567
@file{make install}. Don't forget to copy @file{SDL.dll} in the
1568
installation directory. 
1569

    
1570
@end itemize
1571

    
1572
Note: Currently, Wine does not seem able to launch
1573
QEMU for Win32.
1574

    
1575
@section Mac OS X
1576

    
1577
The Mac OS X patches are not fully merged in QEMU, so you should look
1578
at the QEMU mailing list archive to have all the necessary
1579
information.
1580