提交 29424d1a 编写于 作者: E Eric Blake

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.
上级 34f1a618
/*
* 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
*
* This library is free software; you can redistribute it and/or
......@@ -985,10 +985,8 @@ qemuAgentCommand(qemuAgentPtr mon,
memset(&msg, 0, sizeof(msg));
if (!(cmdstr = virJSONValueToString(cmd, false))) {
virReportOOMError();
if (!(cmdstr = virJSONValueToString(cmd, false)))
goto cleanup;
}
if (virAsprintf(&msg.txBuffer, "%s" LINE_ENDING, cmdstr) < 0) {
virReportOOMError();
goto cleanup;
......@@ -1104,7 +1102,7 @@ qemuAgentCheckError(virJSONValuePtr cmd,
/* Log the full JSON formatted command & error */
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 */
if (!error)
......@@ -1125,7 +1123,7 @@ qemuAgentCheckError(virJSONValuePtr cmd,
char *replystr = virJSONValueToString(reply, false);
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,
_("unable to execute QEMU agent command '%s'"),
qemuAgentCommandName(cmd));
......@@ -1420,7 +1418,8 @@ qemuAgentArbitraryCommand(qemuAgentPtr mon,
if (ret == 0) {
ret = qemuAgentCheckError(cmd, reply);
*result = virJSONValueToString(reply, false);
if (!(*result = virJSONValueToString(reply, false)))
ret = -1;
}
virJSONValueFree(cmd);
......
......@@ -249,10 +249,8 @@ qemuMonitorJSONCommandWithFd(qemuMonitorPtr mon,
}
}
if (!(cmdstr = virJSONValueToString(cmd, false))) {
virReportOOMError();
if (!(cmdstr = virJSONValueToString(cmd, false)))
goto cleanup;
}
if (virAsprintf(&msg.txBuffer, "%s\r\n", cmdstr) < 0) {
virReportOOMError();
goto cleanup;
......@@ -339,7 +337,7 @@ qemuMonitorJSONCheckError(virJSONValuePtr cmd,
/* Log the full JSON formatted command & error */
VIR_DEBUG("unable to execute QEMU command %s: %s",
cmdstr, replystr);
NULLSTR(cmdstr), NULLSTR(replystr));
/* Only send the user the command name + friendly error */
if (!error)
......@@ -360,7 +358,7 @@ qemuMonitorJSONCheckError(virJSONValuePtr cmd,
char *replystr = virJSONValueToString(reply, false);
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,
_("unable to execute QEMU command '%s'"),
qemuMonitorJSONCommandName(cmd));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册