mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
cpu: Do not pass virConnectBaselineCPUFlags to cpuBaseline
The public API flags are handled by the cpuBaselineXML wrapper. The internal cpuBaseline API only needs to know whether it is supposed to drop non-migratable features. Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
d8b3dd16cb
commit
c117ecec91
@ -552,7 +552,8 @@ cpuBaselineXML(const char **xmlCPUs,
|
|||||||
doc = NULL;
|
doc = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(cpu = cpuBaseline(cpus, ncpus, models, nmodels, flags)))
|
if (!(cpu = cpuBaseline(cpus, ncpus, models, nmodels,
|
||||||
|
!!(flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE))))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if ((flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) &&
|
if ((flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) &&
|
||||||
@ -586,18 +587,13 @@ cpuBaselineXML(const char **xmlCPUs,
|
|||||||
* @ncpus: number of CPUs in @cpus
|
* @ncpus: number of CPUs in @cpus
|
||||||
* @models: list of CPU models that can be considered for the baseline CPU
|
* @models: list of CPU models that can be considered for the baseline CPU
|
||||||
* @nmodels: number of CPU models in @models
|
* @nmodels: number of CPU models in @models
|
||||||
* @flags: bitwise-OR of virConnectBaselineCPUFlags
|
* @migratable: requests non-migratable features to be removed from the result
|
||||||
*
|
*
|
||||||
* Computes the most feature-rich CPU which is compatible with all given
|
* Computes the most feature-rich CPU which is compatible with all given
|
||||||
* host CPUs. If @models array is NULL, all models supported by libvirt will
|
* host CPUs. If @models array is NULL, all models supported by libvirt will
|
||||||
* be considered when computing the baseline CPU model, otherwise the baseline
|
* be considered when computing the baseline CPU model, otherwise the baseline
|
||||||
* CPU model will be one of the provided CPU @models.
|
* CPU model will be one of the provided CPU @models.
|
||||||
*
|
*
|
||||||
* If @flags includes VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES then libvirt
|
|
||||||
* will explicitly list all CPU features that are part of the host CPU,
|
|
||||||
* without this flag features that are part of the CPU model will not be
|
|
||||||
* listed.
|
|
||||||
*
|
|
||||||
* Returns baseline CPU definition or NULL on error.
|
* Returns baseline CPU definition or NULL on error.
|
||||||
*/
|
*/
|
||||||
virCPUDefPtr
|
virCPUDefPtr
|
||||||
@ -605,7 +601,7 @@ cpuBaseline(virCPUDefPtr *cpus,
|
|||||||
unsigned int ncpus,
|
unsigned int ncpus,
|
||||||
const char **models,
|
const char **models,
|
||||||
unsigned int nmodels,
|
unsigned int nmodels,
|
||||||
unsigned int flags)
|
bool migratable)
|
||||||
{
|
{
|
||||||
struct cpuArchDriver *driver;
|
struct cpuArchDriver *driver;
|
||||||
size_t i;
|
size_t i;
|
||||||
@ -660,7 +656,7 @@ cpuBaseline(virCPUDefPtr *cpus,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return driver->baseline(cpus, ncpus, models, nmodels, flags);
|
return driver->baseline(cpus, ncpus, models, nmodels, migratable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ typedef virCPUDefPtr
|
|||||||
unsigned int ncpus,
|
unsigned int ncpus,
|
||||||
const char **models,
|
const char **models,
|
||||||
unsigned int nmodels,
|
unsigned int nmodels,
|
||||||
unsigned int flags);
|
bool migratable);
|
||||||
|
|
||||||
typedef int
|
typedef int
|
||||||
(*virCPUArchUpdate)(virCPUDefPtr guest,
|
(*virCPUArchUpdate)(virCPUDefPtr guest,
|
||||||
@ -201,7 +201,7 @@ cpuBaseline (virCPUDefPtr *cpus,
|
|||||||
unsigned int ncpus,
|
unsigned int ncpus,
|
||||||
const char **models,
|
const char **models,
|
||||||
unsigned int nmodels,
|
unsigned int nmodels,
|
||||||
unsigned int flags);
|
bool migratable);
|
||||||
|
|
||||||
int
|
int
|
||||||
virCPUUpdate(virArch arch,
|
virCPUUpdate(virArch arch,
|
||||||
|
@ -77,13 +77,10 @@ armBaseline(virCPUDefPtr *cpus,
|
|||||||
unsigned int ncpus ATTRIBUTE_UNUSED,
|
unsigned int ncpus ATTRIBUTE_UNUSED,
|
||||||
const char **models ATTRIBUTE_UNUSED,
|
const char **models ATTRIBUTE_UNUSED,
|
||||||
unsigned int nmodels ATTRIBUTE_UNUSED,
|
unsigned int nmodels ATTRIBUTE_UNUSED,
|
||||||
unsigned int flags)
|
bool migratable ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
virCPUDefPtr cpu = NULL;
|
virCPUDefPtr cpu = NULL;
|
||||||
|
|
||||||
virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES |
|
|
||||||
VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL);
|
|
||||||
|
|
||||||
if (VIR_ALLOC(cpu) < 0 ||
|
if (VIR_ALLOC(cpu) < 0 ||
|
||||||
VIR_STRDUP(cpu->model, cpus[0]->model) < 0) {
|
VIR_STRDUP(cpu->model, cpus[0]->model) < 0) {
|
||||||
virCPUDefFree(cpu);
|
virCPUDefFree(cpu);
|
||||||
|
@ -768,7 +768,7 @@ ppc64DriverBaseline(virCPUDefPtr *cpus,
|
|||||||
unsigned int ncpus,
|
unsigned int ncpus,
|
||||||
const char **models ATTRIBUTE_UNUSED,
|
const char **models ATTRIBUTE_UNUSED,
|
||||||
unsigned int nmodels ATTRIBUTE_UNUSED,
|
unsigned int nmodels ATTRIBUTE_UNUSED,
|
||||||
unsigned int flags)
|
bool migratable ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
struct ppc64_map *map;
|
struct ppc64_map *map;
|
||||||
const struct ppc64_model *model;
|
const struct ppc64_model *model;
|
||||||
@ -776,9 +776,6 @@ ppc64DriverBaseline(virCPUDefPtr *cpus,
|
|||||||
virCPUDefPtr cpu = NULL;
|
virCPUDefPtr cpu = NULL;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES |
|
|
||||||
VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL);
|
|
||||||
|
|
||||||
if (!(map = ppc64LoadMap()))
|
if (!(map = ppc64LoadMap()))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
@ -1823,7 +1823,7 @@ x86Decode(virCPUDefPtr cpu,
|
|||||||
const char **models,
|
const char **models,
|
||||||
unsigned int nmodels,
|
unsigned int nmodels,
|
||||||
const char *preferred,
|
const char *preferred,
|
||||||
unsigned int flags)
|
bool migratable)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
virCPUx86MapPtr map;
|
virCPUx86MapPtr map;
|
||||||
@ -1839,9 +1839,6 @@ x86Decode(virCPUDefPtr cpu,
|
|||||||
ssize_t i;
|
ssize_t i;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES |
|
|
||||||
VIR_CONNECT_BASELINE_CPU_MIGRATABLE, -1);
|
|
||||||
|
|
||||||
if (!cpuData || x86DataCopy(&data, cpuData) < 0)
|
if (!cpuData || x86DataCopy(&data, cpuData) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -1913,7 +1910,7 @@ x86Decode(virCPUDefPtr cpu,
|
|||||||
/* Remove non-migratable features if requested
|
/* Remove non-migratable features if requested
|
||||||
* Note: this only works as long as no CPU model contains non-migratable
|
* Note: this only works as long as no CPU model contains non-migratable
|
||||||
* features directly */
|
* features directly */
|
||||||
if (flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE) {
|
if (migratable) {
|
||||||
i = 0;
|
i = 0;
|
||||||
while (i < cpuModel->nfeatures) {
|
while (i < cpuModel->nfeatures) {
|
||||||
if (x86FeatureIsMigratable(cpuModel->features[i].name, map)) {
|
if (x86FeatureIsMigratable(cpuModel->features[i].name, map)) {
|
||||||
@ -1953,7 +1950,7 @@ x86DecodeCPUData(virCPUDefPtr cpu,
|
|||||||
unsigned int nmodels,
|
unsigned int nmodels,
|
||||||
const char *preferred)
|
const char *preferred)
|
||||||
{
|
{
|
||||||
return x86Decode(cpu, &data->data.x86, models, nmodels, preferred, 0);
|
return x86Decode(cpu, &data->data.x86, models, nmodels, preferred, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2432,7 +2429,7 @@ x86Baseline(virCPUDefPtr *cpus,
|
|||||||
unsigned int ncpus,
|
unsigned int ncpus,
|
||||||
const char **models,
|
const char **models,
|
||||||
unsigned int nmodels,
|
unsigned int nmodels,
|
||||||
unsigned int flags)
|
bool migratable)
|
||||||
{
|
{
|
||||||
virCPUx86MapPtr map = NULL;
|
virCPUx86MapPtr map = NULL;
|
||||||
virCPUx86ModelPtr base_model = NULL;
|
virCPUx86ModelPtr base_model = NULL;
|
||||||
@ -2444,9 +2441,6 @@ x86Baseline(virCPUDefPtr *cpus,
|
|||||||
const char *modelName;
|
const char *modelName;
|
||||||
bool matchingNames = true;
|
bool matchingNames = true;
|
||||||
|
|
||||||
virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES |
|
|
||||||
VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL);
|
|
||||||
|
|
||||||
if (!(map = virCPUx86GetMap()))
|
if (!(map = virCPUx86GetMap()))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
@ -2529,7 +2523,7 @@ x86Baseline(virCPUDefPtr *cpus,
|
|||||||
virCPUx86DataAddCPUIDInt(&base_model->data, &vendor->cpuid) < 0)
|
virCPUx86DataAddCPUIDInt(&base_model->data, &vendor->cpuid) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (x86Decode(cpu, &base_model->data, models, nmodels, modelName, flags) < 0)
|
if (x86Decode(cpu, &base_model->data, models, nmodels, modelName, migratable) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (STREQ_NULLABLE(cpu->model, modelName))
|
if (STREQ_NULLABLE(cpu->model, modelName))
|
||||||
@ -2838,7 +2832,7 @@ virCPUx86Translate(virCPUDefPtr cpu,
|
|||||||
if (!(translated = virCPUDefCopyWithoutModel(cpu)))
|
if (!(translated = virCPUDefCopyWithoutModel(cpu)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (x86Decode(translated, &model->data, models, nmodels, NULL, 0) < 0)
|
if (x86Decode(translated, &model->data, models, nmodels, NULL, false) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
for (i = 0; i < cpu->nfeatures; i++) {
|
for (i = 0; i < cpu->nfeatures; i++) {
|
||||||
|
@ -324,7 +324,8 @@ cpuTestBaseline(const void *arg)
|
|||||||
if (!(cpus = cpuTestLoadMultiXML(data->arch, data->name, &ncpus)))
|
if (!(cpus = cpuTestLoadMultiXML(data->arch, data->name, &ncpus)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
baseline = cpuBaseline(cpus, ncpus, NULL, 0, data->flags);
|
baseline = cpuBaseline(cpus, ncpus, NULL, 0,
|
||||||
|
!!(data->flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE));
|
||||||
|
|
||||||
if (baseline &&
|
if (baseline &&
|
||||||
(data->flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) &&
|
(data->flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) &&
|
||||||
|
Loading…
Reference in New Issue
Block a user