qga/commands-win32: Use error_setg_win32() for better error messages

We include numeric GetLastError() codes in error messages in a few
places, like this:

    error_setg(errp, "GRIPE: %d", (int)GetLastError());

Show text instead, like this:

    error_setg_win32(errp, GetLastError(), "GRIPE");

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-ID: <20251121121438.1249498-15-armbru@redhat.com>
Reviewed-by: Kostiantyn Kostiuk <kkostiuk@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
This commit is contained in:
Markus Armbruster
2025-11-21 13:14:37 +01:00
parent 0223e79287
commit 3ec3397098

View File

@ -1798,8 +1798,8 @@ void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp)
tf.dwHighDateTime = (DWORD) (time >> 32); tf.dwHighDateTime = (DWORD) (time >> 32);
if (!FileTimeToSystemTime(&tf, &ts)) { if (!FileTimeToSystemTime(&tf, &ts)) {
error_setg(errp, "Failed to convert system time %d", error_setg_win32(errp, GetLastError(),
(int)GetLastError()); "Failed to convert system time");
return; return;
} }
@ -1810,7 +1810,8 @@ void qmp_guest_set_time(bool has_time, int64_t time_ns, Error **errp)
} }
if (!SetSystemTime(&ts)) { if (!SetSystemTime(&ts)) {
error_setg(errp, "Failed to set time to guest: %d", (int)GetLastError()); error_setg_win32(errp, GetLastError(),
"Failed to set time to guest");
return; return;
} }
} }
@ -1834,13 +1835,12 @@ GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp)
(length > sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION))) { (length > sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION))) {
ptr = pslpi = g_malloc0(length); ptr = pslpi = g_malloc0(length);
if (GetLogicalProcessorInformation(pslpi, &length) == FALSE) { if (GetLogicalProcessorInformation(pslpi, &length) == FALSE) {
error_setg(&local_err, "Failed to get processor information: %d", error_setg_win32(&local_err, GetLastError(),
(int)GetLastError()); "Failed to get processor information");
} }
} else { } else {
error_setg(&local_err, error_setg_win32(&local_err, GetLastError(),
"Failed to get processor information buffer length: %d", "Failed to get processor information buffer length");
(int)GetLastError());
} }
while ((local_err == NULL) && (length > 0)) { while ((local_err == NULL) && (length > 0)) {