Fix migration of old pseries
v2 cover Fix migration of old pseries
QEMU 2.4 broke the migration of old pseries machine with the addition of configuration sections, which are sent unconditionally.
This series tries to fix the issue by providing knobs to control submission and reception of configuration sections. It is an alternative to simply skipping configuration for older machines (as it done for x86) because we don't want to break migration from QEMU 2.4 either.
Patches 1 and 2 allow to migrate pseries-2.3 from QEMU 2.3.
Patch 3 is a tentative to support backward migration to QEMU 2.3, but it needs manual intervention.
With this series, I could migrate a pseries-2.3 from QEMU 2.3 or QEMU 2.4 to current head without manual intervention. I could then migrate it back either to QEMU 2.3 with suppress-config-section=on or to QEMU 2.4 without manual intervention.
---
Greg Kurz (3):
migration: allow configuration section to be optional
spapr: fix migration of older pseries
migration: allow to suppress configuration section submission
hw/core/machine.c | 43 +++++++++++++++++++++++++++++++++++++++++++ hw/ppc/spapr.c | 10 ++++++++++ include/hw/boards.h | 2 ++ migration/savevm.c | 29 ++++++++++++++++++++++------- qemu-options.hx | 4 +++- 5 files changed, 80 insertions(+), 8 deletions(-)
---
Greg
PATCH v2 1/3 migration: allow configuration section to be optional
Since QEMU 2.4, the migration stream begins with a configuration section. It is known to break migration of pseries machine from older QEMU. It is possible to fix this in the pseries compat code but it will then break migration of old pseries from latest QEMU.
As an alternative, this patch introduces a new machine property which allows to ignore the abscence of configuration section during incoming migration. It boils to adding:
-machine require-config-section=off
Using this property only makes sense when migrating from an older QEMU. It has no effect on outgoing migration.
---
v2: - renamed property to require-config-section
--- hw/core/machine.c | 22 ++++++++++++++++++++++ include/hw/boards.h | 1 + migration/savevm.c | 21 +++++++++++++++------ qemu-options.hx | 3 ++- 4 files changed, 40 insertions(+), 7 deletions(-)
hw/core/machine.c +22 -0
@@ -312,6 +312,21 @@ static bool machine_get_suppress_vmdesc(Object *obj, Error **errp)return ms->suppress_vmdesc; } +static void machine_set_require_config_section (Object *obj,bool value, +Error **errp) +{ +MachineState *ms =MACHINE (obj); + + ms->require_config_section = value; +} + +static bool machine_get_require_config_section (Object *obj,Error **errp) +{ +MachineState *ms =MACHINE (obj); + +return ms->require_config_section; +} +static int error_on_sysbus_device (SysBusDevice *sbdev,void *opaque) { error_report("Option '-device %s' cannot be handled by this machine",
@@ -365,6 +380,7 @@ static void machine_initfn(Object *obj) ms->kvm_shadow_mem =-1 ; ms->dump_guest_core = true; ms->mem_merge = true; + ms->require_config_section = true;object_property_add_str (obj,"accel" , machine_get_accel, machine_set_accel,NULL );
@@ -467,6 +483,12 @@ static void machine_initfn(Object *obj)object_property_set_description (obj,"suppress-vmdesc" ,"Set on to disable self-describing migration" ,NULL ); +object_property_add_bool (obj,"require-config-section" , + machine_get_require_config_section, + machine_set_require_config_section,NULL ); +object_property_set_description (obj,"require-config-section" , +"Set on/off to reject/accept migration without configuration section" , +NULL );/* Register notifier when init is done for sysbus sanity checks */ ms->sysbus_notifier.notify = machine_init_notify;
include/hw/boards.h +1 -0
@@ -128,6 +128,7 @@ struct MachineState {char *firmware;bool iommu;bool suppress_vmdesc; +bool require_config_section;ram_addr_t ram_size;ram_addr_t maxram_size;
migration/savevm.c +15 -6
@@ -1847,6 +1847,12 @@ static int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis)return 0 ; } +static bool must_receive_configuration (void ) +{ +MachineState *machine =MACHINE (qdev_get_machine ()); +return machine->require_config_section; +} +int qemu_loadvm_state (QEMUFile *f) {MigrationIncomingState *mis =migration_incoming_get_current ();
@@ -1876,15 +1882,18 @@ int qemu_loadvm_state(QEMUFile *f) }if (!savevm_state.skip_configuration) { -if (qemu_get_byte (f) !=QEMU_VM_CONFIGURATION ) { +if (qemu_peek_byte (f,0 ) ==QEMU_VM_CONFIGURATION ) { +qemu_file_skip (f,1 ); + ret =vmstate_load_state (f, &vmstate_configuration, &savevm_state, +0 ); + +if (ret) { +return ret; + } + }else if (must_receive_configuration ()) {error_report ("Configuration section missing" );return -EINVAL ; } - ret =vmstate_load_state (f, &vmstate_configuration, &savevm_state,0 ); - -if (ret) { -return ret; - } } ret =qemu_loadvm_state_main (f, mis);
qemu-options.hx +2 -1
@@ -43,7 +43,8 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \ " aes-key-wrap=on|off controls support for AES key wrapping (default=on)\n" " dea-key-wrap=on|off controls support for DEA key wrapping (default=on)\n" " suppress-vmdesc=on|off disables self-describing migration (default=off)\n" - " nvdimm=on|off controls NVDIMM support (default=off)\n", + " nvdimm=on|off controls NVDIMM support (default=off)\n" + " require-config-section=on|off incoming migration requires configuration section (default=on)\n", QEMU_ARCH_ALL) STEXI @item -machine [type=]@var{name}[,prop=@var{value}[,...]]
PATCH v2 2/3 spapr: fix migration of older pseries
In reply to Greg KurzUse the require-config-section machine property to fix migration of older pseries (version < 2.4) started with an older QEMU (version < 2.4).
Older machines started with QEMU 2.4 are not affected by this change since they send the configuration section unconditionally.
---
v2: - added comment to explain the migration breakage
- updated changelog
--- hw/ppc/spapr.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
hw/ppc/spapr.c +10 -0
@@ -2446,6 +2446,16 @@ static void spapr_machine_2_3_instance_options(MachineState *machine)spapr_machine_2_4_instance_options (machine);savevm_skip_section_footers ();global_state_set_optional (); +/* QEMU 2.4 added a configuration section to the migration stream. A +* call to savevm_skip_configuration() should have been added here +* since pseries-2.3 came with QEMU 2.3. This did not occur. +* The consequence is that pseries-2.3 will now always submit a +* configuration section by default and cannot be migrated back to +* QEMU 2.3. +* The require-config-section property allows pseries-2.3 to be migrated +* from QEMU 2.3 though. +*/ + machine->require_config_section = false; }static void spapr_machine_2_3_class_options (MachineClass *mc)
PATCH v2 3/3 migration: allow to suppress configuration section submission
In reply to Greg KurzSince the addition of the configuration section in QEMU 2.4, it is impossible to migrate a pseries-2.3 machine back to QEMU 2.3.
This patch makes it possible thanks to a new machine property which allows to disable configuration section submission.
To disable submission, just add:
-machine suppress-config-section=on
Alternatively, if the target QEMU version isn't known at startup, this can be done later from the QEMU monitor with:
qom-set /machine suppress-config-section on
This property won't be automatically set for pseries-2.3 because it would then break backward migration to QEMU 2.4. If automatic behaviour is needed, it is up to the tooling to handle this.
--- hw/core/machine.c | 21 +++++++++++++++++++++ include/hw/boards.h | 1 + migration/savevm.c | 8 +++++++- qemu-options.hx | 3 ++- 4 files changed, 31 insertions(+), 2 deletions(-)
hw/core/machine.c +21 -0
@@ -327,6 +327,21 @@ static bool machine_get_require_config_section(Object *obj, Error **errp)return ms->require_config_section; } +static void machine_set_suppress_config_section (Object *obj,bool value, +Error **errp) +{ +MachineState *ms =MACHINE (obj); + + ms->suppress_config_section = value; +} + +static bool machine_get_suppress_config_section (Object *obj,Error **errp) +{ +MachineState *ms =MACHINE (obj); + +return ms->suppress_config_section; +} +static int error_on_sysbus_device (SysBusDevice *sbdev,void *opaque) { error_report("Option '-device %s' cannot be handled by this machine",
@@ -489,6 +504,12 @@ static void machine_initfn(Object *obj)object_property_set_description (obj,"require-config-section" ,"Set on/off to reject/accept migration without configuration section" ,NULL ); +object_property_add_bool (obj,"suppress-config-section" , + machine_get_suppress_config_section, + machine_set_suppress_config_section,NULL ); +object_property_set_description (obj,"suppress-config-section" , +"Set on/off to enable/disable configuration section migration" , +NULL );/* Register notifier when init is done for sysbus sanity checks */ ms->sysbus_notifier.notify = machine_init_notify;
include/hw/boards.h +1 -0
@@ -129,6 +129,7 @@ struct MachineState {bool iommu;bool suppress_vmdesc;bool require_config_section; +bool suppress_config_section;ram_addr_t ram_size;ram_addr_t maxram_size;
migration/savevm.c +7 -1
@@ -878,13 +878,19 @@ bool qemu_savevm_state_blocked(Error **errp)return false; } +static bool should_send_configuration (void ) +{ +MachineState *machine =MACHINE (qdev_get_machine ()); +return !machine->suppress_config_section; +} +void qemu_savevm_state_header (QEMUFile *f) {trace_savevm_state_header ();qemu_put_be32 (f,QEMU_VM_FILE_MAGIC );qemu_put_be32 (f,QEMU_VM_FILE_VERSION ); -if (!savevm_state.skip_configuration) { +if (!savevm_state.skip_configuration &&should_send_configuration ()) {qemu_put_byte (f,QEMU_VM_CONFIGURATION );vmstate_save_state (f, &vmstate_configuration, &savevm_state,0 ); }
qemu-options.hx +2 -1
@@ -44,7 +44,8 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \ " dea-key-wrap=on|off controls support for DEA key wrapping (default=on)\n" " suppress-vmdesc=on|off disables self-describing migration (default=off)\n" " nvdimm=on|off controls NVDIMM support (default=off)\n" - " require-config-section=on|off incoming migration requires configuration section (default=on)\n", + " require-config-section=on|off incoming migration requires configuration section (default=on)\n" + " suppress-config-section=on|off disables configuration section migration (default=off)\n", QEMU_ARCH_ALL) STEXI @item -machine [type=]@var{name}[,prop=@var{value}[,...]]
Re: [Qemu-devel] [PATCH v2 3/3] migration: allow to suppress configuration section submission
Quoted 10 lines · Greg Kurz
Since the addition of the configuration section in QEMU 2.4, it is impossible to migrate a pseries-2.3 machine back to QEMU 2.3.
This patch makes it possible thanks to a new machine property which allows to disable configuration section submission.
To disable submission, just add:
-machine suppress-config-section=on
Quoted 8 lines
Alternatively, if the target QEMU version isn't known at startup, this can be done later from the QEMU monitor with:
qom-set /machine suppress-config-section on
This property won't be automatically set for pseries-2.3 because it would then break backward migration to QEMU 2.4. If automatic behaviour is needed, it is up to the tooling to handle this.
As noted elsewhere, I'd actually be ok with enabling it for pseries-2.3. Basically we have to chose whether to work against qemu 2.3 or 2.4 out of the box, we can't have both, and it sounds like qemu 2.3 is more widely deployed than qemu 2.4.
Quoted 2 lines
Signed-off-by Greg Kurz <[email protected]>
I'm not sure whose tree these need to go in via.
Quoted 98 lines
--- hw/core/machine.c | 21 +++++++++++++++++++++ include/hw/boards.h | 1 + migration/savevm.c | 8 +++++++- qemu-options.hx | 3 ++- 4 files changed, 31 insertions(+), 2 deletions(-)hw/core/machine.c +21
-0@@ -327,6 +327,21 @@ static bool machine_get_require_config_section(Object *obj, Error **errp)return ms->require_config_section; } +static void machine_set_suppress_config_section (Object *obj,bool value, +Error **errp) +{ +MachineState *ms =MACHINE (obj); + + ms->suppress_config_section = value; +} + +static bool machine_get_suppress_config_section (Object *obj,Error **errp) +{ +MachineState *ms =MACHINE (obj); + +return ms->suppress_config_section; +} +static int error_on_sysbus_device (SysBusDevice *sbdev,void *opaque) { error_report("Option '-device %s' cannot be handled by this machine",@@ -489,6 +504,12 @@ static void machine_initfn(Object *obj)object_property_set_description (obj,"require-config-section" ,"Set on/off to reject/accept migration without configuration section" ,NULL ); +object_property_add_bool (obj,"suppress-config-section" , + machine_get_suppress_config_section, + machine_set_suppress_config_section,NULL ); +object_property_set_description (obj,"suppress-config-section" , +"Set on/off to enable/disable configuration section migration" , +NULL );/* Register notifier when init is done for sysbus sanity checks */ ms->sysbus_notifier.notify = machine_init_notify;include/hw/boards.h +1
-0@@ -129,6 +129,7 @@ struct MachineState {bool iommu;bool suppress_vmdesc;bool require_config_section; +bool suppress_config_section;ram_addr_t ram_size;ram_addr_t maxram_size;migration/savevm.c +7
-1@@ -878,13 +878,19 @@ bool qemu_savevm_state_blocked(Error **errp)return false; } +static bool should_send_configuration (void ) +{ +MachineState *machine =MACHINE (qdev_get_machine ()); +return !machine->suppress_config_section; +} +void qemu_savevm_state_header (QEMUFile *f) {trace_savevm_state_header ();qemu_put_be32 (f,QEMU_VM_FILE_MAGIC );qemu_put_be32 (f,QEMU_VM_FILE_VERSION ); -if (!savevm_state.skip_configuration) { +if (!savevm_state.skip_configuration &&should_send_configuration ()) {qemu_put_byte (f,QEMU_VM_CONFIGURATION );vmstate_save_state (f, &vmstate_configuration, &savevm_state,0 ); }qemu-options.hx +2
-1@@ -44,7 +44,8 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \ " dea-key-wrap=on|off controls support for DEA key wrapping (default=on)\n" " suppress-vmdesc=on|off disables self-describing migration (default=off)\n" " nvdimm=on|off controls NVDIMM support (default=off)\n" - " require-config-section=on|off incoming migration requires configuration section (default=on)\n", + " require-config-section=on|off incoming migration requires configuration section (default=on)\n" + " suppress-config-section=on|off disables configuration section migration (default=off)\n", QEMU_ARCH_ALL) STEXI @item -machine [type=]@var{name}[,prop=@var{value}[,...]]
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [Qemu-devel] [PATCH v2 3/3] migration: allow to suppress configuration section submission
Quoted 26 lines · David Gibson
Quoted 10 lines · Greg Kurz
Since the addition of the configuration section in QEMU 2.4, it is impossible to migrate a pseries-2.3 machine back to QEMU 2.3.
This patch makes it possible thanks to a new machine property which allows to disable configuration section submission.
To disable submission, just add:
-machine suppress-config-section=on
Quoted 8 lines
Alternatively, if the target QEMU version isn't known at startup, this can be done later from the QEMU monitor with:
qom-set /machine suppress-config-section on
This property won't be automatically set for pseries-2.3 because it would then break backward migration to QEMU 2.4. If automatic behaviour is needed, it is up to the tooling to handle this.
As noted elsewhere, I'd actually be ok with enabling it for pseries-2.3. Basically we have to chose whether to work against qemu 2.3 or 2.4 out of the box, we can't have both, and it sounds like qemu 2.3 is more widely deployed than qemu 2.4.
Quoted 1 line
Quoted 5 lines
Quoted 1 line
Signed-off-by Greg Kurz <[email protected]>Reviewed-by David Gibson <[email protected]>I'm not sure whose tree these need to go in via.
I'd like to see Juan's ack, and I'm fine if you take it via your tree.
Amit
Re: [Qemu-devel] [PATCH v2 3/3] migration: allow to suppress configuration section submission
Quoted 31 lines · On Thu, 18 Feb 2016 12:06:39 +0530 Amit Shah <[email protected]> wrote:
Quoted 30 lines · David Gibson
Quoted 10 lines · Greg Kurz
Since the addition of the configuration section in QEMU 2.4, it is impossible to migrate a pseries-2.3 machine back to QEMU 2.3.
This patch makes it possible thanks to a new machine property which allows to disable configuration section submission.
To disable submission, just add:
-machine suppress-config-section=on
Quoted 8 lines
Alternatively, if the target QEMU version isn't known at startup, this can be done later from the QEMU monitor with:
qom-set /machine suppress-config-section on
This property won't be automatically set for pseries-2.3 because it would then break backward migration to QEMU 2.4. If automatic behaviour is needed, it is up to the tooling to handle this.
As noted elsewhere, I'd actually be ok with enabling it for pseries-2.3. Basically we have to chose whether to work against qemu 2.3 or 2.4 out of the box, we can't have both, and it sounds like qemu 2.3 is more widely deployed than qemu 2.4.
Quoted 2 lines
Signed-off-by Greg Kurz <[email protected]>Reviewed-by David Gibson <[email protected]>
Quoted 8 lines
Quoted 1 line
I'm not sure whose tree these need to go in via.
I'd like to see Juan's ack, and I'm fine if you take it via your tree.
Amit
Hi,
I also have another option I'd like to submit. Basically, this would be:
- introduce a enforce-config-section machine property which allows to override the savevm_state.skip_configuration flag
- update pseries-2.3 to skip configuration section by default (like it should have been done in the beginning)
It would fix migration from/to QEMU 2.3 of pseries-2.3 without manual intervention. Only migration to/from QEMU 2.4/2.5 would require manual use of the enforce-config-section.
Laurent, is this what you had in mind ?
--
Greg
Re: [Qemu-devel] [PATCH v2 3/3] migration: allow to suppress configuration section submission
Quoted 52 lines · Greg Kurz
Quoted 31 lines · On Thu, 18 Feb 2016 12:06:39 +0530 Amit Shah <[email protected]> wrote:
Quoted 30 lines · David Gibson
Quoted 10 lines · Greg Kurz
Since the addition of the configuration section in QEMU 2.4, it is impossible to migrate a pseries-2.3 machine back to QEMU 2.3.
This patch makes it possible thanks to a new machine property which allows to disable configuration section submission.
To disable submission, just add:
-machine suppress-config-section=on
Quoted 8 lines
Alternatively, if the target QEMU version isn't known at startup, this can be done later from the QEMU monitor with:
qom-set /machine suppress-config-section on
This property won't be automatically set for pseries-2.3 because it would then break backward migration to QEMU 2.4. If automatic behaviour is needed, it is up to the tooling to handle this.
As noted elsewhere, I'd actually be ok with enabling it for pseries-2.3. Basically we have to chose whether to work against qemu 2.3 or 2.4 out of the box, we can't have both, and it sounds like qemu 2.3 is more widely deployed than qemu 2.4.
Quoted 2 lines
Signed-off-by Greg Kurz <[email protected]>Reviewed-by David Gibson <[email protected]>Quoted 8 lines
Quoted 1 line
I'm not sure whose tree these need to go in via.
I'd like to see Juan's ack, and I'm fine if you take it via your tree.
Amit
Hi,
I also have another option I'd like to submit. Basically, this would be:
- introduce a enforce-config-section machine property which allows to override the savevm_state.skip_configuration flag
- update pseries-2.3 to skip configuration section by default (like it should have been done in the beginning)
Quoted 5 lines
It would fix migration from/to QEMU 2.3 of pseries-2.3 without manual intervention. Only migration to/from QEMU 2.4/2.5 would require manual use of the enforce-config-section.
Laurent, is this what you had in mind ?
Yes :)
If you post a new series with this idea, I'll test it to be sure we don't introduce new problems.
Laurent