[Libvir] What is the Difference Between virConnCopyLastError and virCopyLastError?

Richard W.M. Jones rjones at redhat.com
Thu Apr 10 15:39:40 UTC 2008

On Thu, Apr 10, 2008 at 02:56:36PM +0530, ajishrao wrote:
> 3. If virConnectOpen/virConnectOpenReadOnly fails which api should be
> called to know the error code?

You might find some example code useful.  Look at the definition of
CHECK_ERROR macro, used here:

(eg line 63)

and defined here:

(line 45)

and the _raise_virterror function which gets the virterror defined

(line 66)

  errp = conn ? virConnGetLastError (conn) : virGetLastError ();

Note that actually copying the virterror may not be such a good idea.
The lifetime of that structure and the strings / pointers contained
within it is a little bit undefined, and the virCopy* functions don't
do a deep copy IIRC.  So you should take copies of anything you need
yourself, and make sure you don't refer to the conn/dom/net structure
fields if you can possibly avoid it.


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

More information about the libvir-list mailing list