}
+static virJSONValuePtr
+qemuMonitorJSONGetBlockDev(virJSONValuePtr devices,
+ size_t idx)
+{
+ virJSONValuePtr dev = virJSONValueArrayGet(devices, idx);
+
+ if (!dev || dev->type != VIR_JSON_TYPE_OBJECT) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("query-block device entry was not in expected format"));
+ return NULL;
+ }
+ return dev;
+}
+
+
int qemuMonitorJSONGetBlockInfo(qemuMonitorPtr mon,
virHashTablePtr table)
{
return -1;
for (i = 0; i < virJSONValueArraySize(devices); i++) {
- virJSONValuePtr dev = virJSONValueArrayGet(devices, i);
+ virJSONValuePtr dev;
struct qemuDomainDiskInfo *info;
const char *thisdev;
const char *status;
- if (!dev || dev->type != VIR_JSON_TYPE_OBJECT) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("block info device entry was not in expected format"));
+ if (!(dev = qemuMonitorJSONGetBlockDev(devices, i)))
goto cleanup;
- }
if ((thisdev = virJSONValueObjectGetString(dev, "device")) == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
return -1;
for (i = 0; i < virJSONValueArraySize(devices); i++) {
- virJSONValuePtr dev = virJSONValueArrayGet(devices, i);
+ virJSONValuePtr dev;
virJSONValuePtr inserted;
virJSONValuePtr image;
const char *dev_name;
- if (!dev || dev->type != VIR_JSON_TYPE_OBJECT) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("query-block device entry was not "
- "in expected format"));
+ if (!(dev = qemuMonitorJSONGetBlockDev(devices, i)))
goto cleanup;
- }
if (!(dev_name = virJSONValueObjectGetString(dev, "device"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
return NULL;
for (i = 0; i < virJSONValueArraySize(devices); i++) {
- virJSONValuePtr dev = virJSONValueArrayGet(devices, i);
+ virJSONValuePtr dev;
virJSONValuePtr inserted;
virJSONValuePtr image;
const char *thisdev;
- if (!dev || dev->type != VIR_JSON_TYPE_OBJECT) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("block info device entry was not in expected format"));
+ if (!(dev = qemuMonitorJSONGetBlockDev(devices, i)))
goto cleanup;
- }
if (!(thisdev = virJSONValueObjectGetString(dev, "device"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",