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.eb...@proxmox.com>
---

Changes in v2:
    * Keep setting vmid to zero in the error case!
    * Still print error to indicate it's unexpected. Can potentially
      be helpful for debugging.

 qmeventd/qmeventd.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/qmeventd/qmeventd.c b/qmeventd/qmeventd.c
index 503bce69..0130103d 100644
--- a/qmeventd/qmeventd.c
+++ b/qmeventd/qmeventd.c
@@ -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;
-- 
2.39.2



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to