A helper function for copying error objects. Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx> --- Notes: Version 2: - new patch docs/apibuild.py | 1 + src/libvirt_private.syms | 1 + src/util/virerror.c | 19 +++++++++++++++++++ src/util/virerror.h | 1 + 4 files changed, 22 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..3ec12a3 100644 --- a/src/util/virerror.c +++ b/src/util/virerror.c @@ -214,6 +214,25 @@ virCopyError(virErrorPtr from, return ret; } + +virErrorPtr +virErrorCopyNew(virErrorPtr err) +{ + virErrorPtr ret; + + if (!err) + return NULL; + + 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 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list