diff mbox series

spapr: Don't migrate the hpt_maxpagesize cap to older machine types

Message ID 155853262675.1158324.17301777846476373459.stgit@bahia.lan (mailing list archive)
State New, archived
Headers show
Series spapr: Don't migrate the hpt_maxpagesize cap to older machine types | expand

Commit Message

Greg Kurz May 22, 2019, 1:43 p.m. UTC
Commit 0b8c89be7f7b added the hpt_maxpagesize capability to the migration
stream. This is okay for new machine types but it breaks backward migration
to older QEMUs, which don't expect the extra subsection.

Add a compatibility boolean flag to the sPAPR machine class and use it to
skip migration of the capability for machine types 4.0 and older. This
fixes migration to an older QEMU. Note that the destination will emit a
warning:

qemu-system-ppc64: warning: cap-hpt-max-page-size lower level (16) in incoming stream than on destination (24)

This is expected and harmless though. It is okay to migrate from a lower
HPT maximum page size (64k) to a greater one (16M).

Fixes: 0b8c89be7f7b "spapr: Add forgotten capability to migration stream"
Based-on: <20190522074016.10521-3-clg@kaod.org>
Signed-off-by: Greg Kurz <groug@kaod.org>
---

Please notice that this is based on Cedric's patch that make "dual" the
default for the ic-mode property.
---
 hw/ppc/spapr.c         |    1 +
 hw/ppc/spapr_caps.c    |   12 +++++++++++-
 include/hw/ppc/spapr.h |    1 +
 3 files changed, 13 insertions(+), 1 deletion(-)

Comments

David Gibson May 22, 2019, 11:22 p.m. UTC | #1
On Wed, May 22, 2019 at 03:43:46PM +0200, Greg Kurz wrote:
> Commit 0b8c89be7f7b added the hpt_maxpagesize capability to the migration
> stream. This is okay for new machine types but it breaks backward migration
> to older QEMUs, which don't expect the extra subsection.
> 
> Add a compatibility boolean flag to the sPAPR machine class and use it to
> skip migration of the capability for machine types 4.0 and older. This
> fixes migration to an older QEMU. Note that the destination will emit a
> warning:
> 
> qemu-system-ppc64: warning: cap-hpt-max-page-size lower level (16) in incoming stream than on destination (24)
> 
> This is expected and harmless though. It is okay to migrate from a lower
> HPT maximum page size (64k) to a greater one (16M).
> 
> Fixes: 0b8c89be7f7b "spapr: Add forgotten capability to migration stream"
> Based-on: <20190522074016.10521-3-clg@kaod.org>
> Signed-off-by: Greg Kurz <groug@kaod.org>

Applied, thanks.

> ---
> 
> Please notice that this is based on Cedric's patch that make "dual" the
> default for the ic-mode property.
> ---
>  hw/ppc/spapr.c         |    1 +
>  hw/ppc/spapr_caps.c    |   12 +++++++++++-
>  include/hw/ppc/spapr.h |    1 +
>  3 files changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 4fd16b43f014..e2b33e5890ae 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -4431,6 +4431,7 @@ static void spapr_machine_4_0_class_options(MachineClass *mc)
>      compat_props_add(mc->compat_props, hw_compat_4_0, hw_compat_4_0_len);
>      smc->phb_placement = phb_placement_4_0;
>      smc->irq = &spapr_irq_xics;
> +    smc->pre_4_1_migration = true;
>  }
>  
>  DEFINE_SPAPR_MACHINE(4_0, "4.0", false);
> diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c
> index 658eb15a147b..31b466139975 100644
> --- a/hw/ppc/spapr_caps.c
> +++ b/hw/ppc/spapr_caps.c
> @@ -64,6 +64,7 @@ typedef struct SpaprCapabilityInfo {
>      void (*apply)(SpaprMachineState *spapr, uint8_t val, Error **errp);
>      void (*cpu_apply)(SpaprMachineState *spapr, PowerPCCPU *cpu,
>                        uint8_t val, Error **errp);
> +    bool (*migrate_needed)(void *opaque);
>  } SpaprCapabilityInfo;
>  
>  static void spapr_cap_get_bool(Object *obj, Visitor *v, const char *name,
> @@ -350,6 +351,11 @@ static void cap_hpt_maxpagesize_apply(SpaprMachineState *spapr,
>      spapr_check_pagesize(spapr, qemu_minrampagesize(), errp);
>  }
>  
> +static bool cap_hpt_maxpagesize_migrate_needed(void *opaque)
> +{
> +    return !SPAPR_MACHINE_GET_CLASS(opaque)->pre_4_1_migration;
> +}
> +
>  static bool spapr_pagesize_cb(void *opaque, uint32_t seg_pshift,
>                                uint32_t pshift)
>  {
> @@ -542,6 +548,7 @@ SpaprCapabilityInfo capability_table[SPAPR_CAP_NUM] = {
>          .type = "int",
>          .apply = cap_hpt_maxpagesize_apply,
>          .cpu_apply = cap_hpt_maxpagesize_cpu_apply,
> +        .migrate_needed = cap_hpt_maxpagesize_migrate_needed,
>      },
>      [SPAPR_CAP_NESTED_KVM_HV] = {
>          .name = "nested-hv",
> @@ -679,8 +686,11 @@ int spapr_caps_post_migration(SpaprMachineState *spapr)
>  static bool spapr_cap_##sname##_needed(void *opaque)    \
>  {                                                       \
>      SpaprMachineState *spapr = opaque;                  \
> +    bool (*needed)(void *opaque) =                      \
> +        capability_table[cap].migrate_needed;           \
>                                                          \
> -    return spapr->cmd_line_caps[cap] &&                 \
> +    return needed ? needed(opaque) : true &&            \
> +           spapr->cmd_line_caps[cap] &&                 \
>             (spapr->eff.caps[cap] !=                     \
>              spapr->def.caps[cap]);                      \
>  }                                                       \
> diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
> index 9fc91c8f5eac..4f5becf1f3cc 100644
> --- a/include/hw/ppc/spapr.h
> +++ b/include/hw/ppc/spapr.h
> @@ -119,6 +119,7 @@ struct SpaprMachineClass {
>      bool pre_2_10_has_unused_icps;
>      bool legacy_irq_allocation;
>      bool broken_host_serial_model; /* present real host info to the guest */
> +    bool pre_4_1_migration; /* don't migrate hpt-max-page-size */
>  
>      void (*phb_placement)(SpaprMachineState *spapr, uint32_t index,
>                            uint64_t *buid, hwaddr *pio, 
>
diff mbox series

Patch

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 4fd16b43f014..e2b33e5890ae 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -4431,6 +4431,7 @@  static void spapr_machine_4_0_class_options(MachineClass *mc)
     compat_props_add(mc->compat_props, hw_compat_4_0, hw_compat_4_0_len);
     smc->phb_placement = phb_placement_4_0;
     smc->irq = &spapr_irq_xics;
+    smc->pre_4_1_migration = true;
 }
 
 DEFINE_SPAPR_MACHINE(4_0, "4.0", false);
diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c
index 658eb15a147b..31b466139975 100644
--- a/hw/ppc/spapr_caps.c
+++ b/hw/ppc/spapr_caps.c
@@ -64,6 +64,7 @@  typedef struct SpaprCapabilityInfo {
     void (*apply)(SpaprMachineState *spapr, uint8_t val, Error **errp);
     void (*cpu_apply)(SpaprMachineState *spapr, PowerPCCPU *cpu,
                       uint8_t val, Error **errp);
+    bool (*migrate_needed)(void *opaque);
 } SpaprCapabilityInfo;
 
 static void spapr_cap_get_bool(Object *obj, Visitor *v, const char *name,
@@ -350,6 +351,11 @@  static void cap_hpt_maxpagesize_apply(SpaprMachineState *spapr,
     spapr_check_pagesize(spapr, qemu_minrampagesize(), errp);
 }
 
+static bool cap_hpt_maxpagesize_migrate_needed(void *opaque)
+{
+    return !SPAPR_MACHINE_GET_CLASS(opaque)->pre_4_1_migration;
+}
+
 static bool spapr_pagesize_cb(void *opaque, uint32_t seg_pshift,
                               uint32_t pshift)
 {
@@ -542,6 +548,7 @@  SpaprCapabilityInfo capability_table[SPAPR_CAP_NUM] = {
         .type = "int",
         .apply = cap_hpt_maxpagesize_apply,
         .cpu_apply = cap_hpt_maxpagesize_cpu_apply,
+        .migrate_needed = cap_hpt_maxpagesize_migrate_needed,
     },
     [SPAPR_CAP_NESTED_KVM_HV] = {
         .name = "nested-hv",
@@ -679,8 +686,11 @@  int spapr_caps_post_migration(SpaprMachineState *spapr)
 static bool spapr_cap_##sname##_needed(void *opaque)    \
 {                                                       \
     SpaprMachineState *spapr = opaque;                  \
+    bool (*needed)(void *opaque) =                      \
+        capability_table[cap].migrate_needed;           \
                                                         \
-    return spapr->cmd_line_caps[cap] &&                 \
+    return needed ? needed(opaque) : true &&            \
+           spapr->cmd_line_caps[cap] &&                 \
            (spapr->eff.caps[cap] !=                     \
             spapr->def.caps[cap]);                      \
 }                                                       \
diff --git a/include/hw/ppc/spapr.h b/include/hw/ppc/spapr.h
index 9fc91c8f5eac..4f5becf1f3cc 100644
--- a/include/hw/ppc/spapr.h
+++ b/include/hw/ppc/spapr.h
@@ -119,6 +119,7 @@  struct SpaprMachineClass {
     bool pre_2_10_has_unused_icps;
     bool legacy_irq_allocation;
     bool broken_host_serial_model; /* present real host info to the guest */
+    bool pre_4_1_migration; /* don't migrate hpt-max-page-size */
 
     void (*phb_placement)(SpaprMachineState *spapr, uint32_t index,
                           uint64_t *buid, hwaddr *pio,