We often use emulators like Qemu, Virtualbox, VMWare to virtualize another Operating systems on a different platform.

Qemu is popular and open source emulator that lets you virtualize nearly any OS on any other OS. Qemu has now been ported to a new platform: Browsers. Most modern browsers like Chrome 11 and Firefox 4 can run this javascript based Emulator making it possible to run an actual Linux in your browser.

Since javascript is slower than native code, one would expect slower boot times for the Linux, but it boots amazingly fast. With a very minimal download and couple of seconds, your browser window boots into an actual Linux based on commandline. Ofcourse CLI-only makes the OS snappy for executing all your shell commands.

If you aren’t excited so far, read this again: “A PC emulator written in javascript, and running solely in browser“.

Try it now

Technical details of the Javascript based Qemu (read full)

This PC emulator is written entirely in Javascript. The emulated hardware is:

a 32 bit x86 compatible CPU

a 8259 Programmble Interrupt Controller

a 8254 Programmble Interrupt Timer

a 16450 UART.

The code is written in pure Javascript using Typed Arrays which are available in recent browsers. It was tested with Firefox 4 and Google Chrome 11 on Linux, Window and Mac. It doesn’t work with Opera.

CPU Emulation

The code is inspired from my x86 dynamic translator present in QEMU, but there are important differences because here it is an interpreter. The exact restrictions of the emulated CPU are:

No FPU/MMX/SSE No segment limit and right checks when accessing memory (Linux does not rely on them for memory protection, so it is not an issue. The x86 emulator of QEMU has the same restriction). No CS/DS/ES/SS segment overrides. FS/GS overrides are implemented because they are needed for Thread Local Storage in Linux. A few seldom used instructions are missing (BCD operations, BOUND, …). No single-stepping No real mode No 16 bit protected mode (although most 16 bit instructions are present because they are needed to run 32 bit programs).

Most of these restrictions are easy to remove.

Linux distro & kernel

It runs 2.6.20 Linux kernel with configuration available here.

Boot

The disk image is just a ram disk image loaded at boot time. It contains a filesystem generated with Buildroot containing BusyBox. I added my toy C compiler TinyCC and my unfinished but usable emacs clone QEmacs.

Javascript Performance

PC emulator is about 2 times slower using V8 than Jaeger Monkey on 32bit desktops.

I still have to try this on mobile browsers, let me know if that works for you.

We write latest and greatest in Tech Guides, Apple, iPhone, Tablets, Android, Open Source, Latest in Tech, subscribe to us@geeknizer on Twitter OR on Facebook Fanpage:

VN:F [1.9.22_1171]

please wait... Rating: 10.0/10 (3 votes cast)

VN:F [1.9.22_1171]

Rating: +3 (from 3 votes)