[Libguestfs] [PATCH 5/7] New APIs: add-domain and add-libvirt-dom.

Richard W.M. Jones rjones at redhat.com
Wed Nov 10 13:36:15 UTC 2010


On Wed, Nov 10, 2010 at 01:34:29PM +0000, Daniel P. Berrange wrote:
> On Wed, Nov 10, 2010 at 01:23:50PM +0000, Richard W.M. Jones wrote:
> > On Wed, Nov 10, 2010 at 01:17:54PM +0000, Daniel P. Berrange wrote:
> > > On Wed, Nov 10, 2010 at 11:46:31AM +0000, Richard W.M. Jones wrote:
> > > > +# This comes from the Sys::Virt bindings.
> > > > +INPUT
> > > > +O_OBJECT_domain
> > > > +    if (sv_isobject ($arg) && (SvTYPE (SvRV ($arg)) == SVt_PVMG))
> > > > +        $var = ($type)SvIV ((SV*) SvRV ($arg));
> > > > +    else {
> > > > +        warn(\"${Package}::$func_name() -- $var is not a blessed SV reference\");
> > > > +        XSRETURN_UNDEF;
> > > > +    }
> > > 
> > > I haven't been considering this Sys::Virt type mapping to be
> > > part of the stable ABI/API, just an internal impl details. I'm
> > > wondering how other Perl XS modules allow extension, without
> > > exposing their internal typedef implementation detail.
> > 
> > Yup, this is a general problem with providing integration for these
> > pointers through any non-C language bindings.  It could be alleviated
> > by having Sys::Virt provide a little bit of C to perform the SV ->
> > pointer conversion -- I think if it was in Sys/Virt/Virt.so then we
> > would be able to link to it.
> > 
> > > > +  /* Connect to libvirt, find the domain. */
> > > > +  conn = virConnectOpenReadOnly (libvirturi);
> > > > +  if (!conn) {
> > > > +    err = virGetLastError ();
> > > > +    error (g, _("could not connect to libvirt (code %d, domain %d): %s"),
> > > > +           err->code, err->domain, err->message);
> > > > +    goto cleanup;
> > > > +  }
> > > > +
> > > > +  dom = virDomainLookupByName (conn, domain_name);
> > > > +  if (!dom) {
> > > > +    err = virConnGetLastError (conn);
> > > 
> > > NB, virConnGetLastError() is deprecated because it isn't threadsafe.
> > > Instead use virGetLastError() in all places.
> > 
> > Can I call this if I don't have a connection pointer?  See first case
> > above.
[...]

Right, I was reading your comment the wrong way round :-)

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top




More information about the Libguestfs mailing list