Re: [libvirt] [PATCH] virsh: Show errors reported by nonAPI functions

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

 



On Wed, Feb 24, 2010 at 12:55:17PM -0500, Cole Robinson wrote:
> Only API calls trigger the error callback, which is required for
> proper virsh error reporting. Since we use non API functions from
> util/, make sure we properly report these errors.
> 
> Fixes lack of error message from 'virsh create idontexit.xml'
> 
> Signed-off-by: Cole Robinson <crobinso@xxxxxxxxxx>
> ---
>  tools/virsh.c |   12 ++++++++++--
>  1 files changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/virsh.c b/tools/virsh.c
> index 5fdbbe5..74e3fad 100644
> --- a/tools/virsh.c
> +++ b/tools/virsh.c
> @@ -352,8 +352,16 @@ virshErrorHandler(void *unused ATTRIBUTE_UNUSED, virErrorPtr error)
>  static void
>  virshReportError(vshControl *ctl)
>  {
> -    if (last_error == NULL)
> -        return;
> +    if (last_error == NULL) {
> +        /* Calling directly into libvirt util functions won't trigger the
> +         * error callback (which sets last_error), so check it ourselves.
> +         *
> +         * If the returned error has CODE_OK, this most likely means that
> +         * no error was ever raised, so just ignore */
> +        last_error = virSaveLastError();
> +        if (!last_error || last_error->code == VIR_ERR_OK)
> +            return NULL;
> +    }
>  
>      if (last_error->code == VIR_ERR_OK) {
>          vshError(ctl, "%s", _("unknown error"));

  Looks fine, ACK,

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel@xxxxxxxxxxxx  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

--
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]