From: Thomas Lamprecht <t.lamprecht@proxmox.com>
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 [thread overview]
Message-ID: <20261118043817.1659212-6-t.lamprecht@proxmox.com> (raw)
In-Reply-To: <20261118043817.1659212-1-t.lamprecht@proxmox.com>
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 <t.lamprecht@proxmox.com>
---
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 <corosync/corotypes.h>
#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
next prev parent reply other threads:[~2026-11-18 4:39 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 4:37 [PATCH cluster/guest-common/qemu-server/container/manager/docs v3 00/38] fix #7846: guest identity (uid) and cluster ID Thomas Lamprecht
2026-11-18 4:37 ` [PATCH cluster v3 01/38] pmxcfs: reject changes to the cluster ID file from user space Thomas Lamprecht
2026-11-18 4:37 ` [PATCH cluster v3 02/38] pmxcfs: generate a cluster ID on standalone nodes Thomas Lamprecht
2026-11-18 4:37 ` [PATCH cluster v3 03/38] pmxcfs: dfsm: add a callback that runs once all members are in sync Thomas Lamprecht
2026-11-18 4:37 ` [PATCH cluster v3 04/38] pmxcfs: quorum: pass the corosync membership to an optional listener Thomas Lamprecht
2026-11-18 4:37 ` Thomas Lamprecht [this message]
2026-11-18 4:37 ` [PATCH cluster v3 06/38] pmxcfs: dcdb: generate the cluster ID once the cluster is in sync Thomas Lamprecht
2026-11-18 4:37 ` [PATCH cluster v3 07/38] cluster: add helper to read the cluster ID Thomas Lamprecht
2026-11-18 4:37 ` [PATCH cluster v3 08/38] pmxcfs: allow removing the cluster ID file in forced local mode Thomas Lamprecht
2026-11-18 4:37 ` [PATCH guest-common v3 09/38] guest identity: add helpers for the guest uid and registration time Thomas Lamprecht
2026-11-18 4:37 ` [PATCH guest-common v3 10/38] abstract config: assign a guest identity and keep it on config writes Thomas Lamprecht
2026-11-18 4:37 ` [PATCH guest-common v3 11/38] abstract config: let the VMID reservation return the previous state Thomas Lamprecht
2026-11-18 4:37 ` [PATCH guest-common v3 12/38] guest identity: allow taking over a uid that is unused in the cluster Thomas Lamprecht
2026-11-18 4:37 ` [PATCH guest-common v3 13/38] migrate: add shared helpers for the identity command of the migration tunnel Thomas Lamprecht
2026-11-18 4:37 ` [PATCH qemu-server v3 14/38] api: restore: release the VMID if a restore to an unused VMID fails Thomas Lamprecht
2026-11-18 4:37 ` [PATCH qemu-server v3 15/38] api: migrate, clone: refuse targets that would drop the guest identity Thomas Lamprecht
2026-11-18 4:37 ` [PATCH qemu-server v3 16/38] fix #7846: config: add a guest identity to the 'meta' property Thomas Lamprecht
2026-11-18 4:37 ` [PATCH qemu-server v3 17/38] restore: take over the guest uid from the backup where possible Thomas Lamprecht
2026-11-18 4:37 ` [PATCH qemu-server v3 18/38] api: remote migration: take over the guest uid from the source Thomas Lamprecht
2026-11-18 4:37 ` [PATCH qemu-server v3 19/38] api: status: return the guest uid Thomas Lamprecht
2026-11-18 4:37 ` [PATCH qemu-server v3 20/38] tests: remote migration: check a failed command and an early tunnel end Thomas Lamprecht
2026-11-18 4:37 ` [PATCH container v3 21/38] config: add read-only meta property with the creation time Thomas Lamprecht
2026-11-18 4:37 ` [PATCH container v3 22/38] fix #7846: config: add a guest identity to the 'meta' property Thomas Lamprecht
2026-11-18 4:37 ` [PATCH container v3 23/38] api: migrate, clone: refuse targets that would drop the guest identity Thomas Lamprecht
2026-11-18 4:37 ` [PATCH container v3 24/38] restore: take over the guest uid from the backup where possible Thomas Lamprecht
2026-11-18 4:37 ` [PATCH container v3 25/38] restore: refuse overwriting a container with another guest's backup Thomas Lamprecht
2026-11-18 4:37 ` [PATCH container v3 26/38] test: remote migration: check the cleanup of the target after failures Thomas Lamprecht
2026-11-18 4:37 ` [PATCH container v3 27/38] api: remote migration: take over the guest uid from the source Thomas Lamprecht
2026-11-18 4:37 ` [PATCH container v3 28/38] api: status: return the guest uid Thomas Lamprecht
2026-11-18 4:37 ` [PATCH manager v3 29/38] api: cluster resources: add guest uid and registration time Thomas Lamprecht
2026-11-18 4:37 ` [PATCH manager v3 30/38] api: cluster status: add cluster ID Thomas Lamprecht
2026-11-18 4:37 ` [PATCH manager v3 31/38] ui: restore: allow overwriting a guest with a backup of another guest Thomas Lamprecht
2026-11-18 4:37 ` [PATCH manager v3 32/38] ui: migrate: refuse target nodes that would drop the guest identity Thomas Lamprecht
2026-11-18 4:37 ` [PATCH manager v3 33/38] ui: guest summary: show " Thomas Lamprecht
2026-11-18 4:37 ` [PATCH manager v3 34/38] api: bulk migrate: refuse targets that would drop " Thomas Lamprecht
2026-11-18 4:37 ` [PATCH docs v3 35/38] vzdump: describe the guest identity of VMs and containers Thomas Lamprecht
2026-11-18 4:37 ` [PATCH docs v3 36/38] pvecm: document the cluster ID and how to get a new one Thomas Lamprecht
2026-11-18 4:37 ` [PATCH docs v3 37/38] qm: configuration: describe the read-only meta property Thomas Lamprecht
2026-11-18 4:37 ` [PATCH docs v3 38/38] pct: " Thomas Lamprecht
2026-11-18 13:49 ` [PATCH cluster/guest-common/qemu-server/container/manager/docs v3 00/38] fix #7846: guest identity (uid) and cluster ID Dominik Csapak
2026-11-18 14:13 ` Thomas Lamprecht
2026-11-19 10:38 ` superseded: " Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261118043817.1659212-6-t.lamprecht@proxmox.com \
--to=t.lamprecht@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox