Another vircgroup helper to avoid code repetition between
the LXC and QEMU driver.
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
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 679e32116c..4c6ad89ecc 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1692,6 +1692,7 @@ virCgroupGetCpuacctStat;
virCgroupGetCpuacctUsage;
virCgroupGetCpuCfsPeriod;
virCgroupGetCpuCfsQuota;
+virCgroupGetCpuPeriodQuota;
virCgroupGetCpusetCpus;
virCgroupGetCpusetMemoryMigrate;
virCgroupGetCpusetMems;
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index fc559d736a..b2e9bc3a46 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -1783,13 +1783,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 b65708385f..dda4bded08 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -10532,13 +10532,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 1f853beb73..70d85200cb 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -3739,3 +3739,17 @@ virCgroupSetupCpuPeriodQuota(virCgroupPtr cgroup,
return -1;
}
+
+
+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;
+}
diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h
index cc53bae258..a5bd35586d 100644
--- a/src/util/vircgroup.h
+++ b/src/util/vircgroup.h
@@ -227,6 +227,8 @@ int virCgroupSetupCpuShares(virCgroupPtr cgroup, unsigned long long shares,
int virCgroupSetCpuCfsPeriod(virCgroupPtr group, unsigned long long cfs_period);
int virCgroupGetCpuCfsPeriod(virCgroupPtr group, unsigned long long *cfs_period);
+int virCgroupGetCpuPeriodQuota(virCgroupPtr cgroup, unsigned long long *period,
+ long long *quota);
int virCgroupSetupCpuPeriodQuota(virCgroupPtr cgroup, unsigned long long period,
long long quota);
--
2.24.1