qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] util: win32: Write hex value when can't get error message
@ 2025-07-17 14:59 Kostiantyn Kostiuk
  2025-07-17 15:28 ` Yan Vugenfirer
  2025-07-19  6:27 ` Markus Armbruster
  0 siblings, 2 replies; 12+ messages in thread
From: Kostiantyn Kostiuk @ 2025-07-17 14:59 UTC (permalink / raw)
  To: qemu-devel
  Cc: Markus Armbruster, Yan Vugenfirer, Daniel Berrangé,
	Kostiantyn Kostiuk

g_win32_error_message - translate a Win32 error code
(as returned by GetLastError()) into the corresponding message.

In the same time, we call error_setg_win32_internal with
error codes from different Windows componets like VSS or
Performance monitor that provides different codes and
can't be converted with g_win32_error_message. In this
case, the empty suffix will be returned so error will be
masked.

QGA error example:
 - before changes:
  {"error": {"class": "GenericError", "desc": "failed to add D:\\ to snapshot set: "}}
 - after changes:
  {"error": {"class": "GenericError", "desc": "failed to add D:\\ to snapshot set: unknown Windows error 0x8004230e"}}

Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
---
 util/error.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/util/error.c b/util/error.c
index daea2142f3..b1342558ae 100644
--- a/util/error.c
+++ b/util/error.c
@@ -188,6 +188,11 @@ void error_setg_win32_internal(Error **errp,
 
     if (win32_err != 0) {
         suffix = g_win32_error_message(win32_err);
+        // g_win32_error_message() failed
+        if (!suffix[0]) {
+            g_free(suffix);
+            suffix = g_strdup_printf("unknown Windows error 0x%x", win32_err);
+        }
     }
 
     va_start(ap, fmt);
-- 
2.48.1



^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2025-07-28 11:55 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-17 14:59 [PATCH] util: win32: Write hex value when can't get error message Kostiantyn Kostiuk
2025-07-17 15:28 ` Yan Vugenfirer
2025-07-19  6:27 ` Markus Armbruster
2025-07-21  7:07   ` Kostiantyn Kostiuk
2025-07-21  9:22     ` Markus Armbruster
2025-07-21 10:12       ` Kostiantyn Kostiuk
2025-07-21 11:23         ` Yan Vugenfirer
2025-07-21 11:53         ` Philippe Mathieu-Daudé
2025-07-25  9:59           ` Kostiantyn Kostiuk
2025-07-28  9:47             ` Philippe Mathieu-Daudé
2025-07-28  9:58               ` Kostiantyn Kostiuk
2025-07-28 11:12             ` Markus Armbruster

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).