<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml"><head><metahttp-equiv="Content-Type"content="text/html; charset=ISO-8859-1"/><linkrel="stylesheet"type="text/css"href="../libvirt.css"/><linkrel="SHORTCUT ICON"href="/32favicon.png"/><title>Module virterror from libvirt</title></head><body><divid="container"><divid="intro"><divid="adjustments"></div><divid="pageHeader"></div><divid="content2"><h1class="style1">Module virterror from libvirt</h1><tableclass="navigation"width="100%"summary="Navigation header"cellpadding="2"cellspacing="2"><trvalign="middle"><td><aaccesskey="p"href="libvirt-libvirt.html"><imgsrc="left.png"width="24"height="24"border="0"alt="Prev"/></a></td><thalign="left"><ahref="libvirt-libvirt.html">libvirt</a></th><td><aaccesskey="u"href="index.html"><imgsrc="up.png"width="24"height="24"border="0"alt="Up"/></a></td><thalign="left"><ahref="index.html">API documentation</a></th><td><aaccesskey="h"href="../index.html"><imgsrc="home.png"width="24"height="24"border="0"alt="Home"/></a></td><thalign="center"><ahref="../index.html">The virtualization API</a></th></tr></table><p>Provides the interfaces of the libvirt library to handle errors raised while using the library. </p><h2>Table of Contents</h2><preclass="programlisting">Structure <ahref="#virError">virError</a><br/>struct _virError
</pre><p>Copy the content of the last error caught on that connection One will need to free the result with virResetError()</p>
<divclass="variablelist"><tableborder="0"><colalign="left"/><tbody><tr><td><spanclass="term"><i><tt>conn</tt></i>:</span></td><td>pointer to the hypervisor connection</td></tr><tr><td><spanclass="term"><i><tt>to</tt></i>:</span></td><td>target to receive the copy</td></tr><tr><td><spanclass="term"><i><tt>Returns</tt></i>:</span></td><td>0 if no error was found and the error code otherwise and -1 in case of parameter error.</td></tr></tbody></table></div><h3><aname="virConnGetLastError"id="virConnGetLastError"></a>Function: virConnGetLastError</h3><preclass="programlisting"><ahref="libvirt-virterror.html#virErrorPtr">virErrorPtr</a> virConnGetLastError (<ahref="libvirt-libvirt.html#virConnectPtr">virConnectPtr</a> conn)<br/>
</pre><p>Provide a pointer to the last error caught on that connection Simpler but may not be suitable for multithreaded accesses, in which case use virConnCopyLastError()</p>
<divclass="variablelist"><tableborder="0"><colalign="left"/><tbody><tr><td><spanclass="term"><i><tt>conn</tt></i>:</span></td><td>pointer to the hypervisor connection</td></tr><tr><td><spanclass="term"><i><tt>Returns</tt></i>:</span></td><td>a pointer to the last error or NULL if none occured.</td></tr></tbody></table></div><h3><aname="virConnResetLastError"id="virConnResetLastError"></a>Function: virConnResetLastError</h3><preclass="programlisting">void virConnResetLastError (<ahref="libvirt-libvirt.html#virConnectPtr">virConnectPtr</a> conn)<br/>
</pre><p>Reset the last error caught on that connection</p>
<divclass="variablelist"><tableborder="0"><colalign="left"/><tbody><tr><td><spanclass="term"><i><tt>conn</tt></i>:</span></td><td>pointer to the hypervisor connection</td></tr></tbody></table></div><h3><aname="virConnSetErrorFunc"id="virConnSetErrorFunc"></a>Function: virConnSetErrorFunc</h3><preclass="programlisting">void virConnSetErrorFunc (<ahref="libvirt-libvirt.html#virConnectPtr">virConnectPtr</a> conn, <br/> void * userData, <br/><ahref="libvirt-virterror.html#virErrorFunc">virErrorFunc</a> handler)<br/>
</pre><p>Set a connection error handling function, if @handler is NULL it will reset to default which is to pass error back to the global library handler.</p>
<divclass="variablelist"><tableborder="0"><colalign="left"/><tbody><tr><td><spanclass="term"><i><tt>conn</tt></i>:</span></td><td>pointer to the hypervisor connection</td></tr><tr><td><spanclass="term"><i><tt>userData</tt></i>:</span></td><td>pointer to the user data provided in the handler callback</td></tr><tr><td><spanclass="term"><i><tt>handler</tt></i>:</span></td><td>the function to get called in case of error or NULL</td></tr></tbody></table></div><h3><aname="virCopyLastError"id="virCopyLastError"></a>Function: virCopyLastError</h3><preclass="programlisting">int virCopyLastError (<ahref="libvirt-virterror.html#virErrorPtr">virErrorPtr</a> to)<br/>
</pre><p>Copy the content of the last error caught at the library level One will need to free the result with virResetError()</p>
<divclass="variablelist"><tableborder="0"><colalign="left"/><tbody><tr><td><spanclass="term"><i><tt>to</tt></i>:</span></td><td>target to receive the copy</td></tr><tr><td><spanclass="term"><i><tt>Returns</tt></i>:</span></td><td>0 if no error was found and the error code otherwise and -1 in case of parameter error.</td></tr></tbody></table></div><h3><aname="virDefaultErrorFunc"id="virDefaultErrorFunc"></a>Function: virDefaultErrorFunc</h3><preclass="programlisting">void virDefaultErrorFunc (<ahref="libvirt-virterror.html#virErrorPtr">virErrorPtr</a> err)<br/>
</pre><p>Default routine reporting an error to stderr.</p>
<divclass="variablelist"><tableborder="0"><colalign="left"/><tbody><tr><td><spanclass="term"><i><tt>err</tt></i>:</span></td><td>pointer to the error.</td></tr></tbody></table></div><h3><aname="virErrorFunc"id="virErrorFunc"></a>Function type: virErrorFunc</h3><preclass="programlisting">Function type: virErrorFunc
</pre><p>Signature of a function to use when there is an error raised by the library.</p><divclass="variablelist"><tableborder="0"><colalign="left"/><tbody><tr><td><spanclass="term"><i><tt>userData</tt></i>:</span></td><td>user provided data for the error callback</td></tr><tr><td><spanclass="term"><i><tt>error</tt></i>:</span></td><td>the error being raised.</td></tr></tbody></table></div><br/>
</pre><p>Provide a pointer to the last error caught at the library level Simpler but may not be suitable for multithreaded accesses, in which case use virCopyLastError()</p>
<divclass="variablelist"><tableborder="0"><colalign="left"/><tbody><tr><td><spanclass="term"><i><tt>Returns</tt></i>:</span></td><td>a pointer to the last error or NULL if none occured.</td></tr></tbody></table></div><h3><aname="virResetError"id="virResetError"></a>Function: virResetError</h3><preclass="programlisting">void virResetError (<ahref="libvirt-virterror.html#virErrorPtr">virErrorPtr</a> err)<br/>
</pre><p>Reset the error being pointed to</p>
<divclass="variablelist"><tableborder="0"><colalign="left"/><tbody><tr><td><spanclass="term"><i><tt>err</tt></i>:</span></td><td>pointer to the <ahref="libvirt-virterror.html#virError">virError</a> to clean up</td></tr></tbody></table></div><h3><aname="virResetLastError"id="virResetLastError"></a>Function: virResetLastError</h3><preclass="programlisting">void virResetLastError (void)<br/>
</pre><p>Reset the last error caught at the library level.</p>
</pre><p>Set a library global error handling function, if @handler is NULL, it will reset to default printing on stderr. The error raised there are those for which no handler at the connection level could caught.</p>
<divclass="variablelist"><tableborder="0"><colalign="left"/><tbody><tr><td><spanclass="term"><i><tt>userData</tt></i>:</span></td><td>pointer to the user data provided in the handler callback</td></tr><tr><td><spanclass="term"><i><tt>handler</tt></i>:</span></td><td>the function to get called in case of error or NULL</td></tr></tbody></table></div></div></div><divclass="linkList2"><divclass="llinks2"><h3class="links2"><span>main menu</span></h3><ul><li><ahref="../index.html">Home</a></li><li><ahref="../html/index.html">API Menu</a></li><li><ahref="../examples/index.html">C code examples</a></li><li><ahref="../ChangeLog.html">Recent Changes</a></li></ul></div><divclass="llinks2"><h3class="links2"><span>related links</span></h3><ul><li><ahref="https://www.redhat.com/archives/libvir-list/">Mail archive</a></li><li><ahref="http://www.cl.cam.ac.uk/Research/SRG/netos/xen/index.html">Xen project</a></li><li><formaction="../search.php"enctype="application/x-www-form-urlencoded"method="get"><inputname="query"type="text"size="12"value="Search..."/><inputname="submit"type="submit"value="Go"/></form></li><li><ahref="http://xmlsoft.org/"><imgsrc="../Libxml2-Logo-90x34.gif"alt="Made with Libxml2 Logo"/></a></li></ul><pclass="credits">Graphics and design by <ahref="mail:dfong@redhat.com">Diana Fong</a></p></div></div><divid="bottom"><pclass="p1"></p></div></div></body></html>