0.7.1-alt1
[qemu] / qemu / qemu-doc.html
1 <HTML>
2 <HEAD>
3 <!-- Created by texi2html 1.56k from qemu-doc.texi on 24 July 2005 -->
4
5 <TITLE>QEMU CPU Emulator User Documentation</TITLE>
6 </HEAD>
7 <BODY>
8 <H1>QEMU CPU Emulator User Documentation</H1>
9 <P>
10 <P><HR><P>
11 <H1>Table of Contents</H1>
12 <UL>
13 <LI><A NAME="TOC1" HREF="qemu-doc.html#SEC1">1. Introduction</A>
14 <UL>
15 <LI><A NAME="TOC2" HREF="qemu-doc.html#SEC2">1.1 Features</A>
16 </UL>
17 <LI><A NAME="TOC3" HREF="qemu-doc.html#SEC3">2. Installation</A>
18 <UL>
19 <LI><A NAME="TOC4" HREF="qemu-doc.html#SEC4">2.1 Linux</A>
20 <LI><A NAME="TOC5" HREF="qemu-doc.html#SEC5">2.2 Windows</A>
21 <LI><A NAME="TOC6" HREF="qemu-doc.html#SEC6">2.3 Mac OS X</A>
22 </UL>
23 <LI><A NAME="TOC7" HREF="qemu-doc.html#SEC7">3. QEMU PC System emulator invocation</A>
24 <UL>
25 <LI><A NAME="TOC8" HREF="qemu-doc.html#SEC8">3.1 Introduction</A>
26 <LI><A NAME="TOC9" HREF="qemu-doc.html#SEC9">3.2 Quick Start</A>
27 <LI><A NAME="TOC10" HREF="qemu-doc.html#SEC10">3.3 Invocation</A>
28 <LI><A NAME="TOC11" HREF="qemu-doc.html#SEC11">3.4 Keys</A>
29 <LI><A NAME="TOC12" HREF="qemu-doc.html#SEC12">3.5 QEMU Monitor</A>
30 <UL>
31 <LI><A NAME="TOC13" HREF="qemu-doc.html#SEC13">3.5.1 Commands</A>
32 <LI><A NAME="TOC14" HREF="qemu-doc.html#SEC14">3.5.2 Integer expressions</A>
33 </UL>
34 <LI><A NAME="TOC15" HREF="qemu-doc.html#SEC15">3.6 Disk Images</A>
35 <UL>
36 <LI><A NAME="TOC16" HREF="qemu-doc.html#SEC16">3.6.1 Quick start for disk image creation</A>
37 <LI><A NAME="TOC17" HREF="qemu-doc.html#SEC17">3.6.2 Snapshot mode</A>
38 <LI><A NAME="TOC18" HREF="qemu-doc.html#SEC18">3.6.3 <CODE>qemu-img</CODE> Invocation</A>
39 </UL>
40 <LI><A NAME="TOC19" HREF="qemu-doc.html#SEC19">3.7 Network emulation</A>
41 <UL>
42 <LI><A NAME="TOC20" HREF="qemu-doc.html#SEC20">3.7.1 Using tun/tap network interface</A>
43 <LI><A NAME="TOC21" HREF="qemu-doc.html#SEC21">3.7.2 Using the user mode network stack</A>
44 </UL>
45 <LI><A NAME="TOC22" HREF="qemu-doc.html#SEC22">3.8 Direct Linux Boot</A>
46 <LI><A NAME="TOC23" HREF="qemu-doc.html#SEC23">3.9 GDB usage</A>
47 <LI><A NAME="TOC24" HREF="qemu-doc.html#SEC24">3.10 Target OS specific information</A>
48 <UL>
49 <LI><A NAME="TOC25" HREF="qemu-doc.html#SEC25">3.10.1 Linux</A>
50 <LI><A NAME="TOC26" HREF="qemu-doc.html#SEC26">3.10.2 Windows</A>
51 <UL>
52 <LI><A NAME="TOC27" HREF="qemu-doc.html#SEC27">3.10.2.1 SVGA graphic modes support</A>
53 <LI><A NAME="TOC28" HREF="qemu-doc.html#SEC28">3.10.2.2 CPU usage reduction</A>
54 <LI><A NAME="TOC29" HREF="qemu-doc.html#SEC29">3.10.2.3 Windows 2000 disk full problem</A>
55 <LI><A NAME="TOC30" HREF="qemu-doc.html#SEC30">3.10.2.4 Windows XP security problems</A>
56 </UL>
57 <LI><A NAME="TOC31" HREF="qemu-doc.html#SEC31">3.10.3 MS-DOS and FreeDOS</A>
58 <UL>
59 <LI><A NAME="TOC32" HREF="qemu-doc.html#SEC32">3.10.3.1 CPU usage reduction</A>
60 </UL>
61 </UL>
62 </UL>
63 <LI><A NAME="TOC33" HREF="qemu-doc.html#SEC33">4. QEMU PowerPC System emulator invocation</A>
64 <LI><A NAME="TOC34" HREF="qemu-doc.html#SEC34">5. Sparc32 System emulator invocation</A>
65 <LI><A NAME="TOC35" HREF="qemu-doc.html#SEC35">6. Sparc64 System emulator invocation</A>
66 <LI><A NAME="TOC36" HREF="qemu-doc.html#SEC36">7. MIPS System emulator invocation</A>
67 <LI><A NAME="TOC37" HREF="qemu-doc.html#SEC37">8. QEMU User space emulator invocation</A>
68 <UL>
69 <LI><A NAME="TOC38" HREF="qemu-doc.html#SEC38">8.1 Quick Start</A>
70 <LI><A NAME="TOC39" HREF="qemu-doc.html#SEC39">8.2 Wine launch</A>
71 <LI><A NAME="TOC40" HREF="qemu-doc.html#SEC40">8.3 Command line options</A>
72 </UL>
73 <LI><A NAME="TOC41" HREF="qemu-doc.html#SEC41">9. Compilation from the sources</A>
74 <UL>
75 <LI><A NAME="TOC42" HREF="qemu-doc.html#SEC42">9.1 Linux/Unix</A>
76 <UL>
77 <LI><A NAME="TOC43" HREF="qemu-doc.html#SEC43">9.1.1 Compilation</A>
78 <LI><A NAME="TOC44" HREF="qemu-doc.html#SEC44">9.1.2 Tested tool versions</A>
79 </UL>
80 <LI><A NAME="TOC45" HREF="qemu-doc.html#SEC45">9.2 Windows</A>
81 <LI><A NAME="TOC46" HREF="qemu-doc.html#SEC46">9.3 Cross compilation for Windows with Linux</A>
82 <LI><A NAME="TOC47" HREF="qemu-doc.html#SEC47">9.4 Mac OS X</A>
83 </UL>
84 </UL>
85 <P><HR><P>
86
87 <P>
88 QEMU CPU Emulator User Documentation
89
90
91
92
93 <H1><A NAME="SEC1" HREF="qemu-doc.html#TOC1">1. Introduction</A></H1>
94
95
96
97 <H2><A NAME="SEC2" HREF="qemu-doc.html#TOC2">1.1 Features</A></H2>
98
99 <P>
100 QEMU is a FAST! processor emulator using dynamic translation to
101 achieve good emulation speed.
102
103
104 <P>
105 QEMU has two operating modes:
106
107
108
109 <UL>
110
111 <LI>
112
113 Full system emulation. In this mode, QEMU emulates a full system (for
114 example a PC), including a processor and various peripherals. It can
115 be used to launch different Operating Systems without rebooting the
116 PC or to debug system code.
117
118 <LI>
119
120 User mode emulation (Linux host only). In this mode, QEMU can launch
121 Linux processes compiled for one CPU on another CPU. It can be used to
122 launch the Wine Windows API emulator (<A HREF="http://www.winehq.org">http://www.winehq.org</A>) or
123 to ease cross-compilation and cross-debugging.
124
125 </UL>
126
127 <P>
128 QEMU can run without an host kernel driver and yet gives acceptable
129 performance. 
130
131
132 <P>
133 For system emulation, the following hardware targets are supported:
134
135 <UL>
136 <LI>PC (x86 or x86_64 processor)
137
138 <LI>PREP (PowerPC processor)
139
140 <LI>G3 BW PowerMac (PowerPC processor)
141
142 <LI>Mac99 PowerMac (PowerPC processor, in progress)
143
144 <LI>Sun4m (32-bit Sparc processor)
145
146 <LI>Sun4u (64-bit Sparc processor, in progress)
147
148 <LI>Malta board (32-bit MIPS processor, in progress)
149
150 </UL>
151
152 <P>
153 For user emulation, x86, PowerPC, ARM, and Sparc32/64 CPUs are supported.
154
155
156
157
158 <H1><A NAME="SEC3" HREF="qemu-doc.html#TOC3">2. Installation</A></H1>
159
160 <P>
161 If you want to compile QEMU yourself, see section <A HREF="qemu-doc.html#SEC41">9. Compilation from the sources</A>.
162
163
164
165
166 <H2><A NAME="SEC4" HREF="qemu-doc.html#TOC4">2.1 Linux</A></H2>
167
168 <P>
169 If a precompiled package is available for your distribution - you just
170 have to install it. Otherwise, see section <A HREF="qemu-doc.html#SEC41">9. Compilation from the sources</A>.
171
172
173
174
175 <H2><A NAME="SEC5" HREF="qemu-doc.html#TOC5">2.2 Windows</A></H2>
176
177 <P>
178 Download the experimental binary installer at
179 <A HREF="http://www.freeoszoo.org/download.php">http://www.freeoszoo.org/download.php</A>.
180
181
182
183
184 <H2><A NAME="SEC6" HREF="qemu-doc.html#TOC6">2.3 Mac OS X</A></H2>
185
186 <P>
187 Download the experimental binary installer at
188 <A HREF="http://www.freeoszoo.org/download.php">http://www.freeoszoo.org/download.php</A>.
189
190
191
192
193 <H1><A NAME="SEC7" HREF="qemu-doc.html#TOC7">3. QEMU PC System emulator invocation</A></H1>
194
195
196
197 <H2><A NAME="SEC8" HREF="qemu-doc.html#TOC8">3.1 Introduction</A></H2>
198
199 <P>
200 The QEMU System emulator simulates the
201 following PC peripherals:
202
203
204
205 <UL>
206 <LI>
207
208 i440FX host PCI bridge and PIIX3 PCI to ISA bridge
209 <LI>
210
211 Cirrus CLGD 5446 PCI VGA card or dummy VGA card with Bochs VESA
212 extensions (hardware level, including all non standard modes).
213 <LI>
214
215 PS/2 mouse and keyboard
216 <LI>
217
218 2 PCI IDE interfaces with hard disk and CD-ROM support
219 <LI>
220
221 Floppy disk
222 <LI>
223
224 NE2000 PCI network adapters
225 <LI>
226
227 Serial ports
228 <LI>
229
230 Soundblaster 16 card
231 </UL>
232
233 <P>
234 QEMU uses the PC BIOS from the Bochs project and the Plex86/Bochs LGPL
235 VGA BIOS.
236
237
238
239
240 <H2><A NAME="SEC9" HREF="qemu-doc.html#TOC9">3.2 Quick Start</A></H2>
241
242 <P>
243 Download and uncompress the linux image (<TT>`linux.img'</TT>) and type:
244
245
246
247 <PRE>
248 qemu linux.img
249 </PRE>
250
251 <P>
252 Linux should boot and give you a prompt.
253
254
255
256
257 <H2><A NAME="SEC10" HREF="qemu-doc.html#TOC10">3.3 Invocation</A></H2>
258
259
260 <PRE>
261 usage: qemu [options] [disk_image]
262 </PRE>
263
264 <P>
265 <VAR>disk_image</VAR> is a raw hard disk image for IDE hard disk 0.
266
267
268 <P>
269 General options:
270 <DL COMPACT>
271
272 <DT><SAMP>`-fda file'</SAMP>
273 <DD>
274 <DT><SAMP>`-fdb file'</SAMP>
275 <DD>
276 Use <VAR>file</VAR> as floppy disk 0/1 image (See section <A HREF="qemu-doc.html#SEC15">3.6 Disk Images</A>). You can
277 use the host floppy by using <TT>`/dev/fd0'</TT> as filename.
278
279 <DT><SAMP>`-hda file'</SAMP>
280 <DD>
281 <DT><SAMP>`-hdb file'</SAMP>
282 <DD>
283 <DT><SAMP>`-hdc file'</SAMP>
284 <DD>
285 <DT><SAMP>`-hdd file'</SAMP>
286 <DD>
287 Use <VAR>file</VAR> as hard disk 0, 1, 2 or 3 image (See section <A HREF="qemu-doc.html#SEC15">3.6 Disk Images</A>).
288
289 <DT><SAMP>`-cdrom file'</SAMP>
290 <DD>
291 Use <VAR>file</VAR> as CD-ROM image (you cannot use <SAMP>`-hdc'</SAMP> and and
292 <SAMP>`-cdrom'</SAMP> at the same time). You can use the host CD-ROM by
293 using <TT>`/dev/cdrom'</TT> as filename.
294
295 <DT><SAMP>`-boot [a|c|d]'</SAMP>
296 <DD>
297 Boot on floppy (a), hard disk (c) or CD-ROM (d). Hard disk boot is
298 the default.
299
300 <DT><SAMP>`-snapshot'</SAMP>
301 <DD>
302 Write to temporary files instead of disk image files. In this case,
303 the raw disk image you use is not written back. You can however force
304 the write back by pressing <KBD>C-a s</KBD> (See section <A HREF="qemu-doc.html#SEC15">3.6 Disk Images</A>). 
305
306 <DT><SAMP>`-m megs'</SAMP>
307 <DD>
308 Set virtual RAM size to <VAR>megs</VAR> megabytes. Default is 128 MB.
309
310 <DT><SAMP>`-nographic'</SAMP>
311 <DD>
312 Normally, QEMU uses SDL to display the VGA output. With this option,
313 you can totally disable graphical output so that QEMU is a simple
314 command line application. The emulated serial port is redirected on
315 the console. Therefore, you can still use QEMU to debug a Linux kernel
316 with a serial console.
317
318 <DT><SAMP>`-k language'</SAMP>
319 <DD>
320 Use keyboard layout <VAR>language</VAR> (for example <CODE>fr</CODE> for
321 French). This option is only needed where it is not easy to get raw PC
322 keycodes (e.g. on Macs or with some X11 servers). You don't need to
323 use it on PC/Linux or PC/Windows hosts.
324
325 The available layouts are:
326
327 <PRE>
328 ar  de-ch  es  fo     fr-ca  hu  ja  mk     no  pt-br  sv
329 da  en-gb  et  fr     fr-ch  is  lt  nl     pl  ru     th
330 de  en-us  fi  fr-be  hr     it  lv  nl-be  pt  sl     tr
331 </PRE>
332
333 The default is <CODE>en-us</CODE>.
334
335 <DT><SAMP>`-enable-audio'</SAMP>
336 <DD>
337 The SB16 emulation is disabled by default as it may give problems with
338 Windows. You can enable it manually with this option.
339
340 <DT><SAMP>`-localtime'</SAMP>
341 <DD>
342 Set the real time clock to local time (the default is to UTC
343 time). This option is needed to have correct date in MS-DOS or
344 Windows.
345
346 <DT><SAMP>`-full-screen'</SAMP>
347 <DD>
348 Start in full screen.
349
350 <DT><SAMP>`-pidfile file'</SAMP>
351 <DD>
352 Store the QEMU process PID in <VAR>file</VAR>. It is useful if you launch QEMU
353 from a script.
354
355 <DT><SAMP>`-win2k-hack'</SAMP>
356 <DD>
357 Use it when installing Windows 2000 to avoid a disk full bug. After
358 Windows 2000 is installed, you no longer need this option (this option
359 slows down the IDE transfers).
360
361 </DL>
362
363 <P>
364 Network options:
365
366
367 <DL COMPACT>
368
369 <DT><SAMP>`-n script'</SAMP>
370 <DD>
371 Set TUN/TAP network init script [default=/etc/qemu-ifup]. This script
372 is launched to configure the host network interface (usually tun0)
373 corresponding to the virtual NE2000 card.
374
375 <DT><SAMP>`-nics n'</SAMP>
376 <DD>
377 Simulate <VAR>n</VAR> network cards (the default is 1).
378
379 <DT><SAMP>`-macaddr addr'</SAMP>
380 <DD>
381 Set the mac address of the first interface (the format is
382 aa:bb:cc:dd:ee:ff in hexa). The mac address is incremented for each
383 new network interface.
384
385 <DT><SAMP>`-tun-fd fd'</SAMP>
386 <DD>
387 Assumes <VAR>fd</VAR> talks to a tap/tun host network interface and use
388 it. Read <A HREF="http://bellard.org/qemu/tetrinet.html">http://bellard.org/qemu/tetrinet.html</A> to have an
389 example of its use.
390
391 <DT><SAMP>`-user-net'</SAMP>
392 <DD>
393 Use the user mode network stack. This is the default if no tun/tap
394 network init script is found.
395
396 <DT><SAMP>`-tftp prefix'</SAMP>
397 <DD>
398 When using the user mode network stack, activate a built-in TFTP
399 server. All filenames beginning with <VAR>prefix</VAR> can be downloaded
400 from the host to the guest using a TFTP client. The TFTP client on the
401 guest must be configured in binary mode (use the command <CODE>bin</CODE> of
402 the Unix TFTP client). The host IP address on the guest is as usual
403 10.0.2.2.
404
405 <DT><SAMP>`-smb dir'</SAMP>
406 <DD>
407 When using the user mode network stack, activate a built-in SMB
408 server so that Windows OSes can access to the host files in <TT>`dir'</TT>
409 transparently.
410
411 In the guest Windows OS, the line:
412
413 <PRE>
414 10.0.2.4 smbserver
415 </PRE>
416
417 must be added in the file <TT>`C:\WINDOWS\LMHOSTS'</TT> (for windows 9x/Me)
418 or <TT>`C:\WINNT\SYSTEM32\DRIVERS\ETC\LMHOSTS'</TT> (Windows NT/2000).
419
420 Then <TT>`dir'</TT> can be accessed in <TT>`\\smbserver\qemu'</TT>.
421
422 Note that a SAMBA server must be installed on the host OS in
423 <TT>`/usr/sbin/smbd'</TT>. QEMU was tested succesfully with smbd version
424 2.2.7a from the Red Hat 9.
425
426 <DT><SAMP>`-redir [tcp|udp]:host-port:[guest-host]:guest-port'</SAMP>
427 <DD>
428 When using the user mode network stack, redirect incoming TCP or UDP
429 connections to the host port <VAR>host-port</VAR> to the guest
430 <VAR>guest-host</VAR> on guest port <VAR>guest-port</VAR>. If <VAR>guest-host</VAR>
431 is not specified, its value is 10.0.2.15 (default address given by the
432 built-in DHCP server).
433
434 For example, to redirect host X11 connection from screen 1 to guest
435 screen 0, use the following:
436
437
438 <PRE>
439 # on the host
440 qemu -redir tcp:6001::6000 [...]
441 # this host xterm should open in the guest X11 server
442 xterm -display :1
443 </PRE>
444
445 To redirect telnet connections from host port 5555 to telnet port on
446 the guest, use the following:
447
448
449 <PRE>
450 # on the host
451 qemu -redir tcp:5555::23 [...]
452 telnet localhost 5555
453 </PRE>
454
455 Then when you use on the host <CODE>telnet localhost 5555</CODE>, you
456 connect to the guest telnet server.
457
458 <DT><SAMP>`-dummy-net'</SAMP>
459 <DD>
460 Use the dummy network stack: no packet will be received by the network
461 cards.
462
463 </DL>
464
465 <P>
466 Linux boot specific. When using this options, you can use a given
467 Linux kernel without installing it in the disk image. It can be useful
468 for easier testing of various kernels.
469
470
471 <DL COMPACT>
472
473 <DT><SAMP>`-kernel bzImage'</SAMP>
474 <DD>
475 Use <VAR>bzImage</VAR> as kernel image.
476
477 <DT><SAMP>`-append cmdline'</SAMP>
478 <DD>
479 Use <VAR>cmdline</VAR> as kernel command line
480
481 <DT><SAMP>`-initrd file'</SAMP>
482 <DD>
483 Use <VAR>file</VAR> as initial ram disk.
484
485 </DL>
486
487 <P>
488 Debug/Expert options:
489 <DL COMPACT>
490
491 <DT><SAMP>`-serial dev'</SAMP>
492 <DD>
493 Redirect the virtual serial port to host device <VAR>dev</VAR>. Available
494 devices are:
495 <DL COMPACT>
496
497 <DT><CODE>vc</CODE>
498 <DD>
499 Virtual console
500 <DT><CODE>pty</CODE>
501 <DD>
502 [Linux only] Pseudo TTY (a new PTY is automatically allocated)
503 <DT><CODE>null</CODE>
504 <DD>
505 void device
506 <DT><CODE>stdio</CODE>
507 <DD>
508 [Unix only] standard input/output
509 </DL>
510 The default device is <CODE>vc</CODE> in graphical mode and <CODE>stdio</CODE> in
511 non graphical mode.
512
513 This option can be used several times to simulate up to 4 serials
514 ports.
515
516 <DT><SAMP>`-monitor dev'</SAMP>
517 <DD>
518 Redirect the monitor to host device <VAR>dev</VAR> (same devices as the
519 serial port).
520 The default device is <CODE>vc</CODE> in graphical mode and <CODE>stdio</CODE> in
521 non graphical mode.
522
523 <DT><SAMP>`-s'</SAMP>
524 <DD>
525 Wait gdb connection to port 1234 (See section <A HREF="qemu-doc.html#SEC23">3.9 GDB usage</A>). 
526 <DT><SAMP>`-p port'</SAMP>
527 <DD>
528 Change gdb connection port.
529 <DT><SAMP>`-S'</SAMP>
530 <DD>
531 Do not start CPU at startup (you must type 'c' in the monitor).
532 <DT><SAMP>`-d'</SAMP>
533 <DD>
534 Output log in /tmp/qemu.log
535 <DT><SAMP>`-hdachs c,h,s,[,t]'</SAMP>
536 <DD>
537 Force hard disk 0 physical geometry (1 &#60;= <VAR>c</VAR> &#60;= 16383, 1 &#60;=
538 <VAR>h</VAR> &#60;= 16, 1 &#60;= <VAR>s</VAR> &#60;= 63) and optionally force the BIOS
539 translation mode (<VAR>t</VAR>=none, lba or auto). Usually QEMU can guess
540 all thoses parameters. This option is useful for old MS-DOS disk
541 images.
542
543 <DT><SAMP>`-isa'</SAMP>
544 <DD>
545 Simulate an ISA-only system (default is PCI system).
546 <DT><SAMP>`-std-vga'</SAMP>
547 <DD>
548 Simulate a standard VGA card with Bochs VBE extensions (default is
549 Cirrus Logic GD5446 PCI VGA)
550 <DT><SAMP>`-loadvm file'</SAMP>
551 <DD>
552 Start right away with a saved state (<CODE>loadvm</CODE> in monitor)
553 </DL>
554
555
556
557 <H2><A NAME="SEC11" HREF="qemu-doc.html#TOC11">3.4 Keys</A></H2>
558
559 <P>
560 During the graphical emulation, you can use the following keys:
561 <DL COMPACT>
562
563 <DT><KBD>Ctrl-Alt-f</KBD>
564 <DD>
565 Toggle full screen
566
567 <DT><KBD>Ctrl-Alt-n</KBD>
568 <DD>
569 Switch to virtual console 'n'. Standard console mappings are:
570 <DL COMPACT>
571
572 <DT><EM>1</EM>
573 <DD>
574 Target system display
575 <DT><EM>2</EM>
576 <DD>
577 Monitor
578 <DT><EM>3</EM>
579 <DD>
580 Serial port
581 </DL>
582
583 <DT><KBD>Ctrl-Alt</KBD>
584 <DD>
585 Toggle mouse and keyboard grab.
586 </DL>
587
588 <P>
589 In the virtual consoles, you can use <KBD>Ctrl-Up</KBD>, <KBD>Ctrl-Down</KBD>,
590 <KBD>Ctrl-PageUp</KBD> and <KBD>Ctrl-PageDown</KBD> to move in the back log.
591
592
593 <P>
594 During emulation, if you are using the <SAMP>`-nographic'</SAMP> option, use
595 <KBD>Ctrl-a h</KBD> to get terminal commands:
596
597
598 <DL COMPACT>
599
600 <DT><KBD>Ctrl-a h</KBD>
601 <DD>
602 Print this help
603 <DT><KBD>Ctrl-a x</KBD>
604 <DD>
605 Exit emulatior
606 <DT><KBD>Ctrl-a s</KBD>
607 <DD>
608 Save disk data back to file (if -snapshot)
609 <DT><KBD>Ctrl-a b</KBD>
610 <DD>
611 Send break (magic sysrq in Linux)
612 <DT><KBD>Ctrl-a c</KBD>
613 <DD>
614 Switch between console and monitor
615 <DT><KBD>Ctrl-a Ctrl-a</KBD>
616 <DD>
617 Send Ctrl-a
618 </DL>
619
620
621
622 <H2><A NAME="SEC12" HREF="qemu-doc.html#TOC12">3.5 QEMU Monitor</A></H2>
623
624 <P>
625 The QEMU monitor is used to give complex commands to the QEMU
626 emulator. You can use it to:
627
628
629
630 <UL>
631
632 <LI>
633
634 Remove or insert removable medias images
635 (such as CD-ROM or floppies)
636
637 <LI>
638
639 Freeze/unfreeze the Virtual Machine (VM) and save or restore its state
640 from a disk file.
641
642 <LI>Inspect the VM state without an external debugger.
643
644 </UL>
645
646
647
648 <H3><A NAME="SEC13" HREF="qemu-doc.html#TOC13">3.5.1 Commands</A></H3>
649
650 <P>
651 The following commands are available:
652
653
654 <DL COMPACT>
655
656 <DT><SAMP>`help or ? [cmd]'</SAMP>
657 <DD>
658 Show the help for all commands or just for command <VAR>cmd</VAR>.
659
660 <DT><SAMP>`commit'</SAMP>
661 <DD>
662 Commit changes to the disk images (if -snapshot is used)
663
664 <DT><SAMP>`info subcommand'</SAMP>
665 <DD>
666 show various information about the system state
667
668 <DL COMPACT>
669
670 <DT><SAMP>`info network'</SAMP>
671 <DD>
672 show the network state
673 <DT><SAMP>`info block'</SAMP>
674 <DD>
675 show the block devices
676 <DT><SAMP>`info registers'</SAMP>
677 <DD>
678 show the cpu registers
679 <DT><SAMP>`info history'</SAMP>
680 <DD>
681 show the command line history
682 </DL>
683
684 <DT><SAMP>`q or quit'</SAMP>
685 <DD>
686 Quit the emulator.
687
688 <DT><SAMP>`eject [-f] device'</SAMP>
689 <DD>
690 Eject a removable media (use -f to force it).
691
692 <DT><SAMP>`change device filename'</SAMP>
693 <DD>
694 Change a removable media.
695
696 <DT><SAMP>`screendump filename'</SAMP>
697 <DD>
698 Save screen into PPM image <VAR>filename</VAR>.
699
700 <DT><SAMP>`log item1[,...]'</SAMP>
701 <DD>
702 Activate logging of the specified items to <TT>`/tmp/qemu.log'</TT>.
703
704 <DT><SAMP>`savevm filename'</SAMP>
705 <DD>
706 Save the whole virtual machine state to <VAR>filename</VAR>.
707
708 <DT><SAMP>`loadvm filename'</SAMP>
709 <DD>
710 Restore the whole virtual machine state from <VAR>filename</VAR>.
711
712 <DT><SAMP>`stop'</SAMP>
713 <DD>
714 Stop emulation.
715
716 <DT><SAMP>`c or cont'</SAMP>
717 <DD>
718 Resume emulation.
719
720 <DT><SAMP>`gdbserver [port]'</SAMP>
721 <DD>
722 Start gdbserver session (default port=1234)
723
724 <DT><SAMP>`x/fmt addr'</SAMP>
725 <DD>
726 Virtual memory dump starting at <VAR>addr</VAR>.
727
728 <DT><SAMP>`xp /fmt addr'</SAMP>
729 <DD>
730 Physical memory dump starting at <VAR>addr</VAR>.
731
732 <VAR>fmt</VAR> is a format which tells the command how to format the
733 data. Its syntax is: <SAMP>`/{count}{format}{size}'</SAMP>
734
735 <DL COMPACT>
736
737 <DT><VAR>count</VAR>
738 <DD>
739 is the number of items to be dumped.
740
741 <DT><VAR>format</VAR>
742 <DD>
743 can be x (hexa), d (signed decimal), u (unsigned decimal), o (octal),
744 c (char) or i (asm instruction).
745
746 <DT><VAR>size</VAR>
747 <DD>
748 can be b (8 bits), h (16 bits), w (32 bits) or g (64 bits). On x86,
749 <CODE>h</CODE> or <CODE>w</CODE> can be specified with the <CODE>i</CODE> format to
750 respectively select 16 or 32 bit code instruction size.
751
752 </DL>
753
754 Examples: 
755
756 <UL>
757 <LI>
758
759 Dump 10 instructions at the current instruction pointer:
760
761 <PRE>
762 (qemu) x/10i $eip
763 0x90107063:  ret
764 0x90107064:  sti
765 0x90107065:  lea    0x0(%esi,1),%esi
766 0x90107069:  lea    0x0(%edi,1),%edi
767 0x90107070:  ret
768 0x90107071:  jmp    0x90107080
769 0x90107073:  nop
770 0x90107074:  nop
771 0x90107075:  nop
772 0x90107076:  nop
773 </PRE>
774
775 <LI>
776
777 Dump 80 16 bit values at the start of the video memory.
778
779 <PRE>
780 (qemu) xp/80hx 0xb8000
781 0x000b8000: 0x0b50 0x0b6c 0x0b65 0x0b78 0x0b38 0x0b36 0x0b2f 0x0b42
782 0x000b8010: 0x0b6f 0x0b63 0x0b68 0x0b73 0x0b20 0x0b56 0x0b47 0x0b41
783 0x000b8020: 0x0b42 0x0b69 0x0b6f 0x0b73 0x0b20 0x0b63 0x0b75 0x0b72
784 0x000b8030: 0x0b72 0x0b65 0x0b6e 0x0b74 0x0b2d 0x0b63 0x0b76 0x0b73
785 0x000b8040: 0x0b20 0x0b30 0x0b35 0x0b20 0x0b4e 0x0b6f 0x0b76 0x0b20
786 0x000b8050: 0x0b32 0x0b30 0x0b30 0x0b33 0x0720 0x0720 0x0720 0x0720
787 0x000b8060: 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720
788 0x000b8070: 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720
789 0x000b8080: 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720
790 0x000b8090: 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720
791 </PRE>
792
793 </UL>
794
795 <DT><SAMP>`p or print/fmt expr'</SAMP>
796 <DD>
797 Print expression value. Only the <VAR>format</VAR> part of <VAR>fmt</VAR> is
798 used.
799
800 <DT><SAMP>`sendkey keys'</SAMP>
801 <DD>
802 Send <VAR>keys</VAR> to the emulator. Use <CODE>-</CODE> to press several keys
803 simultaneously. Example:
804
805 <PRE>
806 sendkey ctrl-alt-f1
807 </PRE>
808
809 This command is useful to send keys that your graphical user interface
810 intercepts at low level, such as <CODE>ctrl-alt-f1</CODE> in X Window.
811
812 <DT><SAMP>`system_reset'</SAMP>
813 <DD>
814 Reset the system.
815
816 </DL>
817
818
819
820 <H3><A NAME="SEC14" HREF="qemu-doc.html#TOC14">3.5.2 Integer expressions</A></H3>
821
822 <P>
823 The monitor understands integers expressions for every integer
824 argument. You can use register names to get the value of specifics
825 CPU registers by prefixing them with <EM>$</EM>.
826
827
828
829
830 <H2><A NAME="SEC15" HREF="qemu-doc.html#TOC15">3.6 Disk Images</A></H2>
831
832 <P>
833 Since version 0.6.1, QEMU supports many disk image formats, including
834 growable disk images (their size increase as non empty sectors are
835 written), compressed and encrypted disk images.
836
837
838
839
840 <H3><A NAME="SEC16" HREF="qemu-doc.html#TOC16">3.6.1 Quick start for disk image creation</A></H3>
841
842 <P>
843 You can create a disk image with the command:
844
845 <PRE>
846 qemu-img create myimage.img mysize
847 </PRE>
848
849 <P>
850 where <VAR>myimage.img</VAR> is the disk image filename and <VAR>mysize</VAR> is its
851 size in kilobytes. You can add an <CODE>M</CODE> suffix to give the size in
852 megabytes and a <CODE>G</CODE> suffix for gigabytes.
853
854
855 <P>
856 See section <A HREF="qemu-doc.html#SEC18">3.6.3 <CODE>qemu-img</CODE> Invocation</A> for more information.
857
858
859
860
861 <H3><A NAME="SEC17" HREF="qemu-doc.html#TOC17">3.6.2 Snapshot mode</A></H3>
862
863 <P>
864 If you use the option <SAMP>`-snapshot'</SAMP>, all disk images are
865 considered as read only. When sectors in written, they are written in
866 a temporary file created in <TT>`/tmp'</TT>. You can however force the
867 write back to the raw disk images by using the <CODE>commit</CODE> monitor
868 command (or <KBD>C-a s</KBD> in the serial console).
869
870
871
872
873 <H3><A NAME="SEC18" HREF="qemu-doc.html#TOC18">3.6.3 <CODE>qemu-img</CODE> Invocation</A></H3>
874
875
876 <PRE>
877 usage: qemu-img command [command options]
878 </PRE>
879
880 <P>
881 The following commands are supported:
882 <DL COMPACT>
883
884 <DT><SAMP>`create [-e] [-b <VAR>base_image</VAR>] [-f <VAR>fmt</VAR>] <VAR>filename</VAR> [<VAR>size</VAR>]'</SAMP>
885 <DD>
886 <DT><SAMP>`commit [-f <VAR>fmt</VAR>] <VAR>filename</VAR>'</SAMP>
887 <DD>
888 <DT><SAMP>`convert [-c] [-e] [-f <VAR>fmt</VAR>] <VAR>filename</VAR> [-O <VAR>output_fmt</VAR>] <VAR>output_filename</VAR>'</SAMP>
889 <DD>
890 <DT><SAMP>`info [-f <VAR>fmt</VAR>] <VAR>filename</VAR>'</SAMP>
891 <DD>
892 </DL>
893
894 <P>
895 Command parameters:
896 <DL COMPACT>
897
898 <DT><VAR>filename</VAR>
899 <DD>
900  is a disk image filename
901 <DT><VAR>base_image</VAR>
902 <DD>
903 is the read-only disk image which is used as base for a copy on
904     write image; the copy on write image only stores the modified data
905
906 <DT><VAR>fmt</VAR>
907 <DD>
908 is the disk image format. It is guessed automatically in most cases. The following formats are supported:
909
910 <DL COMPACT>
911
912 <DT><CODE>raw</CODE>
913 <DD>
914 Raw disk image format (default). This format has the advantage of
915 being simple and easily exportable to all other emulators. If your file
916 system supports <EM>holes</EM> (for example in ext2 or ext3 on Linux),
917 then only the written sectors will reserve space. Use <CODE>qemu-img
918 info</CODE> to know the real size used by the image or <CODE>ls -ls</CODE> on
919 Unix/Linux.
920
921 <DT><CODE>qcow</CODE>
922 <DD>
923 QEMU image format, the most versatile format. Use it to have smaller
924 images (useful if your filesystem does not supports holes, for example
925 on Windows), optional AES encryption and zlib based compression.
926 <DT><CODE>cow</CODE>
927 <DD>
928 User Mode Linux Copy On Write image format. Used to be the only growable
929 image format in QEMU. It is supported only for compatibility with
930 previous versions. It does not work on win32.
931 <DT><CODE>vmdk</CODE>
932 <DD>
933 VMware 3 and 4 compatible image format.
934 <DT><CODE>cloop</CODE>
935 <DD>
936 Linux Compressed Loop image, useful only to reuse directly compressed
937 CD-ROM images present for example in the Knoppix CD-ROMs.
938 </DL>
939
940 <DT><VAR>size</VAR>
941 <DD>
942 is the disk image size in kilobytes. Optional suffixes <CODE>M</CODE>
943 (megabyte) and <CODE>G</CODE> (gigabyte) are supported 
944
945 <DT><VAR>output_filename</VAR>
946 <DD>
947 is the destination disk image filename 
948
949 <DT><VAR>output_fmt</VAR>
950 <DD>
951  is the destination format
952
953 <DT><VAR>-c</VAR>
954 <DD>
955 indicates that target image must be compressed (qcow format only)
956 <DT><VAR>-e</VAR>
957 <DD>
958 indicates that the target image must be encrypted (qcow format only)
959 </DL>
960
961 <P>
962 Command description:
963
964
965 <DL COMPACT>
966
967 <DT><SAMP>`create [-e] [-b <VAR>base_image</VAR>] [-f <VAR>fmt</VAR>] <VAR>filename</VAR> [<VAR>size</VAR>]'</SAMP>
968 <DD>
969 Create the new disk image <VAR>filename</VAR> of size <VAR>size</VAR> and format
970 <VAR>fmt</VAR>. 
971
972 If <VAR>base_image</VAR> is specified, then the image will record only the
973 differences from <VAR>base_image</VAR>. No size needs to be specified in
974 this case. <VAR>base_image</VAR> will never be modified unless you use the
975 <CODE>commit</CODE> monitor command.
976
977 <DT><SAMP>`commit [-f <VAR>fmt</VAR>] <VAR>filename</VAR>'</SAMP>
978 <DD>
979 Commit the changes recorded in <VAR>filename</VAR> in its base image.
980
981 <DT><SAMP>`convert [-c] [-e] [-f <VAR>fmt</VAR>] <VAR>filename</VAR> [-O <VAR>output_fmt</VAR>] <VAR>output_filename</VAR>'</SAMP>
982 <DD>
983 Convert the disk image <VAR>filename</VAR> to disk image <VAR>output_filename</VAR>
984 using format <VAR>output_fmt</VAR>. It can be optionnaly encrypted
985 (<CODE>-e</CODE> option) or compressed (<CODE>-c</CODE> option).
986
987 Only the format <CODE>qcow</CODE> supports encryption or compression. The
988 compression is read-only. It means that if a compressed sector is
989 rewritten, then it is rewritten as uncompressed data.
990
991 Encryption uses the AES format which is very secure (128 bit keys). Use
992 a long password (16 characters) to get maximum protection.
993
994 Image conversion is also useful to get smaller image when using a
995 growable format such as <CODE>qcow</CODE> or <CODE>cow</CODE>: the empty sectors
996 are detected and suppressed from the destination image.
997
998 <DT><SAMP>`info [-f <VAR>fmt</VAR>] <VAR>filename</VAR>'</SAMP>
999 <DD>
1000 Give information about the disk image <VAR>filename</VAR>. Use it in
1001 particular to know the size reserved on disk which can be different
1002 from the displayed size.
1003 </DL>
1004
1005
1006
1007 <H2><A NAME="SEC19" HREF="qemu-doc.html#TOC19">3.7 Network emulation</A></H2>
1008
1009 <P>
1010 QEMU simulates up to 6 networks cards (NE2000 boards). Each card can
1011 be connected to a specific host network interface.
1012
1013
1014
1015
1016 <H3><A NAME="SEC20" HREF="qemu-doc.html#TOC20">3.7.1 Using tun/tap network interface</A></H3>
1017
1018 <P>
1019 This is the standard way to emulate network. QEMU adds a virtual
1020 network device on your host (called <CODE>tun0</CODE>), and you can then
1021 configure it as if it was a real ethernet card.
1022
1023
1024 <P>
1025 As an example, you can download the <TT>`linux-test-xxx.tar.gz'</TT>
1026 archive and copy the script <TT>`qemu-ifup'</TT> in <TT>`/etc'</TT> and
1027 configure properly <CODE>sudo</CODE> so that the command <CODE>ifconfig</CODE>
1028 contained in <TT>`qemu-ifup'</TT> can be executed as root. You must verify
1029 that your host kernel supports the TUN/TAP network interfaces: the
1030 device <TT>`/dev/net/tun'</TT> must be present.
1031
1032
1033 <P>
1034 See section <A HREF="qemu-doc.html#SEC22">3.8 Direct Linux Boot</A> to have an example of network use with a
1035 Linux distribution.
1036
1037
1038
1039
1040 <H3><A NAME="SEC21" HREF="qemu-doc.html#TOC21">3.7.2 Using the user mode network stack</A></H3>
1041
1042 <P>
1043 By using the option <SAMP>`-user-net'</SAMP> or if you have no tun/tap init
1044 script, QEMU uses a completely user mode network stack (you don't need
1045 root priviledge to use the virtual network). The virtual network
1046 configuration is the following:
1047
1048
1049
1050 <PRE>
1051
1052 QEMU Virtual Machine    &#60;------&#62;  Firewall/DHCP server &#60;-----&#62; Internet
1053      (10.0.2.x)            |          (10.0.2.2)
1054                            |
1055                            ----&#62;  DNS server (10.0.2.3)
1056                            |     
1057                            ----&#62;  SMB server (10.0.2.4)
1058 </PRE>
1059
1060 <P>
1061 The QEMU VM behaves as if it was behind a firewall which blocks all
1062 incoming connections. You can use a DHCP client to automatically
1063 configure the network in the QEMU VM.
1064
1065
1066 <P>
1067 In order to check that the user mode network is working, you can ping
1068 the address 10.0.2.2 and verify that you got an address in the range
1069 10.0.2.x from the QEMU virtual DHCP server.
1070
1071
1072 <P>
1073 Note that <CODE>ping</CODE> is not supported reliably to the internet as it
1074 would require root priviledges. It means you can only ping the local
1075 router (10.0.2.2).
1076
1077
1078 <P>
1079 When using the built-in TFTP server, the router is also the TFTP
1080 server.
1081
1082
1083 <P>
1084 When using the <SAMP>`-redir'</SAMP> option, TCP or UDP connections can be
1085 redirected from the host to the guest. It allows for example to
1086 redirect X11, telnet or SSH connections.
1087
1088
1089
1090
1091 <H2><A NAME="SEC22" HREF="qemu-doc.html#TOC22">3.8 Direct Linux Boot</A></H2>
1092
1093 <P>
1094 This section explains how to launch a Linux kernel inside QEMU without
1095 having to make a full bootable image. It is very useful for fast Linux
1096 kernel testing. The QEMU network configuration is also explained.
1097
1098
1099
1100 <OL>
1101 <LI>
1102
1103 Download the archive <TT>`linux-test-xxx.tar.gz'</TT> containing a Linux
1104 kernel and a disk image. 
1105
1106 <LI>Optional: If you want network support (for example to launch X11 examples), you
1107
1108 must copy the script <TT>`qemu-ifup'</TT> in <TT>`/etc'</TT> and configure
1109 properly <CODE>sudo</CODE> so that the command <CODE>ifconfig</CODE> contained in
1110 <TT>`qemu-ifup'</TT> can be executed as root. You must verify that your host
1111 kernel supports the TUN/TAP network interfaces: the device
1112 <TT>`/dev/net/tun'</TT> must be present.
1113
1114 When network is enabled, there is a virtual network connection between
1115 the host kernel and the emulated kernel. The emulated kernel is seen
1116 from the host kernel at IP address 172.20.0.2 and the host kernel is
1117 seen from the emulated kernel at IP address 172.20.0.1.
1118
1119 <LI>Launch <CODE>qemu.sh</CODE>. You should have the following output:
1120
1121
1122 <PRE>
1123 &#62; ./qemu.sh 
1124 Connected to host network interface: tun0
1125 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
1126 BIOS-provided physical RAM map:
1127  BIOS-e801: 0000000000000000 - 000000000009f000 (usable)
1128  BIOS-e801: 0000000000100000 - 0000000002000000 (usable)
1129 32MB LOWMEM available.
1130 On node 0 totalpages: 8192
1131 zone(0): 4096 pages.
1132 zone(1): 4096 pages.
1133 zone(2): 0 pages.
1134 Kernel command line: root=/dev/hda sb=0x220,5,1,5 ide2=noprobe ide3=noprobe ide4=noprobe ide5=noprobe console=ttyS0
1135 ide_setup: ide2=noprobe
1136 ide_setup: ide3=noprobe
1137 ide_setup: ide4=noprobe
1138 ide_setup: ide5=noprobe
1139 Initializing CPU#0
1140 Detected 2399.621 MHz processor.
1141 Console: colour EGA 80x25
1142 Calibrating delay loop... 4744.80 BogoMIPS
1143 Memory: 28872k/32768k available (1210k kernel code, 3508k reserved, 266k data, 64k init, 0k highmem)
1144 Dentry cache hash table entries: 4096 (order: 3, 32768 bytes)
1145 Inode cache hash table entries: 2048 (order: 2, 16384 bytes)
1146 Mount cache hash table entries: 512 (order: 0, 4096 bytes)
1147 Buffer-cache hash table entries: 1024 (order: 0, 4096 bytes)
1148 Page-cache hash table entries: 8192 (order: 3, 32768 bytes)
1149 CPU: Intel Pentium Pro stepping 03
1150 Checking 'hlt' instruction... OK.
1151 POSIX conformance testing by UNIFIX
1152 Linux NET4.0 for Linux 2.4
1153 Based upon Swansea University Computer Society NET3.039
1154 Initializing RT netlink socket
1155 apm: BIOS not found.
1156 Starting kswapd
1157 Journalled Block Device driver loaded
1158 Detected PS/2 Mouse Port.
1159 pty: 256 Unix98 ptys configured
1160 Serial driver version 5.05c (2001-07-08) with no serial options enabled
1161 ttyS00 at 0x03f8 (irq = 4) is a 16450
1162 ne.c:v1.10 9/23/94 Donald Becker (becker@scyld.com)
1163 Last modified Nov 1, 2000 by Paul Gortmaker
1164 NE*000 ethercard probe at 0x300: 52 54 00 12 34 56
1165 eth0: NE2000 found at 0x300, using IRQ 9.
1166 RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
1167 Uniform Multi-Platform E-IDE driver Revision: 7.00beta4-2.4
1168 ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx
1169 hda: QEMU HARDDISK, ATA DISK drive
1170 ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
1171 hda: attached ide-disk driver.
1172 hda: 20480 sectors (10 MB) w/256KiB Cache, CHS=20/16/63
1173 Partition check:
1174  hda:
1175 Soundblaster audio driver Copyright (C) by Hannu Savolainen 1993-1996
1176 NET4: Linux TCP/IP 1.0 for NET4.0
1177 IP Protocols: ICMP, UDP, TCP, IGMP
1178 IP: routing cache hash table of 512 buckets, 4Kbytes
1179 TCP: Hash tables configured (established 2048 bind 4096)
1180 NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
1181 EXT2-fs warning: mounting unchecked fs, running e2fsck is recommended
1182 VFS: Mounted root (ext2 filesystem).
1183 Freeing unused kernel memory: 64k freed
1184  
1185 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
1186  
1187 QEMU Linux test distribution (based on Redhat 9)
1188  
1189 Type 'exit' to halt the system
1190  
1191 sh-2.05b# 
1192 </PRE>
1193
1194 <LI>
1195
1196 Then you can play with the kernel inside the virtual serial console. You
1197 can launch <CODE>ls</CODE> for example. Type <KBD>Ctrl-a h</KBD> to have an help
1198 about the keys you can type inside the virtual serial console. In
1199 particular, use <KBD>Ctrl-a x</KBD> to exit QEMU and use <KBD>Ctrl-a b</KBD> as
1200 the Magic SysRq key.
1201
1202 <LI>
1203
1204 If the network is enabled, launch the script <TT>`/etc/linuxrc'</TT> in the
1205 emulator (don't forget the leading dot):
1206
1207 <PRE>
1208 . /etc/linuxrc
1209 </PRE>
1210
1211 Then enable X11 connections on your PC from the emulated Linux: 
1212
1213 <PRE>
1214 xhost +172.20.0.2
1215 </PRE>
1216
1217 You can now launch <TT>`xterm'</TT> or <TT>`xlogo'</TT> and verify that you have
1218 a real Virtual Linux system !
1219
1220 </OL>
1221
1222 <P>
1223 NOTES:
1224
1225 <OL>
1226 <LI>
1227
1228 A 2.5.74 kernel is also included in the archive. Just
1229 replace the bzImage in qemu.sh to try it.
1230
1231 <LI>
1232
1233 In order to exit cleanly from qemu, you can do a <EM>shutdown</EM> inside
1234 qemu. qemu will automatically exit when the Linux shutdown is done.
1235
1236 <LI>
1237
1238 You can boot slightly faster by disabling the probe of non present IDE
1239 interfaces. To do so, add the following options on the kernel command
1240 line:
1241
1242 <PRE>
1243 ide1=noprobe ide2=noprobe ide3=noprobe ide4=noprobe ide5=noprobe
1244 </PRE>
1245
1246 <LI>
1247
1248 The example disk image is a modified version of the one made by Kevin
1249 Lawton for the plex86 Project (<A HREF="www.plex86.org">www.plex86.org</A>).
1250
1251 </OL>
1252
1253
1254
1255 <H2><A NAME="SEC23" HREF="qemu-doc.html#TOC23">3.9 GDB usage</A></H2>
1256
1257 <P>
1258 QEMU has a primitive support to work with gdb, so that you can do
1259 'Ctrl-C' while the virtual machine is running and inspect its state.
1260
1261
1262 <P>
1263 In order to use gdb, launch qemu with the '-s' option. It will wait for a
1264 gdb connection:
1265
1266 <PRE>
1267 &#62; qemu -s -kernel arch/i386/boot/bzImage -hda root-2.4.20.img -append "root=/dev/hda"
1268 Connected to host network interface: tun0
1269 Waiting gdb connection on port 1234
1270 </PRE>
1271
1272 <P>
1273 Then launch gdb on the 'vmlinux' executable:
1274
1275 <PRE>
1276 &#62; gdb vmlinux
1277 </PRE>
1278
1279 <P>
1280 In gdb, connect to QEMU:
1281
1282 <PRE>
1283 (gdb) target remote localhost:1234
1284 </PRE>
1285
1286 <P>
1287 Then you can use gdb normally. For example, type 'c' to launch the kernel:
1288
1289 <PRE>
1290 (gdb) c
1291 </PRE>
1292
1293 <P>
1294 Here are some useful tips in order to use gdb on system code:
1295
1296
1297
1298 <OL>
1299 <LI>
1300
1301 Use <CODE>info reg</CODE> to display all the CPU registers.
1302 <LI>
1303
1304 Use <CODE>x/10i $eip</CODE> to display the code at the PC position.
1305 <LI>
1306
1307 Use <CODE>set architecture i8086</CODE> to dump 16 bit code. Then use
1308 <CODE>x/10i $cs*16+*eip</CODE> to dump the code at the PC position.
1309 </OL>
1310
1311
1312
1313 <H2><A NAME="SEC24" HREF="qemu-doc.html#TOC24">3.10 Target OS specific information</A></H2>
1314
1315
1316
1317 <H3><A NAME="SEC25" HREF="qemu-doc.html#TOC25">3.10.1 Linux</A></H3>
1318
1319 <P>
1320 To have access to SVGA graphic modes under X11, use the <CODE>vesa</CODE> or
1321 the <CODE>cirrus</CODE> X11 driver. For optimal performances, use 16 bit
1322 color depth in the guest and the host OS.
1323
1324
1325 <P>
1326 When using a 2.6 guest Linux kernel, you should add the option
1327 <CODE>clock=pit</CODE> on the kernel command line because the 2.6 Linux
1328 kernels make very strict real time clock checks by default that QEMU
1329 cannot simulate exactly.
1330
1331
1332 <P>
1333 When using a 2.6 guest Linux kernel, verify that the 4G/4G patch is
1334 not activated because QEMU is slower with this patch. The QEMU
1335 Accelerator Module is also much slower in this case. Earlier Fedora
1336 Core 3 Linux kernel (&#60; 2.6.9-1.724_FC3) were known to incorporte this
1337 patch by default. Newer kernels don't have it.
1338
1339
1340
1341
1342 <H3><A NAME="SEC26" HREF="qemu-doc.html#TOC26">3.10.2 Windows</A></H3>
1343
1344 <P>
1345 If you have a slow host, using Windows 95 is better as it gives the
1346 best speed. Windows 2000 is also a good choice.
1347
1348
1349
1350
1351 <H4><A NAME="SEC27" HREF="qemu-doc.html#TOC27">3.10.2.1 SVGA graphic modes support</A></H4>
1352
1353 <P>
1354 QEMU emulates a Cirrus Logic GD5446 Video
1355 card. All Windows versions starting from Windows 95 should recognize
1356 and use this graphic card. For optimal performances, use 16 bit color
1357 depth in the guest and the host OS.
1358
1359
1360
1361
1362 <H4><A NAME="SEC28" HREF="qemu-doc.html#TOC28">3.10.2.2 CPU usage reduction</A></H4>
1363
1364 <P>
1365 Windows 9x does not correctly use the CPU HLT
1366 instruction. The result is that it takes host CPU cycles even when
1367 idle. You can install the utility from
1368 <A HREF="http://www.user.cityline.ru/~maxamn/amnhltm.zip">http://www.user.cityline.ru/~maxamn/amnhltm.zip</A> to solve this
1369 problem. Note that no such tool is needed for NT, 2000 or XP.
1370
1371
1372
1373
1374 <H4><A NAME="SEC29" HREF="qemu-doc.html#TOC29">3.10.2.3 Windows 2000 disk full problem</A></H4>
1375
1376 <P>
1377 Windows 2000 has a bug which gives a disk full problem during its
1378 installation. When installing it, use the <SAMP>`-win2k-hack'</SAMP> QEMU
1379 option to enable a specific workaround. After Windows 2000 is
1380 installed, you no longer need this option (this option slows down the
1381 IDE transfers).
1382
1383
1384
1385
1386 <H4><A NAME="SEC30" HREF="qemu-doc.html#TOC30">3.10.2.4 Windows XP security problems</A></H4>
1387
1388 <P>
1389 Some releases of Windows XP install correctly but give a security
1390 error when booting:
1391
1392 <PRE>
1393 A problem is preventing Windows from accurately checking the
1394 license for this computer. Error code: 0x800703e6.
1395 </PRE>
1396
1397 <P>
1398 The only known workaround is to boot in Safe mode
1399 without networking support. 
1400
1401
1402 <P>
1403 Future QEMU releases are likely to correct this bug.
1404
1405
1406
1407
1408 <H3><A NAME="SEC31" HREF="qemu-doc.html#TOC31">3.10.3 MS-DOS and FreeDOS</A></H3>
1409
1410
1411
1412 <H4><A NAME="SEC32" HREF="qemu-doc.html#TOC32">3.10.3.1 CPU usage reduction</A></H4>
1413
1414 <P>
1415 DOS does not correctly use the CPU HLT instruction. The result is that
1416 it takes host CPU cycles even when idle. You can install the utility
1417 from <A HREF="http://www.vmware.com/software/dosidle210.zip">http://www.vmware.com/software/dosidle210.zip</A> to solve this
1418 problem.
1419
1420
1421
1422
1423 <H1><A NAME="SEC33" HREF="qemu-doc.html#TOC33">4. QEMU PowerPC System emulator invocation</A></H1>
1424
1425 <P>
1426 Use the executable <TT>`qemu-system-ppc'</TT> to simulate a complete PREP
1427 or PowerMac PowerPC system.
1428
1429
1430 <P>
1431 QEMU emulates the following PowerMac peripherals:
1432
1433
1434
1435 <UL>
1436 <LI>
1437
1438 UniNorth PCI Bridge 
1439 <LI>
1440
1441 PCI VGA compatible card with VESA Bochs Extensions
1442 <LI>
1443
1444 2 PMAC IDE interfaces with hard disk and CD-ROM support
1445 <LI>
1446
1447 NE2000 PCI adapters
1448 <LI>
1449
1450 Non Volatile RAM
1451 <LI>
1452
1453 VIA-CUDA with ADB keyboard and mouse.
1454 </UL>
1455
1456 <P>
1457 QEMU emulates the following PREP peripherals:
1458
1459
1460
1461 <UL>
1462 <LI>
1463
1464 PCI Bridge
1465 <LI>
1466
1467 PCI VGA compatible card with VESA Bochs Extensions
1468 <LI>
1469
1470 2 IDE interfaces with hard disk and CD-ROM support
1471 <LI>
1472
1473 Floppy disk
1474 <LI>
1475
1476 NE2000 network adapters
1477 <LI>
1478
1479 Serial port
1480 <LI>
1481
1482 PREP Non Volatile RAM
1483 <LI>
1484
1485 PC compatible keyboard and mouse.
1486 </UL>
1487
1488 <P>
1489 QEMU uses the Open Hack'Ware Open Firmware Compatible BIOS available at
1490 <A HREF="http://site.voila.fr/jmayer/OpenHackWare/index.htm">http://site.voila.fr/jmayer/OpenHackWare/index.htm</A>.
1491
1492
1493 <P>
1494 You can read the qemu PC system emulation chapter to have more
1495 informations about QEMU usage.
1496
1497
1498 <P>
1499 The following options are specific to the PowerPC emulation:
1500
1501
1502 <DL COMPACT>
1503
1504 <DT><SAMP>`-prep'</SAMP>
1505 <DD>
1506 Simulate a PREP system (default is PowerMAC)
1507
1508 <DT><SAMP>`-g WxH[xDEPTH]'</SAMP>
1509 <DD>
1510 Set the initial VGA graphic mode. The default is 800x600x15.
1511
1512 </DL>
1513
1514 <P>
1515 More information is available at
1516 <A HREF="http://jocelyn.mayer.free.fr/qemu-ppc/">http://jocelyn.mayer.free.fr/qemu-ppc/</A>.
1517
1518
1519
1520
1521 <H1><A NAME="SEC34" HREF="qemu-doc.html#TOC34">5. Sparc32 System emulator invocation</A></H1>
1522
1523 <P>
1524 Use the executable <TT>`qemu-system-sparc'</TT> to simulate a JavaStation
1525 (sun4m architecture). The emulation is somewhat complete.
1526
1527
1528 <P>
1529 QEMU emulates the following sun4m peripherals:
1530
1531
1532
1533 <UL>
1534 <LI>
1535
1536 IOMMU
1537 <LI>
1538
1539 TCX Frame buffer
1540 <LI>
1541
1542 Lance (Am7990) Ethernet
1543 <LI>
1544
1545 Non Volatile RAM M48T08
1546 <LI>
1547
1548 Slave I/O: timers, interrupt controllers, Zilog serial ports, keyboard
1549 and power/reset logic
1550 <LI>
1551
1552 ESP SCSI controller with hard disk and CD-ROM support
1553 <LI>
1554
1555 Floppy drive
1556 </UL>
1557
1558 <P>
1559 The number of peripherals is fixed in the architecture.
1560
1561
1562 <P>
1563 QEMU uses the Proll, a PROM replacement available at
1564 <A HREF="http://people.redhat.com/zaitcev/linux/">http://people.redhat.com/zaitcev/linux/</A>. The required
1565 QEMU-specific patches are included with the sources.
1566
1567
1568 <P>
1569 A sample Linux 2.6 series kernel and ram disk image are available on
1570 the QEMU web site. Please note that currently neither Linux 2.4
1571 series, NetBSD, nor OpenBSD kernels work.
1572
1573
1574 <P>
1575 The following options are specific to the Sparc emulation:
1576
1577
1578 <DL COMPACT>
1579
1580 <DT><SAMP>`-g WxH'</SAMP>
1581 <DD>
1582 Set the initial TCX graphic mode. The default is 1024x768.
1583
1584 </DL>
1585
1586
1587
1588 <H1><A NAME="SEC35" HREF="qemu-doc.html#TOC35">6. Sparc64 System emulator invocation</A></H1>
1589
1590 <P>
1591 Use the executable <TT>`qemu-system-sparc64'</TT> to simulate a Sun4u machine.
1592 The emulator is not usable for anything yet.
1593
1594
1595 <P>
1596 QEMU emulates the following sun4u peripherals:
1597
1598
1599
1600 <UL>
1601 <LI>
1602
1603 UltraSparc IIi APB PCI Bridge 
1604 <LI>
1605
1606 PCI VGA compatible card with VESA Bochs Extensions
1607 <LI>
1608
1609 Non Volatile RAM M48T59
1610 <LI>
1611
1612 PC-compatible serial ports
1613 </UL>
1614
1615
1616
1617 <H1><A NAME="SEC36" HREF="qemu-doc.html#TOC36">7. MIPS System emulator invocation</A></H1>
1618
1619 <P>
1620 Use the executable <TT>`qemu-system-mips'</TT> to simulate a MIPS machine.
1621 The emulator begins to launch a Linux kernel.
1622
1623
1624
1625
1626 <H1><A NAME="SEC37" HREF="qemu-doc.html#TOC37">8. QEMU User space emulator invocation</A></H1>
1627
1628
1629
1630 <H2><A NAME="SEC38" HREF="qemu-doc.html#TOC38">8.1 Quick Start</A></H2>
1631
1632 <P>
1633 In order to launch a Linux process, QEMU needs the process executable
1634 itself and all the target (x86) dynamic libraries used by it. 
1635
1636
1637
1638 <UL>
1639
1640 <LI>On x86, you can just try to launch any process by using the native
1641
1642 libraries:
1643
1644
1645 <PRE>
1646 qemu-i386 -L / /bin/ls
1647 </PRE>
1648
1649 <CODE>-L /</CODE> tells that the x86 dynamic linker must be searched with a
1650 <TT>`/'</TT> prefix.
1651
1652 <LI>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):
1653
1654
1655 <PRE>
1656 qemu-i386 -L / qemu-i386 -L / /bin/ls
1657 </PRE>
1658
1659 <LI>On non x86 CPUs, you need first to download at least an x86 glibc
1660
1661 (<TT>`qemu-runtime-i386-XXX-.tar.gz'</TT> on the QEMU web page). Ensure that
1662 <CODE>LD_LIBRARY_PATH</CODE> is not set:
1663
1664
1665 <PRE>
1666 unset LD_LIBRARY_PATH 
1667 </PRE>
1668
1669 Then you can launch the precompiled <TT>`ls'</TT> x86 executable:
1670
1671
1672 <PRE>
1673 qemu-i386 tests/i386/ls
1674 </PRE>
1675
1676 You can look at <TT>`qemu-binfmt-conf.sh'</TT> so that
1677 QEMU is automatically launched by the Linux kernel when you try to
1678 launch x86 executables. It requires the <CODE>binfmt_misc</CODE> module in the
1679 Linux kernel.
1680
1681 <LI>The x86 version of QEMU is also included. You can try weird things such as:
1682
1683
1684 <PRE>
1685 qemu-i386 /usr/local/qemu-i386/bin/qemu-i386 /usr/local/qemu-i386/bin/ls-i386
1686 </PRE>
1687
1688 </UL>
1689
1690
1691
1692 <H2><A NAME="SEC39" HREF="qemu-doc.html#TOC39">8.2 Wine launch</A></H2>
1693
1694
1695 <UL>
1696
1697 <LI>Ensure that you have a working QEMU with the x86 glibc
1698
1699 distribution (see previous section). In order to verify it, you must be
1700 able to do:
1701
1702
1703 <PRE>
1704 qemu-i386 /usr/local/qemu-i386/bin/ls-i386
1705 </PRE>
1706
1707 <LI>Download the binary x86 Wine install
1708
1709 (<TT>`qemu-XXX-i386-wine.tar.gz'</TT> on the QEMU web page). 
1710
1711 <LI>Configure Wine on your account. Look at the provided script
1712
1713 <TT>`/usr/local/qemu-i386/bin/wine-conf.sh'</TT>. Your previous
1714 <CODE>${HOME}/.wine</CODE> directory is saved to <CODE>${HOME}/.wine.org</CODE>.
1715
1716 <LI>Then you can try the example <TT>`putty.exe'</TT>:
1717
1718
1719 <PRE>
1720 qemu-i386 /usr/local/qemu-i386/wine/bin/wine /usr/local/qemu-i386/wine/c/Program\ Files/putty.exe
1721 </PRE>
1722
1723 </UL>
1724
1725
1726
1727 <H2><A NAME="SEC40" HREF="qemu-doc.html#TOC40">8.3 Command line options</A></H2>
1728
1729
1730 <PRE>
1731 usage: qemu-i386 [-h] [-d] [-L path] [-s size] program [arguments...]
1732 </PRE>
1733
1734 <DL COMPACT>
1735
1736 <DT><SAMP>`-h'</SAMP>
1737 <DD>
1738 Print the help
1739 <DT><SAMP>`-L path'</SAMP>
1740 <DD>
1741 Set the x86 elf interpreter prefix (default=/usr/local/qemu-i386)
1742 <DT><SAMP>`-s size'</SAMP>
1743 <DD>
1744 Set the x86 stack size in bytes (default=524288)
1745 </DL>
1746
1747 <P>
1748 Debug options:
1749
1750
1751 <DL COMPACT>
1752
1753 <DT><SAMP>`-d'</SAMP>
1754 <DD>
1755 Activate log (logfile=/tmp/qemu.log)
1756 <DT><SAMP>`-p pagesize'</SAMP>
1757 <DD>
1758 Act as if the host page size was 'pagesize' bytes
1759 </DL>
1760
1761
1762
1763 <H1><A NAME="SEC41" HREF="qemu-doc.html#TOC41">9. Compilation from the sources</A></H1>
1764
1765
1766
1767 <H2><A NAME="SEC42" HREF="qemu-doc.html#TOC42">9.1 Linux/Unix</A></H2>
1768
1769
1770
1771 <H3><A NAME="SEC43" HREF="qemu-doc.html#TOC43">9.1.1 Compilation</A></H3>
1772
1773 <P>
1774 First you must decompress the sources:
1775
1776 <PRE>
1777 cd /tmp
1778 tar zxvf qemu-x.y.z.tar.gz
1779 cd qemu-x.y.z
1780 </PRE>
1781
1782 <P>
1783 Then you configure QEMU and build it (usually no options are needed):
1784
1785 <PRE>
1786 ./configure
1787 make
1788 </PRE>
1789
1790 <P>
1791 Then type as root user:
1792
1793 <PRE>
1794 make install
1795 </PRE>
1796
1797 <P>
1798 to install QEMU in <TT>`/usr/local'</TT>.
1799
1800
1801
1802
1803 <H3><A NAME="SEC44" HREF="qemu-doc.html#TOC44">9.1.2 Tested tool versions</A></H3>
1804
1805 <P>
1806 In order to compile QEMU succesfully, it is very important that you
1807 have the right tools. The most important one is gcc. I cannot guaranty
1808 that QEMU works if you do not use a tested gcc version. Look at
1809 'configure' and 'Makefile' if you want to make a different gcc
1810 version work.
1811
1812
1813
1814 <PRE>
1815 host      gcc      binutils      glibc    linux       distribution
1816 ----------------------------------------------------------------------
1817 x86       3.2      2.13.2        2.1.3    2.4.18
1818           2.96     2.11.93.0.2   2.2.5    2.4.18      Red Hat 7.3
1819           3.2.2    2.13.90.0.18  2.3.2    2.4.20      Red Hat 9
1820
1821 PowerPC   3.3 [4]  2.13.90.0.18  2.3.1    2.4.20briq
1822           3.2
1823
1824 Alpha     3.3 [1]  2.14.90.0.4   2.2.5    2.2.20 [2]  Debian 3.0
1825
1826 Sparc32   2.95.4   2.12.90.0.1   2.2.5    2.4.18      Debian 3.0
1827
1828 ARM       2.95.4   2.12.90.0.1   2.2.5    2.4.9 [3]   Debian 3.0
1829
1830 [1] On Alpha, QEMU needs the gcc 'visibility' attribute only available
1831     for gcc version &#62;= 3.3.
1832 [2] Linux &#62;= 2.4.20 is necessary for precise exception support
1833     (untested).
1834 [3] 2.4.9-ac10-rmk2-np1-cerf2
1835
1836 [4] gcc 2.95.x generates invalid code when using too many register
1837 variables. You must use gcc 3.x on PowerPC.
1838 </PRE>
1839
1840
1841
1842 <H2><A NAME="SEC45" HREF="qemu-doc.html#TOC45">9.2 Windows</A></H2>
1843
1844
1845 <UL>
1846 <LI>Install the current versions of MSYS and MinGW from
1847
1848 <A HREF="http://www.mingw.org/">http://www.mingw.org/</A>. You can find detailed installation
1849 instructions in the download section and the FAQ.
1850
1851 <LI>Download
1852
1853 the MinGW development library of SDL 1.2.x
1854 (<TT>`SDL-devel-1.2.x-mingw32.tar.gz'</TT>) from
1855 <A HREF="http://www.libsdl.org">http://www.libsdl.org</A>. Unpack it in a temporary place, and
1856 unpack the archive <TT>`i386-mingw32msvc.tar.gz'</TT> in the MinGW tool
1857 directory. Edit the <TT>`sdl-config'</TT> script so that it gives the
1858 correct SDL directory when invoked.
1859
1860 <LI>Extract the current version of QEMU.
1861
1862  
1863 <LI>Start the MSYS shell (file <TT>`msys.bat'</TT>).
1864
1865 <LI>Change to the QEMU directory. Launch <TT>`./configure'</TT> and
1866
1867 <TT>`make'</TT>.  If you have problems using SDL, verify that
1868 <TT>`sdl-config'</TT> can be launched from the MSYS command line.
1869
1870 <LI>You can install QEMU in <TT>`Program Files/Qemu'</TT> by typing
1871
1872 <TT>`make install'</TT>. Don't forget to copy <TT>`SDL.dll'</TT> in
1873 <TT>`Program Files/Qemu'</TT>.
1874
1875 </UL>
1876
1877
1878
1879 <H2><A NAME="SEC46" HREF="qemu-doc.html#TOC46">9.3 Cross compilation for Windows with Linux</A></H2>
1880
1881
1882 <UL>
1883 <LI>
1884
1885 Install the MinGW cross compilation tools available at
1886 <A HREF="http://www.mingw.org/">http://www.mingw.org/</A>.
1887
1888 <LI>
1889
1890 Install the Win32 version of SDL (<A HREF="http://www.libsdl.org">http://www.libsdl.org</A>) by
1891 unpacking <TT>`i386-mingw32msvc.tar.gz'</TT>. Set up the PATH environment
1892 variable so that <TT>`i386-mingw32msvc-sdl-config'</TT> can be launched by
1893 the QEMU configuration script.
1894
1895 <LI>
1896
1897 Configure QEMU for Windows cross compilation:
1898
1899 <PRE>
1900 ./configure --enable-mingw32
1901 </PRE>
1902
1903 If necessary, you can change the cross-prefix according to the prefix
1904 choosen for the MinGW tools with --cross-prefix. You can also use
1905 --prefix to set the Win32 install path.
1906
1907 <LI>You can install QEMU in the installation directory by typing
1908
1909 <TT>`make install'</TT>. Don't forget to copy <TT>`SDL.dll'</TT> in the
1910 installation directory. 
1911
1912 </UL>
1913
1914 <P>
1915 Note: Currently, Wine does not seem able to launch
1916 QEMU for Win32.
1917
1918
1919
1920
1921 <H2><A NAME="SEC47" HREF="qemu-doc.html#TOC47">9.4 Mac OS X</A></H2>
1922
1923 <P>
1924 The Mac OS X patches are not fully merged in QEMU, so you should look
1925 at the QEMU mailing list archive to have all the necessary
1926 information.
1927
1928
1929 <P><HR><P>
1930 This document was generated on 24 July 2005 using
1931 <A HREF="http://wwwinfo.cern.ch/dis/texi2html/">texi2html</A>&nbsp;1.56k.
1932 </BODY>
1933 </HTML>