[libvirt] [PATCH] vircgroupv2: fix setting cpu.max period

Pavel Hrdina posted 1 patch 4 years, 7 months ago
Test syntax-check passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/f2a2c7b03a808d8a31edb269bfa52b312fbb7156.1567676663.git.phrdina@redhat.com
src/util/vircgroupv2.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[libvirt] [PATCH] vircgroupv2: fix setting cpu.max period
Posted by Pavel Hrdina 4 years, 7 months ago
When we set cpu.max period we need to parse the cpu.max file first as
it contains both quota and period values separated by space.  When only
a single number is written to that file it will set quota, in order to
change period we need to write both values.

The code was prepared for that but mistakenly used new line to end the
string with the first value.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1749227

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 src/util/vircgroupv2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
index 2aca4e5d62..0663c67190 100644
--- a/src/util/vircgroupv2.c
+++ b/src/util/vircgroupv2.c
@@ -1508,7 +1508,7 @@ virCgroupV2SetCpuCfsPeriod(virCgroupPtr group,
                        _("Invalid 'cpu.max' data."));
         return -1;
     }
-    *tmp = '\n';
+    *tmp = '\0';
 
     if (virAsprintf(&value, "%s %llu", str, cfs_period) < 0)
         return -1;
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] vircgroupv2: fix setting cpu.max period
Posted by Erik Skultety 4 years, 7 months ago
On Thu, Sep 05, 2019 at 11:44:47AM +0200, Pavel Hrdina wrote:
> When we set cpu.max period we need to parse the cpu.max file first as
> it contains both quota and period values separated by space.  When only
> a single number is written to that file it will set quota, in order to

"... quota. However, in order to..."

> change period we need to write both values.
>
> The code was prepared for that but mistakenly used new line to end the
> string with the first value.
>
> Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1749227
>
> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> ---
>  src/util/vircgroupv2.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
> index 2aca4e5d62..0663c67190 100644
> --- a/src/util/vircgroupv2.c
> +++ b/src/util/vircgroupv2.c
> @@ -1508,7 +1508,7 @@ virCgroupV2SetCpuCfsPeriod(virCgroupPtr group,
>                         _("Invalid 'cpu.max' data."));
>          return -1;
>      }
> -    *tmp = '\n';
> +    *tmp = '\0';
>
>      if (virAsprintf(&value, "%s %llu", str, cfs_period) < 0)
>          return -1;

Reviewed-by: Erik Skultety <eskultet@redhat.com>

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list