Statistics
| Branch: | Revision:

root / qemu-doc.texi @ d78f3995

History | View | Annotate | Download (109.9 kB)

1
\input texinfo @c -*- texinfo -*-
2
@c %**start of header
3
@setfilename qemu-doc.info
4
@settitle QEMU Emulator User Documentation
5
@exampleindent 0
6
@paragraphindent 0
7
@c %**end of header
8

    
9
@iftex
10
@titlepage
11
@sp 7
12
@center @titlefont{QEMU Emulator}
13
@sp 1
14
@center @titlefont{User Documentation}
15
@sp 3
16
@end titlepage
17
@end iftex
18

    
19
@ifnottex
20
@node Top
21
@top
22

    
23
@menu
24
* Introduction::
25
* Installation::
26
* QEMU PC System emulator::
27
* QEMU System emulator for non PC targets::
28
* QEMU User space emulator::
29
* compilation:: Compilation from the sources
30
* Index::
31
@end menu
32
@end ifnottex
33

    
34
@contents
35

    
36
@node Introduction
37
@chapter Introduction
38

    
39
@menu
40
* intro_features:: Features
41
@end menu
42

    
43
@node intro_features
44
@section Features
45

    
46
QEMU is a FAST! processor emulator using dynamic translation to
47
achieve good emulation speed.
48

    
49
QEMU has two operating modes:
50

    
51
@itemize @minus
52

    
53
@item
54
Full system emulation. In this mode, QEMU emulates a full system (for
55
example a PC), including one or several processors and various
56
peripherals. It can be used to launch different Operating Systems
57
without rebooting the PC or to debug system code.
58

    
59
@item
60
User mode emulation. In this mode, QEMU can launch
61
processes compiled for one CPU on another CPU. It can be used to
62
launch the Wine Windows API emulator (@url{http://www.winehq.org}) or
63
to ease cross-compilation and cross-debugging.
64

    
65
@end itemize
66

    
67
QEMU can run without an host kernel driver and yet gives acceptable
68
performance.
69

    
70
For system emulation, the following hardware targets are supported:
71
@itemize
72
@item PC (x86 or x86_64 processor)
73
@item ISA PC (old style PC without PCI bus)
74
@item PREP (PowerPC processor)
75
@item G3 Beige PowerMac (PowerPC processor)
76
@item Mac99 PowerMac (PowerPC processor, in progress)
77
@item Sun4m/Sun4c/Sun4d (32-bit Sparc processor)
78
@item Sun4u/Sun4v (64-bit Sparc processor, in progress)
79
@item Malta board (32-bit and 64-bit MIPS processors)
80
@item MIPS Magnum (64-bit MIPS processor)
81
@item ARM Integrator/CP (ARM)
82
@item ARM Versatile baseboard (ARM)
83
@item ARM RealView Emulation baseboard (ARM)
84
@item Spitz, Akita, Borzoi, Terrier and Tosa PDAs (PXA270 processor)
85
@item Luminary Micro LM3S811EVB (ARM Cortex-M3)
86
@item Luminary Micro LM3S6965EVB (ARM Cortex-M3)
87
@item Freescale MCF5208EVB (ColdFire V2).
88
@item Arnewsh MCF5206 evaluation board (ColdFire V2).
89
@item Palm Tungsten|E PDA (OMAP310 processor)
90
@item N800 and N810 tablets (OMAP2420 processor)
91
@item MusicPal (MV88W8618 ARM processor)
92
@item Gumstix "Connex" and "Verdex" motherboards (PXA255/270).
93
@item Siemens SX1 smartphone (OMAP310 processor)
94
@end itemize
95

    
96
For user emulation, x86, PowerPC, ARM, 32-bit MIPS, Sparc32/64 and ColdFire(m68k) CPUs are supported.
97

    
98
@node Installation
99
@chapter Installation
100

    
101
If you want to compile QEMU yourself, see @ref{compilation}.
102

    
103
@menu
104
* install_linux::   Linux
105
* install_windows:: Windows
106
* install_mac::     Macintosh
107
@end menu
108

    
109
@node install_linux
110
@section Linux
111

    
112
If a precompiled package is available for your distribution - you just
113
have to install it. Otherwise, see @ref{compilation}.
114

    
115
@node install_windows
116
@section Windows
117

    
118
Download the experimental binary installer at
119
@url{http://www.free.oszoo.org/@/download.html}.
120

    
121
@node install_mac
122
@section Mac OS X
123

    
124
Download the experimental binary installer at
125
@url{http://www.free.oszoo.org/@/download.html}.
126

    
127
@node QEMU PC System emulator
128
@chapter QEMU PC System emulator
129

    
130
@menu
131
* pcsys_introduction:: Introduction
132
* pcsys_quickstart::   Quick Start
133
* sec_invocation::     Invocation
134
* pcsys_keys::         Keys
135
* pcsys_monitor::      QEMU Monitor
136
* disk_images::        Disk Images
137
* pcsys_network::      Network emulation
138
* direct_linux_boot::  Direct Linux Boot
139
* pcsys_usb::          USB emulation
140
* vnc_security::       VNC security
141
* gdb_usage::          GDB usage
142
* pcsys_os_specific::  Target OS specific information
143
@end menu
144

    
145
@node pcsys_introduction
146
@section Introduction
147

    
148
@c man begin DESCRIPTION
149

    
150
The QEMU PC System emulator simulates the
151
following peripherals:
152

    
153
@itemize @minus
154
@item
155
i440FX host PCI bridge and PIIX3 PCI to ISA bridge
156
@item
157
Cirrus CLGD 5446 PCI VGA card or dummy VGA card with Bochs VESA
158
extensions (hardware level, including all non standard modes).
159
@item
160
PS/2 mouse and keyboard
161
@item
162
2 PCI IDE interfaces with hard disk and CD-ROM support
163
@item
164
Floppy disk
165
@item
166
PCI/ISA PCI network adapters
167
@item
168
Serial ports
169
@item
170
Creative SoundBlaster 16 sound card
171
@item
172
ENSONIQ AudioPCI ES1370 sound card
173
@item
174
Intel 82801AA AC97 Audio compatible sound card
175
@item
176
Adlib(OPL2) - Yamaha YM3812 compatible chip
177
@item
178
Gravis Ultrasound GF1 sound card
179
@item
180
CS4231A compatible sound card
181
@item
182
PCI UHCI USB controller and a virtual USB hub.
183
@end itemize
184

    
185
SMP is supported with up to 255 CPUs.
186

    
187
Note that adlib, gus and cs4231a are only available when QEMU was
188
configured with --audio-card-list option containing the name(s) of
189
required card(s).
190

    
191
QEMU uses the PC BIOS from the Bochs project and the Plex86/Bochs LGPL
192
VGA BIOS.
193

    
194
QEMU uses YM3812 emulation by Tatsuyuki Satoh.
195

    
196
QEMU uses GUS emulation(GUSEMU32 @url{http://www.deinmeister.de/gusemu/})
197
by Tibor "TS" Sch?tz.
198

    
199
CS4231A is the chip used in Windows Sound System and GUSMAX products
200

    
201
@c man end
202

    
203
@node pcsys_quickstart
204
@section Quick Start
205

    
206
Download and uncompress the linux image (@file{linux.img}) and type:
207

    
208
@example
209
qemu linux.img
210
@end example
211

    
212
Linux should boot and give you a prompt.
213

    
214
@node sec_invocation
215
@section Invocation
216

    
217
@example
218
@c man begin SYNOPSIS
219
usage: qemu [options] [@var{disk_image}]
220
@c man end
221
@end example
222

    
223
@c man begin OPTIONS
224
@var{disk_image} is a raw hard disk image for IDE hard disk 0. Some
225
targets do not need a disk image.
226

    
227
General options:
228
@table @option
229
@item -h
230
Display help and exit
231

    
232
@item -M @var{machine}
233
Select the emulated @var{machine} (@code{-M ?} for list)
234

    
235
@item -cpu @var{model}
236
Select CPU model (-cpu ? for list and additional feature selection)
237

    
238
@item -smp @var{n}
239
Simulate an SMP system with @var{n} CPUs. On the PC target, up to 255
240
CPUs are supported. On Sparc32 target, Linux limits the number of usable CPUs
241
to 4.
242

    
243
@item -fda @var{file}
244
@item -fdb @var{file}
245
Use @var{file} as floppy disk 0/1 image (@pxref{disk_images}). You can
246
use the host floppy by using @file{/dev/fd0} as filename (@pxref{host_drives}).
247

    
248
@item -hda @var{file}
249
@item -hdb @var{file}
250
@item -hdc @var{file}
251
@item -hdd @var{file}
252
Use @var{file} as hard disk 0, 1, 2 or 3 image (@pxref{disk_images}).
253

    
254
@item -cdrom @var{file}
255
Use @var{file} as CD-ROM image (you cannot use @option{-hdc} and
256
@option{-cdrom} at the same time). You can use the host CD-ROM by
257
using @file{/dev/cdrom} as filename (@pxref{host_drives}).
258

    
259
@item -drive @var{option}[,@var{option}[,@var{option}[,...]]]
260

    
261
Define a new drive. Valid options are:
262

    
263
@table @code
264
@item file=@var{file}
265
This option defines which disk image (@pxref{disk_images}) to use with
266
this drive. If the filename contains comma, you must double it
267
(for instance, "file=my,,file" to use file "my,file").
268
@item if=@var{interface}
269
This option defines on which type on interface the drive is connected.
270
Available types are: ide, scsi, sd, mtd, floppy, pflash, virtio.
271
@item bus=@var{bus},unit=@var{unit}
272
These options define where is connected the drive by defining the bus number and
273
the unit id.
274
@item index=@var{index}
275
This option defines where is connected the drive by using an index in the list
276
of available connectors of a given interface type.
277
@item media=@var{media}
278
This option defines the type of the media: disk or cdrom.
279
@item cyls=@var{c},heads=@var{h},secs=@var{s}[,trans=@var{t}]
280
These options have the same definition as they have in @option{-hdachs}.
281
@item snapshot=@var{snapshot}
282
@var{snapshot} is "on" or "off" and allows to enable snapshot for given drive (see @option{-snapshot}).
283
@item cache=@var{cache}
284
@var{cache} is "none", "writeback", or "writethrough" and controls how the host cache is used to access block data.
285
@item format=@var{format}
286
Specify which disk @var{format} will be used rather than detecting
287
the format.  Can be used to specifiy format=raw to avoid interpreting
288
an untrusted format header.
289
@item serial=@var{serial}
290
This option specifies the serial number to assign to the device.
291
@end table
292

    
293
By default, writethrough caching is used for all block device.  This means that
294
the host page cache will be used to read and write data but write notification
295
will be sent to the guest only when the data has been reported as written by
296
the storage subsystem.
297

    
298
Writeback caching will report data writes as completed as soon as the data is
299
present in the host page cache.  This is safe as long as you trust your host.
300
If your host crashes or loses power, then the guest may experience data
301
corruption.  When using the @option{-snapshot} option, writeback caching is
302
used by default.
303

    
304
The host page can be avoided entirely with @option{cache=none}.  This will
305
attempt to do disk IO directly to the guests memory.  QEMU may still perform
306
an internal copy of the data.
307

    
308
Some block drivers perform badly with @option{cache=writethrough}, most notably,
309
qcow2.  If performance is more important than correctness,
310
@option{cache=writeback} should be used with qcow2.  By default, if no explicit
311
caching is specified for a qcow2 disk image, @option{cache=writeback} will be
312
used.  For all other disk types, @option{cache=writethrough} is the default.
313

    
314
Instead of @option{-cdrom} you can use:
315
@example
316
qemu -drive file=file,index=2,media=cdrom
317
@end example
318

    
319
Instead of @option{-hda}, @option{-hdb}, @option{-hdc}, @option{-hdd}, you can
320
use:
321
@example
322
qemu -drive file=file,index=0,media=disk
323
qemu -drive file=file,index=1,media=disk
324
qemu -drive file=file,index=2,media=disk
325
qemu -drive file=file,index=3,media=disk
326
@end example
327

    
328
You can connect a CDROM to the slave of ide0:
329
@example
330
qemu -drive file=file,if=ide,index=1,media=cdrom
331
@end example
332

    
333
If you don't specify the "file=" argument, you define an empty drive:
334
@example
335
qemu -drive if=ide,index=1,media=cdrom
336
@end example
337

    
338
You can connect a SCSI disk with unit ID 6 on the bus #0:
339
@example
340
qemu -drive file=file,if=scsi,bus=0,unit=6
341
@end example
342

    
343
Instead of @option{-fda}, @option{-fdb}, you can use:
344
@example
345
qemu -drive file=file,index=0,if=floppy
346
qemu -drive file=file,index=1,if=floppy
347
@end example
348

    
349
By default, @var{interface} is "ide" and @var{index} is automatically
350
incremented:
351
@example
352
qemu -drive file=a -drive file=b"
353
@end example
354
is interpreted like:
355
@example
356
qemu -hda a -hdb b
357
@end example
358

    
359
@item -mtdblock file
360
Use 'file' as on-board Flash memory image.
361

    
362
@item -sd file
363
Use 'file' as SecureDigital card image.
364

    
365
@item -pflash file
366
Use 'file' as a parallel flash image.
367

    
368
@item -boot [a|c|d|n]
369
Boot on floppy (a), hard disk (c), CD-ROM (d), or Etherboot (n). Hard disk boot
370
is the default.
371

    
372
@item -snapshot
373
Write to temporary files instead of disk image files. In this case,
374
the raw disk image you use is not written back. You can however force
375
the write back by pressing @key{C-a s} (@pxref{disk_images}).
376

    
377
@item -m @var{megs}
378
Set virtual RAM size to @var{megs} megabytes. Default is 128 MiB.  Optionally,
379
a suffix of ``M'' or ``G'' can be used to signify a value in megabytes or
380
gigabytes respectively.
381

    
382
@item -k @var{language}
383

    
384
Use keyboard layout @var{language} (for example @code{fr} for
385
French). This option is only needed where it is not easy to get raw PC
386
keycodes (e.g. on Macs, with some X11 servers or with a VNC
387
display). You don't normally need to use it on PC/Linux or PC/Windows
388
hosts.
389

    
390
The available layouts are:
391
@example
392
ar  de-ch  es  fo     fr-ca  hu  ja  mk     no  pt-br  sv
393
da  en-gb  et  fr     fr-ch  is  lt  nl     pl  ru     th
394
de  en-us  fi  fr-be  hr     it  lv  nl-be  pt  sl     tr
395
@end example
396

    
397
The default is @code{en-us}.
398

    
399
@item -audio-help
400

    
401
Will show the audio subsystem help: list of drivers, tunable
402
parameters.
403

    
404
@item -soundhw @var{card1}[,@var{card2},...] or -soundhw all
405

    
406
Enable audio and selected sound hardware. Use ? to print all
407
available sound hardware.
408

    
409
@example
410
qemu -soundhw sb16,adlib disk.img
411
qemu -soundhw es1370 disk.img
412
qemu -soundhw ac97 disk.img
413
qemu -soundhw all disk.img
414
qemu -soundhw ?
415
@end example
416

    
417
Note that Linux's i810_audio OSS kernel (for AC97) module might
418
require manually specifying clocking.
419

    
420
@example
421
modprobe i810_audio clocking=48000
422
@end example
423

    
424
@end table
425

    
426
USB options:
427
@table @option
428

    
429
@item -usb
430
Enable the USB driver (will be the default soon)
431

    
432
@item -usbdevice @var{devname}
433
Add the USB device @var{devname}. @xref{usb_devices}.
434

    
435
@table @code
436

    
437
@item mouse
438
Virtual Mouse. This will override the PS/2 mouse emulation when activated.
439

    
440
@item tablet
441
Pointer device that uses absolute coordinates (like a touchscreen). This
442
means qemu is able to report the mouse position without having to grab the
443
mouse. Also overrides the PS/2 mouse emulation when activated.
444

    
445
@item disk:[format=@var{format}]:file
446
Mass storage device based on file. The optional @var{format} argument
447
will be used rather than detecting the format. Can be used to specifiy
448
format=raw to avoid interpreting an untrusted format header.
449

    
450
@item host:bus.addr
451
Pass through the host device identified by bus.addr (Linux only).
452

    
453
@item host:vendor_id:product_id
454
Pass through the host device identified by vendor_id:product_id (Linux only).
455

    
456
@item serial:[vendorid=@var{vendor_id}][,productid=@var{product_id}]:@var{dev}
457
Serial converter to host character device @var{dev}, see @code{-serial} for the
458
available devices.
459

    
460
@item braille
461
Braille device.  This will use BrlAPI to display the braille output on a real
462
or fake device.
463

    
464
@item net:options
465
Network adapter that supports CDC ethernet and RNDIS protocols.
466

    
467
@end table
468

    
469
@item -name @var{name}
470
Sets the @var{name} of the guest.
471
This name will be displayed in the SDL window caption.
472
The @var{name} will also be used for the VNC server.
473

    
474
@item -uuid @var{uuid}
475
Set system UUID.
476

    
477
@end table
478

    
479
Display options:
480
@table @option
481

    
482
@item -nographic
483

    
484
Normally, QEMU uses SDL to display the VGA output. With this option,
485
you can totally disable graphical output so that QEMU is a simple
486
command line application. The emulated serial port is redirected on
487
the console. Therefore, you can still use QEMU to debug a Linux kernel
488
with a serial console.
489

    
490
@item -curses
491

    
492
Normally, QEMU uses SDL to display the VGA output.  With this option,
493
QEMU can display the VGA output when in text mode using a 
494
curses/ncurses interface.  Nothing is displayed in graphical mode.
495

    
496
@item -no-frame
497

    
498
Do not use decorations for SDL windows and start them using the whole
499
available screen space. This makes the using QEMU in a dedicated desktop
500
workspace more convenient.
501

    
502
@item -alt-grab
503

    
504
Use Ctrl-Alt-Shift to grab mouse (instead of Ctrl-Alt).
505

    
506
@item -no-quit
507

    
508
Disable SDL window close capability.
509

    
510
@item -sdl
511

    
512
Enable SDL.
513

    
514
@item -portrait
515

    
516
Rotate graphical output 90 deg left (only PXA LCD).
517

    
518
@item -vga @var{type}
519
Select type of VGA card to emulate. Valid values for @var{type} are
520
@table @code
521
@item cirrus
522
Cirrus Logic GD5446 Video card. All Windows versions starting from
523
Windows 95 should recognize and use this graphic card. For optimal
524
performances, use 16 bit color depth in the guest and the host OS.
525
(This one is the default)
526
@item std
527
Standard VGA card with Bochs VBE extensions.  If your guest OS
528
supports the VESA 2.0 VBE extensions (e.g. Windows XP) and if you want
529
to use high resolution modes (>= 1280x1024x16) then you should use
530
this option.
531
@item vmware
532
VMWare SVGA-II compatible adapter. Use it if you have sufficiently
533
recent XFree86/XOrg server or Windows guest with a driver for this
534
card.
535
@item none
536
Disable VGA card.
537
@end table
538

    
539
@item -full-screen
540
Start in full screen.
541

    
542
@item -vnc @var{display}[,@var{option}[,@var{option}[,...]]]
543

    
544
Normally, QEMU uses SDL to display the VGA output.  With this option,
545
you can have QEMU listen on VNC display @var{display} and redirect the VGA
546
display over the VNC session.  It is very useful to enable the usb
547
tablet device when using this option (option @option{-usbdevice
548
tablet}). When using the VNC display, you must use the @option{-k}
549
parameter to set the keyboard layout if you are not using en-us. Valid
550
syntax for the @var{display} is
551

    
552
@table @code
553

    
554
@item @var{host}:@var{d}
555

    
556
TCP connections will only be allowed from @var{host} on display @var{d}.
557
By convention the TCP port is 5900+@var{d}. Optionally, @var{host} can
558
be omitted in which case the server will accept connections from any host.
559

    
560
@item @code{unix}:@var{path}
561

    
562
Connections will be allowed over UNIX domain sockets where @var{path} is the
563
location of a unix socket to listen for connections on.
564

    
565
@item none
566

    
567
VNC is initialized but not started. The monitor @code{change} command
568
can be used to later start the VNC server.
569

    
570
@end table
571

    
572
Following the @var{display} value there may be one or more @var{option} flags
573
separated by commas. Valid options are
574

    
575
@table @code
576

    
577
@item reverse
578

    
579
Connect to a listening VNC client via a ``reverse'' connection. The
580
client is specified by the @var{display}. For reverse network
581
connections (@var{host}:@var{d},@code{reverse}), the @var{d} argument
582
is a TCP port number, not a display number.
583

    
584
@item password
585

    
586
Require that password based authentication is used for client connections.
587
The password must be set separately using the @code{change} command in the
588
@ref{pcsys_monitor}
589

    
590
@item tls
591

    
592
Require that client use TLS when communicating with the VNC server. This
593
uses anonymous TLS credentials so is susceptible to a man-in-the-middle
594
attack. It is recommended that this option be combined with either the
595
@var{x509} or @var{x509verify} options.
596

    
597
@item x509=@var{/path/to/certificate/dir}
598

    
599
Valid if @option{tls} is specified. Require that x509 credentials are used
600
for negotiating the TLS session. The server will send its x509 certificate
601
to the client. It is recommended that a password be set on the VNC server
602
to provide authentication of the client when this is used. The path following
603
this option specifies where the x509 certificates are to be loaded from.
604
See the @ref{vnc_security} section for details on generating certificates.
605

    
606
@item x509verify=@var{/path/to/certificate/dir}
607

    
608
Valid if @option{tls} is specified. Require that x509 credentials are used
609
for negotiating the TLS session. The server will send its x509 certificate
610
to the client, and request that the client send its own x509 certificate.
611
The server will validate the client's certificate against the CA certificate,
612
and reject clients when validation fails. If the certificate authority is
613
trusted, this is a sufficient authentication mechanism. You may still wish
614
to set a password on the VNC server as a second authentication layer. The
615
path following this option specifies where the x509 certificates are to
616
be loaded from. See the @ref{vnc_security} section for details on generating
617
certificates.
618

    
619
@item sasl
620

    
621
Require that the client use SASL to authenticate with the VNC server.
622
The exact choice of authentication method used is controlled from the
623
system / user's SASL configuration file for the 'qemu' service. This
624
is typically found in /etc/sasl2/qemu.conf. If running QEMU as an
625
unprivileged user, an environment variable SASL_CONF_PATH can be used
626
to make it search alternate locations for the service config.
627
While some SASL auth methods can also provide data encryption (eg GSSAPI),
628
it is recommended that SASL always be combined with the 'tls' and
629
'x509' settings to enable use of SSL and server certificates. This
630
ensures a data encryption preventing compromise of authentication
631
credentials. See the @ref{vnc_security} section for details on using
632
SASL authentication.
633

    
634
@item acl
635

    
636
Turn on access control lists for checking of the x509 client certificate
637
and SASL party. For x509 certs, the ACL check is made against the
638
certificate's distinguished name. This is something that looks like
639
@code{C=GB,O=ACME,L=Boston,CN=bob}. For SASL party, the ACL check is
640
made against the username, which depending on the SASL plugin, may
641
include a realm component, eg @code{bob} or @code{bob@@EXAMPLE.COM}.
642
When the @option{acl} flag is set, the initial access list will be
643
empty, with a @code{deny} policy. Thus no one will be allowed to
644
use the VNC server until the ACLs have been loaded. This can be
645
achieved using the @code{acl} monitor command.
646

    
647
@end table
648

    
649
@end table
650

    
651
Network options:
652

    
653
@table @option
654

    
655
@item -net nic[,vlan=@var{n}][,macaddr=@var{addr}][,model=@var{type}][,name=@var{name}]
656
Create a new Network Interface Card and connect it to VLAN @var{n} (@var{n}
657
= 0 is the default). The NIC is an ne2k_pci by default on the PC
658
target. Optionally, the MAC address can be changed to @var{addr}
659
and a @var{name} can be assigned for use in monitor commands. If no
660
@option{-net} option is specified, a single NIC is created.
661
Qemu can emulate several different models of network card.
662
Valid values for @var{type} are
663
@code{i82551}, @code{i82557b}, @code{i82559er},
664
@code{ne2k_pci}, @code{ne2k_isa}, @code{pcnet}, @code{rtl8139},
665
@code{e1000}, @code{smc91c111}, @code{lance} and @code{mcf_fec}.
666
Not all devices are supported on all targets.  Use -net nic,model=?
667
for a list of available devices for your target.
668

    
669
@item -net user[,vlan=@var{n}][,hostname=@var{name}][,name=@var{name}]
670
Use the user mode network stack which requires no administrator
671
privilege to run.  @option{hostname=name} can be used to specify the client
672
hostname reported by the builtin DHCP server.
673

    
674
@item -net channel,@var{port}:@var{dev}
675
Forward @option{user} TCP connection to port @var{port} to character device @var{dev}
676

    
677
@item -net tap[,vlan=@var{n}][,name=@var{name}][,fd=@var{h}][,ifname=@var{name}][,script=@var{file}][,downscript=@var{dfile}]
678
Connect the host TAP network interface @var{name} to VLAN @var{n}, use
679
the network script @var{file} to configure it and the network script 
680
@var{dfile} to deconfigure it. If @var{name} is not provided, the OS 
681
automatically provides one. @option{fd}=@var{h} can be used to specify
682
the handle of an already opened host TAP interface. The default network 
683
configure script is @file{/etc/qemu-ifup} and the default network 
684
deconfigure script is @file{/etc/qemu-ifdown}. Use @option{script=no} 
685
or @option{downscript=no} to disable script execution. Example:
686

    
687
@example
688
qemu linux.img -net nic -net tap
689
@end example
690

    
691
More complicated example (two NICs, each one connected to a TAP device)
692
@example
693
qemu linux.img -net nic,vlan=0 -net tap,vlan=0,ifname=tap0 \
694
               -net nic,vlan=1 -net tap,vlan=1,ifname=tap1
695
@end example
696

    
697

    
698
@item -net socket[,vlan=@var{n}][,name=@var{name}][,fd=@var{h}][,listen=[@var{host}]:@var{port}][,connect=@var{host}:@var{port}]
699

    
700
Connect the VLAN @var{n} to a remote VLAN in another QEMU virtual
701
machine using a TCP socket connection. If @option{listen} is
702
specified, QEMU waits for incoming connections on @var{port}
703
(@var{host} is optional). @option{connect} is used to connect to
704
another QEMU instance using the @option{listen} option. @option{fd}=@var{h}
705
specifies an already opened TCP socket.
706

    
707
Example:
708
@example
709
# launch a first QEMU instance
710
qemu linux.img -net nic,macaddr=52:54:00:12:34:56 \
711
               -net socket,listen=:1234
712
# connect the VLAN 0 of this instance to the VLAN 0
713
# of the first instance
714
qemu linux.img -net nic,macaddr=52:54:00:12:34:57 \
715
               -net socket,connect=127.0.0.1:1234
716
@end example
717

    
718
@item -net socket[,vlan=@var{n}][,name=@var{name}][,fd=@var{h}][,mcast=@var{maddr}:@var{port}]
719

    
720
Create a VLAN @var{n} shared with another QEMU virtual
721
machines using a UDP multicast socket, effectively making a bus for
722
every QEMU with same multicast address @var{maddr} and @var{port}.
723
NOTES:
724
@enumerate
725
@item
726
Several QEMU can be running on different hosts and share same bus (assuming
727
correct multicast setup for these hosts).
728
@item
729
mcast support is compatible with User Mode Linux (argument @option{eth@var{N}=mcast}), see
730
@url{http://user-mode-linux.sf.net}.
731
@item
732
Use @option{fd=h} to specify an already opened UDP multicast socket.
733
@end enumerate
734

    
735
Example:
736
@example
737
# launch one QEMU instance
738
qemu linux.img -net nic,macaddr=52:54:00:12:34:56 \
739
               -net socket,mcast=230.0.0.1:1234
740
# launch another QEMU instance on same "bus"
741
qemu linux.img -net nic,macaddr=52:54:00:12:34:57 \
742
               -net socket,mcast=230.0.0.1:1234
743
# launch yet another QEMU instance on same "bus"
744
qemu linux.img -net nic,macaddr=52:54:00:12:34:58 \
745
               -net socket,mcast=230.0.0.1:1234
746
@end example
747

    
748
Example (User Mode Linux compat.):
749
@example
750
# launch QEMU instance (note mcast address selected
751
# is UML's default)
752
qemu linux.img -net nic,macaddr=52:54:00:12:34:56 \
753
               -net socket,mcast=239.192.168.1:1102
754
# launch UML
755
/path/to/linux ubd0=/path/to/root_fs eth0=mcast
756
@end example
757

    
758
@item -net vde[,vlan=@var{n}][,name=@var{name}][,sock=@var{socketpath}][,port=@var{n}][,group=@var{groupname}][,mode=@var{octalmode}]
759
Connect VLAN @var{n} to PORT @var{n} of a vde switch running on host and
760
listening for incoming connections on @var{socketpath}. Use GROUP @var{groupname}
761
and MODE @var{octalmode} to change default ownership and permissions for
762
communication port. This option is available only if QEMU has been compiled
763
with vde support enabled.
764

    
765
Example:
766
@example
767
# launch vde switch
768
vde_switch -F -sock /tmp/myswitch
769
# launch QEMU instance
770
qemu linux.img -net nic -net vde,sock=/tmp/myswitch
771
@end example
772

    
773
@item -net none
774
Indicate that no network devices should be configured. It is used to
775
override the default configuration (@option{-net nic -net user}) which
776
is activated if no @option{-net} options are provided.
777

    
778
@item -tftp @var{dir}
779
When using the user mode network stack, activate a built-in TFTP
780
server. The files in @var{dir} will be exposed as the root of a TFTP server.
781
The TFTP client on the guest must be configured in binary mode (use the command
782
@code{bin} of the Unix TFTP client). The host IP address on the guest is as
783
usual 10.0.2.2.
784

    
785
@item -bootp @var{file}
786
When using the user mode network stack, broadcast @var{file} as the BOOTP
787
filename.  In conjunction with @option{-tftp}, this can be used to network boot
788
a guest from a local directory.
789

    
790
Example (using pxelinux):
791
@example
792
qemu -hda linux.img -boot n -tftp /path/to/tftp/files -bootp /pxelinux.0
793
@end example
794

    
795
@item -smb @var{dir}
796
When using the user mode network stack, activate a built-in SMB
797
server so that Windows OSes can access to the host files in @file{@var{dir}}
798
transparently.
799

    
800
In the guest Windows OS, the line:
801
@example
802
10.0.2.4 smbserver
803
@end example
804
must be added in the file @file{C:\WINDOWS\LMHOSTS} (for windows 9x/Me)
805
or @file{C:\WINNT\SYSTEM32\DRIVERS\ETC\LMHOSTS} (Windows NT/2000).
806

    
807
Then @file{@var{dir}} can be accessed in @file{\\smbserver\qemu}.
808

    
809
Note that a SAMBA server must be installed on the host OS in
810
@file{/usr/sbin/smbd}. QEMU was tested successfully with smbd version
811
2.2.7a from the Red Hat 9 and version 3.0.10-1.fc3 from Fedora Core 3.
812

    
813
@item -redir [tcp|udp]:@var{host-port}:[@var{guest-host}]:@var{guest-port}
814

    
815
When using the user mode network stack, redirect incoming TCP or UDP
816
connections to the host port @var{host-port} to the guest
817
@var{guest-host} on guest port @var{guest-port}. If @var{guest-host}
818
is not specified, its value is 10.0.2.15 (default address given by the
819
built-in DHCP server).
820

    
821
For example, to redirect host X11 connection from screen 1 to guest
822
screen 0, use the following:
823

    
824
@example
825
# on the host
826
qemu -redir tcp:6001::6000 [...]
827
# this host xterm should open in the guest X11 server
828
xterm -display :1
829
@end example
830

    
831
To redirect telnet connections from host port 5555 to telnet port on
832
the guest, use the following:
833

    
834
@example
835
# on the host
836
qemu -redir tcp:5555::23 [...]
837
telnet localhost 5555
838
@end example
839

    
840
Then when you use on the host @code{telnet localhost 5555}, you
841
connect to the guest telnet server.
842

    
843
@end table
844

    
845
Bluetooth(R) options:
846
@table @option
847

    
848
@item -bt hci[...]
849
Defines the function of the corresponding Bluetooth HCI.  -bt options
850
are matched with the HCIs present in the chosen machine type.  For
851
example when emulating a machine with only one HCI built into it, only
852
the first @code{-bt hci[...]} option is valid and defines the HCI's
853
logic.  The Transport Layer is decided by the machine type.  Currently
854
the machines @code{n800} and @code{n810} have one HCI and all other
855
machines have none.
856

    
857
@anchor{bt-hcis}
858
The following three types are recognized:
859

    
860
@table @code
861
@item -bt hci,null
862
(default) The corresponding Bluetooth HCI assumes no internal logic
863
and will not respond to any HCI commands or emit events.
864

    
865
@item -bt hci,host[:@var{id}]
866
(@code{bluez} only) The corresponding HCI passes commands / events
867
to / from the physical HCI identified by the name @var{id} (default:
868
@code{hci0}) on the computer running QEMU.  Only available on @code{bluez}
869
capable systems like Linux.
870

    
871
@item -bt hci[,vlan=@var{n}]
872
Add a virtual, standard HCI that will participate in the Bluetooth
873
scatternet @var{n} (default @code{0}).  Similarly to @option{-net}
874
VLANs, devices inside a bluetooth network @var{n} can only communicate
875
with other devices in the same network (scatternet).
876
@end table
877

    
878
@item -bt vhci[,vlan=@var{n}]
879
(Linux-host only) Create a HCI in scatternet @var{n} (default 0) attached
880
to the host bluetooth stack instead of to the emulated target.  This
881
allows the host and target machines to participate in a common scatternet
882
and communicate.  Requires the Linux @code{vhci} driver installed.  Can
883
be used as following:
884

    
885
@example
886
qemu [...OPTIONS...] -bt hci,vlan=5 -bt vhci,vlan=5
887
@end example
888

    
889
@item -bt device:@var{dev}[,vlan=@var{n}]
890
Emulate a bluetooth device @var{dev} and place it in network @var{n}
891
(default @code{0}).  QEMU can only emulate one type of bluetooth devices
892
currently:
893

    
894
@table @code
895
@item keyboard
896
Virtual wireless keyboard implementing the HIDP bluetooth profile.
897
@end table
898

    
899
@end table
900

    
901
i386 target only:
902

    
903
@table @option
904

    
905
@item -win2k-hack
906
Use it when installing Windows 2000 to avoid a disk full bug. After
907
Windows 2000 is installed, you no longer need this option (this option
908
slows down the IDE transfers).
909

    
910
@item -rtc-td-hack
911
Use it if you experience time drift problem in Windows with ACPI HAL.
912
This option will try to figure out how many timer interrupts were not
913
processed by the Windows guest and will re-inject them.
914

    
915
@item -no-fd-bootchk
916
Disable boot signature checking for floppy disks in Bochs BIOS. It may
917
be needed to boot from old floppy disks.
918

    
919
@item -no-acpi
920
Disable ACPI (Advanced Configuration and Power Interface) support. Use
921
it if your guest OS complains about ACPI problems (PC target machine
922
only).
923

    
924
@item -no-hpet
925
Disable HPET support.
926

    
927
@item -acpitable [sig=@var{str}][,rev=@var{n}][,oem_id=@var{str}][,oem_table_id=@var{str}][,oem_rev=@var{n}] [,asl_compiler_id=@var{str}][,asl_compiler_rev=@var{n}][,data=@var{file1}[:@var{file2}]...]
928
Add ACPI table with specified header fields and context from specified files.
929

    
930
@end table
931

    
932
Linux boot specific: When using these options, you can use a given
933
Linux kernel without installing it in the disk image. It can be useful
934
for easier testing of various kernels.
935

    
936
@table @option
937

    
938
@item -kernel @var{bzImage}
939
Use @var{bzImage} as kernel image.
940

    
941
@item -append @var{cmdline}
942
Use @var{cmdline} as kernel command line
943

    
944
@item -initrd @var{file}
945
Use @var{file} as initial ram disk.
946

    
947
@end table
948

    
949
Debug/Expert options:
950
@table @option
951

    
952
@item -serial @var{dev}
953
Redirect the virtual serial port to host character device
954
@var{dev}. The default device is @code{vc} in graphical mode and
955
@code{stdio} in non graphical mode.
956

    
957
This option can be used several times to simulate up to 4 serial
958
ports.
959

    
960
Use @code{-serial none} to disable all serial ports.
961

    
962
Available character devices are:
963
@table @code
964
@item vc[:WxH]
965
Virtual console. Optionally, a width and height can be given in pixel with
966
@example
967
vc:800x600
968
@end example
969
It is also possible to specify width or height in characters:
970
@example
971
vc:80Cx24C
972
@end example
973
@item pty
974
[Linux only] Pseudo TTY (a new PTY is automatically allocated)
975
@item none
976
No device is allocated.
977
@item null
978
void device
979
@item /dev/XXX
980
[Linux only] Use host tty, e.g. @file{/dev/ttyS0}. The host serial port
981
parameters are set according to the emulated ones.
982
@item /dev/parport@var{N}
983
[Linux only, parallel port only] Use host parallel port
984
@var{N}. Currently SPP and EPP parallel port features can be used.
985
@item file:@var{filename}
986
Write output to @var{filename}. No character can be read.
987
@item stdio
988
[Unix only] standard input/output
989
@item pipe:@var{filename}
990
name pipe @var{filename}
991
@item COM@var{n}
992
[Windows only] Use host serial port @var{n}
993
@item udp:[@var{remote_host}]:@var{remote_port}[@@[@var{src_ip}]:@var{src_port}]
994
This implements UDP Net Console.
995
When @var{remote_host} or @var{src_ip} are not specified
996
they default to @code{0.0.0.0}.
997
When not using a specified @var{src_port} a random port is automatically chosen.
998
@item msmouse
999
Three button serial mouse. Configure the guest to use Microsoft protocol.
1000

    
1001
If you just want a simple readonly console you can use @code{netcat} or
1002
@code{nc}, by starting qemu with: @code{-serial udp::4555} and nc as:
1003
@code{nc -u -l -p 4555}. Any time qemu writes something to that port it
1004
will appear in the netconsole session.
1005

    
1006
If you plan to send characters back via netconsole or you want to stop
1007
and start qemu a lot of times, you should have qemu use the same
1008
source port each time by using something like @code{-serial
1009
udp::4555@@:4556} to qemu. Another approach is to use a patched
1010
version of netcat which can listen to a TCP port and send and receive
1011
characters via udp.  If you have a patched version of netcat which
1012
activates telnet remote echo and single char transfer, then you can
1013
use the following options to step up a netcat redirector to allow
1014
telnet on port 5555 to access the qemu port.
1015
@table @code
1016
@item Qemu Options:
1017
-serial udp::4555@@:4556
1018
@item netcat options:
1019
-u -P 4555 -L 0.0.0.0:4556 -t -p 5555 -I -T
1020
@item telnet options:
1021
localhost 5555
1022
@end table
1023

    
1024

    
1025
@item tcp:[@var{host}]:@var{port}[,@var{server}][,nowait][,nodelay]
1026
The TCP Net Console has two modes of operation.  It can send the serial
1027
I/O to a location or wait for a connection from a location.  By default
1028
the TCP Net Console is sent to @var{host} at the @var{port}.  If you use
1029
the @var{server} option QEMU will wait for a client socket application
1030
to connect to the port before continuing, unless the @code{nowait}
1031
option was specified.  The @code{nodelay} option disables the Nagle buffering
1032
algorithm.  If @var{host} is omitted, 0.0.0.0 is assumed. Only
1033
one TCP connection at a time is accepted. You can use @code{telnet} to
1034
connect to the corresponding character device.
1035
@table @code
1036
@item Example to send tcp console to 192.168.0.2 port 4444
1037
-serial tcp:192.168.0.2:4444
1038
@item Example to listen and wait on port 4444 for connection
1039
-serial tcp::4444,server
1040
@item Example to not wait and listen on ip 192.168.0.100 port 4444
1041
-serial tcp:192.168.0.100:4444,server,nowait
1042
@end table
1043

    
1044
@item telnet:@var{host}:@var{port}[,server][,nowait][,nodelay]
1045
The telnet protocol is used instead of raw tcp sockets.  The options
1046
work the same as if you had specified @code{-serial tcp}.  The
1047
difference is that the port acts like a telnet server or client using
1048
telnet option negotiation.  This will also allow you to send the
1049
MAGIC_SYSRQ sequence if you use a telnet that supports sending the break
1050
sequence.  Typically in unix telnet you do it with Control-] and then
1051
type "send break" followed by pressing the enter key.
1052

    
1053
@item unix:@var{path}[,server][,nowait]
1054
A unix domain socket is used instead of a tcp socket.  The option works the
1055
same as if you had specified @code{-serial tcp} except the unix domain socket
1056
@var{path} is used for connections.
1057

    
1058
@item mon:@var{dev_string}
1059
This is a special option to allow the monitor to be multiplexed onto
1060
another serial port.  The monitor is accessed with key sequence of
1061
@key{Control-a} and then pressing @key{c}. See monitor access
1062
@ref{pcsys_keys} in the -nographic section for more keys.
1063
@var{dev_string} should be any one of the serial devices specified
1064
above.  An example to multiplex the monitor onto a telnet server
1065
listening on port 4444 would be:
1066
@table @code
1067
@item -serial mon:telnet::4444,server,nowait
1068
@end table
1069

    
1070
@item braille
1071
Braille device.  This will use BrlAPI to display the braille output on a real
1072
or fake device.
1073

    
1074
@end table
1075

    
1076
@item -parallel @var{dev}
1077
Redirect the virtual parallel port to host device @var{dev} (same
1078
devices as the serial port). On Linux hosts, @file{/dev/parportN} can
1079
be used to use hardware devices connected on the corresponding host
1080
parallel port.
1081

    
1082
This option can be used several times to simulate up to 3 parallel
1083
ports.
1084

    
1085
Use @code{-parallel none} to disable all parallel ports.
1086

    
1087
@item -monitor @var{dev}
1088
Redirect the monitor to host device @var{dev} (same devices as the
1089
serial port).
1090
The default device is @code{vc} in graphical mode and @code{stdio} in
1091
non graphical mode.
1092

    
1093
@item -pidfile @var{file}
1094
Store the QEMU process PID in @var{file}. It is useful if you launch QEMU
1095
from a script.
1096

    
1097
@item -S
1098
Do not start CPU at startup (you must type 'c' in the monitor).
1099

    
1100
@item -s
1101
Wait gdb connection to port 1234 (@pxref{gdb_usage}).
1102

    
1103
@item -p @var{port}
1104
Change gdb connection port.  @var{port} can be either a decimal number
1105
to specify a TCP port, or a host device (same devices as the serial port).
1106

    
1107
@item -d
1108
Output log in /tmp/qemu.log
1109
@item -hdachs @var{c},@var{h},@var{s},[,@var{t}]
1110
Force hard disk 0 physical geometry (1 <= @var{c} <= 16383, 1 <=
1111
@var{h} <= 16, 1 <= @var{s} <= 63) and optionally force the BIOS
1112
translation mode (@var{t}=none, lba or auto). Usually QEMU can guess
1113
all those parameters. This option is useful for old MS-DOS disk
1114
images.
1115

    
1116
@item -L  @var{path}
1117
Set the directory for the BIOS, VGA BIOS and keymaps.
1118

    
1119
@item -bios @var{file}
1120
Set the filename for the BIOS.
1121

    
1122
@item -kernel-kqemu
1123
Enable KQEMU full virtualization (default is user mode only).
1124

    
1125
@item -no-kqemu
1126
Disable KQEMU kernel module usage. KQEMU options are only available if
1127
KQEMU support is enabled when compiling.
1128

    
1129
@item -enable-kvm
1130
Enable KVM full virtualization support. This option is only available
1131
if KVM support is enabled when compiling.
1132

    
1133
@item -no-reboot
1134
Exit instead of rebooting.
1135

    
1136
@item -no-shutdown
1137
Don't exit QEMU on guest shutdown, but instead only stop the emulation.
1138
This allows for instance switching to monitor to commit changes to the
1139
disk image.
1140

    
1141
@item -loadvm @var{file}
1142
Start right away with a saved state (@code{loadvm} in monitor)
1143

    
1144
@item -daemonize
1145
Daemonize the QEMU process after initialization.  QEMU will not detach from
1146
standard IO until it is ready to receive connections on any of its devices.
1147
This option is a useful way for external programs to launch QEMU without having
1148
to cope with initialization race conditions.
1149

    
1150
@item -option-rom @var{file}
1151
Load the contents of @var{file} as an option ROM.
1152
This option is useful to load things like EtherBoot.
1153

    
1154
@item -clock @var{method}
1155
Force the use of the given methods for timer alarm. To see what timers
1156
are available use -clock ?.
1157

    
1158
@item -localtime
1159
Set the real time clock to local time (the default is to UTC
1160
time). This option is needed to have correct date in MS-DOS or
1161
Windows.
1162

    
1163
@item -startdate @var{date}
1164
Set the initial date of the real time clock. Valid formats for
1165
@var{date} are: @code{now} or @code{2006-06-17T16:01:21} or
1166
@code{2006-06-17}. The default value is @code{now}.
1167

    
1168
@item -icount [N|auto]
1169
Enable virtual instruction counter.  The virtual cpu will execute one
1170
instruction every 2^N ns of virtual time.  If @code{auto} is specified
1171
then the virtual cpu speed will be automatically adjusted to keep virtual
1172
time within a few seconds of real time.
1173

    
1174
Note that while this option can give deterministic behavior, it does not
1175
provide cycle accurate emulation.  Modern CPUs contain superscalar out of
1176
order cores with complex cache hierarchies.  The number of instructions
1177
executed often has little or no correlation with actual performance.
1178

    
1179
@item -echr numeric_ascii_value
1180
Change the escape character used for switching to the monitor when using
1181
monitor and serial sharing.  The default is @code{0x01} when using the
1182
@code{-nographic} option.  @code{0x01} is equal to pressing
1183
@code{Control-a}.  You can select a different character from the ascii
1184
control keys where 1 through 26 map to Control-a through Control-z.  For
1185
instance you could use the either of the following to change the escape
1186
character to Control-t.
1187
@table @code
1188
@item -echr 0x14
1189
@item -echr 20
1190
@end table
1191

    
1192
@item -chroot dir
1193
Immediately before starting guest execution, chroot to the specified
1194
directory.  Especially useful in combination with -runas.
1195

    
1196
@item -runas user
1197
Immediately before starting guest execution, drop root privileges, switching
1198
to the specified user.
1199

    
1200
@end table
1201

    
1202
@c man end
1203

    
1204
@node pcsys_keys
1205
@section Keys
1206

    
1207
@c man begin OPTIONS
1208

    
1209
During the graphical emulation, you can use the following keys:
1210
@table @key
1211
@item Ctrl-Alt-f
1212
Toggle full screen
1213

    
1214
@item Ctrl-Alt-n
1215
Switch to virtual console 'n'. Standard console mappings are:
1216
@table @emph
1217
@item 1
1218
Target system display
1219
@item 2
1220
Monitor
1221
@item 3
1222
Serial port
1223
@end table
1224

    
1225
@item Ctrl-Alt
1226
Toggle mouse and keyboard grab.
1227
@end table
1228

    
1229
In the virtual consoles, you can use @key{Ctrl-Up}, @key{Ctrl-Down},
1230
@key{Ctrl-PageUp} and @key{Ctrl-PageDown} to move in the back log.
1231

    
1232
During emulation, if you are using the @option{-nographic} option, use
1233
@key{Ctrl-a h} to get terminal commands:
1234

    
1235
@table @key
1236
@item Ctrl-a h
1237
@item Ctrl-a ?
1238
Print this help
1239
@item Ctrl-a x
1240
Exit emulator
1241
@item Ctrl-a s
1242
Save disk data back to file (if -snapshot)
1243
@item Ctrl-a t
1244
Toggle console timestamps
1245
@item Ctrl-a b
1246
Send break (magic sysrq in Linux)
1247
@item Ctrl-a c
1248
Switch between console and monitor
1249
@item Ctrl-a Ctrl-a
1250
Send Ctrl-a
1251
@end table
1252
@c man end
1253

    
1254
@ignore
1255

    
1256
@c man begin SEEALSO
1257
The HTML documentation of QEMU for more precise information and Linux
1258
user mode emulator invocation.
1259
@c man end
1260

    
1261
@c man begin AUTHOR
1262
Fabrice Bellard
1263
@c man end
1264

    
1265
@end ignore
1266

    
1267
@node pcsys_monitor
1268
@section QEMU Monitor
1269

    
1270
The QEMU monitor is used to give complex commands to the QEMU
1271
emulator. You can use it to:
1272

    
1273
@itemize @minus
1274

    
1275
@item
1276
Remove or insert removable media images
1277
(such as CD-ROM or floppies).
1278

    
1279
@item
1280
Freeze/unfreeze the Virtual Machine (VM) and save or restore its state
1281
from a disk file.
1282

    
1283
@item Inspect the VM state without an external debugger.
1284

    
1285
@end itemize
1286

    
1287
@subsection Commands
1288

    
1289
The following commands are available:
1290

    
1291
@table @option
1292

    
1293
@item help or ? [@var{cmd}]
1294
Show the help for all commands or just for command @var{cmd}.
1295

    
1296
@item commit
1297
Commit changes to the disk images (if -snapshot is used).
1298

    
1299
@item info @var{subcommand}
1300
Show various information about the system state.
1301

    
1302
@table @option
1303
@item info version
1304
show the version of QEMU
1305
@item info network
1306
show the various VLANs and the associated devices
1307
@item info chardev
1308
show the character devices
1309
@item info block
1310
show the block devices
1311
@item info block
1312
show block device statistics
1313
@item info registers
1314
show the cpu registers
1315
@item info cpus
1316
show infos for each CPU
1317
@item info history
1318
show the command line history
1319
@item info irq
1320
show the interrupts statistics (if available)
1321
@item info pic
1322
show i8259 (PIC) state
1323
@item info pci
1324
show emulated PCI device info
1325
@item info tlb
1326
show virtual to physical memory mappings (i386 only)
1327
@item info mem
1328
show the active virtual memory mappings (i386 only)
1329
@item info hpet
1330
show state of HPET (i386 only)
1331
@item info kqemu
1332
show KQEMU information
1333
@item info kvm
1334
show KVM information
1335
@item info usb
1336
show USB devices plugged on the virtual USB hub
1337
@item info usbhost
1338
show all USB host devices
1339
@item info profile
1340
show profiling information
1341
@item info capture
1342
show information about active capturing
1343
@item info snapshots
1344
show list of VM snapshots
1345
@item info status
1346
show the current VM status (running|paused)
1347
@item info pcmcia
1348
show guest PCMCIA status
1349
@item info mice
1350
show which guest mouse is receiving events
1351
@item info vnc
1352
show the vnc server status
1353
@item info name
1354
show the current VM name
1355
@item info uuid
1356
show the current VM UUID
1357
@item info cpustats
1358
show CPU statistics
1359
@item info slirp
1360
show SLIRP statistics (if available)
1361
@item info migrate
1362
show migration status
1363
@item info balloon
1364
show balloon information
1365
@end table
1366

    
1367
@item q or quit
1368
Quit the emulator.
1369

    
1370
@item eject [-f] @var{device}
1371
Eject a removable medium (use -f to force it).
1372

    
1373
@item change @var{device} @var{setting}
1374

    
1375
Change the configuration of a device.
1376

    
1377
@table @option
1378
@item change @var{diskdevice} @var{filename} [@var{format}]
1379
Change the medium for a removable disk device to point to @var{filename}. eg
1380

    
1381
@example
1382
(qemu) change ide1-cd0 /path/to/some.iso
1383
@end example
1384

    
1385
@var{format} is optional.
1386

    
1387
@item change vnc @var{display},@var{options}
1388
Change the configuration of the VNC server. The valid syntax for @var{display}
1389
and @var{options} are described at @ref{sec_invocation}. eg
1390

    
1391
@example
1392
(qemu) change vnc localhost:1
1393
@end example
1394

    
1395
@item change vnc password [@var{password}]
1396

    
1397
Change the password associated with the VNC server. If the new password is not
1398
supplied, the monitor will prompt for it to be entered. VNC passwords are only
1399
significant up to 8 letters. eg
1400

    
1401
@example
1402
(qemu) change vnc password
1403
Password: ********
1404
@end example
1405

    
1406
@end table
1407

    
1408
@item acl @var{subcommand} @var{aclname} @var{match} @var{index}
1409

    
1410
Manage access control lists for network services. There are currently
1411
two named access control lists, @var{vnc.x509dname} and @var{vnc.username}
1412
matching on the x509 client certificate distinguished name, and SASL
1413
username respectively.
1414

    
1415
@table @option
1416
@item acl show <aclname>
1417
list all the match rules in the access control list, and the default
1418
policy
1419
@item acl policy <aclname> @code{allow|deny}
1420
set the default access control list policy, used in the event that
1421
none of the explicit rules match. The default policy at startup is
1422
always @code{deny}
1423
@item acl allow <aclname> <match> [<index>]
1424
add a match to the access control list, allowing access. The match will
1425
normally be an exact username or x509 distinguished name, but can
1426
optionally include wildcard globs. eg @code{*@@EXAMPLE.COM} to allow
1427
all users in the @code{EXAMPLE.COM} kerberos realm. The match will
1428
normally be appended to the end of the ACL, but can be inserted
1429
earlier in the list if the optional @code{index} parameter is supplied.
1430
@item acl deny <aclname> <match> [<index>]
1431
add a match to the access control list, denying access. The match will
1432
normally be an exact username or x509 distinguished name, but can
1433
optionally include wildcard globs. eg @code{*@@EXAMPLE.COM} to allow
1434
all users in the @code{EXAMPLE.COM} kerberos realm. The match will
1435
normally be appended to the end of the ACL, but can be inserted
1436
earlier in the list if the optional @code{index} parameter is supplied.
1437
@item acl remove <aclname> <match>
1438
remove the specified match rule from the access control list.
1439
@item acl reset <aclname>
1440
remove all matches from the access control list, and set the default
1441
policy back to @code{deny}.
1442
@end table
1443

    
1444
@item screendump @var{filename}
1445
Save screen into PPM image @var{filename}.
1446

    
1447
@item logfile @var{filename}
1448
Output logs to @var{filename}.
1449

    
1450
@item log @var{item1}[,...]
1451
Activate logging of the specified items to @file{/tmp/qemu.log}.
1452

    
1453
@item savevm [@var{tag}|@var{id}]
1454
Create a snapshot of the whole virtual machine. If @var{tag} is
1455
provided, it is used as human readable identifier. If there is already
1456
a snapshot with the same tag or ID, it is replaced. More info at
1457
@ref{vm_snapshots}.
1458

    
1459
@item loadvm @var{tag}|@var{id}
1460
Set the whole virtual machine to the snapshot identified by the tag
1461
@var{tag} or the unique snapshot ID @var{id}.
1462

    
1463
@item delvm @var{tag}|@var{id}
1464
Delete the snapshot identified by @var{tag} or @var{id}.
1465

    
1466
@item stop
1467
Stop emulation.
1468

    
1469
@item c or cont
1470
Resume emulation.
1471

    
1472
@item gdbserver [@var{port}]
1473
Start gdbserver session (default @var{port}=1234)
1474

    
1475
@item x/fmt @var{addr}
1476
Virtual memory dump starting at @var{addr}.
1477

    
1478
@item xp /@var{fmt} @var{addr}
1479
Physical memory dump starting at @var{addr}.
1480

    
1481
@var{fmt} is a format which tells the command how to format the
1482
data. Its syntax is: @option{/@{count@}@{format@}@{size@}}
1483

    
1484
@table @var
1485
@item count
1486
is the number of items to be dumped.
1487

    
1488
@item format
1489
can be x (hex), d (signed decimal), u (unsigned decimal), o (octal),
1490
c (char) or i (asm instruction).
1491

    
1492
@item size
1493
can be b (8 bits), h (16 bits), w (32 bits) or g (64 bits). On x86,
1494
@code{h} or @code{w} can be specified with the @code{i} format to
1495
respectively select 16 or 32 bit code instruction size.
1496

    
1497
@end table
1498

    
1499
Examples:
1500
@itemize
1501
@item
1502
Dump 10 instructions at the current instruction pointer:
1503
@example
1504
(qemu) x/10i $eip
1505
0x90107063:  ret
1506
0x90107064:  sti
1507
0x90107065:  lea    0x0(%esi,1),%esi
1508
0x90107069:  lea    0x0(%edi,1),%edi
1509
0x90107070:  ret
1510
0x90107071:  jmp    0x90107080
1511
0x90107073:  nop
1512
0x90107074:  nop
1513
0x90107075:  nop
1514
0x90107076:  nop
1515
@end example
1516

    
1517
@item
1518
Dump 80 16 bit values at the start of the video memory.
1519
@smallexample
1520
(qemu) xp/80hx 0xb8000
1521
0x000b8000: 0x0b50 0x0b6c 0x0b65 0x0b78 0x0b38 0x0b36 0x0b2f 0x0b42
1522
0x000b8010: 0x0b6f 0x0b63 0x0b68 0x0b73 0x0b20 0x0b56 0x0b47 0x0b41
1523
0x000b8020: 0x0b42 0x0b69 0x0b6f 0x0b73 0x0b20 0x0b63 0x0b75 0x0b72
1524
0x000b8030: 0x0b72 0x0b65 0x0b6e 0x0b74 0x0b2d 0x0b63 0x0b76 0x0b73
1525
0x000b8040: 0x0b20 0x0b30 0x0b35 0x0b20 0x0b4e 0x0b6f 0x0b76 0x0b20
1526
0x000b8050: 0x0b32 0x0b30 0x0b30 0x0b33 0x0720 0x0720 0x0720 0x0720
1527
0x000b8060: 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720
1528
0x000b8070: 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720
1529
0x000b8080: 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720
1530
0x000b8090: 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720
1531
@end smallexample
1532
@end itemize
1533

    
1534
@item p or print/@var{fmt} @var{expr}
1535

    
1536
Print expression value. Only the @var{format} part of @var{fmt} is
1537
used.
1538

    
1539
@item sendkey @var{keys}
1540

    
1541
Send @var{keys} to the emulator. @var{keys} could be the name of the
1542
key or @code{#} followed by the raw value in either decimal or hexadecimal
1543
format. Use @code{-} to press several keys simultaneously. Example:
1544
@example
1545
sendkey ctrl-alt-f1
1546
@end example
1547

    
1548
This command is useful to send keys that your graphical user interface
1549
intercepts at low level, such as @code{ctrl-alt-f1} in X Window.
1550

    
1551
@item system_reset
1552

    
1553
Reset the system.
1554

    
1555
@item system_powerdown
1556

    
1557
Power down the system (if supported).
1558

    
1559
@item sum @var{addr} @var{size}
1560

    
1561
Compute the checksum of a memory region.
1562

    
1563
@item usb_add @var{devname}
1564

    
1565
Add the USB device @var{devname}.  For details of available devices see
1566
@ref{usb_devices}
1567

    
1568
@item usb_del @var{devname}
1569

    
1570
Remove the USB device @var{devname} from the QEMU virtual USB
1571
hub. @var{devname} has the syntax @code{bus.addr}. Use the monitor
1572
command @code{info usb} to see the devices you can remove.
1573

    
1574
@item mouse_move @var{dx} @var{dy} [@var{dz}]
1575
Move the active mouse to the specified coordinates @var{dx} @var{dy}
1576
with optional scroll axis @var{dz}.
1577

    
1578
@item mouse_button @var{val}
1579
Change the active mouse button state @var{val} (1=L, 2=M, 4=R).
1580

    
1581
@item mouse_set @var{index}
1582
Set which mouse device receives events at given @var{index}, index
1583
can be obtained with
1584
@example
1585
info mice
1586
@end example
1587

    
1588
@item wavcapture @var{filename} [@var{frequency} [@var{bits} [@var{channels}]]]
1589
Capture audio into @var{filename}. Using sample rate @var{frequency}
1590
bits per sample @var{bits} and number of channels @var{channels}.
1591

    
1592
Defaults:
1593
@itemize @minus
1594
@item Sample rate = 44100 Hz - CD quality
1595
@item Bits = 16
1596
@item Number of channels = 2 - Stereo
1597
@end itemize
1598

    
1599
@item stopcapture @var{index}
1600
Stop capture with a given @var{index}, index can be obtained with
1601
@example
1602
info capture
1603
@end example
1604

    
1605
@item memsave @var{addr} @var{size} @var{file}
1606
save to disk virtual memory dump starting at @var{addr} of size @var{size}.
1607

    
1608
@item pmemsave @var{addr} @var{size} @var{file}
1609
save to disk physical memory dump starting at @var{addr} of size @var{size}.
1610

    
1611
@item boot_set @var{bootdevicelist}
1612

    
1613
Define new values for the boot device list. Those values will override
1614
the values specified on the command line through the @code{-boot} option.
1615

    
1616
The values that can be specified here depend on the machine type, but are
1617
the same that can be specified in the @code{-boot} command line option.
1618

    
1619
@item nmi @var{cpu}
1620
Inject an NMI on the given CPU.
1621

    
1622
@item migrate [-d] @var{uri}
1623
Migrate to @var{uri} (using -d to not wait for completion).
1624

    
1625
@item migrate_cancel
1626
Cancel the current VM migration.
1627

    
1628
@item migrate_set_speed @var{value}
1629
Set maximum speed to @var{value} (in bytes) for migrations.
1630

    
1631
@item balloon @var{value}
1632
Request VM to change its memory allocation to @var{value} (in MB).
1633

    
1634
@item set_link @var{name} [up|down]
1635
Set link @var{name} up or down.
1636

    
1637
@end table
1638

    
1639
@subsection Integer expressions
1640

    
1641
The monitor understands integers expressions for every integer
1642
argument. You can use register names to get the value of specifics
1643
CPU registers by prefixing them with @emph{$}.
1644

    
1645
@node disk_images
1646
@section Disk Images
1647

    
1648
Since version 0.6.1, QEMU supports many disk image formats, including
1649
growable disk images (their size increase as non empty sectors are
1650
written), compressed and encrypted disk images. Version 0.8.3 added
1651
the new qcow2 disk image format which is essential to support VM
1652
snapshots.
1653

    
1654
@menu
1655
* disk_images_quickstart::    Quick start for disk image creation
1656
* disk_images_snapshot_mode:: Snapshot mode
1657
* vm_snapshots::              VM snapshots
1658
* qemu_img_invocation::       qemu-img Invocation
1659
* qemu_nbd_invocation::       qemu-nbd Invocation
1660
* host_drives::               Using host drives
1661
* disk_images_fat_images::    Virtual FAT disk images
1662
* disk_images_nbd::           NBD access
1663
@end menu
1664

    
1665
@node disk_images_quickstart
1666
@subsection Quick start for disk image creation
1667

    
1668
You can create a disk image with the command:
1669
@example
1670
qemu-img create myimage.img mysize
1671
@end example
1672
where @var{myimage.img} is the disk image filename and @var{mysize} is its
1673
size in kilobytes. You can add an @code{M} suffix to give the size in
1674
megabytes and a @code{G} suffix for gigabytes.
1675

    
1676
See @ref{qemu_img_invocation} for more information.
1677

    
1678
@node disk_images_snapshot_mode
1679
@subsection Snapshot mode
1680

    
1681
If you use the option @option{-snapshot}, all disk images are
1682
considered as read only. When sectors in written, they are written in
1683
a temporary file created in @file{/tmp}. You can however force the
1684
write back to the raw disk images by using the @code{commit} monitor
1685
command (or @key{C-a s} in the serial console).
1686

    
1687
@node vm_snapshots
1688
@subsection VM snapshots
1689

    
1690
VM snapshots are snapshots of the complete virtual machine including
1691
CPU state, RAM, device state and the content of all the writable
1692
disks. In order to use VM snapshots, you must have at least one non
1693
removable and writable block device using the @code{qcow2} disk image
1694
format. Normally this device is the first virtual hard drive.
1695

    
1696
Use the monitor command @code{savevm} to create a new VM snapshot or
1697
replace an existing one. A human readable name can be assigned to each
1698
snapshot in addition to its numerical ID.
1699

    
1700
Use @code{loadvm} to restore a VM snapshot and @code{delvm} to remove
1701
a VM snapshot. @code{info snapshots} lists the available snapshots
1702
with their associated information:
1703

    
1704
@example
1705
(qemu) info snapshots
1706
Snapshot devices: hda
1707
Snapshot list (from hda):
1708
ID        TAG                 VM SIZE                DATE       VM CLOCK
1709
1         start                   41M 2006-08-06 12:38:02   00:00:14.954
1710
2                                 40M 2006-08-06 12:43:29   00:00:18.633
1711
3         msys                    40M 2006-08-06 12:44:04   00:00:23.514
1712
@end example
1713

    
1714
A VM snapshot is made of a VM state info (its size is shown in
1715
@code{info snapshots}) and a snapshot of every writable disk image.
1716
The VM state info is stored in the first @code{qcow2} non removable
1717
and writable block device. The disk image snapshots are stored in
1718
every disk image. The size of a snapshot in a disk image is difficult
1719
to evaluate and is not shown by @code{info snapshots} because the
1720
associated disk sectors are shared among all the snapshots to save
1721
disk space (otherwise each snapshot would need a full copy of all the
1722
disk images).
1723

    
1724
When using the (unrelated) @code{-snapshot} option
1725
(@ref{disk_images_snapshot_mode}), you can always make VM snapshots,
1726
but they are deleted as soon as you exit QEMU.
1727

    
1728
VM snapshots currently have the following known limitations:
1729
@itemize
1730
@item
1731
They cannot cope with removable devices if they are removed or
1732
inserted after a snapshot is done.
1733
@item
1734
A few device drivers still have incomplete snapshot support so their
1735
state is not saved or restored properly (in particular USB).
1736
@end itemize
1737

    
1738
@node qemu_img_invocation
1739
@subsection @code{qemu-img} Invocation
1740

    
1741
@include qemu-img.texi
1742

    
1743
@node qemu_nbd_invocation
1744
@subsection @code{qemu-nbd} Invocation
1745

    
1746
@include qemu-nbd.texi
1747

    
1748
@node host_drives
1749
@subsection Using host drives
1750

    
1751
In addition to disk image files, QEMU can directly access host
1752
devices. We describe here the usage for QEMU version >= 0.8.3.
1753

    
1754
@subsubsection Linux
1755

    
1756
On Linux, you can directly use the host device filename instead of a
1757
disk image filename provided you have enough privileges to access
1758
it. For example, use @file{/dev/cdrom} to access to the CDROM or
1759
@file{/dev/fd0} for the floppy.
1760

    
1761
@table @code
1762
@item CD
1763
You can specify a CDROM device even if no CDROM is loaded. QEMU has
1764
specific code to detect CDROM insertion or removal. CDROM ejection by
1765
the guest OS is supported. Currently only data CDs are supported.
1766
@item Floppy
1767
You can specify a floppy device even if no floppy is loaded. Floppy
1768
removal is currently not detected accurately (if you change floppy
1769
without doing floppy access while the floppy is not loaded, the guest
1770
OS will think that the same floppy is loaded).
1771
@item Hard disks
1772
Hard disks can be used. Normally you must specify the whole disk
1773
(@file{/dev/hdb} instead of @file{/dev/hdb1}) so that the guest OS can
1774
see it as a partitioned disk. WARNING: unless you know what you do, it
1775
is better to only make READ-ONLY accesses to the hard disk otherwise
1776
you may corrupt your host data (use the @option{-snapshot} command
1777
line option or modify the device permissions accordingly).
1778
@end table
1779

    
1780
@subsubsection Windows
1781

    
1782
@table @code
1783
@item CD
1784
The preferred syntax is the drive letter (e.g. @file{d:}). The
1785
alternate syntax @file{\\.\d:} is supported. @file{/dev/cdrom} is
1786
supported as an alias to the first CDROM drive.
1787

    
1788
Currently there is no specific code to handle removable media, so it
1789
is better to use the @code{change} or @code{eject} monitor commands to
1790
change or eject media.
1791
@item Hard disks
1792
Hard disks can be used with the syntax: @file{\\.\PhysicalDrive@var{N}}
1793
where @var{N} is the drive number (0 is the first hard disk).
1794

    
1795
WARNING: unless you know what you do, it is better to only make
1796
READ-ONLY accesses to the hard disk otherwise you may corrupt your
1797
host data (use the @option{-snapshot} command line so that the
1798
modifications are written in a temporary file).
1799
@end table
1800

    
1801

    
1802
@subsubsection Mac OS X
1803

    
1804
@file{/dev/cdrom} is an alias to the first CDROM.
1805

    
1806
Currently there is no specific code to handle removable media, so it
1807
is better to use the @code{change} or @code{eject} monitor commands to
1808
change or eject media.
1809

    
1810
@node disk_images_fat_images
1811
@subsection Virtual FAT disk images
1812

    
1813
QEMU can automatically create a virtual FAT disk image from a
1814
directory tree. In order to use it, just type:
1815

    
1816
@example
1817
qemu linux.img -hdb fat:/my_directory
1818
@end example
1819

    
1820
Then you access access to all the files in the @file{/my_directory}
1821
directory without having to copy them in a disk image or to export
1822
them via SAMBA or NFS. The default access is @emph{read-only}.
1823

    
1824
Floppies can be emulated with the @code{:floppy:} option:
1825

    
1826
@example
1827
qemu linux.img -fda fat:floppy:/my_directory
1828
@end example
1829

    
1830
A read/write support is available for testing (beta stage) with the
1831
@code{:rw:} option:
1832

    
1833
@example
1834
qemu linux.img -fda fat:floppy:rw:/my_directory
1835
@end example
1836

    
1837
What you should @emph{never} do:
1838
@itemize
1839
@item use non-ASCII filenames ;
1840
@item use "-snapshot" together with ":rw:" ;
1841
@item expect it to work when loadvm'ing ;
1842
@item write to the FAT directory on the host system while accessing it with the guest system.
1843
@end itemize
1844

    
1845
@node disk_images_nbd
1846
@subsection NBD access
1847

    
1848
QEMU can access directly to block device exported using the Network Block Device
1849
protocol.
1850

    
1851
@example
1852
qemu linux.img -hdb nbd:my_nbd_server.mydomain.org:1024
1853
@end example
1854

    
1855
If the NBD server is located on the same host, you can use an unix socket instead
1856
of an inet socket:
1857

    
1858
@example
1859
qemu linux.img -hdb nbd:unix:/tmp/my_socket
1860
@end example
1861

    
1862
In this case, the block device must be exported using qemu-nbd:
1863

    
1864
@example
1865
qemu-nbd --socket=/tmp/my_socket my_disk.qcow2
1866
@end example
1867

    
1868
The use of qemu-nbd allows to share a disk between several guests:
1869
@example
1870
qemu-nbd --socket=/tmp/my_socket --share=2 my_disk.qcow2
1871
@end example
1872

    
1873
and then you can use it with two guests:
1874
@example
1875
qemu linux1.img -hdb nbd:unix:/tmp/my_socket
1876
qemu linux2.img -hdb nbd:unix:/tmp/my_socket
1877
@end example
1878

    
1879
@node pcsys_network
1880
@section Network emulation
1881

    
1882
QEMU can simulate several network cards (PCI or ISA cards on the PC
1883
target) and can connect them to an arbitrary number of Virtual Local
1884
Area Networks (VLANs). Host TAP devices can be connected to any QEMU
1885
VLAN. VLAN can be connected between separate instances of QEMU to
1886
simulate large networks. For simpler usage, a non privileged user mode
1887
network stack can replace the TAP device to have a basic network
1888
connection.
1889

    
1890
@subsection VLANs
1891

    
1892
QEMU simulates several VLANs. A VLAN can be symbolised as a virtual
1893
connection between several network devices. These devices can be for
1894
example QEMU virtual Ethernet cards or virtual Host ethernet devices
1895
(TAP devices).
1896

    
1897
@subsection Using TAP network interfaces
1898

    
1899
This is the standard way to connect QEMU to a real network. QEMU adds
1900
a virtual network device on your host (called @code{tapN}), and you
1901
can then configure it as if it was a real ethernet card.
1902

    
1903
@subsubsection Linux host
1904

    
1905
As an example, you can download the @file{linux-test-xxx.tar.gz}
1906
archive and copy the script @file{qemu-ifup} in @file{/etc} and
1907
configure properly @code{sudo} so that the command @code{ifconfig}
1908
contained in @file{qemu-ifup} can be executed as root. You must verify
1909
that your host kernel supports the TAP network interfaces: the
1910
device @file{/dev/net/tun} must be present.
1911

    
1912
See @ref{sec_invocation} to have examples of command lines using the
1913
TAP network interfaces.
1914

    
1915
@subsubsection Windows host
1916

    
1917
There is a virtual ethernet driver for Windows 2000/XP systems, called
1918
TAP-Win32. But it is not included in standard QEMU for Windows,
1919
so you will need to get it separately. It is part of OpenVPN package,
1920
so download OpenVPN from : @url{http://openvpn.net/}.
1921

    
1922
@subsection Using the user mode network stack
1923

    
1924
By using the option @option{-net user} (default configuration if no
1925
@option{-net} option is specified), QEMU uses a completely user mode
1926
network stack (you don't need root privilege to use the virtual
1927
network). The virtual network configuration is the following:
1928

    
1929
@example
1930

    
1931
         QEMU VLAN      <------>  Firewall/DHCP server <-----> Internet
1932
                           |          (10.0.2.2)
1933
                           |
1934
                           ---->  DNS server (10.0.2.3)
1935
                           |
1936
                           ---->  SMB server (10.0.2.4)
1937
@end example
1938

    
1939
The QEMU VM behaves as if it was behind a firewall which blocks all
1940
incoming connections. You can use a DHCP client to automatically
1941
configure the network in the QEMU VM. The DHCP server assign addresses
1942
to the hosts starting from 10.0.2.15.
1943

    
1944
In order to check that the user mode network is working, you can ping
1945
the address 10.0.2.2 and verify that you got an address in the range
1946
10.0.2.x from the QEMU virtual DHCP server.
1947

    
1948
Note that @code{ping} is not supported reliably to the internet as it
1949
would require root privileges. It means you can only ping the local
1950
router (10.0.2.2).
1951

    
1952
When using the built-in TFTP server, the router is also the TFTP
1953
server.
1954

    
1955
When using the @option{-redir} option, TCP or UDP connections can be
1956
redirected from the host to the guest. It allows for example to
1957
redirect X11, telnet or SSH connections.
1958

    
1959
@subsection Connecting VLANs between QEMU instances
1960

    
1961
Using the @option{-net socket} option, it is possible to make VLANs
1962
that span several QEMU instances. See @ref{sec_invocation} to have a
1963
basic example.
1964

    
1965
@node direct_linux_boot
1966
@section Direct Linux Boot
1967

    
1968
This section explains how to launch a Linux kernel inside QEMU without
1969
having to make a full bootable image. It is very useful for fast Linux
1970
kernel testing.
1971

    
1972
The syntax is:
1973
@example
1974
qemu -kernel arch/i386/boot/bzImage -hda root-2.4.20.img -append "root=/dev/hda"
1975
@end example
1976

    
1977
Use @option{-kernel} to provide the Linux kernel image and
1978
@option{-append} to give the kernel command line arguments. The
1979
@option{-initrd} option can be used to provide an INITRD image.
1980

    
1981
When using the direct Linux boot, a disk image for the first hard disk
1982
@file{hda} is required because its boot sector is used to launch the
1983
Linux kernel.
1984

    
1985
If you do not need graphical output, you can disable it and redirect
1986
the virtual serial port and the QEMU monitor to the console with the
1987
@option{-nographic} option. The typical command line is:
1988
@example
1989
qemu -kernel arch/i386/boot/bzImage -hda root-2.4.20.img \
1990
     -append "root=/dev/hda console=ttyS0" -nographic
1991
@end example
1992

    
1993
Use @key{Ctrl-a c} to switch between the serial console and the
1994
monitor (@pxref{pcsys_keys}).
1995

    
1996
@node pcsys_usb
1997
@section USB emulation
1998

    
1999
QEMU emulates a PCI UHCI USB controller. You can virtually plug
2000
virtual USB devices or real host USB devices (experimental, works only
2001
on Linux hosts).  Qemu will automatically create and connect virtual USB hubs
2002
as necessary to connect multiple USB devices.
2003

    
2004
@menu
2005
* usb_devices::
2006
* host_usb_devices::
2007
@end menu
2008
@node usb_devices
2009
@subsection Connecting USB devices
2010

    
2011
USB devices can be connected with the @option{-usbdevice} commandline option
2012
or the @code{usb_add} monitor command.  Available devices are:
2013

    
2014
@table @code
2015
@item mouse
2016
Virtual Mouse.  This will override the PS/2 mouse emulation when activated.
2017
@item tablet
2018
Pointer device that uses absolute coordinates (like a touchscreen).
2019
This means qemu is able to report the mouse position without having
2020
to grab the mouse.  Also overrides the PS/2 mouse emulation when activated.
2021
@item disk:@var{file}
2022
Mass storage device based on @var{file} (@pxref{disk_images})
2023
@item host:@var{bus.addr}
2024
Pass through the host device identified by @var{bus.addr}
2025
(Linux only)
2026
@item host:@var{vendor_id:product_id}
2027
Pass through the host device identified by @var{vendor_id:product_id}
2028
(Linux only)
2029
@item wacom-tablet
2030
Virtual Wacom PenPartner tablet.  This device is similar to the @code{tablet}
2031
above but it can be used with the tslib library because in addition to touch
2032
coordinates it reports touch pressure.
2033
@item keyboard
2034
Standard USB keyboard.  Will override the PS/2 keyboard (if present).
2035
@item serial:[vendorid=@var{vendor_id}][,product_id=@var{product_id}]:@var{dev}
2036
Serial converter. This emulates an FTDI FT232BM chip connected to host character
2037
device @var{dev}. The available character devices are the same as for the
2038
@code{-serial} option. The @code{vendorid} and @code{productid} options can be
2039
used to override the default 0403:6001. For instance, 
2040
@example
2041
usb_add serial:productid=FA00:tcp:192.168.0.2:4444
2042
@end example
2043
will connect to tcp port 4444 of ip 192.168.0.2, and plug that to the virtual
2044
serial converter, faking a Matrix Orbital LCD Display (USB ID 0403:FA00).
2045
@item braille
2046
Braille device.  This will use BrlAPI to display the braille output on a real
2047
or fake device.
2048
@item net:@var{options}
2049
Network adapter that supports CDC ethernet and RNDIS protocols.  @var{options}
2050
specifies NIC options as with @code{-net nic,}@var{options} (see description).
2051
For instance, user-mode networking can be used with
2052
@example
2053
qemu [...OPTIONS...] -net user,vlan=0 -usbdevice net:vlan=0
2054
@end example
2055
Currently this cannot be used in machines that support PCI NICs.
2056
@item bt[:@var{hci-type}]
2057
Bluetooth dongle whose type is specified in the same format as with
2058
the @option{-bt hci} option, @pxref{bt-hcis,,allowed HCI types}.  If
2059
no type is given, the HCI logic corresponds to @code{-bt hci,vlan=0}.
2060
This USB device implements the USB Transport Layer of HCI.  Example
2061
usage:
2062
@example
2063
qemu [...OPTIONS...] -usbdevice bt:hci,vlan=3 -bt device:keyboard,vlan=3
2064
@end example
2065
@end table
2066

    
2067
@node host_usb_devices
2068
@subsection Using host USB devices on a Linux host
2069

    
2070
WARNING: this is an experimental feature. QEMU will slow down when
2071
using it. USB devices requiring real time streaming (i.e. USB Video
2072
Cameras) are not supported yet.
2073

    
2074
@enumerate
2075
@item If you use an early Linux 2.4 kernel, verify that no Linux driver
2076
is actually using the USB device. A simple way to do that is simply to
2077
disable the corresponding kernel module by renaming it from @file{mydriver.o}
2078
to @file{mydriver.o.disabled}.
2079

    
2080
@item Verify that @file{/proc/bus/usb} is working (most Linux distributions should enable it by default). You should see something like that:
2081
@example
2082
ls /proc/bus/usb
2083
001  devices  drivers
2084
@end example
2085

    
2086
@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:
2087
@example
2088
chown -R myuid /proc/bus/usb
2089
@end example
2090

    
2091
@item Launch QEMU and do in the monitor:
2092
@example
2093
info usbhost
2094
  Device 1.2, speed 480 Mb/s
2095
    Class 00: USB device 1234:5678, USB DISK
2096
@end example
2097
You should see the list of the devices you can use (Never try to use
2098
hubs, it won't work).
2099

    
2100
@item Add the device in QEMU by using:
2101
@example
2102
usb_add host:1234:5678
2103
@end example
2104

    
2105
Normally the guest OS should report that a new USB device is
2106
plugged. You can use the option @option{-usbdevice} to do the same.
2107

    
2108
@item Now you can try to use the host USB device in QEMU.
2109

    
2110
@end enumerate
2111

    
2112
When relaunching QEMU, you may have to unplug and plug again the USB
2113
device to make it work again (this is a bug).
2114

    
2115
@node vnc_security
2116
@section VNC security
2117

    
2118
The VNC server capability provides access to the graphical console
2119
of the guest VM across the network. This has a number of security
2120
considerations depending on the deployment scenarios.
2121

    
2122
@menu
2123
* vnc_sec_none::
2124
* vnc_sec_password::
2125
* vnc_sec_certificate::
2126
* vnc_sec_certificate_verify::
2127
* vnc_sec_certificate_pw::
2128
* vnc_sec_sasl::
2129
* vnc_sec_certificate_sasl::
2130
* vnc_generate_cert::
2131
* vnc_setup_sasl::
2132
@end menu
2133
@node vnc_sec_none
2134
@subsection Without passwords
2135

    
2136
The simplest VNC server setup does not include any form of authentication.
2137
For this setup it is recommended to restrict it to listen on a UNIX domain
2138
socket only. For example
2139

    
2140
@example
2141
qemu [...OPTIONS...] -vnc unix:/home/joebloggs/.qemu-myvm-vnc
2142
@end example
2143

    
2144
This ensures that only users on local box with read/write access to that
2145
path can access the VNC server. To securely access the VNC server from a
2146
remote machine, a combination of netcat+ssh can be used to provide a secure
2147
tunnel.
2148

    
2149
@node vnc_sec_password
2150
@subsection With passwords
2151

    
2152
The VNC protocol has limited support for password based authentication. Since
2153
the protocol limits passwords to 8 characters it should not be considered
2154
to provide high security. The password can be fairly easily brute-forced by
2155
a client making repeat connections. For this reason, a VNC server using password
2156
authentication should be restricted to only listen on the loopback interface
2157
or UNIX domain sockets. Password authentication is requested with the @code{password}
2158
option, and then once QEMU is running the password is set with the monitor. Until
2159
the monitor is used to set the password all clients will be rejected.
2160

    
2161
@example
2162
qemu [...OPTIONS...] -vnc :1,password -monitor stdio
2163
(qemu) change vnc password
2164
Password: ********
2165
(qemu)
2166
@end example
2167

    
2168
@node vnc_sec_certificate
2169
@subsection With x509 certificates
2170

    
2171
The QEMU VNC server also implements the VeNCrypt extension allowing use of
2172
TLS for encryption of the session, and x509 certificates for authentication.
2173
The use of x509 certificates is strongly recommended, because TLS on its
2174
own is susceptible to man-in-the-middle attacks. Basic x509 certificate
2175
support provides a secure session, but no authentication. This allows any
2176
client to connect, and provides an encrypted session.
2177

    
2178
@example
2179
qemu [...OPTIONS...] -vnc :1,tls,x509=/etc/pki/qemu -monitor stdio
2180
@end example
2181

    
2182
In the above example @code{/etc/pki/qemu} should contain at least three files,
2183
@code{ca-cert.pem}, @code{server-cert.pem} and @code{server-key.pem}. Unprivileged
2184
users will want to use a private directory, for example @code{$HOME/.pki/qemu}.
2185
NB the @code{server-key.pem} file should be protected with file mode 0600 to
2186
only be readable by the user owning it.
2187

    
2188
@node vnc_sec_certificate_verify
2189
@subsection With x509 certificates and client verification
2190

    
2191
Certificates can also provide a means to authenticate the client connecting.
2192
The server will request that the client provide a certificate, which it will
2193
then validate against the CA certificate. This is a good choice if deploying
2194
in an environment with a private internal certificate authority.
2195

    
2196
@example
2197
qemu [...OPTIONS...] -vnc :1,tls,x509verify=/etc/pki/qemu -monitor stdio
2198
@end example
2199

    
2200

    
2201
@node vnc_sec_certificate_pw
2202
@subsection With x509 certificates, client verification and passwords
2203

    
2204
Finally, the previous method can be combined with VNC password authentication
2205
to provide two layers of authentication for clients.
2206

    
2207
@example
2208
qemu [...OPTIONS...] -vnc :1,password,tls,x509verify=/etc/pki/qemu -monitor stdio
2209
(qemu) change vnc password
2210
Password: ********
2211
(qemu)
2212
@end example
2213

    
2214

    
2215
@node vnc_sec_sasl
2216
@subsection With SASL authentication
2217

    
2218
The SASL authentication method is a VNC extension, that provides an
2219
easily extendable, pluggable authentication method. This allows for
2220
integration with a wide range of authentication mechanisms, such as
2221
PAM, GSSAPI/Kerberos, LDAP, SQL databases, one-time keys and more.
2222
The strength of the authentication depends on the exact mechanism
2223
configured. If the chosen mechanism also provides a SSF layer, then
2224
it will encrypt the datastream as well.
2225

    
2226
Refer to the later docs on how to choose the exact SASL mechanism
2227
used for authentication, but assuming use of one supporting SSF,
2228
then QEMU can be launched with:
2229

    
2230
@example
2231
qemu [...OPTIONS...] -vnc :1,sasl -monitor stdio
2232
@end example
2233

    
2234
@node vnc_sec_certificate_sasl
2235
@subsection With x509 certificates and SASL authentication
2236

    
2237
If the desired SASL authentication mechanism does not supported
2238
SSF layers, then it is strongly advised to run it in combination
2239
with TLS and x509 certificates. This provides securely encrypted
2240
data stream, avoiding risk of compromising of the security
2241
credentials. This can be enabled, by combining the 'sasl' option
2242
with the aforementioned TLS + x509 options:
2243

    
2244
@example
2245
qemu [...OPTIONS...] -vnc :1,tls,x509,sasl -monitor stdio
2246
@end example
2247

    
2248

    
2249
@node vnc_generate_cert
2250
@subsection Generating certificates for VNC
2251

    
2252
The GNU TLS packages provides a command called @code{certtool} which can
2253
be used to generate certificates and keys in PEM format. At a minimum it
2254
is neccessary to setup a certificate authority, and issue certificates to
2255
each server. If using certificates for authentication, then each client
2256
will also need to be issued a certificate. The recommendation is for the
2257
server to keep its certificates in either @code{/etc/pki/qemu} or for
2258
unprivileged users in @code{$HOME/.pki/qemu}.
2259

    
2260
@menu
2261
* vnc_generate_ca::
2262
* vnc_generate_server::
2263
* vnc_generate_client::
2264
@end menu
2265
@node vnc_generate_ca
2266
@subsubsection Setup the Certificate Authority
2267

    
2268
This step only needs to be performed once per organization / organizational
2269
unit. First the CA needs a private key. This key must be kept VERY secret
2270
and secure. If this key is compromised the entire trust chain of the certificates
2271
issued with it is lost.
2272

    
2273
@example
2274
# certtool --generate-privkey > ca-key.pem
2275
@end example
2276

    
2277
A CA needs to have a public certificate. For simplicity it can be a self-signed
2278
certificate, or one issue by a commercial certificate issuing authority. To
2279
generate a self-signed certificate requires one core piece of information, the
2280
name of the organization.
2281

    
2282
@example
2283
# cat > ca.info <<EOF
2284
cn = Name of your organization
2285
ca
2286
cert_signing_key
2287
EOF
2288
# certtool --generate-self-signed \
2289
           --load-privkey ca-key.pem
2290
           --template ca.info \
2291
           --outfile ca-cert.pem
2292
@end example
2293

    
2294
The @code{ca-cert.pem} file should be copied to all servers and clients wishing to utilize
2295
TLS support in the VNC server. The @code{ca-key.pem} must not be disclosed/copied at all.
2296

    
2297
@node vnc_generate_server
2298
@subsubsection Issuing server certificates
2299

    
2300
Each server (or host) needs to be issued with a key and certificate. When connecting
2301
the certificate is sent to the client which validates it against the CA certificate.
2302
The core piece of information for a server certificate is the hostname. This should
2303
be the fully qualified hostname that the client will connect with, since the client
2304
will typically also verify the hostname in the certificate. On the host holding the
2305
secure CA private key:
2306

    
2307
@example
2308
# cat > server.info <<EOF
2309
organization = Name  of your organization
2310
cn = server.foo.example.com
2311
tls_www_server
2312
encryption_key
2313
signing_key
2314
EOF
2315
# certtool --generate-privkey > server-key.pem
2316
# certtool --generate-certificate \
2317
           --load-ca-certificate ca-cert.pem \
2318
           --load-ca-privkey ca-key.pem \
2319
           --load-privkey server server-key.pem \
2320
           --template server.info \
2321
           --outfile server-cert.pem
2322
@end example
2323

    
2324
The @code{server-key.pem} and @code{server-cert.pem} files should now be securely copied
2325
to the server for which they were generated. The @code{server-key.pem} is security
2326
sensitive and should be kept protected with file mode 0600 to prevent disclosure.
2327

    
2328
@node vnc_generate_client
2329
@subsubsection Issuing client certificates
2330

    
2331
If the QEMU VNC server is to use the @code{x509verify} option to validate client
2332
certificates as its authentication mechanism, each client also needs to be issued
2333
a certificate. The client certificate contains enough metadata to uniquely identify
2334
the client, typically organization, state, city, building, etc. On the host holding
2335
the secure CA private key:
2336

    
2337
@example
2338
# cat > client.info <<EOF
2339
country = GB
2340
state = London
2341
locality = London
2342
organiazation = Name of your organization
2343
cn = client.foo.example.com
2344
tls_www_client
2345
encryption_key
2346
signing_key
2347
EOF
2348
# certtool --generate-privkey > client-key.pem
2349
# certtool --generate-certificate \
2350
           --load-ca-certificate ca-cert.pem \
2351
           --load-ca-privkey ca-key.pem \
2352
           --load-privkey client-key.pem \
2353
           --template client.info \
2354
           --outfile client-cert.pem
2355
@end example
2356

    
2357
The @code{client-key.pem} and @code{client-cert.pem} files should now be securely
2358
copied to the client for which they were generated.
2359

    
2360

    
2361
@node vnc_setup_sasl
2362

    
2363
@subsection Configuring SASL mechanisms
2364

    
2365
The following documentation assumes use of the Cyrus SASL implementation on a
2366
Linux host, but the principals should apply to any other SASL impl. When SASL
2367
is enabled, the mechanism configuration will be loaded from system default
2368
SASL service config /etc/sasl2/qemu.conf. If running QEMU as an
2369
unprivileged user, an environment variable SASL_CONF_PATH can be used
2370
to make it search alternate locations for the service config.
2371

    
2372
The default configuration might contain
2373

    
2374
@example
2375
mech_list: digest-md5
2376
sasldb_path: /etc/qemu/passwd.db
2377
@end example
2378

    
2379
This says to use the 'Digest MD5' mechanism, which is similar to the HTTP
2380
Digest-MD5 mechanism. The list of valid usernames & passwords is maintained
2381
in the /etc/qemu/passwd.db file, and can be updated using the saslpasswd2
2382
command. While this mechanism is easy to configure and use, it is not
2383
considered secure by modern standards, so only suitable for developers /
2384
ad-hoc testing.
2385

    
2386
A more serious deployment might use Kerberos, which is done with the 'gssapi'
2387
mechanism
2388

    
2389
@example
2390
mech_list: gssapi
2391
keytab: /etc/qemu/krb5.tab
2392
@end example
2393

    
2394
For this to work the administrator of your KDC must generate a Kerberos
2395
principal for the server, with a name of  'qemu/somehost.example.com@@EXAMPLE.COM'
2396
replacing 'somehost.example.com' with the fully qualified host name of the
2397
machine running QEMU, and 'EXAMPLE.COM' with the Keberos Realm.
2398

    
2399
Other configurations will be left as an exercise for the reader. It should
2400
be noted that only Digest-MD5 and GSSAPI provides a SSF layer for data
2401
encryption. For all other mechanisms, VNC should always be configured to
2402
use TLS and x509 certificates to protect security credentials from snooping.
2403

    
2404
@node gdb_usage
2405
@section GDB usage
2406

    
2407
QEMU has a primitive support to work with gdb, so that you can do
2408
'Ctrl-C' while the virtual machine is running and inspect its state.
2409

    
2410
In order to use gdb, launch qemu with the '-s' option. It will wait for a
2411
gdb connection:
2412
@example
2413
> qemu -s -kernel arch/i386/boot/bzImage -hda root-2.4.20.img \
2414
       -append "root=/dev/hda"
2415
Connected to host network interface: tun0
2416
Waiting gdb connection on port 1234
2417
@end example
2418

    
2419
Then launch gdb on the 'vmlinux' executable:
2420
@example
2421
> gdb vmlinux
2422
@end example
2423

    
2424
In gdb, connect to QEMU:
2425
@example
2426
(gdb) target remote localhost:1234
2427
@end example
2428

    
2429
Then you can use gdb normally. For example, type 'c' to launch the kernel:
2430
@example
2431
(gdb) c
2432
@end example
2433

    
2434
Here are some useful tips in order to use gdb on system code:
2435

    
2436
@enumerate
2437
@item
2438
Use @code{info reg} to display all the CPU registers.
2439
@item
2440
Use @code{x/10i $eip} to display the code at the PC position.
2441
@item
2442
Use @code{set architecture i8086} to dump 16 bit code. Then use
2443
@code{x/10i $cs*16+$eip} to dump the code at the PC position.
2444
@end enumerate
2445

    
2446
Advanced debugging options:
2447

    
2448
The default single stepping behavior is step with the IRQs and timer service routines off.  It is set this way because when gdb executes a single step it expects to advance beyond the current instruction.  With the IRQs and and timer service routines on, a single step might jump into the one of the interrupt or exception vectors instead of executing the current instruction. This means you may hit the same breakpoint a number of times before executing the instruction gdb wants to have executed.  Because there are rare circumstances where you want to single step into an interrupt vector the behavior can be controlled from GDB.  There are three commands you can query and set the single step behavior:
2449
@table @code
2450
@item maintenance packet qqemu.sstepbits
2451

    
2452
This will display the MASK bits used to control the single stepping IE:
2453
@example
2454
(gdb) maintenance packet qqemu.sstepbits
2455
sending: "qqemu.sstepbits"
2456
received: "ENABLE=1,NOIRQ=2,NOTIMER=4"
2457
@end example
2458
@item maintenance packet qqemu.sstep
2459

    
2460
This will display the current value of the mask used when single stepping IE:
2461
@example
2462
(gdb) maintenance packet qqemu.sstep
2463
sending: "qqemu.sstep"
2464
received: "0x7"
2465
@end example
2466
@item maintenance packet Qqemu.sstep=HEX_VALUE
2467

    
2468
This will change the single step mask, so if wanted to enable IRQs on the single step, but not timers, you would use:
2469
@example
2470
(gdb) maintenance packet Qqemu.sstep=0x5
2471
sending: "qemu.sstep=0x5"
2472
received: "OK"
2473
@end example
2474
@end table
2475

    
2476
@node pcsys_os_specific
2477
@section Target OS specific information
2478

    
2479
@subsection Linux
2480

    
2481
To have access to SVGA graphic modes under X11, use the @code{vesa} or
2482
the @code{cirrus} X11 driver. For optimal performances, use 16 bit
2483
color depth in the guest and the host OS.
2484

    
2485
When using a 2.6 guest Linux kernel, you should add the option
2486
@code{clock=pit} on the kernel command line because the 2.6 Linux
2487
kernels make very strict real time clock checks by default that QEMU
2488
cannot simulate exactly.
2489

    
2490
When using a 2.6 guest Linux kernel, verify that the 4G/4G patch is
2491
not activated because QEMU is slower with this patch. The QEMU
2492
Accelerator Module is also much slower in this case. Earlier Fedora
2493
Core 3 Linux kernel (< 2.6.9-1.724_FC3) were known to incorporate this
2494
patch by default. Newer kernels don't have it.
2495

    
2496
@subsection Windows
2497

    
2498
If you have a slow host, using Windows 95 is better as it gives the
2499
best speed. Windows 2000 is also a good choice.
2500

    
2501
@subsubsection SVGA graphic modes support
2502

    
2503
QEMU emulates a Cirrus Logic GD5446 Video
2504
card. All Windows versions starting from Windows 95 should recognize
2505
and use this graphic card. For optimal performances, use 16 bit color
2506
depth in the guest and the host OS.
2507

    
2508
If you are using Windows XP as guest OS and if you want to use high
2509
resolution modes which the Cirrus Logic BIOS does not support (i.e. >=
2510
1280x1024x16), then you should use the VESA VBE virtual graphic card
2511
(option @option{-std-vga}).
2512

    
2513
@subsubsection CPU usage reduction
2514

    
2515
Windows 9x does not correctly use the CPU HLT
2516
instruction. The result is that it takes host CPU cycles even when
2517
idle. You can install the utility from
2518
@url{http://www.user.cityline.ru/~maxamn/amnhltm.zip} to solve this
2519
problem. Note that no such tool is needed for NT, 2000 or XP.
2520

    
2521
@subsubsection Windows 2000 disk full problem
2522

    
2523
Windows 2000 has a bug which gives a disk full problem during its
2524
installation. When installing it, use the @option{-win2k-hack} QEMU
2525
option to enable a specific workaround. After Windows 2000 is
2526
installed, you no longer need this option (this option slows down the
2527
IDE transfers).
2528

    
2529
@subsubsection Windows 2000 shutdown
2530

    
2531
Windows 2000 cannot automatically shutdown in QEMU although Windows 98
2532
can. It comes from the fact that Windows 2000 does not automatically
2533
use the APM driver provided by the BIOS.
2534

    
2535
In order to correct that, do the following (thanks to Struan
2536
Bartlett): go to the Control Panel => Add/Remove Hardware & Next =>
2537
Add/Troubleshoot a device => Add a new device & Next => No, select the
2538
hardware from a list & Next => NT Apm/Legacy Support & Next => Next
2539
(again) a few times. Now the driver is installed and Windows 2000 now
2540
correctly instructs QEMU to shutdown at the appropriate moment.
2541

    
2542
@subsubsection Share a directory between Unix and Windows
2543

    
2544
See @ref{sec_invocation} about the help of the option @option{-smb}.
2545

    
2546
@subsubsection Windows XP security problem
2547

    
2548
Some releases of Windows XP install correctly but give a security
2549
error when booting:
2550
@example
2551
A problem is preventing Windows from accurately checking the
2552
license for this computer. Error code: 0x800703e6.
2553
@end example
2554

    
2555
The workaround is to install a service pack for XP after a boot in safe
2556
mode. Then reboot, and the problem should go away. Since there is no
2557
network while in safe mode, its recommended to download the full
2558
installation of SP1 or SP2 and transfer that via an ISO or using the
2559
vvfat block device ("-hdb fat:directory_which_holds_the_SP").
2560

    
2561
@subsection MS-DOS and FreeDOS
2562

    
2563
@subsubsection CPU usage reduction
2564

    
2565
DOS does not correctly use the CPU HLT instruction. The result is that
2566
it takes host CPU cycles even when idle. You can install the utility
2567
from @url{http://www.vmware.com/software/dosidle210.zip} to solve this
2568
problem.
2569

    
2570
@node QEMU System emulator for non PC targets
2571
@chapter QEMU System emulator for non PC targets
2572

    
2573
QEMU is a generic emulator and it emulates many non PC
2574
machines. Most of the options are similar to the PC emulator. The
2575
differences are mentioned in the following sections.
2576

    
2577
@menu
2578
* QEMU PowerPC System emulator::
2579
* Sparc32 System emulator::
2580
* Sparc64 System emulator::
2581
* MIPS System emulator::
2582
* ARM System emulator::
2583
* ColdFire System emulator::
2584
@end menu
2585

    
2586
@node QEMU PowerPC System emulator
2587
@section QEMU PowerPC System emulator
2588

    
2589
Use the executable @file{qemu-system-ppc} to simulate a complete PREP
2590
or PowerMac PowerPC system.
2591

    
2592
QEMU emulates the following PowerMac peripherals:
2593

    
2594
@itemize @minus
2595
@item
2596
UniNorth or Grackle PCI Bridge
2597
@item
2598
PCI VGA compatible card with VESA Bochs Extensions
2599
@item
2600
2 PMAC IDE interfaces with hard disk and CD-ROM support
2601
@item
2602
NE2000 PCI adapters
2603
@item
2604
Non Volatile RAM
2605
@item
2606
VIA-CUDA with ADB keyboard and mouse.
2607
@end itemize
2608

    
2609
QEMU emulates the following PREP peripherals:
2610

    
2611
@itemize @minus
2612
@item
2613
PCI Bridge
2614
@item
2615
PCI VGA compatible card with VESA Bochs Extensions
2616
@item
2617
2 IDE interfaces with hard disk and CD-ROM support
2618
@item
2619
Floppy disk
2620
@item
2621
NE2000 network adapters
2622
@item
2623
Serial port
2624
@item
2625
PREP Non Volatile RAM
2626
@item
2627
PC compatible keyboard and mouse.
2628
@end itemize
2629

    
2630
QEMU uses the Open Hack'Ware Open Firmware Compatible BIOS available at
2631
@url{http://perso.magic.fr/l_indien/OpenHackWare/index.htm}.
2632

    
2633
Since version 0.9.1, QEMU uses OpenBIOS @url{http://www.openbios.org/}
2634
for the g3beige and mac99 PowerMac machines. OpenBIOS is a free (GPL
2635
v2) portable firmware implementation. The goal is to implement a 100%
2636
IEEE 1275-1994 (referred to as Open Firmware) compliant firmware.
2637

    
2638
@c man begin OPTIONS
2639

    
2640
The following options are specific to the PowerPC emulation:
2641

    
2642
@table @option
2643

    
2644
@item -g WxH[xDEPTH]
2645

    
2646
Set the initial VGA graphic mode. The default is 800x600x15.
2647

    
2648
@item -prom-env string
2649

    
2650
Set OpenBIOS variables in NVRAM, for example:
2651

    
2652
@example
2653
qemu-system-ppc -prom-env 'auto-boot?=false' \
2654
 -prom-env 'boot-device=hd:2,\yaboot' \
2655
 -prom-env 'boot-args=conf=hd:2,\yaboot.conf'
2656
@end example
2657

    
2658
These variables are not used by Open Hack'Ware.
2659

    
2660
@end table
2661

    
2662
@c man end
2663

    
2664

    
2665
More information is available at
2666
@url{http://perso.magic.fr/l_indien/qemu-ppc/}.
2667

    
2668
@node Sparc32 System emulator
2669
@section Sparc32 System emulator
2670

    
2671
Use the executable @file{qemu-system-sparc} to simulate the following
2672
Sun4m architecture machines:
2673
@itemize @minus
2674
@item
2675
SPARCstation 4
2676
@item
2677
SPARCstation 5
2678
@item
2679
SPARCstation 10
2680
@item
2681
SPARCstation 20
2682
@item
2683
SPARCserver 600MP
2684
@item
2685
SPARCstation LX
2686
@item
2687
SPARCstation Voyager
2688
@item
2689
SPARCclassic
2690
@item
2691
SPARCbook
2692
@end itemize
2693

    
2694
The emulation is somewhat complete. SMP up to 16 CPUs is supported,
2695
but Linux limits the number of usable CPUs to 4.
2696

    
2697
It's also possible to simulate a SPARCstation 2 (sun4c architecture),
2698
SPARCserver 1000, or SPARCcenter 2000 (sun4d architecture), but these
2699
emulators are not usable yet.
2700

    
2701
QEMU emulates the following sun4m/sun4c/sun4d peripherals:
2702

    
2703
@itemize @minus
2704
@item
2705
IOMMU or IO-UNITs
2706
@item
2707
TCX Frame buffer
2708
@item
2709
Lance (Am7990) Ethernet
2710
@item
2711
Non Volatile RAM M48T02/M48T08
2712
@item
2713
Slave I/O: timers, interrupt controllers, Zilog serial ports, keyboard
2714
and power/reset logic
2715
@item
2716
ESP SCSI controller with hard disk and CD-ROM support
2717
@item
2718
Floppy drive (not on SS-600MP)
2719
@item
2720
CS4231 sound device (only on SS-5, not working yet)
2721
@end itemize
2722

    
2723
The number of peripherals is fixed in the architecture.  Maximum
2724
memory size depends on the machine type, for SS-5 it is 256MB and for
2725
others 2047MB.
2726

    
2727
Since version 0.8.2, QEMU uses OpenBIOS
2728
@url{http://www.openbios.org/}. OpenBIOS is a free (GPL v2) portable
2729
firmware implementation. The goal is to implement a 100% IEEE
2730
1275-1994 (referred to as Open Firmware) compliant firmware.
2731

    
2732
A sample Linux 2.6 series kernel and ram disk image are available on
2733
the QEMU web site. There are still issues with NetBSD and OpenBSD, but
2734
some kernel versions work. Please note that currently Solaris kernels
2735
don't work probably due to interface issues between OpenBIOS and
2736
Solaris.
2737

    
2738
@c man begin OPTIONS
2739

    
2740
The following options are specific to the Sparc32 emulation:
2741

    
2742
@table @option
2743

    
2744
@item -g WxHx[xDEPTH]
2745

    
2746
Set the initial TCX graphic mode. The default is 1024x768x8, currently
2747
the only other possible mode is 1024x768x24.
2748

    
2749
@item -prom-env string
2750

    
2751
Set OpenBIOS variables in NVRAM, for example:
2752

    
2753
@example
2754
qemu-system-sparc -prom-env 'auto-boot?=false' \
2755
 -prom-env 'boot-device=sd(0,2,0):d' -prom-env 'boot-args=linux single'
2756
@end example
2757

    
2758
@item -M [SS-4|SS-5|SS-10|SS-20|SS-600MP|LX|Voyager|SPARCClassic|SPARCbook|SS-2|SS-1000|SS-2000]
2759

    
2760
Set the emulated machine type. Default is SS-5.
2761

    
2762
@end table
2763

    
2764
@c man end
2765

    
2766
@node Sparc64 System emulator
2767
@section Sparc64 System emulator
2768

    
2769
Use the executable @file{qemu-system-sparc64} to simulate a Sun4u
2770
(UltraSPARC PC-like machine), Sun4v (T1 PC-like machine), or generic
2771
Niagara (T1) machine. The emulator is not usable for anything yet, but
2772
it can launch some kernels.
2773

    
2774
QEMU emulates the following peripherals:
2775

    
2776
@itemize @minus
2777
@item
2778
UltraSparc IIi APB PCI Bridge
2779
@item
2780
PCI VGA compatible card with VESA Bochs Extensions
2781
@item
2782
PS/2 mouse and keyboard
2783
@item
2784
Non Volatile RAM M48T59
2785
@item
2786
PC-compatible serial ports
2787
@item
2788
2 PCI IDE interfaces with hard disk and CD-ROM support
2789
@item
2790
Floppy disk
2791
@end itemize
2792

    
2793
@c man begin OPTIONS
2794

    
2795
The following options are specific to the Sparc64 emulation:
2796

    
2797
@table @option
2798

    
2799
@item -prom-env string
2800

    
2801
Set OpenBIOS variables in NVRAM, for example:
2802

    
2803
@example
2804
qemu-system-sparc64 -prom-env 'auto-boot?=false'
2805
@end example
2806

    
2807
@item -M [sun4u|sun4v|Niagara]
2808

    
2809
Set the emulated machine type. The default is sun4u.
2810

    
2811
@end table
2812

    
2813
@c man end
2814

    
2815
@node MIPS System emulator
2816
@section MIPS System emulator
2817

    
2818
Four executables cover simulation of 32 and 64-bit MIPS systems in
2819
both endian options, @file{qemu-system-mips}, @file{qemu-system-mipsel}
2820
@file{qemu-system-mips64} and @file{qemu-system-mips64el}.
2821
Five different machine types are emulated:
2822

    
2823
@itemize @minus
2824
@item
2825
A generic ISA PC-like machine "mips"
2826
@item
2827
The MIPS Malta prototype board "malta"
2828
@item
2829
An ACER Pica "pica61". This machine needs the 64-bit emulator.
2830
@item
2831
MIPS emulator pseudo board "mipssim"
2832
@item
2833
A MIPS Magnum R4000 machine "magnum". This machine needs the 64-bit emulator.
2834
@end itemize
2835

    
2836
The generic emulation is supported by Debian 'Etch' and is able to
2837
install Debian into a virtual disk image. The following devices are
2838
emulated:
2839

    
2840
@itemize @minus
2841
@item
2842
A range of MIPS CPUs, default is the 24Kf
2843
@item
2844
PC style serial port
2845
@item
2846
PC style IDE disk
2847
@item
2848
NE2000 network card
2849
@end itemize
2850

    
2851
The Malta emulation supports the following devices:
2852

    
2853
@itemize @minus
2854
@item
2855
Core board with MIPS 24Kf CPU and Galileo system controller
2856
@item
2857
PIIX4 PCI/USB/SMbus controller
2858
@item
2859
The Multi-I/O chip's serial device
2860
@item
2861
PCnet32 PCI network card
2862
@item
2863
Malta FPGA serial device
2864
@item
2865
Cirrus (default) or any other PCI VGA graphics card
2866
@end itemize
2867

    
2868
The ACER Pica emulation supports:
2869

    
2870
@itemize @minus
2871
@item
2872
MIPS R4000 CPU
2873
@item
2874
PC-style IRQ and DMA controllers
2875
@item
2876
PC Keyboard
2877
@item
2878
IDE controller
2879
@end itemize
2880

    
2881
The mipssim pseudo board emulation provides an environment similiar
2882
to what the proprietary MIPS emulator uses for running Linux.
2883
It supports:
2884

    
2885
@itemize @minus
2886
@item
2887
A range of MIPS CPUs, default is the 24Kf
2888
@item
2889
PC style serial port
2890
@item
2891
MIPSnet network emulation
2892
@end itemize
2893

    
2894
The MIPS Magnum R4000 emulation supports:
2895

    
2896
@itemize @minus
2897
@item
2898
MIPS R4000 CPU
2899
@item
2900
PC-style IRQ controller
2901
@item
2902
PC Keyboard
2903
@item
2904
SCSI controller
2905
@item
2906
G364 framebuffer
2907
@end itemize
2908

    
2909

    
2910
@node ARM System emulator
2911
@section ARM System emulator
2912

    
2913
Use the executable @file{qemu-system-arm} to simulate a ARM
2914
machine. The ARM Integrator/CP board is emulated with the following
2915
devices:
2916

    
2917
@itemize @minus
2918
@item
2919
ARM926E, ARM1026E, ARM946E, ARM1136 or Cortex-A8 CPU
2920
@item
2921
Two PL011 UARTs
2922
@item
2923
SMC 91c111 Ethernet adapter
2924
@item
2925
PL110 LCD controller
2926
@item
2927
PL050 KMI with PS/2 keyboard and mouse.
2928
@item
2929
PL181 MultiMedia Card Interface with SD card.
2930
@end itemize
2931

    
2932
The ARM Versatile baseboard is emulated with the following devices:
2933

    
2934
@itemize @minus
2935
@item
2936
ARM926E, ARM1136 or Cortex-A8 CPU
2937
@item
2938
PL190 Vectored Interrupt Controller
2939
@item
2940
Four PL011 UARTs
2941
@item
2942
SMC 91c111 Ethernet adapter
2943
@item
2944
PL110 LCD controller
2945
@item
2946
PL050 KMI with PS/2 keyboard and mouse.
2947
@item
2948
PCI host bridge.  Note the emulated PCI bridge only provides access to
2949
PCI memory space.  It does not provide access to PCI IO space.
2950
This means some devices (eg. ne2k_pci NIC) are not usable, and others
2951
(eg. rtl8139 NIC) are only usable when the guest drivers use the memory
2952
mapped control registers.
2953
@item
2954
PCI OHCI USB controller.
2955
@item
2956
LSI53C895A PCI SCSI Host Bus Adapter with hard disk and CD-ROM devices.
2957
@item
2958
PL181 MultiMedia Card Interface with SD card.
2959
@end itemize
2960

    
2961
The ARM RealView Emulation baseboard is emulated with the following devices:
2962

    
2963
@itemize @minus
2964
@item
2965
ARM926E, ARM1136, ARM11MPCORE(x4) or Cortex-A8 CPU
2966
@item
2967
ARM AMBA Generic/Distributed Interrupt Controller
2968
@item
2969
Four PL011 UARTs
2970
@item
2971
SMC 91c111 Ethernet adapter
2972
@item
2973
PL110 LCD controller
2974
@item
2975
PL050 KMI with PS/2 keyboard and mouse
2976
@item
2977
PCI host bridge
2978
@item
2979
PCI OHCI USB controller
2980
@item
2981
LSI53C895A PCI SCSI Host Bus Adapter with hard disk and CD-ROM devices
2982
@item
2983
PL181 MultiMedia Card Interface with SD card.
2984
@end itemize
2985

    
2986
The XScale-based clamshell PDA models ("Spitz", "Akita", "Borzoi"
2987
and "Terrier") emulation includes the following peripherals:
2988

    
2989
@itemize @minus
2990
@item
2991
Intel PXA270 System-on-chip (ARM V5TE core)
2992
@item
2993
NAND Flash memory
2994
@item
2995
IBM/Hitachi DSCM microdrive in a PXA PCMCIA slot - not in "Akita"
2996
@item
2997
On-chip OHCI USB controller
2998
@item
2999
On-chip LCD controller
3000
@item
3001
On-chip Real Time Clock
3002
@item
3003
TI ADS7846 touchscreen controller on SSP bus
3004
@item
3005
Maxim MAX1111 analog-digital converter on I@math{^2}C bus
3006
@item
3007
GPIO-connected keyboard controller and LEDs
3008
@item
3009
Secure Digital card connected to PXA MMC/SD host
3010
@item
3011
Three on-chip UARTs
3012
@item
3013
WM8750 audio CODEC on I@math{^2}C and I@math{^2}S busses
3014
@end itemize
3015

    
3016
The Palm Tungsten|E PDA (codename "Cheetah") emulation includes the
3017
following elements:
3018

    
3019
@itemize @minus
3020
@item
3021
Texas Instruments OMAP310 System-on-chip (ARM 925T core)
3022
@item
3023
ROM and RAM memories (ROM firmware image can be loaded with -option-rom)
3024
@item
3025
On-chip LCD controller
3026
@item
3027
On-chip Real Time Clock
3028
@item
3029
TI TSC2102i touchscreen controller / analog-digital converter / Audio
3030
CODEC, connected through MicroWire and I@math{^2}S busses
3031
@item
3032
GPIO-connected matrix keypad
3033
@item
3034
Secure Digital card connected to OMAP MMC/SD host
3035
@item
3036
Three on-chip UARTs
3037
@end itemize
3038

    
3039
Nokia N800 and N810 internet tablets (known also as RX-34 and RX-44 / 48)
3040
emulation supports the following elements:
3041

    
3042
@itemize @minus
3043
@item
3044
Texas Instruments OMAP2420 System-on-chip (ARM 1136 core)
3045
@item
3046
RAM and non-volatile OneNAND Flash memories
3047
@item
3048
Display connected to EPSON remote framebuffer chip and OMAP on-chip
3049
display controller and a LS041y3 MIPI DBI-C controller
3050
@item
3051
TI TSC2301 (in N800) and TI TSC2005 (in N810) touchscreen controllers
3052
driven through SPI bus
3053
@item
3054
National Semiconductor LM8323-controlled qwerty keyboard driven
3055
through I@math{^2}C bus
3056
@item
3057
Secure Digital card connected to OMAP MMC/SD host
3058
@item
3059
Three OMAP on-chip UARTs and on-chip STI debugging console
3060
@item
3061
A Bluetooth(R) transciever and HCI connected to an UART
3062
@item
3063
Mentor Graphics "Inventra" dual-role USB controller embedded in a TI
3064
TUSB6010 chip - only USB host mode is supported
3065
@item
3066
TI TMP105 temperature sensor driven through I@math{^2}C bus
3067
@item
3068
TI TWL92230C power management companion with an RTC on I@math{^2}C bus
3069
@item
3070
Nokia RETU and TAHVO multi-purpose chips with an RTC, connected
3071
through CBUS
3072
@end itemize
3073

    
3074
The Luminary Micro Stellaris LM3S811EVB emulation includes the following
3075
devices:
3076

    
3077
@itemize @minus
3078
@item
3079
Cortex-M3 CPU core.
3080
@item
3081
64k Flash and 8k SRAM.
3082
@item
3083
Timers, UARTs, ADC and I@math{^2}C interface.
3084
@item
3085
OSRAM Pictiva 96x16 OLED with SSD0303 controller on I@math{^2}C bus.
3086
@end itemize
3087

    
3088
The Luminary Micro Stellaris LM3S6965EVB emulation includes the following
3089
devices:
3090

    
3091
@itemize @minus
3092
@item
3093
Cortex-M3 CPU core.
3094
@item
3095
256k Flash and 64k SRAM.
3096
@item
3097
Timers, UARTs, ADC, I@math{^2}C and SSI interfaces.
3098
@item
3099
OSRAM Pictiva 128x64 OLED with SSD0323 controller connected via SSI.
3100
@end itemize
3101

    
3102
The Freecom MusicPal internet radio emulation includes the following
3103
elements:
3104

    
3105
@itemize @minus
3106
@item
3107
Marvell MV88W8618 ARM core.
3108
@item
3109
32 MB RAM, 256 KB SRAM, 8 MB flash.
3110
@item
3111
Up to 2 16550 UARTs
3112
@item
3113
MV88W8xx8 Ethernet controller
3114
@item
3115
MV88W8618 audio controller, WM8750 CODEC and mixer
3116
@item
3117
128?64 display with brightness control
3118
@item
3119
2 buttons, 2 navigation wheels with button function
3120
@end itemize
3121

    
3122
The Siemens SX1 models v1 and v2 (default) basic emulation.
3123
The emulaton includes the following elements:
3124

    
3125
@itemize @minus
3126
@item
3127
Texas Instruments OMAP310 System-on-chip (ARM 925T core)
3128
@item
3129
ROM and RAM memories (ROM firmware image can be loaded with -pflash)
3130
V1
3131
1 Flash of 16MB and 1 Flash of 8MB
3132
V2
3133
1 Flash of 32MB
3134
@item
3135
On-chip LCD controller
3136
@item
3137
On-chip Real Time Clock
3138
@item
3139
Secure Digital card connected to OMAP MMC/SD host
3140
@item
3141
Three on-chip UARTs
3142
@end itemize
3143

    
3144
A Linux 2.6 test image is available on the QEMU web site. More
3145
information is available in the QEMU mailing-list archive.
3146

    
3147
@c man begin OPTIONS
3148

    
3149
The following options are specific to the ARM emulation:
3150

    
3151
@table @option
3152

    
3153
@item -semihosting
3154
Enable semihosting syscall emulation.
3155

    
3156
On ARM this implements the "Angel" interface.
3157

    
3158
Note that this allows guest direct access to the host filesystem,
3159
so should only be used with trusted guest OS.
3160

    
3161
@end table
3162

    
3163
@node ColdFire System emulator
3164
@section ColdFire System emulator
3165

    
3166
Use the executable @file{qemu-system-m68k} to simulate a ColdFire machine.
3167
The emulator is able to boot a uClinux kernel.
3168

    
3169
The M5208EVB emulation includes the following devices:
3170

    
3171
@itemize @minus
3172
@item
3173
MCF5208 ColdFire V2 Microprocessor (ISA A+ with EMAC).
3174
@item
3175
Three Two on-chip UARTs.
3176
@item
3177
Fast Ethernet Controller (FEC)
3178
@end itemize
3179

    
3180
The AN5206 emulation includes the following devices:
3181

    
3182
@itemize @minus
3183
@item
3184
MCF5206 ColdFire V2 Microprocessor.
3185
@item
3186
Two on-chip UARTs.
3187
@end itemize
3188

    
3189
@c man begin OPTIONS
3190

    
3191
The following options are specific to the ARM emulation:
3192

    
3193
@table @option
3194

    
3195
@item -semihosting
3196
Enable semihosting syscall emulation.
3197

    
3198
On M68K this implements the "ColdFire GDB" interface used by libgloss.
3199

    
3200
Note that this allows guest direct access to the host filesystem,
3201
so should only be used with trusted guest OS.
3202

    
3203
@end table
3204

    
3205
@node QEMU User space emulator
3206
@chapter QEMU User space emulator
3207

    
3208
@menu
3209
* Supported Operating Systems ::
3210
* Linux User space emulator::
3211
* Mac OS X/Darwin User space emulator ::
3212
* BSD User space emulator ::
3213
@end menu
3214

    
3215
@node Supported Operating Systems
3216
@section Supported Operating Systems
3217

    
3218
The following OS are supported in user space emulation:
3219

    
3220
@itemize @minus
3221
@item
3222
Linux (referred as qemu-linux-user)
3223
@item
3224
Mac OS X/Darwin (referred as qemu-darwin-user)
3225
@item
3226
BSD (referred as qemu-bsd-user)
3227
@end itemize
3228

    
3229
@node Linux User space emulator
3230
@section Linux User space emulator
3231

    
3232
@menu
3233
* Quick Start::
3234
* Wine launch::
3235
* Command line options::
3236
* Other binaries::
3237
@end menu
3238

    
3239
@node Quick Start
3240
@subsection Quick Start
3241

    
3242
In order to launch a Linux process, QEMU needs the process executable
3243
itself and all the target (x86) dynamic libraries used by it.
3244

    
3245
@itemize
3246

    
3247
@item On x86, you can just try to launch any process by using the native
3248
libraries:
3249

    
3250
@example
3251
qemu-i386 -L / /bin/ls
3252
@end example
3253

    
3254
@code{-L /} tells that the x86 dynamic linker must be searched with a
3255
@file{/} prefix.
3256

    
3257
@item Since QEMU is also a linux process, you can launch qemu with
3258
qemu (NOTE: you can only do that if you compiled QEMU from the sources):
3259

    
3260
@example
3261
qemu-i386 -L / qemu-i386 -L / /bin/ls
3262
@end example
3263

    
3264
@item On non x86 CPUs, you need first to download at least an x86 glibc
3265
(@file{qemu-runtime-i386-XXX-.tar.gz} on the QEMU web page). Ensure that
3266
@code{LD_LIBRARY_PATH} is not set:
3267

    
3268
@example
3269
unset LD_LIBRARY_PATH
3270
@end example
3271

    
3272
Then you can launch the precompiled @file{ls} x86 executable:
3273

    
3274
@example
3275
qemu-i386 tests/i386/ls
3276
@end example
3277
You can look at @file{qemu-binfmt-conf.sh} so that
3278
QEMU is automatically launched by the Linux kernel when you try to
3279
launch x86 executables. It requires the @code{binfmt_misc} module in the
3280
Linux kernel.
3281

    
3282
@item The x86 version of QEMU is also included. You can try weird things such as:
3283
@example
3284
qemu-i386 /usr/local/qemu-i386/bin/qemu-i386 \
3285
          /usr/local/qemu-i386/bin/ls-i386
3286
@end example
3287

    
3288
@end itemize
3289

    
3290
@node Wine launch
3291
@subsection Wine launch
3292

    
3293
@itemize
3294

    
3295
@item Ensure that you have a working QEMU with the x86 glibc
3296
distribution (see previous section). In order to verify it, you must be
3297
able to do:
3298

    
3299
@example
3300
qemu-i386 /usr/local/qemu-i386/bin/ls-i386
3301
@end example
3302

    
3303
@item Download the binary x86 Wine install
3304
(@file{qemu-XXX-i386-wine.tar.gz} on the QEMU web page).
3305

    
3306
@item Configure Wine on your account. Look at the provided script
3307
@file{/usr/local/qemu-i386/@/bin/wine-conf.sh}. Your previous
3308
@code{$@{HOME@}/.wine} directory is saved to @code{$@{HOME@}/.wine.org}.
3309

    
3310
@item Then you can try the example @file{putty.exe}:
3311

    
3312
@example
3313
qemu-i386 /usr/local/qemu-i386/wine/bin/wine \
3314
          /usr/local/qemu-i386/wine/c/Program\ Files/putty.exe
3315
@end example
3316

    
3317
@end itemize
3318

    
3319
@node Command line options
3320
@subsection Command line options
3321

    
3322
@example
3323
usage: qemu-i386 [-h] [-d] [-L path] [-s size] [-cpu model] [-g port] program [arguments...]
3324
@end example
3325

    
3326
@table @option
3327
@item -h
3328
Print the help
3329
@item -L path
3330
Set the x86 elf interpreter prefix (default=/usr/local/qemu-i386)
3331
@item -s size
3332
Set the x86 stack size in bytes (default=524288)
3333
@item -cpu model
3334
Select CPU model (-cpu ? for list and additional feature selection)
3335
@end table
3336

    
3337
Debug options:
3338

    
3339
@table @option
3340
@item -d
3341
Activate log (logfile=/tmp/qemu.log)
3342
@item -p pagesize
3343
Act as if the host page size was 'pagesize' bytes
3344
@item -g port
3345
Wait gdb connection to port
3346
@end table
3347

    
3348
Environment variables:
3349

    
3350
@table @env
3351
@item QEMU_STRACE
3352
Print system calls and arguments similar to the 'strace' program
3353
(NOTE: the actual 'strace' program will not work because the user
3354
space emulator hasn't implemented ptrace).  At the moment this is
3355
incomplete.  All system calls that don't have a specific argument
3356
format are printed with information for six arguments.  Many
3357
flag-style arguments don't have decoders and will show up as numbers.
3358
@end table
3359

    
3360
@node Other binaries
3361
@subsection Other binaries
3362

    
3363
@command{qemu-arm} is also capable of running ARM "Angel" semihosted ELF
3364
binaries (as implemented by the arm-elf and arm-eabi Newlib/GDB
3365
configurations), and arm-uclinux bFLT format binaries.
3366

    
3367
@command{qemu-m68k} is capable of running semihosted binaries using the BDM
3368
(m5xxx-ram-hosted.ld) or m68k-sim (sim.ld) syscall interfaces, and
3369
coldfire uClinux bFLT format binaries.
3370

    
3371
The binary format is detected automatically.
3372

    
3373
@command{qemu-sparc} can execute Sparc32 binaries (Sparc32 CPU, 32 bit ABI).
3374

    
3375
@command{qemu-sparc32plus} can execute Sparc32 and SPARC32PLUS binaries
3376
(Sparc64 CPU, 32 bit ABI).
3377

    
3378
@command{qemu-sparc64} can execute some Sparc64 (Sparc64 CPU, 64 bit ABI) and
3379
SPARC32PLUS binaries (Sparc64 CPU, 32 bit ABI).
3380

    
3381
@node Mac OS X/Darwin User space emulator
3382
@section Mac OS X/Darwin User space emulator
3383

    
3384
@menu
3385
* Mac OS X/Darwin Status::
3386
* Mac OS X/Darwin Quick Start::
3387
* Mac OS X/Darwin Command line options::
3388
@end menu
3389

    
3390
@node Mac OS X/Darwin Status
3391
@subsection Mac OS X/Darwin Status
3392

    
3393
@itemize @minus
3394
@item
3395
target x86 on x86: Most apps (Cocoa and Carbon too) works. [1]
3396
@item
3397
target PowerPC on x86: Not working as the ppc commpage can't be mapped (yet!)
3398
@item
3399
target PowerPC on PowerPC: Most apps (Cocoa and Carbon too) works. [1]
3400
@item
3401
target x86 on PowerPC: most utilities work. Cocoa and Carbon apps are not yet supported.
3402
@end itemize
3403

    
3404
[1] If you're host commpage can be executed by qemu.
3405

    
3406
@node Mac OS X/Darwin Quick Start
3407
@subsection Quick Start
3408

    
3409
In order to launch a Mac OS X/Darwin process, QEMU needs the process executable
3410
itself and all the target dynamic libraries used by it. If you don't have the FAT
3411
libraries (you're running Mac OS X/ppc) you'll need to obtain it from a Mac OS X
3412
CD or compile them by hand.
3413

    
3414
@itemize
3415

    
3416
@item On x86, you can just try to launch any process by using the native
3417
libraries:
3418

    
3419
@example
3420
qemu-i386 /bin/ls
3421
@end example
3422

    
3423
or to run the ppc version of the executable:
3424

    
3425
@example
3426
qemu-ppc /bin/ls
3427
@end example
3428

    
3429
@item On ppc, you'll have to tell qemu where your x86 libraries (and dynamic linker)
3430
are installed:
3431

    
3432
@example
3433
qemu-i386 -L /opt/x86_root/ /bin/ls
3434
@end example
3435

    
3436
@code{-L /opt/x86_root/} tells that the dynamic linker (dyld) path is in
3437
@file{/opt/x86_root/usr/bin/dyld}.
3438

    
3439
@end itemize
3440

    
3441
@node Mac OS X/Darwin Command line options
3442
@subsection Command line options
3443

    
3444
@example
3445
usage: qemu-i386 [-h] [-d] [-L path] [-s size] program [arguments...]
3446
@end example
3447

    
3448
@table @option
3449
@item -h
3450
Print the help
3451
@item -L path
3452
Set the library root path (default=/)
3453
@item -s size
3454
Set the stack size in bytes (default=524288)
3455
@end table
3456

    
3457
Debug options:
3458

    
3459
@table @option
3460
@item -d
3461
Activate log (logfile=/tmp/qemu.log)
3462
@item -p pagesize
3463
Act as if the host page size was 'pagesize' bytes
3464
@end table
3465

    
3466
@node BSD User space emulator
3467
@section BSD User space emulator
3468

    
3469
@menu
3470
* BSD Status::
3471
* BSD Quick Start::
3472
* BSD Command line options::
3473
@end menu
3474

    
3475
@node BSD Status
3476
@subsection BSD Status
3477

    
3478
@itemize @minus
3479
@item
3480
target Sparc64 on Sparc64: Some trivial programs work.
3481
@end itemize
3482

    
3483
@node BSD Quick Start
3484
@subsection Quick Start
3485

    
3486
In order to launch a BSD process, QEMU needs the process executable
3487
itself and all the target dynamic libraries used by it.
3488

    
3489
@itemize
3490

    
3491
@item On Sparc64, you can just try to launch any process by using the native
3492
libraries:
3493

    
3494
@example
3495
qemu-sparc64 /bin/ls
3496
@end example
3497

    
3498
@end itemize
3499

    
3500
@node BSD Command line options
3501
@subsection Command line options
3502

    
3503
@example
3504
usage: qemu-sparc64 [-h] [-d] [-L path] [-s size] [-bsd type] program [arguments...]
3505
@end example
3506

    
3507
@table @option
3508
@item -h
3509
Print the help
3510
@item -L path
3511
Set the library root path (default=/)
3512
@item -s size
3513
Set the stack size in bytes (default=524288)
3514
@item -bsd type
3515
Set the type of the emulated BSD Operating system. Valid values are
3516
FreeBSD, NetBSD and OpenBSD (default).
3517
@end table
3518

    
3519
Debug options:
3520

    
3521
@table @option
3522
@item -d
3523
Activate log (logfile=/tmp/qemu.log)
3524
@item -p pagesize
3525
Act as if the host page size was 'pagesize' bytes
3526
@end table
3527

    
3528
@node compilation
3529
@chapter Compilation from the sources
3530

    
3531
@menu
3532
* Linux/Unix::
3533
* Windows::
3534
* Cross compilation for Windows with Linux::
3535
* Mac OS X::
3536
@end menu
3537

    
3538
@node Linux/Unix
3539
@section Linux/Unix
3540

    
3541
@subsection Compilation
3542

    
3543
First you must decompress the sources:
3544
@example
3545
cd /tmp
3546
tar zxvf qemu-x.y.z.tar.gz
3547
cd qemu-x.y.z
3548
@end example
3549

    
3550
Then you configure QEMU and build it (usually no options are needed):
3551
@example
3552
./configure
3553
make
3554
@end example
3555

    
3556
Then type as root user:
3557
@example
3558
make install
3559
@end example
3560
to install QEMU in @file{/usr/local}.
3561

    
3562
@subsection GCC version
3563

    
3564
In order to compile QEMU successfully, it is very important that you
3565
have the right tools. The most important one is gcc. On most hosts and
3566
in particular on x86 ones, @emph{gcc 4.x is not supported}. If your
3567
Linux distribution includes a gcc 4.x compiler, you can usually
3568
install an older version (it is invoked by @code{gcc32} or
3569
@code{gcc34}). The QEMU configure script automatically probes for
3570
these older versions so that usually you don't have to do anything.
3571

    
3572
@node Windows
3573
@section Windows
3574

    
3575
@itemize
3576
@item Install the current versions of MSYS and MinGW from
3577
@url{http://www.mingw.org/}. You can find detailed installation
3578
instructions in the download section and the FAQ.
3579

    
3580
@item Download
3581
the MinGW development library of SDL 1.2.x
3582
(@file{SDL-devel-1.2.x-@/mingw32.tar.gz}) from
3583
@url{http://www.libsdl.org}. Unpack it in a temporary place, and
3584
unpack the archive @file{i386-mingw32msvc.tar.gz} in the MinGW tool
3585
directory. Edit the @file{sdl-config} script so that it gives the
3586
correct SDL directory when invoked.
3587

    
3588
@item Extract the current version of QEMU.
3589

    
3590
@item Start the MSYS shell (file @file{msys.bat}).
3591

    
3592
@item Change to the QEMU directory. Launch @file{./configure} and
3593
@file{make}.  If you have problems using SDL, verify that
3594
@file{sdl-config} can be launched from the MSYS command line.
3595

    
3596
@item You can install QEMU in @file{Program Files/Qemu} by typing
3597
@file{make install}. Don't forget to copy @file{SDL.dll} in
3598
@file{Program Files/Qemu}.
3599

    
3600
@end itemize
3601

    
3602
@node Cross compilation for Windows with Linux
3603
@section Cross compilation for Windows with Linux
3604

    
3605
@itemize
3606
@item
3607
Install the MinGW cross compilation tools available at
3608
@url{http://www.mingw.org/}.
3609

    
3610
@item
3611
Install the Win32 version of SDL (@url{http://www.libsdl.org}) by
3612
unpacking @file{i386-mingw32msvc.tar.gz}. Set up the PATH environment
3613
variable so that @file{i386-mingw32msvc-sdl-config} can be launched by
3614
the QEMU configuration script.
3615

    
3616
@item
3617
Configure QEMU for Windows cross compilation:
3618
@example
3619
./configure --enable-mingw32
3620
@end example
3621
If necessary, you can change the cross-prefix according to the prefix
3622
chosen for the MinGW tools with --cross-prefix. You can also use
3623
--prefix to set the Win32 install path.
3624

    
3625
@item You can install QEMU in the installation directory by typing
3626
@file{make install}. Don't forget to copy @file{SDL.dll} in the
3627
installation directory.
3628

    
3629
@end itemize
3630

    
3631
Note: Currently, Wine does not seem able to launch
3632
QEMU for Win32.
3633

    
3634
@node Mac OS X
3635
@section Mac OS X
3636

    
3637
The Mac OS X patches are not fully merged in QEMU, so you should look
3638
at the QEMU mailing list archive to have all the necessary
3639
information.
3640

    
3641
@node Index
3642
@chapter Index
3643
@printindex cp
3644

    
3645
@bye