Module virterror from libvirt
Provides the interfaces of the libvirt library to handle errors raised while using the library.
Table of Contents
typedef struct _virError virError
typedef enum virErrorDomain
typedef enum virErrorLevel
typedef enum virErrorNumber
typedef virError * virErrorPtr
int virConnCopyLastError (virConnectPtr conn,
virErrorPtr to)
virErrorPtr virConnGetLastError (virConnectPtr conn)
void virConnResetLastError (virConnectPtr conn)
void virConnSetErrorFunc (virConnectPtr conn,
void * userData,
virErrorFunc handler)
int virCopyLastError (virErrorPtr to)
void virDefaultErrorFunc (virErrorPtr err)
typedef virErrorFunc
void virErrorFunc (void * userData,
virErrorPtr error)
void virFreeError (virErrorPtr err)
virErrorPtr virGetLastError (void)
void virResetError (virErrorPtr err)
void virResetLastError (void)
virErrorPtr virSaveLastError (void)
void virSetErrorFunc (void * userData,
virErrorFunc handler)
Description
struct virError{
int | code | : The error code, a virErrorNumber |
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 | : connection if available, deprecated see note above |
virDomainPtr | dom | : domain if available, deprecated see note above |
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 |
virNetworkPtr | net | : network if available, deprecated see note above |
}
int virConnCopyLastError (virConnectPtr conn,
virErrorPtr to)
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()
conn: | pointer to the hypervisor connection |
to: | target to receive the copy |
Returns: | 0 if no error was found and the error code otherwise and -1 in case of parameter error. |
virErrorPtr virConnGetLastError (virConnectPtr conn)
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.
conn: | pointer to the hypervisor connection |
Returns: | a pointer to the last error or NULL if none occurred. |
void virConnResetLastError (virConnectPtr conn)
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
conn: | pointer to the hypervisor connection |
void virConnSetErrorFunc (virConnectPtr conn,
void * userData,
virErrorFunc handler)
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.
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 |
int virCopyLastError (virErrorPtr to)
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()
to: | target to receive the copy |
Returns: | 0 if no error was found and the error code otherwise and -1 in case of parameter error. |
void virDefaultErrorFunc (virErrorPtr err)
Default routine reporting an error to stderr.
err: | pointer to the error. |
typedef void (*virErrorFunc ) (void * userData,
virErrorPtr error)
Signature of a function to use when there is an error raised by the library.
userData: | user provided data for the error callback |
error: | the error being raised. |
void virFreeError (virErrorPtr err)
Resets and frees the given error.
virErrorPtr virGetLastError (void)
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.
Returns: | a pointer to the last error or NULL if none occurred. |
void virResetError (virErrorPtr err)
Reset the error being pointed to
void virResetLastError (void)
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.
virErrorPtr virSaveLastError (void)
Save the last error into a new error object.
Returns: | a pointer to the copied error or NULL if allocation failed. It is the caller's responsibility to free the error with virFreeError(). |
void virSetErrorFunc (void * userData,
virErrorFunc handler)
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.
userData: | pointer to the user data provided in the handler callback |
handler: | the function to get called in case of error or NULL |