qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v3 3/4] qga: Improve error report by calling error_setg_win32


From: Marc-André Lureau
Subject: Re: [PATCH v3 3/4] qga: Improve error report by calling error_setg_win32()
Date: Fri, 28 Feb 2020 11:23:57 +0100

On Fri, Feb 28, 2020 at 11:07 AM Philippe Mathieu-Daudé
<address@hidden> wrote:
>
> Use error_setg_win32() which adds a hint similar to strerror(errno)).
>
> Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
> ---
> v3: Keep slog() in qmp_guest_shutdown() (Marc-André)
> ---
>  qga/channel-win32.c  | 3 ++-
>  qga/commands-win32.c | 8 +++++---
>  2 files changed, 7 insertions(+), 4 deletions(-)

Reviewed-by: Marc-André Lureau <address@hidden>


>
> diff --git a/qga/channel-win32.c b/qga/channel-win32.c
> index c86f4388db..99648c95b6 100644
> --- a/qga/channel-win32.c
> +++ b/qga/channel-win32.c
> @@ -308,7 +308,8 @@ static gboolean ga_channel_open(GAChannel *c, 
> GAChannelMethod method,
>      }
>
>      if (method == GA_CHANNEL_ISA_SERIAL && 
> !SetCommTimeouts(c->handle,&comTimeOut)) {
> -        g_critical("error setting timeout for com port: %lu",GetLastError());
> +        g_autofree gchar *emsg = g_win32_error_message(GetLastError());
> +        g_critical("error setting timeout for com port: %s", emsg);
>          CloseHandle(c->handle);
>          return false;
>      }
> diff --git a/qga/commands-win32.c b/qga/commands-win32.c
> index 2461fd19bf..9c744d6405 100644
> --- a/qga/commands-win32.c
> +++ b/qga/commands-win32.c
> @@ -315,8 +315,9 @@ void qmp_guest_shutdown(bool has_mode, const char *mode, 
> Error **errp)
>      }
>
>      if (!ExitWindowsEx(shutdown_flag, SHTDN_REASON_FLAG_PLANNED)) {
> -        slog("guest-shutdown failed: %lu", GetLastError());
> -        error_setg(errp, QERR_UNDEFINED_ERROR);
> +        g_autofree gchar *emsg = g_win32_error_message(GetLastError());
> +        slog("guest-shutdown failed: %s", emsg);
> +        error_setg_win32(errp, GetLastError(), "guest-shutdown failed");
>      }
>  }
>
> @@ -1319,7 +1320,8 @@ static DWORD WINAPI do_suspend(LPVOID opaque)
>      DWORD ret = 0;
>
>      if (!SetSuspendState(*mode == GUEST_SUSPEND_MODE_DISK, TRUE, TRUE)) {
> -        slog("failed to suspend guest, %lu", GetLastError());
> +        g_autofree gchar *emsg = g_win32_error_message(GetLastError());
> +        slog("failed to suspend guest: %s", emsg);
>          ret = -1;
>      }
>      g_free(mode);
> --
> 2.21.1
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]