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