Tech News
← Back to articles

Writing a Hypervisor in 1k Lines

read original related products more articles

I've wrote a tutorial on building a hypervisor from scratch in 1,000 lines of code (website). Few chapters are still in progress, but it's already good enough to get you started.

More specifically, type-1 hypervisor on 64-bit RISC-V with the hypervisor extension (on QEMU).

The book is for developers who have finished Operating System in 1,000 Lines and want to learn more about how hypervisors work.

Rust

C is the best language for writing and learning from scratch, however, the most common feedback I got from the OS book readers is: can you write a tutorial in Rust?

While this "Hypervisor in 1,000 Lines" focuses on hypervisor, it starts from scratch again, in Rust! The first few chapters are the same as the OS book, but in Rust. It means this book also partially covers OS in 1,000 Lines in Rust. Enjoy!

Stable Rust

Another interesting aspect of this book is that I used stable Rust, not nightly. This is a big win for Rust - you used to always need nightly Rust due to unstable language features, such as inline assembly.

However, thanks to the continuous efforts of the Rust community, stable Rust now has all the features you need to write a hypervisor!

Hypervisor is essentially a hardware-assisted catch block

... continue reading