]> git.proxmox.com Git - mirror_qemu.git/blame - qemu-doc.texi
virtiofsd: Pass write iov's all the way through
[mirror_qemu.git] / qemu-doc.texi
CommitLineData
386405f7 1\input texinfo @c -*- texinfo -*-
debc7065
FB
2@c %**start of header
3@setfilename qemu-doc.info
44cb280d 4@include version.texi
e080e785
SW
5
6@documentlanguage en
7@documentencoding UTF-8
8
44cb280d 9@settitle QEMU version @value{VERSION} User Documentation
debc7065
FB
10@exampleindent 0
11@paragraphindent 0
12@c %**end of header
386405f7 13
664785ac
TH
14@set qemu_system qemu-system-x86_64
15@set qemu_system_x86 qemu-system-x86_64
16
a1a32b05
SW
17@ifinfo
18@direntry
19* QEMU: (qemu-doc). The QEMU Emulator User Documentation.
20@end direntry
21@end ifinfo
22
0806e3f6 23@iftex
386405f7
FB
24@titlepage
25@sp 7
44cb280d 26@center @titlefont{QEMU version @value{VERSION}}
debc7065
FB
27@sp 1
28@center @titlefont{User Documentation}
386405f7
FB
29@sp 3
30@end titlepage
0806e3f6 31@end iftex
386405f7 32
debc7065
FB
33@ifnottex
34@node Top
35@top
36
37@menu
38* Introduction::
debc7065
FB
39* QEMU PC System emulator::
40* QEMU System emulator for non PC targets::
83195237 41* QEMU User space emulator::
483c6ad4 42* System requirements::
e8412576 43* Security::
78e87797 44* Implementation notes::
eb22aeca 45* Deprecated features::
369e8f5b 46* Recently removed features::
45b47130 47* Supported build platforms::
7544a042 48* License::
debc7065
FB
49* Index::
50@end menu
51@end ifnottex
52
53@contents
54
55@node Introduction
386405f7
FB
56@chapter Introduction
57
debc7065
FB
58@menu
59* intro_features:: Features
60@end menu
61
62@node intro_features
322d0c66 63@section Features
386405f7 64
1f673135
FB
65QEMU is a FAST! processor emulator using dynamic translation to
66achieve good emulation speed.
1eb20527 67
1f3e7e41 68@cindex operating modes
1eb20527 69QEMU has two operating modes:
0806e3f6 70
d7e5edca 71@itemize
7544a042 72@cindex system emulation
1f3e7e41 73@item Full system emulation. In this mode, QEMU emulates a full system (for
3f9f3aa1
FB
74example a PC), including one or several processors and various
75peripherals. It can be used to launch different Operating Systems
76without rebooting the PC or to debug system code.
1eb20527 77
7544a042 78@cindex user mode emulation
1f3e7e41 79@item User mode emulation. In this mode, QEMU can launch
83195237 80processes compiled for one CPU on another CPU. It can be used to
70b7fba9 81launch the Wine Windows API emulator (@url{https://www.winehq.org}) or
1f673135 82to ease cross-compilation and cross-debugging.
1eb20527
FB
83
84@end itemize
85
1f3e7e41
PB
86QEMU has the following features:
87
88@itemize
89@item QEMU can run without a host kernel driver and yet gives acceptable
90performance. It uses dynamic translation to native code for reasonable speed,
91with support for self-modifying code and precise exceptions.
92
93@item It is portable to several operating systems (GNU/Linux, *BSD, Mac OS X,
94Windows) and architectures.
95
96@item It performs accurate software emulation of the FPU.
97@end itemize
322d0c66 98
1f3e7e41 99QEMU user mode emulation has the following features:
52c00a5f 100@itemize
1f3e7e41
PB
101@item Generic Linux system call converter, including most ioctls.
102
103@item clone() emulation using native CPU clone() to use Linux scheduler for threads.
104
105@item Accurate signal handling by remapping host signals to target signals.
106@end itemize
107
108QEMU full system emulation has the following features:
109@itemize
110@item
111QEMU uses a full software MMU for maximum portability.
112
113@item
326c4c3c 114QEMU can optionally use an in-kernel accelerator, like kvm. The accelerators
1f3e7e41
PB
115execute most of the guest code natively, while
116continuing to emulate the rest of the machine.
117
118@item
119Various hardware devices can be emulated and in some cases, host
120devices (e.g. serial and parallel ports, USB, drives) can be used
121transparently by the guest Operating System. Host device passthrough
122can be used for talking to external physical peripherals (e.g. a
123webcam, modem or tape drive).
124
125@item
126Symmetric multiprocessing (SMP) support. Currently, an in-kernel
127accelerator is required to use more than one host CPU for emulation.
128
52c00a5f 129@end itemize
386405f7 130
0806e3f6 131
debc7065 132@node QEMU PC System emulator
3f9f3aa1 133@chapter QEMU PC System emulator
7544a042 134@cindex system emulation (PC)
1eb20527 135
debc7065
FB
136@menu
137* pcsys_introduction:: Introduction
138* pcsys_quickstart:: Quick Start
139* sec_invocation:: Invocation
a40db1b3
PM
140* pcsys_keys:: Keys in the graphical frontends
141* mux_keys:: Keys in the character backend multiplexer
debc7065 142* pcsys_monitor:: QEMU Monitor
2544e9e4 143* cpu_models:: CPU models
debc7065
FB
144* disk_images:: Disk Images
145* pcsys_network:: Network emulation
576fd0a1 146* pcsys_other_devs:: Other Devices
debc7065
FB
147* direct_linux_boot:: Direct Linux Boot
148* pcsys_usb:: USB emulation
f858dcae 149* vnc_security:: VNC security
5d19a6ea 150* network_tls:: TLS setup for network services
debc7065
FB
151* gdb_usage:: GDB usage
152* pcsys_os_specific:: Target OS specific information
153@end menu
154
155@node pcsys_introduction
0806e3f6
FB
156@section Introduction
157
158@c man begin DESCRIPTION
159
3f9f3aa1
FB
160The QEMU PC System emulator simulates the
161following peripherals:
0806e3f6
FB
162
163@itemize @minus
5fafdf24 164@item
15a34c63 165i440FX host PCI bridge and PIIX3 PCI to ISA bridge
0806e3f6 166@item
15a34c63
FB
167Cirrus CLGD 5446 PCI VGA card or dummy VGA card with Bochs VESA
168extensions (hardware level, including all non standard modes).
0806e3f6
FB
169@item
170PS/2 mouse and keyboard
5fafdf24 171@item
15a34c63 1722 PCI IDE interfaces with hard disk and CD-ROM support
1f673135
FB
173@item
174Floppy disk
5fafdf24 175@item
3a2eeac0 176PCI and ISA network adapters
0806e3f6 177@item
05d5818c
FB
178Serial ports
179@item
23076bb3
CM
180IPMI BMC, either and internal or external one
181@item
c0fe3827
FB
182Creative SoundBlaster 16 sound card
183@item
184ENSONIQ AudioPCI ES1370 sound card
185@item
e5c9a13e
AZ
186Intel 82801AA AC97 Audio compatible sound card
187@item
7d72e762
GH
188Intel HD Audio Controller and HDA codec
189@item
2d983446 190Adlib (OPL2) - Yamaha YM3812 compatible chip
b389dbfb 191@item
26463dbc
AZ
192Gravis Ultrasound GF1 sound card
193@item
cc53d26d 194CS4231A compatible sound card
195@item
a92ff8c1 196PCI UHCI, OHCI, EHCI or XHCI USB controller and a virtual USB-1.1 hub.
0806e3f6
FB
197@end itemize
198
3f9f3aa1
FB
199SMP is supported with up to 255 CPUs.
200
a8ad4159 201QEMU uses the PC BIOS from the Seabios project and the Plex86/Bochs LGPL
15a34c63
FB
202VGA BIOS.
203
c0fe3827
FB
204QEMU uses YM3812 emulation by Tatsuyuki Satoh.
205
2d983446 206QEMU uses GUS emulation (GUSEMU32 @url{http://www.deinmeister.de/gusemu/})
26463dbc 207by Tibor "TS" Schütz.
423d65f4 208
1a1a0e20 209Note that, by default, GUS shares IRQ(7) with parallel ports and so
b65ee4fa 210QEMU must be told to not have parallel ports to have working GUS.
720036a5 211
212@example
664785ac 213@value{qemu_system_x86} dos.img -soundhw gus -parallel none
720036a5 214@end example
215
216Alternatively:
217@example
664785ac 218@value{qemu_system_x86} dos.img -device gus,irq=5
720036a5 219@end example
220
221Or some other unclaimed IRQ.
222
cc53d26d 223CS4231A is the chip used in Windows Sound System and GUSMAX products
224
0806e3f6
FB
225@c man end
226
debc7065 227@node pcsys_quickstart
1eb20527 228@section Quick Start
7544a042 229@cindex quick start
1eb20527 230
664785ac
TH
231Download and uncompress a hard disk image with Linux installed (e.g.
232@file{linux.img}) and type:
0806e3f6
FB
233
234@example
664785ac 235@value{qemu_system} linux.img
0806e3f6
FB
236@end example
237
238Linux should boot and give you a prompt.
239
6cc721cf 240@node sec_invocation
ec410fc9
FB
241@section Invocation
242
243@example
0806e3f6 244@c man begin SYNOPSIS
664785ac 245@command{@value{qemu_system}} [@var{options}] [@var{disk_image}]
0806e3f6 246@c man end
ec410fc9
FB
247@end example
248
0806e3f6 249@c man begin OPTIONS
d2c639d6
BS
250@var{disk_image} is a raw hard disk image for IDE hard disk 0. Some
251targets do not need a disk image.
ec410fc9 252
5824d651 253@include qemu-options.texi
ec410fc9 254
3e11db9a
FB
255@c man end
256
e896d0f9
MA
257@subsection Device URL Syntax
258@c TODO merge this with section Disk Images
259
260@c man begin NOTES
261
262In addition to using normal file images for the emulated storage devices,
263QEMU can also use networked resources such as iSCSI devices. These are
264specified using a special URL syntax.
265
266@table @option
267@item iSCSI
268iSCSI support allows QEMU to access iSCSI resources directly and use as
269images for the guest storage. Both disk and cdrom images are supported.
270
271Syntax for specifying iSCSI LUNs is
272``iscsi://<target-ip>[:<port>]/<target-iqn>/<lun>''
273
274By default qemu will use the iSCSI initiator-name
275'iqn.2008-11.org.linux-kvm[:<name>]' but this can also be set from the command
276line or a configuration file.
277
278Since version Qemu 2.4 it is possible to specify a iSCSI request timeout to detect
279stalled requests and force a reestablishment of the session. The timeout
280is specified in seconds. The default is 0 which means no timeout. Libiscsi
2811.15.0 or greater is required for this feature.
282
283Example (without authentication):
284@example
664785ac 285@value{qemu_system} -iscsi initiator-name=iqn.2001-04.com.example:my-initiator \
e896d0f9
MA
286 -cdrom iscsi://192.0.2.1/iqn.2001-04.com.example/2 \
287 -drive file=iscsi://192.0.2.1/iqn.2001-04.com.example/1
288@end example
289
290Example (CHAP username/password via URL):
291@example
664785ac 292@value{qemu_system} -drive file=iscsi://user%password@@192.0.2.1/iqn.2001-04.com.example/1
e896d0f9
MA
293@end example
294
295Example (CHAP username/password via environment variables):
296@example
297LIBISCSI_CHAP_USERNAME="user" \
298LIBISCSI_CHAP_PASSWORD="password" \
664785ac 299@value{qemu_system} -drive file=iscsi://192.0.2.1/iqn.2001-04.com.example/1
e896d0f9
MA
300@end example
301
302@item NBD
303QEMU supports NBD (Network Block Devices) both using TCP protocol as well
0c61ebb0 304as Unix Domain Sockets. With TCP, the default port is 10809.
e896d0f9 305
0c61ebb0
EB
306Syntax for specifying a NBD device using TCP, in preferred URI form:
307``nbd://<server-ip>[:<port>]/[<export>]''
308
309Syntax for specifying a NBD device using Unix Domain Sockets; remember
310that '?' is a shell glob character and may need quoting:
311``nbd+unix:///[<export>]?socket=<domain-socket>''
312
313Older syntax that is also recognized:
e896d0f9
MA
314``nbd:<server-ip>:<port>[:exportname=<export>]''
315
316Syntax for specifying a NBD device using Unix Domain Sockets
317``nbd:unix:<domain-socket>[:exportname=<export>]''
318
319Example for TCP
320@example
664785ac 321@value{qemu_system} --drive file=nbd:192.0.2.1:30000
e896d0f9
MA
322@end example
323
324Example for Unix Domain Sockets
325@example
664785ac 326@value{qemu_system} --drive file=nbd:unix:/tmp/nbd-socket
e896d0f9
MA
327@end example
328
329@item SSH
330QEMU supports SSH (Secure Shell) access to remote disks.
331
332Examples:
333@example
664785ac
TH
334@value{qemu_system} -drive file=ssh://user@@host/path/to/disk.img
335@value{qemu_system} -drive file.driver=ssh,file.user=user,file.host=host,file.port=22,file.path=/path/to/disk.img
e896d0f9
MA
336@end example
337
338Currently authentication must be done using ssh-agent. Other
339authentication methods may be supported in future.
340
341@item Sheepdog
342Sheepdog is a distributed storage system for QEMU.
343QEMU supports using either local sheepdog devices or remote networked
344devices.
345
346Syntax for specifying a sheepdog device
347@example
348sheepdog[+tcp|+unix]://[host:port]/vdiname[?socket=path][#snapid|#tag]
349@end example
350
351Example
352@example
664785ac 353@value{qemu_system} --drive file=sheepdog://192.0.2.1:30000/MyVirtualMachine
e896d0f9
MA
354@end example
355
356See also @url{https://sheepdog.github.io/sheepdog/}.
357
358@item GlusterFS
359GlusterFS is a user space distributed file system.
360QEMU supports the use of GlusterFS volumes for hosting VM disk images using
361TCP, Unix Domain Sockets and RDMA transport protocols.
362
363Syntax for specifying a VM disk image on GlusterFS volume is
364@example
365
366URI:
367gluster[+type]://[host[:port]]/volume/path[?socket=...][,debug=N][,logfile=...]
368
369JSON:
370'json:@{"driver":"qcow2","file":@{"driver":"gluster","volume":"testvol","path":"a.img","debug":N,"logfile":"...",
371@ "server":[@{"type":"tcp","host":"...","port":"..."@},
372@ @{"type":"unix","socket":"..."@}]@}@}'
373@end example
374
375
376Example
377@example
378URI:
664785ac 379@value{qemu_system} --drive file=gluster://192.0.2.1/testvol/a.img,
e896d0f9
MA
380@ file.debug=9,file.logfile=/var/log/qemu-gluster.log
381
382JSON:
664785ac 383@value{qemu_system} 'json:@{"driver":"qcow2",
e896d0f9
MA
384@ "file":@{"driver":"gluster",
385@ "volume":"testvol","path":"a.img",
386@ "debug":9,"logfile":"/var/log/qemu-gluster.log",
387@ "server":[@{"type":"tcp","host":"1.2.3.4","port":24007@},
388@ @{"type":"unix","socket":"/var/run/glusterd.socket"@}]@}@}'
664785ac 389@value{qemu_system} -drive driver=qcow2,file.driver=gluster,file.volume=testvol,file.path=/path/a.img,
e896d0f9
MA
390@ file.debug=9,file.logfile=/var/log/qemu-gluster.log,
391@ file.server.0.type=tcp,file.server.0.host=1.2.3.4,file.server.0.port=24007,
392@ file.server.1.type=unix,file.server.1.socket=/var/run/glusterd.socket
393@end example
394
395See also @url{http://www.gluster.org}.
396
397@item HTTP/HTTPS/FTP/FTPS
398QEMU supports read-only access to files accessed over http(s) and ftp(s).
399
400Syntax using a single filename:
401@example
402<protocol>://[<username>[:<password>]@@]<host>/<path>
403@end example
404
405where:
406@table @option
407@item protocol
408'http', 'https', 'ftp', or 'ftps'.
409
410@item username
411Optional username for authentication to the remote server.
412
413@item password
414Optional password for authentication to the remote server.
415
416@item host
417Address of the remote server.
418
419@item path
420Path on the remote server, including any query string.
421@end table
422
423The following options are also supported:
424@table @option
425@item url
426The full URL when passing options to the driver explicitly.
427
428@item readahead
429The amount of data to read ahead with each range request to the remote server.
430This value may optionally have the suffix 'T', 'G', 'M', 'K', 'k' or 'b'. If it
431does not have a suffix, it will be assumed to be in bytes. The value must be a
432multiple of 512 bytes. It defaults to 256k.
433
434@item sslverify
435Whether to verify the remote server's certificate when connecting over SSL. It
436can have the value 'on' or 'off'. It defaults to 'on'.
437
438@item cookie
439Send this cookie (it can also be a list of cookies separated by ';') with
440each outgoing request. Only supported when using protocols such as HTTP
441which support cookies, otherwise ignored.
442
443@item timeout
444Set the timeout in seconds of the CURL connection. This timeout is the time
445that CURL waits for a response from the remote server to get the size of the
446image to be downloaded. If not set, the default timeout of 5 seconds is used.
447@end table
448
449Note that when passing options to qemu explicitly, @option{driver} is the value
450of <protocol>.
451
452Example: boot from a remote Fedora 20 live ISO image
453@example
93bbbdf6 454@value{qemu_system_x86} --drive media=cdrom,file=https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/20/Live/x86_64/Fedora-Live-Desktop-x86_64-20-1.iso,readonly
e896d0f9 455
93bbbdf6 456@value{qemu_system_x86} --drive media=cdrom,file.driver=http,file.url=http://archives.fedoraproject.org/pub/fedora/linux/releases/20/Live/x86_64/Fedora-Live-Desktop-x86_64-20-1.iso,readonly
e896d0f9
MA
457@end example
458
459Example: boot from a remote Fedora 20 cloud image using a local overlay for
460writes, copy-on-read, and a readahead of 64k
461@example
93bbbdf6 462qemu-img create -f qcow2 -o backing_file='json:@{"file.driver":"http",, "file.url":"http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/20/Images/x86_64/Fedora-x86_64-20-20131211.1-sda.qcow2",, "file.readahead":"64k"@}' /tmp/Fedora-x86_64-20-20131211.1-sda.qcow2
e896d0f9 463
664785ac 464@value{qemu_system_x86} -drive file=/tmp/Fedora-x86_64-20-20131211.1-sda.qcow2,copy-on-read=on
e896d0f9
MA
465@end example
466
467Example: boot from an image stored on a VMware vSphere server with a self-signed
468certificate using a local overlay for writes, a readahead of 64k and a timeout
469of 10 seconds.
470@example
471qemu-img create -f qcow2 -o backing_file='json:@{"file.driver":"https",, "file.url":"https://user:password@@vsphere.example.com/folder/test/test-flat.vmdk?dcPath=Datacenter&dsName=datastore1",, "file.sslverify":"off",, "file.readahead":"64k",, "file.timeout":10@}' /tmp/test.qcow2
472
664785ac 473@value{qemu_system_x86} -drive file=/tmp/test.qcow2
e896d0f9
MA
474@end example
475
476@end table
477
478@c man end
479
debc7065 480@node pcsys_keys
a40db1b3 481@section Keys in the graphical frontends
3e11db9a
FB
482
483@c man begin OPTIONS
484
de1db2a1
BH
485During the graphical emulation, you can use special key combinations to change
486modes. The default key mappings are shown below, but if you use @code{-alt-grab}
487then the modifier is Ctrl-Alt-Shift (instead of Ctrl-Alt) and if you use
488@code{-ctrl-grab} then the modifier is the right Ctrl key (instead of Ctrl-Alt):
489
a1b74fe8 490@table @key
f9859310 491@item Ctrl-Alt-f
7544a042 492@kindex Ctrl-Alt-f
a1b74fe8 493Toggle full screen
a0a821a4 494
d6a65ba3
JK
495@item Ctrl-Alt-+
496@kindex Ctrl-Alt-+
497Enlarge the screen
498
499@item Ctrl-Alt--
500@kindex Ctrl-Alt--
501Shrink the screen
502
c4a735f9 503@item Ctrl-Alt-u
7544a042 504@kindex Ctrl-Alt-u
c4a735f9 505Restore the screen's un-scaled dimensions
506
f9859310 507@item Ctrl-Alt-n
7544a042 508@kindex Ctrl-Alt-n
a0a821a4
FB
509Switch to virtual console 'n'. Standard console mappings are:
510@table @emph
511@item 1
512Target system display
513@item 2
514Monitor
515@item 3
516Serial port
a1b74fe8
FB
517@end table
518
f9859310 519@item Ctrl-Alt
7544a042 520@kindex Ctrl-Alt
a0a821a4
FB
521Toggle mouse and keyboard grab.
522@end table
523
7544a042
SW
524@kindex Ctrl-Up
525@kindex Ctrl-Down
526@kindex Ctrl-PageUp
527@kindex Ctrl-PageDown
3e11db9a
FB
528In the virtual consoles, you can use @key{Ctrl-Up}, @key{Ctrl-Down},
529@key{Ctrl-PageUp} and @key{Ctrl-PageDown} to move in the back log.
530
a40db1b3
PM
531@c man end
532
533@node mux_keys
534@section Keys in the character backend multiplexer
535
536@c man begin OPTIONS
537
538During emulation, if you are using a character backend multiplexer
539(which is the default if you are using @option{-nographic}) then
540several commands are available via an escape sequence. These
541key sequences all start with an escape character, which is @key{Ctrl-a}
542by default, but can be changed with @option{-echr}. The list below assumes
543you're using the default.
ec410fc9
FB
544
545@table @key
a1b74fe8 546@item Ctrl-a h
7544a042 547@kindex Ctrl-a h
ec410fc9 548Print this help
3b46e624 549@item Ctrl-a x
7544a042 550@kindex Ctrl-a x
366dfc52 551Exit emulator
3b46e624 552@item Ctrl-a s
7544a042 553@kindex Ctrl-a s
1f47a922 554Save disk data back to file (if -snapshot)
20d8a3ed 555@item Ctrl-a t
7544a042 556@kindex Ctrl-a t
d2c639d6 557Toggle console timestamps
a1b74fe8 558@item Ctrl-a b
7544a042 559@kindex Ctrl-a b
1f673135 560Send break (magic sysrq in Linux)
a1b74fe8 561@item Ctrl-a c
7544a042 562@kindex Ctrl-a c
a40db1b3
PM
563Rotate between the frontends connected to the multiplexer (usually
564this switches between the monitor and the console)
a1b74fe8 565@item Ctrl-a Ctrl-a
a40db1b3
PM
566@kindex Ctrl-a Ctrl-a
567Send the escape character to the frontend
ec410fc9 568@end table
0806e3f6
FB
569@c man end
570
571@ignore
572
1f673135
FB
573@c man begin SEEALSO
574The HTML documentation of QEMU for more precise information and Linux
575user mode emulator invocation.
576@c man end
577
578@c man begin AUTHOR
579Fabrice Bellard
580@c man end
581
582@end ignore
583
debc7065 584@node pcsys_monitor
1f673135 585@section QEMU Monitor
7544a042 586@cindex QEMU monitor
1f673135
FB
587
588The QEMU monitor is used to give complex commands to the QEMU
589emulator. You can use it to:
590
591@itemize @minus
592
593@item
e598752a 594Remove or insert removable media images
89dfe898 595(such as CD-ROM or floppies).
1f673135 596
5fafdf24 597@item
1f673135
FB
598Freeze/unfreeze the Virtual Machine (VM) and save or restore its state
599from a disk file.
600
601@item Inspect the VM state without an external debugger.
602
603@end itemize
604
605@subsection Commands
606
607The following commands are available:
608
2313086a 609@include qemu-monitor.texi
0806e3f6 610
2cd8af2d
PB
611@include qemu-monitor-info.texi
612
1f673135
FB
613@subsection Integer expressions
614
615The monitor understands integers expressions for every integer
616argument. You can use register names to get the value of specifics
617CPU registers by prefixing them with @emph{$}.
ec410fc9 618
2544e9e4
DB
619@node cpu_models
620@section CPU models
621
622@include docs/qemu-cpu-models.texi
623
1f47a922
FB
624@node disk_images
625@section Disk Images
626
ee29bdb6
PB
627QEMU supports many disk image formats, including growable disk images
628(their size increase as non empty sectors are written), compressed and
629encrypted disk images.
1f47a922 630
debc7065
FB
631@menu
632* disk_images_quickstart:: Quick start for disk image creation
633* disk_images_snapshot_mode:: Snapshot mode
13a2e80f 634* vm_snapshots:: VM snapshots
debc7065 635* qemu_img_invocation:: qemu-img Invocation
975b092b 636* qemu_nbd_invocation:: qemu-nbd Invocation
d3067b02 637* disk_images_formats:: Disk image file formats
19cb3738 638* host_drives:: Using host drives
debc7065 639* disk_images_fat_images:: Virtual FAT disk images
75818250 640* disk_images_nbd:: NBD access
42af9c30 641* disk_images_sheepdog:: Sheepdog disk images
00984e39 642* disk_images_iscsi:: iSCSI LUNs
8809e289 643* disk_images_gluster:: GlusterFS disk images
0a12ec87 644* disk_images_ssh:: Secure Shell (ssh) disk images
e86de5e4 645* disk_images_nvme:: NVMe userspace driver
b1d1cb27 646* disk_image_locking:: Disk image file locking
debc7065
FB
647@end menu
648
649@node disk_images_quickstart
acd935ef
FB
650@subsection Quick start for disk image creation
651
652You can create a disk image with the command:
1f47a922 653@example
acd935ef 654qemu-img create myimage.img mysize
1f47a922 655@end example
acd935ef
FB
656where @var{myimage.img} is the disk image filename and @var{mysize} is its
657size in kilobytes. You can add an @code{M} suffix to give the size in
658megabytes and a @code{G} suffix for gigabytes.
659
debc7065 660See @ref{qemu_img_invocation} for more information.
1f47a922 661
debc7065 662@node disk_images_snapshot_mode
1f47a922
FB
663@subsection Snapshot mode
664
665If you use the option @option{-snapshot}, all disk images are
666considered as read only. When sectors in written, they are written in
667a temporary file created in @file{/tmp}. You can however force the
acd935ef
FB
668write back to the raw disk images by using the @code{commit} monitor
669command (or @key{C-a s} in the serial console).
1f47a922 670
13a2e80f
FB
671@node vm_snapshots
672@subsection VM snapshots
673
674VM snapshots are snapshots of the complete virtual machine including
675CPU state, RAM, device state and the content of all the writable
676disks. In order to use VM snapshots, you must have at least one non
677removable and writable block device using the @code{qcow2} disk image
678format. Normally this device is the first virtual hard drive.
679
680Use the monitor command @code{savevm} to create a new VM snapshot or
681replace an existing one. A human readable name can be assigned to each
19d36792 682snapshot in addition to its numerical ID.
13a2e80f
FB
683
684Use @code{loadvm} to restore a VM snapshot and @code{delvm} to remove
685a VM snapshot. @code{info snapshots} lists the available snapshots
686with their associated information:
687
688@example
689(qemu) info snapshots
690Snapshot devices: hda
691Snapshot list (from hda):
692ID TAG VM SIZE DATE VM CLOCK
6931 start 41M 2006-08-06 12:38:02 00:00:14.954
6942 40M 2006-08-06 12:43:29 00:00:18.633
6953 msys 40M 2006-08-06 12:44:04 00:00:23.514
696@end example
697
698A VM snapshot is made of a VM state info (its size is shown in
699@code{info snapshots}) and a snapshot of every writable disk image.
700The VM state info is stored in the first @code{qcow2} non removable
701and writable block device. The disk image snapshots are stored in
702every disk image. The size of a snapshot in a disk image is difficult
703to evaluate and is not shown by @code{info snapshots} because the
704associated disk sectors are shared among all the snapshots to save
19d36792
FB
705disk space (otherwise each snapshot would need a full copy of all the
706disk images).
13a2e80f
FB
707
708When using the (unrelated) @code{-snapshot} option
709(@ref{disk_images_snapshot_mode}), you can always make VM snapshots,
710but they are deleted as soon as you exit QEMU.
711
712VM snapshots currently have the following known limitations:
713@itemize
5fafdf24 714@item
13a2e80f
FB
715They cannot cope with removable devices if they are removed or
716inserted after a snapshot is done.
5fafdf24 717@item
13a2e80f
FB
718A few device drivers still have incomplete snapshot support so their
719state is not saved or restored properly (in particular USB).
720@end itemize
721
acd935ef
FB
722@node qemu_img_invocation
723@subsection @code{qemu-img} Invocation
1f47a922 724
acd935ef 725@include qemu-img.texi
05efe46e 726
975b092b
TS
727@node qemu_nbd_invocation
728@subsection @code{qemu-nbd} Invocation
729
730@include qemu-nbd.texi
731
78aa8aa0 732@include docs/qemu-block-drivers.texi
0a12ec87 733
debc7065 734@node pcsys_network
9d4fb82e
FB
735@section Network emulation
736
0e0266c2
TH
737QEMU can simulate several network cards (e.g. PCI or ISA cards on the PC
738target) and can connect them to a network backend on the host or an emulated
739hub. The various host network backends can either be used to connect the NIC of
740the guest to a real network (e.g. by using a TAP devices or the non-privileged
741user mode network stack), or to other guest instances running in another QEMU
742process (e.g. by using the socket host network backend).
9d4fb82e 743
41d03949
FB
744@subsection Using TAP network interfaces
745
746This is the standard way to connect QEMU to a real network. QEMU adds
747a virtual network device on your host (called @code{tapN}), and you
748can then configure it as if it was a real ethernet card.
9d4fb82e 749
8f40c388
FB
750@subsubsection Linux host
751
9d4fb82e
FB
752As an example, you can download the @file{linux-test-xxx.tar.gz}
753archive and copy the script @file{qemu-ifup} in @file{/etc} and
754configure properly @code{sudo} so that the command @code{ifconfig}
755contained in @file{qemu-ifup} can be executed as root. You must verify
41d03949 756that your host kernel supports the TAP network interfaces: the
9d4fb82e
FB
757device @file{/dev/net/tun} must be present.
758
ee0f4751
FB
759See @ref{sec_invocation} to have examples of command lines using the
760TAP network interfaces.
9d4fb82e 761
8f40c388
FB
762@subsubsection Windows host
763
764There is a virtual ethernet driver for Windows 2000/XP systems, called
765TAP-Win32. But it is not included in standard QEMU for Windows,
766so you will need to get it separately. It is part of OpenVPN package,
70b7fba9 767so download OpenVPN from : @url{https://openvpn.net/}.
8f40c388 768
9d4fb82e
FB
769@subsection Using the user mode network stack
770
41d03949
FB
771By using the option @option{-net user} (default configuration if no
772@option{-net} option is specified), QEMU uses a completely user mode
4be456f1 773network stack (you don't need root privilege to use the virtual
41d03949 774network). The virtual network configuration is the following:
9d4fb82e
FB
775
776@example
777
0e0266c2 778 guest (10.0.2.15) <------> Firewall/DHCP server <-----> Internet
41d03949 779 | (10.0.2.2)
9d4fb82e 780 |
2518bd0d 781 ----> DNS server (10.0.2.3)
3b46e624 782 |
2518bd0d 783 ----> SMB server (10.0.2.4)
9d4fb82e
FB
784@end example
785
786The QEMU VM behaves as if it was behind a firewall which blocks all
787incoming connections. You can use a DHCP client to automatically
41d03949
FB
788configure the network in the QEMU VM. The DHCP server assign addresses
789to the hosts starting from 10.0.2.15.
9d4fb82e
FB
790
791In order to check that the user mode network is working, you can ping
792the address 10.0.2.2 and verify that you got an address in the range
79310.0.2.x from the QEMU virtual DHCP server.
794
37cbfcce
GH
795Note that ICMP traffic in general does not work with user mode networking.
796@code{ping}, aka. ICMP echo, to the local router (10.0.2.2) shall work,
797however. If you're using QEMU on Linux >= 3.0, it can use unprivileged ICMP
798ping sockets to allow @code{ping} to the Internet. The host admin has to set
799the ping_group_range in order to grant access to those sockets. To allow ping
800for GID 100 (usually users group):
801
802@example
803echo 100 100 > /proc/sys/net/ipv4/ping_group_range
804@end example
b415a407 805
9bf05444
FB
806When using the built-in TFTP server, the router is also the TFTP
807server.
808
c8c6afa8
TH
809When using the @option{'-netdev user,hostfwd=...'} option, TCP or UDP
810connections can be redirected from the host to the guest. It allows for
811example to redirect X11, telnet or SSH connections.
443f1376 812
0e0266c2
TH
813@subsection Hubs
814
815QEMU can simulate several hubs. A hub can be thought of as a virtual connection
816between several network devices. These devices can be for example QEMU virtual
817ethernet cards or virtual Host ethernet devices (TAP devices). You can connect
818guest NICs or host network backends to such a hub using the @option{-netdev
819hubport} or @option{-nic hubport} options. The legacy @option{-net} option
820also connects the given device to the emulated hub with ID 0 (i.e. the default
821hub) unless you specify a netdev with @option{-net nic,netdev=xxx} here.
41d03949 822
0e0266c2 823@subsection Connecting emulated networks between QEMU instances
41d03949 824
0e0266c2
TH
825Using the @option{-netdev socket} (or @option{-nic socket} or
826@option{-net socket}) option, it is possible to create emulated
827networks that span several QEMU instances.
828See the description of the @option{-netdev socket} option in the
829@ref{sec_invocation,,Invocation chapter} to have a basic example.
41d03949 830
576fd0a1 831@node pcsys_other_devs
6cbf4c8c
CM
832@section Other Devices
833
834@subsection Inter-VM Shared Memory device
835
5400c02b
MA
836On Linux hosts, a shared memory device is available. The basic syntax
837is:
6cbf4c8c
CM
838
839@example
664785ac 840@value{qemu_system_x86} -device ivshmem-plain,memdev=@var{hostmem}
5400c02b
MA
841@end example
842
843where @var{hostmem} names a host memory backend. For a POSIX shared
844memory backend, use something like
845
846@example
847-object memory-backend-file,size=1M,share,mem-path=/dev/shm/ivshmem,id=@var{hostmem}
6cbf4c8c
CM
848@end example
849
850If desired, interrupts can be sent between guest VMs accessing the same shared
851memory region. Interrupt support requires using a shared memory server and
852using a chardev socket to connect to it. The code for the shared memory server
853is qemu.git/contrib/ivshmem-server. An example syntax when using the shared
854memory server is:
855
856@example
a75eb03b 857# First start the ivshmem server once and for all
50d34c4e 858ivshmem-server -p @var{pidfile} -S @var{path} -m @var{shm-name} -l @var{shm-size} -n @var{vectors}
a75eb03b
DM
859
860# Then start your qemu instances with matching arguments
664785ac 861@value{qemu_system_x86} -device ivshmem-doorbell,vectors=@var{vectors},chardev=@var{id}
50d34c4e 862 -chardev socket,path=@var{path},id=@var{id}
6cbf4c8c
CM
863@end example
864
865When using the server, the guest will be assigned a VM ID (>=0) that allows guests
866using the same server to communicate via interrupts. Guests can read their
1309cf44 867VM ID from a device register (see ivshmem-spec.txt).
6cbf4c8c 868
62a830b6
MA
869@subsubsection Migration with ivshmem
870
5400c02b
MA
871With device property @option{master=on}, the guest will copy the shared
872memory on migration to the destination host. With @option{master=off},
873the guest will not be able to migrate with the device attached. In the
874latter case, the device should be detached and then reattached after
875migration using the PCI hotplug support.
6cbf4c8c 876
62a830b6
MA
877At most one of the devices sharing the same memory can be master. The
878master must complete migration before you plug back the other devices.
879
7d4f4bda
MAL
880@subsubsection ivshmem and hugepages
881
882Instead of specifying the <shm size> using POSIX shm, you may specify
883a memory backend that has hugepage support:
884
885@example
664785ac 886@value{qemu_system_x86} -object memory-backend-file,size=1G,mem-path=/dev/hugepages/my-shmem-file,share,id=mb1
5400c02b 887 -device ivshmem-plain,memdev=mb1
7d4f4bda
MAL
888@end example
889
890ivshmem-server also supports hugepages mount points with the
891@option{-m} memory path argument.
892
9d4fb82e
FB
893@node direct_linux_boot
894@section Direct Linux Boot
1f673135
FB
895
896This section explains how to launch a Linux kernel inside QEMU without
897having to make a full bootable image. It is very useful for fast Linux
ee0f4751 898kernel testing.
1f673135 899
ee0f4751 900The syntax is:
1f673135 901@example
664785ac 902@value{qemu_system} -kernel bzImage -hda rootdisk.img -append "root=/dev/hda"
1f673135
FB
903@end example
904
ee0f4751
FB
905Use @option{-kernel} to provide the Linux kernel image and
906@option{-append} to give the kernel command line arguments. The
907@option{-initrd} option can be used to provide an INITRD image.
1f673135 908
ee0f4751
FB
909If you do not need graphical output, you can disable it and redirect
910the virtual serial port and the QEMU monitor to the console with the
911@option{-nographic} option. The typical command line is:
1f673135 912@example
664785ac 913@value{qemu_system} -kernel bzImage -hda rootdisk.img \
3804da9d 914 -append "root=/dev/hda console=ttyS0" -nographic
1f673135
FB
915@end example
916
ee0f4751
FB
917Use @key{Ctrl-a c} to switch between the serial console and the
918monitor (@pxref{pcsys_keys}).
1f673135 919
debc7065 920@node pcsys_usb
b389dbfb
FB
921@section USB emulation
922
a92ff8c1
TH
923QEMU can emulate a PCI UHCI, OHCI, EHCI or XHCI USB controller. You can
924plug virtual USB devices or real host USB devices (only works with certain
925host operating systems). QEMU will automatically create and connect virtual
926USB hubs as necessary to connect multiple USB devices.
b389dbfb 927
0aff66b5
PB
928@menu
929* usb_devices::
930* host_usb_devices::
931@end menu
932@node usb_devices
933@subsection Connecting USB devices
b389dbfb 934
a92ff8c1
TH
935USB devices can be connected with the @option{-device usb-...} command line
936option or the @code{device_add} monitor command. Available devices are:
b389dbfb 937
db380c06 938@table @code
a92ff8c1 939@item usb-mouse
0aff66b5 940Virtual Mouse. This will override the PS/2 mouse emulation when activated.
a92ff8c1 941@item usb-tablet
c6d46c20 942Pointer device that uses absolute coordinates (like a touchscreen).
b65ee4fa 943This means QEMU is able to report the mouse position without having
0aff66b5 944to grab the mouse. Also overrides the PS/2 mouse emulation when activated.
a92ff8c1
TH
945@item usb-storage,drive=@var{drive_id}
946Mass storage device backed by @var{drive_id} (@pxref{disk_images})
947@item usb-uas
948USB attached SCSI device, see
70b7fba9 949@url{https://git.qemu.org/?p=qemu.git;a=blob_plain;f=docs/usb-storage.txt,usb-storage.txt}
a92ff8c1
TH
950for details
951@item usb-bot
952Bulk-only transport storage device, see
70b7fba9 953@url{https://git.qemu.org/?p=qemu.git;a=blob_plain;f=docs/usb-storage.txt,usb-storage.txt}
a92ff8c1 954for details here, too
1ee53067 955@item usb-mtp,rootdir=@var{dir}
a92ff8c1
TH
956Media transfer protocol device, using @var{dir} as root of the file tree
957that is presented to the guest.
958@item usb-host,hostbus=@var{bus},hostaddr=@var{addr}
959Pass through the host device identified by @var{bus} and @var{addr}
960@item usb-host,vendorid=@var{vendor},productid=@var{product}
961Pass through the host device identified by @var{vendor} and @var{product} ID
962@item usb-wacom-tablet
f6d2a316
AZ
963Virtual Wacom PenPartner tablet. This device is similar to the @code{tablet}
964above but it can be used with the tslib library because in addition to touch
965coordinates it reports touch pressure.
a92ff8c1 966@item usb-kbd
47b2d338 967Standard USB keyboard. Will override the PS/2 keyboard (if present).
a92ff8c1 968@item usb-serial,chardev=@var{id}
db380c06 969Serial converter. This emulates an FTDI FT232BM chip connected to host character
a92ff8c1
TH
970device @var{id}.
971@item usb-braille,chardev=@var{id}
2e4d9fb1 972Braille device. This will use BrlAPI to display the braille output on a real
a92ff8c1
TH
973or fake device referenced by @var{id}.
974@item usb-net[,netdev=@var{id}]
975Network adapter that supports CDC ethernet and RNDIS protocols. @var{id}
976specifies a netdev defined with @code{-netdev @dots{},id=@var{id}}.
9ad97e65 977For instance, user-mode networking can be used with
6c9f886c 978@example
664785ac 979@value{qemu_system} [...] -netdev user,id=net0 -device usb-net,netdev=net0
6c9f886c 980@end example
a92ff8c1
TH
981@item usb-ccid
982Smartcard reader device
983@item usb-audio
984USB audio device
0aff66b5 985@end table
b389dbfb 986
0aff66b5 987@node host_usb_devices
b389dbfb
FB
988@subsection Using host USB devices on a Linux host
989
990WARNING: this is an experimental feature. QEMU will slow down when
991using it. USB devices requiring real time streaming (i.e. USB Video
992Cameras) are not supported yet.
993
994@enumerate
5fafdf24 995@item If you use an early Linux 2.4 kernel, verify that no Linux driver
b389dbfb
FB
996is actually using the USB device. A simple way to do that is simply to
997disable the corresponding kernel module by renaming it from @file{mydriver.o}
998to @file{mydriver.o.disabled}.
999
1000@item Verify that @file{/proc/bus/usb} is working (most Linux distributions should enable it by default). You should see something like that:
1001@example
1002ls /proc/bus/usb
1003001 devices drivers
1004@end example
1005
1006@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:
1007@example
1008chown -R myuid /proc/bus/usb
1009@end example
1010
1011@item Launch QEMU and do in the monitor:
5fafdf24 1012@example
b389dbfb
FB
1013info usbhost
1014 Device 1.2, speed 480 Mb/s
1015 Class 00: USB device 1234:5678, USB DISK
1016@end example
1017You should see the list of the devices you can use (Never try to use
1018hubs, it won't work).
1019
1020@item Add the device in QEMU by using:
5fafdf24 1021@example
a92ff8c1 1022device_add usb-host,vendorid=0x1234,productid=0x5678
b389dbfb
FB
1023@end example
1024
a92ff8c1
TH
1025Normally the guest OS should report that a new USB device is plugged.
1026You can use the option @option{-device usb-host,...} to do the same.
b389dbfb
FB
1027
1028@item Now you can try to use the host USB device in QEMU.
1029
1030@end enumerate
1031
1032When relaunching QEMU, you may have to unplug and plug again the USB
1033device to make it work again (this is a bug).
1034
f858dcae
TS
1035@node vnc_security
1036@section VNC security
1037
1038The VNC server capability provides access to the graphical console
1039of the guest VM across the network. This has a number of security
1040considerations depending on the deployment scenarios.
1041
1042@menu
1043* vnc_sec_none::
1044* vnc_sec_password::
1045* vnc_sec_certificate::
1046* vnc_sec_certificate_verify::
1047* vnc_sec_certificate_pw::
2f9606b3
AL
1048* vnc_sec_sasl::
1049* vnc_sec_certificate_sasl::
2f9606b3 1050* vnc_setup_sasl::
f858dcae
TS
1051@end menu
1052@node vnc_sec_none
1053@subsection Without passwords
1054
1055The simplest VNC server setup does not include any form of authentication.
1056For this setup it is recommended to restrict it to listen on a UNIX domain
1057socket only. For example
1058
1059@example
664785ac 1060@value{qemu_system} [...OPTIONS...] -vnc unix:/home/joebloggs/.qemu-myvm-vnc
f858dcae
TS
1061@end example
1062
1063This ensures that only users on local box with read/write access to that
1064path can access the VNC server. To securely access the VNC server from a
1065remote machine, a combination of netcat+ssh can be used to provide a secure
1066tunnel.
1067
1068@node vnc_sec_password
1069@subsection With passwords
1070
1071The VNC protocol has limited support for password based authentication. Since
1072the protocol limits passwords to 8 characters it should not be considered
1073to provide high security. The password can be fairly easily brute-forced by
1074a client making repeat connections. For this reason, a VNC server using password
1075authentication should be restricted to only listen on the loopback interface
0f66998f
PM
1076or UNIX domain sockets. Password authentication is not supported when operating
1077in FIPS 140-2 compliance mode as it requires the use of the DES cipher. Password
1078authentication is requested with the @code{password} option, and then once QEMU
1079is running the password is set with the monitor. Until the monitor is used to
1080set the password all clients will be rejected.
f858dcae
TS
1081
1082@example
664785ac 1083@value{qemu_system} [...OPTIONS...] -vnc :1,password -monitor stdio
f858dcae
TS
1084(qemu) change vnc password
1085Password: ********
1086(qemu)
1087@end example
1088
1089@node vnc_sec_certificate
1090@subsection With x509 certificates
1091
1092The QEMU VNC server also implements the VeNCrypt extension allowing use of
1093TLS for encryption of the session, and x509 certificates for authentication.
1094The use of x509 certificates is strongly recommended, because TLS on its
1095own is susceptible to man-in-the-middle attacks. Basic x509 certificate
1096support provides a secure session, but no authentication. This allows any
1097client to connect, and provides an encrypted session.
1098
1099@example
664785ac 1100@value{qemu_system} [...OPTIONS...] \
756b9da7
DB
1101 -object tls-creds-x509,id=tls0,dir=/etc/pki/qemu,endpoint=server,verify-peer=no \
1102 -vnc :1,tls-creds=tls0 -monitor stdio
f858dcae
TS
1103@end example
1104
1105In the above example @code{/etc/pki/qemu} should contain at least three files,
1106@code{ca-cert.pem}, @code{server-cert.pem} and @code{server-key.pem}. Unprivileged
1107users will want to use a private directory, for example @code{$HOME/.pki/qemu}.
1108NB the @code{server-key.pem} file should be protected with file mode 0600 to
1109only be readable by the user owning it.
1110
1111@node vnc_sec_certificate_verify
1112@subsection With x509 certificates and client verification
1113
1114Certificates can also provide a means to authenticate the client connecting.
1115The server will request that the client provide a certificate, which it will
1116then validate against the CA certificate. This is a good choice if deploying
756b9da7
DB
1117in an environment with a private internal certificate authority. It uses the
1118same syntax as previously, but with @code{verify-peer} set to @code{yes}
1119instead.
f858dcae
TS
1120
1121@example
664785ac 1122@value{qemu_system} [...OPTIONS...] \
756b9da7
DB
1123 -object tls-creds-x509,id=tls0,dir=/etc/pki/qemu,endpoint=server,verify-peer=yes \
1124 -vnc :1,tls-creds=tls0 -monitor stdio
f858dcae
TS
1125@end example
1126
1127
1128@node vnc_sec_certificate_pw
1129@subsection With x509 certificates, client verification and passwords
1130
1131Finally, the previous method can be combined with VNC password authentication
1132to provide two layers of authentication for clients.
1133
1134@example
664785ac 1135@value{qemu_system} [...OPTIONS...] \
756b9da7
DB
1136 -object tls-creds-x509,id=tls0,dir=/etc/pki/qemu,endpoint=server,verify-peer=yes \
1137 -vnc :1,tls-creds=tls0,password -monitor stdio
f858dcae
TS
1138(qemu) change vnc password
1139Password: ********
1140(qemu)
1141@end example
1142
2f9606b3
AL
1143
1144@node vnc_sec_sasl
1145@subsection With SASL authentication
1146
1147The SASL authentication method is a VNC extension, that provides an
1148easily extendable, pluggable authentication method. This allows for
1149integration with a wide range of authentication mechanisms, such as
1150PAM, GSSAPI/Kerberos, LDAP, SQL databases, one-time keys and more.
1151The strength of the authentication depends on the exact mechanism
1152configured. If the chosen mechanism also provides a SSF layer, then
1153it will encrypt the datastream as well.
1154
1155Refer to the later docs on how to choose the exact SASL mechanism
1156used for authentication, but assuming use of one supporting SSF,
1157then QEMU can be launched with:
1158
1159@example
664785ac 1160@value{qemu_system} [...OPTIONS...] -vnc :1,sasl -monitor stdio
2f9606b3
AL
1161@end example
1162
1163@node vnc_sec_certificate_sasl
1164@subsection With x509 certificates and SASL authentication
1165
1166If the desired SASL authentication mechanism does not supported
1167SSF layers, then it is strongly advised to run it in combination
1168with TLS and x509 certificates. This provides securely encrypted
1169data stream, avoiding risk of compromising of the security
1170credentials. This can be enabled, by combining the 'sasl' option
1171with the aforementioned TLS + x509 options:
1172
1173@example
664785ac 1174@value{qemu_system} [...OPTIONS...] \
756b9da7
DB
1175 -object tls-creds-x509,id=tls0,dir=/etc/pki/qemu,endpoint=server,verify-peer=yes \
1176 -vnc :1,tls-creds=tls0,sasl -monitor stdio
2f9606b3
AL
1177@end example
1178
5d19a6ea
DB
1179@node vnc_setup_sasl
1180
1181@subsection Configuring SASL mechanisms
1182
1183The following documentation assumes use of the Cyrus SASL implementation on a
1184Linux host, but the principles should apply to any other SASL implementation
1185or host. When SASL is enabled, the mechanism configuration will be loaded from
1186system default SASL service config /etc/sasl2/qemu.conf. If running QEMU as an
1187unprivileged user, an environment variable SASL_CONF_PATH can be used to make
1188it search alternate locations for the service config file.
1189
1190If the TLS option is enabled for VNC, then it will provide session encryption,
1191otherwise the SASL mechanism will have to provide encryption. In the latter
1192case the list of possible plugins that can be used is drastically reduced. In
1193fact only the GSSAPI SASL mechanism provides an acceptable level of security
1194by modern standards. Previous versions of QEMU referred to the DIGEST-MD5
1195mechanism, however, it has multiple serious flaws described in detail in
1196RFC 6331 and thus should never be used any more. The SCRAM-SHA-1 mechanism
1197provides a simple username/password auth facility similar to DIGEST-MD5, but
1198does not support session encryption, so can only be used in combination with
1199TLS.
2f9606b3 1200
5d19a6ea 1201When not using TLS the recommended configuration is
f858dcae 1202
5d19a6ea
DB
1203@example
1204mech_list: gssapi
1205keytab: /etc/qemu/krb5.tab
1206@end example
1207
1208This says to use the 'GSSAPI' mechanism with the Kerberos v5 protocol, with
1209the server principal stored in /etc/qemu/krb5.tab. For this to work the
1210administrator of your KDC must generate a Kerberos principal for the server,
1211with a name of 'qemu/somehost.example.com@@EXAMPLE.COM' replacing
1212'somehost.example.com' with the fully qualified host name of the machine
1213running QEMU, and 'EXAMPLE.COM' with the Kerberos Realm.
1214
1215When using TLS, if username+password authentication is desired, then a
1216reasonable configuration is
1217
1218@example
1219mech_list: scram-sha-1
1220sasldb_path: /etc/qemu/passwd.db
1221@end example
1222
1223The @code{saslpasswd2} program can be used to populate the @code{passwd.db}
1224file with accounts.
1225
1226Other SASL configurations will be left as an exercise for the reader. Note that
1227all mechanisms, except GSSAPI, should be combined with use of TLS to ensure a
1228secure data channel.
1229
1230
1231@node network_tls
1232@section TLS setup for network services
1233
1234Almost all network services in QEMU have the ability to use TLS for
1235session data encryption, along with x509 certificates for simple
1236client authentication. What follows is a description of how to
1237generate certificates suitable for usage with QEMU, and applies to
1238the VNC server, character devices with the TCP backend, NBD server
1239and client, and migration server and client.
1240
1241At a high level, QEMU requires certificates and private keys to be
1242provided in PEM format. Aside from the core fields, the certificates
1243should include various extension data sets, including v3 basic
1244constraints data, key purpose, key usage and subject alt name.
1245
1246The GnuTLS package includes a command called @code{certtool} which can
1247be used to easily generate certificates and keys in the required format
1248with expected data present. Alternatively a certificate management
1249service may be used.
1250
1251At a minimum it is necessary to setup a certificate authority, and
1252issue certificates to each server. If using x509 certificates for
1253authentication, then each client will also need to be issued a
1254certificate.
1255
1256Assuming that the QEMU network services will only ever be exposed to
1257clients on a private intranet, there is no need to use a commercial
1258certificate authority to create certificates. A self-signed CA is
1259sufficient, and in fact likely to be more secure since it removes
1260the ability of malicious 3rd parties to trick the CA into mis-issuing
1261certs for impersonating your services. The only likely exception
1262where a commercial CA might be desirable is if enabling the VNC
1263websockets server and exposing it directly to remote browser clients.
1264In such a case it might be useful to use a commercial CA to avoid
1265needing to install custom CA certs in the web browsers.
1266
1267The recommendation is for the server to keep its certificates in either
1268@code{/etc/pki/qemu} or for unprivileged users in @code{$HOME/.pki/qemu}.
f858dcae
TS
1269
1270@menu
5d19a6ea
DB
1271* tls_generate_ca::
1272* tls_generate_server::
1273* tls_generate_client::
1274* tls_creds_setup::
e1a6dc91 1275* tls_psk::
f858dcae 1276@end menu
5d19a6ea
DB
1277@node tls_generate_ca
1278@subsection Setup the Certificate Authority
f858dcae
TS
1279
1280This step only needs to be performed once per organization / organizational
1281unit. First the CA needs a private key. This key must be kept VERY secret
1282and secure. If this key is compromised the entire trust chain of the certificates
1283issued with it is lost.
1284
1285@example
1286# certtool --generate-privkey > ca-key.pem
1287@end example
1288
5d19a6ea
DB
1289To generate a self-signed certificate requires one core piece of information,
1290the name of the organization. A template file @code{ca.info} should be
1291populated with the desired data to avoid having to deal with interactive
1292prompts from certtool:
f858dcae
TS
1293@example
1294# cat > ca.info <<EOF
1295cn = Name of your organization
1296ca
1297cert_signing_key
1298EOF
1299# certtool --generate-self-signed \
1300 --load-privkey ca-key.pem
1301 --template ca.info \
1302 --outfile ca-cert.pem
1303@end example
1304
5d19a6ea
DB
1305The @code{ca} keyword in the template sets the v3 basic constraints extension
1306to indicate this certificate is for a CA, while @code{cert_signing_key} sets
1307the key usage extension to indicate this will be used for signing other keys.
1308The generated @code{ca-cert.pem} file should be copied to all servers and
1309clients wishing to utilize TLS support in the VNC server. The @code{ca-key.pem}
1310must not be disclosed/copied anywhere except the host responsible for issuing
1311certificates.
f858dcae 1312
5d19a6ea
DB
1313@node tls_generate_server
1314@subsection Issuing server certificates
f858dcae
TS
1315
1316Each server (or host) needs to be issued with a key and certificate. When connecting
1317the certificate is sent to the client which validates it against the CA certificate.
5d19a6ea
DB
1318The core pieces of information for a server certificate are the hostnames and/or IP
1319addresses that will be used by clients when connecting. The hostname / IP address
1320that the client specifies when connecting will be validated against the hostname(s)
1321and IP address(es) recorded in the server certificate, and if no match is found
1322the client will close the connection.
1323
1324Thus it is recommended that the server certificate include both the fully qualified
1325and unqualified hostnames. If the server will have permanently assigned IP address(es),
1326and clients are likely to use them when connecting, they may also be included in the
1327certificate. Both IPv4 and IPv6 addresses are supported. Historically certificates
1328only included 1 hostname in the @code{CN} field, however, usage of this field for
1329validation is now deprecated. Instead modern TLS clients will validate against the
1330Subject Alt Name extension data, which allows for multiple entries. In the future
1331usage of the @code{CN} field may be discontinued entirely, so providing SAN
1332extension data is strongly recommended.
1333
1334On the host holding the CA, create template files containing the information
1335for each server, and use it to issue server certificates.
f858dcae
TS
1336
1337@example
5d19a6ea 1338# cat > server-hostNNN.info <<EOF
f858dcae 1339organization = Name of your organization
5d19a6ea
DB
1340cn = hostNNN.foo.example.com
1341dns_name = hostNNN
1342dns_name = hostNNN.foo.example.com
1343ip_address = 10.0.1.87
1344ip_address = 192.8.0.92
1345ip_address = 2620:0:cafe::87
1346ip_address = 2001:24::92
f858dcae
TS
1347tls_www_server
1348encryption_key
1349signing_key
1350EOF
5d19a6ea 1351# certtool --generate-privkey > server-hostNNN-key.pem
f858dcae
TS
1352# certtool --generate-certificate \
1353 --load-ca-certificate ca-cert.pem \
1354 --load-ca-privkey ca-key.pem \
5d19a6ea
DB
1355 --load-privkey server-hostNNN-key.pem \
1356 --template server-hostNNN.info \
1357 --outfile server-hostNNN-cert.pem
f858dcae
TS
1358@end example
1359
5d19a6ea
DB
1360The @code{dns_name} and @code{ip_address} fields in the template are setting
1361the subject alt name extension data. The @code{tls_www_server} keyword is the
1362key purpose extension to indicate this certificate is intended for usage in
1363a web server. Although QEMU network services are not in fact HTTP servers
1364(except for VNC websockets), setting this key purpose is still recommended.
1365The @code{encryption_key} and @code{signing_key} keyword is the key usage
1366extension to indicate this certificate is intended for usage in the data
1367session.
1368
1369The @code{server-hostNNN-key.pem} and @code{server-hostNNN-cert.pem} files
1370should now be securely copied to the server for which they were generated,
1371and renamed to @code{server-key.pem} and @code{server-cert.pem} when added
1372to the @code{/etc/pki/qemu} directory on the target host. The @code{server-key.pem}
1373file is security sensitive and should be kept protected with file mode 0600
1374to prevent disclosure.
1375
1376@node tls_generate_client
1377@subsection Issuing client certificates
f858dcae 1378
5d19a6ea
DB
1379The QEMU x509 TLS credential setup defaults to enabling client verification
1380using certificates, providing a simple authentication mechanism. If this
1381default is used, each client also needs to be issued a certificate. The client
1382certificate contains enough metadata to uniquely identify the client with the
1383scope of the certificate authority. The client certificate would typically
1384include fields for organization, state, city, building, etc.
1385
1386Once again on the host holding the CA, create template files containing the
1387information for each client, and use it to issue client certificates.
f858dcae 1388
f858dcae
TS
1389
1390@example
5d19a6ea 1391# cat > client-hostNNN.info <<EOF
f858dcae
TS
1392country = GB
1393state = London
5d19a6ea 1394locality = City Of London
63c693f8 1395organization = Name of your organization
5d19a6ea 1396cn = hostNNN.foo.example.com
f858dcae
TS
1397tls_www_client
1398encryption_key
1399signing_key
1400EOF
5d19a6ea 1401# certtool --generate-privkey > client-hostNNN-key.pem
f858dcae
TS
1402# certtool --generate-certificate \
1403 --load-ca-certificate ca-cert.pem \
1404 --load-ca-privkey ca-key.pem \
5d19a6ea
DB
1405 --load-privkey client-hostNNN-key.pem \
1406 --template client-hostNNN.info \
1407 --outfile client-hostNNN-cert.pem
f858dcae
TS
1408@end example
1409
5d19a6ea
DB
1410The subject alt name extension data is not required for clients, so the
1411the @code{dns_name} and @code{ip_address} fields are not included.
1412The @code{tls_www_client} keyword is the key purpose extension to indicate
1413this certificate is intended for usage in a web client. Although QEMU
1414network clients are not in fact HTTP clients, setting this key purpose is
1415still recommended. The @code{encryption_key} and @code{signing_key} keyword
1416is the key usage extension to indicate this certificate is intended for
1417usage in the data session.
1418
1419The @code{client-hostNNN-key.pem} and @code{client-hostNNN-cert.pem} files
1420should now be securely copied to the client for which they were generated,
1421and renamed to @code{client-key.pem} and @code{client-cert.pem} when added
1422to the @code{/etc/pki/qemu} directory on the target host. The @code{client-key.pem}
1423file is security sensitive and should be kept protected with file mode 0600
1424to prevent disclosure.
1425
1426If a single host is going to be using TLS in both a client and server
1427role, it is possible to create a single certificate to cover both roles.
1428This would be quite common for the migration and NBD services, where a
1429QEMU process will be started by accepting a TLS protected incoming migration,
1430and later itself be migrated out to another host. To generate a single
1431certificate, simply include the template data from both the client and server
1432instructions in one.
2f9606b3 1433
5d19a6ea
DB
1434@example
1435# cat > both-hostNNN.info <<EOF
1436country = GB
1437state = London
1438locality = City Of London
1439organization = Name of your organization
1440cn = hostNNN.foo.example.com
1441dns_name = hostNNN
1442dns_name = hostNNN.foo.example.com
1443ip_address = 10.0.1.87
1444ip_address = 192.8.0.92
1445ip_address = 2620:0:cafe::87
1446ip_address = 2001:24::92
1447tls_www_server
1448tls_www_client
1449encryption_key
1450signing_key
1451EOF
1452# certtool --generate-privkey > both-hostNNN-key.pem
1453# certtool --generate-certificate \
1454 --load-ca-certificate ca-cert.pem \
1455 --load-ca-privkey ca-key.pem \
1456 --load-privkey both-hostNNN-key.pem \
1457 --template both-hostNNN.info \
1458 --outfile both-hostNNN-cert.pem
1459@end example
c6a9a9f5 1460
5d19a6ea
DB
1461When copying the PEM files to the target host, save them twice,
1462once as @code{server-cert.pem} and @code{server-key.pem}, and
1463again as @code{client-cert.pem} and @code{client-key.pem}.
1464
1465@node tls_creds_setup
1466@subsection TLS x509 credential configuration
1467
1468QEMU has a standard mechanism for loading x509 credentials that will be
1469used for network services and clients. It requires specifying the
1470@code{tls-creds-x509} class name to the @code{--object} command line
1471argument for the system emulators. Each set of credentials loaded should
1472be given a unique string identifier via the @code{id} parameter. A single
1473set of TLS credentials can be used for multiple network backends, so VNC,
1474migration, NBD, character devices can all share the same credentials. Note,
1475however, that credentials for use in a client endpoint must be loaded
1476separately from those used in a server endpoint.
1477
1478When specifying the object, the @code{dir} parameters specifies which
1479directory contains the credential files. This directory is expected to
1480contain files with the names mentioned previously, @code{ca-cert.pem},
1481@code{server-key.pem}, @code{server-cert.pem}, @code{client-key.pem}
1482and @code{client-cert.pem} as appropriate. It is also possible to
1483include a set of pre-generated Diffie-Hellman (DH) parameters in a file
1484@code{dh-params.pem}, which can be created using the
1485@code{certtool --generate-dh-params} command. If omitted, QEMU will
1486dynamically generate DH parameters when loading the credentials.
1487
1488The @code{endpoint} parameter indicates whether the credentials will
1489be used for a network client or server, and determines which PEM
1490files are loaded.
1491
1492The @code{verify} parameter determines whether x509 certificate
1493validation should be performed. This defaults to enabled, meaning
1494clients will always validate the server hostname against the
1495certificate subject alt name fields and/or CN field. It also
1496means that servers will request that clients provide a certificate
1497and validate them. Verification should never be turned off for
1498client endpoints, however, it may be turned off for server endpoints
1499if an alternative mechanism is used to authenticate clients. For
1500example, the VNC server can use SASL to authenticate clients
1501instead.
1502
1503To load server credentials with client certificate validation
1504enabled
2f9606b3
AL
1505
1506@example
664785ac 1507@value{qemu_system} -object tls-creds-x509,id=tls0,dir=/etc/pki/qemu,endpoint=server
2f9606b3
AL
1508@end example
1509
5d19a6ea 1510while to load client credentials use
2f9606b3
AL
1511
1512@example
664785ac 1513@value{qemu_system} -object tls-creds-x509,id=tls0,dir=/etc/pki/qemu,endpoint=client
2f9606b3
AL
1514@end example
1515
5d19a6ea
DB
1516Network services which support TLS will all have a @code{tls-creds}
1517parameter which expects the ID of the TLS credentials object. For
1518example with VNC:
2f9606b3 1519
5d19a6ea 1520@example
664785ac 1521@value{qemu_system} -vnc 0.0.0.0:0,tls-creds=tls0
5d19a6ea 1522@end example
2f9606b3 1523
e1a6dc91
RJ
1524@node tls_psk
1525@subsection TLS Pre-Shared Keys (PSK)
1526
1527Instead of using certificates, you may also use TLS Pre-Shared Keys
1528(TLS-PSK). This can be simpler to set up than certificates but is
1529less scalable.
1530
1531Use the GnuTLS @code{psktool} program to generate a @code{keys.psk}
1532file containing one or more usernames and random keys:
1533
1534@example
1535mkdir -m 0700 /tmp/keys
1536psktool -u rich -p /tmp/keys/keys.psk
1537@end example
1538
1539TLS-enabled servers such as qemu-nbd can use this directory like so:
1540
1541@example
1542qemu-nbd \
1543 -t -x / \
1544 --object tls-creds-psk,id=tls0,endpoint=server,dir=/tmp/keys \
1545 --tls-creds tls0 \
1546 image.qcow2
1547@end example
1548
1549When connecting from a qemu-based client you must specify the
1550directory containing @code{keys.psk} and an optional @var{username}
1551(defaults to ``qemu''):
1552
1553@example
1554qemu-img info \
1555 --object tls-creds-psk,id=tls0,dir=/tmp/keys,username=rich,endpoint=client \
1556 --image-opts \
1557 file.driver=nbd,file.host=localhost,file.port=10809,file.tls-creds=tls0,file.export=/
1558@end example
1559
0806e3f6 1560@node gdb_usage
da415d54
FB
1561@section GDB usage
1562
1563QEMU has a primitive support to work with gdb, so that you can do
0806e3f6 1564'Ctrl-C' while the virtual machine is running and inspect its state.
da415d54 1565
b65ee4fa 1566In order to use gdb, launch QEMU with the '-s' option. It will wait for a
da415d54
FB
1567gdb connection:
1568@example
664785ac 1569@value{qemu_system} -s -kernel bzImage -hda rootdisk.img -append "root=/dev/hda"
da415d54
FB
1570Connected to host network interface: tun0
1571Waiting gdb connection on port 1234
1572@end example
1573
1574Then launch gdb on the 'vmlinux' executable:
1575@example
1576> gdb vmlinux
1577@end example
1578
1579In gdb, connect to QEMU:
1580@example
6c9bf893 1581(gdb) target remote localhost:1234
da415d54
FB
1582@end example
1583
1584Then you can use gdb normally. For example, type 'c' to launch the kernel:
1585@example
1586(gdb) c
1587@end example
1588
0806e3f6
FB
1589Here are some useful tips in order to use gdb on system code:
1590
1591@enumerate
1592@item
1593Use @code{info reg} to display all the CPU registers.
1594@item
1595Use @code{x/10i $eip} to display the code at the PC position.
1596@item
1597Use @code{set architecture i8086} to dump 16 bit code. Then use
294e8637 1598@code{x/10i $cs*16+$eip} to dump the code at the PC position.
0806e3f6
FB
1599@end enumerate
1600
60897d36
EI
1601Advanced debugging options:
1602
b6af0975 1603The 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 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:
94d45e44 1604@table @code
60897d36
EI
1605@item maintenance packet qqemu.sstepbits
1606
1607This will display the MASK bits used to control the single stepping IE:
1608@example
1609(gdb) maintenance packet qqemu.sstepbits
1610sending: "qqemu.sstepbits"
1611received: "ENABLE=1,NOIRQ=2,NOTIMER=4"
1612@end example
1613@item maintenance packet qqemu.sstep
1614
1615This will display the current value of the mask used when single stepping IE:
1616@example
1617(gdb) maintenance packet qqemu.sstep
1618sending: "qqemu.sstep"
1619received: "0x7"
1620@end example
1621@item maintenance packet Qqemu.sstep=HEX_VALUE
1622
1623This will change the single step mask, so if wanted to enable IRQs on the single step, but not timers, you would use:
1624@example
1625(gdb) maintenance packet Qqemu.sstep=0x5
1626sending: "qemu.sstep=0x5"
1627received: "OK"
1628@end example
94d45e44 1629@end table
60897d36 1630
debc7065 1631@node pcsys_os_specific
1a084f3d
FB
1632@section Target OS specific information
1633
1634@subsection Linux
1635
15a34c63
FB
1636To have access to SVGA graphic modes under X11, use the @code{vesa} or
1637the @code{cirrus} X11 driver. For optimal performances, use 16 bit
1638color depth in the guest and the host OS.
1a084f3d 1639
e3371e62
FB
1640When using a 2.6 guest Linux kernel, you should add the option
1641@code{clock=pit} on the kernel command line because the 2.6 Linux
1642kernels make very strict real time clock checks by default that QEMU
1643cannot simulate exactly.
1644
7c3fc84d
FB
1645When using a 2.6 guest Linux kernel, verify that the 4G/4G patch is
1646not activated because QEMU is slower with this patch. The QEMU
1647Accelerator Module is also much slower in this case. Earlier Fedora
4be456f1 1648Core 3 Linux kernel (< 2.6.9-1.724_FC3) were known to incorporate this
7c3fc84d
FB
1649patch by default. Newer kernels don't have it.
1650
1a084f3d
FB
1651@subsection Windows
1652
1653If you have a slow host, using Windows 95 is better as it gives the
1654best speed. Windows 2000 is also a good choice.
1655
e3371e62
FB
1656@subsubsection SVGA graphic modes support
1657
1658QEMU emulates a Cirrus Logic GD5446 Video
15a34c63
FB
1659card. All Windows versions starting from Windows 95 should recognize
1660and use this graphic card. For optimal performances, use 16 bit color
1661depth in the guest and the host OS.
1a084f3d 1662
3cb0853a
FB
1663If you are using Windows XP as guest OS and if you want to use high
1664resolution modes which the Cirrus Logic BIOS does not support (i.e. >=
16651280x1024x16), then you should use the VESA VBE virtual graphic card
1666(option @option{-std-vga}).
1667
e3371e62
FB
1668@subsubsection CPU usage reduction
1669
1670Windows 9x does not correctly use the CPU HLT
15a34c63
FB
1671instruction. The result is that it takes host CPU cycles even when
1672idle. You can install the utility from
70b7fba9 1673@url{https://web.archive.org/web/20060212132151/http://www.user.cityline.ru/~maxamn/amnhltm.zip}
3ba34a70 1674to solve this problem. Note that no such tool is needed for NT, 2000 or XP.
1a084f3d 1675
9d0a8e6f 1676@subsubsection Windows 2000 disk full problem
e3371e62 1677
9d0a8e6f
FB
1678Windows 2000 has a bug which gives a disk full problem during its
1679installation. When installing it, use the @option{-win2k-hack} QEMU
1680option to enable a specific workaround. After Windows 2000 is
1681installed, you no longer need this option (this option slows down the
1682IDE transfers).
e3371e62 1683
6cc721cf
FB
1684@subsubsection Windows 2000 shutdown
1685
1686Windows 2000 cannot automatically shutdown in QEMU although Windows 98
1687can. It comes from the fact that Windows 2000 does not automatically
1688use the APM driver provided by the BIOS.
1689
1690In order to correct that, do the following (thanks to Struan
1691Bartlett): go to the Control Panel => Add/Remove Hardware & Next =>
1692Add/Troubleshoot a device => Add a new device & Next => No, select the
1693hardware from a list & Next => NT Apm/Legacy Support & Next => Next
1694(again) a few times. Now the driver is installed and Windows 2000 now
5fafdf24 1695correctly instructs QEMU to shutdown at the appropriate moment.
6cc721cf
FB
1696
1697@subsubsection Share a directory between Unix and Windows
1698
c8c6afa8
TH
1699See @ref{sec_invocation} about the help of the option
1700@option{'-netdev user,smb=...'}.
6cc721cf 1701
2192c332 1702@subsubsection Windows XP security problem
e3371e62
FB
1703
1704Some releases of Windows XP install correctly but give a security
1705error when booting:
1706@example
1707A problem is preventing Windows from accurately checking the
1708license for this computer. Error code: 0x800703e6.
1709@end example
e3371e62 1710
2192c332
FB
1711The workaround is to install a service pack for XP after a boot in safe
1712mode. Then reboot, and the problem should go away. Since there is no
1713network while in safe mode, its recommended to download the full
1714installation of SP1 or SP2 and transfer that via an ISO or using the
1715vvfat block device ("-hdb fat:directory_which_holds_the_SP").
e3371e62 1716
a0a821a4
FB
1717@subsection MS-DOS and FreeDOS
1718
1719@subsubsection CPU usage reduction
1720
1721DOS does not correctly use the CPU HLT instruction. The result is that
3ba34a70 1722it takes host CPU cycles even when idle. You can install the utility from
70b7fba9 1723@url{https://web.archive.org/web/20051222085335/http://www.vmware.com/software/dosidle210.zip}
3ba34a70 1724to solve this problem.
a0a821a4 1725
debc7065 1726@node QEMU System emulator for non PC targets
3f9f3aa1
FB
1727@chapter QEMU System emulator for non PC targets
1728
1729QEMU is a generic emulator and it emulates many non PC
1730machines. Most of the options are similar to the PC emulator. The
4be456f1 1731differences are mentioned in the following sections.
3f9f3aa1 1732
debc7065 1733@menu
7544a042 1734* PowerPC System emulator::
24d4de45
TS
1735* Sparc32 System emulator::
1736* Sparc64 System emulator::
1737* MIPS System emulator::
1738* ARM System emulator::
1739* ColdFire System emulator::
7544a042
SW
1740* Cris System emulator::
1741* Microblaze System emulator::
1742* SH4 System emulator::
3aeaea65 1743* Xtensa System emulator::
debc7065
FB
1744@end menu
1745
7544a042
SW
1746@node PowerPC System emulator
1747@section PowerPC System emulator
1748@cindex system emulation (PowerPC)
1a084f3d 1749
15a34c63
FB
1750Use the executable @file{qemu-system-ppc} to simulate a complete PREP
1751or PowerMac PowerPC system.
1a084f3d 1752
b671f9ed 1753QEMU emulates the following PowerMac peripherals:
1a084f3d 1754
15a34c63 1755@itemize @minus
5fafdf24 1756@item
006f3a48 1757UniNorth or Grackle PCI Bridge
15a34c63
FB
1758@item
1759PCI VGA compatible card with VESA Bochs Extensions
5fafdf24 1760@item
15a34c63 17612 PMAC IDE interfaces with hard disk and CD-ROM support
5fafdf24 1762@item
15a34c63
FB
1763NE2000 PCI adapters
1764@item
1765Non Volatile RAM
1766@item
1767VIA-CUDA with ADB keyboard and mouse.
1a084f3d
FB
1768@end itemize
1769
b671f9ed 1770QEMU emulates the following PREP peripherals:
52c00a5f
FB
1771
1772@itemize @minus
5fafdf24 1773@item
15a34c63
FB
1774PCI Bridge
1775@item
1776PCI VGA compatible card with VESA Bochs Extensions
5fafdf24 1777@item
52c00a5f
FB
17782 IDE interfaces with hard disk and CD-ROM support
1779@item
1780Floppy disk
5fafdf24 1781@item
15a34c63 1782NE2000 network adapters
52c00a5f
FB
1783@item
1784Serial port
1785@item
1786PREP Non Volatile RAM
15a34c63
FB
1787@item
1788PC compatible keyboard and mouse.
52c00a5f
FB
1789@end itemize
1790
15a34c63 1791QEMU uses the Open Hack'Ware Open Firmware Compatible BIOS available at
3f9f3aa1 1792@url{http://perso.magic.fr/l_indien/OpenHackWare/index.htm}.
52c00a5f 1793
70b7fba9 1794Since version 0.9.1, QEMU uses OpenBIOS @url{https://www.openbios.org/}
006f3a48
BS
1795for the g3beige and mac99 PowerMac machines. OpenBIOS is a free (GPL
1796v2) portable firmware implementation. The goal is to implement a 100%
1797IEEE 1275-1994 (referred to as Open Firmware) compliant firmware.
992e5acd 1798
15a34c63
FB
1799@c man begin OPTIONS
1800
1801The following options are specific to the PowerPC emulation:
1802
1803@table @option
1804
4e257e5e 1805@item -g @var{W}x@var{H}[x@var{DEPTH}]
15a34c63 1806
340fb41b 1807Set the initial VGA graphic mode. The default is 800x600x32.
15a34c63 1808
4e257e5e 1809@item -prom-env @var{string}
95efd11c
BS
1810
1811Set OpenBIOS variables in NVRAM, for example:
1812
1813@example
1814qemu-system-ppc -prom-env 'auto-boot?=false' \
1815 -prom-env 'boot-device=hd:2,\yaboot' \
1816 -prom-env 'boot-args=conf=hd:2,\yaboot.conf'
1817@end example
1818
1819These variables are not used by Open Hack'Ware.
1820
15a34c63
FB
1821@end table
1822
5fafdf24 1823@c man end
15a34c63
FB
1824
1825
52c00a5f 1826More information is available at
3f9f3aa1 1827@url{http://perso.magic.fr/l_indien/qemu-ppc/}.
52c00a5f 1828
24d4de45
TS
1829@node Sparc32 System emulator
1830@section Sparc32 System emulator
7544a042 1831@cindex system emulation (Sparc32)
e80cfcfc 1832
34a3d239
BS
1833Use the executable @file{qemu-system-sparc} to simulate the following
1834Sun4m architecture machines:
1835@itemize @minus
1836@item
1837SPARCstation 4
1838@item
1839SPARCstation 5
1840@item
1841SPARCstation 10
1842@item
1843SPARCstation 20
1844@item
1845SPARCserver 600MP
1846@item
1847SPARCstation LX
1848@item
1849SPARCstation Voyager
1850@item
1851SPARCclassic
1852@item
1853SPARCbook
1854@end itemize
1855
1856The emulation is somewhat complete. SMP up to 16 CPUs is supported,
1857but Linux limits the number of usable CPUs to 4.
e80cfcfc 1858
6a4e1771 1859QEMU emulates the following sun4m peripherals:
e80cfcfc
FB
1860
1861@itemize @minus
3475187d 1862@item
6a4e1771 1863IOMMU
e80cfcfc 1864@item
33632788 1865TCX or cgthree Frame buffer
5fafdf24 1866@item
e80cfcfc
FB
1867Lance (Am7990) Ethernet
1868@item
34a3d239 1869Non Volatile RAM M48T02/M48T08
e80cfcfc 1870@item
3475187d
FB
1871Slave I/O: timers, interrupt controllers, Zilog serial ports, keyboard
1872and power/reset logic
1873@item
1874ESP SCSI controller with hard disk and CD-ROM support
1875@item
6a3b9cc9 1876Floppy drive (not on SS-600MP)
a2502b58
BS
1877@item
1878CS4231 sound device (only on SS-5, not working yet)
e80cfcfc
FB
1879@end itemize
1880
6a3b9cc9
BS
1881The number of peripherals is fixed in the architecture. Maximum
1882memory size depends on the machine type, for SS-5 it is 256MB and for
7d85892b 1883others 2047MB.
3475187d 1884
30a604f3 1885Since version 0.8.2, QEMU uses OpenBIOS
70b7fba9 1886@url{https://www.openbios.org/}. OpenBIOS is a free (GPL v2) portable
0986ac3b
FB
1887firmware implementation. The goal is to implement a 100% IEEE
18881275-1994 (referred to as Open Firmware) compliant firmware.
3475187d
FB
1889
1890A sample Linux 2.6 series kernel and ram disk image are available on
34a3d239 1891the QEMU web site. There are still issues with NetBSD and OpenBSD, but
9bb9f217 1892most kernel versions work. Please note that currently older Solaris kernels
34a3d239
BS
1893don't work probably due to interface issues between OpenBIOS and
1894Solaris.
3475187d
FB
1895
1896@c man begin OPTIONS
1897
a2502b58 1898The following options are specific to the Sparc32 emulation:
3475187d
FB
1899
1900@table @option
1901
4e257e5e 1902@item -g @var{W}x@var{H}x[x@var{DEPTH}]
3475187d 1903
33632788
MCA
1904Set the initial graphics mode. For TCX, the default is 1024x768x8 with the
1905option of 1024x768x24. For cgthree, the default is 1024x768x8 with the option
1906of 1152x900x8 for people who wish to use OBP.
3475187d 1907
4e257e5e 1908@item -prom-env @var{string}
66508601
BS
1909
1910Set OpenBIOS variables in NVRAM, for example:
1911
1912@example
1913qemu-system-sparc -prom-env 'auto-boot?=false' \
1914 -prom-env 'boot-device=sd(0,2,0):d' -prom-env 'boot-args=linux single'
1915@end example
1916
6a4e1771 1917@item -M [SS-4|SS-5|SS-10|SS-20|SS-600MP|LX|Voyager|SPARCClassic] [|SPARCbook]
a2502b58
BS
1918
1919Set the emulated machine type. Default is SS-5.
1920
3475187d
FB
1921@end table
1922
5fafdf24 1923@c man end
3475187d 1924
24d4de45
TS
1925@node Sparc64 System emulator
1926@section Sparc64 System emulator
7544a042 1927@cindex system emulation (Sparc64)
e80cfcfc 1928
34a3d239
BS
1929Use the executable @file{qemu-system-sparc64} to simulate a Sun4u
1930(UltraSPARC PC-like machine), Sun4v (T1 PC-like machine), or generic
9bb9f217
MCA
1931Niagara (T1) machine. The Sun4u emulator is mostly complete, being
1932able to run Linux, NetBSD and OpenBSD in headless (-nographic) mode. The
a2664ca0
AT
1933Sun4v emulator is still a work in progress.
1934
1935The Niagara T1 emulator makes use of firmware and OS binaries supplied in the S10image/ directory
1936of the OpenSPARC T1 project @url{http://download.oracle.com/technetwork/systems/opensparc/OpenSPARCT1_Arch.1.5.tar.bz2}
1937and is able to boot the disk.s10hw2 Solaris image.
1938@example
1939qemu-system-sparc64 -M niagara -L /path-to/S10image/ \
1940 -nographic -m 256 \
1941 -drive if=pflash,readonly=on,file=/S10image/disk.s10hw2
1942@end example
1943
b756921a 1944
c7ba218d 1945QEMU emulates the following peripherals:
83469015
FB
1946
1947@itemize @minus
1948@item
5fafdf24 1949UltraSparc IIi APB PCI Bridge
83469015
FB
1950@item
1951PCI VGA compatible card with VESA Bochs Extensions
1952@item
34a3d239
BS
1953PS/2 mouse and keyboard
1954@item
83469015
FB
1955Non Volatile RAM M48T59
1956@item
1957PC-compatible serial ports
c7ba218d
BS
1958@item
19592 PCI IDE interfaces with hard disk and CD-ROM support
34a3d239
BS
1960@item
1961Floppy disk
83469015
FB
1962@end itemize
1963
c7ba218d
BS
1964@c man begin OPTIONS
1965
1966The following options are specific to the Sparc64 emulation:
1967
1968@table @option
1969
4e257e5e 1970@item -prom-env @var{string}
34a3d239
BS
1971
1972Set OpenBIOS variables in NVRAM, for example:
1973
1974@example
1975qemu-system-sparc64 -prom-env 'auto-boot?=false'
1976@end example
1977
a2664ca0 1978@item -M [sun4u|sun4v|niagara]
c7ba218d
BS
1979
1980Set the emulated machine type. The default is sun4u.
1981
1982@end table
1983
1984@c man end
1985
24d4de45
TS
1986@node MIPS System emulator
1987@section MIPS System emulator
7544a042 1988@cindex system emulation (MIPS)
9d0a8e6f 1989
f7d257cb
SM
1990@menu
1991* nanoMIPS System emulator ::
1992@end menu
1993
d9aedc32
TS
1994Four executables cover simulation of 32 and 64-bit MIPS systems in
1995both endian options, @file{qemu-system-mips}, @file{qemu-system-mipsel}
1996@file{qemu-system-mips64} and @file{qemu-system-mips64el}.
88cb0a02 1997Five different machine types are emulated:
24d4de45
TS
1998
1999@itemize @minus
2000@item
2001A generic ISA PC-like machine "mips"
2002@item
2003The MIPS Malta prototype board "malta"
2004@item
d9aedc32 2005An ACER Pica "pica61". This machine needs the 64-bit emulator.
6bf5b4e8 2006@item
f0fc6f8f 2007MIPS emulator pseudo board "mipssim"
88cb0a02
AJ
2008@item
2009A MIPS Magnum R4000 machine "magnum". This machine needs the 64-bit emulator.
24d4de45
TS
2010@end itemize
2011
2012The generic emulation is supported by Debian 'Etch' and is able to
2013install Debian into a virtual disk image. The following devices are
2014emulated:
3f9f3aa1
FB
2015
2016@itemize @minus
5fafdf24 2017@item
6bf5b4e8 2018A range of MIPS CPUs, default is the 24Kf
3f9f3aa1
FB
2019@item
2020PC style serial port
2021@item
24d4de45
TS
2022PC style IDE disk
2023@item
3f9f3aa1
FB
2024NE2000 network card
2025@end itemize
2026
24d4de45
TS
2027The Malta emulation supports the following devices:
2028
2029@itemize @minus
2030@item
0b64d008 2031Core board with MIPS 24Kf CPU and Galileo system controller
24d4de45
TS
2032@item
2033PIIX4 PCI/USB/SMbus controller
2034@item
2035The Multi-I/O chip's serial device
2036@item
3a2eeac0 2037PCI network cards (PCnet32 and others)
24d4de45
TS
2038@item
2039Malta FPGA serial device
2040@item
1f605a76 2041Cirrus (default) or any other PCI VGA graphics card
24d4de45
TS
2042@end itemize
2043
ba182a18
AM
2044The Boston board emulation supports the following devices:
2045
2046@itemize @minus
2047@item
2048Xilinx FPGA, which includes a PCIe root port and an UART
2049@item
2050Intel EG20T PCH connects the I/O peripherals, but only the SATA bus is emulated
2051@end itemize
2052
24d4de45
TS
2053The ACER Pica emulation supports:
2054
2055@itemize @minus
2056@item
2057MIPS R4000 CPU
2058@item
2059PC-style IRQ and DMA controllers
2060@item
2061PC Keyboard
2062@item
2063IDE controller
2064@end itemize
3f9f3aa1 2065
88cb0a02
AJ
2066The MIPS Magnum R4000 emulation supports:
2067
2068@itemize @minus
2069@item
2070MIPS R4000 CPU
2071@item
2072PC-style IRQ controller
2073@item
2074PC Keyboard
2075@item
2076SCSI controller
2077@item
2078G364 framebuffer
2079@end itemize
2080
3a1b94d9
AM
2081The Fulong 2E emulation supports:
2082
2083@itemize @minus
2084@item
2085Loongson 2E CPU
2086@item
2087Bonito64 system controller as North Bridge
2088@item
2089VT82C686 chipset as South Bridge
2090@item
2091RTL8139D as a network card chipset
2092@end itemize
2093
53d21e7b
AM
2094The mipssim pseudo board emulation provides an environment similar
2095to what the proprietary MIPS emulator uses for running Linux.
2096It supports:
2097
2098@itemize @minus
2099@item
2100A range of MIPS CPUs, default is the 24Kf
2101@item
2102PC style serial port
2103@item
2104MIPSnet network emulation
2105@end itemize
2106
f7d257cb
SM
2107@node nanoMIPS System emulator
2108@subsection nanoMIPS System emulator
2109@cindex system emulation (nanoMIPS)
2110
2111Executable @file{qemu-system-mipsel} also covers simulation of
211232-bit nanoMIPS system in little endian mode:
2113
2114@itemize @minus
2115@item
2116nanoMIPS I7200 CPU
2117@end itemize
2118
2119Example of @file{qemu-system-mipsel} usage for nanoMIPS is shown below:
2120
2121Download @code{<disk_image_file>} from @url{https://mipsdistros.mips.com/LinuxDistro/nanomips/buildroot/index.html}.
2122
2123Download @code{<kernel_image_file>} from @url{https://mipsdistros.mips.com/LinuxDistro/nanomips/kernels/v4.15.18-432-gb2eb9a8b07a1-20180627102142/index.html}.
2124
2125Start system emulation of Malta board with nanoMIPS I7200 CPU:
2126@example
2127qemu-system-mipsel -cpu I7200 -kernel @code{<kernel_image_file>} \
2128 -M malta -serial stdio -m @code{<memory_size>} -hda @code{<disk_image_file>} \
2129 -append "mem=256m@@0x0 rw console=ttyS0 vga=cirrus vesa=0x111 root=/dev/sda"
2130@end example
2131
88cb0a02 2132
24d4de45
TS
2133@node ARM System emulator
2134@section ARM System emulator
7544a042 2135@cindex system emulation (ARM)
3f9f3aa1
FB
2136
2137Use the executable @file{qemu-system-arm} to simulate a ARM
2138machine. The ARM Integrator/CP board is emulated with the following
2139devices:
2140
2141@itemize @minus
2142@item
9ee6e8bb 2143ARM926E, ARM1026E, ARM946E, ARM1136 or Cortex-A8 CPU
3f9f3aa1
FB
2144@item
2145Two PL011 UARTs
5fafdf24 2146@item
3f9f3aa1 2147SMC 91c111 Ethernet adapter
00a9bf19
PB
2148@item
2149PL110 LCD controller
2150@item
2151PL050 KMI with PS/2 keyboard and mouse.
a1bb27b1
PB
2152@item
2153PL181 MultiMedia Card Interface with SD card.
00a9bf19
PB
2154@end itemize
2155
2156The ARM Versatile baseboard is emulated with the following devices:
2157
2158@itemize @minus
2159@item
9ee6e8bb 2160ARM926E, ARM1136 or Cortex-A8 CPU
00a9bf19
PB
2161@item
2162PL190 Vectored Interrupt Controller
2163@item
2164Four PL011 UARTs
5fafdf24 2165@item
00a9bf19
PB
2166SMC 91c111 Ethernet adapter
2167@item
2168PL110 LCD controller
2169@item
2170PL050 KMI with PS/2 keyboard and mouse.
2171@item
2172PCI host bridge. Note the emulated PCI bridge only provides access to
2173PCI memory space. It does not provide access to PCI IO space.
4be456f1
TS
2174This means some devices (eg. ne2k_pci NIC) are not usable, and others
2175(eg. rtl8139 NIC) are only usable when the guest drivers use the memory
00a9bf19 2176mapped control registers.
e6de1bad
PB
2177@item
2178PCI OHCI USB controller.
2179@item
2180LSI53C895A PCI SCSI Host Bus Adapter with hard disk and CD-ROM devices.
a1bb27b1
PB
2181@item
2182PL181 MultiMedia Card Interface with SD card.
3f9f3aa1
FB
2183@end itemize
2184
21a88941
PB
2185Several variants of the ARM RealView baseboard are emulated,
2186including the EB, PB-A8 and PBX-A9. Due to interactions with the
2187bootloader, only certain Linux kernel configurations work out
2188of the box on these boards.
2189
2190Kernels for the PB-A8 board should have CONFIG_REALVIEW_HIGH_PHYS_OFFSET
2191enabled in the kernel, and expect 512M RAM. Kernels for The PBX-A9 board
2192should have CONFIG_SPARSEMEM enabled, CONFIG_REALVIEW_HIGH_PHYS_OFFSET
2193disabled and expect 1024M RAM.
2194
40c5c6cd 2195The following devices are emulated:
d7739d75
PB
2196
2197@itemize @minus
2198@item
f7c70325 2199ARM926E, ARM1136, ARM11MPCore, Cortex-A8 or Cortex-A9 MPCore CPU
d7739d75
PB
2200@item
2201ARM AMBA Generic/Distributed Interrupt Controller
2202@item
2203Four PL011 UARTs
5fafdf24 2204@item
0ef849d7 2205SMC 91c111 or SMSC LAN9118 Ethernet adapter
d7739d75
PB
2206@item
2207PL110 LCD controller
2208@item
2209PL050 KMI with PS/2 keyboard and mouse
2210@item
2211PCI host bridge
2212@item
2213PCI OHCI USB controller
2214@item
2215LSI53C895A PCI SCSI Host Bus Adapter with hard disk and CD-ROM devices
a1bb27b1
PB
2216@item
2217PL181 MultiMedia Card Interface with SD card.
d7739d75
PB
2218@end itemize
2219
b00052e4
AZ
2220The XScale-based clamshell PDA models ("Spitz", "Akita", "Borzoi"
2221and "Terrier") emulation includes the following peripherals:
2222
2223@itemize @minus
2224@item
2225Intel PXA270 System-on-chip (ARM V5TE core)
2226@item
2227NAND Flash memory
2228@item
2229IBM/Hitachi DSCM microdrive in a PXA PCMCIA slot - not in "Akita"
2230@item
2231On-chip OHCI USB controller
2232@item
2233On-chip LCD controller
2234@item
2235On-chip Real Time Clock
2236@item
2237TI ADS7846 touchscreen controller on SSP bus
2238@item
2239Maxim MAX1111 analog-digital converter on I@math{^2}C bus
2240@item
2241GPIO-connected keyboard controller and LEDs
2242@item
549444e1 2243Secure Digital card connected to PXA MMC/SD host
b00052e4
AZ
2244@item
2245Three on-chip UARTs
2246@item
2247WM8750 audio CODEC on I@math{^2}C and I@math{^2}S busses
2248@end itemize
2249
02645926
AZ
2250The Palm Tungsten|E PDA (codename "Cheetah") emulation includes the
2251following elements:
2252
2253@itemize @minus
2254@item
2255Texas Instruments OMAP310 System-on-chip (ARM 925T core)
2256@item
2257ROM and RAM memories (ROM firmware image can be loaded with -option-rom)
2258@item
2259On-chip LCD controller
2260@item
2261On-chip Real Time Clock
2262@item
2263TI TSC2102i touchscreen controller / analog-digital converter / Audio
2264CODEC, connected through MicroWire and I@math{^2}S busses
2265@item
2266GPIO-connected matrix keypad
2267@item
2268Secure Digital card connected to OMAP MMC/SD host
2269@item
2270Three on-chip UARTs
2271@end itemize
2272
c30bb264
AZ
2273Nokia N800 and N810 internet tablets (known also as RX-34 and RX-44 / 48)
2274emulation supports the following elements:
2275
2276@itemize @minus
2277@item
2278Texas Instruments OMAP2420 System-on-chip (ARM 1136 core)
2279@item
2280RAM and non-volatile OneNAND Flash memories
2281@item
2282Display connected to EPSON remote framebuffer chip and OMAP on-chip
2283display controller and a LS041y3 MIPI DBI-C controller
2284@item
2285TI TSC2301 (in N800) and TI TSC2005 (in N810) touchscreen controllers
2286driven through SPI bus
2287@item
2288National Semiconductor LM8323-controlled qwerty keyboard driven
2289through I@math{^2}C bus
2290@item
2291Secure Digital card connected to OMAP MMC/SD host
2292@item
2293Three OMAP on-chip UARTs and on-chip STI debugging console
2294@item
2295Mentor Graphics "Inventra" dual-role USB controller embedded in a TI
2296TUSB6010 chip - only USB host mode is supported
2297@item
2298TI TMP105 temperature sensor driven through I@math{^2}C bus
2299@item
2300TI TWL92230C power management companion with an RTC on I@math{^2}C bus
2301@item
2302Nokia RETU and TAHVO multi-purpose chips with an RTC, connected
2303through CBUS
2304@end itemize
2305
9ee6e8bb
PB
2306The Luminary Micro Stellaris LM3S811EVB emulation includes the following
2307devices:
2308
2309@itemize @minus
2310@item
2311Cortex-M3 CPU core.
2312@item
231364k Flash and 8k SRAM.
2314@item
2315Timers, UARTs, ADC and I@math{^2}C interface.
2316@item
2317OSRAM Pictiva 96x16 OLED with SSD0303 controller on I@math{^2}C bus.
2318@end itemize
2319
2320The Luminary Micro Stellaris LM3S6965EVB emulation includes the following
2321devices:
2322
2323@itemize @minus
2324@item
2325Cortex-M3 CPU core.
2326@item
2327256k Flash and 64k SRAM.
2328@item
2329Timers, UARTs, ADC, I@math{^2}C and SSI interfaces.
2330@item
2331OSRAM Pictiva 128x64 OLED with SSD0323 controller connected via SSI.
2332@end itemize
2333
57cd6e97
AZ
2334The Freecom MusicPal internet radio emulation includes the following
2335elements:
2336
2337@itemize @minus
2338@item
2339Marvell MV88W8618 ARM core.
2340@item
234132 MB RAM, 256 KB SRAM, 8 MB flash.
2342@item
2343Up to 2 16550 UARTs
2344@item
2345MV88W8xx8 Ethernet controller
2346@item
2347MV88W8618 audio controller, WM8750 CODEC and mixer
2348@item
e080e785 2349128×64 display with brightness control
57cd6e97
AZ
2350@item
23512 buttons, 2 navigation wheels with button function
2352@end itemize
2353
997641a8 2354The Siemens SX1 models v1 and v2 (default) basic emulation.
40c5c6cd 2355The emulation includes the following elements:
997641a8
AZ
2356
2357@itemize @minus
2358@item
2359Texas Instruments OMAP310 System-on-chip (ARM 925T core)
2360@item
2361ROM and RAM memories (ROM firmware image can be loaded with -pflash)
2362V1
23631 Flash of 16MB and 1 Flash of 8MB
2364V2
23651 Flash of 32MB
2366@item
2367On-chip LCD controller
2368@item
2369On-chip Real Time Clock
2370@item
2371Secure Digital card connected to OMAP MMC/SD host
2372@item
2373Three on-chip UARTs
2374@end itemize
2375
3f9f3aa1
FB
2376A Linux 2.6 test image is available on the QEMU web site. More
2377information is available in the QEMU mailing-list archive.
9d0a8e6f 2378
d2c639d6
BS
2379@c man begin OPTIONS
2380
2381The following options are specific to the ARM emulation:
2382
2383@table @option
2384
2385@item -semihosting
2386Enable semihosting syscall emulation.
2387
2388On ARM this implements the "Angel" interface.
2389
2390Note that this allows guest direct access to the host filesystem,
2391so should only be used with trusted guest OS.
2392
2393@end table
2394
abc67eb6
TH
2395@c man end
2396
24d4de45
TS
2397@node ColdFire System emulator
2398@section ColdFire System emulator
7544a042
SW
2399@cindex system emulation (ColdFire)
2400@cindex system emulation (M68K)
209a4e69
PB
2401
2402Use the executable @file{qemu-system-m68k} to simulate a ColdFire machine.
2403The emulator is able to boot a uClinux kernel.
707e011b
PB
2404
2405The M5208EVB emulation includes the following devices:
2406
2407@itemize @minus
5fafdf24 2408@item
707e011b
PB
2409MCF5208 ColdFire V2 Microprocessor (ISA A+ with EMAC).
2410@item
2411Three Two on-chip UARTs.
2412@item
2413Fast Ethernet Controller (FEC)
2414@end itemize
2415
2416The AN5206 emulation includes the following devices:
209a4e69
PB
2417
2418@itemize @minus
5fafdf24 2419@item
209a4e69
PB
2420MCF5206 ColdFire V2 Microprocessor.
2421@item
2422Two on-chip UARTs.
2423@end itemize
2424
d2c639d6
BS
2425@c man begin OPTIONS
2426
7544a042 2427The following options are specific to the ColdFire emulation:
d2c639d6
BS
2428
2429@table @option
2430
2431@item -semihosting
2432Enable semihosting syscall emulation.
2433
2434On M68K this implements the "ColdFire GDB" interface used by libgloss.
2435
2436Note that this allows guest direct access to the host filesystem,
2437so should only be used with trusted guest OS.
2438
2439@end table
2440
abc67eb6
TH
2441@c man end
2442
7544a042
SW
2443@node Cris System emulator
2444@section Cris System emulator
2445@cindex system emulation (Cris)
2446
2447TODO
2448
2449@node Microblaze System emulator
2450@section Microblaze System emulator
2451@cindex system emulation (Microblaze)
2452
2453TODO
2454
2455@node SH4 System emulator
2456@section SH4 System emulator
2457@cindex system emulation (SH4)
2458
2459TODO
2460
3aeaea65
MF
2461@node Xtensa System emulator
2462@section Xtensa System emulator
2463@cindex system emulation (Xtensa)
2464
2465Two executables cover simulation of both Xtensa endian options,
2466@file{qemu-system-xtensa} and @file{qemu-system-xtensaeb}.
2467Two different machine types are emulated:
2468
2469@itemize @minus
2470@item
2471Xtensa emulator pseudo board "sim"
2472@item
2473Avnet LX60/LX110/LX200 board
2474@end itemize
2475
b5e4946f 2476The sim pseudo board emulation provides an environment similar
3aeaea65
MF
2477to one provided by the proprietary Tensilica ISS.
2478It supports:
2479
2480@itemize @minus
2481@item
2482A range of Xtensa CPUs, default is the DC232B
2483@item
2484Console and filesystem access via semihosting calls
2485@end itemize
2486
2487The Avnet LX60/LX110/LX200 emulation supports:
2488
2489@itemize @minus
2490@item
2491A range of Xtensa CPUs, default is the DC232B
2492@item
249316550 UART
2494@item
2495OpenCores 10/100 Mbps Ethernet MAC
2496@end itemize
2497
2498@c man begin OPTIONS
2499
2500The following options are specific to the Xtensa emulation:
2501
2502@table @option
2503
2504@item -semihosting
2505Enable semihosting syscall emulation.
2506
2507Xtensa semihosting provides basic file IO calls, such as open/read/write/seek/select.
2508Tensilica baremetal libc for ISS and linux platform "sim" use this interface.
2509
2510Note that this allows guest direct access to the host filesystem,
2511so should only be used with trusted guest OS.
2512
2513@end table
3f2ce724 2514
abc67eb6
TH
2515@c man end
2516
5fafdf24
TS
2517@node QEMU User space emulator
2518@chapter QEMU User space emulator
83195237
FB
2519
2520@menu
2521* Supported Operating Systems ::
0722cc42 2522* Features::
83195237 2523* Linux User space emulator::
84778508 2524* BSD User space emulator ::
83195237
FB
2525@end menu
2526
2527@node Supported Operating Systems
2528@section Supported Operating Systems
2529
2530The following OS are supported in user space emulation:
2531
2532@itemize @minus
2533@item
4be456f1 2534Linux (referred as qemu-linux-user)
83195237 2535@item
84778508 2536BSD (referred as qemu-bsd-user)
83195237
FB
2537@end itemize
2538
0722cc42
PB
2539@node Features
2540@section Features
2541
2542QEMU user space emulation has the following notable features:
2543
2544@table @strong
2545@item System call translation:
2546QEMU includes a generic system call translator. This means that
2547the parameters of the system calls can be converted to fix
2548endianness and 32/64-bit mismatches between hosts and targets.
2549IOCTLs can be converted too.
2550
2551@item POSIX signal handling:
2552QEMU can redirect to the running program all signals coming from
2553the host (such as @code{SIGALRM}), as well as synthesize signals from
2554virtual CPU exceptions (for example @code{SIGFPE} when the program
2555executes a division by zero).
2556
2557QEMU relies on the host kernel to emulate most signal system
2558calls, for example to emulate the signal mask. On Linux, QEMU
2559supports both normal and real-time signals.
2560
2561@item Threading:
2562On Linux, QEMU can emulate the @code{clone} syscall and create a real
2563host thread (with a separate virtual CPU) for each emulated thread.
2564Note that not all targets currently emulate atomic operations correctly.
2565x86 and ARM use a global lock in order to preserve their semantics.
2566@end table
2567
2568QEMU was conceived so that ultimately it can emulate itself. Although
2569it is not very useful, it is an important test to show the power of the
2570emulator.
2571
83195237
FB
2572@node Linux User space emulator
2573@section Linux User space emulator
386405f7 2574
debc7065
FB
2575@menu
2576* Quick Start::
2577* Wine launch::
2578* Command line options::
79737e4a 2579* Other binaries::
debc7065
FB
2580@end menu
2581
2582@node Quick Start
83195237 2583@subsection Quick Start
df0f11a0 2584
1f673135 2585In order to launch a Linux process, QEMU needs the process executable
5fafdf24 2586itself and all the target (x86) dynamic libraries used by it.
386405f7 2587
1f673135 2588@itemize
386405f7 2589
1f673135
FB
2590@item On x86, you can just try to launch any process by using the native
2591libraries:
386405f7 2592
5fafdf24 2593@example
1f673135
FB
2594qemu-i386 -L / /bin/ls
2595@end example
386405f7 2596
1f673135
FB
2597@code{-L /} tells that the x86 dynamic linker must be searched with a
2598@file{/} prefix.
386405f7 2599
b65ee4fa
SW
2600@item Since QEMU is also a linux process, you can launch QEMU with
2601QEMU (NOTE: you can only do that if you compiled QEMU from the sources):
386405f7 2602
5fafdf24 2603@example
1f673135
FB
2604qemu-i386 -L / qemu-i386 -L / /bin/ls
2605@end example
386405f7 2606
1f673135
FB
2607@item On non x86 CPUs, you need first to download at least an x86 glibc
2608(@file{qemu-runtime-i386-XXX-.tar.gz} on the QEMU web page). Ensure that
2609@code{LD_LIBRARY_PATH} is not set:
df0f11a0 2610
1f673135 2611@example
5fafdf24 2612unset LD_LIBRARY_PATH
1f673135 2613@end example
1eb87257 2614
1f673135 2615Then you can launch the precompiled @file{ls} x86 executable:
1eb87257 2616
1f673135
FB
2617@example
2618qemu-i386 tests/i386/ls
2619@end example
4c3b5a48 2620You can look at @file{scripts/qemu-binfmt-conf.sh} so that
1f673135
FB
2621QEMU is automatically launched by the Linux kernel when you try to
2622launch x86 executables. It requires the @code{binfmt_misc} module in the
2623Linux kernel.
1eb87257 2624
1f673135
FB
2625@item The x86 version of QEMU is also included. You can try weird things such as:
2626@example
debc7065
FB
2627qemu-i386 /usr/local/qemu-i386/bin/qemu-i386 \
2628 /usr/local/qemu-i386/bin/ls-i386
1f673135 2629@end example
1eb20527 2630
1f673135 2631@end itemize
1eb20527 2632
debc7065 2633@node Wine launch
83195237 2634@subsection Wine launch
1eb20527 2635
1f673135 2636@itemize
386405f7 2637
1f673135
FB
2638@item Ensure that you have a working QEMU with the x86 glibc
2639distribution (see previous section). In order to verify it, you must be
2640able to do:
386405f7 2641
1f673135
FB
2642@example
2643qemu-i386 /usr/local/qemu-i386/bin/ls-i386
2644@end example
386405f7 2645
1f673135 2646@item Download the binary x86 Wine install
5fafdf24 2647(@file{qemu-XXX-i386-wine.tar.gz} on the QEMU web page).
386405f7 2648
1f673135 2649@item Configure Wine on your account. Look at the provided script
debc7065 2650@file{/usr/local/qemu-i386/@/bin/wine-conf.sh}. Your previous
1f673135 2651@code{$@{HOME@}/.wine} directory is saved to @code{$@{HOME@}/.wine.org}.
386405f7 2652
1f673135 2653@item Then you can try the example @file{putty.exe}:
386405f7 2654
1f673135 2655@example
debc7065
FB
2656qemu-i386 /usr/local/qemu-i386/wine/bin/wine \
2657 /usr/local/qemu-i386/wine/c/Program\ Files/putty.exe
1f673135 2658@end example
386405f7 2659
1f673135 2660@end itemize
fd429f2f 2661
debc7065 2662@node Command line options
83195237 2663@subsection Command line options
1eb20527 2664
1f673135 2665@example
8485140f 2666@command{qemu-i386} [@option{-h]} [@option{-d]} [@option{-L} @var{path}] [@option{-s} @var{size}] [@option{-cpu} @var{model}] [@option{-g} @var{port}] [@option{-B} @var{offset}] [@option{-R} @var{size}] @var{program} [@var{arguments}...]
1f673135 2667@end example
1eb20527 2668
1f673135
FB
2669@table @option
2670@item -h
2671Print the help
3b46e624 2672@item -L path
1f673135
FB
2673Set the x86 elf interpreter prefix (default=/usr/local/qemu-i386)
2674@item -s size
2675Set the x86 stack size in bytes (default=524288)
34a3d239 2676@item -cpu model
c8057f95 2677Select CPU model (-cpu help for list and additional feature selection)
f66724c9
SW
2678@item -E @var{var}=@var{value}
2679Set environment @var{var} to @var{value}.
2680@item -U @var{var}
2681Remove @var{var} from the environment.
379f6698
PB
2682@item -B offset
2683Offset guest address by the specified number of bytes. This is useful when
1f5c3f8c
SW
2684the address region required by guest applications is reserved on the host.
2685This option is currently only supported on some hosts.
68a1c816
PB
2686@item -R size
2687Pre-allocate a guest virtual address space of the given size (in bytes).
0d6753e5 2688"G", "M", and "k" suffixes may be used when specifying the size.
386405f7
FB
2689@end table
2690
1f673135 2691Debug options:
386405f7 2692
1f673135 2693@table @option
989b697d
PM
2694@item -d item1,...
2695Activate logging of the specified items (use '-d help' for a list of log items)
1f673135
FB
2696@item -p pagesize
2697Act as if the host page size was 'pagesize' bytes
34a3d239
BS
2698@item -g port
2699Wait gdb connection to port
1b530a6d
AJ
2700@item -singlestep
2701Run the emulation in single step mode.
1f673135 2702@end table
386405f7 2703
b01bcae6
AZ
2704Environment variables:
2705
2706@table @env
2707@item QEMU_STRACE
2708Print system calls and arguments similar to the 'strace' program
2709(NOTE: the actual 'strace' program will not work because the user
2710space emulator hasn't implemented ptrace). At the moment this is
2711incomplete. All system calls that don't have a specific argument
2712format are printed with information for six arguments. Many
2713flag-style arguments don't have decoders and will show up as numbers.
5cfdf930 2714@end table
b01bcae6 2715
79737e4a 2716@node Other binaries
83195237 2717@subsection Other binaries
79737e4a 2718
7544a042
SW
2719@cindex user mode (Alpha)
2720@command{qemu-alpha} TODO.
2721
2722@cindex user mode (ARM)
2723@command{qemu-armeb} TODO.
2724
2725@cindex user mode (ARM)
79737e4a
PB
2726@command{qemu-arm} is also capable of running ARM "Angel" semihosted ELF
2727binaries (as implemented by the arm-elf and arm-eabi Newlib/GDB
2728configurations), and arm-uclinux bFLT format binaries.
2729
7544a042
SW
2730@cindex user mode (ColdFire)
2731@cindex user mode (M68K)
e6e5906b
PB
2732@command{qemu-m68k} is capable of running semihosted binaries using the BDM
2733(m5xxx-ram-hosted.ld) or m68k-sim (sim.ld) syscall interfaces, and
2734coldfire uClinux bFLT format binaries.
2735
79737e4a
PB
2736The binary format is detected automatically.
2737
7544a042
SW
2738@cindex user mode (Cris)
2739@command{qemu-cris} TODO.
2740
2741@cindex user mode (i386)
2742@command{qemu-i386} TODO.
2743@command{qemu-x86_64} TODO.
2744
2745@cindex user mode (Microblaze)
2746@command{qemu-microblaze} TODO.
2747
2748@cindex user mode (MIPS)
8639c5c9
AM
2749@command{qemu-mips} executes 32-bit big endian MIPS binaries (MIPS O32 ABI).
2750
2751@command{qemu-mipsel} executes 32-bit little endian MIPS binaries (MIPS O32 ABI).
2752
2753@command{qemu-mips64} executes 64-bit big endian MIPS binaries (MIPS N64 ABI).
2754
2755@command{qemu-mips64el} executes 64-bit little endian MIPS binaries (MIPS N64 ABI).
2756
2757@command{qemu-mipsn32} executes 32-bit big endian MIPS binaries (MIPS N32 ABI).
2758
2759@command{qemu-mipsn32el} executes 32-bit little endian MIPS binaries (MIPS N32 ABI).
7544a042 2760
e671711c
MV
2761@cindex user mode (NiosII)
2762@command{qemu-nios2} TODO.
2763
7544a042
SW
2764@cindex user mode (PowerPC)
2765@command{qemu-ppc64abi32} TODO.
2766@command{qemu-ppc64} TODO.
2767@command{qemu-ppc} TODO.
2768
2769@cindex user mode (SH4)
2770@command{qemu-sh4eb} TODO.
2771@command{qemu-sh4} TODO.
2772
2773@cindex user mode (SPARC)
34a3d239
BS
2774@command{qemu-sparc} can execute Sparc32 binaries (Sparc32 CPU, 32 bit ABI).
2775
a785e42e
BS
2776@command{qemu-sparc32plus} can execute Sparc32 and SPARC32PLUS binaries
2777(Sparc64 CPU, 32 bit ABI).
2778
2779@command{qemu-sparc64} can execute some Sparc64 (Sparc64 CPU, 64 bit ABI) and
2780SPARC32PLUS binaries (Sparc64 CPU, 32 bit ABI).
2781
84778508
BS
2782@node BSD User space emulator
2783@section BSD User space emulator
2784
2785@menu
2786* BSD Status::
2787* BSD Quick Start::
2788* BSD Command line options::
2789@end menu
2790
2791@node BSD Status
2792@subsection BSD Status
2793
2794@itemize @minus
2795@item
2796target Sparc64 on Sparc64: Some trivial programs work.
2797@end itemize
2798
2799@node BSD Quick Start
2800@subsection Quick Start
2801
2802In order to launch a BSD process, QEMU needs the process executable
2803itself and all the target dynamic libraries used by it.
2804
2805@itemize
2806
2807@item On Sparc64, you can just try to launch any process by using the native
2808libraries:
2809
2810@example
2811qemu-sparc64 /bin/ls
2812@end example
2813
2814@end itemize
2815
2816@node BSD Command line options
2817@subsection Command line options
2818
2819@example
8485140f 2820@command{qemu-sparc64} [@option{-h]} [@option{-d]} [@option{-L} @var{path}] [@option{-s} @var{size}] [@option{-bsd} @var{type}] @var{program} [@var{arguments}...]
84778508
BS
2821@end example
2822
2823@table @option
2824@item -h
2825Print the help
2826@item -L path
2827Set the library root path (default=/)
2828@item -s size
2829Set the stack size in bytes (default=524288)
f66724c9
SW
2830@item -ignore-environment
2831Start with an empty environment. Without this option,
40c5c6cd 2832the initial environment is a copy of the caller's environment.
f66724c9
SW
2833@item -E @var{var}=@var{value}
2834Set environment @var{var} to @var{value}.
2835@item -U @var{var}
2836Remove @var{var} from the environment.
84778508
BS
2837@item -bsd type
2838Set the type of the emulated BSD Operating system. Valid values are
2839FreeBSD, NetBSD and OpenBSD (default).
2840@end table
2841
2842Debug options:
2843
2844@table @option
989b697d
PM
2845@item -d item1,...
2846Activate logging of the specified items (use '-d help' for a list of log items)
84778508
BS
2847@item -p pagesize
2848Act as if the host page size was 'pagesize' bytes
1b530a6d
AJ
2849@item -singlestep
2850Run the emulation in single step mode.
84778508
BS
2851@end table
2852
483c6ad4
BP
2853@node System requirements
2854@chapter System requirements
2855
2856@section KVM kernel module
2857
2858On x86_64 hosts, the default set of CPU features enabled by the KVM accelerator
2859require the host to be running Linux v4.5 or newer.
2860
2861The OpteronG[345] CPU models require KVM support for RDTSCP, which was
2862added with Linux 4.5 which is supported by the major distros. And even
2863if RHEL7 has kernel 3.10, KVM there has the required functionality there
2864to make it close to a 4.5 or newer kernel.
47eacb4f 2865
e8412576
SH
2866@include docs/security.texi
2867
78e87797
PB
2868@include qemu-tech.texi
2869
44c67847 2870@include qemu-deprecated.texi
efe2add7 2871
45b47130
DB
2872@node Supported build platforms
2873@appendix Supported build platforms
2874
2875QEMU aims to support building and executing on multiple host OS platforms.
2876This appendix outlines which platforms are the major build targets. These
2877platforms are used as the basis for deciding upon the minimum required
2878versions of 3rd party software QEMU depends on. The supported platforms
2879are the targets for automated testing performed by the project when patches
2880are submitted for review, and tested before and after merge.
2881
2882If a platform is not listed here, it does not imply that QEMU won't work.
2883If an unlisted platform has comparable software versions to a listed platform,
2884there is every expectation that it will work. Bug reports are welcome for
2885problems encountered on unlisted platforms unless they are clearly older
2886vintage than what is described here.
2887
2888Note that when considering software versions shipped in distros as support
2889targets, QEMU considers only the version number, and assumes the features in
2890that distro match the upstream release with the same version. In other words,
2891if a distro backports extra features to the software in their distro, QEMU
2892upstream code will not add explicit support for those backports, unless the
2893feature is auto-detectable in a manner that works for the upstream releases
2894too.
2895
2896The Repology site @url{https://repology.org} is a useful resource to identify
2897currently shipped versions of software in various operating systems, though
2898it does not cover all distros listed below.
2899
2900@section Linux OS
2901
2902For distributions with frequent, short-lifetime releases, the project will
2903aim to support all versions that are not end of life by their respective
2904vendors. For the purposes of identifying supported software versions, the
2905project will look at Fedora, Ubuntu, and openSUSE distros. Other short-
2906lifetime distros will be assumed to ship similar software versions.
2907
2908For distributions with long-lifetime releases, the project will aim to support
2909the most recent major version at all times. Support for the previous major
2910version will be dropped 2 years after the new major version is released. For
2911the purposes of identifying supported software versions, the project will look
2912at RHEL, Debian, Ubuntu LTS, and SLES distros. Other long-lifetime distros will
2913be assumed to ship similar software versions.
2914
2915@section Windows
2916
2917The project supports building with current versions of the MinGW toolchain,
2918hosted on Linux.
2919
2920@section macOS
2921
2922The project supports building with the two most recent versions of macOS, with
2923the current homebrew package set available.
2924
2925@section FreeBSD
2926
2927The project aims to support the all the versions which are not end of life.
2928
2929@section NetBSD
2930
2931The project aims to support the most recent major version at all times. Support
2932for the previous major version will be dropped 2 years after the new major
2933version is released.
2934
2935@section OpenBSD
2936
2937The project aims to support the all the versions which are not end of life.
2938
7544a042
SW
2939@node License
2940@appendix License
2941
2942QEMU is a trademark of Fabrice Bellard.
2943
2f8d8f01
TH
2944QEMU is released under the
2945@url{https://www.gnu.org/licenses/gpl-2.0.txt,GNU General Public License},
2946version 2. Parts of QEMU have specific licenses, see file
70b7fba9 2947@url{https://git.qemu.org/?p=qemu.git;a=blob_plain;f=LICENSE,LICENSE}.
7544a042 2948
debc7065 2949@node Index
7544a042
SW
2950@appendix Index
2951@menu
2952* Concept Index::
2953* Function Index::
2954* Keystroke Index::
2955* Program Index::
2956* Data Type Index::
2957* Variable Index::
2958@end menu
2959
2960@node Concept Index
2961@section Concept Index
2962This is the main index. Should we combine all keywords in one index? TODO
debc7065
FB
2963@printindex cp
2964
7544a042
SW
2965@node Function Index
2966@section Function Index
2967This index could be used for command line options and monitor functions.
2968@printindex fn
2969
2970@node Keystroke Index
2971@section Keystroke Index
2972
2973This is a list of all keystrokes which have a special function
2974in system emulation.
2975
2976@printindex ky
2977
2978@node Program Index
2979@section Program Index
2980@printindex pg
2981
2982@node Data Type Index
2983@section Data Type Index
2984
2985This index could be used for qdev device names and options.
2986
2987@printindex tp
2988
2989@node Variable Index
2990@section Variable Index
2991@printindex vr
2992
debc7065 2993@bye