[libvirt PATCH 2/3] cgroup: use virCgroupSetCpuShares instead of virCgroupSetupCpuShares

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Now that we enforce the cpu.shares range kernel will no longer silently
change the value that libvirt configures so there is no need to read
the value back to get the actual configuration.

Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 src/lxc/lxc_cgroup.c   |  4 +---
 src/lxc/lxc_driver.c   |  6 ++----
 src/qemu/qemu_cgroup.c | 21 +--------------------
 src/qemu/qemu_driver.c |  7 +++----
 4 files changed, 7 insertions(+), 31 deletions(-)

diff --git a/src/lxc/lxc_cgroup.c b/src/lxc/lxc_cgroup.c
index 3c546861f1..af4322d6cf 100644
--- a/src/lxc/lxc_cgroup.c
+++ b/src/lxc/lxc_cgroup.c
@@ -39,10 +39,8 @@ static int virLXCCgroupSetupCpuTune(virDomainDefPtr def,
                                     virCgroupPtr cgroup)
 {
     if (def->cputune.sharesSpecified) {
-        unsigned long long val;
-        if (virCgroupSetupCpuShares(cgroup, def->cputune.shares, &val) < 0)
+        if (virCgroupSetCpuShares(cgroup, def->cputune.shares) < 0)
             return -1;
-        def->cputune.shares = val;
     }
 
     return virCgroupSetupCpuPeriodQuota(cgroup, def->cputune.period,
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 4416acf923..61faceb2de 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -1868,12 +1868,10 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom,
 
         if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_CPU_SHARES)) {
             if (def) {
-                unsigned long long val;
-                if (virCgroupSetupCpuShares(priv->cgroup, params[i].value.ul,
-                                            &val) < 0)
+                if (virCgroupSetCpuShares(priv->cgroup, params[i].value.ul) < 0)
                     goto endjob;
 
-                def->cputune.shares = val;
+                def->cputune.shares = params[i].value.ul;
                 def->cputune.sharesSpecified = true;
             }
 
diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c
index 8c31bb4210..4d94b57e57 100644
--- a/src/qemu/qemu_cgroup.c
+++ b/src/qemu/qemu_cgroup.c
@@ -880,10 +880,6 @@ static int
 qemuSetupCpuCgroup(virDomainObjPtr vm)
 {
     qemuDomainObjPrivatePtr priv = vm->privateData;
-    virObjectEventPtr event = NULL;
-    virTypedParameterPtr eventParams = NULL;
-    int eventNparams = 0;
-    int eventMaxparams = 0;
 
     if (!virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPU)) {
        if (vm->def->cputune.sharesSpecified) {
@@ -896,23 +892,8 @@ qemuSetupCpuCgroup(virDomainObjPtr vm)
     }
 
     if (vm->def->cputune.sharesSpecified) {
-        unsigned long long val;
-        if (virCgroupSetupCpuShares(priv->cgroup, vm->def->cputune.shares,
-                                    &val) < 0)
+        if (virCgroupSetCpuShares(priv->cgroup, vm->def->cputune.shares) < 0)
             return -1;
-
-        if (vm->def->cputune.shares != val) {
-            vm->def->cputune.shares = val;
-            if (virTypedParamsAddULLong(&eventParams, &eventNparams,
-                                        &eventMaxparams,
-                                        VIR_DOMAIN_TUNABLE_CPU_CPU_SHARES,
-                                        val) < 0)
-                return -1;
-
-            event = virDomainEventTunableNewFromObj(vm, eventParams, eventNparams);
-        }
-
-        virObjectEventStateQueue(priv->driver->domainEventState, event);
     }
 
     return 0;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d1a3659774..9a6934f30f 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -9324,17 +9324,16 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
 
         if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_CPU_SHARES)) {
             if (def) {
-                unsigned long long val;
-                if (virCgroupSetupCpuShares(priv->cgroup, value_ul, &val) < 0)
+                if (virCgroupSetCpuShares(priv->cgroup, value_ul) < 0)
                     goto endjob;
 
-                def->cputune.shares = val;
+                def->cputune.shares = value_ul;
                 def->cputune.sharesSpecified = true;
 
                 if (virTypedParamsAddULLong(&eventParams, &eventNparams,
                                             &eventMaxNparams,
                                             VIR_DOMAIN_TUNABLE_CPU_CPU_SHARES,
-                                            val) < 0)
+                                            value_ul) < 0)
                     goto endjob;
             }
 
-- 
2.29.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux