--><head><metahttp-equiv="Content-Type"content="text/html; charset=ISO-8859-1"/><linkrel="stylesheet"type="text/css"href="../main.css"/><linkrel="SHORTCUT ICON"href="../32favicon.png"/><title>libvirt: Module virterror from libvirt</title><metaname="description"content="libvirt, virtualization, virtualization API"/></head><body><divid="header"><divid="headerLogo"></div><divid="headerSearch"><formaction="../search.php"enctype="application/x-www-form-urlencoded"method="get"><div><inputid="query"name="query"type="text"size="12"value=""/><inputid="submit"name="submit"type="submit"value="Search"/></div></form></div></div><divid="body"><divid="menu"><ulclass="l0"><li><div><atitle="Front page of the libvirt website"class="inactive"href="../index.html">Home</a></div></li><li><div><atitle="Details of new features and bugs fixed in each release"class="inactive"href="../news.html">News</a></div></li><li><div><atitle="Get the latest source releases, binary builds and get access to the source repository"class="inactive"href="../downloads.html">Downloads</a></div></li><li><div><atitle="Information for users, administrators and developers"class="active"href="../docs.html">Documentation</a><ulclass="l1"><li><div><atitle="Information about deploying and using libvirt"class="inactive"href="../deployment.html">Deployment</a></div></li><li><div><atitle="Overview of the logical subsystems in the libvirt API"class="inactive"href="../intro.html">Architecture</a></div></li><li><div><atitle="Description of the XML formats used in libvirt"class="inactive"href="../format.html">XML format</a></div></li><li><div><atitle="Hypervisor specific driver information"class="inactive"href="../drivers.html">Drivers</a></div></li><li><div><atitle="Reference manual for the C public API"class="active"href="../html/index.html">API reference</a><ulclass="l2"><li><div><atitle="core interfaces for the libvirt library"class="inactive"href="../html/libvirt-libvirt.html">libvirt</a></div></li><li><div><spanclass="active">virterror</span></div></li><li><div><atitle="matrix of API support per hypervisor per release"class="inactive"href="../hvsupport.html">Driver support</a></div></li></ul></div></li><li><div><atitle="Bindings of the libvirt API for other languages"class="inactive"href="../bindings.html">Language bindings</a></div></li><li><div><atitle="Working on the internals of libvirt API, driver and daemon code"class="inactive"href="../internals.html">Internals</a></div></li></ul></div></li><li><div><atitle="User contributed content"class="inactive"href="http://wiki.libvirt.org">Wiki</a></div></li><li><div><atitle="Frequently asked questions"class="inactive"href="../FAQ.html">FAQ</a></div></li><li><div><atitle="How and where to report bugs and request features"class="inactive"href="../bugs.html">Bug reports</a></div></li><li><div><atitle="How to contact the developers via email and IRC"class="inactive"href="../contact.html">Contact</a></div></li><li><div><atitle="Miscellaneous links of interest related to libvirt"class="inactive"href="../relatedlinks.html">Related Links</a></div></li><li><div><atitle="Overview of all content on the website"class="inactive"href="../sitemap.html">Sitemap</a></div></li></ul></div><divid="content"><h1>Module virterror from libvirt</h1><p>Provides the interfaces of the libvirt library to handle errors raised while using the library. </p><h2>Table of Contents</h2><h3><ahref="#types">Types</a></h3><pre>typedef struct _virError <ahref="#virError">virError</a>
</pre><table><tr><td>int</td><td>code</td><td> : The error code, a <ahref="libvirt-virterror.html#virErrorNumber">virErrorNumber</a></td></tr><tr><td>int</td><td>domain</td><td> : What part of the library raised this error</td></tr><tr><td>char *</td><td>message</td><td> : human-readable informative error message</td></tr><tr><td><ahref="libvirt-virterror.html#virErrorLevel">virErrorLevel</a></td><td>level</td><td> : how consequent is the error</td></tr><tr><td><ahref="libvirt-libvirt.html#virConnectPtr">virConnectPtr</a></td><td>conn</td><td> : connection if available, deprecated see note above</td></tr><tr><td><ahref="libvirt-libvirt.html#virDomainPtr">virDomainPtr</a></td><td>dom</td><td> : domain if available, deprecated see note above</td></tr><tr><td>char *</td><td>str1</td><td> : extra string information</td></tr><tr><td>char *</td><td>str2</td><td> : extra string information</td></tr><tr><td>char *</td><td>str3</td><td> : extra string information</td></tr><tr><td>int</td><td>int1</td><td> : extra number information</td></tr><tr><td>int</td><td>int2</td><td> : extra number information</td></tr><tr><td><ahref="libvirt-libvirt.html#virNetworkPtr">virNetworkPtr</a></td><td>net</td><td> : network if available, deprecated see note above</td></tr></table><pre>
</pre><table><tr><td><aname="VIR_FROM_NONE"id="VIR_FROM_NONE">VIR_FROM_NONE</a></td><td> = </td><td>0</td></tr><tr><td><aname="VIR_FROM_XEN"id="VIR_FROM_XEN">VIR_FROM_XEN</a></td><td> = </td><td>1</td><td> : Error at Xen hypervisor layer</td></tr><tr><td><aname="VIR_FROM_XEND"id="VIR_FROM_XEND">VIR_FROM_XEND</a></td><td> = </td><td>2</td><td> : Error at connection with xend daemon</td></tr><tr><td><aname="VIR_FROM_XENSTORE"id="VIR_FROM_XENSTORE">VIR_FROM_XENSTORE</a></td><td> = </td><td>3</td><td> : Error at connection with xen store</td></tr><tr><td><aname="VIR_FROM_SEXPR"id="VIR_FROM_SEXPR">VIR_FROM_SEXPR</a></td><td> = </td><td>4</td><td> : Error in the S-Expression code</td></tr><tr><td><aname="VIR_FROM_XML"id="VIR_FROM_XML">VIR_FROM_XML</a></td><td> = </td><td>5</td><td> : Error in the XML code</td></tr><tr><td><aname="VIR_FROM_DOM"id="VIR_FROM_DOM">VIR_FROM_DOM</a></td><td> = </td><td>6</td><td> : Error when operating on a domain</td></tr><tr><td><aname="VIR_FROM_RPC"id="VIR_FROM_RPC">VIR_FROM_RPC</a></td><td> = </td><td>7</td><td> : Error in the XML-RPC code</td></tr><tr><td><aname="VIR_FROM_PROXY"id="VIR_FROM_PROXY">VIR_FROM_PROXY</a></td><td> = </td><td>8</td><td> : Error in the proxy code</td></tr><tr><td><aname="VIR_FROM_CONF"id="VIR_FROM_CONF">VIR_FROM_CONF</a></td><td> = </td><td>9</td><td> : Error in the configuration file handling</td></tr><tr><td><aname="VIR_FROM_QEMU"id="VIR_FROM_QEMU">VIR_FROM_QEMU</a></td><td> = </td><td>10</td><td> : Error at the QEMU daemon</td></tr><tr><td><aname="VIR_FROM_NET"id="VIR_FROM_NET">VIR_FROM_NET</a></td><td> = </td><td>11</td><td> : Error when operating on a network</td></tr><tr><td><aname="VIR_FROM_TEST"id="VIR_FROM_TEST">VIR_FROM_TEST</a></td><td> = </td><td>12</td><td> : Error from test driver</td></tr><tr><td><aname="VIR_FROM_REMOTE"id="VIR_FROM_REMOTE">VIR_FROM_REMOTE</a></td><td> = </td><td>13</td><td> : Error from remote driver</td></tr><tr><td><aname="VIR_FROM_OPENVZ"id="VIR_FROM_OPENVZ">VIR_FROM_OPENVZ</a></td><td> = </td><td>14</td><td> : Error from OpenVZ driver</td></tr><tr><td><aname="VIR_FROM_XENXM"id="VIR_FROM_XENXM">VIR_FROM_XENXM</a></td><td> = </td><td>15</td><td> : Error at Xen XM layer</td></tr><tr><td><aname="VIR_FROM_STATS_LINUX"id="VIR_FROM_STATS_LINUX">VIR_FROM_STATS_LINUX</a></td><td> = </td><td>16</td><td> : Error in the Linux Stats code</td></tr><tr><td><aname="VIR_FROM_LXC"id="VIR_FROM_LXC">VIR_FROM_LXC</a></td><td> = </td><td>17</td><td> : Error from Linux Container driver</td></tr><tr><td><aname="VIR_FROM_STORAGE"id="VIR_FROM_STORAGE">VIR_FROM_STORAGE</a></td><td> = </td><td>18</td><td> : Error from storage driver</td></tr><tr><td><aname="VIR_FROM_NETWORK"id="VIR_FROM_NETWORK">VIR_FROM_NETWORK</a></td><td> = </td><td>19</td><td> : Error from network config</td></tr><tr><td><aname="VIR_FROM_DOMAIN"id="VIR_FROM_DOMAIN">VIR_FROM_DOMAIN</a></td><td> = </td><td>20</td><td> : Error from domain config</td></tr><tr><td><aname="VIR_FROM_UML"id="VIR_FROM_UML">VIR_FROM_UML</a></td><td> = </td><td>21</td><td> : Error at the UML driver</td></tr><tr><td><aname="VIR_FROM_NODEDEV"id="VIR_FROM_NODEDEV">VIR_FROM_NODEDEV</a></td><td> = </td><td>22</td><td> : Error from node device monitor</td></tr><tr><td><aname="VIR_FROM_XEN_INOTIFY"id="VIR_FROM_XEN_INOTIFY">VIR_FROM_XEN_INOTIFY</a></td><td> = </td><td>23</td><td> : Error from xen inotify layer</td></tr><tr><td><aname="VIR_FROM_SECURITY"id="VIR_FROM_SECURITY">VIR_FROM_SECURITY</a></td><td> = </td><td>24</td><td> : Error from security framework</td></tr><tr><td><aname="VIR_FROM_VBOX"id="VIR_FROM_VBOX">VIR_FROM_VBOX</a></td><td> = </td><td>25</td><td> : Error from VirtualBox driver</td></tr><tr><td><aname="VIR_FROM_INTERFACE"id="VIR_FROM_INTERFACE">VIR_FROM_INTERFACE</a></td><td> = </td><td>26</td><td> : Error when operating on an interface</td></tr><tr><td><aname="VIR_FROM_ONE"id="VIR_FROM_ONE">VIR_FROM_ONE</a></td><td> = </td><td>27</td><td> : Error from OpenNebula driver</td></tr></table><pre>}
</pre><p>Copy the content of the last error caught on that connection This method is not protected against access from multiple threads. In a multi-threaded application, always use the global virGetLastError() API which is backed by thread local storage. If the connection object was discovered to be invalid by an API call, then the error will be reported against the global error object. Since 0.6.0, all errors reported in the per-connection object are also duplicated in the global error object. As such an application can always use virGetLastError(). This method remains for backwards compatability. 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"><code>virConnGetLastError</code></a></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 This method is not protected against access from multiple threads. In a multi-threaded application, always use the global virGetLastError() API which is backed by thread local storage. If the connection object was discovered to be invalid by an API call, then the error will be reported against the global error object. Since 0.6.0, all errors reported in the per-connection object are also duplicated in the global error object. As such an application can always use virGetLastError(). This method remains for backwards compatability.</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 occurred.</td></tr></tbody></table></div><h3><aname="virConnResetLastError"id="virConnResetLastError"><code>virConnResetLastError</code></a></h3><preclass="programlisting">void virConnResetLastError (<ahref="libvirt-libvirt.html#virConnectPtr">virConnectPtr</a> conn)<br/>
</pre><p>The error object is kept in thread local storage, so separate threads can safely access this concurrently. 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"><code>virConnSetErrorFunc</code></a></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"><code>virCopyLastError</code></a></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 The error object is kept in thread local storage, so separate threads can safely access this concurrently. 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"><code>virDefaultErrorFunc</code></a></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"><code>virErrorFunc</code></a></h3><preclass="programlisting">typedef void (*virErrorFunc ) (void * userData, <br/><ahref="libvirt-virterror.html#virErrorPtr">virErrorPtr</a> error)
</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/><h3><aname="virFreeError"id="virFreeError"><code>virFreeError</code></a></h3><preclass="programlisting">void virFreeError (<ahref="libvirt-virterror.html#virErrorPtr">virErrorPtr</a> err)<br/>
</pre><p>Resets and frees the given error.</p><divclass="variablelist"><tableborder="0"><colalign="left"/><tbody><tr><td><spanclass="term"><i><tt>err</tt></i>:</span></td><td>error to free</td></tr></tbody></table></div><h3><aname="virGetLastError"id="virGetLastError"><code>virGetLastError</code></a></h3><preclass="programlisting"><ahref="libvirt-virterror.html#virErrorPtr">virErrorPtr</a> virGetLastError (void)<br/>
</pre><p>Provide a pointer to the last error caught at the library level The error object is kept in thread local storage, so separate threads can safely access this concurrently.</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 occurred.</td></tr></tbody></table></div><h3><aname="virResetError"id="virResetError"><code>virResetError</code></a></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"><code>virResetLastError</code></a></h3><preclass="programlisting">void virResetLastError (void)<br/>
</pre><p>Reset the last error caught at the library level. The error object is kept in thread local storage, so separate threads can safely access this concurrently, only resetting their own error object.</p><h3><aname="virSaveLastError"id="virSaveLastError"><code>virSaveLastError</code></a></h3><preclass="programlisting"><ahref="libvirt-virterror.html#virErrorPtr">virErrorPtr</a> virSaveLastError (void)<br/>
</pre><p>Save the last error into a new error object.</p><divclass="variablelist"><tableborder="0"><colalign="left"/><tbody><tr><td><spanclass="term"><i><tt>Returns</tt></i>:</span></td><td>a pointer to the copied error or NULL if allocation failed. It is the caller's responsibility to free the error with virFreeError().</td></tr></tbody></table></div><h3><aname="virSetErrorFunc"id="virSetErrorFunc"><code>virSetErrorFunc</code></a></h3><preclass="programlisting">void virSetErrorFunc (void * userData, <br/><ahref="libvirt-virterror.html#virErrorFunc">virErrorFunc</a> handler)<br/>
</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><divid="footer"><pid="sponsor">
Sponsored by:<br/><ahref="http://et.redhat.com/"><imgsrc="../et.png"alt="Project sponsored by Red Hat Emerging Technology"/></a></p></div></body></html>