]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
cgroup: use virCgroupSetCpuShares instead of virCgroupSetupCpuShares
authorPavel Hrdina <phrdina@redhat.com>
Wed, 3 Mar 2021 13:26:53 +0000 (14:26 +0100)
committerPavel Hrdina <phrdina@redhat.com>
Thu, 4 Mar 2021 10:13:28 +0000 (11:13 +0100)
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@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/lxc/lxc_cgroup.c
src/lxc/lxc_driver.c
src/qemu/qemu_cgroup.c
src/qemu/qemu_driver.c

index 3c546861f100ed70789999d7ea87cf84a1c9a527..af4322d6cf3b6f37e9fb70035b82ae55fdb0e6de 100644 (file)
@@ -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,
index 4416acf923d3c1b8de4ead40b432d233fd3634ef..61faceb2de423634ff9c04e30ea14f273cd39134 100644 (file)
@@ -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;
             }
 
index 8c31bb4210bde8db720a1fdcd3c0ec46ca4a543f..4d94b57e575cc5f1a8933d0b30d79aeeae020c16 100644 (file)
@@ -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;
index d1a36597745ff0b6ee47b086b872d16edb0caa47..9a6934f30fd0dd356c24112dfcb432098b507333 100644 (file)
@@ -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;
             }