]> git.proxmox.com Git - qemu-server.git/commitdiff
qmeventd: further improve getting VMID from PID
authorFiona Ebner <f.ebner@proxmox.com>
Mon, 10 Jul 2023 08:53:00 +0000 (10:53 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 17 Jul 2023 09:30:47 +0000 (11:30 +0200)
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>
qmeventd/qmeventd.c

index 503bce6901cf4ba467ccb516f0ff3d56dabc5a4e..0130103de0575b795f7fb800ac8024f4f93c688d 100644 (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;