7548c0
From 7a964b43185f4d818eec0c39197bde17371f4c2b Mon Sep 17 00:00:00 2001
7548c0
Message-Id: <7a964b43185f4d818eec0c39197bde17371f4c2b@dist-git>
7548c0
From: Pavel Hrdina <phrdina@redhat.com>
7548c0
Date: Thu, 21 Jan 2021 10:24:03 -0300
7548c0
Subject: [PATCH] qemu: move cgroup cpu period and quota defines to vircgroup.h
7548c0
7548c0
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
7548c0
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
7548c0
(cherry picked from commit a818e3f6f02ffc9c1c9ea6e8131c307213fa18ec)
7548c0
7548c0
Conflicts:  src/qemu/qemu_driver.c
7548c0
    Context due to lots of changes upstream in the file.
7548c0
7548c0
https://bugzilla.redhat.com/1915733
7548c0
7548c0
Signed-off-by: Daniel Henrique Barboza <dbarboza@redhat.com>
7548c0
Message-Id: <20210121132406.337681-2-dbarboza@redhat.com>
7548c0
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
7548c0
---
7548c0
 src/qemu/qemu_driver.c | 21 ++++++++-------------
7548c0
 src/util/vircgroup.h   |  5 +++++
7548c0
 2 files changed, 13 insertions(+), 13 deletions(-)
7548c0
7548c0
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
7548c0
index 80a4a43e2e..a1103a96dd 100644
7548c0
--- a/src/qemu/qemu_driver.c
7548c0
+++ b/src/qemu/qemu_driver.c
7548c0
@@ -122,11 +122,6 @@ VIR_LOG_INIT("qemu.qemu_driver");
7548c0
 
7548c0
 #define QEMU_NB_NUMA_PARAM 2
7548c0
 
7548c0
-#define QEMU_SCHED_MIN_PERIOD              1000LL
7548c0
-#define QEMU_SCHED_MAX_PERIOD           1000000LL
7548c0
-#define QEMU_SCHED_MIN_QUOTA               1000LL
7548c0
-#define QEMU_SCHED_MAX_QUOTA  18446744073709551LL
7548c0
-
7548c0
 #define QEMU_GUEST_VCPU_MAX_ID 4096
7548c0
 
7548c0
 #define QEMU_NB_BLKIO_PARAM  6
7548c0
@@ -10655,7 +10650,7 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
7548c0
 
7548c0
         } else if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_VCPU_PERIOD)) {
7548c0
             SCHED_RANGE_CHECK(value_ul, VIR_DOMAIN_SCHEDULER_VCPU_PERIOD,
7548c0
-                              QEMU_SCHED_MIN_PERIOD, QEMU_SCHED_MAX_PERIOD);
7548c0
+                              VIR_CGROUP_CPU_PERIOD_MIN, VIR_CGROUP_CPU_PERIOD_MAX);
7548c0
 
7548c0
             if (def && value_ul) {
7548c0
                 if ((rc = qemuSetVcpusBWLive(vm, priv->cgroup, value_ul, 0)))
7548c0
@@ -10675,7 +10670,7 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
7548c0
 
7548c0
         } else if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_VCPU_QUOTA)) {
7548c0
             SCHED_RANGE_CHECK(value_l, VIR_DOMAIN_SCHEDULER_VCPU_QUOTA,
7548c0
-                              QEMU_SCHED_MIN_QUOTA, QEMU_SCHED_MAX_QUOTA);
7548c0
+                              VIR_CGROUP_CPU_QUOTA_MIN, VIR_CGROUP_CPU_QUOTA_MAX);
7548c0
 
7548c0
             if (def && value_l) {
7548c0
                 if ((rc = qemuSetVcpusBWLive(vm, priv->cgroup, 0, value_l)))
7548c0
@@ -10695,7 +10690,7 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
7548c0
 
7548c0
         } else if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_GLOBAL_PERIOD)) {
7548c0
             SCHED_RANGE_CHECK(value_ul, VIR_DOMAIN_SCHEDULER_GLOBAL_PERIOD,
7548c0
-                              QEMU_SCHED_MIN_PERIOD, QEMU_SCHED_MAX_PERIOD);
7548c0
+                              VIR_CGROUP_CPU_PERIOD_MIN, VIR_CGROUP_CPU_PERIOD_MAX);
7548c0
 
7548c0
             if (def && value_ul) {
7548c0
                 if ((rc = qemuSetGlobalBWLive(priv->cgroup, value_ul, 0)))
7548c0
@@ -10715,7 +10710,7 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
7548c0
 
7548c0
         } else if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_GLOBAL_QUOTA)) {
7548c0
             SCHED_RANGE_CHECK(value_l, VIR_DOMAIN_SCHEDULER_GLOBAL_QUOTA,
7548c0
-                              QEMU_SCHED_MIN_QUOTA, QEMU_SCHED_MAX_QUOTA);
7548c0
+                              VIR_CGROUP_CPU_QUOTA_MIN, VIR_CGROUP_CPU_QUOTA_MAX);
7548c0
 
7548c0
             if (def && value_l) {
7548c0
                 if ((rc = qemuSetGlobalBWLive(priv->cgroup, 0, value_l)))
7548c0
@@ -10735,7 +10730,7 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
7548c0
 
7548c0
         } else if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_EMULATOR_PERIOD)) {
7548c0
             SCHED_RANGE_CHECK(value_ul, VIR_DOMAIN_SCHEDULER_EMULATOR_PERIOD,
7548c0
-                              QEMU_SCHED_MIN_PERIOD, QEMU_SCHED_MAX_PERIOD);
7548c0
+                              VIR_CGROUP_CPU_PERIOD_MIN, VIR_CGROUP_CPU_PERIOD_MAX);
7548c0
 
7548c0
             if (def && value_ul) {
7548c0
                 if ((rc = qemuSetEmulatorBandwidthLive(priv->cgroup,
7548c0
@@ -10756,7 +10751,7 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
7548c0
 
7548c0
         } else if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_EMULATOR_QUOTA)) {
7548c0
             SCHED_RANGE_CHECK(value_l, VIR_DOMAIN_SCHEDULER_EMULATOR_QUOTA,
7548c0
-                              QEMU_SCHED_MIN_QUOTA, QEMU_SCHED_MAX_QUOTA);
7548c0
+                              VIR_CGROUP_CPU_QUOTA_MIN, VIR_CGROUP_CPU_QUOTA_MAX);
7548c0
 
7548c0
             if (def && value_l) {
7548c0
                 if ((rc = qemuSetEmulatorBandwidthLive(priv->cgroup,
7548c0
@@ -10777,7 +10772,7 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
7548c0
 
7548c0
         } else if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_IOTHREAD_PERIOD)) {
7548c0
             SCHED_RANGE_CHECK(value_ul, VIR_DOMAIN_SCHEDULER_IOTHREAD_PERIOD,
7548c0
-                              QEMU_SCHED_MIN_PERIOD, QEMU_SCHED_MAX_PERIOD);
7548c0
+                              VIR_CGROUP_CPU_PERIOD_MIN, VIR_CGROUP_CPU_PERIOD_MAX);
7548c0
 
7548c0
             if (def && value_ul) {
7548c0
                 if ((rc = qemuSetIOThreadsBWLive(vm, priv->cgroup, value_ul, 0)))
7548c0
@@ -10797,7 +10792,7 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
7548c0
 
7548c0
         } else if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_IOTHREAD_QUOTA)) {
7548c0
             SCHED_RANGE_CHECK(value_l, VIR_DOMAIN_SCHEDULER_IOTHREAD_QUOTA,
7548c0
-                              QEMU_SCHED_MIN_QUOTA, QEMU_SCHED_MAX_QUOTA);
7548c0
+                              VIR_CGROUP_CPU_QUOTA_MIN, VIR_CGROUP_CPU_QUOTA_MAX);
7548c0
 
7548c0
             if (def && value_l) {
7548c0
                 if ((rc = qemuSetIOThreadsBWLive(vm, priv->cgroup, 0, value_l)))
7548c0
diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h
7548c0
index 3eefe78787..83fa74840f 100644
7548c0
--- a/src/util/vircgroup.h
7548c0
+++ b/src/util/vircgroup.h
7548c0
@@ -243,6 +243,11 @@ virCgroupGetDomainTotalCpuStats(virCgroupPtr group,
7548c0
 int virCgroupSetCpuShares(virCgroupPtr group, unsigned long long shares);
7548c0
 int virCgroupGetCpuShares(virCgroupPtr group, unsigned long long *shares);
7548c0
 
7548c0
+#define VIR_CGROUP_CPU_PERIOD_MIN 1000LL
7548c0
+#define VIR_CGROUP_CPU_PERIOD_MAX 1000000LL
7548c0
+#define VIR_CGROUP_CPU_QUOTA_MIN 1000LL
7548c0
+#define VIR_CGROUP_CPU_QUOTA_MAX 18446744073709551LL
7548c0
+
7548c0
 int virCgroupSetCpuCfsPeriod(virCgroupPtr group, unsigned long long cfs_period);
7548c0
 int virCgroupGetCpuCfsPeriod(virCgroupPtr group, unsigned long long *cfs_period);
7548c0
 
7548c0
-- 
7548c0
2.30.0
7548c0