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.
C Assembly Makefile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE
Makefile Initial commit Oct 8, 2019
README.md Update README.md Oct 9, 2019
fetchnparse.c Initial commit Oct 8, 2019
fetchnparse.h
json.c Initial commit Oct 8, 2019
json.h Initial commit Oct 8, 2019
main.c Initial commit Oct 8, 2019
monitor.asm Initial commit Oct 8, 2019

README.md

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

Placeholder for article link

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.

You can’t perform that action at this time.