]> xenbits.xensource.com Git - libvirt.git/commitdiff
cpu: Do not pass virConnectBaselineCPUFlags to cpuBaseline
authorJiri Denemark <jdenemar@redhat.com>
Fri, 17 Mar 2017 14:58:07 +0000 (15:58 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Mon, 27 Mar 2017 14:29:27 +0000 (16:29 +0200)
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>
src/cpu/cpu.c
src/cpu/cpu.h
src/cpu/cpu_arm.c
src/cpu/cpu_ppc64.c
src/cpu/cpu_x86.c
tests/cputest.c

index 1148031bf1d331f5bf38f147bc17bded19633a6e..93647a2edaf283d64f354073124127963c88e277 100644 (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);
 }
 
 
index 31f95b02e714fa563d3946daac0ef15d3f7dc1bc..8c238ad553d49614c63810f6582d442fe68cdd24 100644 (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,
index a1aba255442d222e4bdd814f72fbaf3549c7852f..474777656cbfb9f588d3bdbdad42bd47b77e77b5 100644 (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);
index 0ad8d17d45a36941a657031c5eb5b4aad9248845..f64592b558bf084295bc5399402f38060c060118 100644 (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;
 
index 388102f359df54e21e1370fd377405bc44aa1fa7..48648a7f40eb8c6293b0a80cd911d3897bfb6259 100644 (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++) {
index e72b405278e4ffc7a94752fb00b6f650e6b083d7..971f71ebf17ec98a013df2677eebc2c31fad227b 100644 (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) &&