qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Building QEMU for WebAssembly


From: Stefan Hajnoczi
Subject: [Qemu-devel] Building QEMU for WebAssembly
Date: Mon, 7 Jan 2019 16:36:05 +0000

As part of the QEMU micro:bit project we considered how end users will
consume QEMU.  The most convenient option is to run emulation directly
in the user's web browser - where their IDE also lives.

Here are my thoughts after a brief investigation into WebAssembly.
Basically the idea is to compile a subset of QEMU with emscripten
(https://kripken.github.io/emscripten-site/) to produce the
WebAssembly binaries that can run in modern web browsers.

The main challenges?  Emscripten and WebAssembly do not offer a full
POSIX environment, so key pieces of QEMU will not compile.

Multi-threading is not yet available in WebAssembly.  Hopefully this
will change soon because multi-threading and related infrastructure
like atomics are used at the core of several areas in QEMU.

Stack-switching is not supported so QEMU's coroutines won't work.
This mostly affects the block layer, which depends heavily on
coroutines.

Self-modifying code is not really supported.  Runtime code generation
is possible (if you jump back into Javascript) but it doesn't seem
designed for JIT compilers.  This makes TCG difficult.

Unicorn.js (https://alexaltea.github.io/unicorn.js/) takes TCI without
device emulation and builds it with emscripten.  So there's proof this
can work, but the challenge will be getting more QEMU components to
compile to WebAssembly.

I think we could build QEMU for machine types that do not have block
devices and other unsupported I/O devices, but it would require
invasive changes to QEMU.  Right now this project seems too risky and
hacky to do in qemu.git, but I wanted to raise the issue in case
others are interested.

Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]