<!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>Handling of errors</title></head><body><divid="container"><divid="intro"><divid="adjustments"></div><divid="pageHeader"></div><divid="content2"><h1class="style1">Handling of errors</h1><p>The main goals of libvirt when it comes to error handling are:</p><ul><li>provide as much detail as possible</li>
<li>provide the informations as soon as possible</li>
<li>provide the information as soon as possible</li>
<li>dont force the library user into one style of error handling</li>
</ul><p>As result the library provide both synchronous, callback based and
asynchronous error reporting. When an error happens in the library code the
...
...
@@ -15,7 +15,7 @@ dynamic structure which can be made thread specific. Error callback can be
set specifically to a connection with</p><p>So error handling in the code is the following:</p><ol><li>if the error can be associated to a connection for example when failing
to look up a domain
<ol><li>if there is a callback associated to the connection set with <ahref="html/libvirt-virterror.html#virConnSetErrorFunc">virConnSetErrorFunc</a>,
call it with the error informations</li>
call it with the error information</li>
<li>otherwise if there is a global callback set with <ahref="html/libvirt-virterror.html#virSetErrorFunc">virSetErrorFunc</a>,
<!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>Libvirt set of C code examples</title></head><body><divid="container"><divid="intro"><divid="adjustments"></div><divid="pageHeader"></div><divid="content2"><h1class="style1">Libvirt set of C code examples</h1><p> The examples are stored per section depending on the main focus
of the example:</p><ul><li><p><ahref="#Informations">Informations</a> :</p><ul><li><ahref="#info1.c">info1.c</a>: Extract informations about Xen domain 0</li></ul></li><li><p><ahref="#Scheduling">Scheduling</a> :</p><ul><li><ahref="#suspend.c">suspend.c</a>: Suspend a domain and then resume its execution</li></ul></li></ul><p> Getting the compilation options and libraries dependancies needed
of the example:</p><ul><li><p><ahref="#Informations">Informations</a> :</p><ul><li><ahref="#info1.c">info1.c</a>: Extract information about Xen domain 0</li></ul></li><li><p><ahref="#Scheduling">Scheduling</a> :</p><ul><li><ahref="#suspend.c">suspend.c</a>: Suspend a domain and then resume its execution</li></ul></li></ul><p> Getting the compilation options and libraries dependancies needed
to generate binaries from the examples is best done on Linux/Unix by using
the pkg-config data which should have been installed as part of <i>make
install</i> step or when installing the libvirt development package:</p><pre>gcc -o example example.c `pkg-config libvirt --libs`</pre><h2><aname="Informations"id="Informations"></a>Informations Examples</h2><h3><aname="info1.c"href="info1.c"id="info1.c">info1.c</a>: Extract informations about Xen domain 0</h3><p>Demonstrate the basic use of the library to connect to the hypervisor and extract domain informations.</p><p>Uses:</p><ul><li> line 29: Function <ahref="../html/libvirt-libvirt.html#virConnectOpenReadOnly">virConnectOpenReadOnly</a> from libvirt.h</li><li> line 36: Function <ahref="../html/libvirt-libvirt.html#virDomainLookupByID">virDomainLookupByID</a> from libvirt.h</li><li> line 43: Function <ahref="../html/libvirt-libvirt.html#virDomainGetInfo">virDomainGetInfo</a> from libvirt.h</li><li> line 53: Function <ahref="../html/libvirt-libvirt.html#virDomainFree">virDomainFree</a> from libvirt.h</li><li> line 55: Function <ahref="../html/libvirt-libvirt.html#virConnectClose">virConnectClose</a> from libvirt.h</li></ul><p>Usage:</p><p>info1</p><p>Author: Daniel Veillard</p><h2><aname="Scheduling"id="Scheduling"></a>Scheduling Examples</h2><h3><aname="suspend.c"href="suspend.c"id="suspend.c">suspend.c</a>: Suspend a domain and then resume its execution</h3><p>Demonstrate the basic use of the library to suspend and resume a domain. If no id is given on the command line this script will suspend and resume the first domain found which is not Domain 0.</p><p>Uses:</p><ul><li> line 31: Function <ahref="../html/libvirt-libvirt.html#virDomainGetInfo">virDomainGetInfo</a> from libvirt.h</li><li> line 50: Function <ahref="../html/libvirt-libvirt.html#virDomainLookupByID">virDomainLookupByID</a> from libvirt.h</li><li> line 62: Function <ahref="../html/libvirt-libvirt.html#virDomainSuspend">virDomainSuspend</a> from libvirt.h</li><li> line 73: Function <ahref="../html/libvirt-libvirt.html#virDomainResume">virDomainResume</a> from libvirt.h</li><li> line 93: Function <ahref="../html/libvirt-libvirt.html#virDomainFree">virDomainFree</a> from libvirt.h</li><li> line 100: Function <ahref="../html/libvirt-libvirt.html#virConnectOpenReadOnly">virConnectOpenReadOnly</a> from libvirt.h</li><li> line 111: Function <ahref="../html/libvirt-libvirt.html#virConnectListDomains">virConnectListDomains</a> from libvirt.h</li><li> line 132: Function <ahref="../html/libvirt-libvirt.html#virConnectClose">virConnectClose</a> from libvirt.h</li></ul><p>Usage:</p><p>suspend [id]</p><p>Author: Daniel Veillard</p></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="https://bugzilla.redhat.com/bugzilla/buglist.cgi?product=Fedora+Core&component=libvirt&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&bug_status=MODIFIED&short_desc_type=allwordssubstr&short_desc=&long_desc_type=allwordssubstr">Open bugs</a></li><li><ahref="http://virt-manager.et.redhat.com/">virt-manager</a></li><li><ahref="http://search.cpan.org/~danberr/Sys-Virt-0.1.0/">Perl bindings</a></li><li><ahref="http://libvirt.org/ocaml/">OCaml bindings</a></li><li><ahref="http://libvirt.org/ruby/">Ruby bindings</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>
install</i> step or when installing the libvirt development package:</p><pre>gcc -o example example.c `pkg-config libvirt --libs`</pre><h2><aname="Informations"id="Informations"></a>Informations Examples</h2><h3><aname="info1.c"href="info1.c"id="info1.c">info1.c</a>: Extract information about Xen domain 0</h3><p>Demonstrate the basic use of the library to connect to the hypervisor and extract domain information.</p><p>Uses:</p><ul><li> line 29: Function <ahref="../html/libvirt-libvirt.html#virConnectOpenReadOnly">virConnectOpenReadOnly</a> from libvirt.h</li><li> line 36: Function <ahref="../html/libvirt-libvirt.html#virDomainLookupByID">virDomainLookupByID</a> from libvirt.h</li><li> line 43: Function <ahref="../html/libvirt-libvirt.html#virDomainGetInfo">virDomainGetInfo</a> from libvirt.h</li><li> line 53: Function <ahref="../html/libvirt-libvirt.html#virDomainFree">virDomainFree</a> from libvirt.h</li><li> line 55: Function <ahref="../html/libvirt-libvirt.html#virConnectClose">virConnectClose</a> from libvirt.h</li></ul><p>Usage:</p><p>info1</p><p>Author: Daniel Veillard</p><h2><aname="Scheduling"id="Scheduling"></a>Scheduling Examples</h2><h3><aname="suspend.c"href="suspend.c"id="suspend.c">suspend.c</a>: Suspend a domain and then resume its execution</h3><p>Demonstrate the basic use of the library to suspend and resume a domain. If no id is given on the command line this script will suspend and resume the first domain found which is not Domain 0.</p><p>Uses:</p><ul><li> line 31: Function <ahref="../html/libvirt-libvirt.html#virDomainGetInfo">virDomainGetInfo</a> from libvirt.h</li><li> line 50: Function <ahref="../html/libvirt-libvirt.html#virDomainLookupByID">virDomainLookupByID</a> from libvirt.h</li><li> line 62: Function <ahref="../html/libvirt-libvirt.html#virDomainSuspend">virDomainSuspend</a> from libvirt.h</li><li> line 73: Function <ahref="../html/libvirt-libvirt.html#virDomainResume">virDomainResume</a> from libvirt.h</li><li> line 93: Function <ahref="../html/libvirt-libvirt.html#virDomainFree">virDomainFree</a> from libvirt.h</li><li> line 100: Function <ahref="../html/libvirt-libvirt.html#virConnectOpenReadOnly">virConnectOpenReadOnly</a> from libvirt.h</li><li> line 111: Function <ahref="../html/libvirt-libvirt.html#virConnectListDomains">virConnectListDomains</a> from libvirt.h</li><li> line 132: Function <ahref="../html/libvirt-libvirt.html#virConnectClose">virConnectClose</a> from libvirt.h</li></ul><p>Usage:</p><p>suspend [id]</p><p>Author: Daniel Veillard</p></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="https://bugzilla.redhat.com/bugzilla/buglist.cgi?product=Fedora+Core&component=libvirt&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&bug_status=MODIFIED&short_desc_type=allwordssubstr&short_desc=&long_desc_type=allwordssubstr">Open bugs</a></li><li><ahref="http://virt-manager.et.redhat.com/">virt-manager</a></li><li><ahref="http://search.cpan.org/~danberr/Sys-Virt-0.1.0/">Perl bindings</a></li><li><ahref="http://libvirt.org/ocaml/">OCaml bindings</a></li><li><ahref="http://libvirt.org/ruby/">Ruby bindings</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>
<li>the <code><os></code> block description is very different, first
it indicates that the type is 'hvm' for hardware virtualization, then
instead of a kernel, boot and command line arguments, it points to an os
boot loader which will extract the boot informations from the boot device
boot loader which will extract the boot information from the boot device
specified in a separate boot element. The <code>dev</code> attribute on
the <code>boot</code> tag can be one of:
<ul><li><code>fd</code> - boot from first floppy device</li>
...
...
@@ -415,7 +415,7 @@ it shows the CPU architecture, and the features of the chip (the feature
block is similar to what you will find in a Xen fully virtualized domain
description).</p><p>The second block (in blue) indicates the paravirtualization support of the
Xen support, you will see the os_type of xen to indicate a paravirtual
kernel, then architecture informations and potential features.</p><p>The third block (in green) gives similar informations but when running a
kernel, then architecture information and potential features.</p><p>The third block (in green) gives similar information but when running a
32 bit OS fully virtualized with Xen using the hvm support.</p><p>This section is likely to be updated and augmented in the future, see <ahref="https://www.redhat.com/archives/libvir-list/2007-March/msg00215.html">the
discussion</a> which led to the capabilities format in the mailing-list
archives.</p></div></div><divclass="linkList2"><divclass="llinks2"><h3class="links2"><span>main menu</span></h3><ul><li><ahref="index.html">Home</a></li><li><ahref="news.html">Releases</a></li><li><ahref="intro.html">Introduction</a></li><li><ahref="architecture.html">libvirt architecture</a></li><li><ahref="downloads.html">Downloads</a></li><li><ahref="format.html">XML Format</a></li><li><ahref="python.html">Bindings for other languages</a></li><li><ahref="errors.html">Handling of errors</a></li><li><ahref="FAQ.html">FAQ</a></li><li><ahref="bugs.html">Reporting bugs and getting help</a></li><li><ahref="windows.html">Windows support</a></li><li><ahref="remote.html">Remote support</a></li><li><ahref="auth.html">Access control</a></li><li><ahref="uri.html">Connection URIs</a></li><li><ahref="hvsupport.html">Hypervisor support</a></li><li><ahref="storage.html">Storage Management</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="https://bugzilla.redhat.com/bugzilla/buglist.cgi?product=Fedora+Core&component=libvirt&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&bug_status=MODIFIED&short_desc_type=allwordssubstr&short_desc=&long_desc_type=allwordssubstr">Open bugs</a></li><li><ahref="http://virt-manager.et.redhat.com/">virt-manager</a></li><li><ahref="http://search.cpan.org/~danberr/Sys-Virt-0.1.0/">Perl bindings</a></li><li><ahref="http://libvirt.org/ocaml/">OCaml bindings</a></li><li><ahref="http://libvirt.org/ruby/">Ruby bindings</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>
SetMem fix (Mark Johnson), URI handling and ordering of
drivers (Daniel Berrange), fix virsh help without hypervisor (Richard
...
...
@@ -344,7 +344,7 @@ and check the <a href="ChangeLog.html">ChangeLog</a> to gauge progress.</p><h3>0
<li>bug fixes: VCPU info breakages on xen 3.0.3, xenDaemonListDomains buffer overflow (Daniel Berrange), reference count bug when creating Xen domains (Daniel Berrange).</li>
<li>improvements: support graphic framebuffer for Xen paravirt (Daniel Berrange), VNC listen IP range support (Daniel Berrange), support for default Xen config files and inactive domains of 3.0.4 (Daniel Berrange).</li>
</ul><h3>0.1.9: Nov 29 2006</h3><ul><li>python bindings: release interpeter lock when calling C (Daniel Berrange)</li>
<li>don't raise HTTP error when looking informations for a domain</li>
<li>don't raise HTTP error when looking information for a domain</li>
<li>some refactoring to use the driver for all entry points</li>
<li>better error reporting (Daniel Berrange)</li>
<li>fix OS reporting when running as non-root</li>
...
...
@@ -362,7 +362,7 @@ and check the <a href="ChangeLog.html">ChangeLog</a> to gauge progress.</p><h3>0
<li>added support for inactive domains, new APIs, various associated cleanup (Daniel Berrange)</li>
<li>special device model for HVM guests (Daniel Berrange)</li>
<li>add API to dump core of domains (but requires a patched xend)</li>
<li>pygrub bootloader informations take over <os> informations</li>
<li>pygrub bootloader information take over <os> information</li>
<li>updated the localization strings</li>
</ul><h3>0.1.8: Oct 16 2006</h3><ul><li> Bug for system with page size != 4k</li>
<li> vcpu number initialization (Philippe Berthault)</li>
...
...
@@ -373,9 +373,9 @@ and check the <a href="ChangeLog.html">ChangeLog</a> to gauge progress.</p><h3>0
<argname='uuid'type='const unsigned char *'info='the UUID string for the network, must be 16 bytes'/>
</function>
<functionname='virDomainGetInfo'file='python'>
<info>Extract informations about a domain. Note that if the connection used to get the domain is limited only a partial set of the informations can be extracted.</info>
<returntype='int *'info='the list of informations or None in case of error'/>
<info>Extract information about a domain. Note that if the connection used to get the domain is limited only a partial set of the information can be extracted.</info>
<returntype='int *'info='the list of information or None in case of error'/>