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);
qemuMonitorMessage msg;
char *cmdstr = NULL;
char *id = NULL;
- virJSONValuePtr exe;
*reply = NULL;
memset(&msg, 0, sizeof(msg));
- exe = virJSONValueObjectGet(cmd, "execute");
- if (exe) {
+ if (virJSONValueObjectHasKey(cmd, "execute") == 1) {
if (!(id = qemuMonitorNextCommandID(mon)))
goto cleanup;
if (virJSONValueObjectAppendString(cmd, "id", id) < 0) {
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;
}
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;
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"));
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;
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;
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");
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;
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;
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) {
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"));
bstats = NULL;
if (backingChain &&
- (backing = virJSONValueObjectGet(dev, "backing")) &&
+ (backing = virJSONValueObjectGetObject(dev, "backing")) &&
qemuMonitorJSONGetOneBlockStatsInfo(backing, dev_name, depth + 1,
hash, true) < 0)
goto cleanup;
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;
bstats->physical = bstats->capacity;
if (backingChain &&
- (backing = virJSONValueObjectGet(image, "backing-image"))) {
+ (backing = virJSONValueObjectGetObject(image, "backing-image"))) {
ret = qemuMonitorJSONBlockStatsUpdateCapacityOne(backing,
dev_name,
depth + 1,
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;
}
/* 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,
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;
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;
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"));
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);
}
}
- virJSONValuePtr comp = virJSONValueObjectGet(ret, "xbzrle-cache");
+ virJSONValuePtr comp = virJSONValueObjectGetObject(ret, "xbzrle-cache");
if (comp) {
status->xbzrle_set = true;
rc = virJSONValueObjectGetNumberUlong(comp, "cache-size",
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;
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;
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"));
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;
if (!top || !image)
return NULL;
if (top != target) {
- backing = virJSONValueObjectGet(image, "backing-image");
+ backing = virJSONValueObjectGetObject(image, "backing-image");
return qemuMonitorJSONDiskNameLookupOne(backing, top->backingStore,
target);
}
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;
}
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;
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"));
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;
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"));
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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"));
ret = -1;
- if (!(data = virJSONValueObjectGet(reply, "return"))) {
+ if (!(data = virJSONValueObjectGetArray(reply, "return"))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("%s reply was missing return data"),
qmpCmd);
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;
if (qemuMonitorJSONCheckError(cmd, reply))
goto cleanup;
- data = virJSONValueObjectGet(reply, "return");
+ data = virJSONValueObjectGetArray(reply, "return");
if ((n = virJSONValueArraySize(data)) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
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;
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;
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;
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"));