QEmu: Difference between revisions
add first draft of booting with qemu |
→CD image: fix link to CD image |
||
Line 11: | Line 11: | ||
===CD image=== | ===CD image=== | ||
Follow the instructions to [create a CD image] of your software. Once you | Follow the instructions to [[CD image|create a CD image]] of your software. Once you | ||
obtained the image you can use it as the emulators CD drive (''-cdrom'') and | obtained the image you can use it as the emulators CD drive (''-cdrom'') and | ||
tell Qemu to boot from it (''-boot d''). | tell Qemu to boot from it (''-boot d''). | ||
Line 18: | Line 18: | ||
qemu -cdrom /path/to/your/cd-image.iso -boot d | qemu -cdrom /path/to/your/cd-image.iso -boot d | ||
===TFTP server=== | ===TFTP server=== |
Revision as of 12:56, 16 September 2007
Qemu is a PC emulator that can be used instead of a real PC to test your L4 applications. In order to boot something with Qemu we have to create a bootable device as we would for a real PC. You can, for instance, create a CD image to boot or you use a tftp server to load your binaries.
The instructions specified here are for Qemu version 0.9.0. Other versions are mentioned explicitly.
CD image
Follow the instructions to create a CD image of your software. Once you obtained the image you can use it as the emulators CD drive (-cdrom) and tell Qemu to boot from it (-boot d).
The full command line would be:
qemu -cdrom /path/to/your/cd-image.iso -boot d
TFTP server
One of the nice feature of Qemu is its built-in TFTP server. The advantage of using a TFTP server to boot your software is that you do not have to recreate the CD image if something changes. You simple replace the binary to use.
If you want to use the built-in TFTP server specify the -tftp Option. Of course this only enable the TFTP server in Qemu--a boot image is still required. The easiest way is to cat the stage1 and stage2 of grub together into one image. You can use the two files from you local installation of Grub in /usr/lib/grub/i386-pc/.
cat /usr/lib/grub/i386-pc/stage1 /usr/lib/grub/i386-pc/stage2 > grub_disk
You may, of course, use your own version Grub instead of the installed.
Now, you use the created grub_disk as boot image of qemu and the -tftp Option to tell the Qemu TFTP Server where to look for files (in this case in the root directory):
qemu grub_disk -tftp /
The Qemu will boot a Grub with a command line where you may load your configuration file (menu.lst) for Grub. If you want to directly boot this configuration file whenever you boot Grub, simply open the created grub_disk in an editor, search for the string (nd)/tftp/menu.lst and replace it with the location of your configuration file. (For Grub version 0.97-os.6 the string is at offset 0x41c.) Do not insert your string but overwrite the existing string. There are enough zeros after the string that can be overwritten.
PXE boot
With recent versions of Qemu (currently only snapshots after February 19th 2007), you may also boot over the network using PXE. You will need a PXE Grub stage2. After you obtained the recent Qemu and the PXE Grub you can boot Qemu with:
qemu -tftp / -bootp /usr/lib/grub/i386-pc/pxegrub -boot n
Again you can modify the pxegrub binary to directly boot your preferred menu.lst. (For Grub version 0.97-os.6 the string is at offset 0x61c.)
Useful options
L4 software print lots of useful information on the serial line which can be helpful when debugging. To interact with the serial console of Qemu use the option -serial:
qemu ... -serial stdio
You may also want to modify the amount of memory Qemu uses with the -m option (here 256 MB):
qemu ... -m 256