mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-22 22:13:18 +00:00
cpu: Drop cpuBaselineXML
The implementation of virConnectBaselineCPU may be different for each hypervisor. Thus it shouldn't really be implmented in the cpu code. Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
7816de498b
commit
abec725ab1
@ -1420,7 +1420,9 @@ bhyveConnectBaselineCPU(virConnectPtr conn,
|
|||||||
unsigned int ncpus,
|
unsigned int ncpus,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
char *cpu = NULL;
|
virCPUDefPtr *cpus = NULL;
|
||||||
|
virCPUDefPtr cpu = NULL;
|
||||||
|
char *cpustr = NULL;
|
||||||
|
|
||||||
virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES |
|
virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES |
|
||||||
VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL);
|
VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL);
|
||||||
@ -1428,10 +1430,24 @@ bhyveConnectBaselineCPU(virConnectPtr conn,
|
|||||||
if (virConnectBaselineCPUEnsureACL(conn) < 0)
|
if (virConnectBaselineCPUEnsureACL(conn) < 0)
|
||||||
goto cleanup;
|
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:
|
cleanup:
|
||||||
return cpu;
|
virCPUDefListFree(cpus);
|
||||||
|
virCPUDefFree(cpu);
|
||||||
|
|
||||||
|
return cpustr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -495,64 +495,6 @@ virCPUProbeHost(virArch arch)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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:
|
* cpuBaseline:
|
||||||
*
|
*
|
||||||
|
@ -196,13 +196,6 @@ virCPUGetHost(virArch arch,
|
|||||||
virCPUDefPtr
|
virCPUDefPtr
|
||||||
virCPUProbeHost(virArch arch);
|
virCPUProbeHost(virArch arch);
|
||||||
|
|
||||||
char *
|
|
||||||
cpuBaselineXML(const char **xmlCPUs,
|
|
||||||
unsigned int ncpus,
|
|
||||||
const char **models,
|
|
||||||
unsigned int nmodels,
|
|
||||||
unsigned int flags);
|
|
||||||
|
|
||||||
virCPUDefPtr
|
virCPUDefPtr
|
||||||
cpuBaseline (virCPUDefPtr *cpus,
|
cpuBaseline (virCPUDefPtr *cpus,
|
||||||
unsigned int ncpus,
|
unsigned int ncpus,
|
||||||
|
@ -1077,7 +1077,6 @@ virStoragePoolObjVolumeListExport;
|
|||||||
|
|
||||||
# cpu/cpu.h
|
# cpu/cpu.h
|
||||||
cpuBaseline;
|
cpuBaseline;
|
||||||
cpuBaselineXML;
|
|
||||||
cpuDecode;
|
cpuDecode;
|
||||||
cpuEncode;
|
cpuEncode;
|
||||||
virCPUCheckFeature;
|
virCPUCheckFeature;
|
||||||
|
@ -6450,7 +6450,9 @@ libxlConnectBaselineCPU(virConnectPtr conn,
|
|||||||
unsigned int ncpus,
|
unsigned int ncpus,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
char *cpu = NULL;
|
virCPUDefPtr *cpus = NULL;
|
||||||
|
virCPUDefPtr cpu = NULL;
|
||||||
|
char *cpustr = NULL;
|
||||||
|
|
||||||
virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES |
|
virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES |
|
||||||
VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL);
|
VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL);
|
||||||
@ -6458,10 +6460,24 @@ libxlConnectBaselineCPU(virConnectPtr conn,
|
|||||||
if (virConnectBaselineCPUEnsureACL(conn) < 0)
|
if (virConnectBaselineCPUEnsureACL(conn) < 0)
|
||||||
goto cleanup;
|
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:
|
cleanup:
|
||||||
return cpu;
|
virCPUDefListFree(cpus);
|
||||||
|
virCPUDefFree(cpu);
|
||||||
|
|
||||||
|
return cpustr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static virHypervisorDriver libxlHypervisorDriver = {
|
static virHypervisorDriver libxlHypervisorDriver = {
|
||||||
|
@ -12989,7 +12989,9 @@ qemuConnectBaselineCPU(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
unsigned int ncpus,
|
unsigned int ncpus,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
char *cpu = NULL;
|
virCPUDefPtr *cpus = NULL;
|
||||||
|
virCPUDefPtr cpu = NULL;
|
||||||
|
char *cpustr = NULL;
|
||||||
|
|
||||||
virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES |
|
virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES |
|
||||||
VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL);
|
VIR_CONNECT_BASELINE_CPU_MIGRATABLE, NULL);
|
||||||
@ -12997,10 +12999,24 @@ qemuConnectBaselineCPU(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
if (virConnectBaselineCPUEnsureACL(conn) < 0)
|
if (virConnectBaselineCPUEnsureACL(conn) < 0)
|
||||||
goto cleanup;
|
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:
|
cleanup:
|
||||||
return cpu;
|
virCPUDefListFree(cpus);
|
||||||
|
virCPUDefFree(cpu);
|
||||||
|
|
||||||
|
return cpustr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1535,13 +1535,29 @@ testConnectBaselineCPU(virConnectPtr conn ATTRIBUTE_UNUSED,
|
|||||||
unsigned int ncpus,
|
unsigned int ncpus,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
char *cpu;
|
virCPUDefPtr *cpus = NULL;
|
||||||
|
virCPUDefPtr cpu = NULL;
|
||||||
|
char *cpustr = NULL;
|
||||||
|
|
||||||
virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES, 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;
|
||||||
|
|
||||||
return cpu;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int testNodeGetInfo(virConnectPtr conn,
|
static int testNodeGetInfo(virConnectPtr conn,
|
||||||
|
@ -945,12 +945,32 @@ vzConnectBaselineCPU(virConnectPtr conn,
|
|||||||
unsigned int ncpus,
|
unsigned int ncpus,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
|
virCPUDefPtr *cpus = NULL;
|
||||||
|
virCPUDefPtr cpu = NULL;
|
||||||
|
char *cpustr = NULL;
|
||||||
|
|
||||||
virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES, NULL);
|
virCheckFlags(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES, NULL);
|
||||||
|
|
||||||
if (virConnectBaselineCPUEnsureACL(conn) < 0)
|
if (virConnectBaselineCPUEnsureACL(conn) < 0)
|
||||||
return NULL;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user