diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2018-07-24 12:40:11 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2018-07-24 12:40:11 +0100 |
commit | aabbca41053e85ffbebcac279c4b85cb2696c55d (patch) | |
tree | e9281fd561d359f7bacad17e004763c736210afe | |
parent | 1a5182c0d2eaa8dc8e7dbd914fba8d07d5595fe0 (diff) | |
parent | ae7da1e5f658ea21d96e565514de20ff2cf24fa1 (diff) | |
download | qemu-aabbca41053e85ffbebcac279c4b85cb2696c55d.zip qemu-aabbca41053e85ffbebcac279c4b85cb2696c55d.tar.gz qemu-aabbca41053e85ffbebcac279c4b85cb2696c55d.tar.bz2 |
Merge remote-tracking branch 'remotes/mdroth/tags/qga-pull-2018-07-23-tag' into staging
qemu-ga patch queue for hard-freeze
* fix leak in qga main loop error path
* better error reporting when Windows version doesn't support fstrim
# gpg: Signature made Tue 24 Jul 2018 00:58:29 BST
# gpg: using RSA key 3353C9CEF108B584
# gpg: Good signature from "Michael Roth <flukshun@gmail.com>"
# gpg: aka "Michael Roth <mdroth@utexas.edu>"
# gpg: aka "Michael Roth <mdroth@linux.vnet.ibm.com>"
# Primary key fingerprint: CEAC C9E1 5534 EBAB B82D 3FA0 3353 C9CE F108 B584
* remotes/mdroth/tags/qga-pull-2018-07-23-tag:
qga: process_event() simplification and leak fix
qga-win: Handle fstrim for OSes lower than Win8
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r-- | qga/commands-win32.c | 13 | ||||
-rw-r--r-- | qga/main.c | 54 |
2 files changed, 40 insertions, 27 deletions
diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 318d760..98d9735 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -865,6 +865,19 @@ qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **errp) GuestFilesystemTrimResponse *resp; HANDLE handle; WCHAR guid[MAX_PATH] = L""; + OSVERSIONINFO osvi; + BOOL win8_or_later; + + ZeroMemory(&osvi, sizeof(OSVERSIONINFO)); + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); + GetVersionEx(&osvi); + win8_or_later = (osvi.dwMajorVersion > 6 || + ((osvi.dwMajorVersion == 6) && + (osvi.dwMinorVersion >= 2))); + if (!win8_or_later) { + error_setg(errp, "fstrim is only supported for Win8+"); + return NULL; + } handle = FindFirstVolumeW(guid, ARRAYSIZE(guid)); if (handle == INVALID_HANDLE_VALUE) { @@ -600,42 +600,42 @@ static void process_command(GAState *s, QDict *req) static void process_event(JSONMessageParser *parser, GQueue *tokens) { GAState *s = container_of(parser, GAState, parser); - QDict *qdict; + QObject *obj; + QDict *req, *rsp; Error *err = NULL; int ret; g_assert(s && parser); g_debug("process_event: called"); - qdict = qobject_to(QDict, json_parser_parse_err(tokens, NULL, &err)); - if (err || !qdict) { - qobject_unref(qdict); - if (!err) { - g_warning("failed to parse event: unknown error"); - error_setg(&err, QERR_JSON_PARSING); - } else { - g_warning("failed to parse event: %s", error_get_pretty(err)); - } - qdict = qmp_error_response(err); + obj = json_parser_parse_err(tokens, NULL, &err); + if (err) { + goto err; } - - /* handle host->guest commands */ - if (qdict_haskey(qdict, "execute")) { - process_command(s, qdict); - } else { - if (!qdict_haskey(qdict, "error")) { - qobject_unref(qdict); - g_warning("unrecognized payload format"); - error_setg(&err, QERR_UNSUPPORTED); - qdict = qmp_error_response(err); - } - ret = send_response(s, qdict); - if (ret < 0) { - g_warning("error sending error response: %s", strerror(-ret)); - } + req = qobject_to(QDict, obj); + if (!req) { + error_setg(&err, QERR_JSON_PARSING); + goto err; + } + if (!qdict_haskey(req, "execute")) { + g_warning("unrecognized payload format"); + error_setg(&err, QERR_UNSUPPORTED); + goto err; } - qobject_unref(qdict); + process_command(s, req); + qobject_unref(obj); + return; + +err: + g_warning("failed to parse event: %s", error_get_pretty(err)); + rsp = qmp_error_response(err); + ret = send_response(s, rsp); + if (ret < 0) { + g_warning("error sending error response: %s", strerror(-ret)); + } + qobject_unref(rsp); + qobject_unref(obj); } /* false return signals GAChannel to close the current client connection */ |