Skip to content

Commit b98a4f8

Browse files
committed
Include support for legacy LXC cgroup naming
1 parent 55e073a commit b98a4f8

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

linux/CGroupUtils.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ static bool CGroup_filterName_internal(const char *cgroup, StrBuf_state* s, StrB
6767
const char* str_machine_slice = "machine.slice";
6868
const char* str_user_slice_prefix = "/user-";
6969

70+
const char* str_lxc_monitor_legacy = "lxc.monitor";
71+
const char* str_lxc_payload_legacy = "lxc.payload";
7072
const char* str_lxc_monitor_prefix = "lxc.monitor.";
7173
const char* str_lxc_payload_prefix = "lxc.payload.";
7274

@@ -193,6 +195,34 @@ static bool CGroup_filterName_internal(const char *cgroup, StrBuf_state* s, StrB
193195
continue;
194196
}
195197

198+
// LXC legacy cgroup naming
199+
if (Label_checkEqual(labelStart, labelLen, str_lxc_monitor_legacy) ||
200+
Label_checkEqual(labelStart, labelLen, str_lxc_payload_legacy)) {
201+
bool isMonitor = Label_checkEqual(labelStart, labelLen, str_lxc_monitor_legacy);
202+
203+
labelStart = nextSlash;
204+
while (*labelStart == '/')
205+
labelStart++;
206+
207+
nextSlash = strchrnul(labelStart, '/');
208+
if (nextSlash - labelStart > 0) {
209+
if (!StrBuf_putsz(s, w, isMonitor ? "[LXC:" : "[lxc:"))
210+
return false;
211+
212+
if (!StrBuf_putsn(s, w, labelStart, nextSlash - labelStart))
213+
return false;
214+
215+
if (!w(s, ']'))
216+
return false;
217+
218+
cgroup = nextSlash;
219+
continue;
220+
}
221+
222+
labelStart = cgroup;
223+
nextSlash = labelStart + labelLen;
224+
}
225+
196226
if (Label_checkSuffix(labelStart, labelLen, str_service_suffix)) {
197227
const size_t serviceNameLen = labelLen - strlen(str_service_suffix);
198228

0 commit comments

Comments
 (0)