[libvirt PATCH] vircgroup: fix g_variant_new_parsed format string causing abort

Pavel Hrdina posted 1 patch 2 months, 1 week ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/038d6e2792ea209b51042730e2494a19af7e7e03.1719504308.git.phrdina@redhat.com
src/util/vircgroupv1.c | 2 +-
src/util/vircgroupv2.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
[libvirt PATCH] vircgroup: fix g_variant_new_parsed format string causing abort
Posted by Pavel Hrdina 2 months, 1 week ago
The original code was incorrect and never tested because at the time of
implementing it the cgroup file `io.weight` was not available.

Resolves: https://issues.redhat.com/browse/RHEL-45185
Introduced-by: 9c1693eff427661616ce1bd2795688f87288a412
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
 src/util/vircgroupv1.c | 2 +-
 src/util/vircgroupv2.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
index 77c7e209ce..c1f0562249 100644
--- a/src/util/vircgroupv1.c
+++ b/src/util/vircgroupv1.c
@@ -1225,7 +1225,7 @@ virCgroupV1SetBlkioDeviceWeight(virCgroup *group,
     if (group->unitName) {
         GVariant *value = NULL;
 
-        value = g_variant_new_parsed("[(%s, uint64 %u)]", path, weight);
+        value = g_variant_new_parsed("[(%s, %t)]", path, weight);
 
         return virCgroupSetValueDBus(group->unitName, "BlockIODeviceWeight", value);
     } else {
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
index db115e25f7..eaf5ae98f6 100644
--- a/src/util/vircgroupv2.c
+++ b/src/util/vircgroupv2.c
@@ -867,7 +867,7 @@ virCgroupV2SetBlkioDeviceWeight(virCgroup *group,
     if (group->unitName) {
         GVariant *value = NULL;
 
-        value = g_variant_new_parsed("[(%s, uint64 %u)]", path, weight);
+        value = g_variant_new_parsed("[(%s, %t)]", path, weight);
 
         return virCgroupSetValueDBus(group->unitName, "IODeviceWeight", value);
     } else {
-- 
2.45.2
Re: [libvirt PATCH] vircgroup: fix g_variant_new_parsed format string causing abort
Posted by Jiri Denemark 2 months, 1 week ago
On Thu, Jun 27, 2024 at 18:05:18 +0200, Pavel Hrdina wrote:
> The original code was incorrect and never tested because at the time of
> implementing it the cgroup file `io.weight` was not available.
> 
> Resolves: https://issues.redhat.com/browse/RHEL-45185
> Introduced-by: 9c1693eff427661616ce1bd2795688f87288a412
> Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
> ---
>  src/util/vircgroupv1.c | 2 +-
>  src/util/vircgroupv2.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Jiri Denemark <jdenemar@redhat.com>