5
0
mirror of git://git.proxmox.com/git/qemu-server.git synced 2025-01-03 01:17:58 +03:00

qmeventd: further improve getting VMID from PID

by also expecting the ".scope" part and trying the next entry if it is
not present instead of immediately failing.

It's still unexpected to encounter such entries, so keep the log line.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
This commit is contained in:
Fiona Ebner 2023-07-10 10:53:00 +02:00 committed by Wolfgang Bumiller
parent d0b587533c
commit a9f2e2d6f9

View File

@ -128,12 +128,14 @@ get_vmid_from_pid(pid_t pid)
errno = 0;
char *endptr = NULL;
vmid = strtoul(vmid_start, &endptr, 10);
if (!endptr || strncmp(endptr, ".scope", 6)) {
fprintf(stderr, "unexpected cgroup entry %s\n", buf);
vmid = 0;
continue;
}
if (errno != 0) {
fprintf(stderr, "error parsing vmid for %d: %s\n", pid, strerror(errno));
vmid = 0;
} else if (*endptr != '.') {
fprintf(stderr, "unexpected cgroup entry %s\n", buf);
vmid = 0;
}
goto ret;