mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
cpu: Add explicit arch parameter for virCPUBaseline
This is required for virCPUBaseline to accept a list of guest CPU definitions since they do not have arch set. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Collin Walling <walling@linux.ibm.com>
This commit is contained in:
parent
388a5c1400
commit
f8c9f6ea2d
@ -1398,7 +1398,7 @@ bhyveConnectBaselineCPU(virConnectPtr conn,
|
||||
if (!(cpus = virCPUDefListParse(xmlCPUs, ncpus, VIR_CPU_TYPE_HOST)))
|
||||
goto cleanup;
|
||||
|
||||
if (!(cpu = virCPUBaseline(cpus, ncpus, NULL,
|
||||
if (!(cpu = virCPUBaseline(VIR_ARCH_NONE, cpus, ncpus, NULL,
|
||||
!!(flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE))))
|
||||
goto cleanup;
|
||||
|
||||
|
@ -481,20 +481,22 @@ virCPUProbeHost(virArch arch)
|
||||
/**
|
||||
* virCPUBaseline:
|
||||
*
|
||||
* @arch: CPU architecture, use VIR_ARCH_NONE to autodetect from @cpus
|
||||
* @cpus: list of host CPU definitions
|
||||
* @ncpus: number of CPUs in @cpus
|
||||
* @models: list of CPU models that can be considered for the baseline CPU
|
||||
* @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 is NULL, all models supported by libvirt will
|
||||
* CPUs. If @models 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.
|
||||
*
|
||||
* Returns baseline CPU definition or NULL on error.
|
||||
*/
|
||||
virCPUDefPtr
|
||||
virCPUBaseline(virCPUDefPtr *cpus,
|
||||
virCPUBaseline(virArch arch,
|
||||
virCPUDefPtr *cpus,
|
||||
unsigned int ncpus,
|
||||
virDomainCapsCPUModelsPtr models,
|
||||
bool migratable)
|
||||
@ -502,7 +504,8 @@ virCPUBaseline(virCPUDefPtr *cpus,
|
||||
struct cpuArchDriver *driver;
|
||||
size_t i;
|
||||
|
||||
VIR_DEBUG("ncpus=%u, models=%p, migratable=%d", ncpus, models, migratable);
|
||||
VIR_DEBUG("arch=%s, ncpus=%u, models=%p, migratable=%d",
|
||||
virArchToString(arch), ncpus, models, migratable);
|
||||
if (cpus) {
|
||||
for (i = 0; i < ncpus; i++)
|
||||
VIR_DEBUG("cpus[%zu]=%p", i, cpus[i]);
|
||||
@ -536,13 +539,16 @@ virCPUBaseline(virCPUDefPtr *cpus,
|
||||
}
|
||||
}
|
||||
|
||||
if ((driver = cpuGetSubDriver(cpus[0]->arch)) == NULL)
|
||||
if (arch == VIR_ARCH_NONE)
|
||||
arch = cpus[0]->arch;
|
||||
|
||||
if ((driver = cpuGetSubDriver(arch)) == NULL)
|
||||
return NULL;
|
||||
|
||||
if (driver->baseline == NULL) {
|
||||
virReportError(VIR_ERR_NO_SUPPORT,
|
||||
_("cannot compute baseline CPU of %s architecture"),
|
||||
virArchToString(cpus[0]->arch));
|
||||
virArchToString(arch));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -194,7 +194,8 @@ virCPUDefPtr
|
||||
virCPUProbeHost(virArch arch);
|
||||
|
||||
virCPUDefPtr
|
||||
virCPUBaseline(virCPUDefPtr *cpus,
|
||||
virCPUBaseline(virArch arch,
|
||||
virCPUDefPtr *cpus,
|
||||
unsigned int ncpus,
|
||||
virDomainCapsCPUModelsPtr models,
|
||||
bool migratable);
|
||||
|
@ -6349,7 +6349,7 @@ libxlConnectBaselineCPU(virConnectPtr conn,
|
||||
if (!(cpus = virCPUDefListParse(xmlCPUs, ncpus, VIR_CPU_TYPE_HOST)))
|
||||
goto cleanup;
|
||||
|
||||
if (!(cpu = virCPUBaseline(cpus, ncpus, NULL,
|
||||
if (!(cpu = virCPUBaseline(VIR_ARCH_NONE, cpus, ncpus, NULL,
|
||||
!!(flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE))))
|
||||
goto cleanup;
|
||||
|
||||
|
@ -13315,7 +13315,7 @@ qemuConnectBaselineCPU(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||
if (!(cpus = virCPUDefListParse(xmlCPUs, ncpus, VIR_CPU_TYPE_HOST)))
|
||||
goto cleanup;
|
||||
|
||||
if (!(baseline = virCPUBaseline(cpus, ncpus, NULL,
|
||||
if (!(baseline = virCPUBaseline(VIR_ARCH_NONE, cpus, ncpus, NULL,
|
||||
!!(flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE))))
|
||||
goto cleanup;
|
||||
|
||||
|
@ -1541,7 +1541,7 @@ testConnectBaselineCPU(virConnectPtr conn ATTRIBUTE_UNUSED,
|
||||
if (!(cpus = virCPUDefListParse(xmlCPUs, ncpus, VIR_CPU_TYPE_HOST)))
|
||||
goto cleanup;
|
||||
|
||||
if (!(cpu = virCPUBaseline(cpus, ncpus, NULL, false)))
|
||||
if (!(cpu = virCPUBaseline(VIR_ARCH_NONE, cpus, ncpus, NULL, false)))
|
||||
goto cleanup;
|
||||
|
||||
if ((flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) &&
|
||||
|
@ -934,7 +934,7 @@ vzConnectBaselineCPU(virConnectPtr conn,
|
||||
if (!(cpus = virCPUDefListParse(xmlCPUs, ncpus, VIR_CPU_TYPE_HOST)))
|
||||
goto cleanup;
|
||||
|
||||
if (!(cpu = virCPUBaseline(cpus, ncpus, NULL, false)))
|
||||
if (!(cpu = virCPUBaseline(VIR_ARCH_NONE, cpus, ncpus, NULL, false)))
|
||||
goto cleanup;
|
||||
|
||||
if ((flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES) &&
|
||||
|
@ -321,7 +321,7 @@ cpuTestBaseline(const void *arg)
|
||||
if (!(cpus = cpuTestLoadMultiXML(data->arch, data->name, &ncpus)))
|
||||
goto cleanup;
|
||||
|
||||
baseline = virCPUBaseline(cpus, ncpus, NULL,
|
||||
baseline = virCPUBaseline(data->arch, cpus, ncpus, NULL,
|
||||
!!(data->flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE));
|
||||
|
||||
if (baseline &&
|
||||
|
Loading…
x
Reference in New Issue
Block a user