提交 8b28fd74 编写于 作者: C Collin Walling 提交者: Jiri Denemark

qemu_monitor: implement query-cpu-model-comparison

Interfaces with QEMU to compare CPU models. The command takes two CPU
models, A and B, that are given a model name and an optional list of
CPU features. Through the query-cpu-model-comparison command issued
via QMP, a result is produced that contains the comparison evaluation
string (identical, superset, subset, incompatible).

The list of properties (aka CPU features) that is returned from the QMP
response is ignored.
Signed-off-by: NCollin Walling <walling@linux.ibm.com>
Reviewed-by: NDaniel Henrique Barboza <danielh413@gmail.com>
Message-Id: <1568924706-2311-12-git-send-email-walling@linux.ibm.com>
Reviewed-by: NJiri Denemark <jdenemar@redhat.com>
上级 aa797c66
......@@ -3575,6 +3575,20 @@ qemuMonitorGetCPUModelBaseline(qemuMonitorPtr mon,
}
int
qemuMonitorGetCPUModelComparison(qemuMonitorPtr mon,
virCPUDefPtr cpu_a,
virCPUDefPtr cpu_b,
char **result)
{
VIR_DEBUG("cpu_a=%p cpu_b=%p", cpu_a, cpu_b);
QEMU_CHECK_MONITOR(mon);
return qemuMonitorJSONGetCPUModelComparison(mon, cpu_a, cpu_b, result);
}
void
qemuMonitorCPUModelInfoFree(qemuMonitorCPUModelInfoPtr model_info)
{
......
......@@ -1158,6 +1158,11 @@ int qemuMonitorGetCPUModelBaseline(qemuMonitorPtr mon,
virCPUDefPtr cpu_b,
qemuMonitorCPUModelInfoPtr *baseline);
int qemuMonitorGetCPUModelComparison(qemuMonitorPtr mon,
virCPUDefPtr cpu_a,
virCPUDefPtr cpu_b,
char **result);
qemuMonitorCPUModelInfoPtr
qemuMonitorCPUModelInfoCopy(const qemuMonitorCPUModelInfo *orig);
......
......@@ -5919,6 +5919,48 @@ qemuMonitorJSONGetCPUModelBaseline(qemuMonitorPtr mon,
}
int
qemuMonitorJSONGetCPUModelComparison(qemuMonitorPtr mon,
virCPUDefPtr cpu_a,
virCPUDefPtr cpu_b,
char **result)
{
VIR_AUTOPTR(virJSONValue) model_a = NULL;
VIR_AUTOPTR(virJSONValue) model_b = NULL;
VIR_AUTOPTR(virJSONValue) cmd = NULL;
VIR_AUTOPTR(virJSONValue) reply = NULL;
const char *data_result;
virJSONValuePtr data;
if (!(model_a = qemuMonitorJSONMakeCPUModel(cpu_a, true)) ||
!(model_b = qemuMonitorJSONMakeCPUModel(cpu_b, true)))
return -1;
if (!(cmd = qemuMonitorJSONMakeCommand("query-cpu-model-comparison",
"a:modela", &model_a,
"a:modelb", &model_b,
NULL)))
return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
return -1;
if (qemuMonitorJSONCheckError(cmd, reply) < 0)
return -1;
data = virJSONValueObjectGetObject(reply, "return");
if (!(data_result = virJSONValueObjectGetString(data, "result"))) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("query-cpu-model-comparison reply data was missing "
"'result'"));
return -1;
}
return VIR_STRDUP(*result, data_result);
}
int qemuMonitorJSONGetCommands(qemuMonitorPtr mon,
char ***commands)
{
......
......@@ -393,6 +393,12 @@ int qemuMonitorJSONGetCPUModelBaseline(qemuMonitorPtr mon,
qemuMonitorCPUModelInfoPtr *baseline)
ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(4);
int qemuMonitorJSONGetCPUModelComparison(qemuMonitorPtr mon,
virCPUDefPtr cpu_a,
virCPUDefPtr cpu_b,
char **result)
ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
int qemuMonitorJSONGetCommands(qemuMonitorPtr mon,
char ***commands)
ATTRIBUTE_NONNULL(2);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册