- Add DMABUF support [VOYAGER-19 VOYAGER-53] - Accelerated SMMU device for GH GPU passthrough [VOYAGER-5 VOYAGER-16 VOYAGER-17 VOYAGER-48] - Resolves: VOYAGER-5 (Backport CMDQV support) - Resolves: VOYAGER-16 (Backport HW accelerated nesting support for arm SMMUv3) - Resolves: VOYAGER-17 (Backport vEVENTQ support for smmuv3) - Resolves: VOYAGER-19 (Backport vfio: Add DMABUF support for PCI BAR regions - qemu-kvm) - Resolves: VOYAGER-48 (qemu-kvm coredump when using traditional smmuv3 device without any GPU device) - Resolves: VOYAGER-53 (qemu-kvm coredump when hotunplug NIC VF interface without smmuv3)
154 lines
5.2 KiB
Diff
154 lines
5.2 KiB
Diff
From 32046d2031796e9856328b8fb8c45a2b837dcb95 Mon Sep 17 00:00:00 2001
|
|
From: Steve Sistare <steven.sistare@oracle.com>
|
|
Date: Wed, 1 Oct 2025 08:33:53 -0700
|
|
Subject: [PATCH] migration: multi-mode notifier
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
RH-Author: Cédric Le Goater <clg@redhat.com>
|
|
RH-MergeRequest: 458: Add DMABUF support
|
|
RH-Jira: VOYAGER-19 VOYAGER-53
|
|
RH-Acked-by: Eric Auger <eric.auger@redhat.com>
|
|
RH-Commit: [1/101] 17b0d6ee96 (clegoate/qemu-kvm-centos)
|
|
|
|
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 <steven.sistare@oracle.com>
|
|
Reviewed-by: Fabiano Rosas <farosas@suse.de>
|
|
Link: https://lore.kernel.org/r/1759332851-370353-2-git-send-email-steven.sistare@oracle.com
|
|
Signed-off-by: Peter Xu <peterx@redhat.com>
|
|
---
|
|
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 a261f99d89..592b93021e 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, ...);
|
|
+
|
|
+/*
|
|
+ * Remove a notifier from all modes.
|
|
+ */
|
|
void migration_remove_notifier(NotifierWithReturn *notify);
|
|
+
|
|
void migration_file_set_error(int ret, Error *err);
|
|
|
|
/* True if incoming migration entered POSTCOPY_INCOMING_DISCARD */
|
|
diff --git a/migration/migration.c b/migration/migration.c
|
|
index 10c216d25d..08a98f74ef 100644
|
|
--- a/migration/migration.c
|
|
+++ b/migration/migration.c
|
|
@@ -74,11 +74,7 @@
|
|
|
|
#define INMIGRATE_DEFAULT_EXIT_ON_ERROR true
|
|
|
|
-static NotifierWithReturnList migration_state_notifiers[] = {
|
|
- NOTIFIER_ELEM_INIT(migration_state_notifiers, MIG_MODE_NORMAL),
|
|
- NOTIFIER_ELEM_INIT(migration_state_notifiers, MIG_MODE_CPR_REBOOT),
|
|
- NOTIFIER_ELEM_INIT(migration_state_notifiers, MIG_MODE_CPR_TRANSFER),
|
|
-};
|
|
+static GSList *migration_state_notifiers[MIG_MODE__MAX];
|
|
|
|
/* Messages sent on the return path from destination to source */
|
|
enum mig_rp_message_type {
|
|
@@ -1665,23 +1661,51 @@ void migration_cancel(void)
|
|
}
|
|
}
|
|
|
|
+static int get_modes(MigMode mode, va_list ap);
|
|
+
|
|
+static void add_notifiers(NotifierWithReturn *notify, int modes)
|
|
+{
|
|
+ for (MigMode mode = 0; mode < MIG_MODE__MAX; mode++) {
|
|
+ if (modes & BIT(mode)) {
|
|
+ migration_state_notifiers[mode] =
|
|
+ g_slist_prepend(migration_state_notifiers[mode], notify);
|
|
+ }
|
|
+ }
|
|
+}
|
|
+
|
|
+void migration_add_notifier_modes(NotifierWithReturn *notify,
|
|
+ MigrationNotifyFunc func, MigMode mode, ...)
|
|
+{
|
|
+ int modes;
|
|
+ va_list ap;
|
|
+
|
|
+ va_start(ap, mode);
|
|
+ modes = get_modes(mode, ap);
|
|
+ va_end(ap);
|
|
+
|
|
+ notify->notify = (NotifierWithReturnFunc)func;
|
|
+ add_notifiers(notify, modes);
|
|
+}
|
|
+
|
|
void migration_add_notifier_mode(NotifierWithReturn *notify,
|
|
MigrationNotifyFunc func, MigMode mode)
|
|
{
|
|
- notify->notify = (NotifierWithReturnFunc)func;
|
|
- notifier_with_return_list_add(&migration_state_notifiers[mode], notify);
|
|
+ migration_add_notifier_modes(notify, func, mode, -1);
|
|
}
|
|
|
|
void migration_add_notifier(NotifierWithReturn *notify,
|
|
MigrationNotifyFunc func)
|
|
{
|
|
- migration_add_notifier_mode(notify, func, MIG_MODE_NORMAL);
|
|
+ migration_add_notifier_modes(notify, func, MIG_MODE_NORMAL, -1);
|
|
}
|
|
|
|
void migration_remove_notifier(NotifierWithReturn *notify)
|
|
{
|
|
if (notify->notify) {
|
|
- notifier_with_return_remove(notify);
|
|
+ for (MigMode mode = 0; mode < MIG_MODE__MAX; mode++) {
|
|
+ migration_blockers[mode] =
|
|
+ g_slist_remove(migration_state_notifiers[mode], notify);
|
|
+ }
|
|
notify->notify = NULL;
|
|
}
|
|
}
|
|
@@ -1691,13 +1715,23 @@ int migration_call_notifiers(MigrationState *s, MigrationEventType type,
|
|
{
|
|
MigMode mode = s->parameters.mode;
|
|
MigrationEvent e;
|
|
+ NotifierWithReturn *notifier;
|
|
+ GSList *elem, *next;
|
|
int ret;
|
|
|
|
e.type = type;
|
|
- ret = notifier_with_return_list_notify(&migration_state_notifiers[mode],
|
|
- &e, errp);
|
|
- assert(!ret || type == MIG_EVENT_PRECOPY_SETUP);
|
|
- return ret;
|
|
+
|
|
+ for (elem = migration_state_notifiers[mode]; elem; elem = next) {
|
|
+ next = elem->next;
|
|
+ notifier = (NotifierWithReturn *)elem->data;
|
|
+ ret = notifier->notify(notifier, &e, errp);
|
|
+ if (ret) {
|
|
+ assert(type == MIG_EVENT_PRECOPY_SETUP);
|
|
+ return ret;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ return 0;
|
|
}
|
|
|
|
bool migration_has_failed(MigrationState *s)
|