qemuMonitorMessage *msg)
{
g_autoptr(virJSONValue) obj = NULL;
- int ret = -1;
VIR_DEBUG("Line [%s]", line);
if (!(obj = virJSONValueFromString(line)))
- goto cleanup;
+ return -1;
if (virJSONValueGetType(obj) != VIR_JSON_TYPE_OBJECT) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Parsed JSON reply '%s' isn't an object"), line);
- goto cleanup;
+ return -1;
}
if (virJSONValueObjectHasKey(obj, "QMP") == 1) {
- ret = 0;
+ return 0;
} else if (virJSONValueObjectHasKey(obj, "event") == 1) {
PROBE(QEMU_MONITOR_RECV_EVENT,
"mon=%p event=%s", mon, line);
- ret = qemuMonitorJSONIOProcessEvent(mon, obj);
+ return qemuMonitorJSONIOProcessEvent(mon, obj);
} else if (virJSONValueObjectHasKey(obj, "error") == 1 ||
virJSONValueObjectHasKey(obj, "return") == 1) {
PROBE(QEMU_MONITOR_RECV_REPLY,
if (msg) {
msg->rxObject = g_steal_pointer(&obj);
msg->finished = 1;
- ret = 0;
+ return 0;
} else {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unexpected JSON reply '%s'"), line);
_("Unknown JSON reply '%s'"), line);
}
- cleanup:
- return ret;
+ return -1;
}
int qemuMonitorJSONIOProcess(qemuMonitor *mon,
if (virJSONValueObjectAppendString(cmd, "id", id) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Unable to append command 'id' string"));
- goto cleanup;
+ return -1;
}
}
if (virJSONValueToBuffer(cmd, &cmdbuf, false) < 0)
- goto cleanup;
+ return -1;
virBufferAddLit(&cmdbuf, "\r\n");
msg.txLength = virBufferUse(&cmdbuf);
}
}
- cleanup:
return ret;
}
g_autoptr(virJSONValue) reply = NULL;
virJSONValue *obj;
const char *data;
- int ret = -1;
cmd = qemuMonitorJSONMakeCommand("human-monitor-command",
"s:command-line", cmd_str,
NULL);
if (!cmd || qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONHasError(reply, "CommandNotFound")) {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("Human monitor command is not available to run %s"),
cmd_str);
- goto cleanup;
+ return -1;
}
if (qemuMonitorJSONCheckError(cmd, reply))
- goto cleanup;
+ return -1;
obj = virJSONValueObjectGet(reply, "return");
data = virJSONValueGetString(obj);
*reply_str = g_strdup(NULLSTR_EMPTY(data));
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
int
qemuMonitorJSONStopCPUs(qemuMonitor *mon)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand("stop", NULL);
g_autoptr(virJSONValue) reply = NULL;
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
int qemuMonitorJSONSystemPowerdown(qemuMonitor *mon)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand("system_powerdown", NULL);
g_autoptr(virJSONValue) reply = NULL;
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
int qemuMonitorJSONSetLink(qemuMonitor *mon,
const char *name,
virDomainNetInterfaceLinkState state)
{
- int ret = -1;
g_autoptr(virJSONValue) reply = NULL;
g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand("set_link",
"s:name", name,
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
int qemuMonitorJSONSystemReset(qemuMonitor *mon)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand("system_reset", NULL);
g_autoptr(virJSONValue) reply = NULL;
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
bool force,
bool fast)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
virJSONValue *data;
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (force && qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
-
- if (!(data = virJSONValueObjectGetArray(reply, "return"))) {
- ret = -2;
- goto cleanup;
- }
+ return -1;
- ret = qemuMonitorJSONExtractCPUInfo(data, entries, nentries, fast);
+ if (!(data = virJSONValueObjectGetArray(reply, "return")))
+ return -2;
- cleanup:
- return ret;
+ return qemuMonitorJSONExtractCPUInfo(data, entries, nentries, fast);
}
qemuMonitorJSONGetBalloonInfo(qemuMonitor *mon,
unsigned long long *currmem)
{
- int ret = -1;
virJSONValue *data;
unsigned long long mem;
g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand("query-balloon",
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
/* See if balloon soft-failed */
if (qemuMonitorJSONHasError(reply, "DeviceNotActive") ||
qemuMonitorJSONHasError(reply, "KVMMissingCap")) {
- ret = 0;
- goto cleanup;
+ return 0;
}
/* See if any other fatal error occurred */
if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0)
- goto cleanup;
+ return -1;
data = virJSONValueObjectGetObject(reply, "return");
if (virJSONValueObjectGetNumberUlong(data, "actual", &mem) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("info balloon reply was missing balloon data"));
- goto cleanup;
+ return -1;
}
*currmem = (mem/1024);
- ret = 1;
- cleanup:
- return ret;
+ return 1;
}
{
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
- virJSONValue *devices = NULL;
if (!(cmd = qemuMonitorJSONMakeCommand("query-block", NULL)))
return NULL;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0 ||
qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0)
- goto cleanup;
-
- devices = virJSONValueObjectStealArray(reply, "return");
+ return NULL;
- cleanup:
- return devices;
+ return virJSONValueObjectStealArray(reply, "return");
}
int qemuMonitorJSONGetBlockInfo(qemuMonitor *mon,
GHashTable *table)
{
- int ret = -1;
size_t i;
g_autoptr(virJSONValue) devices = NULL;
const char *qdev;
if (!(dev = qemuMonitorJSONGetBlockDev(devices, i)))
- goto cleanup;
+ return -1;
if (!(thisdev = qemuMonitorJSONGetBlockDevDevice(dev)))
- goto cleanup;
+ return -1;
thisdev = qemuAliasDiskDriveSkipPrefix(thisdev);
qdev = virJSONValueObjectGetString(dev, "qdev");
if (!qdev && !thisdev) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("query-block device entry was not in expected format"));
- goto cleanup;
+ return -1;
}
if (virJSONValueObjectGetBoolean(dev, "removable", &info.removable) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot read %s value"),
"removable");
- goto cleanup;
+ return -1;
}
/* 'tray_open' is present only if the device has a tray */
if ((status = virJSONValueObjectGetString(dev, "io-status"))) {
info.io_status = qemuMonitorBlockIOStatusToError(status);
if (info.io_status < 0)
- goto cleanup;
+ return -1;
}
if (thisdev &&
qemuMonitorJSONBlockInfoAdd(table, &info, thisdev) < 0)
- goto cleanup;
+ return -1;
if (qdev && STRNEQ_NULLABLE(thisdev, qdev) &&
qemuMonitorJSONBlockInfoAdd(table, &info, qdev) < 0)
- goto cleanup;
+ return -1;
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
GHashTable *stats)
{
g_autoptr(virJSONValue) nodes = NULL;
- int ret = -1;
if (!(nodes = qemuMonitorJSONQueryNamedBlockNodes(mon, false)))
return -1;
if (virJSONValueArrayForeachSteal(nodes,
qemuMonitorJSONBlockStatsUpdateCapacityBlockdevWorker,
stats) < 0)
- goto cleanup;
-
- ret = 0;
+ return -1;
- cleanup:
- return ret;
+ return 0;
}
const char *nodename,
unsigned long long size)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
const char *password,
const char *action_if_connected)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand("set_password",
"s:protocol", protocol,
"s:password", password,
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
int qemuMonitorJSONExpirePassword(qemuMonitor *mon,
const char *protocol,
const char *expire_time)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand("expire_password",
"s:protocol", protocol,
"s:time", expire_time,
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
qemuMonitorJSONSetBalloon(qemuMonitor *mon,
unsigned long long newmem)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand("balloon",
"U:value", newmem * 1024,
NULL);
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
/* See if balloon soft-failed */
if (qemuMonitorJSONHasError(reply, "DeviceNotActive") ||
qemuMonitorJSONHasError(reply, "KVMMissingCap")) {
- ret = 0;
- goto cleanup;
+ return 0;
}
/* See if any other fatal error occurred */
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
+ return -1;
/* Real success */
- ret = 1;
- cleanup:
- return ret;
+ return 1;
}
int qemuMonitorJSONSetCPU(qemuMonitor *mon,
int cpu, bool online)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
} else {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("vCPU unplug is not supported by this QEMU"));
- goto cleanup;
+ return -1;
}
if (!cmd)
- goto cleanup;
-
- if ((ret = qemuMonitorJSONCommand(mon, cmd, &reply)) < 0)
- goto cleanup;
+ return -1;
- ret = qemuMonitorJSONCheckError(cmd, reply);
+ if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
+ return -1;
- cleanup:
- return ret;
+ return qemuMonitorJSONCheckError(cmd, reply);
}
const char *dev_name,
bool force)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand("eject",
"s:device", dev_name,
"b:force", force ? 1 : 0,
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
const char *newmedia,
const char *format)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
unsigned long long length,
const char *path)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand(cmdtype,
"U:val", offset,
"U:size", length,
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
int qemuMonitorJSONSetMigrationSpeed(qemuMonitor *mon,
unsigned long bandwidth)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
int qemuMonitorJSONSetMigrationDowntime(qemuMonitor *mon,
unsigned long long downtime)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
qemuMonitorJSONGetMigrationCacheSize(qemuMonitor *mon,
unsigned long long *cacheSize)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_NUMBER) < 0)
- goto cleanup;
+ return -1;
if (virJSONValueObjectGetNumberUlong(reply, "return", cacheSize) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("invalid cache size in query-migrate-cache-size reply"));
- goto cleanup;
+ return -1;
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
qemuMonitorJSONSetMigrationCacheSize(qemuMonitor *mon,
unsigned long long cacheSize)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
qemuMonitorJSONGetMigrationParams(qemuMonitor *mon,
virJSONValue **params)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0)
- goto cleanup;
+ return -1;
*params = virJSONValueObjectStealObject(reply, "return");
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
int
qemuMonitorMigrationStats *stats,
char **error)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand("query-migrate",
NULL);
g_autoptr(virJSONValue) reply = NULL;
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONGetMigrationStatsReply(reply, stats, error) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
unsigned int flags,
const char *uri)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd =
qemuMonitorJSONMakeCommand("migrate",
"b:detach", flags & QEMU_MONITOR_MIGRATE_BACKGROUND ? 1 : 0,
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
int qemuMonitorJSONMigrateCancel(qemuMonitor *mon)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand("migrate_cancel", NULL);
g_autoptr(virJSONValue) reply = NULL;
if (!cmd)
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand("query-dump", NULL);
g_autoptr(virJSONValue) reply = NULL;
virJSONValue *result = NULL;
- int ret = -1;
if (!cmd)
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0)
- goto cleanup;
+ return -1;
result = virJSONValueObjectGetObject(reply, "return");
- ret = qemuMonitorJSONExtractDumpStats(result, stats);
-
- cleanup:
- return ret;
+ return qemuMonitorJSONExtractDumpStats(result, stats);
}
qemuMonitorJSONGetDumpGuestMemoryCapability(qemuMonitor *mon,
const char *capability)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
virJSONValue *caps;
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0)
- goto cleanup;
+ return -1;
caps = virJSONValueObjectGetObject(reply, "return");
if (!(formats = virJSONValueObjectGetArray(caps, "formats"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("missing supported dump formats"));
- goto cleanup;
+ return -1;
}
for (i = 0; i < virJSONValueArraySize(formats); i++) {
if (!dumpformat || virJSONValueGetType(dumpformat) != VIR_JSON_TYPE_STRING) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("missing entry in supported dump formats"));
- goto cleanup;
+ return -1;
}
- if (STREQ(virJSONValueGetString(dumpformat), capability)) {
- ret = 1;
- goto cleanup;
- }
+ if (STREQ(virJSONValueGetString(dumpformat), capability))
+ return 1;
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
int
const char *dumpformat,
bool detach)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
int qemuMonitorJSONGraphicsRelocate(qemuMonitor *mon,
int tlsPort,
const char *tlsSubject)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand("client_migrate_info",
"s:protocol",
(type == VIR_DOMAIN_GRAPHICS_TYPE_SPICE ? "spice" : "vnc"),
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
const char *fdname,
int fd)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand("getfd",
"s:fdname", fdname,
NULL);
return -1;
if (qemuMonitorJSONCommandWithFd(mon, cmd, fd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
int qemuMonitorJSONCloseFileHandle(qemuMonitor *mon,
const char *fdname)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand("closefd",
"s:fdname", fdname,
NULL);
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
qemuMonitorJSONQueryRxFilterParse(virJSONValue *msg,
virNetDevRxFilter **filter)
{
- int ret = -1;
const char *tmp;
virJSONValue *returnArray;
virJSONValue *entry;
g_autoptr(virNetDevRxFilter) fil = virNetDevRxFilterNew();
if (!fil)
- goto cleanup;
+ return -1;
returnArray = virJSONValueObjectGetArray(msg, "return");
if (!(entry = virJSONValueArrayGet(returnArray, 0))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("query -rx-filter return data missing array element"));
- goto cleanup;
+ _("query-rx-filter return data missing array element"));
+ return -1;
}
if (!(tmp = virJSONValueObjectGetString(entry, "name"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Missing or invalid name "
"in query-rx-filter response"));
- goto cleanup;
+ return -1;
}
fil->name = g_strdup(tmp);
if ((!(tmp = virJSONValueObjectGetString(entry, "main-mac"))) ||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Missing or invalid 'main-mac' "
"in query-rx-filter response"));
- goto cleanup;
+ return -1;
}
if (virJSONValueObjectGetBoolean(entry, "promiscuous",
&fil->promiscuous) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Missing or invalid 'promiscuous' "
"in query-rx-filter response"));
- goto cleanup;
+ return -1;
}
if (virJSONValueObjectGetBoolean(entry, "broadcast-allowed",
&fil->broadcastAllowed) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Missing or invalid 'broadcast-allowed' "
"in query-rx-filter response"));
- goto cleanup;
+ return -1;
}
if ((!(tmp = virJSONValueObjectGetString(entry, "unicast"))) ||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Missing or invalid 'unicast' "
"in query-rx-filter response"));
- goto cleanup;
+ return -1;
}
if (virJSONValueObjectGetBoolean(entry, "unicast-overflow",
&fil->unicast.overflow) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Missing or invalid 'unicast-overflow' "
"in query-rx-filter response"));
- goto cleanup;
+ return -1;
}
if ((!(table = virJSONValueObjectGet(entry, "unicast-table"))) ||
(!virJSONValueIsArray(table))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Missing or invalid 'unicast-table' array "
"in query-rx-filter response"));
- goto cleanup;
+ return -1;
}
nTable = virJSONValueArraySize(table);
fil->unicast.table = g_new0(virMacAddr, nTable);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Missing or invalid element %zu of 'unicast' "
"list in query-rx-filter response"), i);
- goto cleanup;
+ return -1;
}
if (virMacAddrParse(tmp, &fil->unicast.table[i]) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("invalid mac address '%s' in 'unicast-table' "
"array in query-rx-filter response"), tmp);
- goto cleanup;
+ return -1;
}
}
fil->unicast.nTable = nTable;
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Missing or invalid 'multicast' "
"in query-rx-filter response"));
- goto cleanup;
+ return -1;
}
if (virJSONValueObjectGetBoolean(entry, "multicast-overflow",
&fil->multicast.overflow) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Missing or invalid 'multicast-overflow' "
"in query-rx-filter response"));
- goto cleanup;
+ return -1;
}
if ((!(table = virJSONValueObjectGet(entry, "multicast-table"))) ||
(!virJSONValueIsArray(table))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Missing or invalid 'multicast-table' array "
"in query-rx-filter response"));
- goto cleanup;
+ return -1;
}
nTable = virJSONValueArraySize(table);
fil->multicast.table = g_new0(virMacAddr, nTable);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Missing or invalid element %zu of 'multicast' "
"list in query-rx-filter response"), i);
- goto cleanup;
+ return -1;
}
if (virMacAddrParse(tmp, &fil->multicast.table[i]) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("invalid mac address '%s' in 'multicast-table' "
"array in query-rx-filter response"), tmp);
- goto cleanup;
+ return -1;
}
}
fil->multicast.nTable = nTable;
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Missing or invalid 'vlan' "
"in query-rx-filter response"));
- goto cleanup;
+ return -1;
}
if ((!(table = virJSONValueObjectGet(entry, "vlan-table"))) ||
(!virJSONValueIsArray(table))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Missing or invalid 'vlan-table' array "
"in query-rx-filter response"));
- goto cleanup;
+ return -1;
}
nTable = virJSONValueArraySize(table);
fil->vlan.table = g_new0(unsigned int, nTable);
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Missing or invalid element %zu of 'vlan-table' "
"array in query-rx-filter response"), i);
- goto cleanup;
+ return -1;
}
}
fil->vlan.nTable = nTable;
*filter = g_steal_pointer(&fil);
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
qemuMonitorJSONQueryRxFilter(qemuMonitor *mon, const char *alias,
virNetDevRxFilter **filter)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand("query-rx-filter",
"s:name", alias,
NULL);
g_autoptr(virJSONValue) reply = NULL;
if (!cmd)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONQueryRxFilterParse(reply, filter) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
GHashTable *info)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = qemuMonitorJSONMakeCommand("query-chardev",
NULL);
g_autoptr(virJSONValue) reply = NULL;
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0)
- goto cleanup;
+ return -1;
- ret = qemuMonitorJSONExtractChardevInfo(reply, info);
- cleanup:
- return ret;
+ return qemuMonitorJSONExtractChardevInfo(reply, info);
}
int qemuMonitorJSONDelDevice(qemuMonitor *mon,
const char *devalias)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
- if (qemuMonitorJSONHasError(reply, "DeviceNotFound")) {
- ret = -2;
- goto cleanup;
- }
+ if (qemuMonitorJSONHasError(reply, "DeviceNotFound"))
+ return -2;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
int
qemuMonitorJSONTransaction(qemuMonitor *mon, virJSONValue **actions)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
"a:actions", actions,
NULL);
if (!cmd)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
const char *backingName,
unsigned long long speed)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
virTristateBool autofinalize = VIR_TRISTATE_BOOL_ABSENT;
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
virStorageSource *top,
virStorageSource *target)
{
- char *ret = NULL;
g_autoptr(virJSONValue) devices = NULL;
size_t i;
const char *thisdev;
if (!(dev = qemuMonitorJSONGetBlockDev(devices, i)))
- goto cleanup;
+ return NULL;
if (!(thisdev = qemuMonitorJSONGetBlockDevDevice(dev)))
- goto cleanup;
+ return NULL;
if (STREQ(thisdev, device)) {
if ((inserted = virJSONValueObjectGetObject(dev, "inserted")) &&
(image = virJSONValueObjectGetObject(inserted, "image"))) {
- ret = qemuMonitorJSONDiskNameLookupOne(image, top, target);
+ return qemuMonitorJSONDiskNameLookupOne(image, top, target);
}
- break;
}
}
/* Guarantee an error when returning NULL, but don't override a
* more specific error if one was already generated. */
- if (!ret && virGetLastErrorCode() == VIR_ERR_OK)
+ if (virGetLastErrorCode() == VIR_ERR_OK) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unable to find backing name for device %s"),
device);
+ }
- cleanup:
- return ret;
+ return NULL;
}
{
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
- int ret = -1;
if (!(cmd = virJSONValueFromString(cmd_str)))
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (!(*reply_str = virJSONValueToString(reply, false)))
- goto cleanup;
-
- ret = 0;
+ return -1;
- cleanup:
- return ret;
+ return 0;
}
int qemuMonitorJSONInjectNMI(qemuMonitor *mon)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
int qemuMonitorJSONSendKey(qemuMonitor *mon,
unsigned int *keycodes,
unsigned int nkeycodes)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
g_autoptr(virJSONValue) keys = NULL;
if (keycodes[i] > 0xffff) {
virReportError(VIR_ERR_OPERATION_FAILED,
_("keycode %zu is invalid: 0x%X"), i, keycodes[i]);
- goto cleanup;
+ return -1;
}
/* create single key object */
/* Union KeyValue has two types, use the generic one */
if (virJSONValueObjectAppendString(key, "type", "number") < 0)
- goto cleanup;
+ return -1;
/* with the keycode */
if (virJSONValueObjectAppendNumberInt(key, "data", keycodes[i]) < 0)
- goto cleanup;
+ return -1;
if (virJSONValueArrayAppend(keys, &key) < 0)
- goto cleanup;
+ return -1;
}
cmd = qemuMonitorJSONMakeCommand("send-key",
"p:hold-time", holdtime,
NULL);
if (!cmd)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
int qemuMonitorJSONScreendump(qemuMonitor *mon,
unsigned int head,
const char *file)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
const char *backingName,
unsigned long long speed)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
virTristateBool autofinalize = VIR_TRISTATE_BOOL_ABSENT;
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
-
- ret = 0;
+ return -1;
- cleanup:
- return ret;
+ return 0;
}
const char *jobname,
unsigned long long speed)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONBlockJobError(cmd, reply, jobname) < 0)
- goto cleanup;
-
- ret = 0;
+ return -1;
- cleanup:
- return ret;
+ return 0;
}
qemuMonitorJSONDrivePivot(qemuMonitor *mon,
const char *jobname)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONBlockJobError(cmd, reply, jobname) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
const char *fdname,
bool skipauth)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
const char *qdevid,
virDomainBlockIoTuneInfo *reply)
{
- int ret = -1;
g_autoptr(virJSONValue) devices = NULL;
if (!(devices = qemuMonitorJSONQueryBlock(mon)))
return -1;
- ret = qemuMonitorJSONBlockIoThrottleInfo(devices, drivealias, qdevid, reply);
- return ret;
+ return qemuMonitorJSONBlockIoThrottleInfo(devices, drivealias, qdevid, reply);
}
int qemuMonitorJSONSystemWakeup(qemuMonitor *mon)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
int qemuMonitorJSONGetVersion(qemuMonitor *mon,
int *micro,
char **package)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
virJSONValue *data;
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0)
- goto cleanup;
+ return -1;
data = virJSONValueObjectGetObject(reply, "return");
if (!(qemu = virJSONValueObjectGetObject(data, "qemu"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("query-version reply was missing 'qemu' data"));
- goto cleanup;
+ return -1;
}
if (virJSONValueObjectGetNumberInt(qemu, "major", major) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("query-version reply was missing 'major' version"));
- goto cleanup;
+ return -1;
}
if (virJSONValueObjectGetNumberInt(qemu, "minor", minor) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("query-version reply was missing 'minor' version"));
- goto cleanup;
+ return -1;
}
if (virJSONValueObjectGetNumberInt(qemu, "micro", micro) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("query-version reply was missing 'micro' version"));
- goto cleanup;
+ return -1;
}
if (package) {
if (!(tmp = virJSONValueObjectGetString(data, "package"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("query-version reply was missing 'package' version"));
- goto cleanup;
+ return -1;
}
*package = g_strdup(tmp);
}
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
qemuMonitorCPUModelInfo **model_info)
{
g_autoptr(qemuMonitorCPUModelInfo) machine_model = NULL;
- int ret = -1;
machine_model = g_new0(qemuMonitorCPUModelInfo, 1);
machine_model->name = g_strdup(cpu_name);
if (virJSONValueObjectForeachKeyValue(cpu_props,
qemuMonitorJSONParseCPUModelProperty,
machine_model) < 0)
- goto cleanup;
+ return -1;
}
*model_info = g_steal_pointer(&machine_model);
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
bool *enabled,
bool *present)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
virJSONValue *data = NULL;
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0)
- goto cleanup;
+ return -1;
data = virJSONValueObjectGetObject(reply, "return");
virJSONValueObjectGetBoolean(data, "present", present) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("query-kvm replied unexpected data"));
- goto cleanup;
+ return -1;
}
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
+ return -1;
data = virJSONValueObjectGet(reply, "return");
virReportError(VIR_ERR_INTERNAL_ERROR,
_("qom-get invalid object property type %d"),
prop->type);
- goto cleanup;
+ return -1;
break;
}
if (ret == -1) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("qom-get reply was missing return data"));
- goto cleanup;
+ return -1;
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
const char *property,
qemuMonitorJSONObjectProperty *prop)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
virReportError(VIR_ERR_INTERNAL_ERROR,
_("qom-set invalid object property type %d"),
prop->type);
- goto cleanup;
+ return -1;
}
if (!cmd)
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
#undef MAKE_SET_CMD
char *
qemuMonitorJSONGetTargetArch(qemuMonitor *mon)
{
- char *ret = NULL;
const char *arch;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
return NULL;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return NULL;
if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0)
- goto cleanup;
+ return NULL;
data = virJSONValueObjectGetObject(reply, "return");
if (!(arch = virJSONValueObjectGetString(data, "arch"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("query-target reply was missing arch data"));
- goto cleanup;
+ return NULL;
}
- ret = g_strdup(arch);
-
- cleanup:
- return ret;
+ return g_strdup(arch);
}
qemuMonitorJSONGetGICCapabilities(qemuMonitor *mon,
virGICCapability **capabilities)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
virJSONValue *caps;
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
/* If the 'query-gic-capabilities' QMP command was not available
* we simply successfully return zero capabilities.
* This is the case for QEMU <2.6 and all non-ARM architectures */
- if (qemuMonitorJSONHasError(reply, "CommandNotFound")) {
- ret = 0;
- goto cleanup;
- }
+ if (qemuMonitorJSONHasError(reply, "CommandNotFound"))
+ return 0;
if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0)
- goto cleanup;
+ return -1;
caps = virJSONValueObjectGetArray(reply, "return");
n = virJSONValueArraySize(caps);
/* If the returned array was empty we have to return successfully */
- if (n == 0) {
- ret = 0;
- goto cleanup;
- }
+ if (n == 0)
+ return 0;
list = g_new0(virGICCapability, n);
if (!cap || virJSONValueGetType(cap) != VIR_JSON_TYPE_OBJECT) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("missing entry in GIC capabilities list"));
- goto cleanup;
+ return -1;
}
if (virJSONValueObjectGetNumberInt(cap, "version", &version) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("missing GIC version"));
- goto cleanup;
+ return -1;
}
if (virJSONValueObjectGetBoolean(cap, "kernel", &kernel) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("missing in-kernel GIC information"));
- goto cleanup;
+ return -1;
}
if (virJSONValueObjectGetBoolean(cap, "emulated", &emulated) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("missing emulated GIC information"));
- goto cleanup;
+ return -1;
}
list[i].version = version;
list[i].implementation |= VIR_GIC_IMPLEMENTATION_EMULATED;
}
- ret = n;
*capabilities = g_steal_pointer(&list);
-
- cleanup:
- return ret;
+ return n;
}
qemuMonitorJSONGetSEVCapabilities(qemuMonitor *mon,
virSEVCapability **capabilities)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
virJSONValue *caps;
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
/* QEMU has only compiled-in support of SEV */
- if (qemuMonitorJSONHasError(reply, "GenericError")) {
- ret = 0;
- goto cleanup;
- }
+ if (qemuMonitorJSONHasError(reply, "GenericError"))
+ return 0;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
+ return -1;
caps = virJSONValueObjectGetObject(reply, "return");
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("query-sev-capabilities reply was missing"
" 'cbitpos' field"));
- goto cleanup;
+ return -1;
}
if (virJSONValueObjectGetNumberUint(caps, "reduced-phys-bits",
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("query-sev-capabilities reply was missing"
" 'reduced-phys-bits' field"));
- goto cleanup;
+ return -1;
}
if (!(pdh = virJSONValueObjectGetString(caps, "pdh"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("query-sev-capabilities reply was missing"
" 'pdh' field"));
- goto cleanup;
+ return -1;
}
if (!(cert_chain = virJSONValueObjectGetString(caps, "cert-chain"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("query-sev-capabilities reply was missing"
" 'cert-chain' field"));
- goto cleanup;
+ return -1;
}
capability = g_new0(virSEVCapability, 1);
capability->cbitpos = cbitpos;
capability->reduced_phys_bits = reduced_phys_bits;
*capabilities = g_steal_pointer(&capability);
- ret = 1;
- cleanup:
- return ret;
+ return 1;
}
static virJSONValue *
const virStorageNetHostDef *server,
const char *tls_alias)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
g_autoptr(virJSONValue) addr = NULL;
case VIR_STORAGE_NET_HOST_TRANS_LAST:
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("invalid server address"));
- goto cleanup;
+ return -1;
}
if (!addr)
- goto cleanup;
+ return -1;
if (!(cmd = qemuMonitorJSONMakeCommand("nbd-server-start",
"a:addr", &addr,
"S:tls-creds", tls_alias,
NULL)))
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
-
- ret = 0;
+ return -1;
- cleanup:
- return ret;
+ return 0;
}
int
bool writable,
const char *bitmap)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
"b:writable", writable,
"S:bitmap", bitmap,
NULL)))
- return ret;
+ return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
int
qemuMonitorJSONNBDServerStop(qemuMonitor *mon)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
if (!(cmd = qemuMonitorJSONMakeCommand("nbd-server-stop",
NULL)))
- return ret;
+ return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
qemuMonitorJSONAttachCharDevCommand(const char *chrID,
const virDomainChrSourceDef *chr)
{
- virJSONValue *ret = NULL;
g_autoptr(virJSONValue) backend = virJSONValueNewObject();
g_autoptr(virJSONValue) data = virJSONValueNewObject();
g_autoptr(virJSONValue) addr = NULL;
case VIR_DOMAIN_CHR_TYPE_FILE:
backend_type = "file";
if (virJSONValueObjectAppendString(data, "out", chr->data.file.path) < 0)
- goto cleanup;
+ return NULL;
if (virJSONValueObjectAdd(data,
"T:append", chr->data.file.append,
NULL) < 0)
- goto cleanup;
+ return NULL;
break;
case VIR_DOMAIN_CHR_TYPE_DEV:
backend_type = STRPREFIX(chrID, "parallel") ? "parallel" : "serial";
if (virJSONValueObjectAppendString(data, "device",
chr->data.file.path) < 0)
- goto cleanup;
+ return NULL;
break;
case VIR_DOMAIN_CHR_TYPE_TCP:
chr->data.tcp.service);
if (!addr ||
virJSONValueObjectAppend(data, "addr", &addr) < 0)
- goto cleanup;
+ return NULL;
telnet = chr->data.tcp.protocol == VIR_DOMAIN_CHR_TCP_PROTOCOL_TELNET;
if (chr->data.tcp.listen &&
virJSONValueObjectAppendBoolean(data, "wait", false) < 0)
- goto cleanup;
+ return NULL;
if (virJSONValueObjectAppendBoolean(data, "telnet", telnet) < 0 ||
virJSONValueObjectAppendBoolean(data, "server", chr->data.tcp.listen) < 0)
- goto cleanup;
+ return NULL;
if (chr->data.tcp.tlscreds) {
if (!(tlsalias = qemuAliasTLSObjFromSrcAlias(chrID)))
- goto cleanup;
+ return NULL;
if (virJSONValueObjectAppendString(data, "tls-creds", tlsalias) < 0)
- goto cleanup;
+ return NULL;
}
if (qemuMonitorJSONBuildChrChardevReconnect(data, &chr->data.tcp.reconnect) < 0)
- goto cleanup;
+ return NULL;
break;
case VIR_DOMAIN_CHR_TYPE_UDP:
chr->data.udp.connectService);
if (!addr ||
virJSONValueObjectAppend(data, "remote", &addr) < 0)
- goto cleanup;
+ return NULL;
host = chr->data.udp.bindHost;
port = chr->data.udp.bindService;
addr = qemuMonitorJSONBuildInetSocketAddress(host, port);
if (!addr ||
virJSONValueObjectAppend(data, "local", &addr) < 0)
- goto cleanup;
+ return NULL;
}
break;
if (!addr ||
virJSONValueObjectAppend(data, "addr", &addr) < 0)
- goto cleanup;
+ return NULL;
if (chr->data.nix.listen &&
virJSONValueObjectAppendBoolean(data, "wait", false) < 0)
- goto cleanup;
+ return NULL;
if (virJSONValueObjectAppendBoolean(data, "server", chr->data.nix.listen) < 0)
- goto cleanup;
+ return NULL;
if (qemuMonitorJSONBuildChrChardevReconnect(data, &chr->data.nix.reconnect) < 0)
- goto cleanup;
+ return NULL;
break;
case VIR_DOMAIN_CHR_TYPE_SPICEVMC:
if (virJSONValueObjectAppendString(data, "type",
virDomainChrSpicevmcTypeToString(chr->data.spicevmc)) < 0)
- goto cleanup;
+ return NULL;
break;
case VIR_DOMAIN_CHR_TYPE_SPICEPORT:
_("Hotplug unsupported for char device type '%d'"),
chr->type);
}
- goto cleanup;
+ return NULL;
}
if (chr->logfile &&
"s:logfile", chr->logfile,
"T:logappend", chr->logappend,
NULL) < 0)
- goto cleanup;
+ return NULL;
if (virJSONValueObjectAppendString(backend, "type", backend_type) < 0 ||
virJSONValueObjectAppend(backend, "data", &data) < 0)
- goto cleanup;
-
- if (!(ret = qemuMonitorJSONMakeCommand("chardev-add",
- "s:id", chrID,
- "a:backend", &backend,
- NULL)))
- goto cleanup;
+ return NULL;
- cleanup:
- return ret;
+ return qemuMonitorJSONMakeCommand("chardev-add",
+ "s:id", chrID,
+ "a:backend", &backend,
+ NULL);
}
const char *chrID,
virDomainChrSourceDef *chr)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
if (!(cmd = qemuMonitorJSONAttachCharDevCommand(chrID, chr)))
- return ret;
+ return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (chr->type == VIR_DOMAIN_CHR_TYPE_PTY) {
if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0)
- goto cleanup;
+ return -1;
} else {
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
+ return -1;
}
if (chr->type == VIR_DOMAIN_CHR_TYPE_PTY) {
if (!(path = virJSONValueObjectGetString(data, "pty"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("chardev-add reply was missing pty path"));
- goto cleanup;
+ return -1;
}
chr->data.file.path = g_strdup(path);
}
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
int
qemuMonitorJSONDetachCharDev(qemuMonitor *mon,
const char *chrID)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
if (!(cmd = qemuMonitorJSONMakeCommand("chardev-remove",
"s:id", chrID,
NULL)))
- return ret;
+ return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
virJSONValue *data;
- int ret = -1;
if (!(cmd = qemuMonitorJSONMakeCommand("qom-get",
"s:path", QOM_CPU_PATH,
"s:property", property,
NULL)))
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0)
- goto cleanup;
+ return -1;
data = virJSONValueObjectGetArray(reply, "return");
if (!(*cpudata = qemuMonitorJSONParseCPUx86Features(data)))
- goto cleanup;
-
- ret = 0;
+ return -1;
- cleanup:
- return ret;
+ return 0;
}
virJSONValue *data;
size_t i;
size_t n;
- int ret = -1;
if (!(cmd = qemuMonitorJSONMakeCommand("qom-list",
"s:path", QOM_CPU_PATH,
NULL)))
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if ((data = virJSONValueObjectGet(reply, "error"))) {
const char *klass = virJSONValueObjectGetString(data, "class");
if (STREQ_NULLABLE(klass, "DeviceNotFound") ||
STREQ_NULLABLE(klass, "CommandNotFound")) {
- ret = 0;
- goto cleanup;
+ return 0;
}
}
if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0)
- goto cleanup;
+ return -1;
data = virJSONValueObjectGetArray(reply, "return");
n = virJSONValueArraySize(data);
virJSONValue *element = virJSONValueArrayGet(data, i);
if (STREQ_NULLABLE(virJSONValueObjectGetString(element, "name"),
"feature-words"))
- break;
+ return 1;
}
- if (i == n)
- ret = 0;
- else
- ret = 1;
-
- cleanup:
- return ret;
+ return 0;
}
{
g_autoptr(virCPUData) cpuEnabled = NULL;
g_autoptr(virCPUData) cpuDisabled = NULL;
- int ret = -1;
if (!(cpuEnabled = virCPUDataNew(arch)) ||
!(cpuDisabled = virCPUDataNew(arch)))
- goto cleanup;
+ return -1;
if (qemuMonitorJSONGetCPUData(mon, translate, opaque, cpuEnabled) < 0)
- goto cleanup;
+ return -1;
if (disabled &&
qemuMonitorJSONGetCPUDataDisabled(mon, translate, opaque, cpuDisabled) < 0)
- goto cleanup;
+ return -1;
*enabled = g_steal_pointer(&cpuEnabled);
if (disabled)
*disabled = g_steal_pointer(&cpuDisabled);
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
int
qemuMonitorJSONRTCResetReinjection(qemuMonitor *mon)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
if (!(cmd = qemuMonitorJSONMakeCommand("rtc-reset-reinjection",
NULL)))
- return ret;
+ return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
+ return -1;
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
/**
qemuMonitorJSONSetIOThread(qemuMonitor *mon,
qemuMonitorIOThreadInfo *iothreadInfo)
{
- int ret = -1;
g_autofree char *path = NULL;
qemuMonitorJSONObjectProperty prop;
prop.type = QEMU_MONITOR_OBJECT_PROPERTY_INT; \
prop.val.iv = iothreadInfo->propVal; \
if (qemuMonitorJSONSetObjectProperty(mon, path, propName, &prop) < 0) \
- goto cleanup; \
+ return -1; \
}
VIR_IOTHREAD_SET_PROP("poll-max-ns", poll_max_ns);
#undef VIR_IOTHREAD_SET_PROP
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitor *mon,
GHashTable *info)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
virJSONValue *data = NULL;
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0)
- goto cleanup;
+ return -1;
data = virJSONValueObjectGetArray(reply, "return");
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("query-memory-devices reply data doesn't contain "
"enum type discriminator"));
- goto cleanup;
+ return -1;
}
if (!(dimminfo = virJSONValueObjectGetObject(elem, "data"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("query-memory-devices reply data doesn't "
"contain enum data"));
- goto cleanup;
+ return -1;
}
/* While 'id' attribute is marked as optional in QEMU's QAPI
if (!(devalias = virJSONValueObjectGetString(dimminfo, "id"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("dimm memory info data is missing 'id'"));
- goto cleanup;
+ return -1;
}
meminfo = g_new0(qemuMonitorMemoryDeviceInfo, 1);
&meminfo->address) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("malformed/missing addr in dimm memory info"));
- goto cleanup;
+ return -1;
}
if (virJSONValueObjectGetNumberUint(dimminfo, "slot",
&meminfo->slot) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("malformed/missing slot in dimm memory info"));
- goto cleanup;
+ return -1;
}
if (virJSONValueObjectGetBoolean(dimminfo, "hotplugged",
&meminfo->hotplugged) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("malformed/missing hotplugged in dimm memory info"));
- goto cleanup;
+ return -1;
}
&meminfo->hotpluggable) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("malformed/missing hotpluggable in dimm memory info"));
- goto cleanup;
+ return -1;
}
&meminfo->size) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("malformed/missing size in virtio memory info"));
- goto cleanup;
+ return -1;
}
} else {
/* type not handled yet */
}
if (virHashAddEntry(info, devalias, meminfo) < 0)
- goto cleanup;
+ return -1;
meminfo = NULL;
}
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
int
qemuMonitorJSONMigrateStartPostCopy(qemuMonitor *mon)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
-
- ret = qemuMonitorJSONCheckError(cmd, reply);
+ return -1;
- cleanup:
- return ret;
+ return qemuMonitorJSONCheckError(cmd, reply);
}
qemuMonitorMigrationStatus status)
{
const char *statusStr = qemuMonitorMigrationStatusTypeToString(status);
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
-
- ret = qemuMonitorJSONCheckError(cmd, reply);
+ return -1;
- cleanup:
- return ret;
+ return qemuMonitorJSONCheckError(cmd, reply);
}
qemuMonitorJSONGetRTCTime(qemuMonitor *mon,
struct tm *tm)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
virJSONValue *data;
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0)
- goto cleanup;
+ return -1;
data = virJSONValueObjectGet(reply, "return");
virJSONValueObjectGetNumberInt(data, "tm_sec", &tm->tm_sec) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("qemu returned malformed time"));
- goto cleanup;
+ return -1;
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
}
{
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
- virJSONValue *ret = NULL;
if (!(cmd = qemuMonitorJSONMakeCommand("query-qmp-schema", NULL)))
return NULL;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return NULL;
if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0)
- goto cleanup;
-
- ret = virJSONValueObjectStealArray(reply, "return");
+ return NULL;
- cleanup:
- return ret;
+ return virJSONValueObjectStealArray(reply, "return");
}
{
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
- int ret = -1;
if (!(cmd = qemuMonitorJSONMakeCommand("block-set-write-threshold",
"s:node-name", nodename,
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
-
- ret = 0;
+ return -1;
- cleanup:
- return ret;
+ return 0;
}
{
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
- int ret = -1;
if (!(cmd = qemuMonitorJSONMakeCommand("blockdev-open-tray",
"s:id", id,
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
-
- ret = 0;
+ return -1;
- cleanup:
- return ret;
+ return 0;
}
{
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
- int ret = -1;
if (!(cmd = qemuMonitorJSONMakeCommand("blockdev-close-tray",
"s:id", id, NULL)))
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
-
- ret = 0;
+ return -1;
- cleanup:
- return ret;
+ return 0;
}
{
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
- int ret = -1;
if (!(cmd = qemuMonitorJSONMakeCommand("blockdev-remove-medium",
"s:id", id, NULL)))
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
-
- ret = 0;
+ return -1;
- cleanup:
- return ret;
+ return 0;
}
{
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
- int ret = -1;
if (!(cmd = qemuMonitorJSONMakeCommand("blockdev-insert-medium",
"s:id", id,
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
- goto cleanup;
-
- ret = 0;
+ return -1;
- cleanup:
- return ret;
+ return 0;
}
qemuMonitorJSONGetSEVMeasurement(qemuMonitor *mon)
{
const char *tmp;
- char *measurement = NULL;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
virJSONValue *data;
return NULL;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return NULL;
if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0)
- goto cleanup;
+ return NULL;
data = virJSONValueObjectGetObject(reply, "return");
if (!(tmp = virJSONValueObjectGetString(data, "data")))
- goto cleanup;
-
- measurement = g_strdup(tmp);
+ return NULL;
- cleanup:
- return measurement;
+ return g_strdup(tmp);
}
GHashTable *info)
{
virJSONValue *data;
- int ret = -1;
size_t i;
data = virJSONValueObjectGetArray(reply, "return");
}
if (virHashAddEntry(info, alias, entry) < 0)
- goto cleanup;
+ return -1;
entry = NULL;
}
- ret = 0;
- cleanup:
- return ret;
+ return 0;
malformed:
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("malformed prManager reply"));
- goto cleanup;
+ return -1;
}
qemuMonitorJSONGetPRManagerInfo(qemuMonitor *mon,
GHashTable *info)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0)
- goto cleanup;
-
- ret = qemuMonitorJSONExtractPRManagerInfo(reply, info);
- cleanup:
- return ret;
+ return -1;
+ return qemuMonitorJSONExtractPRManagerInfo(reply, info);
}
qemuMonitorJSONGetCurrentMachineInfo(qemuMonitor *mon,
qemuMonitorCurrentMachineInfo *info)
{
- int ret = -1;
g_autoptr(virJSONValue) cmd = NULL;
g_autoptr(virJSONValue) reply = NULL;
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
- goto cleanup;
+ return -1;
if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0)
- goto cleanup;
-
- ret = qemuMonitorJSONExtractCurrentMachineInfo(reply, info);
+ return -1;
- cleanup:
- return ret;
+ return qemuMonitorJSONExtractCurrentMachineInfo(reply, info);
}