mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-30 09:53:10 +00:00
Introduce virCPUGetVendorForModel and use it in QEMU driver
So far QEMU driver does not get CPU model vendor from QEMU directly and it has to ask the CPU driver for the info stored in CPU map. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
2784a83907
commit
bbd2d9cb40
@ -923,6 +923,31 @@ virCPUGetModels(virArch arch, char ***models)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/** virCPUGetVendorForModel:
|
||||||
|
*
|
||||||
|
* @arch: CPU architecture
|
||||||
|
* @model: CPU model to be checked
|
||||||
|
*
|
||||||
|
* Returns @model's vendor or NULL if the vendor is unknown.
|
||||||
|
*/
|
||||||
|
const char *
|
||||||
|
virCPUGetVendorForModel(virArch arch,
|
||||||
|
const char *model)
|
||||||
|
{
|
||||||
|
struct cpuArchDriver *driver;
|
||||||
|
|
||||||
|
VIR_DEBUG("arch=%s", virArchToString(arch));
|
||||||
|
|
||||||
|
if (!(driver = cpuGetSubDriver(arch)))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (!driver->getVendorForModel)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return driver->getVendorForModel(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* virCPUTranslate:
|
* virCPUTranslate:
|
||||||
*
|
*
|
||||||
|
@ -105,6 +105,9 @@ typedef virCPUData *
|
|||||||
typedef int
|
typedef int
|
||||||
(*virCPUArchGetModels)(char ***models);
|
(*virCPUArchGetModels)(char ***models);
|
||||||
|
|
||||||
|
typedef const char *
|
||||||
|
(*virCPUArchGetVendorForModel)(const char *model);
|
||||||
|
|
||||||
typedef int
|
typedef int
|
||||||
(*virCPUArchTranslate)(virCPUDef *cpu,
|
(*virCPUArchTranslate)(virCPUDef *cpu,
|
||||||
virDomainCapsCPUModels *models);
|
virDomainCapsCPUModels *models);
|
||||||
@ -150,6 +153,7 @@ struct cpuArchDriver {
|
|||||||
virCPUArchDataFormat dataFormat;
|
virCPUArchDataFormat dataFormat;
|
||||||
virCPUArchDataParse dataParse;
|
virCPUArchDataParse dataParse;
|
||||||
virCPUArchGetModels getModels;
|
virCPUArchGetModels getModels;
|
||||||
|
virCPUArchGetVendorForModel getVendorForModel;
|
||||||
virCPUArchTranslate translate;
|
virCPUArchTranslate translate;
|
||||||
virCPUArchConvertLegacy convertLegacy;
|
virCPUArchConvertLegacy convertLegacy;
|
||||||
virCPUArchExpandFeatures expandFeatures;
|
virCPUArchExpandFeatures expandFeatures;
|
||||||
@ -262,6 +266,10 @@ virCPUModelIsAllowed(const char *model,
|
|||||||
int
|
int
|
||||||
virCPUGetModels(virArch arch, char ***models);
|
virCPUGetModels(virArch arch, char ***models);
|
||||||
|
|
||||||
|
const char *
|
||||||
|
virCPUGetVendorForModel(virArch arch,
|
||||||
|
const char *model);
|
||||||
|
|
||||||
int
|
int
|
||||||
virCPUTranslate(virArch arch,
|
virCPUTranslate(virArch arch,
|
||||||
virCPUDef *cpu,
|
virCPUDef *cpu,
|
||||||
|
@ -1500,6 +1500,7 @@ virCPUExpandFeatures;
|
|||||||
virCPUGetHost;
|
virCPUGetHost;
|
||||||
virCPUGetHostIsSupported;
|
virCPUGetHostIsSupported;
|
||||||
virCPUGetModels;
|
virCPUGetModels;
|
||||||
|
virCPUGetVendorForModel;
|
||||||
virCPUProbeHost;
|
virCPUProbeHost;
|
||||||
virCPUTranslate;
|
virCPUTranslate;
|
||||||
virCPUUpdate;
|
virCPUUpdate;
|
||||||
|
@ -2175,9 +2175,11 @@ virQEMUCapsAddCPUDefinitions(virQEMUCaps *qemuCaps,
|
|||||||
|
|
||||||
|
|
||||||
static virDomainCapsCPUModels *
|
static virDomainCapsCPUModels *
|
||||||
virQEMUCapsCPUDefsToModels(qemuMonitorCPUDefs *defs,
|
virQEMUCapsCPUDefsToModels(virArch arch,
|
||||||
|
qemuMonitorCPUDefs *defs,
|
||||||
const char **modelAllowed,
|
const char **modelAllowed,
|
||||||
const char **modelForbidden)
|
const char **modelForbidden,
|
||||||
|
bool vendors)
|
||||||
{
|
{
|
||||||
virDomainCapsCPUModels *cpuModels = NULL;
|
virDomainCapsCPUModels *cpuModels = NULL;
|
||||||
size_t i;
|
size_t i;
|
||||||
@ -2187,6 +2189,7 @@ virQEMUCapsCPUDefsToModels(qemuMonitorCPUDefs *defs,
|
|||||||
|
|
||||||
for (i = 0; i < defs->ncpus; i++) {
|
for (i = 0; i < defs->ncpus; i++) {
|
||||||
qemuMonitorCPUDefInfo *cpu = defs->cpus + i;
|
qemuMonitorCPUDefInfo *cpu = defs->cpus + i;
|
||||||
|
char *vendor = NULL;
|
||||||
|
|
||||||
if (modelAllowed && !g_strv_contains(modelAllowed, cpu->name))
|
if (modelAllowed && !g_strv_contains(modelAllowed, cpu->name))
|
||||||
continue;
|
continue;
|
||||||
@ -2194,8 +2197,11 @@ virQEMUCapsCPUDefsToModels(qemuMonitorCPUDefs *defs,
|
|||||||
if (modelForbidden && g_strv_contains(modelForbidden, cpu->name))
|
if (modelForbidden && g_strv_contains(modelForbidden, cpu->name))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (vendors)
|
||||||
|
vendor = g_strdup(virCPUGetVendorForModel(arch, cpu->name));
|
||||||
|
|
||||||
virDomainCapsCPUModelsAdd(cpuModels, cpu->name, cpu->usable,
|
virDomainCapsCPUModelsAdd(cpuModels, cpu->name, cpu->usable,
|
||||||
cpu->blockers, cpu->deprecated, NULL);
|
cpu->blockers, cpu->deprecated, vendor);
|
||||||
}
|
}
|
||||||
|
|
||||||
return cpuModels;
|
return cpuModels;
|
||||||
@ -2213,7 +2219,8 @@ virQEMUCapsGetCPUModels(virQEMUCaps *qemuCaps,
|
|||||||
if (!(defs = virQEMUCapsGetAccel(qemuCaps, type)->cpuModels))
|
if (!(defs = virQEMUCapsGetAccel(qemuCaps, type)->cpuModels))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return virQEMUCapsCPUDefsToModels(defs, modelAllowed, modelForbidden);
|
return virQEMUCapsCPUDefsToModels(qemuCaps->arch, defs,
|
||||||
|
modelAllowed, modelForbidden, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2946,7 +2953,8 @@ virQEMUCapsFetchCPUModels(qemuMonitor *mon,
|
|||||||
if (virQEMUCapsFetchCPUDefinitions(mon, arch, &defs) < 0)
|
if (virQEMUCapsFetchCPUDefinitions(mon, arch, &defs) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (defs && !(*cpuModels = virQEMUCapsCPUDefsToModels(defs, NULL, NULL)))
|
if (defs &&
|
||||||
|
!(*cpuModels = virQEMUCapsCPUDefsToModels(arch, defs, NULL, NULL, false)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user