The Haskell Lightweight Virtual Machine
A Galois Project
by
Updated for GHC 8.0.2
λ nix-shell -p haskell.compiler.ghcHaLVM240
λ nix-shell -p haskell.compiler.integer-simple.ghcHaLVM240
Available from cache.nixos.org
λ nixos ~ → cat > Main.hs <<EOF
heredoc> module Main where
heredoc>
heredoc> import Hypervisor.Console
heredoc> import Control.Concurrent
heredoc> import Control.Monad
heredoc>
heredoc> main :: IO ()
heredoc> main = do
heredoc> () <$ initXenConsole
heredoc> forever $ do
heredoc> threadDelay (1000 * 1000)
heredoc> putStrLn "Hello world!"
heredoc> EOF
[nix-shell:~]$ halvm-ghc Main.hs -o main
[nix-shell:~]$ cat > main.config <<EOF
> name = "main"
> kernel = "main"
> memory = 16
> EOF
[nix-shell:~]$ sudo xl create main.config -c
[nix-shell:~]$ sudo xl create main.config -c
Parsing config from main.config
Hello world!
Hello world!
Hello world!
C-[
[nix-shell:~/halvm-beginning]$ sudo xl list
Name ID Mem VCPUs State Time(s)
main 28 64 1 -b---- 0.1
[nix-shell:~]$ sudo xl destroy main
Where it all comes together
ghc -pgml ldkernel
building path(s) /nix/store/<long-nix-hash>-hello-halvm
Parsing config from /nix/store/<long-nix-hash>-xenConfig
Assigned IP: (10,0,1,188)
C-[
$ curl 10.0.1.188
<!doctype html>
<html>
<head></head>
<body>HaLVM says Hello! You are request 0</body>
</html>%
HaLVM Lightning Talk