diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index 72c51434c7c8bb19a4829691f5d05ab9e6a9f62d..26047d31e294031fa4f424629459cedbd0b4909d 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -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; diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c index 81b93a991bd7a7d08e27b2593768cbf233f0ac4d..2c60d27b1713dad31f67e384c2d58c5172165427 100644 --- a/src/cpu/cpu.c +++ b/src/cpu/cpu.c @@ -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; } diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h index 529068a618397ce5f6d0e52152c7c51ee62ebf38..8c45bf8b3123af76531ab1a765c1e3c47561d49f 100644 --- a/src/cpu/cpu.h +++ b/src/cpu/cpu.h @@ -194,7 +194,8 @@ virCPUDefPtr virCPUProbeHost(virArch arch); virCPUDefPtr -virCPUBaseline(virCPUDefPtr *cpus, +virCPUBaseline(virArch arch, + virCPUDefPtr *cpus, unsigned int ncpus, virDomainCapsCPUModelsPtr models, bool migratable); diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index e11969dca7176813960c9820ed7d15297aac0423..a85ce84404c35d4755d13d07fa8fe58c44a3d5ae 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -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; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 08139553a1920f10e540e9e32801ed61721dd66f..71a6ec95404f6388ff467d8c90df8dbb5d205416 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -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; diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 0d591d5f9952b0b7cd51bacc2e01ada91e40ac78..9456dfe38538a329def14197c64c4024482bcc88 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -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) && diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c index d4cf2d5f62255a6100e51ae03b70327583e6855f..50cd0acfdfee0d56b71afea05cd1f9aad68f4a15 100644 --- a/src/vz/vz_driver.c +++ b/src/vz/vz_driver.c @@ -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) && diff --git a/tests/cputest.c b/tests/cputest.c index beb9afabdfa59b082ef1cf183fce2de2d53c5fc4..9b84ffea86f4f158040384379d5be3695d1c2f0c 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -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 &&