[libvirt] [PATCH] lxc: fix 2 issue around cpuset

There are two bugs in this function: 1. cannot start a vm with cpuset but without numatune settings # virsh -c lxc:/// start helloworld error: Failed to start domain helloworld error: internal error: guest failed to start: Invalid value '1-3' for 'cpuset.mems': Invalid argument we don't free &mask after use it for virCgroupSetCpusetCpus() and then virDomainNumatuneMaybeFormatNodeset() do not get a new &mask, then we use it in virCgroupSetCpusetMems(). 2. when start a lxc with numatune memory mode not strict # virsh -c lxc:/// start helloworld error: Failed to start domain helloworld error: internal error: guest failed to start: Unknown failure in libvirt_lxc startup We shouldn't set anything in cpuset.mems for these mode. Signed-off-by: Luyao Huang <lhuang@redhat.com> --- src/lxc/lxc_cgroup.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lxc/lxc_cgroup.c b/src/lxc/lxc_cgroup.c index c1813e2..5e959a2 100644 --- a/src/lxc/lxc_cgroup.c +++ b/src/lxc/lxc_cgroup.c @@ -77,11 +77,15 @@ static int virLXCCgroupSetupCpusetTune(virDomainDefPtr def, if (virCgroupSetCpusetCpus(cgroup, mask) < 0) goto cleanup; + /* free mask to make sure we won't use it in a wrong way later */ + VIR_FREE(mask); } if (virDomainNumatuneGetMode(def->numa, -1) != - VIR_DOMAIN_NUMATUNE_MEM_STRICT) + VIR_DOMAIN_NUMATUNE_MEM_STRICT) { + ret = 0; goto cleanup; + } if (virDomainNumatuneMaybeFormatNodeset(def->numa, nodemask, &mask, -1) < 0) -- 1.8.3.1

On Fri, Apr 03, 2015 at 06:11:15PM +0800, Luyao Huang wrote:
There are two bugs in this function:
1. cannot start a vm with cpuset but without numatune settings
# virsh -c lxc:/// start helloworld error: Failed to start domain helloworld error: internal error: guest failed to start: Invalid value '1-3' for 'cpuset.mems': Invalid argument
we don't free &mask after use it for virCgroupSetCpusetCpus() and then virDomainNumatuneMaybeFormatNodeset() do not get a new &mask, then we use it in virCgroupSetCpusetMems().
2. when start a lxc with numatune memory mode not strict
I think these two fixes would be better pushed separately.
# virsh -c lxc:/// start helloworld error: Failed to start domain helloworld error: internal error: guest failed to start: Unknown failure in libvirt_lxc startup
We shouldn't set anything in cpuset.mems for these mode.
Signed-off-by: Luyao Huang <lhuang@redhat.com> --- src/lxc/lxc_cgroup.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
ACK, I've split the commit into two and pushed both. Jan

On 04/20/2015 10:04 PM, Ján Tomko wrote:
On Fri, Apr 03, 2015 at 06:11:15PM +0800, Luyao Huang wrote:
There are two bugs in this function:
1. cannot start a vm with cpuset but without numatune settings
# virsh -c lxc:/// start helloworld error: Failed to start domain helloworld error: internal error: guest failed to start: Invalid value '1-3' for 'cpuset.mems': Invalid argument
we don't free &mask after use it for virCgroupSetCpusetCpus() and then virDomainNumatuneMaybeFormatNodeset() do not get a new &mask, then we use it in virCgroupSetCpusetMems().
2. when start a lxc with numatune memory mode not strict I think these two fixes would be better pushed separately.
# virsh -c lxc:/// start helloworld error: Failed to start domain helloworld error: internal error: guest failed to start: Unknown failure in libvirt_lxc startup
We shouldn't set anything in cpuset.mems for these mode.
Signed-off-by: Luyao Huang <lhuang@redhat.com> --- src/lxc/lxc_cgroup.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
ACK, I've split the commit into two and pushed both.
Thanks a lot for your review and split.
Jan
Luyao
participants (3)
-
Ján Tomko
-
lhuang
-
Luyao Huang