mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-23 03:42:19 +00:00
qemuAgentIOProcessLine: refactor cleanup
Refactor the control flow so we can remove the cleanup label. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
377c3dd3b1
commit
59891d32fb
@ -234,8 +234,7 @@ qemuAgentIOProcessLine(qemuAgent *agent,
|
|||||||
const char *line,
|
const char *line,
|
||||||
qemuAgentMessage *msg)
|
qemuAgentMessage *msg)
|
||||||
{
|
{
|
||||||
virJSONValue *obj = NULL;
|
g_autoptr(virJSONValue) obj = NULL;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
VIR_DEBUG("Line [%s]", line);
|
VIR_DEBUG("Line [%s]", line);
|
||||||
|
|
||||||
@ -247,19 +246,19 @@ qemuAgentIOProcessLine(qemuAgent *agent,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virJSONValueGetType(obj) != VIR_JSON_TYPE_OBJECT) {
|
if (virJSONValueGetType(obj) != VIR_JSON_TYPE_OBJECT) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Parsed JSON reply '%s' isn't an object"), line);
|
_("Parsed JSON reply '%s' isn't an object"), line);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virJSONValueObjectHasKey(obj, "QMP") == 1) {
|
if (virJSONValueObjectHasKey(obj, "QMP") == 1) {
|
||||||
ret = 0;
|
return 0;
|
||||||
} else if (virJSONValueObjectHasKey(obj, "event") == 1) {
|
} else if (virJSONValueObjectHasKey(obj, "event") == 1) {
|
||||||
ret = qemuAgentIOProcessEvent(agent, obj);
|
return qemuAgentIOProcessEvent(agent, obj);
|
||||||
} else if (virJSONValueObjectHasKey(obj, "error") == 1 ||
|
} else if (virJSONValueObjectHasKey(obj, "error") == 1 ||
|
||||||
virJSONValueObjectHasKey(obj, "return") == 1) {
|
virJSONValueObjectHasKey(obj, "return") == 1) {
|
||||||
if (msg) {
|
if (msg) {
|
||||||
@ -268,8 +267,7 @@ qemuAgentIOProcessLine(qemuAgent *agent,
|
|||||||
|
|
||||||
if (virJSONValueObjectGetNumberUlong(obj, "return", &id) < 0) {
|
if (virJSONValueObjectGetNumberUlong(obj, "return", &id) < 0) {
|
||||||
VIR_DEBUG("Ignoring delayed reply on sync");
|
VIR_DEBUG("Ignoring delayed reply on sync");
|
||||||
ret = 0;
|
return 0;
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VIR_DEBUG("Guest returned ID: %llu", id);
|
VIR_DEBUG("Guest returned ID: %llu", id);
|
||||||
@ -277,8 +275,7 @@ qemuAgentIOProcessLine(qemuAgent *agent,
|
|||||||
if (msg->id != id) {
|
if (msg->id != id) {
|
||||||
VIR_DEBUG("Guest agent returned ID: %llu instead of %llu",
|
VIR_DEBUG("Guest agent returned ID: %llu instead of %llu",
|
||||||
id, msg->id);
|
id, msg->id);
|
||||||
ret = 0;
|
return 0;
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
msg->rxObject = g_steal_pointer(&obj);
|
msg->rxObject = g_steal_pointer(&obj);
|
||||||
@ -287,15 +284,13 @@ qemuAgentIOProcessLine(qemuAgent *agent,
|
|||||||
/* we are out of sync */
|
/* we are out of sync */
|
||||||
VIR_DEBUG("Ignoring delayed reply");
|
VIR_DEBUG("Ignoring delayed reply");
|
||||||
}
|
}
|
||||||
ret = 0;
|
|
||||||
} else {
|
return 0;
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
_("Unknown JSON reply '%s'"), line);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
virJSONValueFree(obj);
|
_("Unknown JSON reply '%s'"), line);
|
||||||
return ret;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int qemuAgentIOProcessData(qemuAgent *agent,
|
static int qemuAgentIOProcessData(qemuAgent *agent,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user