[libvirt] [PATCH v3 17/20] cpu: Implement backwards compatibility in the ppc64 driver

Jiri Denemark jdenemar at redhat.com
Tue Aug 11 13:17:34 UTC 2015


On Mon, Aug 10, 2015 at 10:55:59 +0200, Andrea Bolognani wrote:
> 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.
> ---
>  src/cpu/cpu_ppc64.c | 36 ++++++++++++++++++++++++++++++++++--
>  1 file changed, 34 insertions(+), 2 deletions(-)
> 
> diff --git a/src/cpu/cpu_ppc64.c b/src/cpu/cpu_ppc64.c
> index bf8f4da..d87e0d1 100644
> --- a/src/cpu/cpu_ppc64.c
> +++ b/src/cpu/cpu_ppc64.c
> @@ -57,6 +57,33 @@ struct ppc64_map {
>      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
> +ppc64LegacyConvertCPUDef(const virCPUDef *legacy)

I think ppc64ConvertLegacyCPUDef would be a slightly better name.

> +{
> +    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
>  ppc64DataFree(virCPUppc64Data *data)
>  {
> @@ -426,18 +453,22 @@ ppc64MakeCPUData(virArch arch,
>  
>  static virCPUCompareResult
>  ppc64Compute(virCPUDefPtr host,
> -             const virCPUDef *cpu,
> +             const virCPUDef *other,
>               virCPUDataPtr *guestData,
>               char **message)
>  {
>      struct ppc64_map *map = NULL;
>      struct ppc64_model *host_model = NULL;
>      struct ppc64_model *guest_model = NULL;
> -
> +    virCPUDefPtr cpu = NULL;
>      virCPUCompareResult ret = VIR_CPU_COMPARE_ERROR;
>      virArch arch;
>      size_t i;
>  
> +    /* Ensure existing configurations are handled correctly */
> +    if (!(cpu = ppc64LegacyConvertCPUDef(other)))
> +        goto cleanup;
> +
>      if (cpu->arch != VIR_ARCH_NONE) {
>          bool found = false;
>  

When reading the tests, I realized we don't do any compatibility hacks
for *Baseline, which is correct because it never worked on Power, but we
should explicitly document it inside ppc64Baseline to avoid confusion in
the future.

> @@ -506,6 +537,7 @@ ppc64Compute(virCPUDefPtr host,
>      ret = VIR_CPU_COMPARE_IDENTICAL;
>  
>   cleanup:
> +    virCPUDefFree(cpu);
>      ppc64MapFree(map);
>      ppc64ModelFree(host_model);
>      ppc64ModelFree(guest_model);

ACK with the comment added.

Jirka




More information about the libvir-list mailing list