render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
Blob Blame History Raw
From 9de6f8ef5dbda65683717dd0001cb606792a9ca3 Mon Sep 17 00:00:00 2001
Message-Id: <9de6f8ef5dbda65683717dd0001cb606792a9ca3@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 10 Jul 2015 08:44:41 +0200
Subject: [PATCH] Introduce virErrorCopyNew

A helper function for copying error objects.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
(cherry picked from commit 9d0a2af6c230ce3007b3504907ccdba09cdc4cf2)

https://bugzilla.redhat.com/show_bug.cgi?id=1090093

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 docs/apibuild.py         |  1 +
 src/libvirt_private.syms |  1 +
 src/util/virerror.c      | 16 ++++++++++++++++
 src/util/virerror.h      |  1 +
 4 files changed, 19 insertions(+)

diff --git a/docs/apibuild.py b/docs/apibuild.py
index 69f991d..f934fb2 100755
--- a/docs/apibuild.py
+++ b/docs/apibuild.py
@@ -102,6 +102,7 @@ ignored_functions = {
   "virDomainMigratePrepare3Params": "private function for migration",
   "virDomainMigrateConfirm3Params": "private function for migration",
   "virDomainMigratePrepareTunnel3Params": "private function for tunnelled migration",
+  "virErrorCopyNew": "private",
 }
 
 ignored_macros = {
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 65168b1..1a03268 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1365,6 +1365,7 @@ ebtablesRemoveForwardAllowIn;
 
 # util/virerror.h
 virDispatchError;
+virErrorCopyNew;
 virErrorInitialize;
 virErrorSetErrnoFromLastError;
 virLastErrorIsSystemErrno;
diff --git a/src/util/virerror.c b/src/util/virerror.c
index fae627b..60b2e79 100644
--- a/src/util/virerror.c
+++ b/src/util/virerror.c
@@ -214,6 +214,22 @@ virCopyError(virErrorPtr from,
     return ret;
 }
 
+
+virErrorPtr
+virErrorCopyNew(virErrorPtr err)
+{
+    virErrorPtr ret;
+
+    if (VIR_ALLOC_QUIET(ret) < 0)
+        return NULL;
+
+    if (virCopyError(err, ret) < 0)
+        VIR_FREE(ret);
+
+    return ret;
+}
+
+
 static virErrorPtr
 virLastErrorObject(void)
 {
diff --git a/src/util/virerror.h b/src/util/virerror.h
index baa2d08..2348648 100644
--- a/src/util/virerror.h
+++ b/src/util/virerror.h
@@ -185,6 +185,7 @@ void virReportOOMErrorFull(int domcode,
     virRaiseErrorObject(__FILE__, __FUNCTION__, __LINE__, obj)
 
 int virSetError(virErrorPtr newerr);
+virErrorPtr virErrorCopyNew(virErrorPtr err);
 void virDispatchError(virConnectPtr conn);
 const char *virStrerror(int theerrno, char *errBuf, size_t errBufLen);
 
-- 
2.4.5