int qemuAgentShutdown(qemuAgent *agent,
qemuAgentShutdownMode mode)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
agent->await_event = QEMU_AGENT_EVENT_RESET;
else
agent->await_event = QEMU_AGENT_EVENT_SHUTDOWN;
- ret = qemuAgentCommand(agent, cmd, &reply,
- VIR_DOMAIN_QEMU_AGENT_COMMAND_SHUTDOWN);
- return ret;
+ return qemuAgentCommand(agent, cmd, &reply,
+ VIR_DOMAIN_QEMU_AGENT_COMMAND_SHUTDOWN);
}
/*
int qemuAgentFSFreeze(qemuAgent *agent, const char **mountpoints,
unsigned int nmountpoints)
{
- int ret = -1;
+ int nfrozen = 0;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
}
if (!cmd)
- goto cleanup;
+ return -1;
if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0)
- goto cleanup;
+ return -1;
- if (virJSONValueObjectGetNumberInt(reply, "return", &ret) < 0) {
+ if (virJSONValueObjectGetNumberInt(reply, "return", &nfrozen) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("malformed return value"));
+ return -1;
}
- cleanup:
- return ret;
+ return nfrozen;
}
/*
*/
int qemuAgentFSThaw(qemuAgent *agent)
{
- int ret = -1;
+ int nthawed = 0;
g_autoptr(virJSONValue) cmd = qemuAgentMakeCommand("guest-fsfreeze-thaw", NULL);
g_autoptr(virJSONValue) reply = NULL;
return -1;
if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0)
- goto cleanup;
+ return -1;
- if (virJSONValueObjectGetNumberInt(reply, "return", &ret) < 0) {
+ if (virJSONValueObjectGetNumberInt(reply, "return", &nthawed) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("malformed return value"));
+ return -1;
}
- cleanup:
- return ret;
+ return nthawed;
}
VIR_ENUM_DECL(qemuAgentSuspendMode);
qemuAgentSuspend(qemuAgent *agent,
unsigned int target)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
return -1;
agent->await_event = QEMU_AGENT_EVENT_SUSPEND;
- ret = qemuAgentCommand(agent, cmd, &reply, agent->timeout);
- return ret;
+ return qemuAgentCommand(agent, cmd, &reply, agent->timeout);
}
int
char **result,
int timeout)
{
- int ret = -1;
+ int rc;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
_("guest agent timeout '%d' is "
"less than the minimum '%d'"),
timeout, VIR_DOMAIN_QEMU_AGENT_COMMAND_MIN);
- goto cleanup;
+ return -1;
}
if (!(cmd = virJSONValueFromString(cmd_str)))
- goto cleanup;
+ return -1;
- if ((ret = qemuAgentCommand(agent, cmd, &reply, timeout)) < 0)
- goto cleanup;
+ if ((rc = qemuAgentCommand(agent, cmd, &reply, timeout)) < 0)
+ return rc;
if (!(*result = virJSONValueToString(reply, false)))
- ret = -1;
-
+ return -1;
- cleanup:
- return ret;
+ return rc;
}
int
qemuAgentFSTrim(qemuAgent *agent,
unsigned long long minimum)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
"U:minimum", minimum,
NULL);
if (!cmd)
- return ret;
-
- ret = qemuAgentCommand(agent, cmd, &reply, agent->timeout);
+ return -1;
- return ret;
+ return qemuAgentCommand(agent, cmd, &reply, agent->timeout);
}
int
qemuAgentGetVCPUs(qemuAgent *agent,
qemuAgentCPUInfo **info)
{
- int ret = -1;
size_t i;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
return -1;
if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0)
- goto cleanup;
+ return -1;
if (!(data = virJSONValueObjectGetArray(reply, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("guest-get-vcpus reply was missing return data"));
- goto cleanup;
+ return -1;
}
ndata = virJSONValueArraySize(data);
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("array element missing in guest-get-vcpus return "
"value"));
- goto cleanup;
+ return -1;
}
if (virJSONValueObjectGetNumberUint(entry, "logical-id", &in->id) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("'logical-id' missing in reply of guest-get-vcpus"));
- goto cleanup;
+ return -1;
}
if (virJSONValueObjectGetBoolean(entry, "online", &in->online) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("'online' missing in reply of guest-get-vcpus"));
- goto cleanup;
+ return -1;
}
if (virJSONValueObjectGetBoolean(entry, "can-offline",
&in->offlinable) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("'can-offline' missing in reply of guest-get-vcpus"));
- goto cleanup;
+ return -1;
}
}
- ret = ndata;
-
- cleanup:
- return ret;
+ return ndata;
}
long long *seconds,
unsigned int *nseconds)
{
- int ret = -1;
unsigned long long json_time;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
cmd = qemuAgentMakeCommand("guest-get-time",
NULL);
if (!cmd)
- return ret;
+ return -1;
if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0)
- goto cleanup;
+ return -1;
if (virJSONValueObjectGetNumberUlong(reply, "return", &json_time) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("malformed return value"));
- goto cleanup;
+ return -1;
}
/* guest agent returns time in nanoseconds,
* we need it in seconds here */
*seconds = json_time / 1000000000LL;
*nseconds = json_time % 1000000000LL;
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
unsigned int nseconds,
bool rtcSync)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
virReportError(VIR_ERR_INVALID_ARG,
_("Time '%lld' is too big for guest agent"),
seconds);
- return ret;
+ return -1;
}
json_time = seconds * 1000000000LL;
}
if (!cmd)
- return ret;
+ return -1;
if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
void