public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Daniel Kral <d.kral@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH cluster 05/12] pmxcfs: server: report responses exceeding the maximum message size
Date: Mon, 24 Aug 2026 10:56:04 +0200	[thread overview]
Message-ID: <20260824085610.111211-7-d.kral@proxmox.com> (raw)
In-Reply-To: <20260824085610.111211-2-d.kral@proxmox.com>

The shared memory ring buffer has a fixed maximum buffer size of
MAX_MSG_SIZE (currently 1 MiB), which is set by the pmxcfs' libqb-based
IPC client. If the maximium buffer size is exceeded, the QB ringbuffer
will fail to allocate the chunk for the response.

qb_ipcs_response_sendv() will fail with -EAGAIN, which will be logged by
pmxcfs as a rather confusing user error:

    [ipcs] crit: qb_ipcs_response_send: Resource temporarily unavailable
    [libqb] error: error receiving from setup sock (/dev/shm/qb-[...]/qb): Bad file descriptor (9)

and makes users of $PVE::Cluster::ipcc_send_rec{,_json}() fail with:

    ipcc_send_rec[13] failed: Transport endpoint is not connected

In huge cluster setups with many nodes, storages, and many thousands of
guests, the current MAX_MSG_SIZE of 1 MiB could be exceeded.

For example, in a test cluster with 10,000 stopped guests, the response
of CFS_IPC_GET_RRD_DUMP does already have 919 KiB, where many of the
runtime values are undefined (U) and therefore the response size would
be much longer if they were all running. Similar response sizes can be
reached with CFS_IPC_GET_GUEST_LIST and
CFS_IPC_GET_GUEST_CONFIG_PROPERTIES.

Report response messages that exceed the maximum message size in the
client and server to make the issue clearer to discern from other
possible errors, e.g. an unresponsive IPC server.

Signed-off-by: Daniel Kral <d.kral@proxmox.com>
---
 src/pmxcfs/server.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/pmxcfs/server.c b/src/pmxcfs/server.c
index abe1bee..54cd3aa 100644
--- a/src/pmxcfs/server.c
+++ b/src/pmxcfs/server.c
@@ -449,15 +449,23 @@ static int32_t s1_msg_process_fn(qb_ipcs_connection_t *c, void *data, size_t siz
 
     cfs_debug("process result %d", result);
 
+    int iov_len = 2;
+    struct iovec iov[iov_len];
+    struct qb_ipc_response_header res_header;
+    int32_t max_msg_size = qb_ipcs_connection_get_buffer_size(c);
+
+    if (sizeof(res_header) + outbuf->len > max_msg_size) {
+        cfs_critical(
+            "response for id %d is too large: %ld > %d", request_id, outbuf->len, max_msg_size
+        );
+        result = -EMSGSIZE;
+    }
+
     /* Do not send the response body in case of an error */
     if (result < 0) {
         g_string_truncate(outbuf, 0);
     }
 
-    int iov_len = 2;
-    struct iovec iov[iov_len];
-    struct qb_ipc_response_header res_header;
-
     res_header.id = request_id;
     res_header.size = sizeof(res_header) + outbuf->len;
     res_header.error = result;
-- 
2.47.3





  parent reply	other threads:[~2026-08-24  8:58 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-24  8:55 [PATCH-SERIES cluster 00/12] addressing large ipc message responses Daniel Kral
2026-08-24  8:56 ` [PATCH cluster 01/12] buildsys: include pmxcfs tidy target in top-level tidy target Daniel Kral
2026-08-24  8:56 ` [PATCH cluster 02/12] run make tidy Daniel Kral
2026-08-24  8:56 ` [PATCH cluster 03/12] pmxcfs: server: simplify non-negative ipc message result responses Daniel Kral
2026-08-24  8:56 ` [PATCH cluster 04/12] pmxcfs: server: simplify ipc message response logic Daniel Kral
2026-08-24  8:56 ` Daniel Kral [this message]
2026-08-24  8:56 ` [PATCH cluster 06/12] pmxcfs: server: remove unnecessary local variable alignment attributes Daniel Kral
2026-08-24  8:56 ` [PATCH cluster 07/12] pmxcfs: server: move message handling to separate function Daniel Kral
2026-08-24  8:56 ` [PATCH cluster 08/12] pmxcfs: server: move message response sending " Daniel Kral
2026-08-24  8:56 ` [PATCH cluster 09/12] pmxcfs: server: simplify message response size calculation Daniel Kral
2026-08-24  8:56 ` [PATCH cluster 10/12] ipcc: move the data pointer initialization up Daniel Kral
2026-08-24  8:56 ` [PATCH cluster 11/12] pmxcfs: server: do not forward qb_ipc_request_header to s1_msg_handle_request Daniel Kral
2026-08-24  8:56 ` [RFC PATCH cluster 12/12] allow large ipc responses by sending the response message in chunks Daniel Kral

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=20260824085610.111211-7-d.kral@proxmox.com \
    --to=d.kral@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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal