[pve-devel] [PATCH cluster v4 1/2] pmxcfs: make status entry removable

Dominik Csapak d.csapak at proxmox.com
Thu May 16 17:12:30 CEST 2019


we can now do a CFS_IPC_SET_STATUS with no data, which results in
removal of the entry in the kv entries

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
new in v4
 data/PVE/Cluster.pm | 6 ++++++
 data/src/status.c   | 4 +++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/data/PVE/Cluster.pm b/data/PVE/Cluster.pm
index 5af11e6..3705a79 100644
--- a/data/PVE/Cluster.pm
+++ b/data/PVE/Cluster.pm
@@ -432,6 +432,12 @@ my $ipcc_get_status = sub {
     return PVE::IPCC::ipcc_send_rec(CFS_IPC_GET_STATUS, $bindata);
 };
 
+my $ipcc_remove_status = sub {
+    my ($name) = @_;
+    my $bindata = pack "Z[256]", $name;
+    return &$ipcc_send_rec(CFS_IPC_SET_STATUS, $bindata);
+};
+
 my $ipcc_update_status = sub {
     my ($name, $data) = @_;
 
diff --git a/data/src/status.c b/data/src/status.c
index 3a52e9b..e6f8490 100644
--- a/data/src/status.c
+++ b/data/src/status.c
@@ -792,7 +792,9 @@ kventry_hash_set(
 	g_return_val_if_fail(data != NULL, FALSE);
 
 	kventry_t *entry;
-	if ((entry = (kventry_t *)g_hash_table_lookup(kvhash, key))) {
+	if (!len) {
+		g_hash_table_remove(kvhash, key);
+	} else if ((entry = (kventry_t *)g_hash_table_lookup(kvhash, key))) {
 		g_free(entry->data);
 		entry->data = g_memdup(data, len);
 		entry->len = len;
-- 
2.11.0





More information about the pve-devel mailing list