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(a)redhat.com>
---
src/cpu/cpu.c | 14 +++++---------
src/cpu/cpu.h | 4 ++--
src/cpu/cpu_arm.c | 5 +----
src/cpu/cpu_ppc64.c | 5 +----
src/cpu/cpu_x86.c | 18 ++++++------------
tests/cputest.c | 3 ++-
6 files changed, 17 insertions(+), 32 deletions(-)
diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c
index d53a7ef2c..8e07e0ce4 100644
--- a/src/cpu/cpu.c
+++ b/src/cpu/cpu.c
@@ -539,7 +539,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) &&
@@ -573,18 +574,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
@@ -592,7 +588,7 @@ cpuBaseline(virCPUDefPtr *cpus,
unsigned int ncpus,
const char **models,
unsigned int nmodels,
- unsigned int flags)
+ bool migratable)
{
struct cpuArchDriver *driver;
size_t i;
@@ -647,7 +643,7 @@ cpuBaseline(virCPUDefPtr *cpus,
return NULL;
}
- return driver->baseline(cpus, ncpus, models, nmodels, flags);
+ return driver->baseline(cpus, ncpus, models, nmodels, migratable);
}
diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h
index 92b0f788e..096eabe4c 100644
--- a/src/cpu/cpu.h
+++ b/src/cpu/cpu.h
@@ -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,
@@ -198,7 +198,7 @@ cpuBaseline (virCPUDefPtr *cpus,
unsigned int ncpus,
const char **models,
unsigned int nmodels,
- unsigned int flags)
+ bool migratable)
ATTRIBUTE_NONNULL(1);
int
diff --git a/src/cpu/cpu_arm.c b/src/cpu/cpu_arm.c
index a1aba2554..474777656 100644
--- a/src/cpu/cpu_arm.c
+++ b/src/cpu/cpu_arm.c
@@ -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);
diff --git a/src/cpu/cpu_ppc64.c b/src/cpu/cpu_ppc64.c
index 0ad8d17d4..f64592b55 100644
--- a/src/cpu/cpu_ppc64.c
+++ b/src/cpu/cpu_ppc64.c
@@ -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;
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 388102f35..48648a7f4 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -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++) {
diff --git a/tests/cputest.c b/tests/cputest.c
index 6396e8670..4a4d427e1 100644
--- a/tests/cputest.c
+++ b/tests/cputest.c
@@ -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) &&
--
2.12.0