mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00:00
LXC fix virCgroupGetValueStr problem with \n
A cgroup file returns integer value terminated with '\n' and remaining it has sometimes harmful effects, for example it leads virStrToLong_ull to fail. * src/util/cgroup.c: strip out terminating \n when reading a value
This commit is contained in:
parent
4f4a1deccb
commit
41fa653f32
@ -309,6 +309,10 @@ static int virCgroupGetValueStr(virCgroupPtr group,
|
||||
DEBUG("Failed to read %s: %m\n", keypath);
|
||||
rc = -errno;
|
||||
} else {
|
||||
/* Terminated with '\n' has sometimes harmful effects to the caller */
|
||||
char *p = strchr(*value, '\n');
|
||||
if (p) *p = '\0';
|
||||
|
||||
rc = 0;
|
||||
}
|
||||
|
||||
@ -969,13 +973,7 @@ int virCgroupSetFreezerState(virCgroupPtr group, const char *state)
|
||||
|
||||
int virCgroupGetFreezerState(virCgroupPtr group, char **state)
|
||||
{
|
||||
int ret;
|
||||
ret = virCgroupGetValueStr(group,
|
||||
return virCgroupGetValueStr(group,
|
||||
VIR_CGROUP_CONTROLLER_CPU,
|
||||
"freezer.state", state);
|
||||
if (ret == 0) {
|
||||
char *p = strchr(*state, '\n');
|
||||
if (p) *p = '\0';
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user