QEMU: The Open Source Processor Emulator
Run Windows apps in any operating system.
I've been playing with QEMU for 47 days now. QEMU is an processor and system emulator written by Fabrice Bellard and released under the GPL(for binaries)/LGPL(for shared objects) licenses. I installed QEMU 0.8.0 on my AMD64/Fedora Core 4 Linux machine and created several guest images and installed different OSes on them, including several flavors of Linux and Windows.
By far the most challenging and the most fun OS to install and work with is MS Windows 3.1:
QEMU emulates a whole PC system with a Pentium II processor, PCI bus, a CirrusLogic graphics card, SoundBlaster 16 sound card, floppy drive, IDE hard drive, CD-ROM, and an Ethernet card. QEMU also provide the emulated system with a DHCP server and a SMB server.
The QEMU download for Linux is only 2.6MB in size, not as overwhelming as VMWare Server's 207MB total download. The QEMU documentation is extremely clear and helpful. The QEMU Users Forum is also a good source of information. (The MacOSX group is very active.)
To get started with the Windows 3.1 installation, all I have to do is:
[weiqi@gao] $ qemu-img create ms-windows.img 500M [weiqi@gao] $ qemu -fda /dev/fd0 -boot a ms-windows.img
QEMU will create the hard drive image, and start booting from the floppy drive. From that point on, everything proceeds exactly as if I'm building a new machine, with one exception—QEMU can't detect floppy disk or CD-ROM disk changes. In addition to the physical act, I have to switch to the QEMU console (Ctrl-Alt-2) and issue commands to tell QEMU that the floppy disk has been changed:
QEMU 0.8.0 monitor - type 'help' for more information (qemu) eject fda (qemu) change fda /dev/fd0
My choice of MS Windows 3.1 as the guest OS is part pragmatism and part nostalgic. Pragmatic because it's small—MS-DOS 6.22 comes in three floppies, and MS Windows 3.1 in six. Nostalgic because I spent considerable amount of time there and I haven't seen it for a long time.
I'll spare you with the boring details of setting up a Windows 3.1 box except for noting how primitive it was and how compact it was. Both CD-ROM support and TCP/IP networking are add-ons to the OS. But it runs fine on 8MB of memory. Thanks to the internet, I'm able to find all the hardware drivers and a few applications.
I leave you with my CONFIG.SYS and AUTOEXEC.BAT:
C:\>type config.sys DEVICE=C:\DOS\HIMEM.SYS DEVICE=C:\DOS\EMM386.EXE NOEMS I=B000-B7FF WIN=B500-B7FF WIN=B200-B4FF BUFFERS=10,0 FILES=50 DOS=UMB LASTDRIVE=E FCBS=16,8 DEVICEHIGH /L:2,12048 =C:\DOS\SETVER.EXE DOS=HIGH DEVICEHIGH /L:2,9872 =C:\SB16\DRV\CSP.SYS /UNIT=0 /BLASTER=A:220 STACKS=9,256 DEVICEHIGH /L:2,22896 =C:\CDPRO\VIDE-CDD.SYS /D:MSCD001 /P:1F0,14 /P:170,15 /P:1 E8,12 /P:168,10 SHELL=C:\DOS\COMMAND.COM C:\DOS\ /p
C:\>type autoexec.bat @ECHO OFF SET SOUND=C:\SB16 SET BLASTER=A220 I5 D1 H5 P330 T6 SET MIDI=SYNTH:1 MAP:E C:\SB16\DIAGNOSE /S C:\SB16\MIXERSET /P /Q C:\WINDOWS\VGAUTIL\winmode.exe t640=75 t800=60 t1024=60 t1152=70 t1280=87 t1600= 0 LH /L:0;2,45456 /S C:\DOS\SMARTDRV.EXE LH /L:2,13984 C:\DOS\SHARE.EXE /L:500 C:\DOSIDLE\DOSIDLE.EXE LH /L:2,27952 C:\DOS\MSCDEX.EXE /D:MSCD001 LH /L:2,6384 C:\DOS\DOSKEY.COM LH /L:2,9216 C:\CRYNWR\NE2000.COM 0x60 11 0xC100 LH /L:2,4144 C:\CRYNWR\WINPKT.COM 0x60 PROMPT $p$g PATH C:\DOS;C:\GUPTA;C:\WINDOWS;c:\trumpet;C:\UTILS;C:\WIN31DDK\386\TOOLS;C:\WIN 31DDK\286\TOOLS SET TEMP=C:\DOS WIN
Oh, and finally, for the other six people on earth who also are trying to run Windows 3.1 in either QEMU or VMWare, I have solved the CPU usage reduction problem by writing my own VxD. This is a 32-bit virtual device driver that hooks the Windows primary scheduler's idle event and issues the privileged (ring 0) HLT instruction. It's similar to AMNHLT and DOSIDLE. I'm calling it WQGHLT and am making it available here.
This blog entry is composed in part in Netscape 4.08 for Windows 3.1 over Trumpet WinSock 3.0.
Re: QEMU: The Open Source Processor Emulator
I almost did not buy a floppy drive for my last computer. I bought it only because it costed only $12.
On the other hand, you can boot from the CD-ROM by using to "-boot d" option.
QEMU also recognize CD-ROM images (.iso files) and floppy disk images (dd if=/dev/fd0 of=ms-dos-disk1.img)and treat them accordingly (qemu -fda ms-dos-disk1.img ...)
Re: QEMU: The Open Source Processor Emulator
I'm using this driver. And I'm using the maximal resolution at the maximal color depth. It's not perfect but it's usable as long.
Re: QEMU: The Open Source Processor Emulator
Re: QEMU: The Open Source Processor Emulator
Weiqi, three things I need to ask you:
1. How in the heck did you get the internet connection (Trumpet Winsock 3.0 and Crynwr NE2000.com) to work in Windows 3.1? I tried it with Internet Explorer 5, and no such luck at all, plus Windows 3.1 as a guest OS wouldn't even boot at all in 386 Enhanced Mode. In the Network settings in Windows Setup, I tried to select Microsoft Network and no such luck. :(
2. How did you get the display of the Windows 3.1 guest OS to display a resolution higher than 800 x 600 @ 16 colours. I tried to do that, but I wound up with a corrupt display. I mean, Windows 3.1 will load properly, but it won't display well.
3. I tried to get MS-DOS to recognise the Oak Technologies VIDE CD-ROM driver to work. I used two different drivers and one of them caused the guest computer to hang and the other one ending up with the message:
"No drives found, aborting installation" and the error message "No valid CDROM device drivers selected".
How did you have sucess with all of this? I'm still new to QEMU and I was hoping that step-by-step process of how all of this was done.
Thank you for your time.
Re: QEMU: The Open Source Processor Emulator
<p>Take a look at my CONFIG.SYS and AUTOEXEC.BAT. They contain configuration settings for the CD-ROM, Sound and packet drivers.</p>
Re: QEMU: The Open Source Processor Emulator
After installing Internet Explorer 5.01 and Netscape Navigator 4.08, Windows 3.1 did work, however I couldn't get on the internet at all. I mean, all the options were for setting up a internet connection were just a list of dial-up modems. I even looked into the OS/2 Warp 4.x How to section for clues on how to get Windows 3.1 to detect the Trumpet Winsock 3 on top of the Crynwr NE2000.COM drivers as well as putting the following lines into the autoexec.bat file:
LH /L:2,9216 C:\CRYNWR\NE2000.COM 0x60 11 0xC100
LH /L:2,4144 C:\CRYNWR\WINPKT.COM 0x60
As a result, still no internet connection under Windows 3.1. What would I need to do in order to get the internet connection to work under Windows 3.1?
I have screenshot of both of the problems that you might want to look into. Here's the first one:
Unable to connect to the internet: <font color="#c000c0">http://qemu-forum.ipi.fi/download.php?id=293</font>
Secondly, I downloaded the Cirrus Logic 5446 drivers from the DriverGuide.com site and it was supposed to work for Windows 3.1, but when I tried to install the Cirrus Logic 5446 drivers under Windows 3.1, I wound up with a video display corruption:
http://qemu-forum.ipi.fi/download.php?id=294
Would I have to use a dummy VGA driver with Bochs extentions in order to get a display of 1024 x 768 @ 256 colours or better? Just curious.
Any help, perhaps a possible tutorial would be appreciated. ^^