Skip to contentSkip to conversation

migration: fix iotest 055, only-migratable break

PATCH Superseded Peter Xu 5 participants 25 messages Jul 3, 2017 – Jul 6, 2017

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Peter Xu

author
#0 lore raw

cover migration: fix iotest 055, only-migratable break

Two breakage introduced during the migration objectify series: one for --only-migratable, another one for iotest 055.

First two patches fixes the breakages. Latter two are documentation updates suggested by Eduardo. Please review. Thanks.

Peter Xu (4):
migration: fix handling for --only-migratable
vl: move global property, migrate init earlier
doc: add item for "-M enforce-config-section"
doc: update TYPE_MIGRATION documents

 include/migration/misc.h |  1 -
 migration/migration.c    | 20 +++++++++-----------
 qemu-options.hx          |  8 ++++++++
 vl.c                     | 26 +++++++++++++-------------
 4 files changed, 30 insertions(+), 25 deletions(-)
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH 1/4 migration: fix handling for --only-migratable

MigrateState object is not ready at that time, so we'll get an assertion. Use qemu_global_option() instead.

Fixes 3df663e ("migration: move only_migratable to MigrationState")
---
 include/migration/misc.h | 1 -
 migration/migration.c    | 5 -----
 vl.c                     | 2 +-
 3 files changed, 1 insertion(+), 7 deletions(-)
include/migration/misc.h +0 -1
index 2255121..c079b77 100644
@@ -53,7 +53,6 @@ bool migration_has_finished(MigrationState *);
 bool migration_has_failed(MigrationState *);
 /* ...and after the device transmission */
 bool migration_in_postcopy_after_devices(MigrationState *);
-void migration_only_migratable_set(void);
 void migration_global_dump(Monitor *mon);
 
 #endif
migration/migration.c +0 -5
index 51ccd1a..dbdc121 100644
@@ -128,11 +128,6 @@ MigrationState *migrate_get_current(void)
     return current_migration;
 }
 
-void migration_only_migratable_set(void)
-{
-    migrate_get_current()->only_migratable = true;
-}
-
 MigrationIncomingState *migration_incoming_get_current(void)
 {
     static bool once;
vl.c +1 -1
index 36ff3f4..0c497a3 100644
@@ -3958,7 +3958,7 @@ int main(int argc, char **argv, char **envp)
                  *
                  * "-global migration.only-migratable=true"
                  */
-                migration_only_migratable_set();
+                qemu_global_option("migration.only-migratable=true");
                 break;
             case QEMU_OPTION_nodefaults:
                 has_defaults = 0;
Signature · 1 line
2.7.4
author
#4 lore raw

PATCH 2/4 vl: move global property, migrate init earlier

In reply to Peter Xu

Currently drive_init_func() may call migrate_get_current() while the migrate object is still not ready yet at that time. Move the migration object init earlier, along with the global properties, right after acceleration init.

This fixes a breakage for iotest 055, which caused an assertion failure.

Fixes 3df663 ("migration: move only_migratable to MigrationState")
---
 vl.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
vl.c +12 -12
index 0c497a3..2ae4313 100644
@@ -4414,6 +4414,18 @@ int main(int argc, char **argv, char **envp)
 
     configure_accelerator(current_machine);
 
+    /*
+     * Register all the global properties, including accel properties,
+     * machine properties, and user-specified ones.
+     */
+    register_global_properties(current_machine);
+
+    /*
+     * Migration object can only be created after global properties
+     * are applied correctly.
+     */
+    migration_object_init();
+
     if (qtest_chrdev) {
         qtest_init(qtest_chrdev, qtest_log, &error_fatal);
     }
@@ -4595,18 +4607,6 @@ int main(int argc, char **argv, char **envp)
             exit (i == 1 ? 1 : 0);
     }
 
-    /*
-     * Register all the global properties, including accel properties,
-     * machine properties, and user-specified ones.
-     */
-    register_global_properties(current_machine);
-
-    /*
-     * Migration object can only be created after global properties
-     * are applied correctly.
-     */
-    migration_object_init();
-
     /* This checkpoint is required by replay to separate prior clock
        reading from the other reads, because timer polling functions query
        clock values from the log. */
Signature · 1 line
2.7.4
author
#9 lore raw

PATCH 3/4 doc: add item for "-M enforce-config-section"

In reply to Peter Xu

It's never documented, and now we have one more parameter for it (which means this one can be obsolete in the future). Document it properly.

Although now when enforce-config-section is set, it'll override the other "-global" parameter, that is not necessarily a rule. Forbid that usage in the document.

---
 qemu-options.hx | 8 ++++++++
 1 file changed, 8 insertions(+)
qemu-options.hx +8 -0
index 297bd8a..927c51f 100644
@@ -85,6 +85,14 @@ Enables or disables NVDIMM support. The default is off.
 @item s390-squash-mcss=on|off
 Enables or disables squashing subchannels into the default css.
 The default is off.
+@item enforce-config-section=on|off
+Decides whether we will send the configuration section when doing
+migration. By default, it is turned on. We can set this to off to
+explicitly disable it. Note: this parameter will be obsolete soon,
+please use "-global migration.send-configuration=on|off" instead.
+"enforce-config-section" cannot be used together with "-global
+migration.send-configuration". If it happens, the behavior is
+undefined.
 @end table
 ETEXI
 
Signature · 1 line
2.7.4
author
#18 lore raw

PATCH 4/4 doc: update TYPE_MIGRATION documents

In reply to Peter Xu

[Peter collected Eduardo's patch comment and formatted into patch]

---
 migration/migration.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
migration/migration.c +9 -6
index dbdc121..6c64b99 100644
@@ -2052,12 +2052,15 @@ static void migration_instance_init(Object *obj)
 static const TypeInfo migration_type = {
     .name = TYPE_MIGRATION,
     /*
-     * NOTE: "migration" itself is not really a device. We used
-     * TYPE_DEVICE here only to leverage some existing QDev features
-     * like "-global" properties, and HW_COMPAT_* fields (which are
-     * finally applied as global properties as well). If one day the
-     * global property feature can be migrated from QDev to QObject in
-     * general, then we can switch to QObject as well.
+     * NOTE:
+     *
+     * TYPE_MIGRATION is not really a device, as the object is not
+     * created using qdev_create(), it is not attached to the qdev
+     * device tree, and it is never realized.
+     *
+     * If one day we allow non-device QOM objects to use the global
+     * property system, we can switch this from TYPE_DEVICE to
+     * TYPE_OBJECT.
      */
     .parent = TYPE_DEVICE,
     .class_init = migration_class_init,
Signature · 1 line
2.7.4
#23 lore raw
In reply to Peter Xu

I tested the 2 patches and they can make iotest 055 passed on both x86 and s390x.

thanks

Quoted 18 lines · Peter Xu

Two breakage introduced during the migration objectify series: one for --only-migratable, another one for iotest 055.

First two patches fixes the breakages. Latter two are documentation updates suggested by Eduardo. Please review. Thanks.

Peter Xu (4):
migration: fix handling for --only-migratable
vl: move global property, migrate init earlier
doc: add item for "-M enforce-config-section"
doc: update TYPE_MIGRATION documents

  include/migration/misc.h |  1 -
  migration/migration.c    | 20 +++++++++-----------
  qemu-options.hx          |  8 ++++++++
  vl.c                     | 26 +++++++++++++-------------
  4 files changed, 30 insertions(+), 25 deletions(-)
Signature · 2 lines
Regards
QingFeng Hao
author
#24 lore raw
Quoted 2 lines · QingFeng Hao

I tested the 2 patches and they can make iotest 055 passed on both x86 and s390x.

Thanks for testing!

Signature · 1 line
Peter Xu
Reviewed-by on v1 1/4
#2 lore raw

Re: [Qemu-devel] [PATCH 1/4] migration: fix handling for --only-migratable

In reply to Peter Xu
Quoted 7 lines · Peter Xu

MigrateState object is not ready at that time, so we'll get an assertion. Use qemu_global_option() instead.

Fixes 3df663e ("migration: move only_migratable to MigrationState")
Quoted 3 lines

bool migration_in_postcopy_after_devices(MigrationState *);
-void migration_only_migratable_set(void);
void migration_global_dump(Monitor *mon);

Nice, one less exported function.

vl.c int main(int argc, char **argv, char **envp) · line 3964

Quoted 5 lines
vl.c +1 -1
-                migration_only_migratable_set();
+                qemu_global_option("migration.only-migratable=true");
                 break;
             case QEMU_OPTION_nodefaults:
                 has_defaults = 0;

aha, that is a much, much nicer way to set functions.

Later, Juan.

Reviewed-by on v1 3/4
#10 lore raw

Re: [Qemu-devel] [PATCH 3/4] doc: add item for "-M enforce-config-section"

In reply to Peter Xu
Quoted 21 lines · Peter Xu

It's never documented, and now we have one more parameter for it (which means this one can be obsolete in the future). Document it properly.

Although now when enforce-config-section is set, it'll override the other "-global" parameter, that is not necessarily a rule. Forbid that usage in the document.

---
 qemu-options.hx | 8 ++++++++
 1 file changed, 8 insertions(+)
qemu-options.hx +0 -0
index 297bd8a..927c51f 100644
@@ -85,6 +85,14 @@ Enables or disables NVDIMM support. The default is off.
 @item s390-squash-mcss=on|off
 Enables or disables squashing subchannels into the default css.
 The default is off.

qemu-options.hx Enables or disables NVDIMM support. The default is off. · line 97

Quoted 10 lines
qemu-options.hx +8 -0
+@item enforce-config-section=on|off
+Decides whether we will send the configuration section when doing
+migration. By default, it is turned on. We can set this to off to
+explicitly disable it. Note: this parameter will be obsolete soon,
+please use "-global migration.send-configuration=on|off" instead.
+"enforce-config-section" cannot be used together with "-global
+migration.send-configuration". If it happens, the behavior is
+undefined.
 @end table
 ETEXI

I will have been explicit that it is *already* obsolete, just that we don't have a way to say that.

Later, Juan.

Reviewed-by on v1 2/4
#5 lore raw

Re: [Qemu-devel] [PATCH 2/4] vl: move global property, migrate init earlier

In reply to Peter Xu
Quoted 25 lines · Peter Xu

Currently drive_init_func() may call migrate_get_current() while the migrate object is still not ready yet at that time. Move the migration object init earlier, along with the global properties, right after acceleration init.

This fixes a breakage for iotest 055, which caused an assertion failure.

Fixes 3df663 ("migration: move only_migratable to MigrationState")
---
 vl.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
vl.c +2 -0
index 0c497a3..2ae4313 100644
@@ -4414,6 +4414,18 @@ int main(int argc, char **argv, char **envp)
 
     configure_accelerator(current_machine);
 
+    /*
+     * Register all the global properties, including accel properties,

vl.c int main(int argc, char **argv, char **envp) · line 4428

Quoted 10 lines
vl.c +10 -0
+     * machine properties, and user-specified ones.
+     */
+    register_global_properties(current_machine);
+
+    /*
+     * Migration object can only be created after global properties
+     * are applied correctly.
+     */
+    migration_object_init();
+

So, things that might introduce bugs here are:
1) Unexpected qdev_prop_register_global() calls between this place and the original register_global_properties() call (that would now happen in a different order).
2) register_global_properties() seeing a different global property list because it is being called earlier.
2.1) AccelClass::global_props is statically defined and will be the
same here. Not a problem.
2.2) MachineClass::compat_props: same as above.
2.3) user-provided global properties: we need to ensure all
properties in the "global" QemuOpts section are already available at this point.

To ensure (1) is not a problem, we need to check all calls for qdev_prop_register_global(). The callers are:

* configure_rtc()
- Called very early, when parsing command-line options. Not a problem.[1]
* global_init_func()
* Called by user_register_global_props()
* Called by register_global_properties().
- That's the code we're moving. Not a problem.
* QEMU_OPTION_rtc_td_hack case in main()
- Called very early, when parsing command-line options. Not a problem.[1]
* QEMU_OPTION_no_kvm_pit_reinjection case in main()
- Called very early, when parsing command-line options. Not a problem.[1]
* register_compat_prop()
* Called by machine_register_compat_props()
* Called by register_global_properties().
- That's the code we're moving. Not a problem.
* Called by machine_register_compat_for_subclass()
* Called by machine_register_compat_props() (see above)
* Called by register_compat_props_array()
* Called by accel_register_compat_props()
* Called by register_global_properties().
- That's the code we're moving. Not a problem.
* qdev_prop_register_global_list()
- Used only by unit test code.
* cpu_common_parse_features()
- Used when initializing CPUs, which is done much later, when machine_run_board_init() is called (or when -device is handled by device_init_func()). Not a problem.[2]
* x86_cpu_parse_featurestr()
- Same as above.

To ensure (2.3) is not a problem, we need to look for references to qemu_find_opts("global") or qemu_global_opts. They are:

* user_register_global_props()
- This is the code we're moving. Not a problem.
* default_driver_check() call at main()
- This happens earlier, before the code we're moving. Not a problem.
* qemu_global_option()
- Called very early, when parsing command-line options. Not a problem.

So the code reordering looks OK.

Notes about things we need to fix in the future:

[1] I think they should be replaced by qemu_global_option() calls, though.
[2] This is a fragile portion of the global property code and should be eventually moved to the command-line parsing section of main().

Quoted 25 lines
vl.c +0 -12
     if (qtest_chrdev) {
         qtest_init(qtest_chrdev, qtest_log, &error_fatal);
     }
@@ -4595,18 +4607,6 @@ int main(int argc, char **argv, char **envp)
             exit (i == 1 ? 1 : 0);
     }
 
-    /*
-     * Register all the global properties, including accel properties,
-     * machine properties, and user-specified ones.
-     */
-    register_global_properties(current_machine);
-
-    /*
-     * Migration object can only be created after global properties
-     * are applied correctly.
-     */
-    migration_object_init();
-
     /* This checkpoint is required by replay to separate prior clock
        reading from the other reads, because timer polling functions query
        clock values from the log. */
Signature · 1 line
2.7.4
Signature · 1 line
Eduardo
Reviewed-by on v1 1/4
#3 lore raw

Re: [Qemu-devel] [PATCH 1/4] migration: fix handling for --only-migratable

In reply to Peter Xu
Quoted 7 lines · Peter Xu

MigrateState object is not ready at that time, so we'll get an assertion. Use qemu_global_option() instead.

Fixes 3df663e ("migration: move only_migratable to MigrationState")
Signature · 1 line
Eduardo
#11 lore raw

Re: [Qemu-devel] [PATCH 3/4] doc: add item for "-M enforce-config-section"

In reply to Peter Xu
Quoted 18 lines · Peter Xu

It's never documented, and now we have one more parameter for it (which means this one can be obsolete in the future). Document it properly.

Although now when enforce-config-section is set, it'll override the other "-global" parameter, that is not necessarily a rule. Forbid that usage in the document.

---
 qemu-options.hx | 8 ++++++++
 1 file changed, 8 insertions(+)
qemu-options.hx +0 -0
index 297bd8a..927c51f 100644

qemu-options.hx Enables or disables NVDIMM support. The default is off. · line 91

Quoted 7 lines
qemu-options.hx +4 -0
@@ -85,6 +85,14 @@ Enables or disables NVDIMM support. The default is off.
 @item s390-squash-mcss=on|off
 Enables or disables squashing subchannels into the default css.
 The default is off.
+@item enforce-config-section=on|off
+Decides whether we will send the configuration section when doing
+migration. By default, it is turned on. We can set this to off to
+explicitly disable it.

[...]

Wait, isn't it off by default?

This seems to imply that "-machine enforce-config-section=on" would have no effect at all, as the option would be already on by default. This is not the case.

I suggest rewriting this as:

If set to "on, force migration code to send configuration section even if the machine-type sets the "migration.send-configuration" property to "off".
Note: this parameter is obsolete, please use "-global migration.send-configuration=on|off" instead.
Behavior is undefined if "enforce-config-section" and "-global migration.send-configuration" are used together.

(Note: we probably should use proper markup (@option/@var/@samp?) instead of quotes above, to format the option names properly in the generated documentation.)

Signature · 1 line
Eduardo
author
#6 lore raw

Re: [Qemu-devel] [PATCH 2/4] vl: move global property, migrate init earlier

In reply to Eduardo Habkost
Quoted 95 lines · Eduardo Habkost
Quoted 25 lines · Peter Xu

Currently drive_init_func() may call migrate_get_current() while the migrate object is still not ready yet at that time. Move the migration object init earlier, along with the global properties, right after acceleration init.

This fixes a breakage for iotest 055, which caused an assertion failure.

Fixes 3df663 ("migration: move only_migratable to MigrationState")
---
 vl.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
vl.c +2 -0
index 0c497a3..2ae4313 100644
@@ -4414,6 +4414,18 @@ int main(int argc, char **argv, char **envp)
 
     configure_accelerator(current_machine);
 
+    /*
+     * Register all the global properties, including accel properties,

vl.c int main(int argc, char **argv, char **envp) · line 4428

Quoted 10 lines
vl.c +10 -0
+     * machine properties, and user-specified ones.
+     */
+    register_global_properties(current_machine);
+
+    /*
+     * Migration object can only be created after global properties
+     * are applied correctly.
+     */
+    migration_object_init();
+

So, things that might introduce bugs here are:
1) Unexpected qdev_prop_register_global() calls between this place and the original register_global_properties() call (that would now happen in a different order).
2) register_global_properties() seeing a different global property list because it is being called earlier.
2.1) AccelClass::global_props is statically defined and will be the
same here. Not a problem.
2.2) MachineClass::compat_props: same as above.
2.3) user-provided global properties: we need to ensure all
properties in the "global" QemuOpts section are already available at this point.

To ensure (1) is not a problem, we need to check all calls for qdev_prop_register_global(). The callers are:

* configure_rtc()
- Called very early, when parsing command-line options. Not a problem.[1]
* global_init_func()
* Called by user_register_global_props()
* Called by register_global_properties().
- That's the code we're moving. Not a problem.
* QEMU_OPTION_rtc_td_hack case in main()
- Called very early, when parsing command-line options. Not a problem.[1]
* QEMU_OPTION_no_kvm_pit_reinjection case in main()
- Called very early, when parsing command-line options. Not a problem.[1]
* register_compat_prop()
* Called by machine_register_compat_props()
* Called by register_global_properties().
- That's the code we're moving. Not a problem.
* Called by machine_register_compat_for_subclass()
* Called by machine_register_compat_props() (see above)
* Called by register_compat_props_array()
* Called by accel_register_compat_props()
* Called by register_global_properties().
- That's the code we're moving. Not a problem.
* qdev_prop_register_global_list()
- Used only by unit test code.
* cpu_common_parse_features()
- Used when initializing CPUs, which is done much later, when machine_run_board_init() is called (or when -device is handled by device_init_func()). Not a problem.[2]
* x86_cpu_parse_featurestr()
- Same as above.

To ensure (2.3) is not a problem, we need to look for references to qemu_find_opts("global") or qemu_global_opts. They are:

* user_register_global_props()
- This is the code we're moving. Not a problem.
* default_driver_check() call at main()
- This happens earlier, before the code we're moving. Not a problem.
* qemu_global_option()
- Called very early, when parsing command-line options. Not a problem.

Quoted 3 lines

So the code reordering looks OK.

I really appreciate for such an in-depth review on this patch.

Quoted 7 lines

Notes about things we need to fix in the future:

[1] I think they should be replaced by qemu_global_option() calls, though.
[2] This is a fragile portion of the global property code and should be eventually moved to the command-line parsing section of main().

Agree on both.

Thanks again!

Signature · 1 line
Peter Xu
author
#12 lore raw

Re: [Qemu-devel] [PATCH 3/4] doc: add item for "-M enforce-config-section"

In reply to Eduardo Habkost
Quoted 44 lines · Eduardo Habkost
Quoted 18 lines · Peter Xu

It's never documented, and now we have one more parameter for it (which means this one can be obsolete in the future). Document it properly.

Although now when enforce-config-section is set, it'll override the other "-global" parameter, that is not necessarily a rule. Forbid that usage in the document.

---
 qemu-options.hx | 8 ++++++++
 1 file changed, 8 insertions(+)
qemu-options.hx +0 -0
index 297bd8a..927c51f 100644

qemu-options.hx Enables or disables NVDIMM support. The default is off. · line 91

Quoted 7 lines
qemu-options.hx +4 -0
@@ -85,6 +85,14 @@ Enables or disables NVDIMM support. The default is off.
 @item s390-squash-mcss=on|off
 Enables or disables squashing subchannels into the default css.
 The default is off.
+@item enforce-config-section=on|off
+Decides whether we will send the configuration section when doing
+migration. By default, it is turned on. We can set this to off to
+explicitly disable it.

[...]

Wait, isn't it off by default?

This seems to imply that "-machine enforce-config-section=on" would have no effect at all, as the option would be already on by default. This is not the case.

I suggest rewriting this as:

If set to "on, force migration code to send configuration section even if the machine-type sets the "migration.send-configuration" property to "off".
Note: this parameter is obsolete, please use "-global migration.send-configuration=on|off" instead.
Behavior is undefined if "enforce-config-section" and "-global migration.send-configuration" are used together.

Quoted 3 lines

(Note: we probably should use proper markup (@option/@var/@samp?) instead of quotes above, to format the option names properly in the generated documentation.)

Yes, you are right. How's this one? (markup used this time)

If @option{enforce-config-section} is set to @var{on}, force migration code to send configuration section even if the machine-type sets the @option{migration.send-configuration} property to @var{off}. @option{enforce-config-section} cannot be used together with @option{-global} @option{migration.send-configuration}. Behavior is undefined if @option{enforce-config-section} and @option{-global} @option{migration.send-configuration} are used together.

NOTE: this parameter is obsolete. Please use @option{-global} @option{migration.send-configuration}=@var{on|off} instead.

Thanks,

Signature · 1 line
Peter Xu
#21 lore raw

Re: [Qemu-devel] [PATCH 4/4] doc: update TYPE_MIGRATION documents

In reply to Peter Xu
Quoted 21 lines · Peter Xu

[Peter collected Eduardo's patch comment and formatted into patch]

---
 migration/migration.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
migration/migration.c +0 -5
index dbdc121..6c64b99 100644
@@ -2052,12 +2052,15 @@ static void migration_instance_init(Object *obj)
 static const TypeInfo migration_type = {
     .name = TYPE_MIGRATION,
     /*
-     * NOTE: "migration" itself is not really a device. We used
-     * TYPE_DEVICE here only to leverage some existing QDev features
-     * like "-global" properties, and HW_COMPAT_* fields (which are
-     * finally applied as global properties as well). If one day the
-     * global property feature can be migrated from QDev to QObject in

migration/migration.c static void migration_instance_init(Object *obj) · line 2063

Quoted 10 lines
migration/migration.c +9 -1
-     * general, then we can switch to QObject as well.
+     * NOTE:
+     *
+     * TYPE_MIGRATION is not really a device, as the object is not
+     * created using qdev_create(), it is not attached to the qdev
+     * device tree, and it is never realized.
+     *
+     * If one day we allow non-device QOM objects to use the global
+     * property system, we can switch this from TYPE_DEVICE to
+     * TYPE_OBJECT.

Suggest to turn this paragraph into a TODO:

* TODO Make this TYPE_OBJECT once QOM provides something like
* TYPE_DEVICE's "-global" properties.

Quoted 3 lines
migration/migration.c +0 -0
      */
     .parent = TYPE_DEVICE,
     .class_init = migration_class_init,
#13 lore raw

Re: [Qemu-devel] [PATCH 3/4] doc: add item for "-M enforce-config-section"

In reply to Peter Xu
Quoted 18 lines · Peter Xu

It's never documented, and now we have one more parameter for it (which means this one can be obsolete in the future). Document it properly.

Although now when enforce-config-section is set, it'll override the other "-global" parameter, that is not necessarily a rule. Forbid that usage in the document.

---
 qemu-options.hx | 8 ++++++++
 1 file changed, 8 insertions(+)
qemu-options.hx +0 -0
index 297bd8a..927c51f 100644

qemu-options.hx Enables or disables NVDIMM support. The default is off. · line 92

Quoted 8 lines
qemu-options.hx +5 -0
@@ -85,6 +85,14 @@ Enables or disables NVDIMM support. The default is off.
 @item s390-squash-mcss=on|off
 Enables or disables squashing subchannels into the default css.
 The default is off.
+@item enforce-config-section=on|off
+Decides whether we will send the configuration section when doing
+migration. By default, it is turned on. We can set this to off to
+explicitly disable it. Note: this parameter will be obsolete soon,
+please use "-global migration.send-configuration=on|off" instead.

Please say "... is deprecated, please use ...", to make it visible in "git-grep -i deprecat".

qemu-options.hx Enables or disables NVDIMM support. The default is off. · line 95

Quoted 3 lines
qemu-options.hx +3 -0
+"enforce-config-section" cannot be used together with "-global
+migration.send-configuration". If it happens, the behavior is
+undefined.

Nasty. Could we catch and reject such invalid usage?

Quoted 2 lines
qemu-options.hx +0 -0
 @end table
 ETEXI
#7 lore raw

Re: [Qemu-devel] [PATCH 2/4] vl: move global property, migrate init earlier

In reply to Eduardo Habkost
Quoted 41 lines · Eduardo Habkost
Quoted 25 lines · Peter Xu

Currently drive_init_func() may call migrate_get_current() while the migrate object is still not ready yet at that time. Move the migration object init earlier, along with the global properties, right after acceleration init.

This fixes a breakage for iotest 055, which caused an assertion failure.

Fixes 3df663 ("migration: move only_migratable to MigrationState")
---
 vl.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
vl.c +2 -0
index 0c497a3..2ae4313 100644
@@ -4414,6 +4414,18 @@ int main(int argc, char **argv, char **envp)
 
     configure_accelerator(current_machine);
 
+    /*
+     * Register all the global properties, including accel properties,

vl.c int main(int argc, char **argv, char **envp) · line 4428

Quoted 10 lines
vl.c +10 -0
+     * machine properties, and user-specified ones.
+     */
+    register_global_properties(current_machine);
+
+    /*
+     * Migration object can only be created after global properties
+     * are applied correctly.
+     */
+    migration_object_init();
+

So, things that might introduce bugs here are:
1) Unexpected qdev_prop_register_global() calls between this place and the original register_global_properties() call (that would now happen in a different order).

Quoted 8 lines

2) register_global_properties() seeing a different global property list because it is being called earlier.
2.1) AccelClass::global_props is statically defined and will be the
same here. Not a problem.
2.2) MachineClass::compat_props: same as above.
2.3) user-provided global properties: we need to ensure all
properties in the "global" QemuOpts section are already available at this point.

This stuff is fragile. There are lots of dependencies, all implicit, and once again we reorder things ever so slightly to keep them satisfied. We could certainly use a more robust solution.

[...]

author
#22 lore raw

Re: [Qemu-devel] [PATCH 4/4] doc: update TYPE_MIGRATION documents

In reply to Markus Armbruster
Quoted 36 lines · Markus Armbruster
Quoted 21 lines · Peter Xu

[Peter collected Eduardo's patch comment and formatted into patch]

---
 migration/migration.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
migration/migration.c +0 -5
index dbdc121..6c64b99 100644
@@ -2052,12 +2052,15 @@ static void migration_instance_init(Object *obj)
 static const TypeInfo migration_type = {
     .name = TYPE_MIGRATION,
     /*
-     * NOTE: "migration" itself is not really a device. We used
-     * TYPE_DEVICE here only to leverage some existing QDev features
-     * like "-global" properties, and HW_COMPAT_* fields (which are
-     * finally applied as global properties as well). If one day the
-     * global property feature can be migrated from QDev to QObject in

migration/migration.c static void migration_instance_init(Object *obj) · line 2063

Quoted 10 lines
migration/migration.c +9 -1
-     * general, then we can switch to QObject as well.
+     * NOTE:
+     *
+     * TYPE_MIGRATION is not really a device, as the object is not
+     * created using qdev_create(), it is not attached to the qdev
+     * device tree, and it is never realized.
+     *
+     * If one day we allow non-device QOM objects to use the global
+     * property system, we can switch this from TYPE_DEVICE to
+     * TYPE_OBJECT.

Suggest to turn this paragraph into a TODO:

Quoted 2 lines

* TODO Make this TYPE_OBJECT once QOM provides something like
* TYPE_DEVICE's "-global" properties.

Sure. Will modify in next version. Thanks,

Signature · 1 line
Peter Xu
author
#14 lore raw

Re: [Qemu-devel] [PATCH 3/4] doc: add item for "-M enforce-config-section"

In reply to Markus Armbruster
Quoted 15 lines · Markus Armbruster
Quoted 13 lines · Peter Xu

It's never documented, and now we have one more parameter for it (which means this one can be obsolete in the future). Document it properly.

Although now when enforce-config-section is set, it'll override the other "-global" parameter, that is not necessarily a rule. Forbid that usage in the document.

---
 qemu-options.hx | 8 ++++++++
 1 file changed, 8 insertions(+)
Quoted 16 lines

qemu-options.hx Enables or disables NVDIMM support. The default is off. · line 92

Quoted 13 lines
qemu-options.hx +5 -0
index 297bd8a..927c51f 100644
@@ -85,6 +85,14 @@ Enables or disables NVDIMM support. The default is off.
 @item s390-squash-mcss=on|off
 Enables or disables squashing subchannels into the default css.
 The default is off.
+@item enforce-config-section=on|off
+Decides whether we will send the configuration section when doing
+migration. By default, it is turned on. We can set this to off to
+explicitly disable it. Note: this parameter will be obsolete soon,
+please use "-global migration.send-configuration=on|off" instead.

Please say "... is deprecated, please use ...", to make it visible in "git-grep -i deprecat".

Both "obsolete" and "deprecated" are used in QEMU for such an usage, but I see indeed "deprecated" is used more often at least in qemu-options.hx (used six times) than "obsolete" (one time only). Let me switch then. :)

Quoted 6 lines

qemu-options.hx Enables or disables NVDIMM support. The default is off. · line 95

Quoted 4 lines
qemu-options.hx +3 -0
+"enforce-config-section" cannot be used together with "-global
+migration.send-configuration". If it happens, the behavior is
+undefined.

Nasty. Could we catch and reject such invalid usage?

Agree. However, looks like we cannot capture it easily on either of the parameters (or, can we?). Since we defined it as "undefined", it should be okay then, right?

After all, iiuc enforce-config-section is already very rarely used (only on some special compat machines), and it'll be even more rare to use the new one without removing the old. Thanks,

Signature · 1 line
Peter Xu
#15 lore raw

Re: [Qemu-devel] [PATCH 3/4] doc: add item for "-M enforce-config-section"

In reply to Markus Armbruster

(CCing Greg, the original author of the code that added the enforce-config-section option)

Quoted 32 lines · Markus Armbruster
Quoted 18 lines · Peter Xu

It's never documented, and now we have one more parameter for it (which means this one can be obsolete in the future). Document it properly.

Although now when enforce-config-section is set, it'll override the other "-global" parameter, that is not necessarily a rule. Forbid that usage in the document.

---
 qemu-options.hx | 8 ++++++++
 1 file changed, 8 insertions(+)
qemu-options.hx +0 -0
index 297bd8a..927c51f 100644

qemu-options.hx Enables or disables NVDIMM support. The default is off. · line 92

Quoted 8 lines
qemu-options.hx +5 -0
@@ -85,6 +85,14 @@ Enables or disables NVDIMM support. The default is off.
 @item s390-squash-mcss=on|off
 Enables or disables squashing subchannels into the default css.
 The default is off.
+@item enforce-config-section=on|off
+Decides whether we will send the configuration section when doing
+migration. By default, it is turned on. We can set this to off to
+explicitly disable it. Note: this parameter will be obsolete soon,
+please use "-global migration.send-configuration=on|off" instead.

Please say "... is deprecated, please use ...", to make it visible in "git-grep -i deprecat".

Quoted 5 lines

qemu-options.hx Enables or disables NVDIMM support. The default is off. · line 95

Quoted 3 lines
qemu-options.hx +3 -0
+"enforce-config-section" cannot be used together with "-global
+migration.send-configuration". If it happens, the behavior is
+undefined.

Nasty. Could we catch and reject such invalid usage?

Actually, the machine option will override migration.send-configuration=off, and I don't believe we will break that rule. Documenting that behavior (but warning that it is deprecated) sounds easier than adding extra code to detect the conflicting options.

We can simply replace "is undefined" with "enforce-config-section will override migration.send-configuration, but enforce-config-section is deprecated".

I don't think anybody is relying on that option. If nobody is using it, we can remove its code soon if we make it trigger a warning. Machine-type compatibility code is already using migration.send-configuration instead.

Signature · 1 line
Eduardo
#8 lore raw

Re: [Qemu-devel] [PATCH 2/4] vl: move global property, migrate init earlier

In reply to Markus Armbruster
Quoted 52 lines · Markus Armbruster
Quoted 41 lines · Eduardo Habkost
Quoted 25 lines · Peter Xu

Currently drive_init_func() may call migrate_get_current() while the migrate object is still not ready yet at that time. Move the migration object init earlier, along with the global properties, right after acceleration init.

This fixes a breakage for iotest 055, which caused an assertion failure.

Fixes 3df663 ("migration: move only_migratable to MigrationState")
---
 vl.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)
vl.c +2 -0
index 0c497a3..2ae4313 100644
@@ -4414,6 +4414,18 @@ int main(int argc, char **argv, char **envp)
 
     configure_accelerator(current_machine);
 
+    /*
+     * Register all the global properties, including accel properties,

vl.c int main(int argc, char **argv, char **envp) · line 4428

Quoted 10 lines
vl.c +10 -0
+     * machine properties, and user-specified ones.
+     */
+    register_global_properties(current_machine);
+
+    /*
+     * Migration object can only be created after global properties
+     * are applied correctly.
+     */
+    migration_object_init();
+

So, things that might introduce bugs here are:
1) Unexpected qdev_prop_register_global() calls between this place and the original register_global_properties() call (that would now happen in a different order).

Quoted 8 lines

2) register_global_properties() seeing a different global property list because it is being called earlier.
2.1) AccelClass::global_props is statically defined and will be the
same here. Not a problem.
2.2) MachineClass::compat_props: same as above.
2.3) user-provided global properties: we need to ensure all
properties in the "global" QemuOpts section are already available at this point.

Quoted 3 lines

This stuff is fragile. There are lots of dependencies, all implicit, and once again we reorder things ever so slightly to keep them satisfied. We could certainly use a more robust solution.

Yes, and we are working on it. Items 2.1-2.3 are already grouped in register_global_properties() to make ordering rules explicit. The rest of the qdev_prop_register_global() calls need to be either replaced with something else or moved to register_global_properties() too.

Signature · 1 line
Eduardo
#16 lore raw

Re: [Qemu-devel] [PATCH 3/4] doc: add item for "-M enforce-config-section"

In reply to Eduardo Habkost
Quoted 42 lines · Eduardo Habkost

(CCing Greg, the original author of the code that added the enforce-config-section option)

Quoted 32 lines · Markus Armbruster
Quoted 18 lines · Peter Xu

It's never documented, and now we have one more parameter for it (which means this one can be obsolete in the future). Document it properly.

Although now when enforce-config-section is set, it'll override the other "-global" parameter, that is not necessarily a rule. Forbid that usage in the document.

---
 qemu-options.hx | 8 ++++++++
 1 file changed, 8 insertions(+)
qemu-options.hx +0 -0
index 297bd8a..927c51f 100644

qemu-options.hx Enables or disables NVDIMM support. The default is off. · line 92

Quoted 8 lines
qemu-options.hx +5 -0
@@ -85,6 +85,14 @@ Enables or disables NVDIMM support. The default is off.
 @item s390-squash-mcss=on|off
 Enables or disables squashing subchannels into the default css.
 The default is off.
+@item enforce-config-section=on|off
+Decides whether we will send the configuration section when doing
+migration. By default, it is turned on. We can set this to off to
+explicitly disable it. Note: this parameter will be obsolete soon,
+please use "-global migration.send-configuration=on|off" instead.

Please say "... is deprecated, please use ...", to make it visible in "git-grep -i deprecat".

Quoted 5 lines

qemu-options.hx Enables or disables NVDIMM support. The default is off. · line 95

Quoted 3 lines
qemu-options.hx +3 -0
+"enforce-config-section" cannot be used together with "-global
+migration.send-configuration". If it happens, the behavior is
+undefined.

Nasty. Could we catch and reject such invalid usage?

Quoted 8 lines

Actually, the machine option will override migration.send-configuration=off, and I don't believe we will break that rule. Documenting that behavior (but warning that it is deprecated) sounds easier than adding extra code to detect the conflicting options.

We can simply replace "is undefined" with "enforce-config-section will override migration.send-configuration, but enforce-config-section is deprecated".

Better than the scary "behavior is undefined". But do we have to say anything at all? If somebody gives both options with different values, the conflicting settings fight it out. In a sane command line, the last one wins. Ours isn't sane. Do we really have to specify who wins?

Quoted 4 lines

I don't think anybody is relying on that option. If nobody is using it, we can remove its code soon if we make it trigger a warning. Machine-type compatibility code is already using migration.send-configuration instead.

What about

@item enforce-config-section=on|off
Controls sending of the configuration section when doing migration (default on). Note: this parameter is deprecated, please use "-global migration.send-configuration=on|off" instead.

author
#17 lore raw

Re: [Qemu-devel] [PATCH 3/4] doc: add item for "-M enforce-config-section"

Quoted 63 lines · Markus Armbruster
Quoted 42 lines · Eduardo Habkost

(CCing Greg, the original author of the code that added the enforce-config-section option)

Quoted 32 lines · Markus Armbruster
Quoted 18 lines · Peter Xu

It's never documented, and now we have one more parameter for it (which means this one can be obsolete in the future). Document it properly.

Although now when enforce-config-section is set, it'll override the other "-global" parameter, that is not necessarily a rule. Forbid that usage in the document.

---
 qemu-options.hx | 8 ++++++++
 1 file changed, 8 insertions(+)
qemu-options.hx +0 -0
index 297bd8a..927c51f 100644

qemu-options.hx Enables or disables NVDIMM support. The default is off. · line 92

Quoted 8 lines
qemu-options.hx +5 -0
@@ -85,6 +85,14 @@ Enables or disables NVDIMM support. The default is off.
 @item s390-squash-mcss=on|off
 Enables or disables squashing subchannels into the default css.
 The default is off.
+@item enforce-config-section=on|off
+Decides whether we will send the configuration section when doing
+migration. By default, it is turned on. We can set this to off to
+explicitly disable it. Note: this parameter will be obsolete soon,
+please use "-global migration.send-configuration=on|off" instead.

Please say "... is deprecated, please use ...", to make it visible in "git-grep -i deprecat".

Quoted 5 lines

qemu-options.hx Enables or disables NVDIMM support. The default is off. · line 95

Quoted 3 lines
qemu-options.hx +3 -0
+"enforce-config-section" cannot be used together with "-global
+migration.send-configuration". If it happens, the behavior is
+undefined.

Nasty. Could we catch and reject such invalid usage?

Quoted 8 lines

Actually, the machine option will override migration.send-configuration=off, and I don't believe we will break that rule. Documenting that behavior (but warning that it is deprecated) sounds easier than adding extra code to detect the conflicting options.

We can simply replace "is undefined" with "enforce-config-section will override migration.send-configuration, but enforce-config-section is deprecated".

Better than the scary "behavior is undefined". But do we have to say anything at all? If somebody gives both options with different values, the conflicting settings fight it out. In a sane command line, the last one wins. Ours isn't sane. Do we really have to specify who wins?

Quoted 4 lines

I don't think anybody is relying on that option. If nobody is using it, we can remove its code soon if we make it trigger a warning. Machine-type compatibility code is already using migration.send-configuration instead.

Quoted 5 lines

What about

@item enforce-config-section=on|off
Controls sending of the configuration section when doing migration (default on).

Sorry to be misleading in current patch. Its default should be "off" but not "on" (as corrected by Eduardo, the point is we are talking about "enforce-config-section", not "migration.send-configuration"). Actually it won't make much sense if someone specify "off" here.

Quoted 2 lines

Note: this parameter is deprecated, please use
"-global migration.send-configuration=on|off" instead.

This is a suggestion I would like to take. I'll remove the whole "undefined" sentence and update my post. Thanks,

Signature · 1 line
Peter Xu