From fd5eb45b95a759d00c085a9dd97a97f08f714158 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Fri, 8 Jan 2010 20:38:55 -0500 Subject: [PATCH] virterror: Add virSetError Can be used to re-set an old error, which may have been squashed by other functions (like cleanup routines). Will be used in subsequent patches --- src/libvirt_private.syms | 1 + src/util/virterror.c | 22 ++++++++++++++++++++++ src/util/virterror_internal.h | 1 + 3 files changed, 24 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 10940ebab3..a8947757b1 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -593,6 +593,7 @@ virRaiseErrorFull; virReportSystemErrorFull; virReportOOMErrorFull; virStrerror; +virSetError; # xml.h diff --git a/src/util/virterror.c b/src/util/virterror.c index bee1242c4c..e2128b9437 100644 --- a/src/util/virterror.c +++ b/src/util/virterror.c @@ -289,6 +289,28 @@ virGetLastError(void) return err; } +/** + * virSetError: + * + * Set the current error from a previously saved error object + * + * Can be used to re-set an old error, which may have been squashed by + * other functions (like cleanup routines). + * + * Returns 0 on success, 1 on failure + */ +int +virSetError(virErrorPtr newerr) +{ + virErrorPtr err; + err = virGetLastError(); + if (!err) + return -1; + + virResetError(err); + return virCopyError(newerr, err); +} + /** * virCopyLastError: * @to: target to receive the copy diff --git a/src/util/virterror_internal.h b/src/util/virterror_internal.h index c246140b76..c7134976c1 100644 --- a/src/util/virterror_internal.h +++ b/src/util/virterror_internal.h @@ -90,6 +90,7 @@ void virReportOOMErrorFull(virConnectPtr conn, __FILE__, __FUNCTION__, __LINE__) +int virSetError(virErrorPtr newerr); void virDispatchError(virConnectPtr conn); const char *virStrerror(int theerrno, char *errBuf, size_t errBufLen); -- GitLab