X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fvirt.c;h=4c526ff45471620616237ac3176ca594e7921bc5;hp=380fabded278184dd33a5ccee9b8c0dd51f35545;hb=fb0864e7b9c6d26269ccea6ec5c0fd921c029781;hpb=263653e10353d8ad155f1faba01981816a2bb712 diff --git a/src/virt.c b/src/virt.c index 380fabded..4c526ff45 100644 --- a/src/virt.c +++ b/src/virt.c @@ -209,6 +209,13 @@ int detect_container(const char **id) { *id = "lxc"; return 1; + } else if (streq(line, "container=lxc-libvirt")) { + fclose(f); + + if (id) + *id = "lxc-libvirt"; + return 1; + } else if (streq(line, "container=systemd-nspawn")) { fclose(f); @@ -229,35 +236,6 @@ int detect_container(const char **id) { fclose(f); } - f = fopen("/proc/self/cgroup", "re"); - if (f) { - - for (;;) { - char line[LINE_MAX], *p; - - if (!fgets(line, sizeof(line), f)) - break; - - p = strchr(strstrip(line), ':'); - if (!p) - continue; - - if (strncmp(p, ":ns:", 4)) - continue; - - if (!streq(p, ":ns:/")) { - fclose(f); - - if (id) - *id = "pidns"; - - return 1; - } - } - - fclose(f); - } - return 0; }