Statistics
| Branch: | Revision:

root / qemu-doc.texi @ dc5d0b3d

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