]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virterror: Add virSetError
authorCole Robinson <crobinso@redhat.com>
Sat, 9 Jan 2010 01:38:55 +0000 (20:38 -0500)
committerCole Robinson <crobinso@redhat.com>
Tue, 12 Jan 2010 15:48:33 +0000 (10:48 -0500)
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
src/util/virterror.c
src/util/virterror_internal.h

index 10940ebab3986a87cfb6819c9fd5594f2e6381a9..a8947757b1ea104c35d909beec93c6e5c60b3bcb 100644 (file)
@@ -593,6 +593,7 @@ virRaiseErrorFull;
 virReportSystemErrorFull;
 virReportOOMErrorFull;
 virStrerror;
+virSetError;
 
 
 # xml.h
index bee1242c4c59bdabad30a5b198c04b77f8793c59..e2128b9437a27b1c51af5dd9c2e83e82475bb056 100644 (file)
@@ -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
index c246140b76d4b65b6e18f18908d7b651be2e2a46..c7134976c1be0d99a462a8392ef3eb38e9e1ff54 100644 (file)
@@ -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);