Function qemuMonitorJSONBuildCPUModelInfoJSON builds Json of form {"model": {"name": "IvyBridge", "props": {}}} from pointer to qemuMonitorCPUModelInfo. --- src/qemu/qemu_monitor_json.c | 49 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index cf31c16a0..320d4601e 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5337,6 +5337,55 @@ qemuMonitorJSONParseCPUModelProperty(const char *key, return 0; } +// model_json: {"model": {"name": "IvyBridge", "props": {}}} +static int +qemuMonitorJSONBuildCPUModelInfoJSON(qemuMonitorCPUModelInfoPtr model, + virJSONValuePtr *model_json) +{ + virJSONValuePtr cpu_props = NULL; + size_t i; + int ret = -1; + + *model_json = NULL; + + if (!(cpu_props = virJSONValueNewObject())) + goto cleanup; + + for (i = 0; i < model->nprops; i++) { + qemuMonitorCPUPropertyPtr prop = model->props + i; + + switch (prop->type) { + case QEMU_MONITOR_CPU_PROPERTY_BOOLEAN: + if (virJSONValueObjectAppendBoolean(cpu_props, prop->name, prop->value.boolean) < 0) + goto cleanup; + break; + + case QEMU_MONITOR_CPU_PROPERTY_STRING: + if (virJSONValueObjectAppendString(cpu_props, prop->name, prop->value.string) < 0) + goto cleanup; + break; + + case QEMU_MONITOR_CPU_PROPERTY_NUMBER: + if (virJSONValueObjectAppendNumberLong(cpu_props, prop->name, prop->value.number) < 0) + goto cleanup; + break; + + case QEMU_MONITOR_CPU_PROPERTY_LAST: + break; + } + } + + if (virJSONValueObjectCreate(model_json, "s:name", model->name, + "a:props", &cpu_props, NULL) < 0) + goto cleanup; + + ret = 0; + + cleanup: + + return ret; +} + // model_json: {"model": {"name": "IvyBridge", "props": {}}} static int qemuMonitorJSONBuildCPUModelInfo(virJSONValuePtr model_json, -- 2.14.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list