Re: [libvirt] [PATCH 2/5] virterror: Add virSetError

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

 



On Mon, Jan 11, 2010 at 03:34:45PM -0500, Cole Robinson wrote:
> 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
> 
> Signed-off-by: Cole Robinson <crobinso@xxxxxxxxxx>
> ---
>  src/libvirt_private.syms      |    1 +
>  src/util/virterror.c          |   22 ++++++++++++++++++++++
>  src/util/virterror_internal.h |    1 +
>  3 files changed, 24 insertions(+), 0 deletions(-)
> 
> diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
> index 10940eb..a894775 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 bee1242..e2128b9 100644
> --- a/src/util/virterror.c
> +++ b/src/util/virterror.c
> @@ -290,6 +290,28 @@ virGetLastError(void)
>  }
>  
>  /**
> + * 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 c246140..c713497 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);
>  
> -- 

ACK

Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]