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“.
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:
loading...
loading...
Science.
loading...
loading...
Science.
loading...
loading...
Does this man just accidentally crap ridiculous code or what?
loading...
loading...
Does this man just accidentally crap ridiculous code or what?
loading...
loading...
To describe this as a port is misleading: it isn’t. It’s an x86 emulator, as is qemu, as are many other things.
loading...
loading...
To describe this as a port is misleading: it isn’t. It’s an x86 emulator, as is qemu, as are many other things.
loading...
loading...
Are you for real? The entire text of this ‘article’ is just you copy-pasting from the original authors technical notes page. Literally, you just ripped it verbatim. Sad
loading...
loading...
Are you for real? The entire text of this ‘article’ is just you copy-pasting from the original authors technical notes page. Literally, you just ripped it verbatim. Sad
loading...
loading...
Does NOT work on the android native browser, however….
It runs ((VERY VERY SLOWLY)) under Firefox mobile on Android.
Unusable, yes. Awesome. Also yes.
loading...
loading...
Actually, it works on the native browser (on Android 2.3.4 at least), which boots in 140 seconds on my Desire. Firefox mobile can boot it in 86 seconds, but it’s impossible to type anything at the prompt.
loading...
loading...
Does NOT work on the android native browser, however….
It runs ((VERY VERY SLOWLY)) under Firefox mobile on Android.
Unusable, yes. Awesome. Also yes.
loading...
loading...
Running old DOS games in a browser.
loading...
loading...