[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] An introduction to the "libvirt-designer" library



People might have noticed Michal's patches[1] for the "libvirt-designer"
and wondered wtf.com that is. This is an attempt to explain it...

If you are familiar with the code in virt-install (also used by virt-manager)
you'll know it has a bunch of internal classes / APIs for dealing with
libvirt configuration, particularly wrt guest domains. If you're also
familiar with other apps like GNOME Boxes, VDSM/oVirt, OpenStack, then
you'll know that these apps have roughly the same needs as virt-install
and virt-manager wrt libvirt configuration. The virt-install internal
APIs though cannot practically be used by these apps since they were
never really designed with broad re-use in mind.

Obviously in such scenarios it is desirable to share code across apps
instead of having them all reinvent the wheel. The libvirt-gconfig
library was the first part in an attempt to address this problem by
providing a formal API for creating & reading libvirt configurations
without having to know anything about XML. This library is completely
policy-free, restricting itself to direct/explicit manipulation
of the configuration attributes. This deals with some of functionality
found in the virt-install internal APIs.

The libosinfo library [2] provides an API for discovering supportable
and optimal hardware for operating systems & hypervisors. This replaces
the OS configuration data tables found inside virt-install.

The next step is to provide a policy-driven API for configurating virtual
machines. When configuring a virtual machine,  parameters can be
roughly split into two groups - guest hardware config and host interaction
config. The idea behind the libvirt-designer API is that when creating or
changing a guest config, application developers should only need to care
about the host interaction config. The guest hardware config can be
figured out automatically on their behalf using data obtained from the
libosinfo library.

As an example, consider adding a disk to a guest. Traditionally an app
developer needs to

 - Choose what virtual hardware to use
 - Figure out guest device name
 - Set the host filename
 - Choose optimal I/O parameters (cache mode, driver type, etc, etc)

With the libvirt-designer APIs, an app developer will need to

 - Set the host filename

The rest of the points will be filled in automatically, though the app
developer will still get the opportunity to further customize the
defaults via the existing libvirt-gconfig APIs.

As mentioned above the libvirt-designer library is binding together the
libvirt-gconfig and libosinfo APIs. It explicitly does *not* directly
depend on libvirt or libvirt-gobject. This is to try to allow the
libvirt-designer library to be used by a wide variety of applications,
no matter how they are interacting with libvirt. eg if they use the
CIM, SNMP or QMF bindings to libvirt they can still use libvirt-designer
to build their XML configurations.

The intent is that there is yet another library, so far called
libvirt-builder, which binds together the libvirt-designer and
libvirt-gobject APIs, to actually automate some of the lifecycle
management and VM provisioning tasks. Since it will use libvirt-gobject,
this final library would not be accessible to apps using CIM/SNMP/QMF
bindings. With this library, we would have more or less complete
coverage of all the important tasks found in the virt-install
internal APIs, which can be reused by other apps. There is of course
still quite a long way to go before we get there, since we're aiming to
build this all up incrementally from the bottom up.

The hope is that in the near term, GNOME Boxes will be able to start
taking advantage of some of the code provided by libvirt-designer,
since it already uses libvirt-gconfig & libosinfo. In addition as
more functionality appears we'll be able to start changing virt-install
to switch it over to these APIs in favour of its internal code.

Regards,
Daniel

[1] https://www.redhat.com/archives/libvir-list/2012-September/msg00214.html
[2] https://fedorahosted.org/libosinfo
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]