Porting Tips

1. Building environment

All system of QEMU is made on MinGW/MSYS because SDL library needs to be compiled on MinGW.

zlib is needed from version 0.6.1.

Please make SDL library from source codes.
"directx" is used for SDL_VIDEODRIVER. It is default. It is faster than "windib" but a keyboard may not work well. Use windib for SDL_VIDEODRIVER. It probably needs some patch for each language to use directx. When the keyboard doesn't work well, set it before you start the program like this.
[DOS prompt] set SDL_VIDEODRIVER=windib
[DOS prompt] qemu.exe -L .......

To set SDL_VIDEODRIVER in MSYS, use /etc/profile. It seems that .bashrc doesn't work.
export SDL_VIDEODRIVER=windib

When SDL_VIDEODRIVER=directx, you can use a full screen by setting SDL_SWSURFACE to flags in sdl.c. The window might not return to the origin after a full screen. When SDL_VIDEODRIVER=windib, VGA TEXT mode doesn't work well.

At first, please download these files to home directory. If you installed MSYS to c:\MSYS\1.0 , home directory is c:\MSYS\1.0\home\(your name).


directx-devel.tar.gz here.
nasm.exe from here.


NOTE:MinGW's runtime library mingw-runtime-3.11.tar.gz doesn't work with QEMU. For example, when I installed MinGW-5.1.2.exe or MinGW-5.1.3.exe (gcc-3.4.2) to build QEMU, Windows 2000 guest doesn't boot because of this library. It stopped with "unhandled win32 exception". When I downgrade the library to mingw-runtime-3.10.tar.gz, it works fine.

Setup MinGW, MSYS and msysDTK. Then update gcc, w32api and mingw-runtime in /mingw directory. Install SDL library on your PC.

$ cd /mingw
$ tar zxvf ~/gcc-core-3.3.1-20030804-1.tar.gz
$ tar zxvf ~/gcc-g++-3.3.1-20030804-1.tar.gz
$ tar zxvf ~/w32api-3.8.tar.gz
$ tar zxvf ~/mingw-runtime-3.9.tar.gz

zlib is configured with --prefix=/mingw and installed in /mingw/include and /mingw/lib.

$ tar zxvf zlib-1.2.3.tar.gz
$ cd zlib-1.2.3
$ ./configure --prefix=/mingw
$ make
$ make install

At first, untar DirectX headers to /usr/local/directx/include. If you have the latest DirectX SDK, set it to CPPFLAGS at configure.
$ mkdir /usr/local
$ cd /usr/local
$ mkdir directx
$ cd directx
$ tar zxvf ~/directx-devel.tar.gz
$ ls
include lib

It might be better to set #define DIRECTINPUT_VERSION 0x0700 in the end of directx.h.

Copy nasm.exe to /mingw/bin
$ cd
$ cp nasm.exe /mingw/bin

Then make and install SDL library. It needs to set CPPFLAGS.
$ cd
$ tar zxvf  SDL-1.2.11.tar.gz
$ cd SDL-1.2.11
$ patch -Z -p1 <../sdl-1.2.11-keyboard/sdl-1.2.11-keyboard.patch
$ ../sdl-1.2.11-keyboard/configure.qemu
$ make
$ makse install

Another DirectX port is available here.

Please check that SDL library is properly installed. SDL.dll is needed to be in PATH directory.

To use QEMU Monitor, please use Ctrl-Alt-2. You can go back to a guest OS window by Ctrl-Alt-1.

You can also use MinGW environment in Cygwin. Use this patch.

mingw-runtime 3.11-1 doesn't work. Downgrade to mingw-runtime 3.10-1.

zlib is available from setup.exe of Cygwin. It is MinGW/mingw-zlib. It is installed in /usr/include/mingw and /usr/lib/mingw.

SDL library is also necessary to compile. It is the same way as MinGW/MSYS.

In addition, there is a cross-compiling environment between Linux and Windows. You can make the program on Linux and execute on Windows. Please refer to an appropriate site.
Here is an example in Ronald's site.

2. Applying a patch and Make

Download qemu-0.8.x.tar.gz from QEMU home page and qemu-0.8.x-xxx.patch from this site.
Place them at the same directory. Type:

$ tar zxvf qemu-0.8.x.tar.gz
$ cd qemu-0.8.x
$ patch -p1 <../qemu-0.8.0-xxx.patch

$ ./configure
$ make

A file "qemu.exe" is made in i386-softmmu directory and a file "qemu-system-ppc.exe" is in ppc-softmmu directory, "qemu-system-sparc.exe" is in sparc-softmmu. "qemu.exe" is a PC emulator , "qemu-system-ppc.exe" is a PowerPC emulator, "qemu-system-sparc.exe" is a SPARC emulator.

When you make the program from CVS, errors occur by missing texi2html.
You can compile the program by these.
$ touch qemu-doc.html qemu-tech.html qemu.1 qemu-img.1

3. Release build

When I build qemu-0.x.y-windows.zip, configure option is like this.

./configure --enable-dsound --enable-adlib --enable-fmod --fmod-inc="/usr/local/fmodapi375win/api/inc"

Other binaries is build like this.
./configure --enable-dsound --enable-adlib

4. To start the program

To test the program, type at i386-softmmu directory if linux.img(hard disk image) is at the top of source codes:

i386-softmmu$ ./qemu.exe -L ../pc-bios -hda ../linux.img

Double hyphen is no more needed. Please use single hyphen for all options.

5. Host OS

The program works on:
Windows XP SP2
Windows 2000 SP4
Windows Me
Windows 98SE

I hear that if it doesn't work on a Windows98 host, it works when DirectX is installed.

To set SDL library to use Windows GDI not DirectX(directx),
[DOS prompt] set SDL_VIDEODRIVER=windib
To set SDL library to use Windows Multimedia API not directSound(dsound),
[DOS prompt] set SDL_AUDIODRIVER=waveout
[DOS prompt] qemu.exe ........

6. Guest OS

Small Linux from QEMU linux-test package
Red Hat Linux 7.2
Knoppix 3.3 Japanese Edition
Knoppix 3.7 Japanese Edition
Windows 98SE Japanese Edition
Windows 2000 Japanese Edition

7. Known problems

Slow down when -smp option is used.here.

The program doesn't work on Hyper-Threading or Multi-processor system.here.

CD-ROM doesn't work in Windows 2003 host.here.

When -snapshot is used, a temporary file can not be created.here.

qemu-img.exe convert doesn't work. here.

DR-DOS EMS, ROX and ReactOS bug. here.

Time in a guest OS is slow.here.

The state of Alt key can sometimes get out of sync with the real state. here.

Windows 2000 disk full problem.
c:\winnt\security\edb*.log grow bigger.here.
8G disk NG by dd if=/dev/zero of=w2k.img bs=1M count=8096. It's OK by dd if=/dev/zero of=w2k.img bs=4096 count=2000000.here.
A patch. It can be used during installation. irq is reset by time?here.
This patch is OK.here.here.
When formatted by FAT32 during installation and convert to NTFS, it is OK.here.
This is a patch. It is the same as above.here.
-hdachs cylinder,16,63 will install fine for win98, win2k pro, win2k server, winxp home upgrade and win2003.here and here.
-win2k-hack option is introduced in CVS. Use it when installing Windows 2000 to avoid a disk full bug. Don't use it after installing Windows 2000. here.
The issue is still present. Even if using -win2k-hack option. here.

-win2k-hack option is introduced from version 0.7.2. Please try to use it only when installing Windows 2000.

Time is not correct in Windows Update for a Windows 2000 guest. SSL doesn't work.here.
Microsoft installer doesn't work. It causes SChannel fail.here.
SP4 can't be applied by Windows Update. Installing DirectX fails.here.

Changing CD-ROM isn't recognized. Upgrade version of Windows can't be installed. When installed, set changing CD-ROM in Explorer and qemu console, then it is changed.here.

Windows XP license issue. If SP1 is applied, it is OK.here.
Windows XP can't boot if boot code is over 480MB.here.

16bit MS-DOS program doesn't work in Windows 2000/XP. The NTVDM CPU has encountered an handle exception. here.
Norton Ghost gets page fault.here.

OS tells 720MB but a real size of file is 2.3GB.here.

When I use full screen by Ctrl-Alt-f at boot time, task bar of Morphix is white when desktop is shown at start up. It seems that it works but I can't see it. It is a problem of SDL.
TFTP server doesn't work.TFTP server works.
I hear the case that ne2000 isn't detected. -> There is a case that Realtek 8029 driver works.

qemu-system-ppc.exe only works on gdb with some breakpoints. Something is wrong with get_time()?? -> A patch is made in the mailing list by Ronald.