return qemuMonitorJSONGetRTCTime(mon, tm);
}
+
+
+virHashTablePtr
+qemuMonitorQueryQMPSchema(qemuMonitorPtr mon)
+{
+ VIR_DEBUG("mon=%p", mon);
+
+ QEMU_CHECK_MONITOR_JSON_NULL(mon);
+
+ return qemuMonitorJSONQueryQMPSchema(mon);
+}
virJSONValueFree(reply);
return ret;
}
+
+
+static int
+qemuMonitorJSONFillQMPSchema(size_t pos ATTRIBUTE_UNUSED,
+ virJSONValuePtr item,
+ void *opaque)
+{
+ const char *name;
+ virHashTablePtr schema = opaque;
+
+ if (!(name = virJSONValueObjectGetString(item, "name"))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("malformed QMP schema"));
+ return -1;
+ }
+
+ if (virHashAddEntry(schema, name, item) < 0)
+ return -1;
+
+ return 0;
+}
+
+
+static void
+qemuMonitorJSONFreeSchemaEntry(void *opaque,
+ const void *name ATTRIBUTE_UNUSED)
+{
+ virJSONValueFree(opaque);
+}
+
+
+virHashTablePtr
+qemuMonitorJSONQueryQMPSchema(qemuMonitorPtr mon)
+{
+ virJSONValuePtr cmd;
+ virJSONValuePtr reply = NULL;
+ virJSONValuePtr arr;
+ virHashTablePtr schema = NULL;
+ virHashTablePtr ret = NULL;
+
+ if (!(cmd = qemuMonitorJSONMakeCommand("query-qmp-schema", NULL)))
+ return NULL;
+
+ if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
+ goto cleanup;
+
+ if (qemuMonitorJSONCheckError(cmd, reply) < 0)
+ goto cleanup;
+
+ arr = virJSONValueObjectGet(reply, "return");
+
+ if (!(schema = virHashCreate(512, qemuMonitorJSONFreeSchemaEntry)))
+ goto cleanup;
+
+ if (virJSONValueArrayForeachSteal(arr, qemuMonitorJSONFillQMPSchema,
+ schema) < 0)
+ goto cleanup;
+
+ VIR_STEAL_PTR(ret, schema);
+
+ cleanup:
+ virJSONValueFree(cmd);
+ virJSONValueFree(reply);
+ virHashFree(schema);
+
+ return ret;
+}