qemu_monitor: expansion cleanups
With refactoring most of the expansion function, let's take care of some additional cleanups. Signed-off-by: Collin Walling <walling@linux.ibm.com> Message-Id: <1568924706-2311-3-git-send-email-walling@linux.ibm.com> Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
3bfa3f11e6
commit
0a0be9b34d
@ -5780,20 +5780,19 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitorPtr mon,
|
|||||||
bool migratable,
|
bool migratable,
|
||||||
qemuMonitorCPUModelInfoPtr *model_info)
|
qemuMonitorCPUModelInfoPtr *model_info)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
VIR_AUTOPTR(virJSONValue) model = NULL;
|
||||||
virJSONValuePtr model = NULL;
|
VIR_AUTOPTR(virJSONValue) cmd = NULL;
|
||||||
virJSONValuePtr cmd = NULL;
|
VIR_AUTOPTR(virJSONValue) reply = NULL;
|
||||||
virJSONValuePtr reply = NULL;
|
|
||||||
virJSONValuePtr data;
|
virJSONValuePtr data;
|
||||||
virJSONValuePtr cpu_model;
|
virJSONValuePtr cpu_model;
|
||||||
virJSONValuePtr cpu_props;
|
virJSONValuePtr cpu_props = NULL;
|
||||||
char const *cpu_name;
|
const char *cpu_name = "";
|
||||||
const char *typeStr = "";
|
const char *typeStr = "";
|
||||||
|
|
||||||
*model_info = NULL;
|
*model_info = NULL;
|
||||||
|
|
||||||
if (!(model = qemuMonitorJSONMakeCPUModel(model_name, migratable)))
|
if (!(model = qemuMonitorJSONMakeCPUModel(model_name, migratable)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
retry:
|
retry:
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@ -5811,35 +5810,33 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitorPtr mon,
|
|||||||
"s:type", typeStr,
|
"s:type", typeStr,
|
||||||
"a:model", &model,
|
"a:model", &model,
|
||||||
NULL)))
|
NULL)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
|
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
/* Even though query-cpu-model-expansion is advertised by query-commands it
|
/* Even though query-cpu-model-expansion is advertised by query-commands it
|
||||||
* may just return GenericError if it is not implemented for the requested
|
* may just return GenericError if it is not implemented for the requested
|
||||||
* guest architecture or it is not supported in the host environment.
|
* guest architecture or it is not supported in the host environment.
|
||||||
*/
|
*/
|
||||||
if (qemuMonitorJSONHasError(reply, "GenericError")) {
|
if (qemuMonitorJSONHasError(reply, "GenericError"))
|
||||||
ret = 0;
|
return 0;
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0)
|
if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_OBJECT) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
data = virJSONValueObjectGetObject(reply, "return");
|
data = virJSONValueObjectGetObject(reply, "return");
|
||||||
|
|
||||||
if (qemuMonitorJSONParseCPUModelData(data,
|
if (qemuMonitorJSONParseCPUModelData(data,
|
||||||
&cpu_model, &cpu_props, &cpu_name) < 0)
|
&cpu_model, &cpu_props, &cpu_name) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
/* QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC_FULL requests "full" expansion
|
/* QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC_FULL requests "full" expansion
|
||||||
* on the result of the initial "static" expansion.
|
* on the result of the initial "static" expansion.
|
||||||
*/
|
*/
|
||||||
if (type == QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC_FULL) {
|
if (type == QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC_FULL) {
|
||||||
if (!(model = virJSONValueCopy(cpu_model)))
|
if (!(model = virJSONValueCopy(cpu_model)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
virJSONValueFree(cmd);
|
virJSONValueFree(cmd);
|
||||||
virJSONValueFree(reply);
|
virJSONValueFree(reply);
|
||||||
@ -5847,13 +5844,7 @@ qemuMonitorJSONGetCPUModelExpansion(qemuMonitorPtr mon,
|
|||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = qemuMonitorJSONParseCPUModel(cpu_name, cpu_props, model_info);
|
return qemuMonitorJSONParseCPUModel(cpu_name, cpu_props, model_info);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
virJSONValueFree(cmd);
|
|
||||||
virJSONValueFree(reply);
|
|
||||||
virJSONValueFree(model);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user