On 9/9/2025 11:43 AM, Peter Xu wrote:
On Thu, Aug 14, 2025 at 10:17:15AM -0700, Steve Sistare wrote:
Allow a notifier to be added for multiple migration modes.
To allow a notifier to appear on multiple per-node lists, use
a generic list type.  We can no longer use NotifierWithReturnList,
because it shoe horns the notifier onto a single list.

Signed-off-by: Steve Sistare <[email protected]>
---
  include/migration/misc.h | 12 ++++++++++
  migration/migration.c    | 60 +++++++++++++++++++++++++++++++++++++-----------
  2 files changed, 59 insertions(+), 13 deletions(-)

diff --git a/include/migration/misc.h b/include/migration/misc.h
index a261f99..592b930 100644
--- a/include/migration/misc.h
+++ b/include/migration/misc.h
@@ -95,7 +95,19 @@ void migration_add_notifier(NotifierWithReturn *notify,
  void migration_add_notifier_mode(NotifierWithReturn *notify,
                                   MigrationNotifyFunc func, MigMode mode);
+/*
+ * Same as migration_add_notifier, but applies to all @mode in the argument
+ * list.  The list is terminated by -1 or MIG_MODE_ALL.  For the latter,
+ * the notifier is added for all modes.
+ */
+void migration_add_notifier_modes(NotifierWithReturn *notify,
+                                  MigrationNotifyFunc func, MigMode mode, ...);

Would it be more common to pass in a bitmask instead (rather than n
parameters, plus a ending -1)?

Yes, but I defined it this way to avoid the common error of passing a bit 
position
rather than a mask, eg:

  A = 10
  B = 7
  migration_add_notifier_modes(A | B)               WRONG
  migration_add_notifier_modes(BIT(A) | BIT(B))     CORRECT

and because IMO passing A, B is slightly more readable than passing BIT(A) | 
BIT(B).

Note the blocker functions also take modes using varargs, so using a bitmask for
the notifiers would give us two different representations.

- Steve



Reply via email to