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

Re: [libvirt] Using libvirt from PHP



On Thu, Mar 26, 2009 at 01:10:12PM +0000, Daniel P. Berrange wrote:
> On Wed, Mar 25, 2009 at 10:01:22PM +0100, Radek Hladik wrote:
> > Option 2) The other option is to create Zend extension which should be 
> > able to call libvirt directly from C. However I've never done anything 
> > like that so I do not know, whether it is reasonable or not.
> 
> This is the option we'd recommend. A few people have expressed interest in
> this idea in the past, but unforatuntely I'm not aware of anyone having
> written any code for this yet. We'd very much like to see a PHP binding
> for libvirt developed & happy to give advice/support to anyone attempting
> this. It is definitely doable, but I don't know how much of a hard learning
> curve PHP C extensions have...
> 
> The libvirt API is quite large, but of course you would not need to suport
> every single API in PHP. You could build it up incrementally focusing on
> the APIs that you actually need in your applicaiton.

  Agreed, option 2) sounds the most sane to me.
There is a XML description of the API as libvirt-api.xml under docs
either in the tarball or in the developper package (at least RPM one)
this may (or not) be helpful in autogenerating some of the binding
code. E.g:

    <function name='virDomainCreateXML' file='libvirt' module='libvirt'>
      <info>Launch a new guest domain, based on an XML description
similar to the one returned by virDomainGetXMLDesc() This function may
requires privileged access to the hypervisor. The domain is not
persistent, so its definition will disappear when it is destroyed, or if
the host is restarted (see virDomainDefineXML() to define persistent
domains).</info>
      <return type='virDomainPtr' info='a new domain object or NULL in
case of failure'/>
      <arg name='conn' type='virConnectPtr' info='pointer to the
hypervisor connection'/>
      <arg name='xmlDesc' type='const char *' info='string containing an
XML description of the domain'/>
      <arg name='flags' type='unsigned int' info='callers should always
pass 0'/>
    </function>

 you have automatic description of the parameters, names and types as
well as the return value. At least of the simple bindings it may help.

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel veillard com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/


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