libvirt: Fix memtune cgroup bug

This PR depends on #1253 

The original code use 'cat' to get the content of a cgroup file. This
will cause problem if the file name contains slash '\' in it. This
fix change it by using 'open' to read.

BTW, This commit also merged some repeat helper functions.

Signed-off-by: Hao Liu <hliu@redhat.com>