Skip to content

A virtual machine monitor and a tiny "operating system" to go with it. When you start Sparkler, it creates a virtual machine using Linux's KVM API. It is written in C and emulates a serial console and some other devices that fetch a tweet from an account, etc.

License

Notifications You must be signed in to change notification settings

shuveb/sparkler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sparkler: A KVM based virtual machine monitor

Welcome to Sparkler, a virtual machine monitor and a tiny "operating system" to go with it. When you start Sparkler, it creates a virtual machine using the Linux's KVM API. It is written in C and emulates the following devices:

  • Console: This is the serial console via which the VM can read the keyboard and write to the screen
  • Twitter device: Reads the latest tweet from Command Line Magic's Twitter account
  • Weather device: Fetches the weather for a few cities
  • Air Quality device: Fetches the air quality readings for a few cities

Accompanying article

Please read this companion article for details on how Sparkler works.

Sparkler architecture

sparkler architecture

Building

Please install GCC and NASM packages for your Linux distribution before you build. Change into the Sparkler directory and type "make". That's all there is to it.

Running

Just run ./sparkler and that should start a Sparkler VM. You can then play around with the options the VM presents. Some distributions need the user to be part of a kvm group if you want to run this as a regular user. Else just prefix the command with sudo.

A sample Sparkler session

Sparkler Session

The Sparkler web service

Although we use libcurl to fetch content off the internet and use json-parser to parse JSON, doing this is a real pain from C. This is very apparent if you’re like me and you’ve for exposed to the simplicity of handling this kind of stuff with higher-level languages. And so, I wrote a quick-and-dirty Sparkler Web Service that outputs JSON that is easily parsable from C. Also, it lets you try out Sparkler in its full glory without you first having to register for a Twitter developer account for you to access the Twitter API, to be able to fetch the tweet. This NodeJS service runs on the excellent Heroku platform for free. You can check out some JSON it outputs by clicking on these links here:

As you can see, I’ve made output from these different APIs structurally similar while removing a whole lot of JSON data we’ll never use. This lets us handle this with C fairly easily. When the monitor program requests for information from the sparkler program, it makes a request to the web service, parses that information and returns it to the monitor program.

About

A virtual machine monitor and a tiny "operating system" to go with it. When you start Sparkler, it creates a virtual machine using Linux's KVM API. It is written in C and emulates a serial console and some other devices that fetch a tweet from an account, etc.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published