From nobody Mon Feb 9 00:55:45 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 153728563156319.200863905177584; Tue, 18 Sep 2018 08:47:11 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9ADA2C05D410; Tue, 18 Sep 2018 15:47:09 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5032C2015C23; Tue, 18 Sep 2018 15:47:09 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id CB9FD4A47A; Tue, 18 Sep 2018 15:47:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8IFkcvp012465 for ; Tue, 18 Sep 2018 11:46:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id 973544F9A1; Tue, 18 Sep 2018 15:46:38 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.181]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B23D5D9C7 for ; Tue, 18 Sep 2018 15:46:37 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Tue, 18 Sep 2018 17:45:48 +0200 Message-Id: <2175fd84239740107a9ff34a517c757d052e0bad.1537285203.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 27/47] vircgroup: extract virCgroupV1(Set|Get)BlkioDeviceReadBps X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Tue, 18 Sep 2018 15:47:10 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina Reviewed-by: Fabiano Fid=C3=AAncio --- src/util/vircgroup.c | 34 ++----------------------- src/util/vircgroupbackend.h | 12 +++++++++ src/util/vircgroupv1.c | 50 +++++++++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 32 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 3fa8aebe04..08b8387fba 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -1421,19 +1421,7 @@ virCgroupSetBlkioDeviceReadBps(virCgroupPtr group, const char *path, unsigned long long rbps) { - VIR_AUTOFREE(char *) str =3D NULL; - VIR_AUTOFREE(char *) blkstr =3D NULL; - - if (!(blkstr =3D virCgroupGetBlockDevString(path))) - return -1; - - if (virAsprintf(&str, "%s%llu", blkstr, rbps) < 0) - return -1; - - return virCgroupSetValueStr(group, - VIR_CGROUP_CONTROLLER_BLKIO, - "blkio.throttle.read_bps_device", - str); + VIR_CGROUP_BACKEND_CALL(group, setBlkioDeviceReadBps, -1, path, rbps); } =20 /** @@ -1527,25 +1515,7 @@ virCgroupGetBlkioDeviceReadBps(virCgroupPtr group, const char *path, unsigned long long *rbps) { - VIR_AUTOFREE(char *) str =3D NULL; - - if (virCgroupGetValueForBlkDev(group, - VIR_CGROUP_CONTROLLER_BLKIO, - "blkio.throttle.read_bps_device", - path, - &str) < 0) - return -1; - - if (!str) { - *rbps =3D 0; - } else if (virStrToLong_ull(str, NULL, 10, rbps) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to parse '%s' as an integer"), - str); - return -1; - } - - return 0; + VIR_CGROUP_BACKEND_CALL(group, getBlkioDeviceReadBps, -1, path, rbps); } =20 /** diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h index e19a3820bf..3ec9a95327 100644 --- a/src/util/vircgroupbackend.h +++ b/src/util/vircgroupbackend.h @@ -182,6 +182,16 @@ typedef int const char *path, unsigned int *wiops); =20 +typedef int +(*virCgroupSetBlkioDeviceReadBpsCB)(virCgroupPtr group, + const char *path, + unsigned long long rbps); + +typedef int +(*virCgroupGetBlkioDeviceReadBpsCB)(virCgroupPtr group, + const char *path, + unsigned long long *rbps); + struct _virCgroupBackend { virCgroupBackendType type; =20 @@ -216,6 +226,8 @@ struct _virCgroupBackend { virCgroupGetBlkioDeviceReadIopsCB getBlkioDeviceReadIops; virCgroupSetBlkioDeviceWriteIopsCB setBlkioDeviceWriteIops; virCgroupGetBlkioDeviceWriteIopsCB getBlkioDeviceWriteIops; + virCgroupSetBlkioDeviceReadBpsCB setBlkioDeviceReadBps; + virCgroupGetBlkioDeviceReadBpsCB getBlkioDeviceReadBps; }; typedef struct _virCgroupBackend virCgroupBackend; typedef virCgroupBackend *virCgroupBackendPtr; diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c index feeefc287d..2c19e6147a 100644 --- a/src/util/vircgroupv1.c +++ b/src/util/vircgroupv1.c @@ -1281,6 +1281,54 @@ virCgroupV1GetBlkioDeviceWriteIops(virCgroupPtr grou= p, } =20 =20 +static int +virCgroupV1SetBlkioDeviceReadBps(virCgroupPtr group, + const char *path, + unsigned long long rbps) +{ + VIR_AUTOFREE(char *) str =3D NULL; + VIR_AUTOFREE(char *) blkstr =3D NULL; + + if (!(blkstr =3D virCgroupGetBlockDevString(path))) + return -1; + + if (virAsprintf(&str, "%s%llu", blkstr, rbps) < 0) + return -1; + + return virCgroupSetValueStr(group, + VIR_CGROUP_CONTROLLER_BLKIO, + "blkio.throttle.read_bps_device", + str); +} + + +static int +virCgroupV1GetBlkioDeviceReadBps(virCgroupPtr group, + const char *path, + unsigned long long *rbps) +{ + VIR_AUTOFREE(char *) str =3D NULL; + + if (virCgroupGetValueForBlkDev(group, + VIR_CGROUP_CONTROLLER_BLKIO, + "blkio.throttle.read_bps_device", + path, + &str) < 0) + return -1; + + if (!str) { + *rbps =3D 0; + } else if (virStrToLong_ull(str, NULL, 10, rbps) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to parse '%s' as an integer"), + str); + return -1; + } + + return 0; +} + + virCgroupBackend virCgroupV1Backend =3D { .type =3D VIR_CGROUP_BACKEND_TYPE_V1, =20 @@ -1313,6 +1361,8 @@ virCgroupBackend virCgroupV1Backend =3D { .getBlkioDeviceReadIops =3D virCgroupV1GetBlkioDeviceReadIops, .setBlkioDeviceWriteIops =3D virCgroupV1SetBlkioDeviceWriteIops, .getBlkioDeviceWriteIops =3D virCgroupV1GetBlkioDeviceWriteIops, + .setBlkioDeviceReadBps =3D virCgroupV1SetBlkioDeviceReadBps, + .getBlkioDeviceReadBps =3D virCgroupV1GetBlkioDeviceReadBps, }; =20 =20 --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list