qemuMonitorJSONGetCPUModelExpansion: refactor parsing functions

Refactor the CPU Model parsing functions within
qemuMonitorJSONGetCPUModelExpansion.  The new functions,
qemuMonitorJSONParseCPUModelExpansionData and
qemuMonitorJSONParseCPUModelExpansion invoke the functions they
replace and leave room for a subsequent patch to handle parsing the
(optional) deprecated_props field resulting from the command.

Signed-off-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
Collin Walling 2024-12-16 18:03:52 -05:00 committed by Jiri Denemark
parent 2d222ecf6e
commit 60e407deb5

View File

@ -5100,6 +5100,37 @@ qemuMonitorJSONParseCPUModel(const char *cpu_name,
}
static int
qemuMonitorJSONParseCPUModelExpansionData(virJSONValue *data,
bool fail_no_props,
virJSONValue **cpu_model,
virJSONValue **cpu_props,
const char **cpu_name)
{
if (qemuMonitorJSONParseCPUModelData(data, "query-cpu-model-expansion",
fail_no_props, cpu_model, cpu_props,
cpu_name) < 0)
return -1;
return 0;
}
static int
qemuMonitorJSONParseCPUModelExpansion(const char *cpu_name,
virJSONValue *cpu_props,
qemuMonitorCPUModelInfo **model_info)
{
g_autoptr(qemuMonitorCPUModelInfo) expanded_model = NULL;
if (qemuMonitorJSONParseCPUModel(cpu_name, cpu_props, &expanded_model) < 0)
return -1;
*model_info = g_steal_pointer(&expanded_model);
return 0;
}
static int
qemuMonitorJSONQueryCPUModelExpansionOne(qemuMonitor *mon,
qemuMonitorCPUModelExpansionType type,
@ -5170,8 +5201,8 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitor *mon,
if ((rc = qemuMonitorJSONQueryCPUModelExpansionOne(mon, type, &model, &data)) <= 0)
return rc;
if (qemuMonitorJSONParseCPUModelData(data, "query-cpu-model-expansion",
fail_no_props, &cpu_model, &cpu_props,
if (qemuMonitorJSONParseCPUModelExpansionData(data, fail_no_props,
&cpu_model, &cpu_props,
&cpu_name) < 0)
return -1;
@ -5188,13 +5219,14 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitor *mon,
if ((rc = qemuMonitorJSONQueryCPUModelExpansionOne(mon, type, &fullModel, &fullData)) <= 0)
return rc;
if (qemuMonitorJSONParseCPUModelData(fullData, "query-cpu-model-expansion",
fail_no_props, &cpu_model, &cpu_props,
if (qemuMonitorJSONParseCPUModelExpansionData(fullData, fail_no_props,
&cpu_model, &cpu_props,
&cpu_name) < 0)
return -1;
}
return qemuMonitorJSONParseCPUModel(cpu_name, cpu_props, model_info);
return qemuMonitorJSONParseCPUModelExpansion(cpu_name, cpu_props,
model_info);
}