Getting started with libvirt

Very recently I have been working on a platform to orchestrate VM creation and lifecycle management across a cluster of nodes with capacity, metadata, storage and network management. I was exploring stuff like KVM + QEMU and XEN when I read about libvirt and found it perfectly suiting my needs.

To start off with, KVM (Kernel-based Virtual Machine) is a virtualization infrastructure for the Linux kernel that turns it into a hypervisor, a software which enables us to run Virtual Machines on top of a host machine. XEN is another such hypervisor.

libvirt, on the other hand is an abstraction layer on top of the various hypervisor platforms with a nice API available to manage virtualization. We can choose to use any of the hypervisor backends that libvirt supports to create and manage virtual machines. The list of hypervisors supported by libvirt are listed below:

Source: Wikipedia

libvirt has an API in C for development. It also has bindings in other languages like python, perl, ocaml, ruby, java, Go, PHP and C#.

Let’s start off with installing libvirt first. Since the workstations I use are ArchLinux and OSX, I will stick to these two platforms only (the installation instructions for other platforms are easily available).

On ArchLinux, you can install libvirt with a KVM backend by installing the following packages

sudo pacman -S libvirt qemu ebtables dnsmasq bridge-utils openbsd-netcat

By default, KVM is the default driver enabled.

On OSX, you can install libvirt by running

brew install libvirt

To ensure that the libvirt daemon is running, run the following command

sudo systemctl status libvirtd

Once the libvirt daemon is running you can use the command line client virsh which comes included in the libvirt package to connect to the daemon.

Once inside the virsh client, you can run a bunch of commands to consume the API.

  • Getting the hypervisor hostname
virsh # hostname
playstation
  • Getting the node information
virsh # nodeinfo 
CPU model:           x86_64
CPU(s):              4
CPU frequency:       1800 MHz
CPU socket(s):       1
Core(s) per socket:  2
Thread(s) per core:  2
NUMA cell(s):        1
Memory size:         8066144 KiB
  • Getting the version
virsh # version
Compiled against library: libvirt 2.3.0
Using library: libvirt 2.3.0
Using API: QEMU 2.3.0
Running hypervisor: QEMU 2.7.0

You can use the help command to get a list of all available commands.

In the next post in the libvirt series, I’ll start off with programmatically consuming the libvirt APIs.

Have you checked out Jujucharms?

Over the past month, I have been exploring various PaaS providers in the market to study how they package and present their PaaS offerings to the users differently, when someone at work pointed out Jujucharms by Canonical (the same company behind Ubuntu). And taking a first look at it - I immediately liked it, just because of the clear and simple way in which they have presented application and service modelling.

Quoting for their website, “Juju is an application and service modelling tool that enables you to quickly model, configure, deploy and manage applications in the cloud with only a few commands. Use it to deploy hundreds of preconfigured services, OpenStack, or your own code to any public or private cloud.”

You can explore the modelling tool yourself here. As an example, I have a WordPress model setup with the Wordpress nodes scaled to 3, one apache node acting as a reverse proxy to the wordpress nodes, a mysql master database connected to the wordpress nodes and a slave mysql instance.

Wordpress model

The best thing about this is when you deploy, Juju will take care of all the configuration required at the various nodes. (In the above example, the reverse proxy will be configured to point to the wordpress nodes, the slave database will be configured to replicate from the master database, etc.)

Once done with the modelling, you can deploy the models you generated for your applications and services to any of the public cloud platforms supported by Juju.

Public clouds supported by Juju

Back on the Grid

I have been off the blogging / social grid for quite a long time now (the last blog came way back in mid 2014), so I feel it’s about time that I resume this blog. I have initiated this with trashing away Tumblr - my old blog (meh! I know.) and moving the old posts to Jekyll running on Github Pages.

I have been keeping quite busy with work over the past year and a half - from working quite extensively on new cloud platforms spanning over the IaaS, PaaS and Serverless space, to exploring and learning newer design and architectural methodologies, plus tinkering with technologies and frameworks which went into building these distributed and highly scalable systems. Which brings me back here - because I am quite keen to share the stuff which I have learnt during this period building these platforms.

So that said - you can expect a lot more entries from now on :)

The last 3 weeks in Krita Animation

Hello planet! Over the past few weeks I have been working on Krita Animation to make it more usable by adding essential animation features and fixing various loose ends. So here is an update on what has been done so far(Also this happens to be my first update on my Google Summer of Code, 2014 project).

Fixed loading of animation layers: Initially the animation layers did not load correctly. Only the first animation layer used to be loaded properly. And there were bugs with the layer box in the timeline GUI too. This has been fixed now. Here is a video demonstrating multiple animation layers and frame switching.

Support for Multiple Animation Layers in Krita

Auto frame breaking: This feature is specifically helpful for animators who don’t like to click the buttons or use the keyboard for adding frames, but directly start drawing on a new frame after selecting the frame. There is an option to disable this feature as it might sometimes get in the way of the workflow. Also there is an option to either insert a blank frame or key frame on frame break. Here is a video demonstrating auto frame breaking.

Auto Frame Breaking in Krita Animation

Frame Navigation actions: Actions for jumping to next and previous keyframes, next and previous frames have also been added with Keyboard shortcuts. This is specifically very helpful for animators who use keyboard to switch frames without clicking the buttons or using the timeline.

Frame Navigation Actions

Changing the timeline width: Added an option to change the timeline width according to the number of frames required in a particular animation.

Changing the timeline width

Animation import: Currently the animation frames and layers get imported in Krita Animation. But the timeline GUI doesn’t get updated accordingly.

The Road Ahead

These are the things I have been intending to add or fix in the next few days:

  • The Onion skin Docker, which is a critical feature and is currently work in progress. There should be something substantial on this soon.
  • Add code to make the timeline GUI refresh/update on its own during import, frame and layer deletion, etc.
  • Frame and layer deletion, layer locking, moving frames and layers.
  • Animation export to PNG sequences.
  • Animation player and scrubbing, caching of probable frames(with some logic like locality of reference).
  • …And lots of bug fixes :)

Also there have been some queries about how to test this stuff. So the only way to test it right now is by building from the source code after checking out the animation development branch, which is ‘animator-plugin-somsubhra’. That is all I have for now. Thanks for reading!

Oh, and by the way Krita started its first donation campaign on Kickstarter to raise money for the 2.9 release and make it more awesome. Here is a direct link to the Kickstarter page: https://www.kickstarter.com/projects/krita/krita-open-source-digital-painting-accelerate-deve

Krita Kickstarter

My blog gets a new home

My blogs have recently changed home - from Blogger to Wordpress running on OpenShift.

I tried out various blog engines like nerve (on node.js) and Nibbleblog, but finally settled for Wordpress, because I was too lazy to do so much configuration stuff. Further Openshift had a Wordpress cartridge so that was too easy to set up (In fact I did not have to do anything except click a button :P ).

I would rate Wordpress higher than Blogger, but I must admit Nibbleblog had a better blog editor and admin dashboard. But it was missing certain essential features like feeds according to tags and categories (and I absolutely need it for integrating it to Planet KDE) and also importing my existing blogs. So finally settled for Wordpress, which should hopefully keep me happy for some time. :D

Update: As of 2016 November I have settled for Jekyll running on Github Pages (I was previously running Tumblr, meh!). I have been using this at a lot of places and I am quite happy with it, so I would definitely recommend it :)