[PATCH qemu-server 3/6] qmevent: call qm disk blockextend when write_threshold event is received

Alexandre Derumier alexandre.derumier at groupe-cyllene.com
Mon Aug 26 13:00:25 CEST 2024


Signed-off-by: Alexandre Derumier <alexandre.derumier at groupe-cyllene.com>
---
 qmeventd/qmeventd.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/qmeventd/qmeventd.c b/qmeventd/qmeventd.c
index d8f3ee7..4f45b6f 100644
--- a/qmeventd/qmeventd.c
+++ b/qmeventd/qmeventd.c
@@ -229,6 +229,33 @@ handle_qmp_event(struct Client *client, struct json_object *obj)
 
 	// check if a backup is running and kill QEMU process if not
 	terminate_check(client);
+    } else if (!strcmp(json_object_get_string(event), "BLOCK_WRITE_THRESHOLD")) {
+
+	struct json_object *data;
+	struct json_object *nodename;
+	if (json_object_object_get_ex(obj, "data", &data) &&
+	    json_object_object_get_ex(data, "node-name", &nodename))
+	{
+	    int pid = fork();
+	    if (pid < 0) {
+		fprintf(stderr, "fork failed: %s\n", strerror(errno));
+		return;
+	    }
+	    if (pid == 0) {
+		char *script = "/usr/sbin/qm";
+		char *args[] = {
+		    script,
+		    "disk",
+		    "blockextend",
+		    client->qemu.vmid,
+		    (char *)json_object_get_string(nodename),
+		    NULL
+		};
+		execvp(script, args);
+		perror("execvp");
+		_exit(1);
+	    }
+	}
     }
 }
 
-- 
2.39.2




More information about the pve-devel mailing list