Yup, I'm glad we cleared that one up. It was confusing that gcc
seemed to be ignoring all the C99 documentation ...
There seem to be three possible ways forward:
(1) Pass the libvirt XML.
(2) Change virDomainPtr in the function prototype to 'void *'.
(3) Change <libvirt.h> to defend the definition of virDomainPtr with a
macro.
Option (3) is a non-starter since we'd break with old versions of
libvirt until everyone upgraded, but I think it's worth getting such a
patch in there.
Option (1) is a problem: until the lock manager API actually turns up
in a released version of libvirt, this would mean we would have to
turn off the check for the domain being shut down (or push it up to
all users).
(2) seems reasonable to me, at the loss of some type safety. I was
wondering if we could do something like this:
#ifndef __VIR_VIRLIB_H__
#define virDomainPtr void *
#endif
extern int guestfs_add_libvirt_dom (guestfs_h *g, virDomainPtr dom, ...);
#ifndef __VIR_VIRLIB_H__
#undef virDomainPtr
#endif
which would at least be type-safe if users included <libvirt.h> before
<guestfs.h>, and not be type-safe but still work if they are included
the other way around.
I can't believe we are the only people to have hit this problem ...
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine. Supports Linux and Windows.
http://et.redhat.com/~rjones/virt-df/