mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-06 08:58:35 +03:00
cpu: Implement backwards compatibility in the ppc64 driver
All previously recognized CPU models (POWER7_v2.1, POWER7_v2.3, POWER7+_v2.1 and POWER8_v1.0) are internally converted to the corrisponding generation name so that existing guests don't stop working.
This commit is contained in:
parent
36300d2ba1
commit
dee2247afa
@ -57,6 +57,33 @@ struct ppc64_map {
|
|||||||
struct ppc64_model *models;
|
struct ppc64_model *models;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Convert a legacy CPU definition by transforming
|
||||||
|
* model names to generation names:
|
||||||
|
* POWER7_v2.1 => POWER7
|
||||||
|
* POWER7_v2.3 => POWER7
|
||||||
|
* POWER7+_v2.1 => POWER7
|
||||||
|
* POWER8_v1.0 => POWER8 */
|
||||||
|
static virCPUDefPtr
|
||||||
|
ppc64ConvertLegacyCPUDef(const virCPUDef *legacy)
|
||||||
|
{
|
||||||
|
virCPUDefPtr cpu;
|
||||||
|
|
||||||
|
if (!(cpu = virCPUDefCopy(legacy)))
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
if (!(STREQ(cpu->model, "POWER7_v2.1") ||
|
||||||
|
STREQ(cpu->model, "POWER7_v2.3") ||
|
||||||
|
STREQ(cpu->model, "POWER7+_v2.1") ||
|
||||||
|
STREQ(cpu->model, "POWER8_v1.0"))) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
cpu->model[strlen("POWERx")] = 0;
|
||||||
|
|
||||||
|
out:
|
||||||
|
return cpu;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ppc64DataFree(virCPUppc64Data *data)
|
ppc64DataFree(virCPUppc64Data *data)
|
||||||
{
|
{
|
||||||
@ -424,18 +451,22 @@ ppc64MakeCPUData(virArch arch,
|
|||||||
|
|
||||||
static virCPUCompareResult
|
static virCPUCompareResult
|
||||||
ppc64Compute(virCPUDefPtr host,
|
ppc64Compute(virCPUDefPtr host,
|
||||||
const virCPUDef *cpu,
|
const virCPUDef *other,
|
||||||
virCPUDataPtr *guestData,
|
virCPUDataPtr *guestData,
|
||||||
char **message)
|
char **message)
|
||||||
{
|
{
|
||||||
struct ppc64_map *map = NULL;
|
struct ppc64_map *map = NULL;
|
||||||
struct ppc64_model *host_model = NULL;
|
struct ppc64_model *host_model = NULL;
|
||||||
struct ppc64_model *guest_model = NULL;
|
struct ppc64_model *guest_model = NULL;
|
||||||
|
virCPUDefPtr cpu = NULL;
|
||||||
virCPUCompareResult ret = VIR_CPU_COMPARE_ERROR;
|
virCPUCompareResult ret = VIR_CPU_COMPARE_ERROR;
|
||||||
virArch arch;
|
virArch arch;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
|
/* Ensure existing configurations are handled correctly */
|
||||||
|
if (!(cpu = ppc64ConvertLegacyCPUDef(other)))
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
if (cpu->arch != VIR_ARCH_NONE) {
|
if (cpu->arch != VIR_ARCH_NONE) {
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
@ -504,6 +535,7 @@ ppc64Compute(virCPUDefPtr host,
|
|||||||
ret = VIR_CPU_COMPARE_IDENTICAL;
|
ret = VIR_CPU_COMPARE_IDENTICAL;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
virCPUDefFree(cpu);
|
||||||
ppc64MapFree(map);
|
ppc64MapFree(map);
|
||||||
ppc64ModelFree(host_model);
|
ppc64ModelFree(host_model);
|
||||||
ppc64ModelFree(guest_model);
|
ppc64ModelFree(guest_model);
|
||||||
@ -681,6 +713,17 @@ ppc64DriverBaseline(virCPUDefPtr *cpus,
|
|||||||
for (i = 0; i < ncpus; i++) {
|
for (i = 0; i < ncpus; i++) {
|
||||||
const struct ppc64_vendor *vnd;
|
const struct ppc64_vendor *vnd;
|
||||||
|
|
||||||
|
/* Hosts running old (<= 1.2.18) versions of libvirt will report
|
||||||
|
* strings like 'power7+' or 'power8e' instead of proper CPU model
|
||||||
|
* names in the capabilities XML; moreover, they lack information
|
||||||
|
* about some proper CPU models like 'POWER8'.
|
||||||
|
* This implies two things:
|
||||||
|
* 1) baseline among such hosts never worked
|
||||||
|
* 2) while a few models, eg. 'POWER8_v1.0', could work on both
|
||||||
|
* old and new versions of libvirt, the information we have
|
||||||
|
* here is not enough to pick such a model
|
||||||
|
* Hence we just compare models by name to decide whether or not
|
||||||
|
* two hosts are compatible */
|
||||||
if (STRNEQ(cpus[i]->model, model->name)) {
|
if (STRNEQ(cpus[i]->model, model->name)) {
|
||||||
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
|
virReportError(VIR_ERR_OPERATION_FAILED, "%s",
|
||||||
_("CPUs are incompatible"));
|
_("CPUs are incompatible"));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user