blob: 57cf8f8d33f6db32b738e1b2aebee0a9bb55b713 [file] [log] [blame]
bellard386405f2003-03-23 21:28:45 +00001\input texinfo @c -*- texinfo -*-
2
bellard0806e3f2003-10-01 00:15:32 +00003@iftex
bellard1f673132004-04-04 15:21:17 +00004@settitle QEMU CPU Emulator User Documentation
bellard386405f2003-03-23 21:28:45 +00005@titlepage
6@sp 7
bellard1f673132004-04-04 15:21:17 +00007@center @titlefont{QEMU CPU Emulator User Documentation}
bellard386405f2003-03-23 21:28:45 +00008@sp 3
9@end titlepage
bellard0806e3f2003-10-01 00:15:32 +000010@end iftex
bellard386405f2003-03-23 21:28:45 +000011
12@chapter Introduction
13
bellard322d0c62003-06-15 23:29:28 +000014@section Features
bellard386405f2003-03-23 21:28:45 +000015
bellard1f673132004-04-04 15:21:17 +000016QEMU is a FAST! processor emulator using dynamic translation to
17achieve good emulation speed.
bellard1eb20522003-06-25 16:21:49 +000018
19QEMU has two operating modes:
bellard0806e3f2003-10-01 00:15:32 +000020
21@itemize @minus
22
23@item
bellard1f673132004-04-04 15:21:17 +000024Full system emulation. In this mode, QEMU emulates a full system (for
25example a PC), including a processor and various peripherials. It can
26be used to launch different Operating Systems without rebooting the
27PC or to debug system code.
bellard1eb20522003-06-25 16:21:49 +000028
bellard0806e3f2003-10-01 00:15:32 +000029@item
bellard1f673132004-04-04 15:21:17 +000030User mode emulation (Linux host only). In this mode, QEMU can launch
31Linux processes compiled for one CPU on another CPU. It can be used to
32launch the Wine Windows API emulator (@url{http://www.winehq.org}) or
33to ease cross-compilation and cross-debugging.
bellard1eb20522003-06-25 16:21:49 +000034
35@end itemize
36
bellard1f673132004-04-04 15:21:17 +000037As QEMU requires no host kernel driver to run, it is very safe and
bellard1eb20522003-06-25 16:21:49 +000038easy to use.
bellard322d0c62003-06-15 23:29:28 +000039
bellard52c00a52004-04-25 21:27:03 +000040For system emulation, the following hardware targets are supported:
41@itemize
42@item PC (x86 processor)
43@item PREP (PowerPC processor)
44@end itemize
bellard386405f2003-03-23 21:28:45 +000045
bellard1f673132004-04-04 15:21:17 +000046For user emulation, x86, PowerPC, ARM, and SPARC CPUs are supported.
bellard0806e3f2003-10-01 00:15:32 +000047
bellard5b9f4572003-10-28 00:49:54 +000048@chapter Installation
49
bellard1f673132004-04-04 15:21:17 +000050@section Linux
51
bellard5b9f4572003-10-28 00:49:54 +000052If you want to compile QEMU, please read the @file{README} which gives
53the related information. Otherwise just download the binary
54distribution (@file{qemu-XXX-i386.tar.gz}) and untar it as root in
55@file{/}:
56
57@example
58su
59cd /
60tar zxvf /tmp/qemu-XXX-i386.tar.gz
61@end example
62
bellard1f673132004-04-04 15:21:17 +000063@section Windows
64w
bellardd691f662003-03-24 21:58:34 +000065@itemize
bellard1f673132004-04-04 15:21:17 +000066@item Install the current versions of MSYS and MinGW from
67@url{http://www.mingw.org/}. You can find detailed installation
68instructions in the download section and the FAQ.
bellardd691f662003-03-24 21:58:34 +000069
bellard1f673132004-04-04 15:21:17 +000070@item Download
71the MinGW development library of SDL 1.2.x
72(@file{SDL-devel-1.2.x-mingw32.tar.gz}) from
73@url{http://www.libsdl.org}. Unpack it in a temporary place, and
74unpack the archive @file{i386-mingw32msvc.tar.gz} in the MinGW tool
75directory. Edit the @file{sdl-config} script so that it gives the
76correct SDL directory when invoked.
bellard386405f2003-03-23 21:28:45 +000077
bellard1f673132004-04-04 15:21:17 +000078@item Extract the current version of QEMU.
79
80@item Start the MSYS shell (file @file{msys.bat}).
bellard386405f2003-03-23 21:28:45 +000081
bellard1f673132004-04-04 15:21:17 +000082@item Change to the QEMU directory. Launch @file{./configure} and
83@file{make}. If you have problems using SDL, verify that
84@file{sdl-config} can be launched from the MSYS command line.
bellard386405f2003-03-23 21:28:45 +000085
bellard1f673132004-04-04 15:21:17 +000086@item You can install QEMU in @file{Program Files/Qemu} by typing
87@file{make install}. Don't forget to copy @file{SDL.dll} in
88@file{Program Files/Qemu}.
bellard1eb87252003-04-11 01:12:28 +000089
bellard168485b2003-03-29 16:57:34 +000090@end itemize
91
bellard1f673132004-04-04 15:21:17 +000092@section Cross compilation for Windows with Linux
bellard168485b2003-03-29 16:57:34 +000093
94@itemize
bellard1f673132004-04-04 15:21:17 +000095@item
96Install the MinGW cross compilation tools available at
97@url{http://www.mingw.org/}.
bellard168485b2003-03-29 16:57:34 +000098
bellard1f673132004-04-04 15:21:17 +000099@item
100Install the Win32 version of SDL (@url{http://www.libsdl.org}) by
101unpacking @file{i386-mingw32msvc.tar.gz}. Set up the PATH environment
102variable so that @file{i386-mingw32msvc-sdl-config} can be launched by
103the QEMU configuration script.
bellard168485b2003-03-29 16:57:34 +0000104
bellard1f673132004-04-04 15:21:17 +0000105@item
106Configure QEMU for Windows cross compilation:
bellard168485b2003-03-29 16:57:34 +0000107@example
bellard1f673132004-04-04 15:21:17 +0000108./configure --enable-mingw32
bellard168485b2003-03-29 16:57:34 +0000109@end example
bellard1f673132004-04-04 15:21:17 +0000110If necessary, you can change the cross-prefix according to the prefix
111choosen for the MinGW tools with --cross-prefix. You can also use
112--prefix to set the Win32 install path.
bellard168485b2003-03-29 16:57:34 +0000113
bellard1f673132004-04-04 15:21:17 +0000114@item You can install QEMU in the installation directory by typing
115@file{make install}. Don't forget to copy @file{SDL.dll} in the
116installation directory.
bellardd691f662003-03-24 21:58:34 +0000117
118@end itemize
119
bellard1f673132004-04-04 15:21:17 +0000120Note: Currently, Wine does not seem able to launch
121QEMU for Win32.
bellardd691f662003-03-24 21:58:34 +0000122
bellard1f673132004-04-04 15:21:17 +0000123@section Mac OS X
bellardd691f662003-03-24 21:58:34 +0000124
bellard1f673132004-04-04 15:21:17 +0000125Mac OS X is currently not supported.
bellarddf0f11a2003-05-28 00:27:57 +0000126
bellard52c00a52004-04-25 21:27:03 +0000127@chapter QEMU PC System emulator invocation
bellard1eb20522003-06-25 16:21:49 +0000128
bellard0806e3f2003-10-01 00:15:32 +0000129@section Introduction
130
131@c man begin DESCRIPTION
132
bellard52c00a52004-04-25 21:27:03 +0000133The QEMU System emulator simulates a complete PC.
bellard0806e3f2003-10-01 00:15:32 +0000134
135In order to meet specific user needs, two versions of QEMU are
136available:
137
138@enumerate
139
140@item
bellard285dc332003-10-27 23:58:04 +0000141@code{qemu-fast} uses the host Memory Management Unit (MMU) to simulate
bellard0806e3f2003-10-01 00:15:32 +0000142the x86 MMU. It is @emph{fast} but has limitations because the whole 4 GB
143address space cannot be used and some memory mapped peripherials
144cannot be emulated accurately yet. Therefore, a specific Linux kernel
145must be used (@xref{linux_compile}).
146
147@item
bellard285dc332003-10-27 23:58:04 +0000148@code{qemu} uses a software MMU. It is about @emph{two times
149slower} but gives a more accurate emulation.
bellard0806e3f2003-10-01 00:15:32 +0000150
151@end enumerate
152
153QEMU emulates the following PC peripherials:
154
155@itemize @minus
156@item
157VGA (hardware level, including all non standard modes)
158@item
159PS/2 mouse and keyboard
160@item
bellard181f1552003-11-13 01:47:16 +00001612 IDE interfaces with hard disk and CD-ROM support
bellard1f673132004-04-04 15:21:17 +0000162@item
163Floppy disk
bellard0806e3f2003-10-01 00:15:32 +0000164@item
bellard1f673132004-04-04 15:21:17 +0000165up to 6 NE2000 network adapters
bellard0806e3f2003-10-01 00:15:32 +0000166@item
bellard181f1552003-11-13 01:47:16 +0000167Serial port
168@item
169Soundblaster 16 card
bellard0806e3f2003-10-01 00:15:32 +0000170@end itemize
171
172@c man end
173
bellard1eb20522003-06-25 16:21:49 +0000174@section Quick Start
175
bellard285dc332003-10-27 23:58:04 +0000176Download and uncompress the linux image (@file{linux.img}) and type:
bellard0806e3f2003-10-01 00:15:32 +0000177
178@example
bellard285dc332003-10-27 23:58:04 +0000179qemu linux.img
bellard0806e3f2003-10-01 00:15:32 +0000180@end example
181
182Linux should boot and give you a prompt.
183
bellard1f673132004-04-04 15:21:17 +0000184@section Invocation
185
186@example
187@c man begin SYNOPSIS
188usage: qemu [options] [disk_image]
189@c man end
190@end example
191
192@c man begin OPTIONS
193@var{disk_image} is a raw hard disk image for IDE hard disk 0.
194
195General options:
196@table @option
197@item -fda file
198@item -fdb file
199Use @var{file} as floppy disk 0/1 image (@xref{disk_images}).
200
201@item -hda file
202@item -hdb file
203@item -hdc file
204@item -hdd file
205Use @var{file} as hard disk 0, 1, 2 or 3 image (@xref{disk_images}).
206
207@item -cdrom file
208Use @var{file} as CD-ROM image (you cannot use @option{-hdc} and and
209@option{-cdrom} at the same time).
210
211@item -boot [a|c|d]
212Boot on floppy (a), hard disk (c) or CD-ROM (d). Hard disk boot is
213the default.
214
215@item -snapshot
216Write to temporary files instead of disk image files. In this case,
217the raw disk image you use is not written back. You can however force
218the write back by pressing @key{C-a s} (@xref{disk_images}).
219
220@item -m megs
221Set virtual RAM size to @var{megs} megabytes.
222
223@item -initrd file
224Use @var{file} as initial ram disk.
225
226@item -nographic
227
228Normally, QEMU uses SDL to display the VGA output. With this option,
229you can totally disable graphical output so that QEMU is a simple
230command line application. The emulated serial port is redirected on
231the console. Therefore, you can still use QEMU to debug a Linux kernel
232with a serial console.
233
234@end table
235
236Network options:
237
238@table @option
239
240@item -n script
bellard52c00a52004-04-25 21:27:03 +0000241Set TUN/TAP network init script [default=/etc/qemu-ifup]. This script
242is launched to configure the host network interface (usually tun0)
bellard1f673132004-04-04 15:21:17 +0000243corresponding to the virtual NE2000 card.
244
bellard1f673132004-04-04 15:21:17 +0000245@item -macaddr addr
246
247Set the mac address of the first interface (the format is
248aa:bb:cc:dd:ee:ff in hexa). The mac address is incremented for each
249new network interface.
250
bellard52c00a52004-04-25 21:27:03 +0000251@item -tun-fd fd
252Assumes @var{fd} talks to a tap/tun host network interface and use
253it. Read @url{http://bellard.org/qemu/tetrinet.html} to have an
254example of its use.
255
256@item -user-net
257(Experimental) Use the user mode network stack. This is the default if
258no tun/tap network init script is found.
259
260@item -dummy-net
261Use the dummy network stack: no packet will be received on the network
262cards.
bellard1f673132004-04-04 15:21:17 +0000263
264@end table
265
266Linux boot specific. When using this options, you can use a given
267Linux kernel without installing it in the disk image. It can be useful
268for easier testing of various kernels.
269
270@table @option
271
272@item -kernel bzImage
273Use @var{bzImage} as kernel image.
274
275@item -append cmdline
276Use @var{cmdline} as kernel command line
277
278@item -initrd file
279Use @var{file} as initial ram disk.
280
281@end table
282
283Debug options:
284@table @option
285@item -s
286Wait gdb connection to port 1234 (@xref{gdb_usage}).
287@item -p port
288Change gdb connection port.
bellard52c00a52004-04-25 21:27:03 +0000289@item -S
290Do not start CPU at startup (you must type 'c' in the monitor).
bellard1f673132004-04-04 15:21:17 +0000291@item -d
292Output log in /tmp/qemu.log
293@end table
294
295During emulation, if you are using the serial console, use @key{C-a h}
296to get terminal commands:
297
298@table @key
299@item C-a h
300Print this help
301@item C-a x
302Exit emulatior
303@item C-a s
304Save disk data back to file (if -snapshot)
305@item C-a b
306Send break (magic sysrq in Linux)
307@item C-a c
308Switch between console and monitor
309@item C-a C-a
310Send C-a
311@end table
312@c man end
313
314@ignore
315
316@setfilename qemu
317@settitle QEMU System Emulator
318
319@c man begin SEEALSO
320The HTML documentation of QEMU for more precise information and Linux
321user mode emulator invocation.
322@c man end
323
324@c man begin AUTHOR
325Fabrice Bellard
326@c man end
327
328@end ignore
329
330@end ignore
331
332
333@section QEMU Monitor
334
335The QEMU monitor is used to give complex commands to the QEMU
336emulator. You can use it to:
337
338@itemize @minus
339
340@item
341Remove or insert removable medias images
342(such as CD-ROM or floppies)
343
344@item
345Freeze/unfreeze the Virtual Machine (VM) and save or restore its state
346from a disk file.
347
348@item Inspect the VM state without an external debugger.
349
350@end itemize
351
352@subsection Commands
353
354The following commands are available:
355
356@table @option
357
358@item help or ? [cmd]
359Show the help for all commands or just for command @var{cmd}.
360
361@item commit
362Commit changes to the disk images (if -snapshot is used)
363
364@item info subcommand
365show various information about the system state
366
367@table @option
368@item info network
369show the network state
370@item info block
371show the block devices
372@item info registers
373show the cpu registers
374@item info history
375show the command line history
376@end table
377
378@item q or quit
379Quit the emulator.
380
381@item eject [-f] device
382Eject a removable media (use -f to force it).
383
384@item change device filename
385Change a removable media.
386
387@item screendump filename
388Save screen into PPM image @var{filename}.
389
390@item log item1[,...]
391Activate logging of the specified items to @file{/tmp/qemu.log}.
392
393@item savevm filename
394Save the whole virtual machine state to @var{filename}.
395
396@item loadvm filename
397Restore the whole virtual machine state from @var{filename}.
398
399@item stop
400Stop emulation.
401
402@item c or cont
403Resume emulation.
404
405@item gdbserver [port]
406Start gdbserver session (default port=1234)
407
408@item x/fmt addr
409Virtual memory dump starting at @var{addr}.
410
411@item xp /fmt addr
412Physical memory dump starting at @var{addr}.
413
414@var{fmt} is a format which tells the command how to format the
415data. Its syntax is: @option{/@{count@}@{format@}@{size@}}
416
417@table @var
418@item count
419is the number of items to be dumped.
420
421@item format
422can be x (hexa), d (signed decimal), u (unsigned decimal), o (octal),
423c (char) or i (asm instruction).
424
425@item size
bellard52c00a52004-04-25 21:27:03 +0000426can be b (8 bits), h (16 bits), w (32 bits) or g (64 bits). On x86,
427@code{h} or @code{w} can be specified with the @code{i} format to
428respectively select 16 or 32 bit code instruction size.
bellard1f673132004-04-04 15:21:17 +0000429
430@end table
431
432Examples:
433@itemize
434@item
435Dump 10 instructions at the current instruction pointer:
436@example
437(qemu) x/10i $eip
4380x90107063: ret
4390x90107064: sti
4400x90107065: lea 0x0(%esi,1),%esi
4410x90107069: lea 0x0(%edi,1),%edi
4420x90107070: ret
4430x90107071: jmp 0x90107080
4440x90107073: nop
4450x90107074: nop
4460x90107075: nop
4470x90107076: nop
448@end example
449
450@item
451Dump 80 16 bit values at the start of the video memory.
452@example
453(qemu) xp/80hx 0xb8000
4540x000b8000: 0x0b50 0x0b6c 0x0b65 0x0b78 0x0b38 0x0b36 0x0b2f 0x0b42
4550x000b8010: 0x0b6f 0x0b63 0x0b68 0x0b73 0x0b20 0x0b56 0x0b47 0x0b41
4560x000b8020: 0x0b42 0x0b69 0x0b6f 0x0b73 0x0b20 0x0b63 0x0b75 0x0b72
4570x000b8030: 0x0b72 0x0b65 0x0b6e 0x0b74 0x0b2d 0x0b63 0x0b76 0x0b73
4580x000b8040: 0x0b20 0x0b30 0x0b35 0x0b20 0x0b4e 0x0b6f 0x0b76 0x0b20
4590x000b8050: 0x0b32 0x0b30 0x0b30 0x0b33 0x0720 0x0720 0x0720 0x0720
4600x000b8060: 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720
4610x000b8070: 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720
4620x000b8080: 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720
4630x000b8090: 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720
464@end example
465@end itemize
466
467@item p or print/fmt expr
468
469Print expression value. Only the @var{format} part of @var{fmt} is
470used.
471
472@end table
473
474@subsection Integer expressions
475
476The monitor understands integers expressions for every integer
477argument. You can use register names to get the value of specifics
478CPU registers by prefixing them with @emph{$}.
479
480@node disk_images
481@section Disk Images
482
483@subsection Raw disk images
484
485The disk images can simply be raw images of the hard disk. You can
486create them with the command:
487@example
488dd if=/dev/zero of=myimage bs=1024 count=mysize
489@end example
490where @var{myimage} is the image filename and @var{mysize} is its size
491in kilobytes.
492
493@subsection Snapshot mode
494
495If you use the option @option{-snapshot}, all disk images are
496considered as read only. When sectors in written, they are written in
497a temporary file created in @file{/tmp}. You can however force the
498write back to the raw disk images by pressing @key{C-a s}.
499
500NOTE: The snapshot mode only works with raw disk images.
501
502@subsection Copy On Write disk images
503
504QEMU also supports user mode Linux
505(@url{http://user-mode-linux.sourceforge.net/}) Copy On Write (COW)
506disk images. The COW disk images are much smaller than normal images
507as they store only modified sectors. They also permit the use of the
508same disk image template for many users.
509
510To create a COW disk images, use the command:
511
512@example
513qemu-mkcow -f myrawimage.bin mycowimage.cow
514@end example
515
516@file{myrawimage.bin} is a raw image you want to use as original disk
517image. It will never be written to.
518
519@file{mycowimage.cow} is the COW disk image which is created by
520@code{qemu-mkcow}. You can use it directly with the @option{-hdx}
521options. You must not modify the original raw disk image if you use
522COW images, as COW images only store the modified sectors from the raw
523disk image. QEMU stores the original raw disk image name and its
524modified time in the COW disk image so that chances of mistakes are
525reduced.
526
527If the raw disk image is not read-only, by pressing @key{C-a s} you
528can flush the COW disk image back into the raw disk image, as in
529snapshot mode.
530
531COW disk images can also be created without a corresponding raw disk
532image. It is useful to have a big initial virtual disk image without
533using much disk space. Use:
534
535@example
536qemu-mkcow mycowimage.cow 1024
537@end example
538
539to create a 1 gigabyte empty COW disk image.
540
541NOTES:
542@enumerate
543@item
544COW disk images must be created on file systems supporting
545@emph{holes} such as ext2 or ext3.
546@item
547Since holes are used, the displayed size of the COW disk image is not
548the real one. To know it, use the @code{ls -ls} command.
549@end enumerate
550
bellard0806e3f2003-10-01 00:15:32 +0000551@section Direct Linux Boot and Network emulation
552
553This section explains how to launch a Linux kernel inside QEMU without
554having to make a full bootable image. It is very useful for fast Linux
555kernel testing. The QEMU network configuration is also explained.
bellard1eb20522003-06-25 16:21:49 +0000556
557@enumerate
558@item
bellard0806e3f2003-10-01 00:15:32 +0000559Download the archive @file{linux-test-xxx.tar.gz} containing a Linux
560kernel and a disk image.
bellard1eb20522003-06-25 16:21:49 +0000561
562@item Optional: If you want network support (for example to launch X11 examples), you
bellard0806e3f2003-10-01 00:15:32 +0000563must copy the script @file{qemu-ifup} in @file{/etc} and configure
bellard1eb20522003-06-25 16:21:49 +0000564properly @code{sudo} so that the command @code{ifconfig} contained in
bellard0806e3f2003-10-01 00:15:32 +0000565@file{qemu-ifup} can be executed as root. You must verify that your host
bellard1eb20522003-06-25 16:21:49 +0000566kernel supports the TUN/TAP network interfaces: the device
567@file{/dev/net/tun} must be present.
568
569When network is enabled, there is a virtual network connection between
570the host kernel and the emulated kernel. The emulated kernel is seen
571from the host kernel at IP address 172.20.0.2 and the host kernel is
572seen from the emulated kernel at IP address 172.20.0.1.
573
bellard0806e3f2003-10-01 00:15:32 +0000574@item Launch @code{qemu.sh}. You should have the following output:
bellard1eb20522003-06-25 16:21:49 +0000575
576@example
bellard0806e3f2003-10-01 00:15:32 +0000577> ./qemu.sh
bellard181f1552003-11-13 01:47:16 +0000578Connected to host network interface: tun0
579Linux 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
bellard1eb20522003-06-25 16:21:49 +0000580BIOS-provided physical RAM map:
bellard46907642003-07-07 12:17:46 +0000581 BIOS-e801: 0000000000000000 - 000000000009f000 (usable)
582 BIOS-e801: 0000000000100000 - 0000000002000000 (usable)
bellard1eb20522003-06-25 16:21:49 +000058332MB LOWMEM available.
584On node 0 totalpages: 8192
585zone(0): 4096 pages.
586zone(1): 4096 pages.
587zone(2): 0 pages.
bellard181f1552003-11-13 01:47:16 +0000588Kernel command line: root=/dev/hda sb=0x220,5,1,5 ide2=noprobe ide3=noprobe ide4=noprobe ide5=noprobe console=ttyS0
bellard46907642003-07-07 12:17:46 +0000589ide_setup: ide2=noprobe
590ide_setup: ide3=noprobe
591ide_setup: ide4=noprobe
592ide_setup: ide5=noprobe
bellard1eb20522003-06-25 16:21:49 +0000593Initializing CPU#0
bellard181f1552003-11-13 01:47:16 +0000594Detected 2399.621 MHz processor.
595Console: colour EGA 80x25
596Calibrating delay loop... 4744.80 BogoMIPS
597Memory: 28872k/32768k available (1210k kernel code, 3508k reserved, 266k data, 64k init, 0k highmem)
bellard1eb20522003-06-25 16:21:49 +0000598Dentry cache hash table entries: 4096 (order: 3, 32768 bytes)
599Inode cache hash table entries: 2048 (order: 2, 16384 bytes)
bellard181f1552003-11-13 01:47:16 +0000600Mount cache hash table entries: 512 (order: 0, 4096 bytes)
bellard1eb20522003-06-25 16:21:49 +0000601Buffer-cache hash table entries: 1024 (order: 0, 4096 bytes)
602Page-cache hash table entries: 8192 (order: 3, 32768 bytes)
603CPU: Intel Pentium Pro stepping 03
604Checking 'hlt' instruction... OK.
605POSIX conformance testing by UNIFIX
606Linux NET4.0 for Linux 2.4
607Based upon Swansea University Computer Society NET3.039
608Initializing RT netlink socket
609apm: BIOS not found.
610Starting kswapd
bellard46907642003-07-07 12:17:46 +0000611Journalled Block Device driver loaded
bellard181f1552003-11-13 01:47:16 +0000612Detected PS/2 Mouse Port.
bellard1eb20522003-06-25 16:21:49 +0000613pty: 256 Unix98 ptys configured
614Serial driver version 5.05c (2001-07-08) with no serial options enabled
615ttyS00 at 0x03f8 (irq = 4) is a 16450
616ne.c:v1.10 9/23/94 Donald Becker (becker@scyld.com)
617Last modified Nov 1, 2000 by Paul Gortmaker
618NE*000 ethercard probe at 0x300: 52 54 00 12 34 56
619eth0: NE2000 found at 0x300, using IRQ 9.
bellard46907642003-07-07 12:17:46 +0000620RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
bellard181f1552003-11-13 01:47:16 +0000621Uniform Multi-Platform E-IDE driver Revision: 7.00beta4-2.4
622ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx
623hda: QEMU HARDDISK, ATA DISK drive
624ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
625hda: attached ide-disk driver.
626hda: 20480 sectors (10 MB) w/256KiB Cache, CHS=20/16/63
627Partition check:
628 hda:
629Soundblaster audio driver Copyright (C) by Hannu Savolainen 1993-1996
bellard1eb20522003-06-25 16:21:49 +0000630NET4: Linux TCP/IP 1.0 for NET4.0
631IP Protocols: ICMP, UDP, TCP, IGMP
632IP: routing cache hash table of 512 buckets, 4Kbytes
bellard46907642003-07-07 12:17:46 +0000633TCP: Hash tables configured (established 2048 bind 4096)
bellard1eb20522003-06-25 16:21:49 +0000634NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
bellard46907642003-07-07 12:17:46 +0000635EXT2-fs warning: mounting unchecked fs, running e2fsck is recommended
bellard1eb20522003-06-25 16:21:49 +0000636VFS: Mounted root (ext2 filesystem).
bellard181f1552003-11-13 01:47:16 +0000637Freeing unused kernel memory: 64k freed
638
639Linux 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
640
641QEMU Linux test distribution (based on Redhat 9)
642
643Type 'exit' to halt the system
644
645sh-2.05b#
bellard1eb20522003-06-25 16:21:49 +0000646@end example
647
648@item
649Then you can play with the kernel inside the virtual serial console. You
650can launch @code{ls} for example. Type @key{Ctrl-a h} to have an help
651about the keys you can type inside the virtual serial console. In
bellardd5a0b502003-06-27 12:02:03 +0000652particular, use @key{Ctrl-a x} to exit QEMU and use @key{Ctrl-a b} as
653the Magic SysRq key.
bellard1eb20522003-06-25 16:21:49 +0000654
655@item
656If the network is enabled, launch the script @file{/etc/linuxrc} in the
657emulator (don't forget the leading dot):
658@example
659. /etc/linuxrc
660@end example
661
662Then enable X11 connections on your PC from the emulated Linux:
663@example
664xhost +172.20.0.2
665@end example
666
667You can now launch @file{xterm} or @file{xlogo} and verify that you have
668a real Virtual Linux system !
669
670@end enumerate
671
bellardd5a0b502003-06-27 12:02:03 +0000672NOTES:
673@enumerate
674@item
bellard0806e3f2003-10-01 00:15:32 +0000675A 2.5.74 kernel is also included in the archive. Just
676replace the bzImage in qemu.sh to try it.
bellardd5a0b502003-06-27 12:02:03 +0000677
678@item
bellard1f673132004-04-04 15:21:17 +0000679qemu-fast creates a temporary file in @var{$QEMU_TMPDIR} (@file{/tmp} is the
bellardd5a0b502003-06-27 12:02:03 +0000680default) containing all the simulated PC memory. If possible, try to use
681a temporary directory using the tmpfs filesystem to avoid too many
682unnecessary disk accesses.
683
684@item
bellard9d4520d2003-10-28 01:38:57 +0000685In order to exit cleanly from qemu, you can do a @emph{shutdown} inside
686qemu. qemu will automatically exit when the Linux shutdown is done.
bellard46907642003-07-07 12:17:46 +0000687
688@item
689You can boot slightly faster by disabling the probe of non present IDE
690interfaces. To do so, add the following options on the kernel command
691line:
692@example
693ide1=noprobe ide2=noprobe ide3=noprobe ide4=noprobe ide5=noprobe
694@end example
695
696@item
697The example disk image is a modified version of the one made by Kevin
bellard1eb20522003-06-25 16:21:49 +0000698Lawton for the plex86 Project (@url{www.plex86.org}).
699
bellardd5a0b502003-06-27 12:02:03 +0000700@end enumerate
701
bellard0806e3f2003-10-01 00:15:32 +0000702@node linux_compile
bellard46907642003-07-07 12:17:46 +0000703@section Linux Kernel Compilation
bellard1eb20522003-06-25 16:21:49 +0000704
bellard285dc332003-10-27 23:58:04 +0000705You can use any linux kernel with QEMU. However, if you want to use
bellard1f673132004-04-04 15:21:17 +0000706@code{qemu-fast} to get maximum performances, you must use a modified
707guest kernel. If you are using a 2.6 guest kernel, you can use
708directly the patch @file{linux-2.6-qemu-fast.patch} made by Rusty
709Russel available in the QEMU source archive. Otherwise, you can make the
710following changes @emph{by hand} to the Linux kernel:
bellard1eb20522003-06-25 16:21:49 +0000711
bellard46907642003-07-07 12:17:46 +0000712@enumerate
713@item
714The kernel must be mapped at 0x90000000 (the default is
7150xc0000000). You must modify only two lines in the kernel source:
716
717In @file{include/asm/page.h}, replace
bellard1eb20522003-06-25 16:21:49 +0000718@example
719#define __PAGE_OFFSET (0xc0000000)
720@end example
721by
722@example
723#define __PAGE_OFFSET (0x90000000)
724@end example
725
bellard46907642003-07-07 12:17:46 +0000726And in @file{arch/i386/vmlinux.lds}, replace
bellard1eb20522003-06-25 16:21:49 +0000727@example
728 . = 0xc0000000 + 0x100000;
729@end example
730by
731@example
732 . = 0x90000000 + 0x100000;
733@end example
734
bellard46907642003-07-07 12:17:46 +0000735@item
736If you want to enable SMP (Symmetric Multi-Processing) support, you
737must make the following change in @file{include/asm/fixmap.h}. Replace
bellard1eb20522003-06-25 16:21:49 +0000738@example
bellard46907642003-07-07 12:17:46 +0000739#define FIXADDR_TOP (0xffffX000UL)
bellard1eb20522003-06-25 16:21:49 +0000740@end example
bellard46907642003-07-07 12:17:46 +0000741by
742@example
743#define FIXADDR_TOP (0xa7ffX000UL)
744@end example
745(X is 'e' or 'f' depending on the kernel version). Although you can
746use an SMP kernel with QEMU, it only supports one CPU.
bellard1eb20522003-06-25 16:21:49 +0000747
bellard46907642003-07-07 12:17:46 +0000748@item
bellard1f673132004-04-04 15:21:17 +0000749If you are not using a 2.6 kernel as host kernel but if you use a target
7502.6 kernel, you must also ensure that the 'HZ' define is set to 100
bellardd5a0b502003-06-27 12:02:03 +0000751(1000 is the default) as QEMU cannot currently emulate timers at
bellard1f673132004-04-04 15:21:17 +0000752frequencies greater than 100 Hz on host Linux systems < 2.6. In
bellard46907642003-07-07 12:17:46 +0000753@file{include/asm/param.h}, replace:
bellardd5a0b502003-06-27 12:02:03 +0000754
755@example
756# define HZ 1000 /* Internal kernel timer frequency */
757@end example
758by
759@example
760# define HZ 100 /* Internal kernel timer frequency */
761@end example
762
bellard46907642003-07-07 12:17:46 +0000763@end enumerate
764
765The file config-2.x.x gives the configuration of the example kernels.
766
767Just type
768@example
769make bzImage
770@end example
771
772As you would do to make a real kernel. Then you can use with QEMU
773exactly the same kernel as you would boot on your PC (in
774@file{arch/i386/boot/bzImage}).
bellardda415d52003-06-27 18:50:50 +0000775
bellard0806e3f2003-10-01 00:15:32 +0000776@node gdb_usage
bellardda415d52003-06-27 18:50:50 +0000777@section GDB usage
778
779QEMU has a primitive support to work with gdb, so that you can do
bellard0806e3f2003-10-01 00:15:32 +0000780'Ctrl-C' while the virtual machine is running and inspect its state.
bellardda415d52003-06-27 18:50:50 +0000781
bellard9d4520d2003-10-28 01:38:57 +0000782In order to use gdb, launch qemu with the '-s' option. It will wait for a
bellardda415d52003-06-27 18:50:50 +0000783gdb connection:
784@example
bellard6c9bf892004-01-24 13:46:56 +0000785> qemu -s -kernel arch/i386/boot/bzImage -hda root-2.4.20.img -append "root=/dev/hda"
bellardda415d52003-06-27 18:50:50 +0000786Connected to host network interface: tun0
787Waiting gdb connection on port 1234
788@end example
789
790Then launch gdb on the 'vmlinux' executable:
791@example
792> gdb vmlinux
793@end example
794
795In gdb, connect to QEMU:
796@example
bellard6c9bf892004-01-24 13:46:56 +0000797(gdb) target remote localhost:1234
bellardda415d52003-06-27 18:50:50 +0000798@end example
799
800Then you can use gdb normally. For example, type 'c' to launch the kernel:
801@example
802(gdb) c
803@end example
804
bellard0806e3f2003-10-01 00:15:32 +0000805Here are some useful tips in order to use gdb on system code:
806
807@enumerate
808@item
809Use @code{info reg} to display all the CPU registers.
810@item
811Use @code{x/10i $eip} to display the code at the PC position.
812@item
813Use @code{set architecture i8086} to dump 16 bit code. Then use
814@code{x/10i $cs*16+*eip} to dump the code at the PC position.
815@end enumerate
816
bellard52c00a52004-04-25 21:27:03 +0000817@chapter QEMU PREP PowerPC System emulator invocation
818
819Use the executable @file{qemu-system-ppc} to simulate a complete PREP
820PowerPC system.
821
822QEMU emulates the following PREP peripherials:
823
824@itemize @minus
825@item
8262 IDE interfaces with hard disk and CD-ROM support
827@item
828Floppy disk
829@item
830up to 6 NE2000 network adapters
831@item
832Serial port
833@item
834PREP Non Volatile RAM
835@end itemize
836
837You can read the qemu PC system emulation chapter to have more
838informations about QEMU usage.
839
840More information is available at
841@url{http://jocelyn.mayer.free.fr/qemu-ppc/}.
842
bellard1f673132004-04-04 15:21:17 +0000843@chapter QEMU User space emulator invocation
bellard386405f2003-03-23 21:28:45 +0000844
bellard1f673132004-04-04 15:21:17 +0000845@section Quick Start
bellard386405f2003-03-23 21:28:45 +0000846
bellard1f673132004-04-04 15:21:17 +0000847In order to launch a Linux process, QEMU needs the process executable
848itself and all the target (x86) dynamic libraries used by it.
bellard386405f2003-03-23 21:28:45 +0000849
bellard1f673132004-04-04 15:21:17 +0000850@itemize
bellard386405f2003-03-23 21:28:45 +0000851
bellard1f673132004-04-04 15:21:17 +0000852@item On x86, you can just try to launch any process by using the native
853libraries:
bellard386405f2003-03-23 21:28:45 +0000854
bellard1f673132004-04-04 15:21:17 +0000855@example
856qemu-i386 -L / /bin/ls
857@end example
bellardfd429f22003-03-30 20:59:46 +0000858
bellard1f673132004-04-04 15:21:17 +0000859@code{-L /} tells that the x86 dynamic linker must be searched with a
860@file{/} prefix.
bellard1eb20522003-06-25 16:21:49 +0000861
bellard1f673132004-04-04 15:21:17 +0000862@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):
bellard1eb20522003-06-25 16:21:49 +0000863
bellard1f673132004-04-04 15:21:17 +0000864@example
865qemu-i386 -L / qemu-i386 -L / /bin/ls
866@end example
bellard386405f2003-03-23 21:28:45 +0000867
bellard1f673132004-04-04 15:21:17 +0000868@item On non x86 CPUs, you need first to download at least an x86 glibc
869(@file{qemu-runtime-i386-XXX-.tar.gz} on the QEMU web page). Ensure that
870@code{LD_LIBRARY_PATH} is not set:
bellard386405f2003-03-23 21:28:45 +0000871
bellard1f673132004-04-04 15:21:17 +0000872@example
873unset LD_LIBRARY_PATH
874@end example
bellard386405f2003-03-23 21:28:45 +0000875
bellard1f673132004-04-04 15:21:17 +0000876Then you can launch the precompiled @file{ls} x86 executable:
bellard386405f2003-03-23 21:28:45 +0000877
bellard1f673132004-04-04 15:21:17 +0000878@example
879qemu-i386 tests/i386/ls
880@end example
881You can look at @file{qemu-binfmt-conf.sh} so that
882QEMU is automatically launched by the Linux kernel when you try to
883launch x86 executables. It requires the @code{binfmt_misc} module in the
884Linux kernel.
bellard386405f2003-03-23 21:28:45 +0000885
bellard1f673132004-04-04 15:21:17 +0000886@item The x86 version of QEMU is also included. You can try weird things such as:
887@example
888qemu-i386 /usr/local/qemu-i386/bin/qemu-i386 /usr/local/qemu-i386/bin/ls-i386
889@end example
bellard386405f2003-03-23 21:28:45 +0000890
bellard1f673132004-04-04 15:21:17 +0000891@end itemize
bellard386405f2003-03-23 21:28:45 +0000892
bellard1f673132004-04-04 15:21:17 +0000893@section Wine launch
bellard386405f2003-03-23 21:28:45 +0000894
bellard1f673132004-04-04 15:21:17 +0000895@itemize
bellard386405f2003-03-23 21:28:45 +0000896
bellard1f673132004-04-04 15:21:17 +0000897@item Ensure that you have a working QEMU with the x86 glibc
898distribution (see previous section). In order to verify it, you must be
899able to do:
bellard386405f2003-03-23 21:28:45 +0000900
bellard1f673132004-04-04 15:21:17 +0000901@example
902qemu-i386 /usr/local/qemu-i386/bin/ls-i386
903@end example
bellard386405f2003-03-23 21:28:45 +0000904
bellard1f673132004-04-04 15:21:17 +0000905@item Download the binary x86 Wine install
906(@file{qemu-XXX-i386-wine.tar.gz} on the QEMU web page).
bellard386405f2003-03-23 21:28:45 +0000907
bellard1f673132004-04-04 15:21:17 +0000908@item Configure Wine on your account. Look at the provided script
909@file{/usr/local/qemu-i386/bin/wine-conf.sh}. Your previous
910@code{$@{HOME@}/.wine} directory is saved to @code{$@{HOME@}/.wine.org}.
bellard386405f2003-03-23 21:28:45 +0000911
bellard1f673132004-04-04 15:21:17 +0000912@item Then you can try the example @file{putty.exe}:
bellard386405f2003-03-23 21:28:45 +0000913
bellard1f673132004-04-04 15:21:17 +0000914@example
915qemu-i386 /usr/local/qemu-i386/wine/bin/wine /usr/local/qemu-i386/wine/c/Program\ Files/putty.exe
916@end example
bellard386405f2003-03-23 21:28:45 +0000917
bellard1f673132004-04-04 15:21:17 +0000918@end itemize
bellard386405f2003-03-23 21:28:45 +0000919
bellard1f673132004-04-04 15:21:17 +0000920@section Command line options
bellard386405f2003-03-23 21:28:45 +0000921
bellard1f673132004-04-04 15:21:17 +0000922@example
923usage: qemu-i386 [-h] [-d] [-L path] [-s size] program [arguments...]
924@end example
bellard386405f2003-03-23 21:28:45 +0000925
bellard1f673132004-04-04 15:21:17 +0000926@table @option
927@item -h
928Print the help
929@item -L path
930Set the x86 elf interpreter prefix (default=/usr/local/qemu-i386)
931@item -s size
932Set the x86 stack size in bytes (default=524288)
bellard386405f2003-03-23 21:28:45 +0000933@end table
934
bellard1f673132004-04-04 15:21:17 +0000935Debug options:
bellard386405f2003-03-23 21:28:45 +0000936
bellard1f673132004-04-04 15:21:17 +0000937@table @option
938@item -d
939Activate log (logfile=/tmp/qemu.log)
940@item -p pagesize
941Act as if the host page size was 'pagesize' bytes
942@end table
bellard386405f2003-03-23 21:28:45 +0000943