Statistics
| Branch: | Revision:

root / qemu-doc.texi @ d1d9f421

History | View | Annotate | Download (32.2 kB)

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