Statistics
| Branch: | Revision:

root / qemu-doc.texi @ ed96ca35

History | View | Annotate | Download (46.5 kB)

1 386405f7 bellard
\input texinfo @c -*- texinfo -*-
2 386405f7 bellard
3 0806e3f6 bellard
@iftex
4 1f673135 bellard
@settitle QEMU CPU Emulator User Documentation
5 386405f7 bellard
@titlepage
6 386405f7 bellard
@sp 7
7 1f673135 bellard
@center @titlefont{QEMU CPU Emulator User Documentation}
8 386405f7 bellard
@sp 3
9 386405f7 bellard
@end titlepage
10 0806e3f6 bellard
@end iftex
11 386405f7 bellard
12 386405f7 bellard
@chapter Introduction
13 386405f7 bellard
14 322d0c66 bellard
@section Features
15 386405f7 bellard
16 1f673135 bellard
QEMU is a FAST! processor emulator using dynamic translation to
17 1f673135 bellard
achieve good emulation speed.
18 1eb20527 bellard
19 1eb20527 bellard
QEMU has two operating modes:
20 0806e3f6 bellard
21 0806e3f6 bellard
@itemize @minus
22 0806e3f6 bellard
23 0806e3f6 bellard
@item 
24 1f673135 bellard
Full system emulation. In this mode, QEMU emulates a full system (for
25 3f9f3aa1 bellard
example a PC), including one or several processors and various
26 3f9f3aa1 bellard
peripherals. It can be used to launch different Operating Systems
27 3f9f3aa1 bellard
without rebooting the PC or to debug system code.
28 1eb20527 bellard
29 0806e3f6 bellard
@item 
30 1f673135 bellard
User mode emulation (Linux host only). In this mode, QEMU can launch
31 1f673135 bellard
Linux processes compiled for one CPU on another CPU. It can be used to
32 1f673135 bellard
launch the Wine Windows API emulator (@url{http://www.winehq.org}) or
33 1f673135 bellard
to ease cross-compilation and cross-debugging.
34 1eb20527 bellard
35 1eb20527 bellard
@end itemize
36 1eb20527 bellard
37 7c3fc84d bellard
QEMU can run without an host kernel driver and yet gives acceptable
38 6f2f2b24 bellard
performance. 
39 322d0c66 bellard
40 52c00a5f bellard
For system emulation, the following hardware targets are supported:
41 52c00a5f bellard
@itemize
42 9d0a8e6f bellard
@item PC (x86 or x86_64 processor)
43 3f9f3aa1 bellard
@item ISA PC (old style PC without PCI bus)
44 52c00a5f bellard
@item PREP (PowerPC processor)
45 9d0a8e6f bellard
@item G3 BW PowerMac (PowerPC processor)
46 9d0a8e6f bellard
@item Mac99 PowerMac (PowerPC processor, in progress)
47 3475187d bellard
@item Sun4m (32-bit Sparc processor)
48 3475187d bellard
@item Sun4u (64-bit Sparc processor, in progress)
49 3f9f3aa1 bellard
@item Malta board (32-bit MIPS processor)
50 ed96ca35 pbrook
@item ARM Integrator/CP (ARM926E or 1026E processor)
51 52c00a5f bellard
@end itemize
52 386405f7 bellard
53 3f9f3aa1 bellard
For user emulation, x86, PowerPC, ARM, MIPS, and Sparc32/64 CPUs are supported.
54 0806e3f6 bellard
55 5b9f457a bellard
@chapter Installation
56 5b9f457a bellard
57 15a34c63 bellard
If you want to compile QEMU yourself, see @ref{compilation}.
58 15a34c63 bellard
59 1f673135 bellard
@section Linux
60 1f673135 bellard
61 7c3fc84d bellard
If a precompiled package is available for your distribution - you just
62 7c3fc84d bellard
have to install it. Otherwise, see @ref{compilation}.
63 5b9f457a bellard
64 1f673135 bellard
@section Windows
65 8cd0ac2f bellard
66 15a34c63 bellard
Download the experimental binary installer at
67 15a34c63 bellard
@url{http://www.freeoszoo.org/download.php}.
68 d691f669 bellard
69 1f673135 bellard
@section Mac OS X
70 d691f669 bellard
71 15a34c63 bellard
Download the experimental binary installer at
72 15a34c63 bellard
@url{http://www.freeoszoo.org/download.php}.
73 df0f11a0 bellard
74 3f9f3aa1 bellard
@chapter QEMU PC System emulator
75 1eb20527 bellard
76 0806e3f6 bellard
@section Introduction
77 0806e3f6 bellard
78 0806e3f6 bellard
@c man begin DESCRIPTION
79 0806e3f6 bellard
80 3f9f3aa1 bellard
The QEMU PC System emulator simulates the
81 3f9f3aa1 bellard
following peripherals:
82 0806e3f6 bellard
83 0806e3f6 bellard
@itemize @minus
84 15a34c63 bellard
@item 
85 15a34c63 bellard
i440FX host PCI bridge and PIIX3 PCI to ISA bridge
86 0806e3f6 bellard
@item
87 15a34c63 bellard
Cirrus CLGD 5446 PCI VGA card or dummy VGA card with Bochs VESA
88 15a34c63 bellard
extensions (hardware level, including all non standard modes).
89 0806e3f6 bellard
@item
90 0806e3f6 bellard
PS/2 mouse and keyboard
91 0806e3f6 bellard
@item 
92 15a34c63 bellard
2 PCI IDE interfaces with hard disk and CD-ROM support
93 1f673135 bellard
@item
94 1f673135 bellard
Floppy disk
95 0806e3f6 bellard
@item 
96 15a34c63 bellard
NE2000 PCI network adapters
97 0806e3f6 bellard
@item
98 05d5818c bellard
Serial ports
99 05d5818c bellard
@item
100 c0fe3827 bellard
Creative SoundBlaster 16 sound card
101 c0fe3827 bellard
@item
102 c0fe3827 bellard
ENSONIQ AudioPCI ES1370 sound card
103 c0fe3827 bellard
@item
104 c0fe3827 bellard
Adlib(OPL2) - Yamaha YM3812 compatible chip
105 b389dbfb bellard
@item
106 b389dbfb bellard
PCI UHCI USB controller and a virtual USB hub.
107 0806e3f6 bellard
@end itemize
108 0806e3f6 bellard
109 3f9f3aa1 bellard
SMP is supported with up to 255 CPUs.
110 3f9f3aa1 bellard
111 c0fe3827 bellard
Note that adlib is only available when QEMU was configured with
112 c0fe3827 bellard
-enable-adlib
113 c0fe3827 bellard
114 15a34c63 bellard
QEMU uses the PC BIOS from the Bochs project and the Plex86/Bochs LGPL
115 15a34c63 bellard
VGA BIOS.
116 15a34c63 bellard
117 c0fe3827 bellard
QEMU uses YM3812 emulation by Tatsuyuki Satoh.
118 c0fe3827 bellard
119 0806e3f6 bellard
@c man end
120 0806e3f6 bellard
121 1eb20527 bellard
@section Quick Start
122 1eb20527 bellard
123 285dc330 bellard
Download and uncompress the linux image (@file{linux.img}) and type:
124 0806e3f6 bellard
125 0806e3f6 bellard
@example
126 285dc330 bellard
qemu linux.img
127 0806e3f6 bellard
@end example
128 0806e3f6 bellard
129 0806e3f6 bellard
Linux should boot and give you a prompt.
130 0806e3f6 bellard
131 6cc721cf bellard
@node sec_invocation
132 ec410fc9 bellard
@section Invocation
133 ec410fc9 bellard
134 ec410fc9 bellard
@example
135 0806e3f6 bellard
@c man begin SYNOPSIS
136 0806e3f6 bellard
usage: qemu [options] [disk_image]
137 0806e3f6 bellard
@c man end
138 ec410fc9 bellard
@end example
139 ec410fc9 bellard
140 0806e3f6 bellard
@c man begin OPTIONS
141 9d4520d0 bellard
@var{disk_image} is a raw hard disk image for IDE hard disk 0.
142 ec410fc9 bellard
143 ec410fc9 bellard
General options:
144 ec410fc9 bellard
@table @option
145 3dbbdc25 bellard
@item -M machine
146 3dbbdc25 bellard
Select the emulated machine (@code{-M ?} for list)
147 3dbbdc25 bellard
148 2be3bc02 bellard
@item -fda file
149 2be3bc02 bellard
@item -fdb file
150 be3edd95 bellard
Use @var{file} as floppy disk 0/1 image (@xref{disk_images}). You can
151 be3edd95 bellard
use the host floppy by using @file{/dev/fd0} as filename.
152 2be3bc02 bellard
153 ec410fc9 bellard
@item -hda file
154 ec410fc9 bellard
@item -hdb file
155 181f1558 bellard
@item -hdc file
156 181f1558 bellard
@item -hdd file
157 2be3bc02 bellard
Use @var{file} as hard disk 0, 1, 2 or 3 image (@xref{disk_images}).
158 1f47a922 bellard
159 181f1558 bellard
@item -cdrom file
160 181f1558 bellard
Use @var{file} as CD-ROM image (you cannot use @option{-hdc} and and
161 be3edd95 bellard
@option{-cdrom} at the same time). You can use the host CD-ROM by
162 be3edd95 bellard
using @file{/dev/cdrom} as filename.
163 181f1558 bellard
164 1f673135 bellard
@item -boot [a|c|d]
165 1f673135 bellard
Boot on floppy (a), hard disk (c) or CD-ROM (d). Hard disk boot is
166 2be3bc02 bellard
the default.
167 1f47a922 bellard
168 181f1558 bellard
@item -snapshot
169 1f47a922 bellard
Write to temporary files instead of disk image files. In this case,
170 1f47a922 bellard
the raw disk image you use is not written back. You can however force
171 1f47a922 bellard
the write back by pressing @key{C-a s} (@xref{disk_images}). 
172 ec410fc9 bellard
173 ec410fc9 bellard
@item -m megs
174 15a34c63 bellard
Set virtual RAM size to @var{megs} megabytes. Default is 128 MB.
175 ec410fc9 bellard
176 3f9f3aa1 bellard
@item -smp n
177 3f9f3aa1 bellard
Simulate an SMP system with @var{n} CPUs. On the PC target, up to 255
178 3f9f3aa1 bellard
CPUs are supported.
179 3f9f3aa1 bellard
180 0806e3f6 bellard
@item -nographic
181 0806e3f6 bellard
182 0806e3f6 bellard
Normally, QEMU uses SDL to display the VGA output. With this option,
183 0806e3f6 bellard
you can totally disable graphical output so that QEMU is a simple
184 0806e3f6 bellard
command line application. The emulated serial port is redirected on
185 0806e3f6 bellard
the console. Therefore, you can still use QEMU to debug a Linux kernel
186 0806e3f6 bellard
with a serial console.
187 0806e3f6 bellard
188 3d11d0eb bellard
@item -k language
189 3d11d0eb bellard
190 3d11d0eb bellard
Use keyboard layout @var{language} (for example @code{fr} for
191 3d11d0eb bellard
French). This option is only needed where it is not easy to get raw PC
192 3d11d0eb bellard
keycodes (e.g. on Macs or with some X11 servers). You don't need to
193 3d11d0eb bellard
use it on PC/Linux or PC/Windows hosts.
194 3d11d0eb bellard
195 3d11d0eb bellard
The available layouts are:
196 3d11d0eb bellard
@example
197 3d11d0eb bellard
ar  de-ch  es  fo     fr-ca  hu  ja  mk     no  pt-br  sv
198 3d11d0eb bellard
da  en-gb  et  fr     fr-ch  is  lt  nl     pl  ru     th
199 3d11d0eb bellard
de  en-us  fi  fr-be  hr     it  lv  nl-be  pt  sl     tr
200 3d11d0eb bellard
@end example
201 3d11d0eb bellard
202 3d11d0eb bellard
The default is @code{en-us}.
203 3d11d0eb bellard
204 1d14ffa9 bellard
@item -audio-help
205 1d14ffa9 bellard
206 1d14ffa9 bellard
Will show the audio subsystem help: list of drivers, tunable
207 1d14ffa9 bellard
parameters.
208 1d14ffa9 bellard
209 6a36d84e bellard
@item -soundhw card1,card2,... or -soundhw all
210 1d14ffa9 bellard
211 1d14ffa9 bellard
Enable audio and selected sound hardware. Use ? to print all
212 1d14ffa9 bellard
available sound hardware.
213 1d14ffa9 bellard
214 1d14ffa9 bellard
@example
215 1d14ffa9 bellard
qemu -soundhw sb16,adlib hda
216 1d14ffa9 bellard
qemu -soundhw es1370 hda
217 6a36d84e bellard
qemu -soundhw all hda
218 1d14ffa9 bellard
qemu -soundhw ?
219 1d14ffa9 bellard
@end example
220 a8c490cd bellard
221 15a34c63 bellard
@item -localtime
222 15a34c63 bellard
Set the real time clock to local time (the default is to UTC
223 15a34c63 bellard
time). This option is needed to have correct date in MS-DOS or
224 15a34c63 bellard
Windows.
225 15a34c63 bellard
226 d63d307f bellard
@item -full-screen
227 d63d307f bellard
Start in full screen.
228 d63d307f bellard
229 f7cce898 bellard
@item -pidfile file
230 f7cce898 bellard
Store the QEMU process PID in @var{file}. It is useful if you launch QEMU
231 f7cce898 bellard
from a script.
232 f7cce898 bellard
233 9d0a8e6f bellard
@item -win2k-hack
234 9d0a8e6f bellard
Use it when installing Windows 2000 to avoid a disk full bug. After
235 9d0a8e6f bellard
Windows 2000 is installed, you no longer need this option (this option
236 9d0a8e6f bellard
slows down the IDE transfers).
237 9d0a8e6f bellard
238 0806e3f6 bellard
@end table
239 0806e3f6 bellard
240 b389dbfb bellard
USB options:
241 b389dbfb bellard
@table @option
242 b389dbfb bellard
243 b389dbfb bellard
@item -usb
244 b389dbfb bellard
Enable the USB driver (will be the default soon)
245 b389dbfb bellard
246 b389dbfb bellard
@item -usbdevice devname
247 b389dbfb bellard
Add the USB device @var{devname}. See the monitor command
248 b389dbfb bellard
@code{usb_add} to have more information.
249 b389dbfb bellard
@end table
250 b389dbfb bellard
251 1f673135 bellard
Network options:
252 1f673135 bellard
253 1f673135 bellard
@table @option
254 1f673135 bellard
255 a41b2ff2 pbrook
@item -net nic[,vlan=n][,macaddr=addr][,model=type]
256 41d03949 bellard
Create a new Network Interface Card and connect it to VLAN @var{n} (@var{n}
257 41d03949 bellard
= 0 is the default). The NIC is currently an NE2000 on the PC
258 41d03949 bellard
target. Optionally, the MAC address can be changed. If no
259 41d03949 bellard
@option{-net} option is specified, a single NIC is created.
260 a41b2ff2 pbrook
Qemu can emulate several different models of network card.  Valid values for
261 a41b2ff2 pbrook
@var{type} are @code{ne2k_pci}, @code{ne2k_isa}, @code{rtl8139},
262 a41b2ff2 pbrook
@code{smc91c111} and @code{lance}.  Not all devices are supported on all
263 a41b2ff2 pbrook
targets.
264 41d03949 bellard
265 41d03949 bellard
@item -net user[,vlan=n]
266 7e89463d bellard
Use the user mode network stack which requires no administrator
267 039af320 bellard
priviledge to run.
268 41d03949 bellard
269 41d03949 bellard
@item -net tap[,vlan=n][,fd=h][,ifname=name][,script=file]
270 41d03949 bellard
Connect the host TAP network interface @var{name} to VLAN @var{n} and
271 41d03949 bellard
use the network script @var{file} to configure it. The default
272 41d03949 bellard
network script is @file{/etc/qemu-ifup}. If @var{name} is not
273 41d03949 bellard
provided, the OS automatically provides one.  @option{fd=h} can be
274 41d03949 bellard
used to specify the handle of an already opened host TAP interface. Example:
275 1f673135 bellard
276 41d03949 bellard
@example
277 41d03949 bellard
qemu linux.img -net nic -net tap
278 41d03949 bellard
@end example
279 41d03949 bellard
280 41d03949 bellard
More complicated example (two NICs, each one connected to a TAP device)
281 41d03949 bellard
@example
282 41d03949 bellard
qemu linux.img -net nic,vlan=0 -net tap,vlan=0,ifname=tap0 \
283 41d03949 bellard
               -net nic,vlan=1 -net tap,vlan=1,ifname=tap1
284 41d03949 bellard
@end example
285 3f1a88f4 bellard
286 3f1a88f4 bellard
287 41d03949 bellard
@item -net socket[,vlan=n][,fd=h][,listen=[host]:port][,connect=host:port]
288 1f673135 bellard
289 41d03949 bellard
Connect the VLAN @var{n} to a remote VLAN in another QEMU virtual
290 41d03949 bellard
machine using a TCP socket connection. If @option{listen} is
291 41d03949 bellard
specified, QEMU waits for incoming connections on @var{port}
292 41d03949 bellard
(@var{host} is optional). @option{connect} is used to connect to
293 3d830459 bellard
another QEMU instance using the @option{listen} option. @option{fd=h}
294 3d830459 bellard
specifies an already opened TCP socket.
295 1f673135 bellard
296 41d03949 bellard
Example:
297 41d03949 bellard
@example
298 41d03949 bellard
# launch a first QEMU instance
299 7e89463d bellard
qemu linux.img -net nic,macaddr=52:54:00:12:34:56 -net socket,listen=:1234
300 41d03949 bellard
# connect the VLAN 0 of this instance to the VLAN 0 of the first instance
301 7e89463d bellard
qemu linux.img -net nic,macaddr=52:54:00:12:34:57 -net socket,connect=127.0.0.1:1234
302 41d03949 bellard
@end example
303 52c00a5f bellard
304 3d830459 bellard
@item -net socket[,vlan=n][,fd=h][,mcast=maddr:port]
305 3d830459 bellard
306 3d830459 bellard
Create a VLAN @var{n} shared with another QEMU virtual
307 3d830459 bellard
machines using a UDP multicast socket, effectively making a bus for 
308 3d830459 bellard
every QEMU with same multicast address @var{maddr} and @var{port}.
309 3d830459 bellard
NOTES:
310 3d830459 bellard
@enumerate
311 3d830459 bellard
@item 
312 3d830459 bellard
Several QEMU can be running on different hosts and share same bus (assuming 
313 3d830459 bellard
correct multicast setup for these hosts).
314 3d830459 bellard
@item
315 3d830459 bellard
mcast support is compatible with User Mode Linux (argument @option{eth@var{N}=mcast}), see
316 3d830459 bellard
@url{http://user-mode-linux.sf.net}.
317 3d830459 bellard
@item Use @option{fd=h} to specify an already opened UDP multicast socket.
318 3d830459 bellard
@end enumerate
319 3d830459 bellard
320 3d830459 bellard
Example:
321 3d830459 bellard
@example
322 3d830459 bellard
# launch one QEMU instance
323 3d830459 bellard
qemu linux.img -net nic,macaddr=52:54:00:12:34:56 -net socket,mcast=230.0.0.1:1234
324 3d830459 bellard
# launch another QEMU instance on same "bus"
325 3d830459 bellard
qemu linux.img -net nic,macaddr=52:54:00:12:34:57 -net socket,mcast=230.0.0.1:1234
326 3d830459 bellard
# launch yet another QEMU instance on same "bus"
327 3d830459 bellard
qemu linux.img -net nic,macaddr=52:54:00:12:34:58 -net socket,mcast=230.0.0.1:1234
328 3d830459 bellard
@end example
329 3d830459 bellard
330 3d830459 bellard
Example (User Mode Linux compat.):
331 3d830459 bellard
@example
332 3d830459 bellard
# launch QEMU instance (note mcast address selected is UML's default)
333 3d830459 bellard
qemu linux.img -net nic,macaddr=52:54:00:12:34:56 -net socket,mcast=239.192.168.1:1102
334 3d830459 bellard
# launch UML
335 3d830459 bellard
/path/to/linux ubd0=/path/to/root_fs eth0=mcast
336 3d830459 bellard
@end example
337 3d830459 bellard
338 41d03949 bellard
@item -net none
339 41d03949 bellard
Indicate that no network devices should be configured. It is used to
340 039af320 bellard
override the default configuration (@option{-net nic -net user}) which
341 039af320 bellard
is activated if no @option{-net} options are provided.
342 52c00a5f bellard
343 9bf05444 bellard
@item -tftp prefix
344 9bf05444 bellard
When using the user mode network stack, activate a built-in TFTP
345 9bf05444 bellard
server. All filenames beginning with @var{prefix} can be downloaded
346 9bf05444 bellard
from the host to the guest using a TFTP client. The TFTP client on the
347 9bf05444 bellard
guest must be configured in binary mode (use the command @code{bin} of
348 9bf05444 bellard
the Unix TFTP client). The host IP address on the guest is as usual
349 9bf05444 bellard
10.0.2.2.
350 9bf05444 bellard
351 2518bd0d bellard
@item -smb dir
352 2518bd0d bellard
When using the user mode network stack, activate a built-in SMB
353 2518bd0d bellard
server so that Windows OSes can access to the host files in @file{dir}
354 2518bd0d bellard
transparently.
355 2518bd0d bellard
356 2518bd0d bellard
In the guest Windows OS, the line:
357 2518bd0d bellard
@example
358 2518bd0d bellard
10.0.2.4 smbserver
359 2518bd0d bellard
@end example
360 2518bd0d bellard
must be added in the file @file{C:\WINDOWS\LMHOSTS} (for windows 9x/Me)
361 2518bd0d bellard
or @file{C:\WINNT\SYSTEM32\DRIVERS\ETC\LMHOSTS} (Windows NT/2000).
362 2518bd0d bellard
363 2518bd0d bellard
Then @file{dir} can be accessed in @file{\\smbserver\qemu}.
364 2518bd0d bellard
365 2518bd0d bellard
Note that a SAMBA server must be installed on the host OS in
366 2518bd0d bellard
@file{/usr/sbin/smbd}. QEMU was tested succesfully with smbd version
367 6cc721cf bellard
2.2.7a from the Red Hat 9 and version 3.0.10-1.fc3 from Fedora Core 3.
368 2518bd0d bellard
369 9bf05444 bellard
@item -redir [tcp|udp]:host-port:[guest-host]:guest-port
370 9bf05444 bellard
371 9bf05444 bellard
When using the user mode network stack, redirect incoming TCP or UDP
372 9bf05444 bellard
connections to the host port @var{host-port} to the guest
373 9bf05444 bellard
@var{guest-host} on guest port @var{guest-port}. If @var{guest-host}
374 9bf05444 bellard
is not specified, its value is 10.0.2.15 (default address given by the
375 9bf05444 bellard
built-in DHCP server).
376 9bf05444 bellard
377 9bf05444 bellard
For example, to redirect host X11 connection from screen 1 to guest
378 9bf05444 bellard
screen 0, use the following:
379 9bf05444 bellard
380 9bf05444 bellard
@example
381 9bf05444 bellard
# on the host
382 9bf05444 bellard
qemu -redir tcp:6001::6000 [...]
383 9bf05444 bellard
# this host xterm should open in the guest X11 server
384 9bf05444 bellard
xterm -display :1
385 9bf05444 bellard
@end example
386 9bf05444 bellard
387 9bf05444 bellard
To redirect telnet connections from host port 5555 to telnet port on
388 9bf05444 bellard
the guest, use the following:
389 9bf05444 bellard
390 9bf05444 bellard
@example
391 9bf05444 bellard
# on the host
392 9bf05444 bellard
qemu -redir tcp:5555::23 [...]
393 9bf05444 bellard
telnet localhost 5555
394 9bf05444 bellard
@end example
395 9bf05444 bellard
396 9bf05444 bellard
Then when you use on the host @code{telnet localhost 5555}, you
397 9bf05444 bellard
connect to the guest telnet server.
398 9bf05444 bellard
399 1f673135 bellard
@end table
400 1f673135 bellard
401 41d03949 bellard
Linux boot specific: When using these options, you can use a given
402 1f673135 bellard
Linux kernel without installing it in the disk image. It can be useful
403 1f673135 bellard
for easier testing of various kernels.
404 1f673135 bellard
405 0806e3f6 bellard
@table @option
406 0806e3f6 bellard
407 0806e3f6 bellard
@item -kernel bzImage 
408 0806e3f6 bellard
Use @var{bzImage} as kernel image.
409 0806e3f6 bellard
410 0806e3f6 bellard
@item -append cmdline 
411 0806e3f6 bellard
Use @var{cmdline} as kernel command line
412 0806e3f6 bellard
413 0806e3f6 bellard
@item -initrd file
414 0806e3f6 bellard
Use @var{file} as initial ram disk.
415 0806e3f6 bellard
416 ec410fc9 bellard
@end table
417 ec410fc9 bellard
418 15a34c63 bellard
Debug/Expert options:
419 ec410fc9 bellard
@table @option
420 a0a821a4 bellard
421 a0a821a4 bellard
@item -serial dev
422 a0a821a4 bellard
Redirect the virtual serial port to host device @var{dev}. Available
423 a0a821a4 bellard
devices are:
424 a0a821a4 bellard
@table @code
425 a0a821a4 bellard
@item vc
426 a0a821a4 bellard
Virtual console
427 a0a821a4 bellard
@item pty
428 a0a821a4 bellard
[Linux only] Pseudo TTY (a new PTY is automatically allocated)
429 a0a821a4 bellard
@item null
430 a0a821a4 bellard
void device
431 f8d179e3 bellard
@item /dev/XXX
432 e57a8c0e bellard
[Linux only] Use host tty, e.g. @file{/dev/ttyS0}. The host serial port
433 f8d179e3 bellard
parameters are set according to the emulated ones.
434 e57a8c0e bellard
@item /dev/parportN
435 e57a8c0e bellard
[Linux only, parallel port only] Use host parallel port
436 e57a8c0e bellard
@var{N}. Currently only SPP parallel port features can be used.
437 f8d179e3 bellard
@item file:filename
438 f8d179e3 bellard
Write output to filename. No character can be read.
439 a0a821a4 bellard
@item stdio
440 a0a821a4 bellard
[Unix only] standard input/output
441 f8d179e3 bellard
@item pipe:filename
442 f8d179e3 bellard
[Unix only] name pipe @var{filename}
443 a0a821a4 bellard
@end table
444 a0a821a4 bellard
The default device is @code{vc} in graphical mode and @code{stdio} in
445 a0a821a4 bellard
non graphical mode.
446 a0a821a4 bellard
447 05d5818c bellard
This option can be used several times to simulate up to 4 serials
448 05d5818c bellard
ports.
449 05d5818c bellard
450 e57a8c0e bellard
@item -parallel dev
451 e57a8c0e bellard
Redirect the virtual parallel port to host device @var{dev} (same
452 e57a8c0e bellard
devices as the serial port). On Linux hosts, @file{/dev/parportN} can
453 e57a8c0e bellard
be used to use hardware devices connected on the corresponding host
454 e57a8c0e bellard
parallel port.
455 e57a8c0e bellard
456 e57a8c0e bellard
This option can be used several times to simulate up to 3 parallel
457 e57a8c0e bellard
ports.
458 e57a8c0e bellard
459 a0a821a4 bellard
@item -monitor dev
460 a0a821a4 bellard
Redirect the monitor to host device @var{dev} (same devices as the
461 a0a821a4 bellard
serial port).
462 a0a821a4 bellard
The default device is @code{vc} in graphical mode and @code{stdio} in
463 a0a821a4 bellard
non graphical mode.
464 a0a821a4 bellard
465 ec410fc9 bellard
@item -s
466 0806e3f6 bellard
Wait gdb connection to port 1234 (@xref{gdb_usage}). 
467 ec410fc9 bellard
@item -p port
468 ec410fc9 bellard
Change gdb connection port.
469 52c00a5f bellard
@item -S
470 52c00a5f bellard
Do not start CPU at startup (you must type 'c' in the monitor).
471 ec410fc9 bellard
@item -d             
472 9d4520d0 bellard
Output log in /tmp/qemu.log
473 46d4767d bellard
@item -hdachs c,h,s,[,t]
474 46d4767d bellard
Force hard disk 0 physical geometry (1 <= @var{c} <= 16383, 1 <=
475 46d4767d bellard
@var{h} <= 16, 1 <= @var{s} <= 63) and optionally force the BIOS
476 46d4767d bellard
translation mode (@var{t}=none, lba or auto). Usually QEMU can guess
477 46d4767d bellard
all thoses parameters. This option is useful for old MS-DOS disk
478 46d4767d bellard
images.
479 7c3fc84d bellard
480 15a34c63 bellard
@item -std-vga
481 15a34c63 bellard
Simulate a standard VGA card with Bochs VBE extensions (default is
482 15a34c63 bellard
Cirrus Logic GD5446 PCI VGA)
483 d63d307f bellard
@item -loadvm file
484 d63d307f bellard
Start right away with a saved state (@code{loadvm} in monitor)
485 ec410fc9 bellard
@end table
486 ec410fc9 bellard
487 3e11db9a bellard
@c man end
488 3e11db9a bellard
489 3e11db9a bellard
@section Keys
490 3e11db9a bellard
491 3e11db9a bellard
@c man begin OPTIONS
492 3e11db9a bellard
493 a1b74fe8 bellard
During the graphical emulation, you can use the following keys:
494 a1b74fe8 bellard
@table @key
495 f9859310 bellard
@item Ctrl-Alt-f
496 a1b74fe8 bellard
Toggle full screen
497 a0a821a4 bellard
498 f9859310 bellard
@item Ctrl-Alt-n
499 a0a821a4 bellard
Switch to virtual console 'n'. Standard console mappings are:
500 a0a821a4 bellard
@table @emph
501 a0a821a4 bellard
@item 1
502 a0a821a4 bellard
Target system display
503 a0a821a4 bellard
@item 2
504 a0a821a4 bellard
Monitor
505 a0a821a4 bellard
@item 3
506 a0a821a4 bellard
Serial port
507 a1b74fe8 bellard
@end table
508 a1b74fe8 bellard
509 f9859310 bellard
@item Ctrl-Alt
510 a0a821a4 bellard
Toggle mouse and keyboard grab.
511 a0a821a4 bellard
@end table
512 a0a821a4 bellard
513 3e11db9a bellard
In the virtual consoles, you can use @key{Ctrl-Up}, @key{Ctrl-Down},
514 3e11db9a bellard
@key{Ctrl-PageUp} and @key{Ctrl-PageDown} to move in the back log.
515 3e11db9a bellard
516 a0a821a4 bellard
During emulation, if you are using the @option{-nographic} option, use
517 a0a821a4 bellard
@key{Ctrl-a h} to get terminal commands:
518 ec410fc9 bellard
519 ec410fc9 bellard
@table @key
520 a1b74fe8 bellard
@item Ctrl-a h
521 ec410fc9 bellard
Print this help
522 a1b74fe8 bellard
@item Ctrl-a x    
523 ec410fc9 bellard
Exit emulatior
524 a1b74fe8 bellard
@item Ctrl-a s    
525 1f47a922 bellard
Save disk data back to file (if -snapshot)
526 a1b74fe8 bellard
@item Ctrl-a b
527 1f673135 bellard
Send break (magic sysrq in Linux)
528 a1b74fe8 bellard
@item Ctrl-a c
529 1f673135 bellard
Switch between console and monitor
530 a1b74fe8 bellard
@item Ctrl-a Ctrl-a
531 a1b74fe8 bellard
Send Ctrl-a
532 ec410fc9 bellard
@end table
533 0806e3f6 bellard
@c man end
534 0806e3f6 bellard
535 0806e3f6 bellard
@ignore
536 0806e3f6 bellard
537 0806e3f6 bellard
@setfilename qemu 
538 0806e3f6 bellard
@settitle QEMU System Emulator
539 0806e3f6 bellard
540 1f673135 bellard
@c man begin SEEALSO
541 1f673135 bellard
The HTML documentation of QEMU for more precise information and Linux
542 1f673135 bellard
user mode emulator invocation.
543 1f673135 bellard
@c man end
544 1f673135 bellard
545 1f673135 bellard
@c man begin AUTHOR
546 1f673135 bellard
Fabrice Bellard
547 1f673135 bellard
@c man end
548 1f673135 bellard
549 1f673135 bellard
@end ignore
550 1f673135 bellard
551 1f673135 bellard
@end ignore
552 1f673135 bellard
553 1f673135 bellard
@section QEMU Monitor
554 1f673135 bellard
555 1f673135 bellard
The QEMU monitor is used to give complex commands to the QEMU
556 1f673135 bellard
emulator. You can use it to:
557 1f673135 bellard
558 1f673135 bellard
@itemize @minus
559 1f673135 bellard
560 1f673135 bellard
@item
561 1f673135 bellard
Remove or insert removable medias images
562 1f673135 bellard
(such as CD-ROM or floppies)
563 1f673135 bellard
564 1f673135 bellard
@item 
565 1f673135 bellard
Freeze/unfreeze the Virtual Machine (VM) and save or restore its state
566 1f673135 bellard
from a disk file.
567 1f673135 bellard
568 1f673135 bellard
@item Inspect the VM state without an external debugger.
569 1f673135 bellard
570 1f673135 bellard
@end itemize
571 1f673135 bellard
572 1f673135 bellard
@subsection Commands
573 1f673135 bellard
574 1f673135 bellard
The following commands are available:
575 1f673135 bellard
576 1f673135 bellard
@table @option
577 1f673135 bellard
578 1f673135 bellard
@item help or ? [cmd]
579 1f673135 bellard
Show the help for all commands or just for command @var{cmd}.
580 1f673135 bellard
581 1f673135 bellard
@item commit  
582 1f673135 bellard
Commit changes to the disk images (if -snapshot is used)
583 1f673135 bellard
584 1f673135 bellard
@item info subcommand 
585 1f673135 bellard
show various information about the system state
586 1f673135 bellard
587 1f673135 bellard
@table @option
588 1f673135 bellard
@item info network
589 41d03949 bellard
show the various VLANs and the associated devices
590 1f673135 bellard
@item info block
591 1f673135 bellard
show the block devices
592 1f673135 bellard
@item info registers
593 1f673135 bellard
show the cpu registers
594 1f673135 bellard
@item info history
595 1f673135 bellard
show the command line history
596 b389dbfb bellard
@item info pci
597 b389dbfb bellard
show emulated PCI device
598 b389dbfb bellard
@item info usb
599 b389dbfb bellard
show USB devices plugged on the virtual USB hub
600 b389dbfb bellard
@item info usbhost
601 b389dbfb bellard
show all USB host devices
602 1f673135 bellard
@end table
603 1f673135 bellard
604 1f673135 bellard
@item q or quit
605 1f673135 bellard
Quit the emulator.
606 1f673135 bellard
607 1f673135 bellard
@item eject [-f] device
608 1f673135 bellard
Eject a removable media (use -f to force it).
609 1f673135 bellard
610 1f673135 bellard
@item change device filename
611 1f673135 bellard
Change a removable media.
612 1f673135 bellard
613 1f673135 bellard
@item screendump filename
614 1f673135 bellard
Save screen into PPM image @var{filename}.
615 1f673135 bellard
616 1f673135 bellard
@item log item1[,...]
617 1f673135 bellard
Activate logging of the specified items to @file{/tmp/qemu.log}.
618 1f673135 bellard
619 1f673135 bellard
@item savevm filename
620 1f673135 bellard
Save the whole virtual machine state to @var{filename}.
621 1f673135 bellard
622 1f673135 bellard
@item loadvm filename
623 1f673135 bellard
Restore the whole virtual machine state from @var{filename}.
624 1f673135 bellard
625 1f673135 bellard
@item stop
626 1f673135 bellard
Stop emulation.
627 1f673135 bellard
628 1f673135 bellard
@item c or cont
629 1f673135 bellard
Resume emulation.
630 1f673135 bellard
631 1f673135 bellard
@item gdbserver [port]
632 1f673135 bellard
Start gdbserver session (default port=1234)
633 1f673135 bellard
634 1f673135 bellard
@item x/fmt addr
635 1f673135 bellard
Virtual memory dump starting at @var{addr}.
636 1f673135 bellard
637 1f673135 bellard
@item xp /fmt addr
638 1f673135 bellard
Physical memory dump starting at @var{addr}.
639 1f673135 bellard
640 1f673135 bellard
@var{fmt} is a format which tells the command how to format the
641 1f673135 bellard
data. Its syntax is: @option{/@{count@}@{format@}@{size@}}
642 1f673135 bellard
643 1f673135 bellard
@table @var
644 1f673135 bellard
@item count 
645 1f673135 bellard
is the number of items to be dumped.
646 1f673135 bellard
647 1f673135 bellard
@item format
648 1f673135 bellard
can be x (hexa), d (signed decimal), u (unsigned decimal), o (octal),
649 1f673135 bellard
c (char) or i (asm instruction).
650 1f673135 bellard
651 1f673135 bellard
@item size
652 52c00a5f bellard
can be b (8 bits), h (16 bits), w (32 bits) or g (64 bits). On x86,
653 52c00a5f bellard
@code{h} or @code{w} can be specified with the @code{i} format to
654 52c00a5f bellard
respectively select 16 or 32 bit code instruction size.
655 1f673135 bellard
656 1f673135 bellard
@end table
657 1f673135 bellard
658 1f673135 bellard
Examples: 
659 1f673135 bellard
@itemize
660 1f673135 bellard
@item
661 1f673135 bellard
Dump 10 instructions at the current instruction pointer:
662 1f673135 bellard
@example 
663 1f673135 bellard
(qemu) x/10i $eip
664 1f673135 bellard
0x90107063:  ret
665 1f673135 bellard
0x90107064:  sti
666 1f673135 bellard
0x90107065:  lea    0x0(%esi,1),%esi
667 1f673135 bellard
0x90107069:  lea    0x0(%edi,1),%edi
668 1f673135 bellard
0x90107070:  ret
669 1f673135 bellard
0x90107071:  jmp    0x90107080
670 1f673135 bellard
0x90107073:  nop
671 1f673135 bellard
0x90107074:  nop
672 1f673135 bellard
0x90107075:  nop
673 1f673135 bellard
0x90107076:  nop
674 1f673135 bellard
@end example
675 1f673135 bellard
676 1f673135 bellard
@item
677 1f673135 bellard
Dump 80 16 bit values at the start of the video memory.
678 1f673135 bellard
@example 
679 1f673135 bellard
(qemu) xp/80hx 0xb8000
680 1f673135 bellard
0x000b8000: 0x0b50 0x0b6c 0x0b65 0x0b78 0x0b38 0x0b36 0x0b2f 0x0b42
681 1f673135 bellard
0x000b8010: 0x0b6f 0x0b63 0x0b68 0x0b73 0x0b20 0x0b56 0x0b47 0x0b41
682 1f673135 bellard
0x000b8020: 0x0b42 0x0b69 0x0b6f 0x0b73 0x0b20 0x0b63 0x0b75 0x0b72
683 1f673135 bellard
0x000b8030: 0x0b72 0x0b65 0x0b6e 0x0b74 0x0b2d 0x0b63 0x0b76 0x0b73
684 1f673135 bellard
0x000b8040: 0x0b20 0x0b30 0x0b35 0x0b20 0x0b4e 0x0b6f 0x0b76 0x0b20
685 1f673135 bellard
0x000b8050: 0x0b32 0x0b30 0x0b30 0x0b33 0x0720 0x0720 0x0720 0x0720
686 1f673135 bellard
0x000b8060: 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720
687 1f673135 bellard
0x000b8070: 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720
688 1f673135 bellard
0x000b8080: 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720
689 1f673135 bellard
0x000b8090: 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720
690 1f673135 bellard
@end example
691 1f673135 bellard
@end itemize
692 1f673135 bellard
693 1f673135 bellard
@item p or print/fmt expr
694 1f673135 bellard
695 1f673135 bellard
Print expression value. Only the @var{format} part of @var{fmt} is
696 1f673135 bellard
used.
697 0806e3f6 bellard
698 a3a91a35 bellard
@item sendkey keys
699 a3a91a35 bellard
700 a3a91a35 bellard
Send @var{keys} to the emulator. Use @code{-} to press several keys
701 a3a91a35 bellard
simultaneously. Example:
702 a3a91a35 bellard
@example
703 a3a91a35 bellard
sendkey ctrl-alt-f1
704 a3a91a35 bellard
@end example
705 a3a91a35 bellard
706 a3a91a35 bellard
This command is useful to send keys that your graphical user interface
707 a3a91a35 bellard
intercepts at low level, such as @code{ctrl-alt-f1} in X Window.
708 a3a91a35 bellard
709 15a34c63 bellard
@item system_reset
710 15a34c63 bellard
711 15a34c63 bellard
Reset the system.
712 15a34c63 bellard
713 b389dbfb bellard
@item usb_add devname
714 b389dbfb bellard
715 b389dbfb bellard
Plug the USB device devname to the QEMU virtual USB hub. @var{devname}
716 b389dbfb bellard
is either a virtual device name (for example @code{mouse}) or a host
717 b389dbfb bellard
USB device identifier. Host USB device identifiers have the following
718 b389dbfb bellard
syntax: @code{host:bus.addr} or @code{host:vendor_id:product_id}.
719 b389dbfb bellard
720 b389dbfb bellard
@item usb_del devname
721 b389dbfb bellard
722 b389dbfb bellard
Remove the USB device @var{devname} from the QEMU virtual USB
723 b389dbfb bellard
hub. @var{devname} has the syntax @code{bus.addr}. Use the monitor
724 b389dbfb bellard
command @code{info usb} to see the devices you can remove.
725 b389dbfb bellard
726 1f673135 bellard
@end table
727 0806e3f6 bellard
728 1f673135 bellard
@subsection Integer expressions
729 1f673135 bellard
730 1f673135 bellard
The monitor understands integers expressions for every integer
731 1f673135 bellard
argument. You can use register names to get the value of specifics
732 1f673135 bellard
CPU registers by prefixing them with @emph{$}.
733 ec410fc9 bellard
734 1f47a922 bellard
@node disk_images
735 1f47a922 bellard
@section Disk Images
736 1f47a922 bellard
737 acd935ef bellard
Since version 0.6.1, QEMU supports many disk image formats, including
738 acd935ef bellard
growable disk images (their size increase as non empty sectors are
739 acd935ef bellard
written), compressed and encrypted disk images.
740 1f47a922 bellard
741 acd935ef bellard
@subsection Quick start for disk image creation
742 acd935ef bellard
743 acd935ef bellard
You can create a disk image with the command:
744 1f47a922 bellard
@example
745 acd935ef bellard
qemu-img create myimage.img mysize
746 1f47a922 bellard
@end example
747 acd935ef bellard
where @var{myimage.img} is the disk image filename and @var{mysize} is its
748 acd935ef bellard
size in kilobytes. You can add an @code{M} suffix to give the size in
749 acd935ef bellard
megabytes and a @code{G} suffix for gigabytes.
750 acd935ef bellard
751 acd935ef bellard
@xref{qemu_img_invocation} for more information.
752 1f47a922 bellard
753 1f47a922 bellard
@subsection Snapshot mode
754 1f47a922 bellard
755 1f47a922 bellard
If you use the option @option{-snapshot}, all disk images are
756 1f47a922 bellard
considered as read only. When sectors in written, they are written in
757 1f47a922 bellard
a temporary file created in @file{/tmp}. You can however force the
758 acd935ef bellard
write back to the raw disk images by using the @code{commit} monitor
759 acd935ef bellard
command (or @key{C-a s} in the serial console).
760 1f47a922 bellard
761 acd935ef bellard
@node qemu_img_invocation
762 acd935ef bellard
@subsection @code{qemu-img} Invocation
763 1f47a922 bellard
764 acd935ef bellard
@include qemu-img.texi
765 05efe46e bellard
766 2c6cadd4 bellard
@subsection Virtual FAT disk images
767 2c6cadd4 bellard
768 2c6cadd4 bellard
QEMU can automatically create a virtual FAT disk image from a
769 2c6cadd4 bellard
directory tree. In order to use it, just type:
770 2c6cadd4 bellard
771 2c6cadd4 bellard
@example 
772 2c6cadd4 bellard
qemu linux.img -hdb fat:/my_directory
773 2c6cadd4 bellard
@end example
774 2c6cadd4 bellard
775 2c6cadd4 bellard
Then you access access to all the files in the @file{/my_directory}
776 2c6cadd4 bellard
directory without having to copy them in a disk image or to export
777 2c6cadd4 bellard
them via SAMBA or NFS. The default access is @emph{read-only}.
778 2c6cadd4 bellard
779 2c6cadd4 bellard
Floppies can be emulated with the @code{:floppy:} option:
780 2c6cadd4 bellard
781 2c6cadd4 bellard
@example 
782 2c6cadd4 bellard
qemu linux.img -fda fat:floppy:/my_directory
783 2c6cadd4 bellard
@end example
784 2c6cadd4 bellard
785 2c6cadd4 bellard
A read/write support is available for testing (beta stage) with the
786 2c6cadd4 bellard
@code{:rw:} option:
787 2c6cadd4 bellard
788 2c6cadd4 bellard
@example 
789 2c6cadd4 bellard
qemu linux.img -fda fat:floppy:rw:/my_directory
790 2c6cadd4 bellard
@end example
791 2c6cadd4 bellard
792 2c6cadd4 bellard
What you should @emph{never} do:
793 2c6cadd4 bellard
@itemize
794 2c6cadd4 bellard
@item use non-ASCII filenames ;
795 2c6cadd4 bellard
@item use "-snapshot" together with ":rw:" ;
796 85b2c688 bellard
@item expect it to work when loadvm'ing ;
797 85b2c688 bellard
@item write to the FAT directory on the host system while accessing it with the guest system.
798 2c6cadd4 bellard
@end itemize
799 2c6cadd4 bellard
800 9d4fb82e bellard
@section Network emulation
801 9d4fb82e bellard
802 41d03949 bellard
QEMU can simulate several networks cards (NE2000 boards on the PC
803 41d03949 bellard
target) and can connect them to an arbitrary number of Virtual Local
804 41d03949 bellard
Area Networks (VLANs). Host TAP devices can be connected to any QEMU
805 41d03949 bellard
VLAN. VLAN can be connected between separate instances of QEMU to
806 41d03949 bellard
simulate large networks. For simpler usage, a non priviledged user mode
807 41d03949 bellard
network stack can replace the TAP device to have a basic network
808 41d03949 bellard
connection.
809 41d03949 bellard
810 41d03949 bellard
@subsection VLANs
811 9d4fb82e bellard
812 41d03949 bellard
QEMU simulates several VLANs. A VLAN can be symbolised as a virtual
813 41d03949 bellard
connection between several network devices. These devices can be for
814 41d03949 bellard
example QEMU virtual Ethernet cards or virtual Host ethernet devices
815 41d03949 bellard
(TAP devices).
816 9d4fb82e bellard
817 41d03949 bellard
@subsection Using TAP network interfaces
818 41d03949 bellard
819 41d03949 bellard
This is the standard way to connect QEMU to a real network. QEMU adds
820 41d03949 bellard
a virtual network device on your host (called @code{tapN}), and you
821 41d03949 bellard
can then configure it as if it was a real ethernet card.
822 9d4fb82e bellard
823 9d4fb82e bellard
As an example, you can download the @file{linux-test-xxx.tar.gz}
824 9d4fb82e bellard
archive and copy the script @file{qemu-ifup} in @file{/etc} and
825 9d4fb82e bellard
configure properly @code{sudo} so that the command @code{ifconfig}
826 9d4fb82e bellard
contained in @file{qemu-ifup} can be executed as root. You must verify
827 41d03949 bellard
that your host kernel supports the TAP network interfaces: the
828 9d4fb82e bellard
device @file{/dev/net/tun} must be present.
829 9d4fb82e bellard
830 9d4fb82e bellard
See @ref{direct_linux_boot} to have an example of network use with a
831 41d03949 bellard
Linux distribution and @ref{sec_invocation} to have examples of
832 41d03949 bellard
command lines using the TAP network interfaces.
833 9d4fb82e bellard
834 9d4fb82e bellard
@subsection Using the user mode network stack
835 9d4fb82e bellard
836 41d03949 bellard
By using the option @option{-net user} (default configuration if no
837 41d03949 bellard
@option{-net} option is specified), QEMU uses a completely user mode
838 41d03949 bellard
network stack (you don't need root priviledge to use the virtual
839 41d03949 bellard
network). The virtual network configuration is the following:
840 9d4fb82e bellard
841 9d4fb82e bellard
@example
842 9d4fb82e bellard
843 41d03949 bellard
         QEMU VLAN      <------>  Firewall/DHCP server <-----> Internet
844 41d03949 bellard
                           |          (10.0.2.2)
845 9d4fb82e bellard
                           |
846 2518bd0d bellard
                           ---->  DNS server (10.0.2.3)
847 2518bd0d bellard
                           |     
848 2518bd0d bellard
                           ---->  SMB server (10.0.2.4)
849 9d4fb82e bellard
@end example
850 9d4fb82e bellard
851 9d4fb82e bellard
The QEMU VM behaves as if it was behind a firewall which blocks all
852 9d4fb82e bellard
incoming connections. You can use a DHCP client to automatically
853 41d03949 bellard
configure the network in the QEMU VM. The DHCP server assign addresses
854 41d03949 bellard
to the hosts starting from 10.0.2.15.
855 9d4fb82e bellard
856 9d4fb82e bellard
In order to check that the user mode network is working, you can ping
857 9d4fb82e bellard
the address 10.0.2.2 and verify that you got an address in the range
858 9d4fb82e bellard
10.0.2.x from the QEMU virtual DHCP server.
859 9d4fb82e bellard
860 b415a407 bellard
Note that @code{ping} is not supported reliably to the internet as it
861 b415a407 bellard
would require root priviledges. It means you can only ping the local
862 b415a407 bellard
router (10.0.2.2).
863 b415a407 bellard
864 9bf05444 bellard
When using the built-in TFTP server, the router is also the TFTP
865 9bf05444 bellard
server.
866 9bf05444 bellard
867 9bf05444 bellard
When using the @option{-redir} option, TCP or UDP connections can be
868 9bf05444 bellard
redirected from the host to the guest. It allows for example to
869 9bf05444 bellard
redirect X11, telnet or SSH connections.
870 443f1376 bellard
871 41d03949 bellard
@subsection Connecting VLANs between QEMU instances
872 41d03949 bellard
873 41d03949 bellard
Using the @option{-net socket} option, it is possible to make VLANs
874 41d03949 bellard
that span several QEMU instances. See @ref{sec_invocation} to have a
875 41d03949 bellard
basic example.
876 41d03949 bellard
877 9d4fb82e bellard
@node direct_linux_boot
878 9d4fb82e bellard
@section Direct Linux Boot
879 1f673135 bellard
880 1f673135 bellard
This section explains how to launch a Linux kernel inside QEMU without
881 1f673135 bellard
having to make a full bootable image. It is very useful for fast Linux
882 1f673135 bellard
kernel testing. The QEMU network configuration is also explained.
883 1f673135 bellard
884 1f673135 bellard
@enumerate
885 1f673135 bellard
@item
886 1f673135 bellard
Download the archive @file{linux-test-xxx.tar.gz} containing a Linux
887 1f673135 bellard
kernel and a disk image. 
888 1f673135 bellard
889 1f673135 bellard
@item Optional: If you want network support (for example to launch X11 examples), you
890 1f673135 bellard
must copy the script @file{qemu-ifup} in @file{/etc} and configure
891 1f673135 bellard
properly @code{sudo} so that the command @code{ifconfig} contained in
892 1f673135 bellard
@file{qemu-ifup} can be executed as root. You must verify that your host
893 1f673135 bellard
kernel supports the TUN/TAP network interfaces: the device
894 1f673135 bellard
@file{/dev/net/tun} must be present.
895 1f673135 bellard
896 1f673135 bellard
When network is enabled, there is a virtual network connection between
897 1f673135 bellard
the host kernel and the emulated kernel. The emulated kernel is seen
898 1f673135 bellard
from the host kernel at IP address 172.20.0.2 and the host kernel is
899 1f673135 bellard
seen from the emulated kernel at IP address 172.20.0.1.
900 1f673135 bellard
901 1f673135 bellard
@item Launch @code{qemu.sh}. You should have the following output:
902 1f673135 bellard
903 1f673135 bellard
@example
904 1f673135 bellard
> ./qemu.sh 
905 1f673135 bellard
Connected to host network interface: tun0
906 1f673135 bellard
Linux version 2.4.21 (bellard@voyager.localdomain) (gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)) #5 Tue Nov 11 18:18:53 CET 2003
907 1f673135 bellard
BIOS-provided physical RAM map:
908 1f673135 bellard
 BIOS-e801: 0000000000000000 - 000000000009f000 (usable)
909 1f673135 bellard
 BIOS-e801: 0000000000100000 - 0000000002000000 (usable)
910 1f673135 bellard
32MB LOWMEM available.
911 1f673135 bellard
On node 0 totalpages: 8192
912 1f673135 bellard
zone(0): 4096 pages.
913 1f673135 bellard
zone(1): 4096 pages.
914 1f673135 bellard
zone(2): 0 pages.
915 1f673135 bellard
Kernel command line: root=/dev/hda sb=0x220,5,1,5 ide2=noprobe ide3=noprobe ide4=noprobe ide5=noprobe console=ttyS0
916 1f673135 bellard
ide_setup: ide2=noprobe
917 1f673135 bellard
ide_setup: ide3=noprobe
918 1f673135 bellard
ide_setup: ide4=noprobe
919 1f673135 bellard
ide_setup: ide5=noprobe
920 1f673135 bellard
Initializing CPU#0
921 1f673135 bellard
Detected 2399.621 MHz processor.
922 1f673135 bellard
Console: colour EGA 80x25
923 1f673135 bellard
Calibrating delay loop... 4744.80 BogoMIPS
924 1f673135 bellard
Memory: 28872k/32768k available (1210k kernel code, 3508k reserved, 266k data, 64k init, 0k highmem)
925 1f673135 bellard
Dentry cache hash table entries: 4096 (order: 3, 32768 bytes)
926 1f673135 bellard
Inode cache hash table entries: 2048 (order: 2, 16384 bytes)
927 1f673135 bellard
Mount cache hash table entries: 512 (order: 0, 4096 bytes)
928 1f673135 bellard
Buffer-cache hash table entries: 1024 (order: 0, 4096 bytes)
929 1f673135 bellard
Page-cache hash table entries: 8192 (order: 3, 32768 bytes)
930 1f673135 bellard
CPU: Intel Pentium Pro stepping 03
931 1f673135 bellard
Checking 'hlt' instruction... OK.
932 1f673135 bellard
POSIX conformance testing by UNIFIX
933 1f673135 bellard
Linux NET4.0 for Linux 2.4
934 1f673135 bellard
Based upon Swansea University Computer Society NET3.039
935 1f673135 bellard
Initializing RT netlink socket
936 1f673135 bellard
apm: BIOS not found.
937 1f673135 bellard
Starting kswapd
938 1f673135 bellard
Journalled Block Device driver loaded
939 1f673135 bellard
Detected PS/2 Mouse Port.
940 1f673135 bellard
pty: 256 Unix98 ptys configured
941 1f673135 bellard
Serial driver version 5.05c (2001-07-08) with no serial options enabled
942 1f673135 bellard
ttyS00 at 0x03f8 (irq = 4) is a 16450
943 1f673135 bellard
ne.c:v1.10 9/23/94 Donald Becker (becker@scyld.com)
944 1f673135 bellard
Last modified Nov 1, 2000 by Paul Gortmaker
945 1f673135 bellard
NE*000 ethercard probe at 0x300: 52 54 00 12 34 56
946 1f673135 bellard
eth0: NE2000 found at 0x300, using IRQ 9.
947 1f673135 bellard
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
948 1f673135 bellard
Uniform Multi-Platform E-IDE driver Revision: 7.00beta4-2.4
949 1f673135 bellard
ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx
950 1f673135 bellard
hda: QEMU HARDDISK, ATA DISK drive
951 1f673135 bellard
ide0 at 0x1f0-0x1f7,0x3f6 on irq 14
952 1f673135 bellard
hda: attached ide-disk driver.
953 1f673135 bellard
hda: 20480 sectors (10 MB) w/256KiB Cache, CHS=20/16/63
954 1f673135 bellard
Partition check:
955 1f673135 bellard
 hda:
956 1f673135 bellard
Soundblaster audio driver Copyright (C) by Hannu Savolainen 1993-1996
957 1f673135 bellard
NET4: Linux TCP/IP 1.0 for NET4.0
958 1f673135 bellard
IP Protocols: ICMP, UDP, TCP, IGMP
959 1f673135 bellard
IP: routing cache hash table of 512 buckets, 4Kbytes
960 1f673135 bellard
TCP: Hash tables configured (established 2048 bind 4096)
961 1f673135 bellard
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
962 1f673135 bellard
EXT2-fs warning: mounting unchecked fs, running e2fsck is recommended
963 1f673135 bellard
VFS: Mounted root (ext2 filesystem).
964 1f673135 bellard
Freeing unused kernel memory: 64k freed
965 1f673135 bellard
 
966 1f673135 bellard
Linux version 2.4.21 (bellard@voyager.localdomain) (gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)) #5 Tue Nov 11 18:18:53 CET 2003
967 1f673135 bellard
 
968 1f673135 bellard
QEMU Linux test distribution (based on Redhat 9)
969 1f673135 bellard
 
970 1f673135 bellard
Type 'exit' to halt the system
971 1f673135 bellard
 
972 1f673135 bellard
sh-2.05b# 
973 1f673135 bellard
@end example
974 1f673135 bellard
975 1f673135 bellard
@item
976 1f673135 bellard
Then you can play with the kernel inside the virtual serial console. You
977 1f673135 bellard
can launch @code{ls} for example. Type @key{Ctrl-a h} to have an help
978 1f673135 bellard
about the keys you can type inside the virtual serial console. In
979 1f673135 bellard
particular, use @key{Ctrl-a x} to exit QEMU and use @key{Ctrl-a b} as
980 1f673135 bellard
the Magic SysRq key.
981 1f673135 bellard
982 1f673135 bellard
@item 
983 1f673135 bellard
If the network is enabled, launch the script @file{/etc/linuxrc} in the
984 1f673135 bellard
emulator (don't forget the leading dot):
985 1f673135 bellard
@example
986 1f673135 bellard
. /etc/linuxrc
987 1f673135 bellard
@end example
988 1f673135 bellard
989 1f673135 bellard
Then enable X11 connections on your PC from the emulated Linux: 
990 1f673135 bellard
@example
991 1f673135 bellard
xhost +172.20.0.2
992 1f673135 bellard
@end example
993 1f673135 bellard
994 1f673135 bellard
You can now launch @file{xterm} or @file{xlogo} and verify that you have
995 1f673135 bellard
a real Virtual Linux system !
996 1f673135 bellard
997 1f673135 bellard
@end enumerate
998 1f673135 bellard
999 1f673135 bellard
NOTES:
1000 1f673135 bellard
@enumerate
1001 1f673135 bellard
@item 
1002 1f673135 bellard
A 2.5.74 kernel is also included in the archive. Just
1003 1f673135 bellard
replace the bzImage in qemu.sh to try it.
1004 1f673135 bellard
1005 1f673135 bellard
@item 
1006 1f673135 bellard
In order to exit cleanly from qemu, you can do a @emph{shutdown} inside
1007 1f673135 bellard
qemu. qemu will automatically exit when the Linux shutdown is done.
1008 1f673135 bellard
1009 1f673135 bellard
@item 
1010 1f673135 bellard
You can boot slightly faster by disabling the probe of non present IDE
1011 1f673135 bellard
interfaces. To do so, add the following options on the kernel command
1012 1f673135 bellard
line:
1013 1f673135 bellard
@example
1014 1f673135 bellard
ide1=noprobe ide2=noprobe ide3=noprobe ide4=noprobe ide5=noprobe
1015 1f673135 bellard
@end example
1016 1f673135 bellard
1017 1f673135 bellard
@item 
1018 1f673135 bellard
The example disk image is a modified version of the one made by Kevin
1019 1f673135 bellard
Lawton for the plex86 Project (@url{www.plex86.org}).
1020 1f673135 bellard
1021 1f673135 bellard
@end enumerate
1022 1f673135 bellard
1023 b389dbfb bellard
@section USB emulation
1024 b389dbfb bellard
1025 b389dbfb bellard
QEMU emulates a PCI UHCI USB controller and a 8 port USB hub connected
1026 b389dbfb bellard
to it. You can virtually plug to the hub virtual USB devices or real
1027 b389dbfb bellard
host USB devices (experimental, works only on Linux hosts).
1028 b389dbfb bellard
1029 b389dbfb bellard
@subsection Using virtual USB devices
1030 b389dbfb bellard
1031 b389dbfb bellard
A virtual USB mouse device is available for testing in QEMU.
1032 b389dbfb bellard
1033 b389dbfb bellard
You can try it with the following monitor commands:
1034 b389dbfb bellard
1035 b389dbfb bellard
@example
1036 b389dbfb bellard
# add the mouse device
1037 b389dbfb bellard
(qemu) usb_add mouse 
1038 b389dbfb bellard
1039 b389dbfb bellard
# show the virtual USB devices plugged on the QEMU Virtual USB hub
1040 b389dbfb bellard
(qemu) info usb
1041 b389dbfb bellard
  Device 0.3, speed 12 Mb/s
1042 b389dbfb bellard
1043 b389dbfb bellard
# after some time you can try to remove the mouse
1044 b389dbfb bellard
(qemu) usb_del 0.3
1045 b389dbfb bellard
@end example
1046 b389dbfb bellard
1047 b389dbfb bellard
The option @option{-usbdevice} is similar to the monitor command
1048 b389dbfb bellard
@code{usb_add}.
1049 b389dbfb bellard
1050 b389dbfb bellard
@subsection Using host USB devices on a Linux host
1051 b389dbfb bellard
1052 b389dbfb bellard
WARNING: this is an experimental feature. QEMU will slow down when
1053 b389dbfb bellard
using it. USB devices requiring real time streaming (i.e. USB Video
1054 b389dbfb bellard
Cameras) are not supported yet.
1055 b389dbfb bellard
1056 b389dbfb bellard
@enumerate
1057 b389dbfb bellard
@item If you use an early Linux 2.4 kernel, verify that no Linux driver 
1058 b389dbfb bellard
is actually using the USB device. A simple way to do that is simply to
1059 b389dbfb bellard
disable the corresponding kernel module by renaming it from @file{mydriver.o}
1060 b389dbfb bellard
to @file{mydriver.o.disabled}.
1061 b389dbfb bellard
1062 b389dbfb bellard
@item Verify that @file{/proc/bus/usb} is working (most Linux distributions should enable it by default). You should see something like that:
1063 b389dbfb bellard
@example
1064 b389dbfb bellard
ls /proc/bus/usb
1065 b389dbfb bellard
001  devices  drivers
1066 b389dbfb bellard
@end example
1067 b389dbfb bellard
1068 b389dbfb bellard
@item Since only root can access to the USB devices directly, you can either launch QEMU as root or change the permissions of the USB devices you want to use. For testing, the following suffices:
1069 b389dbfb bellard
@example
1070 b389dbfb bellard
chown -R myuid /proc/bus/usb
1071 b389dbfb bellard
@end example
1072 b389dbfb bellard
1073 b389dbfb bellard
@item Launch QEMU and do in the monitor:
1074 b389dbfb bellard
@example 
1075 b389dbfb bellard
info usbhost
1076 b389dbfb bellard
  Device 1.2, speed 480 Mb/s
1077 b389dbfb bellard
    Class 00: USB device 1234:5678, USB DISK
1078 b389dbfb bellard
@end example
1079 b389dbfb bellard
You should see the list of the devices you can use (Never try to use
1080 b389dbfb bellard
hubs, it won't work).
1081 b389dbfb bellard
1082 b389dbfb bellard
@item Add the device in QEMU by using:
1083 b389dbfb bellard
@example 
1084 b389dbfb bellard
usb_add host:1234:5678
1085 b389dbfb bellard
@end example
1086 b389dbfb bellard
1087 b389dbfb bellard
Normally the guest OS should report that a new USB device is
1088 b389dbfb bellard
plugged. You can use the option @option{-usbdevice} to do the same.
1089 b389dbfb bellard
1090 b389dbfb bellard
@item Now you can try to use the host USB device in QEMU.
1091 b389dbfb bellard
1092 b389dbfb bellard
@end enumerate
1093 b389dbfb bellard
1094 b389dbfb bellard
When relaunching QEMU, you may have to unplug and plug again the USB
1095 b389dbfb bellard
device to make it work again (this is a bug).
1096 b389dbfb bellard
1097 0806e3f6 bellard
@node gdb_usage
1098 da415d54 bellard
@section GDB usage
1099 da415d54 bellard
1100 da415d54 bellard
QEMU has a primitive support to work with gdb, so that you can do
1101 0806e3f6 bellard
'Ctrl-C' while the virtual machine is running and inspect its state.
1102 da415d54 bellard
1103 9d4520d0 bellard
In order to use gdb, launch qemu with the '-s' option. It will wait for a
1104 da415d54 bellard
gdb connection:
1105 da415d54 bellard
@example
1106 6c9bf893 bellard
> qemu -s -kernel arch/i386/boot/bzImage -hda root-2.4.20.img -append "root=/dev/hda"
1107 da415d54 bellard
Connected to host network interface: tun0
1108 da415d54 bellard
Waiting gdb connection on port 1234
1109 da415d54 bellard
@end example
1110 da415d54 bellard
1111 da415d54 bellard
Then launch gdb on the 'vmlinux' executable:
1112 da415d54 bellard
@example
1113 da415d54 bellard
> gdb vmlinux
1114 da415d54 bellard
@end example
1115 da415d54 bellard
1116 da415d54 bellard
In gdb, connect to QEMU:
1117 da415d54 bellard
@example
1118 6c9bf893 bellard
(gdb) target remote localhost:1234
1119 da415d54 bellard
@end example
1120 da415d54 bellard
1121 da415d54 bellard
Then you can use gdb normally. For example, type 'c' to launch the kernel:
1122 da415d54 bellard
@example
1123 da415d54 bellard
(gdb) c
1124 da415d54 bellard
@end example
1125 da415d54 bellard
1126 0806e3f6 bellard
Here are some useful tips in order to use gdb on system code:
1127 0806e3f6 bellard
1128 0806e3f6 bellard
@enumerate
1129 0806e3f6 bellard
@item
1130 0806e3f6 bellard
Use @code{info reg} to display all the CPU registers.
1131 0806e3f6 bellard
@item
1132 0806e3f6 bellard
Use @code{x/10i $eip} to display the code at the PC position.
1133 0806e3f6 bellard
@item
1134 0806e3f6 bellard
Use @code{set architecture i8086} to dump 16 bit code. Then use
1135 0806e3f6 bellard
@code{x/10i $cs*16+*eip} to dump the code at the PC position.
1136 0806e3f6 bellard
@end enumerate
1137 0806e3f6 bellard
1138 1a084f3d bellard
@section Target OS specific information
1139 1a084f3d bellard
1140 1a084f3d bellard
@subsection Linux
1141 1a084f3d bellard
1142 15a34c63 bellard
To have access to SVGA graphic modes under X11, use the @code{vesa} or
1143 15a34c63 bellard
the @code{cirrus} X11 driver. For optimal performances, use 16 bit
1144 15a34c63 bellard
color depth in the guest and the host OS.
1145 1a084f3d bellard
1146 e3371e62 bellard
When using a 2.6 guest Linux kernel, you should add the option
1147 e3371e62 bellard
@code{clock=pit} on the kernel command line because the 2.6 Linux
1148 e3371e62 bellard
kernels make very strict real time clock checks by default that QEMU
1149 e3371e62 bellard
cannot simulate exactly.
1150 e3371e62 bellard
1151 7c3fc84d bellard
When using a 2.6 guest Linux kernel, verify that the 4G/4G patch is
1152 7c3fc84d bellard
not activated because QEMU is slower with this patch. The QEMU
1153 7c3fc84d bellard
Accelerator Module is also much slower in this case. Earlier Fedora
1154 7c3fc84d bellard
Core 3 Linux kernel (< 2.6.9-1.724_FC3) were known to incorporte this
1155 7c3fc84d bellard
patch by default. Newer kernels don't have it.
1156 7c3fc84d bellard
1157 1a084f3d bellard
@subsection Windows
1158 1a084f3d bellard
1159 1a084f3d bellard
If you have a slow host, using Windows 95 is better as it gives the
1160 1a084f3d bellard
best speed. Windows 2000 is also a good choice.
1161 1a084f3d bellard
1162 e3371e62 bellard
@subsubsection SVGA graphic modes support
1163 e3371e62 bellard
1164 e3371e62 bellard
QEMU emulates a Cirrus Logic GD5446 Video
1165 15a34c63 bellard
card. All Windows versions starting from Windows 95 should recognize
1166 15a34c63 bellard
and use this graphic card. For optimal performances, use 16 bit color
1167 15a34c63 bellard
depth in the guest and the host OS.
1168 1a084f3d bellard
1169 e3371e62 bellard
@subsubsection CPU usage reduction
1170 e3371e62 bellard
1171 e3371e62 bellard
Windows 9x does not correctly use the CPU HLT
1172 15a34c63 bellard
instruction. The result is that it takes host CPU cycles even when
1173 15a34c63 bellard
idle. You can install the utility from
1174 15a34c63 bellard
@url{http://www.user.cityline.ru/~maxamn/amnhltm.zip} to solve this
1175 15a34c63 bellard
problem. Note that no such tool is needed for NT, 2000 or XP.
1176 1a084f3d bellard
1177 9d0a8e6f bellard
@subsubsection Windows 2000 disk full problem
1178 e3371e62 bellard
1179 9d0a8e6f bellard
Windows 2000 has a bug which gives a disk full problem during its
1180 9d0a8e6f bellard
installation. When installing it, use the @option{-win2k-hack} QEMU
1181 9d0a8e6f bellard
option to enable a specific workaround. After Windows 2000 is
1182 9d0a8e6f bellard
installed, you no longer need this option (this option slows down the
1183 9d0a8e6f bellard
IDE transfers).
1184 e3371e62 bellard
1185 6cc721cf bellard
@subsubsection Windows 2000 shutdown
1186 6cc721cf bellard
1187 6cc721cf bellard
Windows 2000 cannot automatically shutdown in QEMU although Windows 98
1188 6cc721cf bellard
can. It comes from the fact that Windows 2000 does not automatically
1189 6cc721cf bellard
use the APM driver provided by the BIOS.
1190 6cc721cf bellard
1191 6cc721cf bellard
In order to correct that, do the following (thanks to Struan
1192 6cc721cf bellard
Bartlett): go to the Control Panel => Add/Remove Hardware & Next =>
1193 6cc721cf bellard
Add/Troubleshoot a device => Add a new device & Next => No, select the
1194 6cc721cf bellard
hardware from a list & Next => NT Apm/Legacy Support & Next => Next
1195 6cc721cf bellard
(again) a few times. Now the driver is installed and Windows 2000 now
1196 6cc721cf bellard
correctly instructs QEMU to shutdown at the appropriate moment. 
1197 6cc721cf bellard
1198 6cc721cf bellard
@subsubsection Share a directory between Unix and Windows
1199 6cc721cf bellard
1200 6cc721cf bellard
See @ref{sec_invocation} about the help of the option @option{-smb}.
1201 6cc721cf bellard
1202 e3371e62 bellard
@subsubsection Windows XP security problems
1203 e3371e62 bellard
1204 e3371e62 bellard
Some releases of Windows XP install correctly but give a security
1205 e3371e62 bellard
error when booting:
1206 e3371e62 bellard
@example
1207 e3371e62 bellard
A problem is preventing Windows from accurately checking the
1208 e3371e62 bellard
license for this computer. Error code: 0x800703e6.
1209 e3371e62 bellard
@end example
1210 e3371e62 bellard
The only known workaround is to boot in Safe mode
1211 e3371e62 bellard
without networking support. 
1212 e3371e62 bellard
1213 e3371e62 bellard
Future QEMU releases are likely to correct this bug.
1214 e3371e62 bellard
1215 a0a821a4 bellard
@subsection MS-DOS and FreeDOS
1216 a0a821a4 bellard
1217 a0a821a4 bellard
@subsubsection CPU usage reduction
1218 a0a821a4 bellard
1219 a0a821a4 bellard
DOS does not correctly use the CPU HLT instruction. The result is that
1220 a0a821a4 bellard
it takes host CPU cycles even when idle. You can install the utility
1221 a0a821a4 bellard
from @url{http://www.vmware.com/software/dosidle210.zip} to solve this
1222 a0a821a4 bellard
problem.
1223 a0a821a4 bellard
1224 3f9f3aa1 bellard
@chapter QEMU System emulator for non PC targets
1225 3f9f3aa1 bellard
1226 3f9f3aa1 bellard
QEMU is a generic emulator and it emulates many non PC
1227 3f9f3aa1 bellard
machines. Most of the options are similar to the PC emulator. The
1228 3f9f3aa1 bellard
differences are mentionned in the following sections.
1229 3f9f3aa1 bellard
1230 3f9f3aa1 bellard
@section QEMU PowerPC System emulator
1231 1a084f3d bellard
1232 15a34c63 bellard
Use the executable @file{qemu-system-ppc} to simulate a complete PREP
1233 15a34c63 bellard
or PowerMac PowerPC system.
1234 1a084f3d bellard
1235 b671f9ed bellard
QEMU emulates the following PowerMac peripherals:
1236 1a084f3d bellard
1237 15a34c63 bellard
@itemize @minus
1238 15a34c63 bellard
@item 
1239 15a34c63 bellard
UniNorth PCI Bridge 
1240 15a34c63 bellard
@item
1241 15a34c63 bellard
PCI VGA compatible card with VESA Bochs Extensions
1242 15a34c63 bellard
@item 
1243 15a34c63 bellard
2 PMAC IDE interfaces with hard disk and CD-ROM support
1244 15a34c63 bellard
@item 
1245 15a34c63 bellard
NE2000 PCI adapters
1246 15a34c63 bellard
@item
1247 15a34c63 bellard
Non Volatile RAM
1248 15a34c63 bellard
@item
1249 15a34c63 bellard
VIA-CUDA with ADB keyboard and mouse.
1250 1a084f3d bellard
@end itemize
1251 1a084f3d bellard
1252 b671f9ed bellard
QEMU emulates the following PREP peripherals:
1253 52c00a5f bellard
1254 52c00a5f bellard
@itemize @minus
1255 52c00a5f bellard
@item 
1256 15a34c63 bellard
PCI Bridge
1257 15a34c63 bellard
@item
1258 15a34c63 bellard
PCI VGA compatible card with VESA Bochs Extensions
1259 15a34c63 bellard
@item 
1260 52c00a5f bellard
2 IDE interfaces with hard disk and CD-ROM support
1261 52c00a5f bellard
@item
1262 52c00a5f bellard
Floppy disk
1263 52c00a5f bellard
@item 
1264 15a34c63 bellard
NE2000 network adapters
1265 52c00a5f bellard
@item
1266 52c00a5f bellard
Serial port
1267 52c00a5f bellard
@item
1268 52c00a5f bellard
PREP Non Volatile RAM
1269 15a34c63 bellard
@item
1270 15a34c63 bellard
PC compatible keyboard and mouse.
1271 52c00a5f bellard
@end itemize
1272 52c00a5f bellard
1273 15a34c63 bellard
QEMU uses the Open Hack'Ware Open Firmware Compatible BIOS available at
1274 3f9f3aa1 bellard
@url{http://perso.magic.fr/l_indien/OpenHackWare/index.htm}.
1275 52c00a5f bellard
1276 15a34c63 bellard
@c man begin OPTIONS
1277 15a34c63 bellard
1278 15a34c63 bellard
The following options are specific to the PowerPC emulation:
1279 15a34c63 bellard
1280 15a34c63 bellard
@table @option
1281 15a34c63 bellard
1282 15a34c63 bellard
@item -g WxH[xDEPTH]  
1283 15a34c63 bellard
1284 15a34c63 bellard
Set the initial VGA graphic mode. The default is 800x600x15.
1285 15a34c63 bellard
1286 15a34c63 bellard
@end table
1287 15a34c63 bellard
1288 15a34c63 bellard
@c man end 
1289 15a34c63 bellard
1290 15a34c63 bellard
1291 52c00a5f bellard
More information is available at
1292 3f9f3aa1 bellard
@url{http://perso.magic.fr/l_indien/qemu-ppc/}.
1293 52c00a5f bellard
1294 3f9f3aa1 bellard
@section Sparc32 System emulator invocation
1295 e80cfcfc bellard
1296 e80cfcfc bellard
Use the executable @file{qemu-system-sparc} to simulate a JavaStation
1297 3475187d bellard
(sun4m architecture). The emulation is somewhat complete.
1298 e80cfcfc bellard
1299 b671f9ed bellard
QEMU emulates the following sun4m peripherals:
1300 e80cfcfc bellard
1301 e80cfcfc bellard
@itemize @minus
1302 3475187d bellard
@item
1303 e80cfcfc bellard
IOMMU
1304 e80cfcfc bellard
@item
1305 e80cfcfc bellard
TCX Frame buffer
1306 e80cfcfc bellard
@item 
1307 e80cfcfc bellard
Lance (Am7990) Ethernet
1308 e80cfcfc bellard
@item
1309 e80cfcfc bellard
Non Volatile RAM M48T08
1310 e80cfcfc bellard
@item
1311 3475187d bellard
Slave I/O: timers, interrupt controllers, Zilog serial ports, keyboard
1312 3475187d bellard
and power/reset logic
1313 3475187d bellard
@item
1314 3475187d bellard
ESP SCSI controller with hard disk and CD-ROM support
1315 3475187d bellard
@item
1316 3475187d bellard
Floppy drive
1317 e80cfcfc bellard
@end itemize
1318 e80cfcfc bellard
1319 3475187d bellard
The number of peripherals is fixed in the architecture.
1320 3475187d bellard
1321 e80cfcfc bellard
QEMU uses the Proll, a PROM replacement available at
1322 3475187d bellard
@url{http://people.redhat.com/zaitcev/linux/}. The required
1323 3475187d bellard
QEMU-specific patches are included with the sources.
1324 3475187d bellard
1325 3475187d bellard
A sample Linux 2.6 series kernel and ram disk image are available on
1326 3475187d bellard
the QEMU web site. Please note that currently neither Linux 2.4
1327 3475187d bellard
series, NetBSD, nor OpenBSD kernels work.
1328 3475187d bellard
1329 3475187d bellard
@c man begin OPTIONS
1330 3475187d bellard
1331 3475187d bellard
The following options are specific to the Sparc emulation:
1332 3475187d bellard
1333 3475187d bellard
@table @option
1334 3475187d bellard
1335 3475187d bellard
@item -g WxH
1336 3475187d bellard
1337 3475187d bellard
Set the initial TCX graphic mode. The default is 1024x768.
1338 3475187d bellard
1339 3475187d bellard
@end table
1340 3475187d bellard
1341 3475187d bellard
@c man end 
1342 3475187d bellard
1343 3f9f3aa1 bellard
@section Sparc64 System emulator invocation
1344 e80cfcfc bellard
1345 3475187d bellard
Use the executable @file{qemu-system-sparc64} to simulate a Sun4u machine.
1346 3475187d bellard
The emulator is not usable for anything yet.
1347 b756921a bellard
1348 83469015 bellard
QEMU emulates the following sun4u peripherals:
1349 83469015 bellard
1350 83469015 bellard
@itemize @minus
1351 83469015 bellard
@item
1352 83469015 bellard
UltraSparc IIi APB PCI Bridge 
1353 83469015 bellard
@item
1354 83469015 bellard
PCI VGA compatible card with VESA Bochs Extensions
1355 83469015 bellard
@item
1356 83469015 bellard
Non Volatile RAM M48T59
1357 83469015 bellard
@item
1358 83469015 bellard
PC-compatible serial ports
1359 83469015 bellard
@end itemize
1360 83469015 bellard
1361 3f9f3aa1 bellard
@section MIPS System emulator invocation
1362 9d0a8e6f bellard
1363 9d0a8e6f bellard
Use the executable @file{qemu-system-mips} to simulate a MIPS machine.
1364 3f9f3aa1 bellard
The emulator is able to boot a Linux kernel and to run a Linux Debian
1365 3f9f3aa1 bellard
installation from NFS. The following devices are emulated:
1366 3f9f3aa1 bellard
1367 3f9f3aa1 bellard
@itemize @minus
1368 3f9f3aa1 bellard
@item 
1369 3f9f3aa1 bellard
MIPS R4K CPU
1370 3f9f3aa1 bellard
@item
1371 3f9f3aa1 bellard
PC style serial port
1372 3f9f3aa1 bellard
@item
1373 3f9f3aa1 bellard
NE2000 network card
1374 3f9f3aa1 bellard
@end itemize
1375 3f9f3aa1 bellard
1376 3f9f3aa1 bellard
More information is available in the QEMU mailing-list archive.
1377 3f9f3aa1 bellard
1378 3f9f3aa1 bellard
@section ARM System emulator invocation
1379 3f9f3aa1 bellard
1380 3f9f3aa1 bellard
Use the executable @file{qemu-system-arm} to simulate a ARM
1381 3f9f3aa1 bellard
machine. The ARM Integrator/CP board is emulated with the following
1382 3f9f3aa1 bellard
devices:
1383 3f9f3aa1 bellard
1384 3f9f3aa1 bellard
@itemize @minus
1385 3f9f3aa1 bellard
@item
1386 ed96ca35 pbrook
ARM926E or ARM1026E CPU
1387 3f9f3aa1 bellard
@item
1388 3f9f3aa1 bellard
Two PL011 UARTs
1389 3f9f3aa1 bellard
@item 
1390 3f9f3aa1 bellard
SMC 91c111 Ethernet adapter
1391 3f9f3aa1 bellard
@end itemize
1392 3f9f3aa1 bellard
1393 3f9f3aa1 bellard
A Linux 2.6 test image is available on the QEMU web site. More
1394 3f9f3aa1 bellard
information is available in the QEMU mailing-list archive.
1395 9d0a8e6f bellard
1396 3f9f3aa1 bellard
@chapter QEMU Linux User space emulator 
1397 386405f7 bellard
1398 1f673135 bellard
@section Quick Start
1399 df0f11a0 bellard
1400 1f673135 bellard
In order to launch a Linux process, QEMU needs the process executable
1401 1f673135 bellard
itself and all the target (x86) dynamic libraries used by it. 
1402 386405f7 bellard
1403 1f673135 bellard
@itemize
1404 386405f7 bellard
1405 1f673135 bellard
@item On x86, you can just try to launch any process by using the native
1406 1f673135 bellard
libraries:
1407 386405f7 bellard
1408 1f673135 bellard
@example 
1409 1f673135 bellard
qemu-i386 -L / /bin/ls
1410 1f673135 bellard
@end example
1411 386405f7 bellard
1412 1f673135 bellard
@code{-L /} tells that the x86 dynamic linker must be searched with a
1413 1f673135 bellard
@file{/} prefix.
1414 386405f7 bellard
1415 1f673135 bellard
@item Since QEMU is also a linux process, you can launch qemu with qemu (NOTE: you can only do that if you compiled QEMU from the sources):
1416 386405f7 bellard
1417 1f673135 bellard
@example 
1418 1f673135 bellard
qemu-i386 -L / qemu-i386 -L / /bin/ls
1419 1f673135 bellard
@end example
1420 386405f7 bellard
1421 1f673135 bellard
@item On non x86 CPUs, you need first to download at least an x86 glibc
1422 1f673135 bellard
(@file{qemu-runtime-i386-XXX-.tar.gz} on the QEMU web page). Ensure that
1423 1f673135 bellard
@code{LD_LIBRARY_PATH} is not set:
1424 df0f11a0 bellard
1425 1f673135 bellard
@example
1426 1f673135 bellard
unset LD_LIBRARY_PATH 
1427 1f673135 bellard
@end example
1428 1eb87257 bellard
1429 1f673135 bellard
Then you can launch the precompiled @file{ls} x86 executable:
1430 1eb87257 bellard
1431 1f673135 bellard
@example
1432 1f673135 bellard
qemu-i386 tests/i386/ls
1433 1f673135 bellard
@end example
1434 1f673135 bellard
You can look at @file{qemu-binfmt-conf.sh} so that
1435 1f673135 bellard
QEMU is automatically launched by the Linux kernel when you try to
1436 1f673135 bellard
launch x86 executables. It requires the @code{binfmt_misc} module in the
1437 1f673135 bellard
Linux kernel.
1438 1eb87257 bellard
1439 1f673135 bellard
@item The x86 version of QEMU is also included. You can try weird things such as:
1440 1f673135 bellard
@example
1441 1f673135 bellard
qemu-i386 /usr/local/qemu-i386/bin/qemu-i386 /usr/local/qemu-i386/bin/ls-i386
1442 1f673135 bellard
@end example
1443 1eb20527 bellard
1444 1f673135 bellard
@end itemize
1445 1eb20527 bellard
1446 1f673135 bellard
@section Wine launch
1447 1eb20527 bellard
1448 1f673135 bellard
@itemize
1449 386405f7 bellard
1450 1f673135 bellard
@item Ensure that you have a working QEMU with the x86 glibc
1451 1f673135 bellard
distribution (see previous section). In order to verify it, you must be
1452 1f673135 bellard
able to do:
1453 386405f7 bellard
1454 1f673135 bellard
@example
1455 1f673135 bellard
qemu-i386 /usr/local/qemu-i386/bin/ls-i386
1456 1f673135 bellard
@end example
1457 386405f7 bellard
1458 1f673135 bellard
@item Download the binary x86 Wine install
1459 1f673135 bellard
(@file{qemu-XXX-i386-wine.tar.gz} on the QEMU web page). 
1460 386405f7 bellard
1461 1f673135 bellard
@item Configure Wine on your account. Look at the provided script
1462 1f673135 bellard
@file{/usr/local/qemu-i386/bin/wine-conf.sh}. Your previous
1463 1f673135 bellard
@code{$@{HOME@}/.wine} directory is saved to @code{$@{HOME@}/.wine.org}.
1464 386405f7 bellard
1465 1f673135 bellard
@item Then you can try the example @file{putty.exe}:
1466 386405f7 bellard
1467 1f673135 bellard
@example
1468 1f673135 bellard
qemu-i386 /usr/local/qemu-i386/wine/bin/wine /usr/local/qemu-i386/wine/c/Program\ Files/putty.exe
1469 1f673135 bellard
@end example
1470 386405f7 bellard
1471 1f673135 bellard
@end itemize
1472 fd429f2f bellard
1473 1f673135 bellard
@section Command line options
1474 1eb20527 bellard
1475 1f673135 bellard
@example
1476 1f673135 bellard
usage: qemu-i386 [-h] [-d] [-L path] [-s size] program [arguments...]
1477 1f673135 bellard
@end example
1478 1eb20527 bellard
1479 1f673135 bellard
@table @option
1480 1f673135 bellard
@item -h
1481 1f673135 bellard
Print the help
1482 1f673135 bellard
@item -L path   
1483 1f673135 bellard
Set the x86 elf interpreter prefix (default=/usr/local/qemu-i386)
1484 1f673135 bellard
@item -s size
1485 1f673135 bellard
Set the x86 stack size in bytes (default=524288)
1486 386405f7 bellard
@end table
1487 386405f7 bellard
1488 1f673135 bellard
Debug options:
1489 386405f7 bellard
1490 1f673135 bellard
@table @option
1491 1f673135 bellard
@item -d
1492 1f673135 bellard
Activate log (logfile=/tmp/qemu.log)
1493 1f673135 bellard
@item -p pagesize
1494 1f673135 bellard
Act as if the host page size was 'pagesize' bytes
1495 1f673135 bellard
@end table
1496 386405f7 bellard
1497 15a34c63 bellard
@node compilation
1498 15a34c63 bellard
@chapter Compilation from the sources
1499 15a34c63 bellard
1500 7c3fc84d bellard
@section Linux/Unix
1501 7c3fc84d bellard
1502 7c3fc84d bellard
@subsection Compilation
1503 7c3fc84d bellard
1504 7c3fc84d bellard
First you must decompress the sources:
1505 7c3fc84d bellard
@example
1506 7c3fc84d bellard
cd /tmp
1507 7c3fc84d bellard
tar zxvf qemu-x.y.z.tar.gz
1508 7c3fc84d bellard
cd qemu-x.y.z
1509 7c3fc84d bellard
@end example
1510 7c3fc84d bellard
1511 7c3fc84d bellard
Then you configure QEMU and build it (usually no options are needed):
1512 7c3fc84d bellard
@example
1513 7c3fc84d bellard
./configure
1514 7c3fc84d bellard
make
1515 7c3fc84d bellard
@end example
1516 7c3fc84d bellard
1517 7c3fc84d bellard
Then type as root user:
1518 7c3fc84d bellard
@example
1519 7c3fc84d bellard
make install
1520 7c3fc84d bellard
@end example
1521 7c3fc84d bellard
to install QEMU in @file{/usr/local}.
1522 7c3fc84d bellard
1523 7c3fc84d bellard
@subsection Tested tool versions
1524 7c3fc84d bellard
1525 7c3fc84d bellard
In order to compile QEMU succesfully, it is very important that you
1526 7c3fc84d bellard
have the right tools. The most important one is gcc. I cannot guaranty
1527 7c3fc84d bellard
that QEMU works if you do not use a tested gcc version. Look at
1528 7c3fc84d bellard
'configure' and 'Makefile' if you want to make a different gcc
1529 7c3fc84d bellard
version work.
1530 7c3fc84d bellard
1531 7c3fc84d bellard
@example
1532 7c3fc84d bellard
host      gcc      binutils      glibc    linux       distribution
1533 7c3fc84d bellard
----------------------------------------------------------------------
1534 7c3fc84d bellard
x86       3.2      2.13.2        2.1.3    2.4.18
1535 7c3fc84d bellard
          2.96     2.11.93.0.2   2.2.5    2.4.18      Red Hat 7.3
1536 7c3fc84d bellard
          3.2.2    2.13.90.0.18  2.3.2    2.4.20      Red Hat 9
1537 7c3fc84d bellard
1538 7c3fc84d bellard
PowerPC   3.3 [4]  2.13.90.0.18  2.3.1    2.4.20briq
1539 7c3fc84d bellard
          3.2
1540 7c3fc84d bellard
1541 7c3fc84d bellard
Alpha     3.3 [1]  2.14.90.0.4   2.2.5    2.2.20 [2]  Debian 3.0
1542 7c3fc84d bellard
1543 7c3fc84d bellard
Sparc32   2.95.4   2.12.90.0.1   2.2.5    2.4.18      Debian 3.0
1544 7c3fc84d bellard
1545 7c3fc84d bellard
ARM       2.95.4   2.12.90.0.1   2.2.5    2.4.9 [3]   Debian 3.0
1546 7c3fc84d bellard
1547 7c3fc84d bellard
[1] On Alpha, QEMU needs the gcc 'visibility' attribute only available
1548 7c3fc84d bellard
    for gcc version >= 3.3.
1549 7c3fc84d bellard
[2] Linux >= 2.4.20 is necessary for precise exception support
1550 7c3fc84d bellard
    (untested).
1551 7c3fc84d bellard
[3] 2.4.9-ac10-rmk2-np1-cerf2
1552 7c3fc84d bellard
1553 7c3fc84d bellard
[4] gcc 2.95.x generates invalid code when using too many register
1554 7c3fc84d bellard
variables. You must use gcc 3.x on PowerPC.
1555 7c3fc84d bellard
@end example
1556 15a34c63 bellard
1557 15a34c63 bellard
@section Windows
1558 15a34c63 bellard
1559 15a34c63 bellard
@itemize
1560 15a34c63 bellard
@item Install the current versions of MSYS and MinGW from
1561 15a34c63 bellard
@url{http://www.mingw.org/}. You can find detailed installation
1562 15a34c63 bellard
instructions in the download section and the FAQ.
1563 15a34c63 bellard
1564 15a34c63 bellard
@item Download 
1565 15a34c63 bellard
the MinGW development library of SDL 1.2.x
1566 15a34c63 bellard
(@file{SDL-devel-1.2.x-mingw32.tar.gz}) from
1567 15a34c63 bellard
@url{http://www.libsdl.org}. Unpack it in a temporary place, and
1568 15a34c63 bellard
unpack the archive @file{i386-mingw32msvc.tar.gz} in the MinGW tool
1569 15a34c63 bellard
directory. Edit the @file{sdl-config} script so that it gives the
1570 15a34c63 bellard
correct SDL directory when invoked.
1571 15a34c63 bellard
1572 15a34c63 bellard
@item Extract the current version of QEMU.
1573 15a34c63 bellard
 
1574 15a34c63 bellard
@item Start the MSYS shell (file @file{msys.bat}).
1575 15a34c63 bellard
1576 15a34c63 bellard
@item Change to the QEMU directory. Launch @file{./configure} and 
1577 15a34c63 bellard
@file{make}.  If you have problems using SDL, verify that
1578 15a34c63 bellard
@file{sdl-config} can be launched from the MSYS command line.
1579 15a34c63 bellard
1580 15a34c63 bellard
@item You can install QEMU in @file{Program Files/Qemu} by typing 
1581 15a34c63 bellard
@file{make install}. Don't forget to copy @file{SDL.dll} in
1582 15a34c63 bellard
@file{Program Files/Qemu}.
1583 15a34c63 bellard
1584 15a34c63 bellard
@end itemize
1585 15a34c63 bellard
1586 15a34c63 bellard
@section Cross compilation for Windows with Linux
1587 15a34c63 bellard
1588 15a34c63 bellard
@itemize
1589 15a34c63 bellard
@item
1590 15a34c63 bellard
Install the MinGW cross compilation tools available at
1591 15a34c63 bellard
@url{http://www.mingw.org/}.
1592 15a34c63 bellard
1593 15a34c63 bellard
@item 
1594 15a34c63 bellard
Install the Win32 version of SDL (@url{http://www.libsdl.org}) by
1595 15a34c63 bellard
unpacking @file{i386-mingw32msvc.tar.gz}. Set up the PATH environment
1596 15a34c63 bellard
variable so that @file{i386-mingw32msvc-sdl-config} can be launched by
1597 15a34c63 bellard
the QEMU configuration script.
1598 15a34c63 bellard
1599 15a34c63 bellard
@item 
1600 15a34c63 bellard
Configure QEMU for Windows cross compilation:
1601 15a34c63 bellard
@example
1602 15a34c63 bellard
./configure --enable-mingw32
1603 15a34c63 bellard
@end example
1604 15a34c63 bellard
If necessary, you can change the cross-prefix according to the prefix
1605 15a34c63 bellard
choosen for the MinGW tools with --cross-prefix. You can also use
1606 15a34c63 bellard
--prefix to set the Win32 install path.
1607 15a34c63 bellard
1608 15a34c63 bellard
@item You can install QEMU in the installation directory by typing 
1609 15a34c63 bellard
@file{make install}. Don't forget to copy @file{SDL.dll} in the
1610 15a34c63 bellard
installation directory. 
1611 15a34c63 bellard
1612 15a34c63 bellard
@end itemize
1613 15a34c63 bellard
1614 15a34c63 bellard
Note: Currently, Wine does not seem able to launch
1615 15a34c63 bellard
QEMU for Win32.
1616 15a34c63 bellard
1617 15a34c63 bellard
@section Mac OS X
1618 15a34c63 bellard
1619 15a34c63 bellard
The Mac OS X patches are not fully merged in QEMU, so you should look
1620 15a34c63 bellard
at the QEMU mailing list archive to have all the necessary
1621 15a34c63 bellard
information.