Rather than grabbing an arbitrary JSON value and then checking
if it has the right type, we might as well request the correct
type to begin with.
* src/qemu/qemu_monitor_json.c (qemuMonitorJSONIOProcessEvent)
(qemuMonitorJSONCommandWithFd, qemuMonitorJSONHandleGraphics)
(qemuMonitorJSONGetStatus, qemuMonitorJSONExtractCPUInfo)
(qemuMonitorJSONGetVirtType, qemuMonitorJSONGetBalloonInfo)
(qemuMonitorJSONGetMemoryStats)
(qemuMonitorJSONDevGetBlockExtent)
(qemuMonitorJSONGetOneBlockStatsInfo)
(qemuMonitorJSONGetAllBlockStatsInfo)
(qemuMonitorJSONBlockStatsUpdateCapacityOne)
(qemuMonitorJSONBlockStatsUpdateCapacity)
(qemuMonitorJSONGetBlockExtent)
(qemuMonitorJSONGetMigrationStatusReply)
(qemuMonitorJSONGetDumpGuestMemoryCapability)
(qemuMonitorJSONAddFd, qemuMonitorJSONQueryRxFilterParse)
(qemuMonitorJSONExtractChardevInfo)
(qemuMonitorJSONDiskNameLookupOne)
(qemuMonitorJSONDiskNameLookup)
(qemuMonitorJSONGetAllBlockJobInfo)
(qemuMonitorJSONBlockIoThrottleInfo, qemuMonitorJSONGetVersion)
(qemuMonitorJSONGetMachines, qemuMonitorJSONGetCPUDefinitions)
(qemuMonitorJSONGetCommands, qemuMonitorJSONGetEvents)
(qemuMonitorJSONGetKVMState, qemuMonitorJSONGetObjectTypes)
(qemuMonitorJSONGetObjectListPaths)
(qemuMonitorJSONGetObjectProps, qemuMonitorJSONGetTargetArch)
(qemuMonitorJSONGetMigrationCapabilities)
(qemuMonitorJSONGetStringArray, qemuMonitorJSONAttachCharDev)
(qemuMonitorJSONGetCPUx86Data, qemuMonitorJSONGetIOThreads)
(qemuMonitorJSONGetMemoryDeviceInfo): Use shorter idioms.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
src/qemu/qemu_monitor_json.c | 164 ++++++++++++++++---------------------------
1 file changed, 61 insertions(+), 103 deletions(-)
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 0ba549e..a530b53 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -154,12 +154,10 @@ qemuMonitorJSONIOProcessEvent(qemuMonitorPtr mon,
if ((data = virJSONValueObjectGet(obj, "data")))
details = virJSONValueToString(data, false);
if ((timestamp = virJSONValueObjectGet(obj, "timestamp"))) {
- virJSONValuePtr elt;
-
- if ((elt = virJSONValueObjectGet(timestamp, "seconds")))
- ignore_value(virJSONValueGetNumberLong(elt, &seconds));
- if ((elt = virJSONValueObjectGet(timestamp, "microseconds")))
- ignore_value(virJSONValueGetNumberUint(elt, µs));
+ ignore_value(virJSONValueObjectGetNumberLong(timestamp, "seconds",
+ &seconds));
+ ignore_value(virJSONValueObjectGetNumberUint(timestamp,
"microseconds",
+ µs));
}
qemuMonitorEmitEvent(mon, type, seconds, micros, details);
VIR_FREE(details);
@@ -271,7 +269,7 @@ qemuMonitorJSONCommandWithFd(qemuMonitorPtr mon,
memset(&msg, 0, sizeof(msg));
- exe = virJSONValueObjectGet(cmd, "execute");
+ exe = virJSONValueObjectGetObject(cmd, "execute");
if (exe) {
if (!(id = qemuMonitorNextCommandID(mon)))
goto cleanup;
@@ -630,11 +628,11 @@ static void qemuMonitorJSONHandleGraphics(qemuMonitorPtr mon,
virJSONValuePtr da
virJSONValuePtr client;
virJSONValuePtr server;
- if (!(client = virJSONValueObjectGet(data, "client"))) {
+ if (!(client = virJSONValueObjectGetObject(data, "client"))) {
VIR_WARN("missing client info in VNC event");
return;
}
- if (!(server = virJSONValueObjectGet(data, "server"))) {
+ if (!(server = virJSONValueObjectGetObject(data, "server"))) {
VIR_WARN("missing server info in VNC event");
return;
}
@@ -1080,7 +1078,7 @@ qemuMonitorJSONGetStatus(qemuMonitorPtr mon,
ret = -1;
- if (!(data = virJSONValueObjectGet(reply, "return"))) {
+ if (!(data = virJSONValueObjectGetObject(reply, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("query-status reply was missing return data"));
goto cleanup;
@@ -1183,18 +1181,12 @@ qemuMonitorJSONExtractCPUInfo(virJSONValuePtr reply,
int *threads = NULL;
int ncpus;
- if (!(data = virJSONValueObjectGet(reply, "return"))) {
+ if (!(data = virJSONValueObjectGetArray(reply, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cpu reply was missing return data"));
goto cleanup;
}
- if (data->type != VIR_JSON_TYPE_ARRAY) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("cpu information was not an array"));
- goto cleanup;
- }
-
if ((ncpus = virJSONValueArraySize(data)) <= 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cpu information was empty"));
@@ -1282,7 +1274,7 @@ int qemuMonitorJSONGetVirtType(qemuMonitorPtr mon,
virJSONValuePtr data;
bool val = false;
- if (!(data = virJSONValueObjectGet(reply, "return"))) {
+ if (!(data = virJSONValueObjectGetObject(reply, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("info kvm reply was missing return data"));
ret = -1;
@@ -1405,7 +1397,7 @@ qemuMonitorJSONGetBalloonInfo(qemuMonitorPtr mon,
virJSONValuePtr data;
unsigned long long mem;
- if (!(data = virJSONValueObjectGet(reply, "return"))) {
+ if (!(data = virJSONValueObjectGetObject(reply, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("info balloon reply was missing return
data"));
ret = -1;
@@ -1500,7 +1492,7 @@ int qemuMonitorJSONGetMemoryStats(qemuMonitorPtr mon,
if ((ret = qemuMonitorJSONCommand(mon, cmd, &reply)) < 0)
goto cleanup;
- if ((data = virJSONValueObjectGet(reply, "error"))) {
+ if ((data = virJSONValueObjectGetObject(reply, "error"))) {
const char *klass = virJSONValueObjectGetString(data, "class");
const char *desc = virJSONValueObjectGetString(data, "desc");
@@ -1515,7 +1507,7 @@ int qemuMonitorJSONGetMemoryStats(qemuMonitorPtr mon,
if ((ret = qemuMonitorJSONCheckError(cmd, reply)) < 0)
goto cleanup;
- if (!(data = virJSONValueObjectGet(reply, "return"))) {
+ if (!(data = virJSONValueObjectGetObject(reply, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("qom-get reply was missing return data"));
goto cleanup;
@@ -1598,8 +1590,7 @@ int qemuMonitorJSONGetBlockInfo(qemuMonitorPtr mon,
ret = -1;
- devices = virJSONValueObjectGet(reply, "return");
- if (!devices || devices->type != VIR_JSON_TYPE_ARRAY) {
+ if (!(devices = virJSONValueObjectGetArray(reply, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("block info reply was missing device list"));
goto cleanup;
@@ -1686,15 +1677,11 @@ qemuMonitorJSONDevGetBlockExtent(virJSONValuePtr dev,
virJSONValuePtr stats;
virJSONValuePtr parent;
- if ((parent = virJSONValueObjectGet(dev, "parent")) == NULL ||
- parent->type != VIR_JSON_TYPE_OBJECT) {
+ if ((parent = virJSONValueObjectGetObject(dev, "parent")) == NULL)
return QEMU_MONITOR_BLOCK_EXTENT_ERROR_NOPARENT;
- }
- if ((stats = virJSONValueObjectGet(parent, "stats")) == NULL ||
- stats->type != VIR_JSON_TYPE_OBJECT) {
+ if ((stats = virJSONValueObjectGetObject(parent, "stats")) == NULL)
return QEMU_MONITOR_BLOCK_EXTENT_ERROR_NOSTATS;
- }
if (virJSONValueObjectGetNumberUlong(stats, "wr_highest_offset",
extent) < 0) {
@@ -1724,8 +1711,7 @@ qemuMonitorJSONGetOneBlockStatsInfo(virJSONValuePtr dev,
if (VIR_ALLOC(bstats) < 0)
goto cleanup;
- if ((stats = virJSONValueObjectGet(dev, "stats")) == NULL ||
- stats->type != VIR_JSON_TYPE_OBJECT) {
+ if ((stats = virJSONValueObjectGetObject(dev, "stats")) == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("blockstats stats entry was not "
"in expected format"));
@@ -1759,7 +1745,7 @@ qemuMonitorJSONGetOneBlockStatsInfo(virJSONValuePtr dev,
bstats = NULL;
if (backingChain &&
- (backing = virJSONValueObjectGet(dev, "backing")) &&
+ (backing = virJSONValueObjectGetObject(dev, "backing")) &&
qemuMonitorJSONGetOneBlockStatsInfo(backing, dev_name, depth + 1,
hash, true) < 0)
goto cleanup;
@@ -1794,8 +1780,7 @@ qemuMonitorJSONGetAllBlockStatsInfo(qemuMonitorPtr mon,
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
goto cleanup;
- devices = virJSONValueObjectGet(reply, "return");
- if (!devices || devices->type != VIR_JSON_TYPE_ARRAY) {
+ if (!(devices = virJSONValueObjectGetArray(reply, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("blockstats reply was missing device list"));
goto cleanup;
@@ -1873,7 +1858,7 @@ qemuMonitorJSONBlockStatsUpdateCapacityOne(virJSONValuePtr image,
bstats->physical = bstats->capacity;
if (backingChain &&
- (backing = virJSONValueObjectGet(image, "backing-image"))) {
+ (backing = virJSONValueObjectGetObject(image, "backing-image"))) {
ret = qemuMonitorJSONBlockStatsUpdateCapacityOne(backing,
dev_name,
depth + 1,
@@ -1908,8 +1893,7 @@ qemuMonitorJSONBlockStatsUpdateCapacity(qemuMonitorPtr mon,
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
goto cleanup;
- devices = virJSONValueObjectGet(reply, "return");
- if (!devices || devices->type != VIR_JSON_TYPE_ARRAY) {
+ if (!(devices = virJSONValueObjectGetArray(reply, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("query-block reply was missing device list"));
goto cleanup;
@@ -1936,8 +1920,8 @@ qemuMonitorJSONBlockStatsUpdateCapacity(qemuMonitorPtr mon,
}
/* drive may be empty */
- if (!(inserted = virJSONValueObjectGet(dev, "inserted")) ||
- !(image = virJSONValueObjectGet(inserted, "image")))
+ if (!(inserted = virJSONValueObjectGetObject(dev, "inserted")) ||
+ !(image = virJSONValueObjectGetObject(inserted, "image")))
continue;
if (qemuMonitorJSONBlockStatsUpdateCapacityOne(image, dev_name, 0,
@@ -2010,8 +1994,7 @@ int qemuMonitorJSONGetBlockExtent(qemuMonitorPtr mon,
goto cleanup;
ret = -1;
- devices = virJSONValueObjectGet(reply, "return");
- if (!devices || devices->type != VIR_JSON_TYPE_ARRAY) {
+ if (!(devices = virJSONValueObjectGetArray(reply, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("blockstats reply was missing device list"));
goto cleanup;
@@ -2483,7 +2466,7 @@ qemuMonitorJSONGetMigrationStatusReply(virJSONValuePtr reply,
int rc;
double mbps;
- if (!(ret = virJSONValueObjectGet(reply, "return"))) {
+ if (!(ret = virJSONValueObjectGetObject(reply, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("info migration reply was missing return data"));
return -1;
@@ -2521,7 +2504,7 @@ qemuMonitorJSONGetMigrationStatusReply(virJSONValuePtr reply,
if (status->status == QEMU_MONITOR_MIGRATION_STATUS_ACTIVE ||
status->status == QEMU_MONITOR_MIGRATION_STATUS_CANCELLING ||
status->status == QEMU_MONITOR_MIGRATION_STATUS_COMPLETED) {
- virJSONValuePtr ram = virJSONValueObjectGet(ret, "ram");
+ virJSONValuePtr ram = virJSONValueObjectGetObject(ret, "ram");
if (!ram) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("migration was active, but no RAM info was
set"));
@@ -2564,7 +2547,7 @@ qemuMonitorJSONGetMigrationStatusReply(virJSONValuePtr reply,
ignore_value(virJSONValueObjectGetNumberUlong(ram, "normal-bytes",
&status->ram_normal_bytes));
- virJSONValuePtr disk = virJSONValueObjectGet(ret, "disk");
+ virJSONValuePtr disk = virJSONValueObjectGetObject(ret, "disk");
if (disk) {
rc = virJSONValueObjectGetNumberUlong(disk, "transferred",
&status->disk_transferred);
@@ -2600,7 +2583,7 @@ qemuMonitorJSONGetMigrationStatusReply(virJSONValuePtr reply,
}
}
- virJSONValuePtr comp = virJSONValueObjectGet(ret, "xbzrle-cache");
+ virJSONValuePtr comp = virJSONValueObjectGetObject(ret,
"xbzrle-cache");
if (comp) {
status->xbzrle_set = true;
rc = virJSONValueObjectGetNumberUlong(comp, "cache-size",
@@ -2757,15 +2740,13 @@ qemuMonitorJSONGetDumpGuestMemoryCapability(qemuMonitorPtr mon,
ret = -1;
- caps = virJSONValueObjectGet(reply, "return");
- if (!caps || caps->type != VIR_JSON_TYPE_OBJECT) {
+ if (!(caps = virJSONValueObjectGetObject(reply, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("missing dump guest memory capabilities"));
goto cleanup;
}
- formats = virJSONValueObjectGet(caps, "formats");
- if (!formats || formats->type != VIR_JSON_TYPE_ARRAY) {
+ if (!(formats = virJSONValueObjectGetArray(caps, "formats"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("missing supported dump formats"));
goto cleanup;
@@ -2999,16 +2980,14 @@ qemuMonitorJSONAddFd(qemuMonitorPtr mon, int fdset, int fd, const
char *name)
ret = qemuMonitorJSONCheckError(cmd, reply);
}
if (ret == 0) {
- virJSONValuePtr data = virJSONValueObjectGet(reply, "return");
+ virJSONValuePtr data = virJSONValueObjectGetObject(reply, "return");
- if (!data || data->type != VIR_JSON_TYPE_OBJECT) {
+ if (!data) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("missing return information"));
goto error;
}
- data = virJSONValueObjectGet(data, "fd");
- if (!data || data->type != VIR_JSON_TYPE_NUMBER ||
- virJSONValueGetNumberInt(data, &ret) < 0) {
+ if (virJSONValueObjectGetNumberInt(data, "fd", &ret) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("incomplete return information"));
goto error;
@@ -3122,16 +3101,11 @@ qemuMonitorJSONQueryRxFilterParse(virJSONValuePtr msg,
if (!fil)
goto cleanup;
- if (!(returnArray = virJSONValueObjectGet(msg, "return"))) {
+ if (!(returnArray = virJSONValueObjectGetArray(msg, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("query-rx-filter reply was missing return data"));
goto cleanup;
}
- if (returnArray->type != VIR_JSON_TYPE_ARRAY) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("query-rx-filter return data was not an array"));
- goto cleanup;
- }
if (!(entry = virJSONValueArrayGet(returnArray, 0))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("query -rx-filter return data missing array
element"));
@@ -3342,18 +3316,12 @@ qemuMonitorJSONExtractChardevInfo(virJSONValuePtr reply,
size_t i;
qemuMonitorChardevInfoPtr entry = NULL;
- if (!(data = virJSONValueObjectGet(reply, "return"))) {
+ if (!(data = virJSONValueObjectGetArray(reply, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("character device reply was missing return data"));
goto cleanup;
}
- if (data->type != VIR_JSON_TYPE_ARRAY) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("character device information was not an array"));
- goto cleanup;
- }
-
for (i = 0; i < virJSONValueArraySize(data); i++) {
virJSONValuePtr chardev = virJSONValueArrayGet(data, i);
const char *type;
@@ -3849,7 +3817,7 @@ qemuMonitorJSONDiskNameLookupOne(virJSONValuePtr image,
if (!top || !image)
return NULL;
if (top != target) {
- backing = virJSONValueObjectGet(image, "backing-image");
+ backing = virJSONValueObjectGetObject(image, "backing-image");
return qemuMonitorJSONDiskNameLookupOne(backing, top->backingStore,
target);
}
@@ -3887,8 +3855,7 @@ qemuMonitorJSONDiskNameLookup(qemuMonitorPtr mon,
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
goto cleanup;
- devices = virJSONValueObjectGet(reply, "return");
- if (!devices || devices->type != VIR_JSON_TYPE_ARRAY) {
+ if (!(devices = virJSONValueObjectGetArray(reply, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("block info reply was missing device list"));
goto cleanup;
@@ -3913,8 +3880,8 @@ qemuMonitorJSONDiskNameLookup(qemuMonitorPtr mon,
}
if (STREQ(thisdev, device)) {
- if ((inserted = virJSONValueObjectGet(dev, "inserted")) &&
- (image = virJSONValueObjectGet(inserted, "image"))) {
+ if ((inserted = virJSONValueObjectGetObject(dev, "inserted"))
&&
+ (image = virJSONValueObjectGetObject(inserted, "image"))) {
ret = qemuMonitorJSONDiskNameLookupOne(image, top, target);
}
break;
@@ -4159,18 +4126,12 @@ qemuMonitorJSONGetAllBlockJobInfo(qemuMonitorPtr mon)
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
goto cleanup;
- if ((data = virJSONValueObjectGet(reply, "return")) == NULL) {
+ if ((data = virJSONValueObjectGetArray(reply, "return")) == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("reply was missing return data"));
goto cleanup;
}
- if (data->type != VIR_JSON_TYPE_ARRAY) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("unrecognized format of block job information"));
- goto cleanup;
- }
-
if ((nr_results = virJSONValueArraySize(data)) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("unable to determine array size"));
@@ -4390,9 +4351,7 @@ qemuMonitorJSONBlockIoThrottleInfo(virJSONValuePtr result,
size_t i;
bool found = false;
- io_throttle = virJSONValueObjectGet(result, "return");
-
- if (!io_throttle || io_throttle->type != VIR_JSON_TYPE_ARRAY) {
+ if (!(io_throttle = virJSONValueObjectGetArray(result, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_(" block_io_throttle reply was missing device list"));
goto cleanup;
@@ -4421,8 +4380,7 @@ qemuMonitorJSONBlockIoThrottleInfo(virJSONValuePtr result,
continue;
found = true;
- if ((inserted = virJSONValueObjectGet(temp_dev, "inserted")) == NULL
||
- inserted->type != VIR_JSON_TYPE_OBJECT) {
+ if (!(inserted = virJSONValueObjectGetObject(temp_dev, "inserted"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("block_io_throttle inserted entry "
"was not in expected format"));
@@ -4609,13 +4567,13 @@ int qemuMonitorJSONGetVersion(qemuMonitorPtr mon,
ret = -1;
- if (!(data = virJSONValueObjectGet(reply, "return"))) {
+ if (!(data = virJSONValueObjectGetObject(reply, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("query-version reply was missing 'return'
data"));
goto cleanup;
}
- if (!(qemu = virJSONValueObjectGet(data, "qemu"))) {
+ if (!(qemu = virJSONValueObjectGetObject(data, "qemu"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("query-version reply was missing 'qemu'
data"));
goto cleanup;
@@ -4683,7 +4641,7 @@ int qemuMonitorJSONGetMachines(qemuMonitorPtr mon,
ret = -1;
- if (!(data = virJSONValueObjectGet(reply, "return"))) {
+ if (!(data = virJSONValueObjectGetArray(reply, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("query-machines reply was missing return data"));
goto cleanup;
@@ -4795,7 +4753,7 @@ int qemuMonitorJSONGetCPUDefinitions(qemuMonitorPtr mon,
ret = -1;
- if (!(data = virJSONValueObjectGet(reply, "return"))) {
+ if (!(data = virJSONValueObjectGetArray(reply, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("query-cpu-definitions reply was missing return
data"));
goto cleanup;
@@ -4863,7 +4821,7 @@ int qemuMonitorJSONGetCommands(qemuMonitorPtr mon,
ret = -1;
- if (!(data = virJSONValueObjectGet(reply, "return"))) {
+ if (!(data = virJSONValueObjectGetArray(reply, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("query-commands reply was missing return data"));
goto cleanup;
@@ -4936,7 +4894,7 @@ int qemuMonitorJSONGetEvents(qemuMonitorPtr mon,
ret = -1;
- if (!(data = virJSONValueObjectGet(reply, "return"))) {
+ if (!(data = virJSONValueObjectGetArray(reply, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("query-events reply was missing return data"));
goto cleanup;
@@ -5131,7 +5089,7 @@ int qemuMonitorJSONGetKVMState(qemuMonitorPtr mon,
ret = -1;
- if (!(data = virJSONValueObjectGet(reply, "return"))) {
+ if (!(data = virJSONValueObjectGetObject(reply, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("query-kvm reply was missing return data"));
goto cleanup;
@@ -5179,7 +5137,7 @@ int qemuMonitorJSONGetObjectTypes(qemuMonitorPtr mon,
ret = -1;
- if (!(data = virJSONValueObjectGet(reply, "return"))) {
+ if (!(data = virJSONValueObjectGetArray(reply, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("qom-list-types reply was missing return data"));
goto cleanup;
@@ -5250,7 +5208,7 @@ int qemuMonitorJSONGetObjectListPaths(qemuMonitorPtr mon,
ret = -1;
- if (!(data = virJSONValueObjectGet(reply, "return"))) {
+ if (!(data = virJSONValueObjectGetArray(reply, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("qom-list reply was missing return data"));
goto cleanup;
@@ -5501,7 +5459,7 @@ int qemuMonitorJSONGetObjectProps(qemuMonitorPtr mon,
ret = -1;
- if (!(data = virJSONValueObjectGet(reply, "return"))) {
+ if (!(data = virJSONValueObjectGetArray(reply, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("device-list-properties reply was missing return
data"));
goto cleanup;
@@ -5564,7 +5522,7 @@ qemuMonitorJSONGetTargetArch(qemuMonitorPtr mon)
if (rv < 0)
goto cleanup;
- if (!(data = virJSONValueObjectGet(reply, "return"))) {
+ if (!(data = virJSONValueObjectGetObject(reply, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("query-target reply was missing return data"));
goto cleanup;
@@ -5616,7 +5574,7 @@ qemuMonitorJSONGetMigrationCapabilities(qemuMonitorPtr mon,
ret = -1;
- if (!(caps = virJSONValueObjectGet(reply, "return")) ||
+ if (!(caps = virJSONValueObjectGetArray(reply, "return")) ||
(n = virJSONValueArraySize(caps)) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("missing migration capabilities"));
@@ -5894,7 +5852,7 @@ qemuMonitorJSONGetStringArray(qemuMonitorPtr mon, const char
*qmpCmd,
ret = -1;
- if (!(data = virJSONValueObjectGet(reply, "return"))) {
+ if (!(data = virJSONValueObjectGetArray(reply, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("%s reply was missing return data"),
qmpCmd);
@@ -6092,7 +6050,7 @@ qemuMonitorJSONAttachCharDev(qemuMonitorPtr mon,
virJSONValuePtr data;
const char *path;
- if (!(data = virJSONValueObjectGet(reply, "return"))) {
+ if (!(data = virJSONValueObjectGetObject(reply, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("chardev-add reply was missing return data"));
goto cleanup;
@@ -6260,7 +6218,7 @@ qemuMonitorJSONGetCPUx86Data(qemuMonitorPtr mon,
if (qemuMonitorJSONCheckError(cmd, reply))
goto cleanup;
- data = virJSONValueObjectGet(reply, "return");
+ data = virJSONValueObjectGetArray(reply, "return");
if ((n = virJSONValueArraySize(data)) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -6297,7 +6255,7 @@ qemuMonitorJSONGetCPUx86Data(qemuMonitorPtr mon,
if (qemuMonitorJSONCheckError(cmd, reply))
goto cleanup;
- if (!(data = virJSONValueObjectGet(reply, "return"))) {
+ if (!(data = virJSONValueObjectGetArray(reply, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("qom-get reply was missing return data"));
goto cleanup;
@@ -6416,7 +6374,7 @@ qemuMonitorJSONGetIOThreads(qemuMonitorPtr mon,
ret = -1;
- if (!(data = virJSONValueObjectGet(reply, "return"))) {
+ if (!(data = virJSONValueObjectGetArray(reply, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("query-iothreads reply was missing return data"));
goto cleanup;
@@ -6514,7 +6472,7 @@ qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitorPtr mon,
ret = -1;
- if (!(data = virJSONValueObjectGet(reply, "return"))) {
+ if (!(data = virJSONValueObjectGetArray(reply, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("query-memory-devices reply was missing return
data"));
goto cleanup;
@@ -6542,7 +6500,7 @@ qemuMonitorJSONGetMemoryDeviceInfo(qemuMonitorPtr mon,
virJSONValuePtr dimminfo;
const char *devalias;
- if (!(dimminfo = virJSONValueObjectGet(elem, "data"))) {
+ if (!(dimminfo = virJSONValueObjectGetObject(elem, "data"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("query-memory-devices reply data doesn't
"
"contain enum data"));
--
2.4.3