Jisha

Guest OS Deployment Tool For Xen

Developed By Adam Huda
As part of the UCSB RACELab
under the guidance of Prof. Chandra Krintz


Click to download the alpha version of Jisha
Click to download a talk on Jisha

Introduction

Jisha makes its easy to deploy guest operating system images on a host running the Xen virtual machine monitor. Jisha is based on functionality implemented in the xen-get utility. In a nutshell, Jisha works by caching the image metadata advertised by image servers. A Jisha user can then search this metadata to find a particular guest os image they wish to install. Once a user has found their desired the image, Jisha will take care of fetching the image and communicating with Xend (via libvirt) to automatically start the guest domain.

Image Feed Cache

Jisha maintains a local cache of all images it is aware of in a file called 'feed_cache'. Before you can really do anything useful with Jisha the feed cache needs to populated by combing the image servers listed in image_feeds.list. This can be done by running 'ruby jisha.rb update'. This will build a cache of metadata (in YAML format) for all images advertised over RSS 2.0 by the image servers. The figure below illustrates this process. The image servers in the figure are the ones listed in image_feeds.list.

Usage

Update the image feed cache
# ruby jisha.rb update

Clean the image feed cache
# ruby jisha.rb clean

Search the cache using a query string
# ruby jisha.rb search <query_string>

Install an image
# ruby jisha.rb install <image_name>

Remove an image
# ruby jisha.rb remove <image_name>

Image Feeds

If you wish to offer guest os images for use with Jisha that you must create an RSS 2.0 feed. Click here to see an example image feed.

Software Architecture

Both ParserFactory and Jisha are singletons. We use factories, since in the future, images will be advertised in a variety of forms (ATOM, RSS 2.0, etc.) and we want to be able to figure out what types of feeds Jisha can handle without creating an actual parser. All classes except for VirtualMachine have been implemented. VirtualMachine will make the actual libvirt calls to start or stop an image. Futher information is provided in the Development Status section

Development Status

Jisha is currently in alpha release and is very close to fully functional prototype. The only missing piece is the necessary libvirt calls to create and destroy the actual guest domains. Since libvirt is a C based API, a wrapper is necessary to use the API in Ruby. Unfortunately, the current libvirt release only includes bindings for python. This means that we had to create our own Ruby module to make calls to the libvirt API.

After exploring several possibilities, we settled on taking the SWIG route. The SWIG tool can automatically generate wrappers for C/C++ APIs so that they can be used in higher level scripting languages. In order to build a Ruby module for a libvirt, we first created an SWIG interface file called 'libvirt.i' which includes the real libvirt.h header file.

Contents of libvirt.i
%module libvirt
%{
#include "libvirt.h"
%}

Now that we have 'libvirt.i' we can use SWIG to generate the wrapper code which is dumped into a file called 'libvirt_wrap.c'.

Running swig to generate libvirt_wrap.c
$ swig -ruby libvirt.i

Now we need to build the libvirt Ruby module. In order to build the module, we need a Makefile. Fortunately Ruby makes this easy, just create a file called extconf.rb.

Contents of extconf.rb
require 'mkmf'
create_makefile('libvirt')

Run 'extconf.rb' through Ruby to generate the Makefile.

Running extconf.rb to generate a Makefile
$ ruby extconf.rb

After running the above command, we now have a Makefile to build libvirt_wrap.c into a Ruby module.

Building and installing the libvirt Ruby module
$ make
$ sudo make install

We can now access the libvirt API through Ruby. For example:

Contents of test_libvirt.rb
require 'libvirt'
xendConnection = Libvirt.virConnectOpenReadOnly("")

Unfortunately, at this point, I'm getting an unresolved symbol error at virConnectOpenReadOnly even though I can see the symbol in the library using nm. I'm still working on getting past this point.

Future Work

Links