<htmlxmlns="http://www.w3.org/1999/xhtml"><head><metahttp-equiv="Content-Type"content="text/html; charset=ISO-8859-1"/><linkrel="stylesheet"type="text/css"href="libvirt.css"/><linkrel="SHORTCUT ICON"href="/32favicon.png"/><title>Bindings for other languages</title></head><body><divid="container"><divid="intro"><divid="adjustments"></div><divid="pageHeader"></div><divid="content2"><h1class="style1">Bindings for other languages</h1><p>Libvirt comes with bindings to support other languages than
pure C. First the headers embeds the necessary declarations to
allow direct acces from C++ code, but also we have bindings for
higher level kind of languages:</p><ul><li>Python: Libvirt comes with direct support for the Python language
(just make sure you installed the libvirt-python package if not
compiling from sources). See below for more informations about
using libvirt with python</li>
<li>Perl: Daniel Berrange provides <ahref="http://search.cpan.org/~danberr/Sys-Virt-0.1.0/">bindings for
Perl</a>.</li>
<li>OCaml: Richard Jones supplies <ahref="http://libvirt.org/ocaml/">bindings for OCaml</a>.</li>
<li>Ruby: David Lutterkork provides <ahref="http://libvirt.org/ruby/">bindings for Ruby</a>.</li>
</ul><p>Support, requests or help for libvirt bindings are welcome on
the <ahref="https://www.redhat.com/mailman/listinfo/libvir-list/">mailing
list</a>, as usual try to provide enough background informations
and make sure you use recent version, see the <ahref="bugs.html">help
page</a>.</p><p>The remaining of this page focuses on the Python bindings.</p><p>The Python binding should be complete and are mostly automatically
(virDomainPtr domain, unsigned long memory);</code></p><p>become</p><p><code>virConn::numOfDomains(self)</code></p><p><code>virDomain::setMaxMemory(self, memory)</code></p><p>This process is fully automated, you can get a summary of the conversion
in the file libvirtclass.txt present in the python dir or in the docs.There
is a couple of function who don't map directly to their C counterparts due to
specificities in their argument conversions:</p><ul><li><code><ahref="html/libvirt-libvirt.html#virConnectListDomains">virConnectListDomains</a></code>
is replaced by <code>virDomain::listDomainsID(self)</code> which returns
a list of the integer ID for the currently running domains</li>
print dom0.<spanstyle="color: #FF0080; background-color: #FFFFFF">info</span>()</pre><p>There is not much to comment about it, it really is a straight mapping
from the C API, the only points to notice are:</p><ul><li>the import of the module called <code><spanstyle="color: #0071FF; background-color: #FFFFFF">libvirt</span></code></li>
<li>getting a connection to the hypervisor, in that case using the
openReadOnly function allows the code to execute as a normal user.</li>