mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 14:15:28 +00:00
qemu: don't override earlier json error
I built without yajl support, and noticed a strange failure message in qemumonitorjsontest: 2013-02-22 16:12:37.503+0000: 19812: error : virJSONValueToString:1119 : internal error No JSON parser implementation is available 2013-02-22 16:12:37.503+0000: 19812: error : qemuMonitorJSONCommandWithFd:253 : out of memory While a later patch will fix the test to skip when json is not present, this patch avoids overriding the more useful error message from virJSONValueToString returning NULL. * src/qemu/qemu_monitor_json.c (qemuMonitorJSONCommandWithFd): Don't override message. (qemuMonitorJSONCheckError): Don't print NULL. * src/qemu/qemu_agent.c (qemuAgentCommand): Don't override message. (qemuAgentCheckError): Don't print NULL. (qemuAgentArbitraryCommand): Properly fail on OOM.
This commit is contained in:
parent
34f1a618a5
commit
29424d1acd
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* qemu_agent.h: interaction with QEMU guest agent
|
* qemu_agent.h: interaction with QEMU guest agent
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2012 Red Hat, Inc.
|
* Copyright (C) 2006-2013 Red Hat, Inc.
|
||||||
* Copyright (C) 2006 Daniel P. Berrange
|
* Copyright (C) 2006 Daniel P. Berrange
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
@ -985,10 +985,8 @@ qemuAgentCommand(qemuAgentPtr mon,
|
|||||||
|
|
||||||
memset(&msg, 0, sizeof(msg));
|
memset(&msg, 0, sizeof(msg));
|
||||||
|
|
||||||
if (!(cmdstr = virJSONValueToString(cmd, false))) {
|
if (!(cmdstr = virJSONValueToString(cmd, false)))
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
if (virAsprintf(&msg.txBuffer, "%s" LINE_ENDING, cmdstr) < 0) {
|
if (virAsprintf(&msg.txBuffer, "%s" LINE_ENDING, cmdstr) < 0) {
|
||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1104,7 +1102,7 @@ qemuAgentCheckError(virJSONValuePtr cmd,
|
|||||||
|
|
||||||
/* Log the full JSON formatted command & error */
|
/* Log the full JSON formatted command & error */
|
||||||
VIR_DEBUG("unable to execute QEMU agent command %s: %s",
|
VIR_DEBUG("unable to execute QEMU agent command %s: %s",
|
||||||
cmdstr, replystr);
|
NULLSTR(cmdstr), NULLSTR(replystr));
|
||||||
|
|
||||||
/* Only send the user the command name + friendly error */
|
/* Only send the user the command name + friendly error */
|
||||||
if (!error)
|
if (!error)
|
||||||
@ -1125,7 +1123,7 @@ qemuAgentCheckError(virJSONValuePtr cmd,
|
|||||||
char *replystr = virJSONValueToString(reply, false);
|
char *replystr = virJSONValueToString(reply, false);
|
||||||
|
|
||||||
VIR_DEBUG("Neither 'return' nor 'error' is set in the JSON reply %s: %s",
|
VIR_DEBUG("Neither 'return' nor 'error' is set in the JSON reply %s: %s",
|
||||||
cmdstr, replystr);
|
NULLSTR(cmdstr), NULLSTR(replystr));
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("unable to execute QEMU agent command '%s'"),
|
_("unable to execute QEMU agent command '%s'"),
|
||||||
qemuAgentCommandName(cmd));
|
qemuAgentCommandName(cmd));
|
||||||
@ -1420,7 +1418,8 @@ qemuAgentArbitraryCommand(qemuAgentPtr mon,
|
|||||||
|
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
ret = qemuAgentCheckError(cmd, reply);
|
ret = qemuAgentCheckError(cmd, reply);
|
||||||
*result = virJSONValueToString(reply, false);
|
if (!(*result = virJSONValueToString(reply, false)))
|
||||||
|
ret = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
virJSONValueFree(cmd);
|
virJSONValueFree(cmd);
|
||||||
|
@ -249,10 +249,8 @@ qemuMonitorJSONCommandWithFd(qemuMonitorPtr mon,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(cmdstr = virJSONValueToString(cmd, false))) {
|
if (!(cmdstr = virJSONValueToString(cmd, false)))
|
||||||
virReportOOMError();
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
|
||||||
if (virAsprintf(&msg.txBuffer, "%s\r\n", cmdstr) < 0) {
|
if (virAsprintf(&msg.txBuffer, "%s\r\n", cmdstr) < 0) {
|
||||||
virReportOOMError();
|
virReportOOMError();
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -339,7 +337,7 @@ qemuMonitorJSONCheckError(virJSONValuePtr cmd,
|
|||||||
|
|
||||||
/* Log the full JSON formatted command & error */
|
/* Log the full JSON formatted command & error */
|
||||||
VIR_DEBUG("unable to execute QEMU command %s: %s",
|
VIR_DEBUG("unable to execute QEMU command %s: %s",
|
||||||
cmdstr, replystr);
|
NULLSTR(cmdstr), NULLSTR(replystr));
|
||||||
|
|
||||||
/* Only send the user the command name + friendly error */
|
/* Only send the user the command name + friendly error */
|
||||||
if (!error)
|
if (!error)
|
||||||
@ -360,7 +358,7 @@ qemuMonitorJSONCheckError(virJSONValuePtr cmd,
|
|||||||
char *replystr = virJSONValueToString(reply, false);
|
char *replystr = virJSONValueToString(reply, false);
|
||||||
|
|
||||||
VIR_DEBUG("Neither 'return' nor 'error' is set in the JSON reply %s: %s",
|
VIR_DEBUG("Neither 'return' nor 'error' is set in the JSON reply %s: %s",
|
||||||
cmdstr, replystr);
|
NULLSTR(cmdstr), NULLSTR(replystr));
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("unable to execute QEMU command '%s'"),
|
_("unable to execute QEMU command '%s'"),
|
||||||
qemuMonitorJSONCommandName(cmd));
|
qemuMonitorJSONCommandName(cmd));
|
||||||
|
Loading…
Reference in New Issue
Block a user