From: Hannes Laimer <h.laimer@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH pve-cluster 09/12] pmxcfs: notify: emit change events over the notification socket
Date: Thu, 22 Oct 2026 16:22:02 +0200 [thread overview]
Message-ID: <20261022142205.930536-10-h.laimer@proxmox.com> (raw)
In-Reply-To: <20261022142205.930536-1-h.laimer@proxmox.com>
The daemon serves the socket at /run/pve-cluster/pmxcfs.sock to root
and the www-data group. The filesystem works without the socket, so
the daemon only logs a failure to start it. The notifier runs on a
thread of its own, so it starts after the daemonize fork.
The notifier's log messages go through the daemon's logging under
their own domain, so they land in the same journal stream as the
daemon's other messages.
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
src/pmxcfs/cfs-utils.h | 4 ++++
src/pmxcfs/pmxcfs.c | 24 ++++++++++++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/src/pmxcfs/cfs-utils.h b/src/pmxcfs/cfs-utils.h
index ed67264..29f844e 100644
--- a/src/pmxcfs/cfs-utils.h
+++ b/src/pmxcfs/cfs-utils.h
@@ -78,6 +78,10 @@ void ipc_log_fn(const char *file, int32_t line, int32_t severity, const char *ms
cfs_log(G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, __FILE__, __LINE__, G_STRFUNC, __VA_ARGS__)
#define cfs_dom_critical(domain, ...) \
cfs_log(domain, G_LOG_LEVEL_CRITICAL, __FILE__, __LINE__, G_STRFUNC, __VA_ARGS__)
+#define cfs_warn(...) \
+ cfs_log(G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, __FILE__, __LINE__, G_STRFUNC, __VA_ARGS__)
+#define cfs_dom_warn(domain, ...) \
+ cfs_log(domain, G_LOG_LEVEL_WARNING, __FILE__, __LINE__, G_STRFUNC, __VA_ARGS__)
#define cfs_message(...) \
cfs_log(G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, __FILE__, __LINE__, G_STRFUNC, __VA_ARGS__)
#define cfs_dom_message(domain, ...) \
diff --git a/src/pmxcfs/pmxcfs.c b/src/pmxcfs/pmxcfs.c
index 14f1168..34bd4be 100644
--- a/src/pmxcfs/pmxcfs.c
+++ b/src/pmxcfs/pmxcfs.c
@@ -39,6 +39,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/utsname.h>
+#include <syslog.h>
#include <unistd.h>
#include <qb/qbdefs.h>
@@ -51,6 +52,7 @@
#include "confdb.h"
#include "dcdb.h"
#include "dfsm.h"
+#include "pmxcfs-notify.h"
#include "quorum.h"
#include "server.h"
#include "status.h"
@@ -58,6 +60,7 @@
#define DBFILENAME VARLIBDIR "/config.db"
#define LOCKFILE VARLIBDIR "/.pmxcfs.lockfile"
#define RESTART_FLAG_FILE RUNDIR "/cfs-restart-flag"
+#define NOTIFY_SOCKET RUNDIR "/pmxcfs.sock"
#define CFSDIR "/etc/pve"
@@ -78,6 +81,18 @@ static void glib_log_handler(
cfs_log(log_domain, log_level, NULL, 0, NULL, "%s", message);
}
+static void notify_log_cb(int priority, const char *msg) {
+ if (priority <= LOG_ERR) {
+ cfs_dom_critical("notify", "%s", msg);
+ } else if (priority <= LOG_WARNING) {
+ cfs_dom_warn("notify", "%s", msg);
+ } else if (priority <= LOG_INFO) {
+ cfs_dom_message("notify", "%s", msg);
+ } else {
+ cfs_dom_debug("notify", "%s", msg);
+ }
+}
+
static gboolean write_pidfile(pid_t pid) {
char *strpid = g_strdup_printf("%d\n", pid);
gboolean res = atomic_write_file(CFS_PID_FN, strpid, strlen(strpid), 0644, getgid());
@@ -1032,6 +1047,13 @@ int main(int argc, char *argv[]) {
cfs_loop_add_service(corosync_loop, service_status, QB_LOOP_LOW);
}
+ memdb_set_notify_hook(pmxcfs_notify_emit);
+
+ // must run before any other thread starts, since the bind changes the process umask
+ if (pmxcfs_notify_init(NOTIFY_SOCKET, cfs.gid, notify_log_cb) != 0) {
+ cfs_critical("running without change notification socket");
+ }
+
cfs_loop_start_worker(corosync_loop);
server_start(memdb);
@@ -1053,6 +1075,8 @@ int main(int argc, char *argv[]) {
server_stop();
+ pmxcfs_notify_shutdown();
+
fuse_unmount(CFSDIR, fuse_chan);
fuse_destroy(fuse);
--
2.47.3
next prev parent reply other threads:[~2026-10-22 14:23 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-22 14:21 [PATCH cluster 00/12] pmxcfs: add a change notification socket Hannes Laimer
2026-10-22 14:21 ` [PATCH pve-cluster 01/12] buildsys: add rust workspace under src/rust Hannes Laimer
2026-10-22 14:21 ` [PATCH pve-cluster 02/12] rust: notify: add path templates with placeholder capture Hannes Laimer
2026-10-22 14:21 ` [PATCH pve-cluster 03/12] rust: notify: add the wire protocol Hannes Laimer
2026-10-22 14:21 ` [PATCH pve-cluster 04/12] rust: notify: add subscription matching Hannes Laimer
2026-10-22 14:21 ` [PATCH pve-cluster 05/12] rust: notify: add the socket server Hannes Laimer
2026-10-22 14:21 ` [PATCH pve-cluster 06/12] rust: ffi: add C ABI staticlib for pmxcfs Hannes Laimer
2026-10-22 14:22 ` [PATCH pve-cluster 07/12] pmxcfs: memdb: add change notification hook Hannes Laimer
2026-10-22 14:22 ` [PATCH pve-cluster 08/12] buildsys: link pmxcfs against the rust notify staticlib Hannes Laimer
2026-10-22 14:22 ` Hannes Laimer [this message]
2026-10-22 14:22 ` [PATCH pve-cluster 10/12] cfs: add perl client for the change notification socket Hannes Laimer
2026-10-22 14:22 ` [PATCH pve-cluster 11/12] cfs: add hook registry for change notification consumers Hannes Laimer
2026-10-22 14:22 ` [PATCH pve-cluster 12/12] cfs: add runner executing cluster change hooks in children Hannes Laimer
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=20261022142205.930536-10-h.laimer@proxmox.com \
--to=h.laimer@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