unsigned int ncpus,
unsigned int flags)
{
- char *cpu = NULL;
+ virCPUDefPtr *cpus = NULL;
+ virCPUDefPtr cpu = NULL;
+ char *cpustr = NULL;
virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES |
VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL);
if (virConnectBaselineCPUEnsureACL(conn) < 0)
goto cleanup;
- cpu = cpuBaselineXML(xmlCPUs, ncpus, NULL, 0, flags);
+ if (!(cpus = virCPUDefListParse(xmlCPUs, ncpus, VIR_CPU_TYPE_HOST)))
+ goto cleanup;
+
+ if (!(cpu = cpuBaseline(cpus, ncpus, NULL, 0,
+ !!(flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE))))
+ goto cleanup;
+
+ if ((flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) &&
+ virCPUExpandFeatures(cpus[0]->arch, cpu) < 0)
+ goto cleanup;
+
+ cpustr = virCPUDefFormat(cpu, NULL, false);
cleanup:
- return cpu;
+ virCPUDefListFree(cpus);
+ virCPUDefFree(cpu);
+
+ return cpustr;
}
static int
}
-/**
- * cpuBaselineXML:
- *
- * @xmlCPUs: list of host CPU XML descriptions
- * @ncpus: number of CPUs in @xmlCPUs
- * @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
- *
- * 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 XML description of the baseline CPU or NULL on error.
- */
-char *
-cpuBaselineXML(const char **xmlCPUs,
- unsigned int ncpus,
- const char **models,
- unsigned int nmodels,
- unsigned int flags)
-{
- virCPUDefPtr *cpus = NULL;
- virCPUDefPtr cpu = NULL;
- char *cpustr = NULL;
-
- VIR_DEBUG("ncpus=%u, nmodels=%u", ncpus, nmodels);
-
- virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES |
- VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL);
-
- if (!(cpus = virCPUDefListParse(xmlCPUs, ncpus, VIR_CPU_TYPE_HOST)))
- goto cleanup;
-
- if (!(cpu = cpuBaseline(cpus, ncpus, models, nmodels,
- !!(flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE))))
- goto cleanup;
-
- if ((flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) &&
- virCPUExpandFeatures(cpus[0]->arch, cpu) < 0)
- goto cleanup;
-
- cpustr = virCPUDefFormat(cpu, NULL, false);
-
- cleanup:
- virCPUDefListFree(cpus);
- virCPUDefFree(cpu);
-
- return cpustr;
-}
-
-
/**
* cpuBaseline:
*
virCPUDefPtr
virCPUProbeHost(virArch arch);
-char *
-cpuBaselineXML(const char **xmlCPUs,
- unsigned int ncpus,
- const char **models,
- unsigned int nmodels,
- unsigned int flags);
-
virCPUDefPtr
cpuBaseline (virCPUDefPtr *cpus,
unsigned int ncpus,
# cpu/cpu.h
cpuBaseline;
-cpuBaselineXML;
cpuDecode;
cpuEncode;
virCPUCheckFeature;
unsigned int ncpus,
unsigned int flags)
{
- char *cpu = NULL;
+ virCPUDefPtr *cpus = NULL;
+ virCPUDefPtr cpu = NULL;
+ char *cpustr = NULL;
virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES |
VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL);
if (virConnectBaselineCPUEnsureACL(conn) < 0)
goto cleanup;
- cpu = cpuBaselineXML(xmlCPUs, ncpus, NULL, 0, flags);
+ if (!(cpus = virCPUDefListParse(xmlCPUs, ncpus, VIR_CPU_TYPE_HOST)))
+ goto cleanup;
+
+ if (!(cpu = cpuBaseline(cpus, ncpus, NULL, 0,
+ !!(flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE))))
+ goto cleanup;
+
+ if ((flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) &&
+ virCPUExpandFeatures(cpus[0]->arch, cpu) < 0)
+ goto cleanup;
+
+ cpustr = virCPUDefFormat(cpu, NULL, false);
cleanup:
- return cpu;
+ virCPUDefListFree(cpus);
+ virCPUDefFree(cpu);
+
+ return cpustr;
}
static virHypervisorDriver libxlHypervisorDriver = {
unsigned int ncpus,
unsigned int flags)
{
- char *cpu = NULL;
+ virCPUDefPtr *cpus = NULL;
+ virCPUDefPtr cpu = NULL;
+ char *cpustr = NULL;
virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES |
VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL);
if (virConnectBaselineCPUEnsureACL(conn) < 0)
goto cleanup;
- cpu = cpuBaselineXML(xmlCPUs, ncpus, NULL, 0, flags);
+ if (!(cpus = virCPUDefListParse(xmlCPUs, ncpus, VIR_CPU_TYPE_HOST)))
+ goto cleanup;
+
+ if (!(cpu = cpuBaseline(cpus, ncpus, NULL, 0,
+ !!(flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE))))
+ goto cleanup;
+
+ if ((flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) &&
+ virCPUExpandFeatures(cpus[0]->arch, cpu) < 0)
+ goto cleanup;
+
+ cpustr = virCPUDefFormat(cpu, NULL, false);
cleanup:
- return cpu;
+ virCPUDefListFree(cpus);
+ virCPUDefFree(cpu);
+
+ return cpustr;
}
unsigned int ncpus,
unsigned int flags)
{
- char *cpu;
+ virCPUDefPtr *cpus = NULL;
+ virCPUDefPtr cpu = NULL;
+ char *cpustr = NULL;
virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES, NULL);
- cpu = cpuBaselineXML(xmlCPUs, ncpus, NULL, 0, flags);
+ if (!(cpus = virCPUDefListParse(xmlCPUs, ncpus, VIR_CPU_TYPE_HOST)))
+ goto cleanup;
+
+ if (!(cpu = cpuBaseline(cpus, ncpus, NULL, 0, false)))
+ goto cleanup;
+
+ if ((flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) &&
+ virCPUExpandFeatures(cpus[0]->arch, cpu) < 0)
+ goto cleanup;
+
+ cpustr = virCPUDefFormat(cpu, NULL, false);
+
+ cleanup:
+ virCPUDefListFree(cpus);
+ virCPUDefFree(cpu);
- return cpu;
+ return cpustr;
}
static int testNodeGetInfo(virConnectPtr conn,
unsigned int ncpus,
unsigned int flags)
{
+ virCPUDefPtr *cpus = NULL;
+ virCPUDefPtr cpu = NULL;
+ char *cpustr = NULL;
+
virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES, NULL);
if (virConnectBaselineCPUEnsureACL(conn) < 0)
return NULL;
- return cpuBaselineXML(xmlCPUs, ncpus, NULL, 0, flags);
+ if (!(cpus = virCPUDefListParse(xmlCPUs, ncpus, VIR_CPU_TYPE_HOST)))
+ goto cleanup;
+
+ if (!(cpu = cpuBaseline(cpus, ncpus, NULL, 0, false)))
+ goto cleanup;
+
+ if ((flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) &&
+ virCPUExpandFeatures(cpus[0]->arch, cpu) < 0)
+ goto cleanup;
+
+ cpustr = virCPUDefFormat(cpu, NULL, false);
+
+ cleanup:
+ virCPUDefListFree(cpus);
+ virCPUDefFree(cpu);
+
+ return cpustr;
}