qmeventd: add block write threshold event handling

This commit is contained in:
Tiago Sousa 2025-10-10 18:02:20 +01:00
parent 14823177f5
commit 7f7776c18e

View file

@ -43,7 +43,7 @@
#define DEFAULT_KILL_TIMEOUT 60
static int verbose = 0;
static int verbose = 1;
static int kill_timeout = DEFAULT_KILL_TIMEOUT;
static int epoll_fd = 0;
static const char *progname;
@ -209,6 +209,25 @@ void 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)) {
// needs concurrency control
char extend_queue_path[] = "/etc/pve/extend-queue";
FILE *p_extend_queue = fopen(extend_queue_path, "a");
if (p_extend_queue == NULL) {
VERBOSE_PRINT(
"%s: Couldn't open extend queue file %s", client->qemu.vmid, extend_queue_path
);
} else {
const char *nodename_string = json_object_get_string(nodename);
fprintf(p_extend_queue, "%s: %s\n", client->qemu.vmid, nodename_string);
}
fclose(p_extend_queue);
}
}
}