From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 965FE1FF0C0 for ; Wed, 18 Nov 2026 05:39:09 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 49E902170B; Wed, 18 Nov 2026 05:38:29 +0100 (CET) From: Thomas Lamprecht To: pve-devel@lists.proxmox.com Subject: [PATCH cluster v3 05/38] pmxcfs: confdb: call an optional listener when the nodes get published Date: Wed, 18 Nov 2026 05:37:17 +0100 Message-ID: <20261118043817.1659212-6-t.lamprecht@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261118043817.1659212-1-t.lamprecht@proxmox.com> References: <20261118043817.1659212-1-t.lamprecht@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1794976701840 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.191 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: CMF2COGHH3E5NZPILZYCXFDWHVYKGCP3 X-Message-ID-Hash: CMF2COGHH3E5NZPILZYCXFDWHVYKGCP3 X-MailFrom: t.lamprecht@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: A service that decides by the configured nodes has to decide again when they change. Neither the quorum nor the group of a dfsm has to change with them, for example when a node that is offline gets removed from the configuration. Call an optional listener each time the nodes of the corosync configuration got published. It runs on the loop thread, like the quorum listener. Existing behavior is unchanged when no listener is registered. Signed-off-by: Thomas Lamprecht --- changes v2 -> v3: * new in v3 src/pmxcfs/confdb.c | 18 ++++++++++++++---- src/pmxcfs/confdb.h | 5 ++++- src/pmxcfs/pmxcfs.c | 2 +- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/pmxcfs/confdb.c b/src/pmxcfs/confdb.c index 43427e0..7632f9f 100644 --- a/src/pmxcfs/confdb.c +++ b/src/pmxcfs/confdb.c @@ -38,6 +38,7 @@ #include #include "cfs-utils.h" +#include "confdb.h" #include "loop.h" #include "status.h" @@ -46,6 +47,8 @@ typedef struct { cmap_track_handle_t track_nodelist_handle; cmap_track_handle_t track_version_handle; gboolean changes; + cfs_confdb_changed_fn_t changed_fn; + gpointer changed_data; } cs_private_t; static cs_error_t cmap_read_clusternodes(cmap_handle_t handle, cfs_clinfo_t *clinfo) { @@ -132,7 +135,8 @@ static cs_error_t cmap_read_clusternodes(cmap_handle_t handle, cfs_clinfo_t *cli return result; } -static cs_error_t cmap_read_config(cmap_handle_t handle) { +static cs_error_t cmap_read_config(cs_private_t *private) { + cmap_handle_t handle = private->handle; cs_error_t result; uint64_t config_version = 0; @@ -156,6 +160,9 @@ static cs_error_t cmap_read_config(cmap_handle_t handle) { result = cmap_read_clusternodes(handle, clinfo); if (result == CS_OK) { cfs_status_set_clinfo(clinfo); + if (private->changed_fn) { + private->changed_fn(private->changed_data); + } } else { cfs_clinfo_destroy(clinfo); } @@ -281,7 +288,7 @@ static int service_cmap_initialize(cfs_service_t *service, gpointer context) { return -1; } - cmap_read_config(handle); + cmap_read_config(private); return cmap_fd; } @@ -311,7 +318,7 @@ loop: if (result == CS_OK || result == CS_ERR_TRY_AGAIN) { if (private->changes) { - result = cmap_read_config(handle); + result = cmap_read_config(private); private->changes = FALSE; @@ -334,7 +341,7 @@ static cfs_service_callbacks_t cfs_confdb_callbacks = { .cfs_service_dispatch_fn = service_cmap_dispatch, }; -cfs_service_t *service_confdb_new(void) { +cfs_service_t *service_confdb_new(cfs_confdb_changed_fn_t changed_fn, gpointer changed_data) { cfs_service_t *service; cs_private_t *private = g_new0(cs_private_t, 1); @@ -342,6 +349,9 @@ cfs_service_t *service_confdb_new(void) { return NULL; } + private->changed_fn = changed_fn; + private->changed_data = changed_data; + service = cfs_service_new(&cfs_confdb_callbacks, G_LOG_DOMAIN, private); return service; diff --git a/src/pmxcfs/confdb.h b/src/pmxcfs/confdb.h index 46ec888..2286b34 100644 --- a/src/pmxcfs/confdb.h +++ b/src/pmxcfs/confdb.h @@ -25,7 +25,10 @@ #include "loop.h" -cfs_service_t *service_confdb_new(void); +/* Called on the loop thread each time the nodes of the corosync configuration got published. */ +typedef void (*cfs_confdb_changed_fn_t)(gpointer data); + +cfs_service_t *service_confdb_new(cfs_confdb_changed_fn_t changed_fn, gpointer changed_data); void service_confdb_destroy(cfs_service_t *service); diff --git a/src/pmxcfs/pmxcfs.c b/src/pmxcfs/pmxcfs.c index 284bae1..2ab48dc 100644 --- a/src/pmxcfs/pmxcfs.c +++ b/src/pmxcfs/pmxcfs.c @@ -1023,7 +1023,7 @@ int main(int argc, char *argv[]) { cfs_loop_add_service(corosync_loop, service_quorum, QB_LOOP_HIGH); - service_confdb = service_confdb_new(); + service_confdb = service_confdb_new(NULL, NULL); cfs_loop_add_service(corosync_loop, service_confdb, QB_LOOP_MED); -- 2.47.3