diff mbox

[v2,3/3] migration: allow to suppress configuration section submission

Message ID 20160217160628.840.96784.stgit@bahia.huguette.org (mailing list archive)
State New, archived
Headers show

Commit Message

Greg Kurz Feb. 17, 2016, 4:06 p.m. UTC
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

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.

Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
---
 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(-)

Comments

David Gibson Feb. 18, 2016, 2:50 a.m. UTC | #1
On Wed, Feb 17, 2016 at 05:06:43PM +0100, Greg Kurz wrote:
> 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
> 
> 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.

> 
> Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>

Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

I'm not sure whose tree these need to go in via.

> ---
>  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(-)
> 
> diff --git a/hw/core/machine.c b/hw/core/machine.c
> index 7203dd260bf2..ad4ecdc65787 100644
> --- a/hw/core/machine.c
> +++ b/hw/core/machine.c
> @@ -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;
> diff --git a/include/hw/boards.h b/include/hw/boards.h
> index d6ff1ba4c260..35aaa6493458 100644
> --- a/include/hw/boards.h
> +++ b/include/hw/boards.h
> @@ -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;
> diff --git a/migration/savevm.c b/migration/savevm.c
> index f8dee03a3350..3fd07efeb38b 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -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);
>      }
> diff --git a/qemu-options.hx b/qemu-options.hx
> index 172471c75b1c..af08fa8ec314 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -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}[,...]]
>
Amit Shah Feb. 18, 2016, 6:36 a.m. UTC | #2
On (Thu) 18 Feb 2016 [13:50:25], David Gibson wrote:
> On Wed, Feb 17, 2016 at 05:06:43PM +0100, Greg Kurz wrote:
> > 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
> > 
> > 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.
> 
> > 
> > Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
> 
> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> 
> 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
Greg Kurz Feb. 18, 2016, 9:24 a.m. UTC | #3
On Thu, 18 Feb 2016 12:06:39 +0530
Amit Shah <amit.shah@redhat.com> wrote:

> On (Thu) 18 Feb 2016 [13:50:25], David Gibson wrote:
> > On Wed, Feb 17, 2016 at 05:06:43PM +0100, Greg Kurz wrote:  
> > > 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
> > > 
> > > 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.
> >   
> > > 
> > > Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>  
> > 
> > Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> > 
> > 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
Laurent Vivier Feb. 18, 2016, 10:25 a.m. UTC | #4
On 18/02/2016 10:24, Greg Kurz wrote:
> On Thu, 18 Feb 2016 12:06:39 +0530
> Amit Shah <amit.shah@redhat.com> wrote:
> 
>> On (Thu) 18 Feb 2016 [13:50:25], David Gibson wrote:
>>> On Wed, Feb 17, 2016 at 05:06:43PM +0100, Greg Kurz wrote:  
>>>> 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
>>>>
>>>> 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.
>>>   
>>>>
>>>> Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>  
>>>
>>> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
>>>
>>> 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 ?

Yes :)

If you post a new series with this idea, I'll test it to be sure we
don't introduce new problems.

Laurent
diff mbox

Patch

diff --git a/hw/core/machine.c b/hw/core/machine.c
index 7203dd260bf2..ad4ecdc65787 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -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;
diff --git a/include/hw/boards.h b/include/hw/boards.h
index d6ff1ba4c260..35aaa6493458 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -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;
diff --git a/migration/savevm.c b/migration/savevm.c
index f8dee03a3350..3fd07efeb38b 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -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);
     }
diff --git a/qemu-options.hx b/qemu-options.hx
index 172471c75b1c..af08fa8ec314 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -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}[,...]]