mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-02 01:45:17 +00:00
qemu: agent: Use virJSONValueObjectGetArray
Replace virJSONValueObjectGet + virJSONValueIsArray by the single API which returns only an array. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
1d05a04821
commit
66f0dd63b4
@ -1789,12 +1789,6 @@ qemuAgentGetFSInfoFillDisks(virJSONValue *jsondisks,
|
|||||||
size_t ndisks;
|
size_t ndisks;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (!virJSONValueIsArray(jsondisks)) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
||||||
_("Malformed guest-get-fsinfo 'disk' data array"));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ndisks = virJSONValueArraySize(jsondisks);
|
ndisks = virJSONValueArraySize(jsondisks);
|
||||||
|
|
||||||
if (ndisks)
|
if (ndisks)
|
||||||
@ -1846,15 +1840,9 @@ qemuAgentGetFSInfo(qemuAgent *agent,
|
|||||||
report_unsupported)) < 0)
|
report_unsupported)) < 0)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
if (!(data = virJSONValueObjectGet(reply, "return"))) {
|
if (!(data = virJSONValueObjectGetArray(reply, "return"))) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("guest-get-fsinfo reply was missing return data"));
|
_("guest-get-fsinfo reply was missing or not an array"));
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!virJSONValueIsArray(data)) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
||||||
_("Malformed guest-get-fsinfo data array"));
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1934,9 +1922,9 @@ qemuAgentGetFSInfo(qemuAgent *agent,
|
|||||||
info_ret[i]->total_bytes = -1;
|
info_ret[i]->total_bytes = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(disk = virJSONValueObjectGet(entry, "disk"))) {
|
if (!(disk = virJSONValueObjectGetArray(entry, "disk"))) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("'disk' missing in reply of guest-get-fsinfo"));
|
_("'disk' missing or not an array in reply of guest-get-fsinfo"));
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2067,16 +2055,9 @@ qemuAgentGetInterfaceAddresses(virDomainInterfacePtr **ifaces_ret,
|
|||||||
|
|
||||||
/* as well as IP address which - moreover -
|
/* as well as IP address which - moreover -
|
||||||
* can be presented multiple times */
|
* can be presented multiple times */
|
||||||
ip_addr_arr = virJSONValueObjectGet(iface_obj, "ip-addresses");
|
if (!(ip_addr_arr = virJSONValueObjectGetArray(iface_obj, "ip-addresses")))
|
||||||
if (!ip_addr_arr)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (!virJSONValueIsArray(ip_addr_arr)) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
|
||||||
_("Malformed ip-addresses array"));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If current iface already exists, continue with the count */
|
/* If current iface already exists, continue with the count */
|
||||||
addrs_count = iface->naddrs;
|
addrs_count = iface->naddrs;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user