bellard | 386405f | 2003-03-23 21:28:45 +0000 | [diff] [blame] | 1 | \input texinfo @c -*- texinfo -*- |
| 2 | |
bellard | 0806e3f | 2003-10-01 00:15:32 +0000 | [diff] [blame] | 3 | @iftex |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 4 | @settitle QEMU CPU Emulator User Documentation |
bellard | 386405f | 2003-03-23 21:28:45 +0000 | [diff] [blame] | 5 | @titlepage |
| 6 | @sp 7 |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 7 | @center @titlefont{QEMU CPU Emulator User Documentation} |
bellard | 386405f | 2003-03-23 21:28:45 +0000 | [diff] [blame] | 8 | @sp 3 |
| 9 | @end titlepage |
bellard | 0806e3f | 2003-10-01 00:15:32 +0000 | [diff] [blame] | 10 | @end iftex |
bellard | 386405f | 2003-03-23 21:28:45 +0000 | [diff] [blame] | 11 | |
| 12 | @chapter Introduction |
| 13 | |
bellard | 322d0c6 | 2003-06-15 23:29:28 +0000 | [diff] [blame] | 14 | @section Features |
bellard | 386405f | 2003-03-23 21:28:45 +0000 | [diff] [blame] | 15 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 16 | QEMU is a FAST! processor emulator using dynamic translation to |
| 17 | achieve good emulation speed. |
bellard | 1eb2052 | 2003-06-25 16:21:49 +0000 | [diff] [blame] | 18 | |
| 19 | QEMU has two operating modes: |
bellard | 0806e3f | 2003-10-01 00:15:32 +0000 | [diff] [blame] | 20 | |
| 21 | @itemize @minus |
| 22 | |
| 23 | @item |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 24 | Full system emulation. In this mode, QEMU emulates a full system (for |
| 25 | example a PC), including a processor and various peripherials. It can |
| 26 | be used to launch different Operating Systems without rebooting the |
| 27 | PC or to debug system code. |
bellard | 1eb2052 | 2003-06-25 16:21:49 +0000 | [diff] [blame] | 28 | |
bellard | 0806e3f | 2003-10-01 00:15:32 +0000 | [diff] [blame] | 29 | @item |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 30 | User mode emulation (Linux host only). In this mode, QEMU can launch |
| 31 | Linux processes compiled for one CPU on another CPU. It can be used to |
| 32 | launch the Wine Windows API emulator (@url{http://www.winehq.org}) or |
| 33 | to ease cross-compilation and cross-debugging. |
bellard | 1eb2052 | 2003-06-25 16:21:49 +0000 | [diff] [blame] | 34 | |
| 35 | @end itemize |
| 36 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 37 | As QEMU requires no host kernel driver to run, it is very safe and |
bellard | 1eb2052 | 2003-06-25 16:21:49 +0000 | [diff] [blame] | 38 | easy to use. |
bellard | 322d0c6 | 2003-06-15 23:29:28 +0000 | [diff] [blame] | 39 | |
bellard | 52c00a5 | 2004-04-25 21:27:03 +0000 | [diff] [blame^] | 40 | For system emulation, the following hardware targets are supported: |
| 41 | @itemize |
| 42 | @item PC (x86 processor) |
| 43 | @item PREP (PowerPC processor) |
| 44 | @end itemize |
bellard | 386405f | 2003-03-23 21:28:45 +0000 | [diff] [blame] | 45 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 46 | For user emulation, x86, PowerPC, ARM, and SPARC CPUs are supported. |
bellard | 0806e3f | 2003-10-01 00:15:32 +0000 | [diff] [blame] | 47 | |
bellard | 5b9f457 | 2003-10-28 00:49:54 +0000 | [diff] [blame] | 48 | @chapter Installation |
| 49 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 50 | @section Linux |
| 51 | |
bellard | 5b9f457 | 2003-10-28 00:49:54 +0000 | [diff] [blame] | 52 | If you want to compile QEMU, please read the @file{README} which gives |
| 53 | the related information. Otherwise just download the binary |
| 54 | distribution (@file{qemu-XXX-i386.tar.gz}) and untar it as root in |
| 55 | @file{/}: |
| 56 | |
| 57 | @example |
| 58 | su |
| 59 | cd / |
| 60 | tar zxvf /tmp/qemu-XXX-i386.tar.gz |
| 61 | @end example |
| 62 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 63 | @section Windows |
| 64 | w |
bellard | d691f66 | 2003-03-24 21:58:34 +0000 | [diff] [blame] | 65 | @itemize |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 66 | @item Install the current versions of MSYS and MinGW from |
| 67 | @url{http://www.mingw.org/}. You can find detailed installation |
| 68 | instructions in the download section and the FAQ. |
bellard | d691f66 | 2003-03-24 21:58:34 +0000 | [diff] [blame] | 69 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 70 | @item Download |
| 71 | the MinGW development library of SDL 1.2.x |
| 72 | (@file{SDL-devel-1.2.x-mingw32.tar.gz}) from |
| 73 | @url{http://www.libsdl.org}. Unpack it in a temporary place, and |
| 74 | unpack the archive @file{i386-mingw32msvc.tar.gz} in the MinGW tool |
| 75 | directory. Edit the @file{sdl-config} script so that it gives the |
| 76 | correct SDL directory when invoked. |
bellard | 386405f | 2003-03-23 21:28:45 +0000 | [diff] [blame] | 77 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 78 | @item Extract the current version of QEMU. |
| 79 | |
| 80 | @item Start the MSYS shell (file @file{msys.bat}). |
bellard | 386405f | 2003-03-23 21:28:45 +0000 | [diff] [blame] | 81 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 82 | @item Change to the QEMU directory. Launch @file{./configure} and |
| 83 | @file{make}. If you have problems using SDL, verify that |
| 84 | @file{sdl-config} can be launched from the MSYS command line. |
bellard | 386405f | 2003-03-23 21:28:45 +0000 | [diff] [blame] | 85 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 86 | @item You can install QEMU in @file{Program Files/Qemu} by typing |
| 87 | @file{make install}. Don't forget to copy @file{SDL.dll} in |
| 88 | @file{Program Files/Qemu}. |
bellard | 1eb8725 | 2003-04-11 01:12:28 +0000 | [diff] [blame] | 89 | |
bellard | 168485b | 2003-03-29 16:57:34 +0000 | [diff] [blame] | 90 | @end itemize |
| 91 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 92 | @section Cross compilation for Windows with Linux |
bellard | 168485b | 2003-03-29 16:57:34 +0000 | [diff] [blame] | 93 | |
| 94 | @itemize |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 95 | @item |
| 96 | Install the MinGW cross compilation tools available at |
| 97 | @url{http://www.mingw.org/}. |
bellard | 168485b | 2003-03-29 16:57:34 +0000 | [diff] [blame] | 98 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 99 | @item |
| 100 | Install the Win32 version of SDL (@url{http://www.libsdl.org}) by |
| 101 | unpacking @file{i386-mingw32msvc.tar.gz}. Set up the PATH environment |
| 102 | variable so that @file{i386-mingw32msvc-sdl-config} can be launched by |
| 103 | the QEMU configuration script. |
bellard | 168485b | 2003-03-29 16:57:34 +0000 | [diff] [blame] | 104 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 105 | @item |
| 106 | Configure QEMU for Windows cross compilation: |
bellard | 168485b | 2003-03-29 16:57:34 +0000 | [diff] [blame] | 107 | @example |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 108 | ./configure --enable-mingw32 |
bellard | 168485b | 2003-03-29 16:57:34 +0000 | [diff] [blame] | 109 | @end example |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 110 | If necessary, you can change the cross-prefix according to the prefix |
| 111 | choosen for the MinGW tools with --cross-prefix. You can also use |
| 112 | --prefix to set the Win32 install path. |
bellard | 168485b | 2003-03-29 16:57:34 +0000 | [diff] [blame] | 113 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 114 | @item You can install QEMU in the installation directory by typing |
| 115 | @file{make install}. Don't forget to copy @file{SDL.dll} in the |
| 116 | installation directory. |
bellard | d691f66 | 2003-03-24 21:58:34 +0000 | [diff] [blame] | 117 | |
| 118 | @end itemize |
| 119 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 120 | Note: Currently, Wine does not seem able to launch |
| 121 | QEMU for Win32. |
bellard | d691f66 | 2003-03-24 21:58:34 +0000 | [diff] [blame] | 122 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 123 | @section Mac OS X |
bellard | d691f66 | 2003-03-24 21:58:34 +0000 | [diff] [blame] | 124 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 125 | Mac OS X is currently not supported. |
bellard | df0f11a | 2003-05-28 00:27:57 +0000 | [diff] [blame] | 126 | |
bellard | 52c00a5 | 2004-04-25 21:27:03 +0000 | [diff] [blame^] | 127 | @chapter QEMU PC System emulator invocation |
bellard | 1eb2052 | 2003-06-25 16:21:49 +0000 | [diff] [blame] | 128 | |
bellard | 0806e3f | 2003-10-01 00:15:32 +0000 | [diff] [blame] | 129 | @section Introduction |
| 130 | |
| 131 | @c man begin DESCRIPTION |
| 132 | |
bellard | 52c00a5 | 2004-04-25 21:27:03 +0000 | [diff] [blame^] | 133 | The QEMU System emulator simulates a complete PC. |
bellard | 0806e3f | 2003-10-01 00:15:32 +0000 | [diff] [blame] | 134 | |
| 135 | In order to meet specific user needs, two versions of QEMU are |
| 136 | available: |
| 137 | |
| 138 | @enumerate |
| 139 | |
| 140 | @item |
bellard | 285dc33 | 2003-10-27 23:58:04 +0000 | [diff] [blame] | 141 | @code{qemu-fast} uses the host Memory Management Unit (MMU) to simulate |
bellard | 0806e3f | 2003-10-01 00:15:32 +0000 | [diff] [blame] | 142 | the x86 MMU. It is @emph{fast} but has limitations because the whole 4 GB |
| 143 | address space cannot be used and some memory mapped peripherials |
| 144 | cannot be emulated accurately yet. Therefore, a specific Linux kernel |
| 145 | must be used (@xref{linux_compile}). |
| 146 | |
| 147 | @item |
bellard | 285dc33 | 2003-10-27 23:58:04 +0000 | [diff] [blame] | 148 | @code{qemu} uses a software MMU. It is about @emph{two times |
| 149 | slower} but gives a more accurate emulation. |
bellard | 0806e3f | 2003-10-01 00:15:32 +0000 | [diff] [blame] | 150 | |
| 151 | @end enumerate |
| 152 | |
| 153 | QEMU emulates the following PC peripherials: |
| 154 | |
| 155 | @itemize @minus |
| 156 | @item |
| 157 | VGA (hardware level, including all non standard modes) |
| 158 | @item |
| 159 | PS/2 mouse and keyboard |
| 160 | @item |
bellard | 181f155 | 2003-11-13 01:47:16 +0000 | [diff] [blame] | 161 | 2 IDE interfaces with hard disk and CD-ROM support |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 162 | @item |
| 163 | Floppy disk |
bellard | 0806e3f | 2003-10-01 00:15:32 +0000 | [diff] [blame] | 164 | @item |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 165 | up to 6 NE2000 network adapters |
bellard | 0806e3f | 2003-10-01 00:15:32 +0000 | [diff] [blame] | 166 | @item |
bellard | 181f155 | 2003-11-13 01:47:16 +0000 | [diff] [blame] | 167 | Serial port |
| 168 | @item |
| 169 | Soundblaster 16 card |
bellard | 0806e3f | 2003-10-01 00:15:32 +0000 | [diff] [blame] | 170 | @end itemize |
| 171 | |
| 172 | @c man end |
| 173 | |
bellard | 1eb2052 | 2003-06-25 16:21:49 +0000 | [diff] [blame] | 174 | @section Quick Start |
| 175 | |
bellard | 285dc33 | 2003-10-27 23:58:04 +0000 | [diff] [blame] | 176 | Download and uncompress the linux image (@file{linux.img}) and type: |
bellard | 0806e3f | 2003-10-01 00:15:32 +0000 | [diff] [blame] | 177 | |
| 178 | @example |
bellard | 285dc33 | 2003-10-27 23:58:04 +0000 | [diff] [blame] | 179 | qemu linux.img |
bellard | 0806e3f | 2003-10-01 00:15:32 +0000 | [diff] [blame] | 180 | @end example |
| 181 | |
| 182 | Linux should boot and give you a prompt. |
| 183 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 184 | @section Invocation |
| 185 | |
| 186 | @example |
| 187 | @c man begin SYNOPSIS |
| 188 | usage: qemu [options] [disk_image] |
| 189 | @c man end |
| 190 | @end example |
| 191 | |
| 192 | @c man begin OPTIONS |
| 193 | @var{disk_image} is a raw hard disk image for IDE hard disk 0. |
| 194 | |
| 195 | General options: |
| 196 | @table @option |
| 197 | @item -fda file |
| 198 | @item -fdb file |
| 199 | Use @var{file} as floppy disk 0/1 image (@xref{disk_images}). |
| 200 | |
| 201 | @item -hda file |
| 202 | @item -hdb file |
| 203 | @item -hdc file |
| 204 | @item -hdd file |
| 205 | Use @var{file} as hard disk 0, 1, 2 or 3 image (@xref{disk_images}). |
| 206 | |
| 207 | @item -cdrom file |
| 208 | Use @var{file} as CD-ROM image (you cannot use @option{-hdc} and and |
| 209 | @option{-cdrom} at the same time). |
| 210 | |
| 211 | @item -boot [a|c|d] |
| 212 | Boot on floppy (a), hard disk (c) or CD-ROM (d). Hard disk boot is |
| 213 | the default. |
| 214 | |
| 215 | @item -snapshot |
| 216 | Write to temporary files instead of disk image files. In this case, |
| 217 | the raw disk image you use is not written back. You can however force |
| 218 | the write back by pressing @key{C-a s} (@xref{disk_images}). |
| 219 | |
| 220 | @item -m megs |
| 221 | Set virtual RAM size to @var{megs} megabytes. |
| 222 | |
| 223 | @item -initrd file |
| 224 | Use @var{file} as initial ram disk. |
| 225 | |
| 226 | @item -nographic |
| 227 | |
| 228 | Normally, QEMU uses SDL to display the VGA output. With this option, |
| 229 | you can totally disable graphical output so that QEMU is a simple |
| 230 | command line application. The emulated serial port is redirected on |
| 231 | the console. Therefore, you can still use QEMU to debug a Linux kernel |
| 232 | with a serial console. |
| 233 | |
| 234 | @end table |
| 235 | |
| 236 | Network options: |
| 237 | |
| 238 | @table @option |
| 239 | |
| 240 | @item -n script |
bellard | 52c00a5 | 2004-04-25 21:27:03 +0000 | [diff] [blame^] | 241 | Set TUN/TAP network init script [default=/etc/qemu-ifup]. This script |
| 242 | is launched to configure the host network interface (usually tun0) |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 243 | corresponding to the virtual NE2000 card. |
| 244 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 245 | @item -macaddr addr |
| 246 | |
| 247 | Set the mac address of the first interface (the format is |
| 248 | aa:bb:cc:dd:ee:ff in hexa). The mac address is incremented for each |
| 249 | new network interface. |
| 250 | |
bellard | 52c00a5 | 2004-04-25 21:27:03 +0000 | [diff] [blame^] | 251 | @item -tun-fd fd |
| 252 | Assumes @var{fd} talks to a tap/tun host network interface and use |
| 253 | it. Read @url{http://bellard.org/qemu/tetrinet.html} to have an |
| 254 | example of its use. |
| 255 | |
| 256 | @item -user-net |
| 257 | (Experimental) Use the user mode network stack. This is the default if |
| 258 | no tun/tap network init script is found. |
| 259 | |
| 260 | @item -dummy-net |
| 261 | Use the dummy network stack: no packet will be received on the network |
| 262 | cards. |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 263 | |
| 264 | @end table |
| 265 | |
| 266 | Linux boot specific. When using this options, you can use a given |
| 267 | Linux kernel without installing it in the disk image. It can be useful |
| 268 | for easier testing of various kernels. |
| 269 | |
| 270 | @table @option |
| 271 | |
| 272 | @item -kernel bzImage |
| 273 | Use @var{bzImage} as kernel image. |
| 274 | |
| 275 | @item -append cmdline |
| 276 | Use @var{cmdline} as kernel command line |
| 277 | |
| 278 | @item -initrd file |
| 279 | Use @var{file} as initial ram disk. |
| 280 | |
| 281 | @end table |
| 282 | |
| 283 | Debug options: |
| 284 | @table @option |
| 285 | @item -s |
| 286 | Wait gdb connection to port 1234 (@xref{gdb_usage}). |
| 287 | @item -p port |
| 288 | Change gdb connection port. |
bellard | 52c00a5 | 2004-04-25 21:27:03 +0000 | [diff] [blame^] | 289 | @item -S |
| 290 | Do not start CPU at startup (you must type 'c' in the monitor). |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 291 | @item -d |
| 292 | Output log in /tmp/qemu.log |
| 293 | @end table |
| 294 | |
| 295 | During emulation, if you are using the serial console, use @key{C-a h} |
| 296 | to get terminal commands: |
| 297 | |
| 298 | @table @key |
| 299 | @item C-a h |
| 300 | Print this help |
| 301 | @item C-a x |
| 302 | Exit emulatior |
| 303 | @item C-a s |
| 304 | Save disk data back to file (if -snapshot) |
| 305 | @item C-a b |
| 306 | Send break (magic sysrq in Linux) |
| 307 | @item C-a c |
| 308 | Switch between console and monitor |
| 309 | @item C-a C-a |
| 310 | Send C-a |
| 311 | @end table |
| 312 | @c man end |
| 313 | |
| 314 | @ignore |
| 315 | |
| 316 | @setfilename qemu |
| 317 | @settitle QEMU System Emulator |
| 318 | |
| 319 | @c man begin SEEALSO |
| 320 | The HTML documentation of QEMU for more precise information and Linux |
| 321 | user mode emulator invocation. |
| 322 | @c man end |
| 323 | |
| 324 | @c man begin AUTHOR |
| 325 | Fabrice Bellard |
| 326 | @c man end |
| 327 | |
| 328 | @end ignore |
| 329 | |
| 330 | @end ignore |
| 331 | |
| 332 | |
| 333 | @section QEMU Monitor |
| 334 | |
| 335 | The QEMU monitor is used to give complex commands to the QEMU |
| 336 | emulator. You can use it to: |
| 337 | |
| 338 | @itemize @minus |
| 339 | |
| 340 | @item |
| 341 | Remove or insert removable medias images |
| 342 | (such as CD-ROM or floppies) |
| 343 | |
| 344 | @item |
| 345 | Freeze/unfreeze the Virtual Machine (VM) and save or restore its state |
| 346 | from a disk file. |
| 347 | |
| 348 | @item Inspect the VM state without an external debugger. |
| 349 | |
| 350 | @end itemize |
| 351 | |
| 352 | @subsection Commands |
| 353 | |
| 354 | The following commands are available: |
| 355 | |
| 356 | @table @option |
| 357 | |
| 358 | @item help or ? [cmd] |
| 359 | Show the help for all commands or just for command @var{cmd}. |
| 360 | |
| 361 | @item commit |
| 362 | Commit changes to the disk images (if -snapshot is used) |
| 363 | |
| 364 | @item info subcommand |
| 365 | show various information about the system state |
| 366 | |
| 367 | @table @option |
| 368 | @item info network |
| 369 | show the network state |
| 370 | @item info block |
| 371 | show the block devices |
| 372 | @item info registers |
| 373 | show the cpu registers |
| 374 | @item info history |
| 375 | show the command line history |
| 376 | @end table |
| 377 | |
| 378 | @item q or quit |
| 379 | Quit the emulator. |
| 380 | |
| 381 | @item eject [-f] device |
| 382 | Eject a removable media (use -f to force it). |
| 383 | |
| 384 | @item change device filename |
| 385 | Change a removable media. |
| 386 | |
| 387 | @item screendump filename |
| 388 | Save screen into PPM image @var{filename}. |
| 389 | |
| 390 | @item log item1[,...] |
| 391 | Activate logging of the specified items to @file{/tmp/qemu.log}. |
| 392 | |
| 393 | @item savevm filename |
| 394 | Save the whole virtual machine state to @var{filename}. |
| 395 | |
| 396 | @item loadvm filename |
| 397 | Restore the whole virtual machine state from @var{filename}. |
| 398 | |
| 399 | @item stop |
| 400 | Stop emulation. |
| 401 | |
| 402 | @item c or cont |
| 403 | Resume emulation. |
| 404 | |
| 405 | @item gdbserver [port] |
| 406 | Start gdbserver session (default port=1234) |
| 407 | |
| 408 | @item x/fmt addr |
| 409 | Virtual memory dump starting at @var{addr}. |
| 410 | |
| 411 | @item xp /fmt addr |
| 412 | Physical memory dump starting at @var{addr}. |
| 413 | |
| 414 | @var{fmt} is a format which tells the command how to format the |
| 415 | data. Its syntax is: @option{/@{count@}@{format@}@{size@}} |
| 416 | |
| 417 | @table @var |
| 418 | @item count |
| 419 | is the number of items to be dumped. |
| 420 | |
| 421 | @item format |
| 422 | can be x (hexa), d (signed decimal), u (unsigned decimal), o (octal), |
| 423 | c (char) or i (asm instruction). |
| 424 | |
| 425 | @item size |
bellard | 52c00a5 | 2004-04-25 21:27:03 +0000 | [diff] [blame^] | 426 | can be b (8 bits), h (16 bits), w (32 bits) or g (64 bits). On x86, |
| 427 | @code{h} or @code{w} can be specified with the @code{i} format to |
| 428 | respectively select 16 or 32 bit code instruction size. |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 429 | |
| 430 | @end table |
| 431 | |
| 432 | Examples: |
| 433 | @itemize |
| 434 | @item |
| 435 | Dump 10 instructions at the current instruction pointer: |
| 436 | @example |
| 437 | (qemu) x/10i $eip |
| 438 | 0x90107063: ret |
| 439 | 0x90107064: sti |
| 440 | 0x90107065: lea 0x0(%esi,1),%esi |
| 441 | 0x90107069: lea 0x0(%edi,1),%edi |
| 442 | 0x90107070: ret |
| 443 | 0x90107071: jmp 0x90107080 |
| 444 | 0x90107073: nop |
| 445 | 0x90107074: nop |
| 446 | 0x90107075: nop |
| 447 | 0x90107076: nop |
| 448 | @end example |
| 449 | |
| 450 | @item |
| 451 | Dump 80 16 bit values at the start of the video memory. |
| 452 | @example |
| 453 | (qemu) xp/80hx 0xb8000 |
| 454 | 0x000b8000: 0x0b50 0x0b6c 0x0b65 0x0b78 0x0b38 0x0b36 0x0b2f 0x0b42 |
| 455 | 0x000b8010: 0x0b6f 0x0b63 0x0b68 0x0b73 0x0b20 0x0b56 0x0b47 0x0b41 |
| 456 | 0x000b8020: 0x0b42 0x0b69 0x0b6f 0x0b73 0x0b20 0x0b63 0x0b75 0x0b72 |
| 457 | 0x000b8030: 0x0b72 0x0b65 0x0b6e 0x0b74 0x0b2d 0x0b63 0x0b76 0x0b73 |
| 458 | 0x000b8040: 0x0b20 0x0b30 0x0b35 0x0b20 0x0b4e 0x0b6f 0x0b76 0x0b20 |
| 459 | 0x000b8050: 0x0b32 0x0b30 0x0b30 0x0b33 0x0720 0x0720 0x0720 0x0720 |
| 460 | 0x000b8060: 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 |
| 461 | 0x000b8070: 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 |
| 462 | 0x000b8080: 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 |
| 463 | 0x000b8090: 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 0x0720 |
| 464 | @end example |
| 465 | @end itemize |
| 466 | |
| 467 | @item p or print/fmt expr |
| 468 | |
| 469 | Print expression value. Only the @var{format} part of @var{fmt} is |
| 470 | used. |
| 471 | |
| 472 | @end table |
| 473 | |
| 474 | @subsection Integer expressions |
| 475 | |
| 476 | The monitor understands integers expressions for every integer |
| 477 | argument. You can use register names to get the value of specifics |
| 478 | CPU registers by prefixing them with @emph{$}. |
| 479 | |
| 480 | @node disk_images |
| 481 | @section Disk Images |
| 482 | |
| 483 | @subsection Raw disk images |
| 484 | |
| 485 | The disk images can simply be raw images of the hard disk. You can |
| 486 | create them with the command: |
| 487 | @example |
| 488 | dd if=/dev/zero of=myimage bs=1024 count=mysize |
| 489 | @end example |
| 490 | where @var{myimage} is the image filename and @var{mysize} is its size |
| 491 | in kilobytes. |
| 492 | |
| 493 | @subsection Snapshot mode |
| 494 | |
| 495 | If you use the option @option{-snapshot}, all disk images are |
| 496 | considered as read only. When sectors in written, they are written in |
| 497 | a temporary file created in @file{/tmp}. You can however force the |
| 498 | write back to the raw disk images by pressing @key{C-a s}. |
| 499 | |
| 500 | NOTE: The snapshot mode only works with raw disk images. |
| 501 | |
| 502 | @subsection Copy On Write disk images |
| 503 | |
| 504 | QEMU also supports user mode Linux |
| 505 | (@url{http://user-mode-linux.sourceforge.net/}) Copy On Write (COW) |
| 506 | disk images. The COW disk images are much smaller than normal images |
| 507 | as they store only modified sectors. They also permit the use of the |
| 508 | same disk image template for many users. |
| 509 | |
| 510 | To create a COW disk images, use the command: |
| 511 | |
| 512 | @example |
| 513 | qemu-mkcow -f myrawimage.bin mycowimage.cow |
| 514 | @end example |
| 515 | |
| 516 | @file{myrawimage.bin} is a raw image you want to use as original disk |
| 517 | image. It will never be written to. |
| 518 | |
| 519 | @file{mycowimage.cow} is the COW disk image which is created by |
| 520 | @code{qemu-mkcow}. You can use it directly with the @option{-hdx} |
| 521 | options. You must not modify the original raw disk image if you use |
| 522 | COW images, as COW images only store the modified sectors from the raw |
| 523 | disk image. QEMU stores the original raw disk image name and its |
| 524 | modified time in the COW disk image so that chances of mistakes are |
| 525 | reduced. |
| 526 | |
| 527 | If the raw disk image is not read-only, by pressing @key{C-a s} you |
| 528 | can flush the COW disk image back into the raw disk image, as in |
| 529 | snapshot mode. |
| 530 | |
| 531 | COW disk images can also be created without a corresponding raw disk |
| 532 | image. It is useful to have a big initial virtual disk image without |
| 533 | using much disk space. Use: |
| 534 | |
| 535 | @example |
| 536 | qemu-mkcow mycowimage.cow 1024 |
| 537 | @end example |
| 538 | |
| 539 | to create a 1 gigabyte empty COW disk image. |
| 540 | |
| 541 | NOTES: |
| 542 | @enumerate |
| 543 | @item |
| 544 | COW disk images must be created on file systems supporting |
| 545 | @emph{holes} such as ext2 or ext3. |
| 546 | @item |
| 547 | Since holes are used, the displayed size of the COW disk image is not |
| 548 | the real one. To know it, use the @code{ls -ls} command. |
| 549 | @end enumerate |
| 550 | |
bellard | 0806e3f | 2003-10-01 00:15:32 +0000 | [diff] [blame] | 551 | @section Direct Linux Boot and Network emulation |
| 552 | |
| 553 | This section explains how to launch a Linux kernel inside QEMU without |
| 554 | having to make a full bootable image. It is very useful for fast Linux |
| 555 | kernel testing. The QEMU network configuration is also explained. |
bellard | 1eb2052 | 2003-06-25 16:21:49 +0000 | [diff] [blame] | 556 | |
| 557 | @enumerate |
| 558 | @item |
bellard | 0806e3f | 2003-10-01 00:15:32 +0000 | [diff] [blame] | 559 | Download the archive @file{linux-test-xxx.tar.gz} containing a Linux |
| 560 | kernel and a disk image. |
bellard | 1eb2052 | 2003-06-25 16:21:49 +0000 | [diff] [blame] | 561 | |
| 562 | @item Optional: If you want network support (for example to launch X11 examples), you |
bellard | 0806e3f | 2003-10-01 00:15:32 +0000 | [diff] [blame] | 563 | must copy the script @file{qemu-ifup} in @file{/etc} and configure |
bellard | 1eb2052 | 2003-06-25 16:21:49 +0000 | [diff] [blame] | 564 | properly @code{sudo} so that the command @code{ifconfig} contained in |
bellard | 0806e3f | 2003-10-01 00:15:32 +0000 | [diff] [blame] | 565 | @file{qemu-ifup} can be executed as root. You must verify that your host |
bellard | 1eb2052 | 2003-06-25 16:21:49 +0000 | [diff] [blame] | 566 | kernel supports the TUN/TAP network interfaces: the device |
| 567 | @file{/dev/net/tun} must be present. |
| 568 | |
| 569 | When network is enabled, there is a virtual network connection between |
| 570 | the host kernel and the emulated kernel. The emulated kernel is seen |
| 571 | from the host kernel at IP address 172.20.0.2 and the host kernel is |
| 572 | seen from the emulated kernel at IP address 172.20.0.1. |
| 573 | |
bellard | 0806e3f | 2003-10-01 00:15:32 +0000 | [diff] [blame] | 574 | @item Launch @code{qemu.sh}. You should have the following output: |
bellard | 1eb2052 | 2003-06-25 16:21:49 +0000 | [diff] [blame] | 575 | |
| 576 | @example |
bellard | 0806e3f | 2003-10-01 00:15:32 +0000 | [diff] [blame] | 577 | > ./qemu.sh |
bellard | 181f155 | 2003-11-13 01:47:16 +0000 | [diff] [blame] | 578 | Connected to host network interface: tun0 |
| 579 | Linux version 2.4.21 (bellard@voyager.localdomain) (gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)) #5 Tue Nov 11 18:18:53 CET 2003 |
bellard | 1eb2052 | 2003-06-25 16:21:49 +0000 | [diff] [blame] | 580 | BIOS-provided physical RAM map: |
bellard | 4690764 | 2003-07-07 12:17:46 +0000 | [diff] [blame] | 581 | BIOS-e801: 0000000000000000 - 000000000009f000 (usable) |
| 582 | BIOS-e801: 0000000000100000 - 0000000002000000 (usable) |
bellard | 1eb2052 | 2003-06-25 16:21:49 +0000 | [diff] [blame] | 583 | 32MB LOWMEM available. |
| 584 | On node 0 totalpages: 8192 |
| 585 | zone(0): 4096 pages. |
| 586 | zone(1): 4096 pages. |
| 587 | zone(2): 0 pages. |
bellard | 181f155 | 2003-11-13 01:47:16 +0000 | [diff] [blame] | 588 | Kernel command line: root=/dev/hda sb=0x220,5,1,5 ide2=noprobe ide3=noprobe ide4=noprobe ide5=noprobe console=ttyS0 |
bellard | 4690764 | 2003-07-07 12:17:46 +0000 | [diff] [blame] | 589 | ide_setup: ide2=noprobe |
| 590 | ide_setup: ide3=noprobe |
| 591 | ide_setup: ide4=noprobe |
| 592 | ide_setup: ide5=noprobe |
bellard | 1eb2052 | 2003-06-25 16:21:49 +0000 | [diff] [blame] | 593 | Initializing CPU#0 |
bellard | 181f155 | 2003-11-13 01:47:16 +0000 | [diff] [blame] | 594 | Detected 2399.621 MHz processor. |
| 595 | Console: colour EGA 80x25 |
| 596 | Calibrating delay loop... 4744.80 BogoMIPS |
| 597 | Memory: 28872k/32768k available (1210k kernel code, 3508k reserved, 266k data, 64k init, 0k highmem) |
bellard | 1eb2052 | 2003-06-25 16:21:49 +0000 | [diff] [blame] | 598 | Dentry cache hash table entries: 4096 (order: 3, 32768 bytes) |
| 599 | Inode cache hash table entries: 2048 (order: 2, 16384 bytes) |
bellard | 181f155 | 2003-11-13 01:47:16 +0000 | [diff] [blame] | 600 | Mount cache hash table entries: 512 (order: 0, 4096 bytes) |
bellard | 1eb2052 | 2003-06-25 16:21:49 +0000 | [diff] [blame] | 601 | Buffer-cache hash table entries: 1024 (order: 0, 4096 bytes) |
| 602 | Page-cache hash table entries: 8192 (order: 3, 32768 bytes) |
| 603 | CPU: Intel Pentium Pro stepping 03 |
| 604 | Checking 'hlt' instruction... OK. |
| 605 | POSIX conformance testing by UNIFIX |
| 606 | Linux NET4.0 for Linux 2.4 |
| 607 | Based upon Swansea University Computer Society NET3.039 |
| 608 | Initializing RT netlink socket |
| 609 | apm: BIOS not found. |
| 610 | Starting kswapd |
bellard | 4690764 | 2003-07-07 12:17:46 +0000 | [diff] [blame] | 611 | Journalled Block Device driver loaded |
bellard | 181f155 | 2003-11-13 01:47:16 +0000 | [diff] [blame] | 612 | Detected PS/2 Mouse Port. |
bellard | 1eb2052 | 2003-06-25 16:21:49 +0000 | [diff] [blame] | 613 | pty: 256 Unix98 ptys configured |
| 614 | Serial driver version 5.05c (2001-07-08) with no serial options enabled |
| 615 | ttyS00 at 0x03f8 (irq = 4) is a 16450 |
| 616 | ne.c:v1.10 9/23/94 Donald Becker (becker@scyld.com) |
| 617 | Last modified Nov 1, 2000 by Paul Gortmaker |
| 618 | NE*000 ethercard probe at 0x300: 52 54 00 12 34 56 |
| 619 | eth0: NE2000 found at 0x300, using IRQ 9. |
bellard | 4690764 | 2003-07-07 12:17:46 +0000 | [diff] [blame] | 620 | RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize |
bellard | 181f155 | 2003-11-13 01:47:16 +0000 | [diff] [blame] | 621 | Uniform Multi-Platform E-IDE driver Revision: 7.00beta4-2.4 |
| 622 | ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx |
| 623 | hda: QEMU HARDDISK, ATA DISK drive |
| 624 | ide0 at 0x1f0-0x1f7,0x3f6 on irq 14 |
| 625 | hda: attached ide-disk driver. |
| 626 | hda: 20480 sectors (10 MB) w/256KiB Cache, CHS=20/16/63 |
| 627 | Partition check: |
| 628 | hda: |
| 629 | Soundblaster audio driver Copyright (C) by Hannu Savolainen 1993-1996 |
bellard | 1eb2052 | 2003-06-25 16:21:49 +0000 | [diff] [blame] | 630 | NET4: Linux TCP/IP 1.0 for NET4.0 |
| 631 | IP Protocols: ICMP, UDP, TCP, IGMP |
| 632 | IP: routing cache hash table of 512 buckets, 4Kbytes |
bellard | 4690764 | 2003-07-07 12:17:46 +0000 | [diff] [blame] | 633 | TCP: Hash tables configured (established 2048 bind 4096) |
bellard | 1eb2052 | 2003-06-25 16:21:49 +0000 | [diff] [blame] | 634 | NET4: Unix domain sockets 1.0/SMP for Linux NET4.0. |
bellard | 4690764 | 2003-07-07 12:17:46 +0000 | [diff] [blame] | 635 | EXT2-fs warning: mounting unchecked fs, running e2fsck is recommended |
bellard | 1eb2052 | 2003-06-25 16:21:49 +0000 | [diff] [blame] | 636 | VFS: Mounted root (ext2 filesystem). |
bellard | 181f155 | 2003-11-13 01:47:16 +0000 | [diff] [blame] | 637 | Freeing unused kernel memory: 64k freed |
| 638 | |
| 639 | Linux version 2.4.21 (bellard@voyager.localdomain) (gcc version 3.2.2 20030222 (Red Hat Linux 3.2.2-5)) #5 Tue Nov 11 18:18:53 CET 2003 |
| 640 | |
| 641 | QEMU Linux test distribution (based on Redhat 9) |
| 642 | |
| 643 | Type 'exit' to halt the system |
| 644 | |
| 645 | sh-2.05b# |
bellard | 1eb2052 | 2003-06-25 16:21:49 +0000 | [diff] [blame] | 646 | @end example |
| 647 | |
| 648 | @item |
| 649 | Then you can play with the kernel inside the virtual serial console. You |
| 650 | can launch @code{ls} for example. Type @key{Ctrl-a h} to have an help |
| 651 | about the keys you can type inside the virtual serial console. In |
bellard | d5a0b50 | 2003-06-27 12:02:03 +0000 | [diff] [blame] | 652 | particular, use @key{Ctrl-a x} to exit QEMU and use @key{Ctrl-a b} as |
| 653 | the Magic SysRq key. |
bellard | 1eb2052 | 2003-06-25 16:21:49 +0000 | [diff] [blame] | 654 | |
| 655 | @item |
| 656 | If the network is enabled, launch the script @file{/etc/linuxrc} in the |
| 657 | emulator (don't forget the leading dot): |
| 658 | @example |
| 659 | . /etc/linuxrc |
| 660 | @end example |
| 661 | |
| 662 | Then enable X11 connections on your PC from the emulated Linux: |
| 663 | @example |
| 664 | xhost +172.20.0.2 |
| 665 | @end example |
| 666 | |
| 667 | You can now launch @file{xterm} or @file{xlogo} and verify that you have |
| 668 | a real Virtual Linux system ! |
| 669 | |
| 670 | @end enumerate |
| 671 | |
bellard | d5a0b50 | 2003-06-27 12:02:03 +0000 | [diff] [blame] | 672 | NOTES: |
| 673 | @enumerate |
| 674 | @item |
bellard | 0806e3f | 2003-10-01 00:15:32 +0000 | [diff] [blame] | 675 | A 2.5.74 kernel is also included in the archive. Just |
| 676 | replace the bzImage in qemu.sh to try it. |
bellard | d5a0b50 | 2003-06-27 12:02:03 +0000 | [diff] [blame] | 677 | |
| 678 | @item |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 679 | qemu-fast creates a temporary file in @var{$QEMU_TMPDIR} (@file{/tmp} is the |
bellard | d5a0b50 | 2003-06-27 12:02:03 +0000 | [diff] [blame] | 680 | default) containing all the simulated PC memory. If possible, try to use |
| 681 | a temporary directory using the tmpfs filesystem to avoid too many |
| 682 | unnecessary disk accesses. |
| 683 | |
| 684 | @item |
bellard | 9d4520d | 2003-10-28 01:38:57 +0000 | [diff] [blame] | 685 | In order to exit cleanly from qemu, you can do a @emph{shutdown} inside |
| 686 | qemu. qemu will automatically exit when the Linux shutdown is done. |
bellard | 4690764 | 2003-07-07 12:17:46 +0000 | [diff] [blame] | 687 | |
| 688 | @item |
| 689 | You can boot slightly faster by disabling the probe of non present IDE |
| 690 | interfaces. To do so, add the following options on the kernel command |
| 691 | line: |
| 692 | @example |
| 693 | ide1=noprobe ide2=noprobe ide3=noprobe ide4=noprobe ide5=noprobe |
| 694 | @end example |
| 695 | |
| 696 | @item |
| 697 | The example disk image is a modified version of the one made by Kevin |
bellard | 1eb2052 | 2003-06-25 16:21:49 +0000 | [diff] [blame] | 698 | Lawton for the plex86 Project (@url{www.plex86.org}). |
| 699 | |
bellard | d5a0b50 | 2003-06-27 12:02:03 +0000 | [diff] [blame] | 700 | @end enumerate |
| 701 | |
bellard | 0806e3f | 2003-10-01 00:15:32 +0000 | [diff] [blame] | 702 | @node linux_compile |
bellard | 4690764 | 2003-07-07 12:17:46 +0000 | [diff] [blame] | 703 | @section Linux Kernel Compilation |
bellard | 1eb2052 | 2003-06-25 16:21:49 +0000 | [diff] [blame] | 704 | |
bellard | 285dc33 | 2003-10-27 23:58:04 +0000 | [diff] [blame] | 705 | You can use any linux kernel with QEMU. However, if you want to use |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 706 | @code{qemu-fast} to get maximum performances, you must use a modified |
| 707 | guest kernel. If you are using a 2.6 guest kernel, you can use |
| 708 | directly the patch @file{linux-2.6-qemu-fast.patch} made by Rusty |
| 709 | Russel available in the QEMU source archive. Otherwise, you can make the |
| 710 | following changes @emph{by hand} to the Linux kernel: |
bellard | 1eb2052 | 2003-06-25 16:21:49 +0000 | [diff] [blame] | 711 | |
bellard | 4690764 | 2003-07-07 12:17:46 +0000 | [diff] [blame] | 712 | @enumerate |
| 713 | @item |
| 714 | The kernel must be mapped at 0x90000000 (the default is |
| 715 | 0xc0000000). You must modify only two lines in the kernel source: |
| 716 | |
| 717 | In @file{include/asm/page.h}, replace |
bellard | 1eb2052 | 2003-06-25 16:21:49 +0000 | [diff] [blame] | 718 | @example |
| 719 | #define __PAGE_OFFSET (0xc0000000) |
| 720 | @end example |
| 721 | by |
| 722 | @example |
| 723 | #define __PAGE_OFFSET (0x90000000) |
| 724 | @end example |
| 725 | |
bellard | 4690764 | 2003-07-07 12:17:46 +0000 | [diff] [blame] | 726 | And in @file{arch/i386/vmlinux.lds}, replace |
bellard | 1eb2052 | 2003-06-25 16:21:49 +0000 | [diff] [blame] | 727 | @example |
| 728 | . = 0xc0000000 + 0x100000; |
| 729 | @end example |
| 730 | by |
| 731 | @example |
| 732 | . = 0x90000000 + 0x100000; |
| 733 | @end example |
| 734 | |
bellard | 4690764 | 2003-07-07 12:17:46 +0000 | [diff] [blame] | 735 | @item |
| 736 | If you want to enable SMP (Symmetric Multi-Processing) support, you |
| 737 | must make the following change in @file{include/asm/fixmap.h}. Replace |
bellard | 1eb2052 | 2003-06-25 16:21:49 +0000 | [diff] [blame] | 738 | @example |
bellard | 4690764 | 2003-07-07 12:17:46 +0000 | [diff] [blame] | 739 | #define FIXADDR_TOP (0xffffX000UL) |
bellard | 1eb2052 | 2003-06-25 16:21:49 +0000 | [diff] [blame] | 740 | @end example |
bellard | 4690764 | 2003-07-07 12:17:46 +0000 | [diff] [blame] | 741 | by |
| 742 | @example |
| 743 | #define FIXADDR_TOP (0xa7ffX000UL) |
| 744 | @end example |
| 745 | (X is 'e' or 'f' depending on the kernel version). Although you can |
| 746 | use an SMP kernel with QEMU, it only supports one CPU. |
bellard | 1eb2052 | 2003-06-25 16:21:49 +0000 | [diff] [blame] | 747 | |
bellard | 4690764 | 2003-07-07 12:17:46 +0000 | [diff] [blame] | 748 | @item |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 749 | If you are not using a 2.6 kernel as host kernel but if you use a target |
| 750 | 2.6 kernel, you must also ensure that the 'HZ' define is set to 100 |
bellard | d5a0b50 | 2003-06-27 12:02:03 +0000 | [diff] [blame] | 751 | (1000 is the default) as QEMU cannot currently emulate timers at |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 752 | frequencies greater than 100 Hz on host Linux systems < 2.6. In |
bellard | 4690764 | 2003-07-07 12:17:46 +0000 | [diff] [blame] | 753 | @file{include/asm/param.h}, replace: |
bellard | d5a0b50 | 2003-06-27 12:02:03 +0000 | [diff] [blame] | 754 | |
| 755 | @example |
| 756 | # define HZ 1000 /* Internal kernel timer frequency */ |
| 757 | @end example |
| 758 | by |
| 759 | @example |
| 760 | # define HZ 100 /* Internal kernel timer frequency */ |
| 761 | @end example |
| 762 | |
bellard | 4690764 | 2003-07-07 12:17:46 +0000 | [diff] [blame] | 763 | @end enumerate |
| 764 | |
| 765 | The file config-2.x.x gives the configuration of the example kernels. |
| 766 | |
| 767 | Just type |
| 768 | @example |
| 769 | make bzImage |
| 770 | @end example |
| 771 | |
| 772 | As you would do to make a real kernel. Then you can use with QEMU |
| 773 | exactly the same kernel as you would boot on your PC (in |
| 774 | @file{arch/i386/boot/bzImage}). |
bellard | da415d5 | 2003-06-27 18:50:50 +0000 | [diff] [blame] | 775 | |
bellard | 0806e3f | 2003-10-01 00:15:32 +0000 | [diff] [blame] | 776 | @node gdb_usage |
bellard | da415d5 | 2003-06-27 18:50:50 +0000 | [diff] [blame] | 777 | @section GDB usage |
| 778 | |
| 779 | QEMU has a primitive support to work with gdb, so that you can do |
bellard | 0806e3f | 2003-10-01 00:15:32 +0000 | [diff] [blame] | 780 | 'Ctrl-C' while the virtual machine is running and inspect its state. |
bellard | da415d5 | 2003-06-27 18:50:50 +0000 | [diff] [blame] | 781 | |
bellard | 9d4520d | 2003-10-28 01:38:57 +0000 | [diff] [blame] | 782 | In order to use gdb, launch qemu with the '-s' option. It will wait for a |
bellard | da415d5 | 2003-06-27 18:50:50 +0000 | [diff] [blame] | 783 | gdb connection: |
| 784 | @example |
bellard | 6c9bf89 | 2004-01-24 13:46:56 +0000 | [diff] [blame] | 785 | > qemu -s -kernel arch/i386/boot/bzImage -hda root-2.4.20.img -append "root=/dev/hda" |
bellard | da415d5 | 2003-06-27 18:50:50 +0000 | [diff] [blame] | 786 | Connected to host network interface: tun0 |
| 787 | Waiting gdb connection on port 1234 |
| 788 | @end example |
| 789 | |
| 790 | Then launch gdb on the 'vmlinux' executable: |
| 791 | @example |
| 792 | > gdb vmlinux |
| 793 | @end example |
| 794 | |
| 795 | In gdb, connect to QEMU: |
| 796 | @example |
bellard | 6c9bf89 | 2004-01-24 13:46:56 +0000 | [diff] [blame] | 797 | (gdb) target remote localhost:1234 |
bellard | da415d5 | 2003-06-27 18:50:50 +0000 | [diff] [blame] | 798 | @end example |
| 799 | |
| 800 | Then you can use gdb normally. For example, type 'c' to launch the kernel: |
| 801 | @example |
| 802 | (gdb) c |
| 803 | @end example |
| 804 | |
bellard | 0806e3f | 2003-10-01 00:15:32 +0000 | [diff] [blame] | 805 | Here are some useful tips in order to use gdb on system code: |
| 806 | |
| 807 | @enumerate |
| 808 | @item |
| 809 | Use @code{info reg} to display all the CPU registers. |
| 810 | @item |
| 811 | Use @code{x/10i $eip} to display the code at the PC position. |
| 812 | @item |
| 813 | Use @code{set architecture i8086} to dump 16 bit code. Then use |
| 814 | @code{x/10i $cs*16+*eip} to dump the code at the PC position. |
| 815 | @end enumerate |
| 816 | |
bellard | 52c00a5 | 2004-04-25 21:27:03 +0000 | [diff] [blame^] | 817 | @chapter QEMU PREP PowerPC System emulator invocation |
| 818 | |
| 819 | Use the executable @file{qemu-system-ppc} to simulate a complete PREP |
| 820 | PowerPC system. |
| 821 | |
| 822 | QEMU emulates the following PREP peripherials: |
| 823 | |
| 824 | @itemize @minus |
| 825 | @item |
| 826 | 2 IDE interfaces with hard disk and CD-ROM support |
| 827 | @item |
| 828 | Floppy disk |
| 829 | @item |
| 830 | up to 6 NE2000 network adapters |
| 831 | @item |
| 832 | Serial port |
| 833 | @item |
| 834 | PREP Non Volatile RAM |
| 835 | @end itemize |
| 836 | |
| 837 | You can read the qemu PC system emulation chapter to have more |
| 838 | informations about QEMU usage. |
| 839 | |
| 840 | More information is available at |
| 841 | @url{http://jocelyn.mayer.free.fr/qemu-ppc/}. |
| 842 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 843 | @chapter QEMU User space emulator invocation |
bellard | 386405f | 2003-03-23 21:28:45 +0000 | [diff] [blame] | 844 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 845 | @section Quick Start |
bellard | 386405f | 2003-03-23 21:28:45 +0000 | [diff] [blame] | 846 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 847 | In order to launch a Linux process, QEMU needs the process executable |
| 848 | itself and all the target (x86) dynamic libraries used by it. |
bellard | 386405f | 2003-03-23 21:28:45 +0000 | [diff] [blame] | 849 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 850 | @itemize |
bellard | 386405f | 2003-03-23 21:28:45 +0000 | [diff] [blame] | 851 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 852 | @item On x86, you can just try to launch any process by using the native |
| 853 | libraries: |
bellard | 386405f | 2003-03-23 21:28:45 +0000 | [diff] [blame] | 854 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 855 | @example |
| 856 | qemu-i386 -L / /bin/ls |
| 857 | @end example |
bellard | fd429f2 | 2003-03-30 20:59:46 +0000 | [diff] [blame] | 858 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 859 | @code{-L /} tells that the x86 dynamic linker must be searched with a |
| 860 | @file{/} prefix. |
bellard | 1eb2052 | 2003-06-25 16:21:49 +0000 | [diff] [blame] | 861 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 862 | @item Since QEMU is also a linux process, you can launch qemu with qemu (NOTE: you can only do that if you compiled QEMU from the sources): |
bellard | 1eb2052 | 2003-06-25 16:21:49 +0000 | [diff] [blame] | 863 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 864 | @example |
| 865 | qemu-i386 -L / qemu-i386 -L / /bin/ls |
| 866 | @end example |
bellard | 386405f | 2003-03-23 21:28:45 +0000 | [diff] [blame] | 867 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 868 | @item On non x86 CPUs, you need first to download at least an x86 glibc |
| 869 | (@file{qemu-runtime-i386-XXX-.tar.gz} on the QEMU web page). Ensure that |
| 870 | @code{LD_LIBRARY_PATH} is not set: |
bellard | 386405f | 2003-03-23 21:28:45 +0000 | [diff] [blame] | 871 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 872 | @example |
| 873 | unset LD_LIBRARY_PATH |
| 874 | @end example |
bellard | 386405f | 2003-03-23 21:28:45 +0000 | [diff] [blame] | 875 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 876 | Then you can launch the precompiled @file{ls} x86 executable: |
bellard | 386405f | 2003-03-23 21:28:45 +0000 | [diff] [blame] | 877 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 878 | @example |
| 879 | qemu-i386 tests/i386/ls |
| 880 | @end example |
| 881 | You can look at @file{qemu-binfmt-conf.sh} so that |
| 882 | QEMU is automatically launched by the Linux kernel when you try to |
| 883 | launch x86 executables. It requires the @code{binfmt_misc} module in the |
| 884 | Linux kernel. |
bellard | 386405f | 2003-03-23 21:28:45 +0000 | [diff] [blame] | 885 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 886 | @item The x86 version of QEMU is also included. You can try weird things such as: |
| 887 | @example |
| 888 | qemu-i386 /usr/local/qemu-i386/bin/qemu-i386 /usr/local/qemu-i386/bin/ls-i386 |
| 889 | @end example |
bellard | 386405f | 2003-03-23 21:28:45 +0000 | [diff] [blame] | 890 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 891 | @end itemize |
bellard | 386405f | 2003-03-23 21:28:45 +0000 | [diff] [blame] | 892 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 893 | @section Wine launch |
bellard | 386405f | 2003-03-23 21:28:45 +0000 | [diff] [blame] | 894 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 895 | @itemize |
bellard | 386405f | 2003-03-23 21:28:45 +0000 | [diff] [blame] | 896 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 897 | @item Ensure that you have a working QEMU with the x86 glibc |
| 898 | distribution (see previous section). In order to verify it, you must be |
| 899 | able to do: |
bellard | 386405f | 2003-03-23 21:28:45 +0000 | [diff] [blame] | 900 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 901 | @example |
| 902 | qemu-i386 /usr/local/qemu-i386/bin/ls-i386 |
| 903 | @end example |
bellard | 386405f | 2003-03-23 21:28:45 +0000 | [diff] [blame] | 904 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 905 | @item Download the binary x86 Wine install |
| 906 | (@file{qemu-XXX-i386-wine.tar.gz} on the QEMU web page). |
bellard | 386405f | 2003-03-23 21:28:45 +0000 | [diff] [blame] | 907 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 908 | @item Configure Wine on your account. Look at the provided script |
| 909 | @file{/usr/local/qemu-i386/bin/wine-conf.sh}. Your previous |
| 910 | @code{$@{HOME@}/.wine} directory is saved to @code{$@{HOME@}/.wine.org}. |
bellard | 386405f | 2003-03-23 21:28:45 +0000 | [diff] [blame] | 911 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 912 | @item Then you can try the example @file{putty.exe}: |
bellard | 386405f | 2003-03-23 21:28:45 +0000 | [diff] [blame] | 913 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 914 | @example |
| 915 | qemu-i386 /usr/local/qemu-i386/wine/bin/wine /usr/local/qemu-i386/wine/c/Program\ Files/putty.exe |
| 916 | @end example |
bellard | 386405f | 2003-03-23 21:28:45 +0000 | [diff] [blame] | 917 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 918 | @end itemize |
bellard | 386405f | 2003-03-23 21:28:45 +0000 | [diff] [blame] | 919 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 920 | @section Command line options |
bellard | 386405f | 2003-03-23 21:28:45 +0000 | [diff] [blame] | 921 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 922 | @example |
| 923 | usage: qemu-i386 [-h] [-d] [-L path] [-s size] program [arguments...] |
| 924 | @end example |
bellard | 386405f | 2003-03-23 21:28:45 +0000 | [diff] [blame] | 925 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 926 | @table @option |
| 927 | @item -h |
| 928 | Print the help |
| 929 | @item -L path |
| 930 | Set the x86 elf interpreter prefix (default=/usr/local/qemu-i386) |
| 931 | @item -s size |
| 932 | Set the x86 stack size in bytes (default=524288) |
bellard | 386405f | 2003-03-23 21:28:45 +0000 | [diff] [blame] | 933 | @end table |
| 934 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 935 | Debug options: |
bellard | 386405f | 2003-03-23 21:28:45 +0000 | [diff] [blame] | 936 | |
bellard | 1f67313 | 2004-04-04 15:21:17 +0000 | [diff] [blame] | 937 | @table @option |
| 938 | @item -d |
| 939 | Activate log (logfile=/tmp/qemu.log) |
| 940 | @item -p pagesize |
| 941 | Act as if the host page size was 'pagesize' bytes |
| 942 | @end table |
bellard | 386405f | 2003-03-23 21:28:45 +0000 | [diff] [blame] | 943 | |