Another vircgroup helper to avoid code repetition between the LXC and QEMU driver. Signed-off-by: Daniel Henrique Barboza <danielhb413@xxxxxxxxx> --- src/libvirt_private.syms | 1 + src/lxc/lxc_driver.c | 8 +------- src/qemu/qemu_driver.c | 8 +------- src/util/vircgroup.c | 14 ++++++++++++++ src/util/vircgroup.h | 2 ++ 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 7143e12838..ffd76253b3 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1685,6 +1685,7 @@ virCgroupGetCpuacctStat; virCgroupGetCpuacctUsage; virCgroupGetCpuCfsPeriod; virCgroupGetCpuCfsQuota; +virCgroupGetCpuPeriodQuota; virCgroupGetCpusetCpus; virCgroupGetCpusetMemoryMigrate; virCgroupGetCpusetMems; diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index b5c02b3ccb..2b4b68ba41 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1780,13 +1780,7 @@ static int lxcGetVcpuBWLive(virCgroupPtr cgroup, unsigned long long *period, long long *quota) { - if (virCgroupGetCpuCfsPeriod(cgroup, period) < 0) - return -1; - - if (virCgroupGetCpuCfsQuota(cgroup, quota) < 0) - return -1; - - return 0; + return virCgroupGetCpuPeriodQuota(cgroup, period, quota); } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d2177d73a2..148424d5f0 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -10530,13 +10530,7 @@ static int qemuGetVcpuBWLive(virCgroupPtr cgroup, unsigned long long *period, long long *quota) { - if (virCgroupGetCpuCfsPeriod(cgroup, period) < 0) - return -1; - - if (virCgroupGetCpuCfsQuota(cgroup, quota) < 0) - return -1; - - return 0; + return virCgroupGetCpuPeriodQuota(cgroup, period, quota); } static int diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 530f1b7223..dad475c436 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -3731,6 +3731,20 @@ virCgroupSetupCpuPeriodQuota(virCgroupPtr cgroup, } +int +virCgroupGetCpuPeriodQuota(virCgroupPtr cgroup, unsigned long long *period, + long long *quota) +{ + if (virCgroupGetCpuCfsPeriod(cgroup, period) < 0) + return -1; + + if (virCgroupGetCpuCfsQuota(cgroup, quota) < 0) + return -1; + + return 0; +} + + int virCgroupSetupDomainBlkioParameters(virCgroupPtr cgroup, virDomainDefPtr def, virTypedParameterPtr params, int nparams) diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h index 5d238937d2..10c4b75863 100644 --- a/src/util/vircgroup.h +++ b/src/util/vircgroup.h @@ -290,6 +290,8 @@ bool virCgroupControllerAvailable(int controller); int virCgroupSetupBlkioTune(virCgroupPtr cgroup, virDomainBlkiotune blkio); int virCgroupSetupMemtune(virCgroupPtr cgroup, virDomainMemtune mem); int virCgroupSetupCpusetCpus(virCgroupPtr cgroup, virBitmapPtr cpumask); +int virCgroupGetCpuPeriodQuota(virCgroupPtr cgroup, unsigned long long *period, + long long *quota); int virCgroupSetAndRetrieveCpuShares(virCgroupPtr cgroup, unsigned long long shares, unsigned long long *realValue); -- 2.24.1