[libvirt] Question about building libvirt.so

Cedric Bosdonnat cbosdonnat at suse.com
Fri Feb 21 08:19:35 UTC 2014


Hello Vik,

On Thu, 2014-02-20 at 15:14 -0800, vikhyath reddy wrote:
> Thanks for libvirt. It is a life saver. I am in the process of writing
> some custom wrappers for libvirt so that it can be easily accessed
> from nodejs using the nodejs-ffi interfacing (basically describes a
> way to convert nodejs to c calls). I did write the wrapper on the
> lines of the examples provided. But I am unable to see my new
> functions in the libvirt.so file (which nodejs interfacing needs).
> Which means that my wrappers under <libvirt>/wrappers/ are not getting
> into libvirt.so like the ones at <libvirt>/examples

I don't quite get what you are doing. Why would you need to modify
libvirt to wrap it in a nodejs-based script? What is that
libvirt/wrappers folder you are mentioning? there is no such thing in
the libvirt repository.

>From what I understood from the nodejs-ffi page, you should mostly write
javascript code similar to this:

------------ %< ------------

var ref = require('ref');
var ffi = require('ffi');

var virConnect = ref.types.void;
var virConnectPtr = ref.refType(virConnect);

var libvirt = ffi.Library('libvirt', {
  'virInitialize': [ 'int', [ ] ],
  'virConnectOpen': [virConnectPtr, [ string ]],
  ...
});

------------ %< ------------

I'm pretty sure generating this could be automated by a small program or
script or even a clang plugin, using include/libvirt/libvirt.h.in as
input.

> Can you please guide me as to where I am going wrong? I was able to do
> a successful configure + make and I thought this will regenerate the
> new libvirt.so (which it does, but I cant see my new wrapper methods
> in it).

I case you really want to modify libvirt, then you should proceed as
mentioned on this page:

http://libvirt.org/compiling.html

Regards,
--
Cedric




More information about the libvir-list mailing list