From nobody Sun Feb 8 21:42:12 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 1537285645141498.17102491570745; Tue, 18 Sep 2018 08:47:25 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ABDD98831E; Tue, 18 Sep 2018 15:47:22 +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 69D5B7DE4D; Tue, 18 Sep 2018 15:47:22 +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 E0C0D4A496; Tue, 18 Sep 2018 15:47:21 +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 w8IFkb7k012452 for ; Tue, 18 Sep 2018 11:46:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id C0F744F9A1; Tue, 18 Sep 2018 15:46:37 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.181]) by smtp.corp.redhat.com (Postfix) with ESMTP id 44A6C5D9C7 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:47 +0200 Message-Id: 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 26/47] vircgroup: extract virCgroupV1(Set|Get)BlkioDeviceWriteIops 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.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 18 Sep 2018 15:47:23 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Pavel Hrdina --- 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 5fbad25d5c..3fa8aebe04 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -1404,19 +1404,7 @@ virCgroupSetBlkioDeviceWriteIops(virCgroupPtr group, const char *path, unsigned int wiops) { - VIR_AUTOFREE(char *) str =3D NULL; - VIR_AUTOFREE(char *) blkstr =3D NULL; - - if (!(blkstr =3D virCgroupGetBlockDevString(path))) - return -1; - - if (virAsprintf(&str, "%s%u", blkstr, wiops) < 0) - return -1; - - return virCgroupSetValueStr(group, - VIR_CGROUP_CONTROLLER_BLKIO, - "blkio.throttle.write_iops_device", - str); + VIR_CGROUP_BACKEND_CALL(group, setBlkioDeviceWriteIops, -1, path, wiop= s); } =20 =20 @@ -1523,25 +1511,7 @@ virCgroupGetBlkioDeviceWriteIops(virCgroupPtr group, const char *path, unsigned int *wiops) { - VIR_AUTOFREE(char *) str =3D NULL; - - if (virCgroupGetValueForBlkDev(group, - VIR_CGROUP_CONTROLLER_BLKIO, - "blkio.throttle.write_iops_device", - path, - &str) < 0) - return -1; - - if (!str) { - *wiops =3D 0; - } else if (virStrToLong_ui(str, NULL, 10, wiops) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to parse '%s' as an integer"), - str); - return -1; - } - - return 0; + VIR_CGROUP_BACKEND_CALL(group, getBlkioDeviceWriteIops, -1, path, wiop= s); } =20 /** diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h index 813ed61b6a..e19a3820bf 100644 --- a/src/util/vircgroupbackend.h +++ b/src/util/vircgroupbackend.h @@ -172,6 +172,16 @@ typedef int const char *path, unsigned int *riops); =20 +typedef int +(*virCgroupSetBlkioDeviceWriteIopsCB)(virCgroupPtr group, + const char *path, + unsigned int wiops); + +typedef int +(*virCgroupGetBlkioDeviceWriteIopsCB)(virCgroupPtr group, + const char *path, + unsigned int *wiops); + struct _virCgroupBackend { virCgroupBackendType type; =20 @@ -204,6 +214,8 @@ struct _virCgroupBackend { virCgroupGetBlkioDeviceWeightCB getBlkioDeviceWeight; virCgroupSetBlkioDeviceReadIopsCB setBlkioDeviceReadIops; virCgroupGetBlkioDeviceReadIopsCB getBlkioDeviceReadIops; + virCgroupSetBlkioDeviceWriteIopsCB setBlkioDeviceWriteIops; + virCgroupGetBlkioDeviceWriteIopsCB getBlkioDeviceWriteIops; }; typedef struct _virCgroupBackend virCgroupBackend; typedef virCgroupBackend *virCgroupBackendPtr; diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c index d418ef41df..feeefc287d 100644 --- a/src/util/vircgroupv1.c +++ b/src/util/vircgroupv1.c @@ -1233,6 +1233,54 @@ virCgroupV1GetBlkioDeviceReadIops(virCgroupPtr group, } =20 =20 +static int +virCgroupV1SetBlkioDeviceWriteIops(virCgroupPtr group, + const char *path, + unsigned int wiops) +{ + VIR_AUTOFREE(char *) str =3D NULL; + VIR_AUTOFREE(char *) blkstr =3D NULL; + + if (!(blkstr =3D virCgroupGetBlockDevString(path))) + return -1; + + if (virAsprintf(&str, "%s%u", blkstr, wiops) < 0) + return -1; + + return virCgroupSetValueStr(group, + VIR_CGROUP_CONTROLLER_BLKIO, + "blkio.throttle.write_iops_device", + str); +} + + +static int +virCgroupV1GetBlkioDeviceWriteIops(virCgroupPtr group, + const char *path, + unsigned int *wiops) +{ + VIR_AUTOFREE(char *) str =3D NULL; + + if (virCgroupGetValueForBlkDev(group, + VIR_CGROUP_CONTROLLER_BLKIO, + "blkio.throttle.write_iops_device", + path, + &str) < 0) + return -1; + + if (!str) { + *wiops =3D 0; + } else if (virStrToLong_ui(str, NULL, 10, wiops) < 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 @@ -1263,6 +1311,8 @@ virCgroupBackend virCgroupV1Backend =3D { .getBlkioDeviceWeight =3D virCgroupV1GetBlkioDeviceWeight, .setBlkioDeviceReadIops =3D virCgroupV1SetBlkioDeviceReadIops, .getBlkioDeviceReadIops =3D virCgroupV1GetBlkioDeviceReadIops, + .setBlkioDeviceWriteIops =3D virCgroupV1SetBlkioDeviceWriteIops, + .getBlkioDeviceWriteIops =3D virCgroupV1GetBlkioDeviceWriteIops, }; =20 =20 --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list