qga: Improve error report by calling error_setg_win32()

Use error_setg_win32() which adds a hint similar to strerror(errno)).

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20200228100726.8414-4-philmd@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
Philippe Mathieu-Daudé 2020-02-28 11:07:25 +01:00 committed by Markus Armbruster
parent cf0c76cd6d
commit 672db77892
2 changed files with 7 additions and 4 deletions

View File

@ -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;
}

View File

@ -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);