On Sun, Mar 09, 2008 at 10:52:33PM +0530, Ajishrao.r wrote: > Hi, > I am using libvirt to manage, The Hypervisor, Can Any one Help me > about handling error? My main questions are. > > --- What is Library level Error Handling? > --- Any Example to use > > void virSetErrorFunc (void * userData,virErrorFunc > <http://libvirt.org/html/libvirt-virterror.html#virErrorFunc> handler) I'm not aware of any example code which uses this. The intention is that it allows a user function to be called when an error occurs. The normal way to do this is to check for an error return code from a function and call virConnGetLastError to retrieve the error. > --- What is the difference between these two funtions? > > int virConnCopyLastError (virConnectPtr > <http://libvirt.org/html/libvirt-libvirt.html#virConnectPtr> > conn,virErrorPtr > <http://libvirt.org/html/libvirt-virterror.html#virErrorPtr> to) > virErrorPtr <http://libvirt.org/html/libvirt-virterror.html#virErrorPtr> virConnGetLastError (virConnectPtr > <http://libvirt.org/html/libvirt-libvirt.html#virConnectPtr> conn) Not a lot of difference. virGetLastError returns a pointer to the global last error structure used by the library. This structure may be updated on subsequent calls. virCopyLastError copies this structure so your copy won't be mutated on subsequent calls. The global last error structure _isn't_ used much. There is also a per-connection error structure. Which one is used is an interesting subject. There are loads of other problems with keeping the error structure or a copy of it around for a long time (eg. connections and domains may be freed) so it's better to avoid this. The best documentation for virterror is the source (src/virterror.c) Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into Xen guests. http://et.redhat.com/~rjones/virt-p2v -- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list