From nobody Sun Sep 28 17:05:17 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1758549041; cv=none; d=zohomail.com; s=zohoarc; b=YoOqzQZvCoOJfjNuFMM6+CmOEfrkGf5iTAe+4+k122Cup8w+FXGw0CY/PfH5y5aJX3DOKSZ8Vu15RNyluODBoUnfAuVYnxbsGjhCyfqVUd+Vh22/KM5erG6s+3hlnIwGv2bLG54yXsmJJG9WeSHUXdpHbzKlH1d2ys4ofg0yiWM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758549041; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=a1OWDnMLDg8boXx6EnW3WJpFBvSqT8/lF0638NDHTDw=; b=Qgul7bK4Z+w0GRlxjCzCEMApVz7TdT0I9yLSCNLKoaO2KTOR9x2TW5SxQST0N/Dd+6+N8nZNrlms/xP5rgzzppSys4P3KPPrrquVrC0Si32p1qDAMHv5H1SPF7EfiX7wDOAMo+Lm3ur5udmrIi0uD1ykxTa0I/AcCghkAmq9jyc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 175854904128833.874121316093465; Mon, 22 Sep 2025 06:50:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0gvh-0000Tq-7N; Mon, 22 Sep 2025 09:50:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0gva-0000QV-Bp for qemu-devel@nongnu.org; Mon, 22 Sep 2025 09:50:02 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0gvT-0001ti-1u for qemu-devel@nongnu.org; Mon, 22 Sep 2025 09:50:02 -0400 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 58M7NKHu006483; Mon, 22 Sep 2025 13:49:50 GMT Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 499kvttfmn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 Sep 2025 13:49:50 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 58MCMrcL034116; Mon, 22 Sep 2025 13:49:49 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 49a6nhan86-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 Sep 2025 13:49:49 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 58MDnlWD004351; Mon, 22 Sep 2025 13:49:49 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 49a6nhan6x-2; Mon, 22 Sep 2025 13:49:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :date:from:in-reply-to:message-id:references:subject:to; s= corp-2025-04-25; bh=a1OWDnMLDg8boXx6EnW3WJpFBvSqT8/lF0638NDHTDw=; b= m7peNvEpdWJWWx16SmsiO5beBcqIwtsXHrG4iKEBU5/+/7vfF85jnuAfhUFYqmjk DfcgLw4LxG5/GcYn995GRwho7OHpFM5rm0BGhoyOqOYuOMHDIgC5LjF0DS5Yz0fX tKDoJiHQa9e5t26KGTfOhptCZLoDxnwCsf6GWwz3zxGUif7slOag9ddsg98h8thU qEwKij1k7GHaI7MYOP/FGI1S2vQ2O4GzjnjEzWZl/Qj/zvv7Okn4s6ncSDZke+ni h0C4Vbhp/kyL0XWvmznXKCeu0KJhuO2KSO3K2EVUkRDyMh9ikPmy8H6cLKATIa/b nww5fxwRfINQmh2+ZwOeow== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Peter Xu , Markus Armbruster , Paolo Bonzini , Eric Blake , "Dr. David Alan Gilbert" , Cedric Le Goater , Alex Williamson , Steve Sistare Subject: [PATCH V4 1/8] migration: multi-mode notifier Date: Mon, 22 Sep 2025 06:49:38 -0700 Message-Id: <1758548985-354793-2-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1758548985-354793-1-git-send-email-steven.sistare@oracle.com> References: <1758548985-354793-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1117,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-09-22_01,2025-09-22_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 mlxscore=0 spamscore=0 malwarescore=0 phishscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2508110000 definitions=main-2509220135 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwOTIwMDAyNSBTYWx0ZWRfX/Qe2ZnnjzvI5 M95mU5YM4OhUfWRi2qOQKbY6wEs28p9LUG4X9YzECVxyjHcdYxbYZoYHkOpy+znyOjiTLSxmpbl LwXtHySknXKxckP3eXoHKxv0rSNWPE3N4qwlATjgU9F2Fj3NBfDCYsdwCsdmm928uO2p2F9PDvW WmUXr7EfD8ISG035cl7ppEDxUARiaTF7akwIWdKnlfVp4i9fsiHl9qFRJREtGGFevv6REAU6yNO ELOVvrylyZWpkQl50iJLjFqvq+j2hTWM+u7dqskBnYbfTPMH0XIHpVXL7k9OM++uUIQvYu+9NpQ tK3S3epdOlV6T7g64Es5dPwZ+fx9qjmhBOf+xZ2+BU1WvtCsWZZaEBOXgFTZs4u7EBywv/wnEtJ jWVmNmyOdEB1jmf2o2FBeYKzCFufYQ== X-Authority-Analysis: v=2.4 cv=UPPdHDfy c=1 sm=1 tr=0 ts=68d153fe b=1 cx=c_pps a=e1sVV491RgrpLwSTMOnk8w==:117 a=e1sVV491RgrpLwSTMOnk8w==:17 a=yJojWOMRYYMA:10 a=yPCof4ZbAAAA:8 a=qm0lDVemfS40E2rT5CEA:9 cc=ntf awl=host:13614 X-Proofpoint-GUID: Ga9aDgP-61HG5lJfm8DQqM3p0By6obAZ X-Proofpoint-ORIG-GUID: Ga9aDgP-61HG5lJfm8DQqM3p0By6obAZ Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=steven.sistare@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1758549043678116600 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Fabiano Rosas --- 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); =20 +/* + * 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); =20 /* True if incoming migration entered POSTCOPY_INCOMING_DISCARD */ diff --git a/migration/migration.c b/migration/migration.c index 10c216d..08a98f7 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -74,11 +74,7 @@ =20 #define INMIGRATE_DEFAULT_EXIT_ON_ERROR true =20 -static NotifierWithReturnList migration_state_notifiers[] =3D { - 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]; =20 /* Messages sent on the return path from destination to source */ enum mig_rp_message_type { @@ -1665,23 +1661,51 @@ void migration_cancel(void) } } =20 +static int get_modes(MigMode mode, va_list ap); + +static void add_notifiers(NotifierWithReturn *notify, int modes) +{ + for (MigMode mode =3D 0; mode < MIG_MODE__MAX; mode++) { + if (modes & BIT(mode)) { + migration_state_notifiers[mode] =3D + 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 =3D get_modes(mode, ap); + va_end(ap); + + notify->notify =3D (NotifierWithReturnFunc)func; + add_notifiers(notify, modes); +} + void migration_add_notifier_mode(NotifierWithReturn *notify, MigrationNotifyFunc func, MigMode mode) { - notify->notify =3D (NotifierWithReturnFunc)func; - notifier_with_return_list_add(&migration_state_notifiers[mode], notify= ); + migration_add_notifier_modes(notify, func, mode, -1); } =20 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); } =20 void migration_remove_notifier(NotifierWithReturn *notify) { if (notify->notify) { - notifier_with_return_remove(notify); + for (MigMode mode =3D 0; mode < MIG_MODE__MAX; mode++) { + migration_blockers[mode] =3D + g_slist_remove(migration_state_notifiers[mode], notify); + } notify->notify =3D NULL; } } @@ -1691,13 +1715,23 @@ int migration_call_notifiers(MigrationState *s, Mig= rationEventType type, { MigMode mode =3D s->parameters.mode; MigrationEvent e; + NotifierWithReturn *notifier; + GSList *elem, *next; int ret; =20 e.type =3D type; - ret =3D notifier_with_return_list_notify(&migration_state_notifiers[mo= de], - &e, errp); - assert(!ret || type =3D=3D MIG_EVENT_PRECOPY_SETUP); - return ret; + + for (elem =3D migration_state_notifiers[mode]; elem; elem =3D next) { + next =3D elem->next; + notifier =3D (NotifierWithReturn *)elem->data; + ret =3D notifier->notify(notifier, &e, errp); + if (ret) { + assert(type =3D=3D MIG_EVENT_PRECOPY_SETUP); + return ret; + } + } + + return 0; } =20 bool migration_has_failed(MigrationState *s) --=20 1.8.3.1