SSE3044: Operating Systems (Fall 2012)

Using QEMU for Pintos

September 1, 2012

Jin-Soo Kim
Computer Systems Laboratory
Sungkyunkwan University

The recent KVM-based QEMU does not work for Pintos. If you want to use QEMU for your Pintos projects on Ubuntu 12.04.1 LTS, please follow the steps below.

Install QEMU full system emulation binaries

Install the qemu-system package and make a symbolic link from /usr/bin/qemu to /usr/bin/qemu-system-i386.

$ sudo apt-get install qemu-system
$ cd /usr/bin
$ sudo ln -s qemu-system-i386 qemu

Modify the Pintos script

In Pintos, QEMU (or bochs) is invoked via the script ~/pintos/src/utils/pintos. The script attaches the '-no-kqemu' argument when QEMU is used as a system simulator, but the current version of qemu does not undertand that argument. So, we simply drop the argument by commenting out the corresponding line (line 622) in the ~/pintos/src/utils/pintos script.

# Runs QEMU.
sub run_qemu {
    print "warning: qemu doesn't support --terminal\n"
      if $vga eq 'terminal';
    print "warning: qemu doesn't support jitter\n"
      if defined $jitter;
    my (@cmd) = ('qemu');
    #push (@cmd, '-no-kqemu');
    push (@cmd, '-hda', $disks[0]) if defined $disks[0];
    push (@cmd, '-hdb', $disks[1]) if defined $disks[1];
    push (@cmd, '-hdc', $disks[2]) if defined $disks[2];
    push (@cmd, '-hdd', $disks[3]) if defined $disks[3];
    push (@cmd, '-m', $mem);
    push (@cmd, '-net', 'none');
    push (@cmd, '-nographic') if $vga eq 'none';
    push (@cmd, '-serial', 'stdio') if $serial && $vga ne 'none';
    push (@cmd, '-S') if $debug eq 'monitor';
    push (@cmd, '-s', '-S') if $debug eq 'gdb';
    push (@cmd, '-monitor', 'null') if $vga eq 'none' && $debug eq 'none';
    run_command (@cmd);

Now use it!

QEMU (instead of bochs) can be used to run Pintos by specifying --qemu argument when you run the ~/pintos/src/utils/pintos script as follows:

$ cd ~/pintos/src/threads
$ make
$ ../utils/pintos --qemu -- run alarm-multiple

Note that if you want to use QEMU during make check, you have to change the definition of SIMULATOR from --bochs to --qemu in the Make.vars file in ~/pintos/src/[threads|userprog|vm|filesys]/ directories.

# -*- makefile -*-

kernel.bin: DEFINES =
KERNEL_SUBDIRS = threads devices lib lib/kernel $(TEST_SUBDIRS)
TEST_SUBDIRS = tests/threads
GRADING_FILE = $(SRCDIR)/tests/threads/Grading

SIMULATOR = --qemu