summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2020-03-09 13:51:14 +0000
committerPeter Maydell <peter.maydell@linaro.org>2020-03-09 13:51:14 +0000
commitdee65a00d1e6c255c9c888e47a692803d60dc6ca (patch)
tree8e425557553125d5417687742fedb455fde23c5a
parent7a5853cec479a448edae0fb2aaf4e2f78c9c774d (diff)
parentd1eddab86f92e7e060c8a473695c7f24ec00c9ab (diff)
downloadqemu-dee65a00d1e6c255c9c888e47a692803d60dc6ca.zip
Merge remote-tracking branch 'remotes/armbru/tags/pull-error-2020-03-09' into staging
Error reporting patches for 2020-03-09 # gpg: Signature made Mon 09 Mar 2020 12:37:04 GMT # gpg: using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653 # gpg: issuer "armbru@redhat.com" # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full] # gpg: aka "Markus Armbruster <armbru@pond.sub.org>" [full] # Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653 * remotes/armbru/tags/pull-error-2020-03-09: qga: Fix a memory leak qga: Improve error report by calling error_setg_win32() util/osdep: Improve error report by calling error_setg_win32() chardev: Improve error report by calling error_setg_win32() Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--chardev/char-pipe.c2
-rw-r--r--chardev/char-win.c2
-rw-r--r--qga/channel-win32.c7
-rw-r--r--qga/commands-win32.c8
-rw-r--r--util/osdep.c4
5 files changed, 13 insertions, 10 deletions
diff --git a/chardev/char-pipe.c b/chardev/char-pipe.c
index 94d714ffcd..fd12c9e63b 100644
--- a/chardev/char-pipe.c
+++ b/chardev/char-pipe.c
@@ -70,7 +70,7 @@ static int win_chr_pipe_init(Chardev *chr, const char *filename,
MAXCONNECT, NSENDBUF, NRECVBUF, NTIMEOUT, NULL);
g_free(openname);
if (s->file == INVALID_HANDLE_VALUE) {
- error_setg(errp, "Failed CreateNamedPipe (%lu)", GetLastError());
+ error_setg_win32(errp, GetLastError(), "Failed CreateNamedPipe");
s->file = NULL;
goto fail;
}
diff --git a/chardev/char-win.c b/chardev/char-win.c
index 34825f683d..d4fb44c4dc 100644
--- a/chardev/char-win.c
+++ b/chardev/char-win.c
@@ -96,7 +96,7 @@ int win_chr_serial_init(Chardev *chr, const char *filename, Error **errp)
s->file = CreateFile(filename, GENERIC_READ | GENERIC_WRITE, 0, NULL,
OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0);
if (s->file == INVALID_HANDLE_VALUE) {
- error_setg(errp, "Failed CreateFile (%lu)", GetLastError());
+ error_setg_win32(errp, GetLastError(), "Failed CreateFile");
s->file = NULL;
goto fail;
}
diff --git a/qga/channel-win32.c b/qga/channel-win32.c
index c86f4388db..4f04868a76 100644
--- a/qga/channel-win32.c
+++ b/qga/channel-win32.c
@@ -302,13 +302,14 @@ static gboolean ga_channel_open(GAChannel *c, GAChannelMethod method,
OPEN_EXISTING,
FILE_FLAG_NO_BUFFERING | FILE_FLAG_OVERLAPPED, NULL);
if (c->handle == INVALID_HANDLE_VALUE) {
- g_critical("error opening path %s: %s", newpath,
- g_win32_error_message(GetLastError()));
+ g_autofree gchar *emsg = g_win32_error_message(GetLastError());
+ g_critical("error opening path %s: %s", newpath, emsg);
return false;
}
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);
diff --git a/util/osdep.c b/util/osdep.c
index f7d06050f7..4829c07ff6 100644
--- a/util/osdep.c
+++ b/util/osdep.c
@@ -82,8 +82,8 @@ static int qemu_mprotect__osdep(void *addr, size_t size, int prot)
DWORD old_protect;
if (!VirtualProtect(addr, size, prot, &old_protect)) {
- error_report("%s: VirtualProtect failed with error code %ld",
- __func__, GetLastError());
+ g_autofree gchar *emsg = g_win32_error_message(GetLastError());
+ error_report("%s: VirtualProtect failed: %s", __func__, emsg);
return -1;
}
return 0;