When expanding a CPU model via query-cpu-model-expansion, any features
that were a part of the original model are discarded. For exmaple,
when expanding modelA with features f1, f2, a full expansion may reveal
feature f3, but the expanded model will not include f1 or f2.
Let's pass a virCPUDefPtr to the expansion function in preparation for
taking features into consideration.
Signed-off-by: Collin Walling <walling@linux.ibm.com>
Message-Id: <
1568924706-2311-4-git-send-email-walling@linux.ibm.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
qemuMonitorCPUModelInfoPtr nonMigratable = NULL;
virHashTablePtr hash = NULL;
const char *model;
+ virCPUDefPtr cpu;
qemuMonitorCPUModelExpansionType type;
virDomainVirtType virtType;
int ret = -1;
model = "host";
}
+ if (VIR_ALLOC(cpu) < 0 || VIR_STRDUP(cpu->model, model) < 0)
+ goto cleanup;
+
/* Some x86_64 features defined in cpu_map.xml use spelling which differ
* from the one preferred by QEMU. Static expansion would give us only the
* preferred spelling. With new QEMU we always use the QEMU's canonical
else
type = QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC;
- if (qemuMonitorGetCPUModelExpansion(mon, type, model, true, &modelInfo) < 0)
+ if (qemuMonitorGetCPUModelExpansion(mon, type, cpu, true, &modelInfo) < 0)
goto cleanup;
/* Try to check migratability of each feature. */
if (modelInfo &&
- qemuMonitorGetCPUModelExpansion(mon, type, model, false,
+ qemuMonitorGetCPUModelExpansion(mon, type, cpu, false,
&nonMigratable) < 0)
goto cleanup;
virHashFree(hash);
qemuMonitorCPUModelInfoFree(nonMigratable);
qemuMonitorCPUModelInfoFree(modelInfo);
+ virCPUDefFree(cpu);
return ret;
}
int
qemuMonitorGetCPUModelExpansion(qemuMonitorPtr mon,
qemuMonitorCPUModelExpansionType type,
- const char *model_name,
+ virCPUDefPtr cpu,
bool migratable,
qemuMonitorCPUModelInfoPtr *model_info)
{
- VIR_DEBUG("type=%d model_name=%s migratable=%d",
- type, model_name, migratable);
+ VIR_DEBUG("type=%d cpu=%p migratable=%d", type, cpu, migratable);
QEMU_CHECK_MONITOR(mon);
- return qemuMonitorJSONGetCPUModelExpansion(mon, type, model_name,
+ return qemuMonitorJSONGetCPUModelExpansion(mon, type, cpu,
migratable, model_info);
}
int qemuMonitorGetCPUModelExpansion(qemuMonitorPtr mon,
qemuMonitorCPUModelExpansionType type,
- const char *model_name,
+ virCPUDefPtr cpu,
bool migratable,
qemuMonitorCPUModelInfoPtr *model_info);
static virJSONValuePtr
-qemuMonitorJSONMakeCPUModel(const char *model_name,
+qemuMonitorJSONMakeCPUModel(virCPUDefPtr cpu,
bool migratable)
{
virJSONValuePtr model = NULL;
if (!(model = virJSONValueNewObject()))
goto error;
- if (virJSONValueObjectAppendString(model, "name", model_name) < 0)
+ if (virJSONValueObjectAppendString(model, "name", cpu->model) < 0)
goto error;
if (!migratable) {
int
qemuMonitorJSONGetCPUModelExpansion(qemuMonitorPtr mon,
qemuMonitorCPUModelExpansionType type,
- const char *model_name,
+ virCPUDefPtr cpu,
bool migratable,
qemuMonitorCPUModelInfoPtr *model_info)
{
*model_info = NULL;
- if (!(model = qemuMonitorJSONMakeCPUModel(model_name, migratable)))
+ if (!(model = qemuMonitorJSONMakeCPUModel(cpu, migratable)))
return -1;
retry:
int qemuMonitorJSONGetCPUModelExpansion(qemuMonitorPtr mon,
qemuMonitorCPUModelExpansionType type,
- const char *model_name,
+ virCPUDefPtr cpu,
bool migratable,
qemuMonitorCPUModelInfoPtr *model_info)
ATTRIBUTE_NONNULL(3) ATTRIBUTE_NONNULL(5);
virQEMUCapsPtr qemuCaps = NULL;
qemuMonitorTestPtr testMon = NULL;
qemuMonitorCPUModelInfoPtr model = NULL;
+ virCPUDefPtr cpu = NULL;
char *json = NULL;
if (virAsprintf(&json, "%s/cputestdata/%s-cpuid-%s.json",
if (!(testMon = qemuMonitorTestNewFromFile(json, driver.xmlopt, true)))
goto error;
+ if (VIR_ALLOC(cpu) < 0 || VIR_STRDUP(cpu->model, "host") < 0)
+ goto cleanup;
+
if (qemuMonitorGetCPUModelExpansion(qemuMonitorTestGetMonitor(testMon),
QEMU_MONITOR_CPU_MODEL_EXPANSION_STATIC,
- "host", true, &model) < 0)
+ cpu, true, &model) < 0)
goto error;
if (!(qemuCaps = virQEMUCapsNew()))
cleanup:
qemuMonitorCPUModelInfoFree(model);
qemuMonitorTestFree(testMon);
+ virCPUDefFree(cpu);
VIR_FREE(json);
return qemuCaps;