Skip to contentSkip to conversation

Error reporting patches for 2020-03-09

GIT PULL Applied Markus Armbruster 2 participants 6 messages Mar 9, 2020

lore
Share & tools
lore
#0 lore raw

The following changes since commit 67f17e23baca5dd545fe98b01169cc351a70fe35:

Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2020-03-06 17:15:36 +0000)

are available in the Git repository at:

git://repo.or.cz/qemu/armbru.git tags/pull-error-2020-03-09

for you to fetch changes up to d1eddab86f92e7e060c8a473695c7f24ec00c9ab:

qga: Fix a memory leak (2020-03-09 13:36:15 +0100)

----------------------------------------------------------------
Error reporting patches for 2020-03-09

* Improve error reporting on Windows

----------------------------------------------------------------
Philippe Mathieu-Daudé (4):
chardev: Improve error report by calling error_setg_win32() util/osdep: Improve error report by calling error_setg_win32()
qga: Improve error report by calling error_setg_win32()
qga: Fix a memory leak

 chardev/char-pipe.c  | 2 +-
 chardev/char-win.c   | 2 +-
 qga/channel-win32.c  | 7 ++++---
 qga/commands-win32.c | 8 +++++---
 util/osdep.c         | 4 ++--
 5 files changed, 13 insertions(+), 10 deletions(-)
Signature · 1 line
2.21.1
#1 lore raw

[PULL 4/4] qga: Fix a memory leak

From: Philippe Mathieu-Daudé <[email protected]>

The string returned by g_win32_error_message() has to be deallocated with g_free().

Message-Id: <[email protected]>

---
 qga/channel-win32.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
qga/channel-win32.c +2 -2
index 99648c95b6..4f04868a76 100644
@@ -302,8 +302,8 @@ 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;
     }
 
Signature · 1 line
2.21.1
#2 lore raw

[PULL 3/4] qga: Improve error report by calling error_setg_win32()

In reply to Markus Armbruster

From: Philippe Mathieu-Daudé <[email protected]>

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

Message-Id: <[email protected]>

---
 qga/channel-win32.c  | 3 ++-
 qga/commands-win32.c | 8 +++++---
 2 files changed, 7 insertions(+), 4 deletions(-)
qga/channel-win32.c +2 -1
index c86f4388db..99648c95b6 100644
@@ -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;
     }
qga/commands-win32.c +5 -3
index 2461fd19bf..9c744d6405 100644
@@ -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);
Signature · 1 line
2.21.1
#3 lore raw

[PULL 2/4] util/osdep: Improve error report by calling error_setg_win32()

In reply to Markus Armbruster

From: Philippe Mathieu-Daudé <[email protected]>

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

Message-Id: <[email protected]>

---
 util/osdep.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
util/osdep.c +2 -2
index f7d06050f7..4829c07ff6 100644
@@ -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;
Signature · 1 line
2.21.1
#4 lore raw

[PULL 1/4] chardev: Improve error report by calling error_setg_win32()

In reply to Markus Armbruster

From: Philippe Mathieu-Daudé <[email protected]>

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

Message-Id: <[email protected]>

---
 chardev/char-pipe.c | 2 +-
 chardev/char-win.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
chardev/char-pipe.c +1 -1
index 94d714ffcd..fd12c9e63b 100644
@@ -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;
     }
chardev/char-win.c +1 -1
index 34825f683d..d4fb44c4dc 100644
@@ -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;
     }
Signature · 1 line
2.21.1
#5 lore raw
In reply to Markus Armbruster
Quoted 16 lines · Markus Armbruster

The following changes since commit 67f17e23baca5dd545fe98b01169cc351a70fe35:

Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2020-03-06 17:15:36 +0000)

are available in the Git repository at:

git://repo.or.cz/qemu/armbru.git tags/pull-error-2020-03-09

for you to fetch changes up to d1eddab86f92e7e060c8a473695c7f24ec00c9ab:

qga: Fix a memory leak (2020-03-09 13:36:15 +0100)

----------------------------------------------------------------
Error reporting patches for 2020-03-09

Quoted 9 lines

* Improve error reporting on Windows

----------------------------------------------------------------
Philippe Mathieu-Daudé (4):
chardev: Improve error report by calling error_setg_win32() util/osdep: Improve error report by calling error_setg_win32()
qga: Improve error report by calling error_setg_win32()
qga: Fix a memory leak

Applied, thanks.

Please update the changelog at https://wiki.qemu.org/ChangeLog/5.0
for any user-visible changes.

-- PMM