char *cgroup_path = strrchr(buf, ':');
if (!cgroup_path) {
fprintf(stderr, "unexpected cgroup entry %s\n", buf);
- goto ret;
+ continue;
}
cgroup_path++;
- if (strncmp(cgroup_path, "/qemu.slice", 11)) {
+ if (strncmp(cgroup_path, "/qemu.slice/", 12)) {
continue;
}
char *vmid_start = strrchr(buf, '/');
if (!vmid_start) {
fprintf(stderr, "unexpected cgroup entry %s\n", buf);
- goto ret;
+ continue;
}
vmid_start++;
if (vmid_start[0] == '-' || vmid_start[0] == '\0') {
fprintf(stderr, "invalid vmid in cgroup entry %s\n", buf);
- goto ret;
+ continue;
}
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;
if (errno) {
fprintf(stderr, "error parsing vmid for %d: %s\n", pid, strerror(errno));
} else {
- fprintf(stderr, "error parsing vmid for %d: no qemu.slice cgroup entry\n", pid);
+ fprintf(stderr, "error parsing vmid for %d: no matching qemu.slice cgroup entry\n", pid);
}
ret: