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:
Jiri Denemark 2017-03-17 15:58:07 +01:00
parent d8b3dd16cb
commit c117ecec91
6 changed files with 17 additions and 32 deletions

View File

@ -552,7 +552,8 @@ cpuBaselineXML(const char **xmlCPUs,
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;
if ((flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) &&
@ -586,18 +587,13 @@ cpuBaselineXML(const char **xmlCPUs,
* @ncpus: number of CPUs in @cpus
* @models: list of CPU models that can be considered for the baseline CPU
* @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
* host CPUs. If @models array is NULL, all models supported by libvirt will
* be considered when computing the baseline CPU model, otherwise the baseline
* 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.
*/
virCPUDefPtr
@ -605,7 +601,7 @@ cpuBaseline(virCPUDefPtr *cpus,
unsigned int ncpus,
const char **models,
unsigned int nmodels,
unsigned int flags)
bool migratable)
{
struct cpuArchDriver *driver;
size_t i;
@ -660,7 +656,7 @@ cpuBaseline(virCPUDefPtr *cpus,
return NULL;
}
return driver->baseline(cpus, ncpus, models, nmodels, flags);
return driver->baseline(cpus, ncpus, models, nmodels, migratable);
}

View File

@ -79,7 +79,7 @@ typedef virCPUDefPtr
unsigned int ncpus,
const char **models,
unsigned int nmodels,
unsigned int flags);
bool migratable);
typedef int
(*virCPUArchUpdate)(virCPUDefPtr guest,
@ -201,7 +201,7 @@ cpuBaseline (virCPUDefPtr *cpus,
unsigned int ncpus,
const char **models,
unsigned int nmodels,
unsigned int flags);
bool migratable);
int
virCPUUpdate(virArch arch,

View File

@ -77,13 +77,10 @@ armBaseline(virCPUDefPtr *cpus,
unsigned int ncpus ATTRIBUTE_UNUSED,
const char **models ATTRIBUTE_UNUSED,
unsigned int nmodels ATTRIBUTE_UNUSED,
unsigned int flags)
bool migratable ATTRIBUTE_UNUSED)
{
virCPUDefPtr cpu = NULL;
virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES |
VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL);
if (VIR_ALLOC(cpu) < 0 ||
VIR_STRDUP(cpu->model, cpus[0]->model) < 0) {
virCPUDefFree(cpu);

View File

@ -768,7 +768,7 @@ ppc64DriverBaseline(virCPUDefPtr *cpus,
unsigned int ncpus,
const char **models ATTRIBUTE_UNUSED,
unsigned int nmodels ATTRIBUTE_UNUSED,
unsigned int flags)
bool migratable ATTRIBUTE_UNUSED)
{
struct ppc64_map *map;
const struct ppc64_model *model;
@ -776,9 +776,6 @@ ppc64DriverBaseline(virCPUDefPtr *cpus,
virCPUDefPtr cpu = NULL;
size_t i;
virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES |
VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL);
if (!(map = ppc64LoadMap()))
goto error;

View File

@ -1823,7 +1823,7 @@ x86Decode(virCPUDefPtr cpu,
const char **models,
unsigned int nmodels,
const char *preferred,
unsigned int flags)
bool migratable)
{
int ret = -1;
virCPUx86MapPtr map;
@ -1839,9 +1839,6 @@ x86Decode(virCPUDefPtr cpu,
ssize_t i;
int rc;
virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES |
VIR_CONNECT_BASELINE_CPU_MIGRATABLE, -1);
if (!cpuData || x86DataCopy(&data, cpuData) < 0)
return -1;
@ -1913,7 +1910,7 @@ x86Decode(virCPUDefPtr cpu,
/* Remove non-migratable features if requested
* Note: this only works as long as no CPU model contains non-migratable
* features directly */
if (flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE) {
if (migratable) {
i = 0;
while (i < cpuModel->nfeatures) {
if (x86FeatureIsMigratable(cpuModel->features[i].name, map)) {
@ -1953,7 +1950,7 @@ x86DecodeCPUData(virCPUDefPtr cpu,
unsigned int nmodels,
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,
const char **models,
unsigned int nmodels,
unsigned int flags)
bool migratable)
{
virCPUx86MapPtr map = NULL;
virCPUx86ModelPtr base_model = NULL;
@ -2444,9 +2441,6 @@ x86Baseline(virCPUDefPtr *cpus,
const char *modelName;
bool matchingNames = true;
virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES |
VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL);
if (!(map = virCPUx86GetMap()))
goto error;
@ -2529,7 +2523,7 @@ x86Baseline(virCPUDefPtr *cpus,
virCPUx86DataAddCPUIDInt(&base_model->data, &vendor->cpuid) < 0)
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;
if (STREQ_NULLABLE(cpu->model, modelName))
@ -2838,7 +2832,7 @@ virCPUx86Translate(virCPUDefPtr cpu,
if (!(translated = virCPUDefCopyWithoutModel(cpu)))
goto cleanup;
if (x86Decode(translated, &model->data, models, nmodels, NULL, 0) < 0)
if (x86Decode(translated, &model->data, models, nmodels, NULL, false) < 0)
goto cleanup;
for (i = 0; i < cpu->nfeatures; i++) {

View File

@ -324,7 +324,8 @@ cpuTestBaseline(const void *arg)
if (!(cpus = cpuTestLoadMultiXML(data->arch, data->name, &ncpus)))
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 &&
(data->flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) &&