From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: philmd@linaro.org, kkostiuk@redhat.com, michael.roth@amd.com
Subject: [PATCH 1/3] qga-win32: Improve guest-set-user-password, guest-file-open errors
Date: Tue, 14 May 2024 12:58:26 +0200 [thread overview]
Message-ID: <20240514105829.729342-2-armbru@redhat.com> (raw)
In-Reply-To: <20240514105829.729342-1-armbru@redhat.com>
When guest-set-user-password's argument @password can't be converted
from UTF-8 to UTF-16, we report something like
Guest agent command failed, error was 'Invalid sequence in conversion input'
Improve this to
can't convert 'password' to UTF-16: Invalid sequence in conversion input
Likewise for argument @username, and guest-file-open argument @path,
even though I'm not sure you can actually get invalid input past the
QMP core there.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
qga/commands-win32.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/qga/commands-win32.c b/qga/commands-win32.c
index 6fee0e1e6f..ed31077457 100644
--- a/qga/commands-win32.c
+++ b/qga/commands-win32.c
@@ -217,6 +217,9 @@ int64_t qmp_guest_file_open(const char *path, const char *mode, Error **errp)
w_path = g_utf8_to_utf16(path, -1, NULL, NULL, &gerr);
if (!w_path) {
+ error_setg(errp, "can't convert 'path' to UTF-16: %s",
+ gerr->message);
+ g_error_free(gerr);
goto done;
}
@@ -244,10 +247,6 @@ int64_t qmp_guest_file_open(const char *path, const char *mode, Error **errp)
slog("guest-file-open, handle: % " PRId64, fd);
done:
- if (gerr) {
- error_setg(errp, QERR_QGA_COMMAND_FAILED, gerr->message);
- g_error_free(gerr);
- }
g_free(w_path);
return fd;
}
@@ -1946,11 +1945,17 @@ void qmp_guest_set_user_password(const char *username,
user = g_utf8_to_utf16(username, -1, NULL, NULL, &gerr);
if (!user) {
+ error_setg(errp, "can't convert 'username' to UTF-16: %s",
+ gerr->message);
+ g_error_free(gerr);
goto done;
}
wpass = g_utf8_to_utf16(rawpasswddata, -1, NULL, NULL, &gerr);
if (!wpass) {
+ error_setg(errp, "can't convert 'password' to UTF-16: %s",
+ gerr->message);
+ g_error_free(gerr);
goto done;
}
@@ -1966,10 +1971,6 @@ void qmp_guest_set_user_password(const char *username,
}
done:
- if (gerr) {
- error_setg(errp, QERR_QGA_COMMAND_FAILED, gerr->message);
- g_error_free(gerr);
- }
g_free(user);
g_free(wpass);
g_free(rawpasswddata);
--
2.45.0
next prev parent reply other threads:[~2024-05-14 11:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-14 10:58 [PATCH 0/3] error: Eliminate QERR_QGA_COMMAND_FAILED Markus Armbruster
2024-05-14 10:58 ` Markus Armbruster [this message]
2024-05-14 13:16 ` [PATCH 1/3] qga-win32: Improve guest-set-user-password, guest-file-open errors Philippe Mathieu-Daudé
2024-05-14 17:38 ` Konstantin Kostiuk
2024-05-14 10:58 ` [PATCH 2/3] qga: Shorten several error messages Markus Armbruster
2024-05-14 11:02 ` Markus Armbruster
2024-05-14 13:17 ` Philippe Mathieu-Daudé
2024-05-14 17:39 ` Konstantin Kostiuk
2024-05-14 10:58 ` [PATCH 3/3] qerror: QERR_QGA_COMMAND_FAILED is no longer used, drop Markus Armbruster
2024-05-14 13:17 ` Philippe Mathieu-Daudé
2024-05-14 17:39 ` Konstantin Kostiuk
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=20240514105829.729342-2-armbru@redhat.com \
--to=armbru@redhat.com \
--cc=kkostiuk@redhat.com \
--cc=michael.roth@amd.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
/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).