[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] Introduce virCopyLastError()



# HG changeset patch
# User john levon sun com
# Date 1233859424 28800
# Node ID dd8a1923aae38d9e36cb98a934af64450ecd85a2
# Parent  8086732c0e4250d26a4cfed2411e86b209712eb5
Introduce virCopyLastError()

Allow applications to store a copy of the last error reported.

Signed-off-by: John Levon <john levon sun com>

diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h
--- a/include/libvirt/virterror.h
+++ b/include/libvirt/virterror.h
@@ -172,6 +172,7 @@ typedef void (*virErrorFunc) (void *user
  */
 
 virErrorPtr		virGetLastError		(void);
+virErrorPtr		virSaveLastError	(void);
 void			virResetLastError	(void);
 void			virResetError		(virErrorPtr err);
 
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -247,4 +247,9 @@ LIBVIRT_0.6.0 {
 
 } LIBVIRT_0.5.0;
 
+LIBVIRT_0.6.1 {
+    global:
+	virSaveLastError;
+} LIBVIRT_0.6.0;
+
 # .... define new API here using predicted next version number ....
diff --git a/src/virterror.c b/src/virterror.c
--- a/src/virterror.c
+++ b/src/virterror.c
@@ -286,6 +286,25 @@ virCopyLastError(virErrorPtr to)
 }
 
 /**
+ * virSaveLastError:
+ *
+ * Save the last error into a new error object.
+ *
+ * Returns a pointer to the copied error or NULL if allocation failed.
+ */
+virErrorPtr
+virSaveLastError(void)
+{
+    virErrorPtr to;
+
+    if (VIR_ALLOC(to) < 0)
+        return NULL;
+
+    virCopyLastError(to);
+    return to;
+}
+
+/**
  * virResetError:
  * @err: pointer to the virError to clean up
  *


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]