From 8557bc67a4bf0887b98e54bd7d42f3eec0ffc34c Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Fri, 24 Feb 2006 22:36:10 +0000 Subject: [PATCH] * src/Makefile.am src/internal.h src/libvirt.c src/libvirt_sym.version src/virterror.c include/Makefile.am include/virterror.h: adding the public APIs for errors, callbacks and synchronous. The boring stuff is still left to do, plugging it. Also need to be exposed at the python level. * doc//*: rebuilt Daniel --- ChangeLog | 9 + docs/APIchunk0.html | 120 +++++---- docs/APIchunk1.html | 167 +++++++------ docs/APIchunk2.html | 158 +++++++----- docs/APIconstructors.html | 2 + docs/APIfiles.html | 26 ++ docs/APIfunctions.html | 15 +- docs/APIsymbols.html | 28 ++- docs/html/book1.html | 2 +- docs/html/index.html | 2 +- docs/html/libvirt-lib.html | 2 +- docs/html/libvirt-libvirt.html | 2 +- docs/libvirt-api.xml | 111 +++++++++ docs/libvirt-refs.xml | 436 +++++++++++++++++++++++++++++---- include/Makefile.am | 3 +- include/libvirt/Makefile.am | 3 +- include/libvirt/virterror.h | 114 +++++++++ include/virterror.h | 114 +++++++++ src/Makefile.am | 5 +- src/internal.h | 9 +- src/libvirt.c | 2 +- src/libvirt_sym.version | 10 + src/virterror.c | 175 +++++++++++++ 23 files changed, 1271 insertions(+), 244 deletions(-) create mode 100644 include/libvirt/virterror.h create mode 100644 include/virterror.h create mode 100644 src/virterror.c diff --git a/ChangeLog b/ChangeLog index 46e24cfc18..cddb4a66f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Fri Feb 24 23:33:55 CET 2006 Daniel Veillard + + * src/Makefile.am src/internal.h src/libvirt.c src/libvirt_sym.version + src/virterror.c include/Makefile.am include/virterror.h: adding + the public APIs for errors, callbacks and synchronous. The boring + stuff is still left to do, plugging it. Also need to be exposed + at the python level. + * doc//*: rebuilt + Fri Feb 24 22:17:12 CET 2006 Daniel Veillard * docs/index.py docs/search.php: fixing the search engine. diff --git a/docs/APIchunk0.html b/docs/APIchunk0.html index c4d92e1f45..5b9e5ca667 100644 --- a/docs/APIchunk0.html +++ b/docs/APIchunk0.html @@ -1,14 +1,16 @@ -API Alphabetic Index A-e for libvirt

API Alphabetic Index A-e for libvirt

A-e -f-o -p-y -z-z +API Alphabetic Index A-c for libvirt

API Alphabetic Index A-c for libvirt

A-c +d-n +o-t +u-z

Letter A:

ABI
_virDomainInfo
APIs
virConnectOpenReadOnly
After
virDomainSave

Letter C:

CPU
virDomainSuspend
Collect
virConnectListDomains
+
Copy
virConnCopyLastError
+virCopyLastError

Letter D:

Destroy
virDomainDestroy
Domain0
virDomainGetMaxMemory
virDomainSetMaxMemory
@@ -31,7 +33,9 @@

Letter L:

Launch
virDomainCreateLinux
Linux
virDomainCreateLinux

Letter M:

Macro
LIBVIR_VERSION_NUMBER
-

Letter N:

NULL
virConnectGetType
+

Letter N:

NULL
virConnGetLastError
+virConnSetErrorFunc
+virConnectGetType
virConnectOpen
virConnectOpenReadOnly
virDomainCreateLinux
@@ -43,18 +47,32 @@ virDomainLookupByName
virDomainLookupByUUID
virDomainSetMaxMemory
+virGetLastError
virGetVersion
+virSetErrorFunc
Note
virDomainGetInfo
virDomainShutdown

Letter O:

OUT
virConnectGetVersion
virGetVersion
-

Letter P:

Provide
virDomainGetXMLDesc
+
One
virConnCopyLastError
+virCopyLastError
+

Letter P:

Provide
virConnGetLastError
+virDomainGetXMLDesc
+virGetLastError
Provides
virConnectNumOfDomains
virGetVersion

Letter R:

Read-Only
virConnectGetVersion
+
Reset
virConnResetLastError
+virResetError
+virResetLastError
Resume
virDomainResume
Retrieve
virDomainGetMaxMemory
-

Letter S:

Shutdown
virDomainShutdown
+

Letter S:

Set
virConnSetErrorFunc
+virSetErrorFunc
+
Shutdown
virDomainShutdown
+
Signature
virErrorFunc
+
Simpler
virConnGetLastError
+virGetLastError
Suspends
virDomainSuspend

Letter T:

TODO:
_virDomainInfo
virDomainShutdown
@@ -77,6 +95,7 @@ virDomainLookupByUUID
Use
virDomainSave
virDomainSuspend
+

Letter W:

What
_virError

Letter X:

XML
virDomainCreateLinux
virDomainGetXMLDesc
Xen
virGetVersion
@@ -88,6 +107,8 @@ virDomainResume
virDomainSetMaxMemory
virDomainSuspend
+
accesses
virConnGetLastError
+virGetLastError
active
virConnectListDomains
virConnectNumOfDomains
virDomainSuspend
@@ -114,48 +135,76 @@ virConnectClose
virConnectOpenReadOnly
virDomainDestroy
+virSetErrorFunc
argument
virConnectOpen
virConnectOpenReadOnly
array
virConnectListDomains
virDomainGetUUID
assumed
virGetVersion
available
_virDomainInfo
+_virError
virConnectOpenReadOnly
availble
virGetVersion
-

Letter b:

back
virDomainDestroy
+

Letter b:

back
virConnSetErrorFunc
+virDomainDestroy
virGetVersion
based
virDomainCreateLinux
virDomainLookupByID
virDomainLookupByName
virDomainLookupByUUID
being
virDomainShutdown
+virErrorFunc
+virResetError
below
_virDomainInfo
block
_virDomainKernel
-
but
virDomainShutdown
+
but
virConnGetLastError
+virDomainShutdown
virDomainSuspend
+virGetLastError
bytes
virDomainGetUUID

Letter c:

call
_virDomainInfo
virConnectGetVersion
virDomainDestroy
virDomainSave
-
called
virConnectClose
+
callback
virConnSetErrorFunc
+virErrorFunc
+virSetErrorFunc
+
called
virConnSetErrorFunc
+virConnectClose
virConnectOpen
virConnectOpenReadOnly
+virSetErrorFunc
caller
virDomainGetXMLDesc
calling
virDomainResume
can
_virDomainInfo
virConnectGetVersion
virDomainGetInfo
capacities
virConnectGetVersion
+
caught
virConnCopyLastError
+virConnGetLastError
+virConnResetLastError
+virCopyLastError
+virGetLastError
+virResetLastError
+virSetErrorFunc
change
virDomainSetMaxMemory
check
_virDomainInfo
+
clean
virResetError
clients
_virDomainInfo
closes
virConnectClose
-
code
virGetVersion
+
code
_virError
+virConnCopyLastError
+virCopyLastError
+virGetVersion
collect
virConnectListDomains
command
_virDomainKernel
compiled
virGetVersion
connection
_virDomainInfo
+_virError
+virConnCopyLastError
+virConnGetLastError
+virConnResetLastError
+virConnSetErrorFunc
virConnectClose
virConnectGetType
virConnectGetVersion
@@ -169,46 +218,19 @@ virDomainLookupByName
virDomainLookupByUUID
virDomainRestore
+virSetErrorFunc
+
consequent
_virError
+
content
virConnCopyLastError
+virCopyLastError
contents
virDomainSave
control
virConnectOpenReadOnly
+
copy
virConnCopyLastError
+virCopyLastError
+
could
virSetErrorFunc
currently
virConnectOpen
virConnectOpenReadOnly
-

Letter d:

data
virDomainDestroy
-virDomainFree
-
deallocated
virDomainGetName
-
description
virDomainCreateLinux
-virDomainGetXMLDesc
-
device
_virDomainKernel
-
disk
virDomainRestore
-virDomainSave
-
doable
virDomainShutdown
-
does
virDomainDestroy
-
domains
virConnectListDomains
-virConnectNumOfDomains
-virConnectOpenReadOnly
-
down
virDomainDestroy
-

Letter e:

encoded
virDomainGetXMLDesc
-
error
virConnectClose
-virConnectGetType
-virConnectGetVersion
-virConnectListDomains
-virConnectNumOfDomains
-virConnectOpen
-virConnectOpenReadOnly
-virDomainDestroy
-virDomainGetID
-virDomainGetMaxMemory
-virDomainGetOSType
-virDomainGetUUID
-virDomainGetXMLDesc
-virGetVersion
-
especially
virConnectClose
-
extracted
_virDomainInfo
-virConnectGetVersion
-virDomainGetInfo
-
extraction
virDomainGetXMLDesc
-

A-e -f-o -p-y -z-z +

A-c +d-n +o-t +u-z

diff --git a/docs/APIchunk1.html b/docs/APIchunk1.html index 1e9f639a93..12bf99afed 100644 --- a/docs/APIchunk1.html +++ b/docs/APIchunk1.html @@ -1,10 +1,36 @@ -API Alphabetic Index f-o for libvirt

API Alphabetic Index f-o for libvirt

A-e -f-o -p-y -z-z -

Letter f:

failure
virDomainCreateLinux
+API Alphabetic Index d-n for libvirt

API Alphabetic Index d-n for libvirt

A-c +d-n +o-t +u-z +

Letter d:

data
virConnSetErrorFunc
+virDomainDestroy
+virDomainFree
+virErrorFunc
+virSetErrorFunc
+
deallocated
virDomainGetName
+
default
virConnSetErrorFunc
+virSetErrorFunc
+
description
virDomainCreateLinux
+virDomainGetXMLDesc
+
device
_virDomainKernel
+
disk
virDomainRestore
+virDomainSave
+
doable
virDomainShutdown
+
does
virDomainDestroy
+
domains
virConnectListDomains
+virConnectNumOfDomains
+virConnectOpenReadOnly
+
down
virDomainDestroy
+

Letter e:

encoded
virDomainGetXMLDesc
+
especially
virConnectClose
+
extra
_virError
+
extracted
_virDomainInfo
+virConnectGetVersion
+virDomainGetInfo
+
extraction
virDomainGetXMLDesc
+

Letter f:

failure
virDomainCreateLinux
virDomainDestroy
virDomainFree
virDomainGetInfo
@@ -25,6 +51,7 @@ virConnectOpenReadOnly
flags
virDomainGetXMLDesc
for
_virDomainInfo
+virConnGetLastError
virConnectGetVersion
virDomainGetID
virDomainGetName
@@ -33,11 +60,18 @@ virDomainLookupByUUID
virDomainSave
virDomainShutdown
+virErrorFunc
+virGetLastError
virGetVersion
+virSetErrorFunc
format
virGetVersion
-
found
virConnectListDomains
+
found
virConnCopyLastError
+virConnectListDomains
virConnectNumOfDomains
-
free
virDomainGetXMLDesc
+virCopyLastError
+
free
virConnCopyLastError
+virCopyLastError
+virDomainGetXMLDesc
freed
virDomainDestroy
virDomainFree
from
_virDomainInfo
@@ -45,7 +79,8 @@
frozen
virDomainResume
virDomainSuspend
full
_virDomainInfo
-
function
virConnectClose
+
function
virConnSetErrorFunc
+virConnectClose
virConnectOpen
virConnectOpenReadOnly
virDomainCreateLinux
@@ -53,43 +88,39 @@ virDomainResume
virDomainSetMaxMemory
virDomainSuspend
+virErrorFunc
+virSetErrorFunc
functionalities
virConnectOpenReadOnly
further
virConnectClose
virDomainSuspend

Letter g:

general
virDomainShutdown
-
get
virConnectOpen
+
get
virConnSetErrorFunc
+virConnectOpen
virConnectOpenReadOnly
virDomainGetInfo
virDomainGetMaxMemory
+virSetErrorFunc
given
virDomainDestroy
virDomainLookupByName
virDomainLookupByUUID
+
global
virConnSetErrorFunc
+virSetErrorFunc
guest
virDomainCreateLinux
virDomainShutdown
-

Letter h:

have
virGetVersion
-
hypervisor
_virDomainInfo
-virConnectClose
-virConnectGetType
-virConnectGetVersion
-virConnectListDomains
-virConnectNumOfDomains
-virConnectOpen
-virConnectOpenReadOnly
-virDomainCreateLinux
-virDomainDestroy
-virDomainGetID
-virDomainLookupByID
-virDomainLookupByName
-virDomainLookupByUUID
-virDomainRestore
-virDomainSetMaxMemory
-virDomainSuspend
-virGetVersion
+

Letter h:

handler
virConnSetErrorFunc
+virSetErrorFunc
+
handling
virConnSetErrorFunc
+virSetErrorFunc
+
have
virGetVersion
+
how
_virError
+
human-readable
_virError

Letter i:

ignore
virDomainShutdown
image
_virDomainKernel
-
information
virDomainGetInfo
+
information
_virError
+virDomainGetInfo
virGetVersion
informations
virDomainGetInfo
+
informative
_virError
init
_virDomainKernel
instance
virDomainDestroy
virDomainFree
@@ -106,12 +137,29 @@ virDomainSetMaxMemory
knowing
virDomainShutdown

Letter l:

lack
virConnectGetVersion
+
last
virConnCopyLastError
+virConnGetLastError
+virConnResetLastError
+virCopyLastError
+virGetLastError
+virResetLastError
later
virDomainGetXMLDesc
level
virConnectGetVersion
+virCopyLastError
virDomainSuspend
+virGetLastError
+virResetLastError
+virSetErrorFunc
libbrary
virConnectOpenReadOnly
library
LIBVIR_VERSION_NUMBER
+_virError
+virConnSetErrorFunc
+virCopyLastError
+virErrorFunc
+virGetLastError
virGetVersion
+virResetLastError
+virSetErrorFunc
lifetime
virDomainGetName
limited
_virDomainInfo
virDomainGetInfo
@@ -126,7 +174,8 @@
maximum
_virDomainInfo
virDomainGetMaxMemory
virDomainSetMaxMemory
-
may
virConnectGetVersion
+
may
virConnGetLastError
+virConnectGetVersion
virDomainCreateLinux
virDomainDestroy
virDomainGetXMLDesc
@@ -134,11 +183,13 @@ virDomainSave
virDomainShutdown
virDomainSuspend
+virGetLastError
memory
_virDomainInfo
virDomainGetMaxMemory
virDomainSave
virDomainSetMaxMemory
virDomainSuspend
+
message
_virError
method
virDomainRestore
virDomainSave
methods
virConnectOpenReadOnly
@@ -147,11 +198,15 @@ virConnectGetVersion
virGetVersion
monitoring
virConnectClose
+
multithreaded
virConnGetLastError
+virGetLastError
must
virDomainGetXMLDesc

Letter n:

name
virConnectGetType
virDomainGetName
virDomainLookupByName
-
need
virConnectClose
+
need
virConnCopyLastError
+virConnectClose
+virCopyLastError
virDomainGetName
needed
virConnectClose
new
virDomainCreateLinux
@@ -159,7 +214,10 @@ virDomainLookupByID
virDomainLookupByName
virDomainLookupByUUID
-
not
virConnectClose
+
none
virConnGetLastError
+virGetLastError
+
not
virConnGetLastError
+virConnectClose
virConnectGetVersion
virDomainDestroy
virDomainFree
@@ -167,46 +225,15 @@ virDomainGetXMLDesc
virDomainSave
virDomainShutdown
+virGetLastError
virGetVersion
-
number
virConnectListDomains
+
number
_virError
+virConnectListDomains
virConnectNumOfDomains
virDomainGetID
virDomainLookupByID
-

Letter o:

object
virDomainCreateLinux
-virDomainDestroy
-virDomainFree
-virDomainGetID
-virDomainGetInfo
-virDomainGetMaxMemory
-virDomainGetName
-virDomainGetOSType
-virDomainGetUUID
-virDomainGetXMLDesc
-virDomainLookupByID
-virDomainLookupByName
-virDomainLookupByUUID
-virDomainResume
-virDomainSave
-virDomainSetMaxMemory
-virDomainShutdown
-virDomainSuspend
-
one
_virDomainInfo
-virDomainCreateLinux
-
only
_virDomainInfo
-virConnectGetVersion
-virDomainGetInfo
-
operation
virDomainGetOSType
-
option
virDomainShutdown
-
optional
_virDomainKernel
-virConnectOpen
-virConnectOpenReadOnly
-virDomainCreateLinux
-
otherwise
virConnectGetType
-virConnectGetVersion
-virGetVersion
-
output
virDomainSave
-

A-e -f-o -p-y -z-z +

A-c +d-n +o-t +u-z

diff --git a/docs/APIchunk2.html b/docs/APIchunk2.html index 80da2803f5..261c812825 100644 --- a/docs/APIchunk2.html +++ b/docs/APIchunk2.html @@ -1,19 +1,65 @@ -API Alphabetic Index p-y for libvirt

API Alphabetic Index p-y for libvirt

A-e -f-o -p-y -z-z -

Letter p:

padding
_virDomainInfo
+API Alphabetic Index o-t for libvirt

API Alphabetic Index o-t for libvirt

A-c +d-n +o-t +u-z +

Letter o:

object
virDomainCreateLinux
+virDomainDestroy
+virDomainFree
+virDomainGetID
+virDomainGetInfo
+virDomainGetMaxMemory
+virDomainGetName
+virDomainGetOSType
+virDomainGetUUID
+virDomainGetXMLDesc
+virDomainLookupByID
+virDomainLookupByName
+virDomainLookupByUUID
+virDomainResume
+virDomainSave
+virDomainSetMaxMemory
+virDomainShutdown
+virDomainSuspend
+
occured
virConnGetLastError
+virGetLastError
+
one
_virDomainInfo
+virDomainCreateLinux
+
only
_virDomainInfo
+virConnectGetVersion
+virDomainGetInfo
+
operation
virDomainGetOSType
+
option
virDomainShutdown
+
optional
_virDomainKernel
+virConnectOpen
+virConnectOpenReadOnly
+virDomainCreateLinux
+
otherwise
virConnCopyLastError
+virConnectGetType
+virConnectGetVersion
+virCopyLastError
+virGetVersion
+
output
virDomainSave
+

Letter p:

padding
_virDomainInfo
+
parameter
virConnCopyLastError
+virCopyLastError
parameters
_virDomainKernel
+
part
_virError
partial
virDomainGetInfo
-
pass
virConnectOpen
+
pass
virConnSetErrorFunc
+virConnectOpen
virConnectOpenReadOnly
path
virDomainRestore
virDomainSave
physical
virDomainGetMaxMemory
virDomainSetMaxMemory
-
pointer
virConnectClose
+
pointed
virResetError
+
pointer
virConnCopyLastError
+virConnGetLastError
+virConnResetLastError
+virConnSetErrorFunc
+virConnectClose
virConnectGetType
virConnectGetVersion
virConnectListDomains
@@ -28,7 +74,11 @@ virDomainLookupByName
virDomainLookupByUUID
virDomainRestore
+virGetLastError
+virResetError
+virSetErrorFunc
pointing
_virDomainKernel
+
printing
virSetErrorFunc
private
_virDomainInfo
priviledged
virConnectGetVersion
virDomainCreateLinux
@@ -40,12 +90,20 @@
process
virDomainResume
virDomainSuspend
protection
_virDomainInfo
+
provided
virConnSetErrorFunc
+virErrorFunc
+virSetErrorFunc
providing
LIBVIR_VERSION_NUMBER
public
virDomainGetName
publicly
_virDomainInfo
-

Letter r:

ramdisk
_virDomainKernel
+

Letter r:

raised
_virError
+virErrorFunc
+virSetErrorFunc
+
ramdisk
_virDomainKernel
reactivate
virDomainSuspend
reboot
virDomainShutdown
+
receive
virConnCopyLastError
+virCopyLastError
relaunch
virDomainGetXMLDesc
release
virConnectGetVersion
virGetVersion
@@ -57,12 +115,16 @@ virDomainSuspend
reserved
virDomainGetMaxMemory
virDomainSetMaxMemory
+
reset
virConnSetErrorFunc
+virSetErrorFunc
resources
virDomainDestroy
virDomainSuspend
restarted
virDomainResume
restore
virDomainRestore
virDomainSave
restricted
virConnectOpenReadOnly
+
result
virConnCopyLastError
+virCopyLastError
return
virConnectGetVersion
virDomainDestroy
virGetVersion
@@ -104,11 +166,13 @@ virDomainResume
static
virConnectGetType
stay
virDomainSuspend
+
stderr
virSetErrorFunc
still
virDomainShutdown
stopped
virDomainShutdown
store
virConnectListDomains
virConnectOpen
-
string
virConnectGetType
+
string
_virError
+virConnectGetType
virDomainGetName
virDomainGetOSType
virDomainLookupByUUID
@@ -128,13 +192,20 @@ virDomainShutdown
virDomainSuspend
successful
virDomainSave
+
suitable
virConnGetLastError
+virGetLastError
suspend
virDomainSave
suspended
virDomainResume
system
virDomainGetOSType
-

Letter t:

term
_virDomainInfo
+

Letter t:

target
virConnCopyLastError
+virCopyLastError
+
term
_virDomainInfo
terminated
virConnectGetType
virDomainGetXMLDesc
-
that
virDomainGetInfo
+
that
virConnCopyLastError
+virConnGetLastError
+virConnResetLastError
+virDomainGetInfo
virDomainGetName
virDomainShutdown
their
virConnectListDomains
@@ -143,70 +214,21 @@ virDomainSetMaxMemory
there
virConnectClose
virDomainShutdown
+virErrorFunc
+virSetErrorFunc
thereafter
virDomainDestroy
virDomainFree
this
_virDomainInfo
+_virError
virDomainGetMaxMemory
virDomainSave
virDomainSetMaxMemory
+
those
virSetErrorFunc
two
virGetVersion
type
virDomainGetOSType
virGetVersion
-

Letter u:

unknown
virGetVersion
-
unsigned
virDomainGetID
-
unused
virConnectOpen
-virConnectOpenReadOnly
-
usable
virConnectOpenReadOnly
-virDomainShutdown
-
used
_virDomainInfo
-virConnectGetType
-virDomainDestroy
-virDomainFree
-virDomainGetInfo
-virDomainGetXMLDesc
-virDomainSuspend
-
user
virDomainGetInfo
-

Letter v:

value
virConnectGetVersion
-virDomainGetXMLDesc
-virGetVersion
-
values
virGetVersion
-
version
LIBVIR_VERSION_NUMBER
-virConnectGetVersion
-virGetVersion
-
virDomainCreateLinux
virDomainGetXMLDesc
-
virDomainFlags
_virDomainInfo
-virDomainCreateLinux
-
virDomainGetXMLDesc
virDomainCreateLinux
-
virDomainInfo
virDomainGetInfo
-
virDomainRestore
virDomainSave
-
virDomainResume
virDomainSuspend
-
virDomainSave
virDomainRestore
-
virSuspendDomain
virDomainResume
-

Letter w:

was
virDomainResume
-virGetVersion
-
what
_virDomainInfo
-
where
virDomainGetMaxMemory
-virDomainResume
-virDomainSetMaxMemory
-
which
virConnectClose
-virGetVersion
-
while
virGetVersion
-
will
virDomainGetName
-virDomainRestore
-virDomainSave
-virDomainSuspend
-virGetVersion
-
with
_virDomainInfo
-virConnectClose
-virConnectGetVersion
-virDomainGetXMLDesc
-
without
virDomainSuspend
-
work
virConnectGetVersion
-

Letter x:

xen
virConnectOpen
-
xenstore
_virDomainInfo
-

Letter y:

yet
virDomainGetXMLDesc
-

A-e -f-o -p-y -z-z +

A-c +d-n +o-t +u-z

diff --git a/docs/APIconstructors.html b/docs/APIconstructors.html index 28c11b5c30..e49ac6ba15 100644 --- a/docs/APIconstructors.html +++ b/docs/APIconstructors.html @@ -8,4 +8,6 @@ virDomainLookupByID
virDomainLookupByName
virDomainLookupByUUID
+

Type virErrorPtr:

virConnGetLastError
+virGetLastError

diff --git a/docs/APIfiles.html b/docs/APIfiles.html index f04c727050..c1e9bf3d7b 100644 --- a/docs/APIfiles.html +++ b/docs/APIfiles.html @@ -58,4 +58,30 @@ virDomainState
virDomainSuspend
virGetVersion
+

Module virterror:

VIR_ERR_ERROR
+VIR_ERR_INTERNAL_ERROR
+VIR_ERR_NONE
+VIR_ERR_NO_MEMORY
+VIR_ERR_OK
+VIR_ERR_WARNING
+VIR_FROM_DOM
+VIR_FROM_NONE
+VIR_FROM_XEN
+VIR_FROM_XEND
+_virError
+virConnCopyLastError
+virConnGetLastError
+virConnResetLastError
+virConnSetErrorFunc
+virCopyLastError
+virError
+virErrorDomain
+virErrorFunc
+virErrorLevel
+virErrorNumber
+virErrorPtr
+virGetLastError
+virResetError
+virResetLastError
+virSetErrorFunc

diff --git a/docs/APIfunctions.html b/docs/APIfunctions.html index c31ccfde69..a4ccfd4c2d 100644 --- a/docs/APIfunctions.html +++ b/docs/APIfunctions.html @@ -7,7 +7,11 @@

Type unsigned long:

virDomainSetMaxMemory

Type unsigned long *:

virConnectGetVersion
virGetVersion
-

Type virConnectPtr:

virConnectClose
+

Type virConnectPtr:

virConnCopyLastError
+virConnGetLastError
+virConnResetLastError
+virConnSetErrorFunc
+virConnectClose
virConnectGetType
virConnectGetVersion
virConnectListDomains
@@ -32,4 +36,13 @@ virDomainSetMaxMemory
virDomainShutdown
virDomainSuspend
+

Type virErrorFunc:

virConnSetErrorFunc
+virSetErrorFunc
+

Type virErrorPtr:

virConnCopyLastError
+virCopyLastError
+virErrorFunc
+virResetError
+

Type void *:

virConnSetErrorFunc
+virErrorFunc
+virSetErrorFunc

diff --git a/docs/APIsymbols.html b/docs/APIsymbols.html index c78bcd994b..000003d662 100644 --- a/docs/APIsymbols.html +++ b/docs/APIsymbols.html @@ -17,9 +17,24 @@ VIR_DOMAIN_RUNNING
VIR_DOMAIN_SHUTDOWN
VIR_DOMAIN_SHUTOFF
+VIR_ERR_ERROR
+VIR_ERR_INTERNAL_ERROR
+VIR_ERR_NONE
+VIR_ERR_NO_MEMORY
+VIR_ERR_OK
+VIR_ERR_WARNING
+VIR_FROM_DOM
+VIR_FROM_NONE
+VIR_FROM_XEN
+VIR_FROM_XEND

Letter _:

_virDomainInfo
_virDomainKernel
-

Letter v:

virConnect
+_virError
+

Letter v:

virConnCopyLastError
+virConnGetLastError
+virConnResetLastError
+virConnSetErrorFunc
+virConnect
virConnectClose
virConnectGetType
virConnectGetVersion
@@ -28,6 +43,7 @@ virConnectOpen
virConnectOpenReadOnly
virConnectPtr
+virCopyLastError
virDeviceMode
virDomain
virDomainCreateFlags
@@ -57,5 +73,15 @@ virDomainShutdown
virDomainState
virDomainSuspend
+virError
+virErrorDomain
+virErrorFunc
+virErrorLevel
+virErrorNumber
+virErrorPtr
+virGetLastError
virGetVersion
+virResetError
+virResetLastError
+virSetErrorFunc

diff --git a/docs/html/book1.html b/docs/html/book1.html index f857984bf6..d7e03b950f 100644 --- a/docs/html/book1.html +++ b/docs/html/book1.html @@ -1,3 +1,3 @@ -Reference Manual for libvirt

Reference Manual for libvirt

Table of Contents

  • libvirt: core interfaces for the libvirt library

+Reference Manual for libvirt

Reference Manual for libvirt

Table of Contents

  • libvirt: core interfaces for the libvirt library
  • virterror: error handling interfaces for the libvirt library

diff --git a/docs/html/index.html b/docs/html/index.html index f857984bf6..d7e03b950f 100644 --- a/docs/html/index.html +++ b/docs/html/index.html @@ -1,3 +1,3 @@ -Reference Manual for libvirt

Reference Manual for libvirt

Table of Contents

  • libvirt: core interfaces for the libvirt library

+Reference Manual for libvirt

Reference Manual for libvirt

Table of Contents

  • libvirt: core interfaces for the libvirt library
  • virterror: error handling interfaces for the libvirt library

diff --git a/docs/html/libvirt-lib.html b/docs/html/libvirt-lib.html index f857984bf6..d7e03b950f 100644 --- a/docs/html/libvirt-lib.html +++ b/docs/html/libvirt-lib.html @@ -1,3 +1,3 @@ -Reference Manual for libvirt

Reference Manual for libvirt

Table of Contents

  • libvirt: core interfaces for the libvirt library

+Reference Manual for libvirt

Reference Manual for libvirt

Table of Contents

  • libvirt: core interfaces for the libvirt library
  • virterror: error handling interfaces for the libvirt library

diff --git a/docs/html/libvirt-libvirt.html b/docs/html/libvirt-libvirt.html index 18b6a955ce..5a5890e6ae 100644 --- a/docs/html/libvirt-libvirt.html +++ b/docs/html/libvirt-libvirt.html @@ -1,6 +1,6 @@ -Module libvirt from libvirt

Module libvirt from libvirt

Provides the interfaces of the libvirt library to handle Xen domains from a process running in domain 0

Table of Contents

#define LIBVIR_VERSION_NUMBER
Structure virConnect
struct _virConnect +Module libvirt from libvirt

Module libvirt from libvirt

Provides the interfaces of the libvirt library to handle Xen domains from a process running in domain 0

Table of Contents

#define LIBVIR_VERSION_NUMBER
Structure virConnect
struct _virConnect The content of this structure is not made public by the API.
Typedef virConnect * virConnectPtr
 
Enum virDeviceMode
diff --git a/docs/libvirt-api.xml b/docs/libvirt-api.xml
index 33e4606b91..b1096c0a2a 100644
--- a/docs/libvirt-api.xml
+++ b/docs/libvirt-api.xml
@@ -64,6 +64,37 @@
      
      
     
+    
+     error handling interfaces for the libvirt library
+     Provides the interfaces of the libvirt library to handle errors raised while using the library. 
+     Daniel Veillard <veillard@redhat.com> 
+     
+     
+     
+     
+     
+     
+     
+     
+     
+     
+     
+     
+     
+     
+     
+     
+     
+     
+     
+     
+     
+     
+     
+     
+     
+     
+    
   
   
     
@@ -85,6 +116,16 @@
     
     
     
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
     
     
       a virConnectPtr is pointer to a virConnect private structure, this is the type used to reference a connection to the Xen Hypervisor in the API.
@@ -122,6 +163,46 @@
     
     
     
+    
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+    
+    
+    
+    
+    
+    
+      Copy the content of the last error caught on that connection One will need to free the result with virResetError()
+      
+      
+      
+    
+    
+      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()
+      
+      
+    
+    
+      Reset the last error caught on that connection
+      
+      
+    
+    
+      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.
+      
+      
+      
+      
+    
     
       This function closes the connection to the Hypervisor. This should not be called if further interaction with the Hypervisor are needed especially if there is running domain which need further monitoring by the application.
       
@@ -160,6 +241,11 @@
       
       
     
+    
+      Copy the content of the last error caught at the library level One will need to free the result with virResetError()
+      
+      
+    
     
       Launch a new Linux guest domain, based on an XML description similar to the one returned by virDomainGetXMLDesc() This function may requires priviledged access to the hypervisor.
       
@@ -266,6 +352,16 @@
       
       
     
+    
+      Signature of a function to use when there is an error raised by the library.
+      
+      
+      
+    
+    
+      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()
+      
+    
     
       Provides two information back, @libVer is the version of the library while @typeVer will be the version of the hypervisor type @type against which the library was compiled. If @type is NULL, "Xen" is assumed, if @type is unknown or not availble, an error code will be returned and @typeVer will be 0.
       
@@ -273,5 +369,20 @@
       
       
     
+    
+      Reset the error being pointed to
+      
+      
+    
+    
+      Reset the last error caught at the library level.
+      
+    
+    
+      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.
+      
+      
+      
+    
   
 
diff --git a/docs/libvirt-refs.xml b/docs/libvirt-refs.xml
index 1e7892f7e9..4adcbe66fc 100644
--- a/docs/libvirt-refs.xml
+++ b/docs/libvirt-refs.xml
@@ -18,8 +18,23 @@
     
     
     
+    
+    
+    
+    
+    
+    
+    
+    
+    
+    
     
     
+    
+    
+    
+    
+    
     
     
     
@@ -29,6 +44,7 @@
     
     
     
+    
     
     
     
@@ -58,7 +74,17 @@
     
     
     
+    
+    
+    
+    
+    
+    
+    
     
+    
+    
+    
   
   
     
@@ -81,12 +107,27 @@
       
       
       
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
     
     
       
       
+      
     
     
+      
+      
+      
+      
       
       
       
@@ -96,6 +137,7 @@
       
       
       
+      
       
       
       
@@ -125,7 +167,17 @@
       
       
       
+      
+      
+      
+      
+      
+      
+      
       
+      
+      
+      
     
   
   
@@ -145,6 +197,10 @@
       
       
     
+    
+      
+      
+    
   
   
     
@@ -167,6 +223,10 @@
       
     
     
+      
+      
+      
+      
       
       
       
@@ -197,6 +257,21 @@
       
       
     
+    
+      
+      
+    
+    
+      
+      
+      
+      
+    
+    
+      
+      
+      
+    
   
   
     
@@ -259,6 +334,34 @@
       
       
     
+    
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+      
+    
   
   
     
@@ -280,6 +383,10 @@
         
           
         
+        
+          
+          
+        
       
       
         
@@ -349,6 +456,8 @@
       
       
         
+          
+          
           
           
           
@@ -361,7 +470,9 @@
           
           
           
+          
           
+          
         
         
           
@@ -373,10 +484,16 @@
           
           
         
+        
+          
+          
+        
       
       
         
+          
           
+          
         
         
           
@@ -387,6 +504,11 @@
         
           
         
+        
+          
+          
+          
+        
         
           
         
@@ -395,9 +517,20 @@
         
       
       
+        
+          
+          
+        
         
           
         
+        
+          
+        
+        
+          
+          
+        
         
           
         
@@ -439,6 +572,11 @@
           
         
       
+      
+        
+          
+        
+      
       
         
           
@@ -461,6 +599,10 @@
           
           
         
+        
+          
+          
+        
         
           
           
@@ -512,6 +654,7 @@
           
           
           
+          
         
         
           
@@ -526,6 +669,7 @@
         
         
           
+          
           
         
         
@@ -534,6 +678,7 @@
       
       
         
+          
           
           
         
@@ -545,6 +690,8 @@
         
         
           
+          
+          
         
         
           
@@ -553,8 +700,10 @@
           
         
         
+          
           
           
+          
         
         
           
@@ -567,10 +716,17 @@
           
           
         
+        
+          
+          
+          
+        
         
+          
           
           
           
+          
         
         
           
@@ -586,12 +742,24 @@
         
           
         
+        
+          
+          
+          
+          
+          
+          
+          
+        
         
           
         
         
           
         
+        
+          
+        
         
           
         
@@ -599,6 +767,9 @@
           
         
         
+          
+          
+          
           
         
         
@@ -612,6 +783,11 @@
         
         
           
+          
+          
+          
+          
+          
           
           
           
@@ -625,6 +801,14 @@
           
           
           
+          
+        
+        
+          
+        
+        
+          
+          
         
         
           
@@ -632,19 +816,35 @@
         
           
         
+        
+          
+          
+        
+        
+          
+        
         
           
           
         
       
+    
+    
       
         
+          
           
           
+          
+          
         
         
           
         
+        
+          
+          
+        
         
           
           
@@ -675,25 +875,12 @@
         
           
         
-        
-          
-          
-          
-          
-          
-          
-          
-          
-          
-          
-          
-          
-          
-          
-        
         
           
         
+        
+          
+        
         
           
           
@@ -703,8 +890,6 @@
           
         
       
-    
-    
       
         
           
@@ -740,6 +925,7 @@
         
         
           
+          
           
           
           
@@ -748,16 +934,23 @@
           
           
           
+          
+          
           
+          
         
         
           
         
         
+          
           
           
+          
         
         
+          
+          
           
         
         
@@ -776,6 +969,7 @@
           
         
         
+          
           
           
           
@@ -784,6 +978,8 @@
           
           
           
+          
+          
         
         
           
@@ -798,44 +994,44 @@
           
         
         
+          
           
           
           
           
+          
         
         
           
           
           
         
+        
+          
+          
+        
         
           
           
         
       
       
+        
+          
+          
+        
+        
+          
+          
+        
         
           
         
-        
-          
-          
-          
-          
-          
-          
-          
-          
-          
-          
-          
-          
-          
-          
-          
-          
-          
-          
+        
+          
+        
+        
+          
         
       
       
@@ -846,12 +1042,16 @@
           
         
         
+          
           
           
         
         
           
         
+        
+          
+        
         
           
         
@@ -892,19 +1092,38 @@
         
           
         
+        
+          
+          
+          
+          
+          
+          
+        
         
           
         
         
           
+          
           
+          
+          
+          
         
         
           
         
         
           
+          
+          
+          
+          
+          
           
+          
+          
         
         
           
@@ -941,6 +1160,7 @@
           
         
         
+          
           
           
           
@@ -949,6 +1169,7 @@
           
           
           
+          
         
         
           
@@ -957,6 +1178,9 @@
           
           
         
+        
+          
+        
         
           
           
@@ -975,6 +1199,10 @@
         
           
         
+        
+          
+          
+        
         
           
         
@@ -986,7 +1214,9 @@
           
         
         
+          
           
+          
           
         
         
@@ -999,7 +1229,12 @@
           
           
         
+        
+          
+          
+        
         
+          
           
           
           
@@ -1008,15 +1243,19 @@
           
           
           
+          
           
         
         
+          
           
           
           
           
         
       
+    
+    
       
         
           
@@ -1038,6 +1277,10 @@
           
           
         
+        
+          
+          
+        
         
           
           
@@ -1060,27 +1303,35 @@
           
         
         
+          
           
           
+          
           
         
         
           
         
       
-    
-    
       
         
           
         
+        
+          
+          
+        
         
           
         
+        
+          
+        
         
           
         
         
+          
           
           
         
@@ -1092,7 +1343,14 @@
           
           
         
+        
+          
+        
         
+          
+          
+          
+          
           
           
           
@@ -1108,10 +1366,16 @@
           
           
           
+          
+          
+          
         
         
           
         
+        
+          
+        
         
           
         
@@ -1133,6 +1397,11 @@
         
           
         
+        
+          
+          
+          
+        
         
           
         
@@ -1144,6 +1413,11 @@
         
       
       
+        
+          
+          
+          
+        
         
           
         
@@ -1153,6 +1427,10 @@
         
           
         
+        
+          
+          
+        
         
           
         
@@ -1174,6 +1452,10 @@
           
           
         
+        
+          
+          
+        
         
           
           
@@ -1188,6 +1470,10 @@
         
           
         
+        
+          
+          
+        
         
           
           
@@ -1271,6 +1557,9 @@
         
           
         
+        
+          
+        
         
           
         
@@ -1282,6 +1571,7 @@
           
         
         
+          
           
           
           
@@ -1309,6 +1599,10 @@
         
           
         
+        
+          
+          
+        
         
           
         
@@ -1320,6 +1614,10 @@
         
       
       
+        
+          
+          
+        
         
           
         
@@ -1328,6 +1626,9 @@
           
         
         
+          
+          
+          
           
           
           
@@ -1343,6 +1644,8 @@
         
           
           
+          
+          
         
         
           
@@ -1350,10 +1653,14 @@
         
         
           
+          
           
           
           
         
+        
+          
+        
         
           
         
@@ -1362,6 +1669,8 @@
           
         
       
+    
+    
       
         
           
@@ -1377,6 +1686,11 @@
           
           
         
+        
+          
+          
+          
+        
         
           
           
@@ -1387,7 +1701,10 @@
           
         
         
+          
           
+          
+          
         
       
       
@@ -1404,6 +1721,12 @@
           
           
         
+        
+          
+        
+        
+          
+        
         
           
         
@@ -1426,41 +1749,66 @@
         
           
         
+        
+          
+        
+        
+          
+        
+        
+          
+          
+        
         
           
         
       
       
         
+          
+          
           
           
         
         
           
         
+        
+          
+        
         
           
           
           
         
         
+          
+          
           
+          
           
+          
         
         
           
         
         
+          
+          
+          
           
           
           
           
           
+          
         
         
           
+          
           
           
+          
           
         
         
@@ -1483,8 +1831,6 @@
           
         
       
-    
-    
       
         
           
@@ -1492,10 +1838,10 @@
       
     
     
-      
-      
-      
-      
+      
+      
+      
+      
     
   
 
diff --git a/include/Makefile.am b/include/Makefile.am
index ff05f77a66..8589dc56f0 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -2,7 +2,8 @@
 
 virincdir = $(includedir)/libvirt
 
-virinc_HEADERS = libvirt.h
+virinc_HEADERS = libvirt.h		\
+		 virterror.h
 
 install-exec-hook:
 	$(mkinstalldirs) $(DESTDIR)$(virincdir)
diff --git a/include/libvirt/Makefile.am b/include/libvirt/Makefile.am
index ff05f77a66..8589dc56f0 100644
--- a/include/libvirt/Makefile.am
+++ b/include/libvirt/Makefile.am
@@ -2,7 +2,8 @@
 
 virincdir = $(includedir)/libvirt
 
-virinc_HEADERS = libvirt.h
+virinc_HEADERS = libvirt.h		\
+		 virterror.h
 
 install-exec-hook:
 	$(mkinstalldirs) $(DESTDIR)$(virincdir)
diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h
new file mode 100644
index 0000000000..bd5e2acd02
--- /dev/null
+++ b/include/libvirt/virterror.h
@@ -0,0 +1,114 @@
+/*
+ * virterror.h:
+ * Summary: error handling interfaces for the libvirt library
+ * Description: Provides the interfaces of the libvirt library to handle
+ *              errors raised while using the library.
+ *
+ * Copy:  Copyright (C) 2006 Red Hat, Inc.
+ *
+ * See COPYING.LIB for the License of this software
+ *
+ * Author: Daniel Veillard 
+ */
+
+#ifndef __VIR_VIRERR_H__
+#define __VIR_VIRERR_H__
+
+#include 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * virErrorLevel:
+ *
+ * Indicates the level of an error
+ */
+typedef enum {
+    VIR_ERR_NONE = 0,
+    VIR_ERR_WARNING = 1,	/* A simple warning */
+    VIR_ERR_ERROR = 2		/* An error */
+} virErrorLevel;
+
+/**
+ * virErrorDomain:
+ *
+ * Indicates where an error may have come from
+ */
+typedef enum {
+    VIR_FROM_NONE = 0,
+    VIR_FROM_XEN,	/* Error at Xen hypervisor layer */
+    VIR_FROM_XEND,	/* Error at connection with xend daemon */
+    VIR_FROM_DOM	/* Error when operating on a domain */
+} virErrorDomain;
+
+
+/**
+ * virError:
+ *
+ * A libvirt Error instance.
+ */
+
+typedef struct _virError virError;
+typedef virError *virErrorPtr;
+struct _virError {
+    int		code;	/* The error code, e.g. an virParserError */
+    int		domain;	/* What part of the library raised this error */
+    char       *message;/* human-readable informative error message */
+    virErrorLevel level;/* how consequent is the error */
+    virConnectPtr conn;	/* the connection if available */
+    virDomainPtr dom;	/* the domain if available */
+    char       *str1;	/* extra string information */
+    char       *str2;	/* extra string information */
+    char       *str3;	/* extra string information */
+    int		int1;	/* extra number information */
+    int		int2;	/* extra number information */
+};
+
+/**
+ * virErrorNumber:
+ *
+ * The full list of errors the library can generate
+ */
+typedef enum {
+    VIR_ERR_OK = 0,
+    VIR_ERR_INTERNAL_ERROR, /* 1 */
+    VIR_ERR_NO_MEMORY  /* 2 */
+} virErrorNumber;
+
+/**
+ * virErrorFunc:
+ * @userData:  user provided data for the error callback
+ * @error:  the error being raised.
+ *
+ * Signature of a function to use when there is an error raised by the library.
+ */
+typedef void (*virErrorFunc) (void *userData, virErrorPtr error);
+
+/*
+ * Errors can be handled as asynchronous callbacks or after the routine
+ * failed. They can also be handled globally at the library level, or
+ * at the connection level (which then has priority
+ */
+
+virErrorPtr		virGetLastError		(void);
+void			virResetLastError	(void);
+void			virResetError		(virErrorPtr err);
+
+virErrorPtr		virConnGetLastError	(virConnectPtr conn);
+void			virConnResetLastError	(virConnectPtr conn);
+int			virCopyLastError	(virErrorPtr to);
+
+void			virSetErrorFunc		(void *userData,
+						 virErrorFunc handler);
+void			virConnSetErrorFunc	(virConnectPtr conn,
+						 void *userData,
+						 virErrorFunc handler);
+int			virConnCopyLastError	(virConnectPtr conn,
+						 virErrorPtr to);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __VIR_VIRERR_H__ */
diff --git a/include/virterror.h b/include/virterror.h
new file mode 100644
index 0000000000..bd5e2acd02
--- /dev/null
+++ b/include/virterror.h
@@ -0,0 +1,114 @@
+/*
+ * virterror.h:
+ * Summary: error handling interfaces for the libvirt library
+ * Description: Provides the interfaces of the libvirt library to handle
+ *              errors raised while using the library.
+ *
+ * Copy:  Copyright (C) 2006 Red Hat, Inc.
+ *
+ * See COPYING.LIB for the License of this software
+ *
+ * Author: Daniel Veillard 
+ */
+
+#ifndef __VIR_VIRERR_H__
+#define __VIR_VIRERR_H__
+
+#include 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * virErrorLevel:
+ *
+ * Indicates the level of an error
+ */
+typedef enum {
+    VIR_ERR_NONE = 0,
+    VIR_ERR_WARNING = 1,	/* A simple warning */
+    VIR_ERR_ERROR = 2		/* An error */
+} virErrorLevel;
+
+/**
+ * virErrorDomain:
+ *
+ * Indicates where an error may have come from
+ */
+typedef enum {
+    VIR_FROM_NONE = 0,
+    VIR_FROM_XEN,	/* Error at Xen hypervisor layer */
+    VIR_FROM_XEND,	/* Error at connection with xend daemon */
+    VIR_FROM_DOM	/* Error when operating on a domain */
+} virErrorDomain;
+
+
+/**
+ * virError:
+ *
+ * A libvirt Error instance.
+ */
+
+typedef struct _virError virError;
+typedef virError *virErrorPtr;
+struct _virError {
+    int		code;	/* The error code, e.g. an virParserError */
+    int		domain;	/* What part of the library raised this error */
+    char       *message;/* human-readable informative error message */
+    virErrorLevel level;/* how consequent is the error */
+    virConnectPtr conn;	/* the connection if available */
+    virDomainPtr dom;	/* the domain if available */
+    char       *str1;	/* extra string information */
+    char       *str2;	/* extra string information */
+    char       *str3;	/* extra string information */
+    int		int1;	/* extra number information */
+    int		int2;	/* extra number information */
+};
+
+/**
+ * virErrorNumber:
+ *
+ * The full list of errors the library can generate
+ */
+typedef enum {
+    VIR_ERR_OK = 0,
+    VIR_ERR_INTERNAL_ERROR, /* 1 */
+    VIR_ERR_NO_MEMORY  /* 2 */
+} virErrorNumber;
+
+/**
+ * virErrorFunc:
+ * @userData:  user provided data for the error callback
+ * @error:  the error being raised.
+ *
+ * Signature of a function to use when there is an error raised by the library.
+ */
+typedef void (*virErrorFunc) (void *userData, virErrorPtr error);
+
+/*
+ * Errors can be handled as asynchronous callbacks or after the routine
+ * failed. They can also be handled globally at the library level, or
+ * at the connection level (which then has priority
+ */
+
+virErrorPtr		virGetLastError		(void);
+void			virResetLastError	(void);
+void			virResetError		(virErrorPtr err);
+
+virErrorPtr		virConnGetLastError	(virConnectPtr conn);
+void			virConnResetLastError	(virConnectPtr conn);
+int			virCopyLastError	(virErrorPtr to);
+
+void			virSetErrorFunc		(void *userData,
+						 virErrorFunc handler);
+void			virConnSetErrorFunc	(virConnectPtr conn,
+						 void *userData,
+						 virErrorFunc handler);
+int			virConnCopyLastError	(virConnectPtr conn,
+						 virErrorPtr to);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __VIR_VIRERR_H__ */
diff --git a/src/Makefile.am b/src/Makefile.am
index 549462d085..a3812ad124 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -14,10 +14,11 @@ libvirt_la_LDFLAGS = -Wl,--version-script=$(srcdir)/libvirt_sym.version \
 libvirt_la_SOURCES =						\
 		libvirt.c internal.h				\
 		hash.c hash.h					\
-		xml.c xml.h						\
+		xml.c xml.h					\
 		xen_internal.c xen_internal.h			\
 		xend_internal.c xend_internal.h			\
-		sexpr.c sexpr.h
+		sexpr.c sexpr.h					\
+		virterror.c
 
 bin_PROGRAMS=virsh
 
diff --git a/src/internal.h b/src/internal.h
index 7dc71d0d6b..d9c89c469e 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -13,6 +13,7 @@
 
 #include "hash.h"
 #include "libvirt.h"
+#include "virterror.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -85,8 +86,14 @@ struct _virConnect {
     struct sockaddr_un addr_un;	/* the unix address */
     struct sockaddr_in addr_in; /* the inet address */
 
+    /* error stuff */
+    virError     err;		/* the last error */
+    virErrorFunc handler;	/* associated handlet */
+    void        *userData;	/* the user data */
+
+    /* misc */
     virHashTablePtr   domains;	/* hash table for known domains */
-    int          flags;		/* a set of connection flags */
+    int               flags;	/* a set of connection flags */
 };
 
 /**
diff --git a/src/libvirt.c b/src/libvirt.c
index 6c4596da54..7b8325a49f 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -688,7 +688,7 @@ virDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid) {
     char **names;
     char **tmp;
     unsigned char ident[16];
-    int id;
+    int id = -1;
 
     if (!VIR_IS_CONNECT(conn))
 	return(NULL);
diff --git a/src/libvirt_sym.version b/src/libvirt_sym.version
index a8f1ed670a..e8c507d915 100644
--- a/src/libvirt_sym.version
+++ b/src/libvirt_sym.version
@@ -27,5 +27,15 @@
 	virDomainShutdown;
 	virDomainSuspend;
 	virGetVersion;
+	virCopyLastError;
+	virConnSetErrorFunc;
+	virResetLastError;
+	virErrorFunc;
+	virResetError;
+	virConnGetLastError;
+	virGetLastError;
+	virSetErrorFunc;
+	virConnCopyLastError;
+	virConnResetLastError;
     local: *;
 };
diff --git a/src/virterror.c b/src/virterror.c
new file mode 100644
index 0000000000..ebb90a588c
--- /dev/null
+++ b/src/virterror.c
@@ -0,0 +1,175 @@
+/*
+ * virterror.c: implements error handling and reporting code for libvirt
+ *
+ * Copy:  Copyright (C) 2006 Red Hat, Inc.
+ *
+ * See COPYING.LIB for the License of this software
+ *
+ * Author: Daniel Veillard 
+ */
+
+#include 
+#include 
+#include 
+#include "libvirt.h"
+#include "virterror.h"
+#include "internal.h"
+
+static virError     lastErr = 		/* the last error */
+{ 0, 0, NULL, VIR_ERR_NONE, NULL, NULL, NULL, NULL, NULL, 0, 0};
+static virErrorFunc virErrorHandler = NULL;/* global error handlet */
+static void        *virUserData = NULL;	/* associated data */
+
+/*
+ * virGetLastError:
+ *
+ * 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()
+ *
+ * Returns a pointer to the last error or NULL if none occured.
+ */
+virErrorPtr
+virGetLastError(void) {
+    if (lastErr.code == VIR_ERR_OK)
+        return(NULL);
+    return(&lastErr);
+}
+
+/*
+ * virCopyLastError:
+ * @to: target to receive the copy
+ *
+ * Copy the content of the last error caught at the library level
+ * One will need to free the result with virResetError()
+ *
+ * Returns 0 if no error was found and the error code otherwise and -1 in case
+ *         of parameter error.
+ */
+int
+virCopyLastError(virErrorPtr to) {
+    if (to == NULL)
+        return(-1);
+    if (lastErr.code == VIR_ERR_OK)
+        return(0);
+    memcpy(to, &lastErr, sizeof(virError));
+    return(lastErr.code);
+}
+
+/**
+ * virResetError:
+ * @err: pointer to the virError to clean up
+ * 
+ * Reset the error being pointed to
+ */
+void
+virResetError(virErrorPtr err) {
+    if (err == NULL)
+        return;
+    if (err->message != NULL)
+        free(err->message);
+    if (err->str1 != NULL)
+        free(err->str1);
+    if (err->str2 != NULL)
+        free(err->str2);
+    if (err->str3 != NULL)
+        free(err->str3);
+    memset(err, 0, sizeof(virError));
+}
+
+/**
+ * virResetLastError:
+ * 
+ * Reset the last error caught at the library level.
+ */
+void
+virResetLastError(void) {
+    virResetError(&lastErr);
+}
+
+/**
+ * virConnGetLastError:
+ * @conn: pointer to the hypervisor connection
+ *
+ * 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()
+ *
+ * Returns a pointer to the last error or NULL if none occured.
+ */
+virErrorPtr
+virConnGetLastError(virConnectPtr conn) {
+    if (conn == NULL)
+	return(NULL);
+    return(&conn->err);
+}
+
+/**
+ * virConnCopyLastError:
+ * @conn: pointer to the hypervisor connection
+ * @to: target to receive the copy
+ *
+ * Copy the content of the last error caught on that connection
+ * One will need to free the result with virResetError()
+ *
+ * Returns 0 if no error was found and the error code otherwise and -1 in case
+ *         of parameter error.
+ */
+int
+virConnCopyLastError(virConnectPtr conn, virErrorPtr to) {
+    if (conn == NULL)
+	return(-1);
+    if (to == NULL)
+        return(-1);
+    if (conn->err.code == VIR_ERR_OK)
+        return(0);
+    memcpy(to, &conn->err, sizeof(virError));
+    return(conn->err.code);
+}
+
+/**
+ * virConnResetLastError:
+ * @conn: pointer to the hypervisor connection
+ *
+ * Reset the last error caught on that connection
+ */
+void
+virConnResetLastError(virConnectPtr conn) {
+    if (conn == NULL)
+        return;
+    virResetError(&conn->err);
+}
+
+/**
+ * virSetErrorFunc:
+ * @userData: pointer to the user data provided in the handler callback
+ * @handler: the function to get called in case of error or NULL
+ *
+ * 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.
+ */
+void
+virSetErrorFunc(void *userData, virErrorFunc handler) {
+    virErrorHandler = handler;
+    virUserData = userData;
+}
+
+/**
+ * virConnSetErrorFunc:
+ * @conn: pointer to the hypervisor connection
+ * @userData: pointer to the user data provided in the handler callback
+ * @handler: the function to get called in case of error or NULL
+ *
+ * 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.
+ */
+void
+virConnSetErrorFunc(virConnectPtr conn, void *userData, virErrorFunc handler) {
+    if (conn == NULL)
+        return;
+    conn->handler = handler;
+    conn->userData = userData;
+}
+
-- 
GitLab