[PATCH] qga-vss: Write hex value of error in log

Kostiantyn Kostiuk posted 1 patch 2 months, 3 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20250825135311.138330-1-kkostiuk@redhat.com
Maintainers: Kostiantyn Kostiuk <kkostiuk@redhat.com>, Michael Roth <michael.roth@amd.com>
qga/vss-win32/requester.cpp | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
[PATCH] qga-vss: Write hex value of error in log
Posted by Kostiantyn Kostiuk 2 months, 3 weeks ago
QGA-VSS writes error using error_setg_win32_internal,
which call g_win32_error_message.

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.

This commit directly add hex value of error code.

Reproduce:
 - Run QGA command: {"execute": "guest-fsfreeze-freeze-list", "arguments": {"mountpoints": ["D:"]}}

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: Windows error 0x8004230e: "}}

Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
---
 qga/vss-win32/requester.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/qga/vss-win32/requester.cpp b/qga/vss-win32/requester.cpp
index 4401d55e3a..644514fb95 100644
--- a/qga/vss-win32/requester.cpp
+++ b/qga/vss-win32/requester.cpp
@@ -28,8 +28,9 @@
 
 #define err_set(e, err, fmt, ...) {                                         \
     (e)->error_setg_win32_wrapper((e)->errp, __FILE__, __LINE__, __func__,  \
-                                   err, fmt, ## __VA_ARGS__);               \
-    qga_debug(fmt, ## __VA_ARGS__);                                         \
+                                   err, fmt ": Windows error 0x%lx",        \
+                                   ## __VA_ARGS__, err);                    \
+    qga_debug(fmt ": Windows error 0x%lx", ## __VA_ARGS__, err);            \
 }
 /* Bad idea, works only when (e)->errp != NULL: */
 #define err_is_set(e) ((e)->errp && *(e)->errp)
-- 
2.50.1
Re: [PATCH] qga-vss: Write hex value of error in log
Posted by Yan Vugenfirer 2 months, 2 weeks ago
On Mon, Aug 25, 2025 at 4:53 PM Kostiantyn Kostiuk <kkostiuk@redhat.com> wrote:
>
> QGA-VSS writes error using error_setg_win32_internal,
> which call g_win32_error_message.
>
> 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.
>
> This commit directly add hex value of error code.
>
> Reproduce:
>  - Run QGA command: {"execute": "guest-fsfreeze-freeze-list", "arguments": {"mountpoints": ["D:"]}}
>
> 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: Windows error 0x8004230e: "}}
>
> Signed-off-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
> ---
>  qga/vss-win32/requester.cpp | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/qga/vss-win32/requester.cpp b/qga/vss-win32/requester.cpp
> index 4401d55e3a..644514fb95 100644
> --- a/qga/vss-win32/requester.cpp
> +++ b/qga/vss-win32/requester.cpp
> @@ -28,8 +28,9 @@
>
>  #define err_set(e, err, fmt, ...) {                                         \
>      (e)->error_setg_win32_wrapper((e)->errp, __FILE__, __LINE__, __func__,  \
> -                                   err, fmt, ## __VA_ARGS__);               \
> -    qga_debug(fmt, ## __VA_ARGS__);                                         \
> +                                   err, fmt ": Windows error 0x%lx",        \
> +                                   ## __VA_ARGS__, err);                    \
> +    qga_debug(fmt ": Windows error 0x%lx", ## __VA_ARGS__, err);            \
>  }
>  /* Bad idea, works only when (e)->errp != NULL: */
>  #define err_is_set(e) ((e)->errp && *(e)->errp)
> --
> 2.50.1
>

Reviewed-by: Yan Vugenfirer <yvugenfi@redhat.com>