From: Kostiantyn Kostiuk <kkostiuk@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org, "Yan Vugenfirer" <yvugenfi@redhat.com>,
"Daniel Berrangé" <berrange@redhat.com>
Subject: Re: [PATCH] util: win32: Write hex value when can't get error message
Date: Mon, 21 Jul 2025 10:07:27 +0300 [thread overview]
Message-ID: <CAPMcbCp=PBMSxtTxCMkxigdovaY=MTNLRo6f3BBXNRT6vu4wmw@mail.gmail.com> (raw)
In-Reply-To: <87pldwbspt.fsf@pond.sub.org>
[-- Attachment #1: Type: text/plain, Size: 2592 bytes --]
On Sat, Jul 19, 2025 at 9:27 AM Markus Armbruster <armbru@redhat.com> wrote:
> Kostiantyn Kostiuk <kkostiuk@redhat.com> writes:
>
> > 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.
>
> Are these error codes from GetLastError()?
>
No.
VSS functions directly return an error code.
Section: Return value -
https://learn.microsoft.com/en-us/windows/win32/api/vsbackup/nf-vsbackup-ivssbackupcomponents-addtosnapshotset
Performance Counters API can return a system error code or a PDH error code.
Section: Return value -
https://learn.microsoft.com/en-us/windows/win32/api/pdh/nf-pdh-pdhopenqueryw
System error code = GetLastError, PDH error code, something else.
https://learn.microsoft.com/en-us/windows/win32/perfctrs/pdh-error-codes
FormatMessage requires LoadLibrary(L"pdh.dll") to work properly.
> > 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"}}
>
> Exact reproducer?
>
Yes, for example, with VSS.
Execute: {"execute": "guest-fsfreeze-freeze-list", "arguments":
{"mountpoints": ["C:"]}}
After this commit, you will get {"error": {"class": "GenericError", "desc":
"failed to add C: to snapshot set: unknown Windows error 0x80042308"}}
>
> > 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);
>
>
[-- Attachment #2: Type: text/html, Size: 4524 bytes --]
next prev parent reply other threads:[~2025-07-21 7:08 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAPMcbCp=PBMSxtTxCMkxigdovaY=MTNLRo6f3BBXNRT6vu4wmw@mail.gmail.com' \
--to=kkostiuk@redhat.com \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=yvugenfi@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).