mirror of https://github.com/xemu-project/xemu.git
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 -----BEGIN PGP SIGNATURE----- iQFOBAABCgA4FiEEzqzJ4VU066u4LT+gM1PJzvEItYQFAltWa6UaHG1kcm90aEBs aW51eC52bmV0LmlibS5jb20ACgkQM1PJzvEItYSNFgf8DfDrGDuWGITKFBBacLwx OwEF7O2hyYfBKXDe7aYrWDEMiETtqzOTcKigwbNt52uEKBMA0teRXwUrO1g7b7/X wGhmgFwBHri8VX3TK6ObWGtLWFkXDZ5QJTnCM4Ml2MjYDz2nwiAlmaIxxo7logf5 ITZ+NCqyG6jazyFdYXVOuimk5KI+e8yZm0vEDuARKluCaKrAd9Zc0IkDWeqwxkPH bAcqPBsg7ZFF6cHyNC/HAlkQe/Sj6vAyOddAHDM5AI/Gmc09h8NCioKzBhWDJFU5 yg6sTqAONV3huZi/SqvfVBppr4+ZoWOMw/83eVF6efpS5/+9L0XRWYVP7Sgq8deG TQ== =e+ml -----END PGP SIGNATURE----- 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>
This commit is contained in:
commit
aabbca4105
|
@ -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) {
|
||||
|
|
54
qga/main.c
54
qga/main.c
|
@ -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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
/* 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));
|
||||
}
|
||||
}
|
||||
process_command(s, req);
|
||||
qobject_unref(obj);
|
||||
return;
|
||||
|
||||
qobject_unref(qdict);
|
||||
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 */
|
||||
|
|
Loading…
Reference in New Issue