From 8c12940a66e84ace6c428f4ddbda547d862316b0 Mon Sep 17 00:00:00 2001 From: Stefan Hanreich Date: Fri, 1 Aug 2025 14:10:25 +0200 Subject: [PATCH 01/10] pmxcfs: remove legacy ipam db and mac cache files Those files get migrated with pve-network >= 0.9.9 - so we do not need to observe them anymore via pmxcfs. Signed-off-by: Stefan Hanreich Link: https://lore.proxmox.com/20250801121029.201766-2-s.hanreich@proxmox.com Signed-off-by: Thomas Lamprecht --- src/PVE/Cluster.pm | 2 -- src/pmxcfs/status.c | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/PVE/Cluster.pm b/src/PVE/Cluster.pm index 9380241..e829687 100644 --- a/src/PVE/Cluster.pm +++ b/src/PVE/Cluster.pm @@ -61,8 +61,6 @@ my $observed = { 'priv/tfa.cfg' => 1, 'priv/token.cfg' => 1, 'priv/acme/plugins.cfg' => 1, - 'priv/ipam.db' => 1, # TODO: replaced by sdn/ipam-pve-db.json, remove in PVE 9+ - 'priv/macs.db' => 1, # TODO: replaced by sdn/mac-cache.json, remove in PVE 9+ '/qemu-server/' => 1, '/openvz/' => 1, '/lxc/' => 1, diff --git a/src/pmxcfs/status.c b/src/pmxcfs/status.c index a00e793..d07ab33 100644 --- a/src/pmxcfs/status.c +++ b/src/pmxcfs/status.c @@ -88,8 +88,6 @@ static memdb_change_t memdb_change_array[] = { {.path = "priv/acme/plugins.cfg"}, {.path = "priv/tfa.cfg"}, {.path = "priv/token.cfg"}, - {.path = "priv/ipam.db"}, // TODO: replaced by sdn/ipam-pve-db.json remove with PVE 9 or later - {.path = "priv/macs.db"}, // TODO: replaced by sdn/mac-cache.json remove with PVE 9 or later {.path = "datacenter.cfg"}, {.path = "vzdump.cron"}, {.path = "vzdump.conf"}, From 8239d5c3657a0e3fe751689bce920b7c2c87e531 Mon Sep 17 00:00:00 2001 From: Lukas Wagner Date: Fri, 1 Aug 2025 11:54:27 +0200 Subject: [PATCH 02/10] pmxcfs: status: add one more missing g_free Otherwise we leak the memory that was already allocated for `filename`. Signed-off-by: Lukas Wagner Tested-by: Maximiliano Sandoval Reviewed-by: Maximiliano Sandoval Link: https://lore.proxmox.com/20250801095431.117317-1-l.wagner@proxmox.com Signed-off-by: Thomas Lamprecht --- src/pmxcfs/status.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pmxcfs/status.c b/src/pmxcfs/status.c index d07ab33..51db09b 100644 --- a/src/pmxcfs/status.c +++ b/src/pmxcfs/status.c @@ -1367,6 +1367,8 @@ static void update_rrd_data(const char *key, gconstpointer data, size_t len) { } else if (g_file_test(filename_pve2, G_FILE_TEST_EXISTS)) { // old file exists, use it use_pve2_file = 1; + + g_free(filename); filename = g_strdup_printf("%s", filename_pve2); } else { // neither file exists, check for directories to decide and create file From 426cb07ed853db202aaa219b06be80e7bbb4c74c Mon Sep 17 00:00:00 2001 From: Lukas Wagner Date: Fri, 1 Aug 2025 11:54:28 +0200 Subject: [PATCH 03/10] pmxcfs: status: avoid unnecessary string allocations Signed-off-by: Lukas Wagner Tested-by: Maximiliano Sandoval Reviewed-by: Maximiliano Sandoval Link: https://lore.proxmox.com/20250801095431.117317-2-l.wagner@proxmox.com Signed-off-by: Thomas Lamprecht --- src/pmxcfs/status.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/src/pmxcfs/status.c b/src/pmxcfs/status.c index 51db09b..ebaac72 100644 --- a/src/pmxcfs/status.c +++ b/src/pmxcfs/status.c @@ -1372,14 +1372,12 @@ static void update_rrd_data(const char *key, gconstpointer data, size_t len) { filename = g_strdup_printf("%s", filename_pve2); } else { // neither file exists, check for directories to decide and create file - char *dir_pve2 = g_strdup_printf(RRDDIR "/pve2-node"); - char *dir_pve90 = g_strdup_printf(RRDDIR "/pve-node-9.0"); - if (g_file_test(dir_pve90, G_FILE_TEST_IS_DIR)) { + if (g_file_test(RRDDIR "/pve-node-9.0", G_FILE_TEST_IS_DIR)) { int argcount = sizeof(rrd_def_node_pve9_0) / sizeof(void *) - 1; create_rrd_file(filename, argcount, rrd_def_node_pve9_0); - } else if (g_file_test(dir_pve2, G_FILE_TEST_IS_DIR)) { + } else if (g_file_test(RRDDIR "/pve2-node", G_FILE_TEST_IS_DIR)) { use_pve2_file = 1; g_free(filename); @@ -1402,8 +1400,6 @@ static void update_rrd_data(const char *key, gconstpointer data, size_t len) { int argcount = sizeof(rrd_def_node_pve9_0) / sizeof(void *) - 1; create_rrd_file(filename, argcount, rrd_def_node_pve9_0); } - g_free(dir_pve2); - g_free(dir_pve90); } skip = 2; // first two columns are live data that isn't archived @@ -1448,14 +1444,12 @@ static void update_rrd_data(const char *key, gconstpointer data, size_t len) { filename = g_strdup_printf("%s", filename_pve2); } else { // neither file exists, check for directories to decide and create file - char *dir_pve2 = g_strdup_printf(RRDDIR "/pve2-vm"); - char *dir_pve90 = g_strdup_printf(RRDDIR "/pve-vm-9.0"); - if (g_file_test(dir_pve90, G_FILE_TEST_IS_DIR)) { + if (g_file_test(RRDDIR "/pve-vm-9.0", G_FILE_TEST_IS_DIR)) { int argcount = sizeof(rrd_def_vm_pve9_0) / sizeof(void *) - 1; create_rrd_file(filename, argcount, rrd_def_vm_pve9_0); - } else if (g_file_test(dir_pve2, G_FILE_TEST_IS_DIR)) { + } else if (g_file_test(RRDDIR "/pve2-vm", G_FILE_TEST_IS_DIR)) { use_pve2_file = 1; g_free(filename); @@ -1470,8 +1464,6 @@ static void update_rrd_data(const char *key, gconstpointer data, size_t len) { int argcount = sizeof(rrd_def_vm_pve9_0) / sizeof(void *) - 1; create_rrd_file(filename, argcount, rrd_def_vm_pve9_0); } - g_free(dir_pve2); - g_free(dir_pve90); } skip = 4; // first 4 columns are live data that isn't archived @@ -1518,17 +1510,15 @@ static void update_rrd_data(const char *key, gconstpointer data, size_t len) { filename = g_strdup_printf("%s", filename_pve2); } else { // neither file exists, check for directories to decide and create file - char *dir_pve2 = g_strdup_printf(RRDDIR "/pve2-storage"); - char *dir_pve90 = g_strdup_printf(RRDDIR "/pve-storage-9.0"); - if (g_file_test(dir_pve90, G_FILE_TEST_IS_DIR)) { + if (g_file_test(RRDDIR "/pve-storage-9.0", G_FILE_TEST_IS_DIR)) { char *dir = g_path_get_dirname(filename); checked_mkdir(dir, 0755); g_free(dir); int argcount = sizeof(rrd_def_storage_pve9_0) / sizeof(void *) - 1; create_rrd_file(filename, argcount, rrd_def_storage_pve9_0); - } else if (g_file_test(dir_pve2, G_FILE_TEST_IS_DIR)) { + } else if (g_file_test(RRDDIR "/pve2-storage", G_FILE_TEST_IS_DIR)) { g_free(filename); filename = g_strdup_printf("%s", filename_pve2); @@ -1549,8 +1539,6 @@ static void update_rrd_data(const char *key, gconstpointer data, size_t len) { int argcount = sizeof(rrd_def_storage_pve9_0) / sizeof(void *) - 1; create_rrd_file(filename, argcount, rrd_def_storage_pve9_0); } - g_free(dir_pve2); - g_free(dir_pve90); } // actual data columns didn't change between pve2-storage and pve-storage-9.0 From c66917260e8bdf2a76878baee0ba91c6f4469207 Mon Sep 17 00:00:00 2001 From: Lukas Wagner Date: Fri, 1 Aug 2025 11:54:29 +0200 Subject: [PATCH 04/10] pmxcfs: status: call g_strdup instead of g_strdup_printf when no formatting is needed This should be a tiny bit more efficient. Signed-off-by: Lukas Wagner Tested-by: Maximiliano Sandoval Reviewed-by: Maximiliano Sandoval Link: https://lore.proxmox.com/20250801095431.117317-3-l.wagner@proxmox.com Signed-off-by: Thomas Lamprecht --- src/pmxcfs/status.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pmxcfs/status.c b/src/pmxcfs/status.c index ebaac72..462e530 100644 --- a/src/pmxcfs/status.c +++ b/src/pmxcfs/status.c @@ -1369,7 +1369,7 @@ static void update_rrd_data(const char *key, gconstpointer data, size_t len) { use_pve2_file = 1; g_free(filename); - filename = g_strdup_printf("%s", filename_pve2); + filename = g_strdup(filename_pve2); } else { // neither file exists, check for directories to decide and create file @@ -1381,7 +1381,7 @@ static void update_rrd_data(const char *key, gconstpointer data, size_t len) { use_pve2_file = 1; g_free(filename); - filename = g_strdup_printf("%s", filename_pve2); + filename = g_strdup(filename_pve2); char *dir = g_path_get_dirname(filename); checked_mkdir(dir, 0755); @@ -1441,7 +1441,7 @@ static void update_rrd_data(const char *key, gconstpointer data, size_t len) { // old file exists, use it use_pve2_file = 1; g_free(filename); - filename = g_strdup_printf("%s", filename_pve2); + filename = g_strdup(filename_pve2); } else { // neither file exists, check for directories to decide and create file @@ -1453,7 +1453,7 @@ static void update_rrd_data(const char *key, gconstpointer data, size_t len) { use_pve2_file = 1; g_free(filename); - filename = g_strdup_printf("%s", filename_pve2); + filename = g_strdup(filename_pve2); int argcount = sizeof(rrd_def_vm) / sizeof(void *) - 1; create_rrd_file(filename, argcount, rrd_def_vm); @@ -1507,7 +1507,7 @@ static void update_rrd_data(const char *key, gconstpointer data, size_t len) { } else if (g_file_test(filename_pve2, G_FILE_TEST_EXISTS)) { // old file exists, use it g_free(filename); - filename = g_strdup_printf("%s", filename_pve2); + filename = g_strdup(filename_pve2); } else { // neither file exists, check for directories to decide and create file @@ -1520,7 +1520,7 @@ static void update_rrd_data(const char *key, gconstpointer data, size_t len) { create_rrd_file(filename, argcount, rrd_def_storage_pve9_0); } else if (g_file_test(RRDDIR "/pve2-storage", G_FILE_TEST_IS_DIR)) { g_free(filename); - filename = g_strdup_printf("%s", filename_pve2); + filename = g_strdup(filename_pve2); char *dir = g_path_get_dirname(filename); checked_mkdir(dir, 0755); From 0795244f98b6e5e34491b9a1b3967d5bf935afd8 Mon Sep 17 00:00:00 2001 From: Lukas Wagner Date: Fri, 1 Aug 2025 11:54:30 +0200 Subject: [PATCH 05/10] pmxcfs: status: remove string literal params for g_strdup_printf Signed-off-by: Lukas Wagner Tested-by: Maximiliano Sandoval Reviewed-by: Maximiliano Sandoval Link: https://lore.proxmox.com/20250801095431.117317-4-l.wagner@proxmox.com Signed-off-by: Thomas Lamprecht --- src/pmxcfs/status.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pmxcfs/status.c b/src/pmxcfs/status.c index 462e530..105cd61 100644 --- a/src/pmxcfs/status.c +++ b/src/pmxcfs/status.c @@ -1429,7 +1429,7 @@ static void update_rrd_data(const char *key, gconstpointer data, size_t len) { } filename = g_strdup_printf(RRDDIR "/pve-vm-9.0/%s", vmid); - char *filename_pve2 = g_strdup_printf(RRDDIR "/%s/%s", "pve2-vm", vmid); + char *filename_pve2 = g_strdup_printf(RRDDIR "/pve2-vm/%s", vmid); int use_pve2_file = 0; @@ -1498,7 +1498,7 @@ static void update_rrd_data(const char *key, gconstpointer data, size_t len) { } filename = g_strdup_printf(RRDDIR "/pve-storage-9.0/%s", node); - char *filename_pve2 = g_strdup_printf(RRDDIR "/%s/%s", "pve2-storage", node); + char *filename_pve2 = g_strdup_printf(RRDDIR "/pve2-storage/%s", node); // check existing rrd files and directories if (g_file_test(filename, G_FILE_TEST_EXISTS)) { From 054995ba3d43e2bfe1e8fcd3d63549e3579e6ef9 Mon Sep 17 00:00:00 2001 From: Lukas Wagner Date: Fri, 1 Aug 2025 11:54:31 +0200 Subject: [PATCH 06/10] pmxcfs: status: avoid g_strdup when not needed `filename_pve2` is not accessed anymore after assigning the copy to `filename`, so we can simply 'transfer' the ownership to `filename` and set `filenname_pve2` to NULL. The call to `g_free(filename_pve2)` later can handle a NULL arg, it will simply do nothing in this case. Signed-off-by: Lukas Wagner Tested-by: Maximiliano Sandoval Reviewed-by: Maximiliano Sandoval Link: https://lore.proxmox.com/20250801095431.117317-5-l.wagner@proxmox.com Signed-off-by: Thomas Lamprecht --- src/pmxcfs/status.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/pmxcfs/status.c b/src/pmxcfs/status.c index 105cd61..130f08f 100644 --- a/src/pmxcfs/status.c +++ b/src/pmxcfs/status.c @@ -1369,7 +1369,8 @@ static void update_rrd_data(const char *key, gconstpointer data, size_t len) { use_pve2_file = 1; g_free(filename); - filename = g_strdup(filename_pve2); + filename = filename_pve2; + filename_pve2 = NULL; } else { // neither file exists, check for directories to decide and create file @@ -1381,7 +1382,8 @@ static void update_rrd_data(const char *key, gconstpointer data, size_t len) { use_pve2_file = 1; g_free(filename); - filename = g_strdup(filename_pve2); + filename = filename_pve2; + filename_pve2 = NULL; char *dir = g_path_get_dirname(filename); checked_mkdir(dir, 0755); @@ -1441,7 +1443,8 @@ static void update_rrd_data(const char *key, gconstpointer data, size_t len) { // old file exists, use it use_pve2_file = 1; g_free(filename); - filename = g_strdup(filename_pve2); + filename = filename_pve2; + filename_pve2 = NULL; } else { // neither file exists, check for directories to decide and create file @@ -1453,7 +1456,8 @@ static void update_rrd_data(const char *key, gconstpointer data, size_t len) { use_pve2_file = 1; g_free(filename); - filename = g_strdup(filename_pve2); + filename = filename_pve2; + filename_pve2 = NULL; int argcount = sizeof(rrd_def_vm) / sizeof(void *) - 1; create_rrd_file(filename, argcount, rrd_def_vm); @@ -1507,7 +1511,8 @@ static void update_rrd_data(const char *key, gconstpointer data, size_t len) { } else if (g_file_test(filename_pve2, G_FILE_TEST_EXISTS)) { // old file exists, use it g_free(filename); - filename = g_strdup(filename_pve2); + filename = filename_pve2; + filename_pve2 = NULL; } else { // neither file exists, check for directories to decide and create file @@ -1520,7 +1525,8 @@ static void update_rrd_data(const char *key, gconstpointer data, size_t len) { create_rrd_file(filename, argcount, rrd_def_storage_pve9_0); } else if (g_file_test(RRDDIR "/pve2-storage", G_FILE_TEST_IS_DIR)) { g_free(filename); - filename = g_strdup(filename_pve2); + filename = filename_pve2; + filename_pve2 = NULL; char *dir = g_path_get_dirname(filename); checked_mkdir(dir, 0755); From 63862b41c385c71a56c88abb9d8d5803ddc044fd Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Fri, 1 Aug 2025 14:58:07 +0200 Subject: [PATCH 07/10] bump version to 9.0.5 Signed-off-by: Thomas Lamprecht --- debian/changelog | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/debian/changelog b/debian/changelog index c670721..9d02688 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +pve-cluster (9.0.5) trixie; urgency=medium + + * pmxcfs: remove legacy ipam db and mac cache files. + + * pmxcfs: various internal code clean-ups and fixing some smaller memory + leaks. + + -- Proxmox Support Team Fri, 01 Aug 2025 14:58:03 +0200 + pve-cluster (9.0.4) trixie; urgency=medium * pmxcfs: status: fix create sub directories in /var/lib/rrdcached/db when From e2c572850b587d4b74c029b01dff2b655d661876 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Mon, 4 Aug 2025 11:43:52 +0200 Subject: [PATCH 08/10] rrd: cope with only partially renamed memavailable field During initial development of the revised metrics series this field was sourced by 'memfree' from /proc/meminfo as parsed by our ProcFS tools, but as memavailable got added for PVE 8.4, as it much better shows the state of actually available memory [0], I suggested to Aaron to move the new RRD format also to that metric. While that was done, the RRD definition was still using the old name, while I fixed in in pmxcfs, I forgot to do so in the upgrade migration tool, which then created an RRD file with the old name. Thus map the old name to the new one here in case there is no existing entry for the new one already, if one would be parsed later it would override this fallback anyway. [0] as while the kernel tries to use unused memory to improve performance, it has no issue to release that again quickly on memory pressure. Signed-off-by: Thomas Lamprecht --- src/PVE/RRD.pm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/PVE/RRD.pm b/src/PVE/RRD.pm index c95f495..8fe1927 100644 --- a/src/PVE/RRD.pm +++ b/src/PVE/RRD.pm @@ -37,6 +37,7 @@ sub create_rrd_data { $setup = $setup_pve2; $timeframe = "year" if $timeframe eq "decade"; # we only store up to one year in the old format } + my $is_node = !!($rrdname =~ /^pve-node/); my ($reso, $count) = @{ $setup->{$timeframe} }; my $ctime = $reso * int(time() / $reso); @@ -70,6 +71,8 @@ sub create_rrd_data { my $name = $names->[$i]; if (defined(my $val = $line->[$i])) { $entry->{$name} = $val; + $entry->{memavailable} = $val + if $is_node && $name eq 'memfree' && !exists($entry->{memavailable}); } else { # leave empty fields undefined # maybe make this configurable? From 253de0cdfe1cd53ab8940c2e5147d363c82f9e46 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Mon, 4 Aug 2025 12:38:24 +0200 Subject: [PATCH 09/10] bump version to 9.0.6 Signed-off-by: Thomas Lamprecht --- debian/changelog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/debian/changelog b/debian/changelog index 9d02688..9ac4178 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +pve-cluster (9.0.6) trixie; urgency=medium + + * rrd: cope with only partially renamed memavailable field when old data was + migrated. + + -- Proxmox Support Team Mon, 04 Aug 2025 12:38:19 +0200 + pve-cluster (9.0.5) trixie; urgency=medium * pmxcfs: remove legacy ipam db and mac cache files. From 2abc96b39c17c6769dd89ee7057f7627662f2c62 Mon Sep 17 00:00:00 2001 From: Tiago Sousa Date: Sat, 13 Sep 2025 18:59:28 +0100 Subject: [PATCH 10/10] monitor extend queue file --- src/PVE/Cluster.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PVE/Cluster.pm b/src/PVE/Cluster.pm index e829687..233ba69 100644 --- a/src/PVE/Cluster.pm +++ b/src/PVE/Cluster.pm @@ -87,6 +87,7 @@ my $observed = { 'mapping/directory.cfg' => 1, 'mapping/pci.cfg' => 1, 'mapping/usb.cfg' => 1, + 'extend-queue' => 1, }; sub prepare_observed_file_basedirs {