• M
    Fix crash in lxcDomainSetMemoryParameters · 6044bdcd
    Martin Kletzander 提交于
    The function doesn't check whether the request is made for active or
    inactive domain.  Thus when the domain is not running it still tries
    accessing non-existing cgroups (priv->cgroup, which is NULL).
    
    I re-made the function in order for it to work the same way it's qemu
    counterpart does.
    
    Reproducer:
     1) Define an LXC domain
     2) Do 'virsh memtune <domain> --hard-limit 133T'
    
    Backtrace:
     Thread 6 (Thread 0x7fffec8c0700 (LWP 26826)):
     #0  0x00007ffff70edcc4 in virCgroupPathOfController (group=0x0, controller=3,
         key=0x7ffff75734bd "memory.limit_in_bytes", path=0x7fffec8bf718) at util/vircgroup.c:1764
     #1  0x00007ffff70e9206 in virCgroupSetValueStr (group=0x0, controller=3,
         key=0x7ffff75734bd "memory.limit_in_bytes", value=0x7fffe409f360 "1073741824")
         at util/vircgroup.c:669
     #2  0x00007ffff70e98b4 in virCgroupSetValueU64 (group=0x0, controller=3,
         key=0x7ffff75734bd "memory.limit_in_bytes", value=1073741824) at util/vircgroup.c:740
     #3  0x00007ffff70ee518 in virCgroupSetMemory (group=0x0, kb=1048576) at util/vircgroup.c:1904
     #4  0x00007ffff70ee675 in virCgroupSetMemoryHardLimit (group=0x0, kb=1048576)
         at util/vircgroup.c:1944
     #5  0x00005555557d54c8 in lxcDomainSetMemoryParameters (dom=0x7fffe40cc420,
         params=0x7fffe409f100, nparams=1, flags=0) at lxc/lxc_driver.c:774
     #6  0x00007ffff72c20f9 in virDomainSetMemoryParameters (domain=0x7fffe40cc420,
         params=0x7fffe409f100, nparams=1, flags=0) at libvirt.c:4051
     #7  0x000055555561365f in remoteDispatchDomainSetMemoryParameters (server=0x555555eb7e00,
         client=0x555555ec4b10, msg=0x555555eb94e0, rerr=0x7fffec8bfb70, args=0x7fffe40b8510)
         at remote_dispatch.h:7621
     #8  0x00005555556133fd in remoteDispatchDomainSetMemoryParametersHelper (server=0x555555eb7e00,
         client=0x555555ec4b10, msg=0x555555eb94e0, rerr=0x7fffec8bfb70, args=0x7fffe40b8510,
         ret=0x7fffe40b84f0) at remote_dispatch.h:7591
     #9  0x00007ffff73b293f in virNetServerProgramDispatchCall (prog=0x555555ec3ae0,
         server=0x555555eb7e00, client=0x555555ec4b10, msg=0x555555eb94e0)
         at rpc/virnetserverprogram.c:435
     #10 0x00007ffff73b207f in virNetServerProgramDispatch (prog=0x555555ec3ae0,
         server=0x555555eb7e00, client=0x555555ec4b10, msg=0x555555eb94e0)
         at rpc/virnetserverprogram.c:305
     #11 0x00007ffff73a4d2c in virNetServerProcessMsg (srv=0x555555eb7e00, client=0x555555ec4b10,
         prog=0x555555ec3ae0, msg=0x555555eb94e0) at rpc/virnetserver.c:165
     #12 0x00007ffff73a4e8d in virNetServerHandleJob (jobOpaque=0x555555ec3e30, opaque=0x555555eb7e00)
         at rpc/virnetserver.c:186
     #13 0x00007ffff7187f3f in virThreadPoolWorker (opaque=0x555555eb7ac0) at util/virthreadpool.c:144
     #14 0x00007ffff718733a in virThreadHelper (data=0x555555eb7890) at util/virthreadpthread.c:161
     #15 0x00007ffff468ed89 in start_thread (arg=0x7fffec8c0700) at pthread_create.c:308
     #16 0x00007ffff3da26bd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:113
    Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
    (cherry picked from commit 9faf3f29)
    6044bdcd
lxc_driver.c 140.2 KB