|
|
c480ed |
From d18c1d955b505493213e540d427868cc74e03c64 Mon Sep 17 00:00:00 2001
|
|
|
c480ed |
Message-Id: <d18c1d955b505493213e540d427868cc74e03c64@dist-git>
|
|
|
c480ed |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
Date: Mon, 1 Jul 2019 17:06:47 +0200
|
|
|
c480ed |
Subject: [PATCH] vircgroup: extract virCgroupV1(Set|Get)BlkioDeviceReadBps
|
|
|
c480ed |
MIME-Version: 1.0
|
|
|
c480ed |
Content-Type: text/plain; charset=UTF-8
|
|
|
c480ed |
Content-Transfer-Encoding: 8bit
|
|
|
c480ed |
|
|
|
c480ed |
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
(cherry picked from commit 32f199250bd52fe52cba6bfbc3ee6a7f6c88c2ff)
|
|
|
c480ed |
|
|
|
c480ed |
Conflicts:
|
|
|
c480ed |
src/util/vircgroup.c - missing commit 34e9c29357
|
|
|
c480ed |
|
|
|
c480ed |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
|
|
|
c480ed |
|
|
|
c480ed |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
Message-Id: <562851da4866890cef588cf7f6f890118f3f81f4.1561993100.git.phrdina@redhat.com>
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
---
|
|
|
c480ed |
src/util/vircgroup.c | 34 ++-----------------------
|
|
|
c480ed |
src/util/vircgroupbackend.h | 12 +++++++++
|
|
|
c480ed |
src/util/vircgroupv1.c | 50 +++++++++++++++++++++++++++++++++++++
|
|
|
c480ed |
3 files changed, 64 insertions(+), 32 deletions(-)
|
|
|
c480ed |
|
|
|
c480ed |
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
|
|
|
c480ed |
index 4b682d72d7..ab587ea306 100644
|
|
|
c480ed |
--- a/src/util/vircgroup.c
|
|
|
c480ed |
+++ b/src/util/vircgroup.c
|
|
|
c480ed |
@@ -1419,19 +1419,7 @@ virCgroupSetBlkioDeviceReadBps(virCgroupPtr group,
|
|
|
c480ed |
const char *path,
|
|
|
c480ed |
unsigned long long rbps)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_AUTOFREE(char *) str = NULL;
|
|
|
c480ed |
- VIR_AUTOFREE(char *) blkstr = NULL;
|
|
|
c480ed |
-
|
|
|
c480ed |
- if (!(blkstr = virCgroupGetBlockDevString(path)))
|
|
|
c480ed |
- return -1;
|
|
|
c480ed |
-
|
|
|
c480ed |
- if (virAsprintf(&str, "%s%llu", blkstr, rbps) < 0)
|
|
|
c480ed |
- return -1;
|
|
|
c480ed |
-
|
|
|
c480ed |
- return virCgroupSetValueStr(group,
|
|
|
c480ed |
- VIR_CGROUP_CONTROLLER_BLKIO,
|
|
|
c480ed |
- "blkio.throttle.read_bps_device",
|
|
|
c480ed |
- str);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, setBlkioDeviceReadBps, -1, path, rbps);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
/**
|
|
|
c480ed |
@@ -1525,25 +1513,7 @@ virCgroupGetBlkioDeviceReadBps(virCgroupPtr group,
|
|
|
c480ed |
const char *path,
|
|
|
c480ed |
unsigned long long *rbps)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_AUTOFREE(char *) str = NULL;
|
|
|
c480ed |
-
|
|
|
c480ed |
- if (virCgroupGetValueForBlkDev(group,
|
|
|
c480ed |
- VIR_CGROUP_CONTROLLER_BLKIO,
|
|
|
c480ed |
- "blkio.throttle.read_bps_device",
|
|
|
c480ed |
- path,
|
|
|
c480ed |
- &str) < 0)
|
|
|
c480ed |
- return -1;
|
|
|
c480ed |
-
|
|
|
c480ed |
- if (!str) {
|
|
|
c480ed |
- *rbps = 0;
|
|
|
c480ed |
- } else if (virStrToLong_ull(str, NULL, 10, rbps) < 0) {
|
|
|
c480ed |
- virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
c480ed |
- _("Unable to parse '%s' as an integer"),
|
|
|
c480ed |
- str);
|
|
|
c480ed |
- return -1;
|
|
|
c480ed |
- }
|
|
|
c480ed |
-
|
|
|
c480ed |
- return 0;
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, getBlkioDeviceReadBps, -1, path, rbps);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
/**
|
|
|
c480ed |
diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h
|
|
|
c480ed |
index 58e1828e01..3f1055a5d8 100644
|
|
|
c480ed |
--- a/src/util/vircgroupbackend.h
|
|
|
c480ed |
+++ b/src/util/vircgroupbackend.h
|
|
|
c480ed |
@@ -190,6 +190,16 @@ typedef int
|
|
|
c480ed |
const char *path,
|
|
|
c480ed |
unsigned int *wiops);
|
|
|
c480ed |
|
|
|
c480ed |
+typedef int
|
|
|
c480ed |
+(*virCgroupSetBlkioDeviceReadBpsCB)(virCgroupPtr group,
|
|
|
c480ed |
+ const char *path,
|
|
|
c480ed |
+ unsigned long long rbps);
|
|
|
c480ed |
+
|
|
|
c480ed |
+typedef int
|
|
|
c480ed |
+(*virCgroupGetBlkioDeviceReadBpsCB)(virCgroupPtr group,
|
|
|
c480ed |
+ const char *path,
|
|
|
c480ed |
+ unsigned long long *rbps);
|
|
|
c480ed |
+
|
|
|
c480ed |
struct _virCgroupBackend {
|
|
|
c480ed |
virCgroupBackendType type;
|
|
|
c480ed |
|
|
|
c480ed |
@@ -224,6 +234,8 @@ struct _virCgroupBackend {
|
|
|
c480ed |
virCgroupGetBlkioDeviceReadIopsCB getBlkioDeviceReadIops;
|
|
|
c480ed |
virCgroupSetBlkioDeviceWriteIopsCB setBlkioDeviceWriteIops;
|
|
|
c480ed |
virCgroupGetBlkioDeviceWriteIopsCB getBlkioDeviceWriteIops;
|
|
|
c480ed |
+ virCgroupSetBlkioDeviceReadBpsCB setBlkioDeviceReadBps;
|
|
|
c480ed |
+ virCgroupGetBlkioDeviceReadBpsCB getBlkioDeviceReadBps;
|
|
|
c480ed |
};
|
|
|
c480ed |
typedef struct _virCgroupBackend virCgroupBackend;
|
|
|
c480ed |
typedef virCgroupBackend *virCgroupBackendPtr;
|
|
|
c480ed |
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
|
|
|
c480ed |
index 5b0199a89f..e5663ccfb9 100644
|
|
|
c480ed |
--- a/src/util/vircgroupv1.c
|
|
|
c480ed |
+++ b/src/util/vircgroupv1.c
|
|
|
c480ed |
@@ -1282,6 +1282,54 @@ virCgroupV1GetBlkioDeviceWriteIops(virCgroupPtr group,
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
+static int
|
|
|
c480ed |
+virCgroupV1SetBlkioDeviceReadBps(virCgroupPtr group,
|
|
|
c480ed |
+ const char *path,
|
|
|
c480ed |
+ unsigned long long rbps)
|
|
|
c480ed |
+{
|
|
|
c480ed |
+ VIR_AUTOFREE(char *) str = NULL;
|
|
|
c480ed |
+ VIR_AUTOFREE(char *) blkstr = NULL;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (!(blkstr = virCgroupGetBlockDevString(path)))
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (virAsprintf(&str, "%s%llu", blkstr, rbps) < 0)
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ return virCgroupSetValueStr(group,
|
|
|
c480ed |
+ VIR_CGROUP_CONTROLLER_BLKIO,
|
|
|
c480ed |
+ "blkio.throttle.read_bps_device",
|
|
|
c480ed |
+ str);
|
|
|
c480ed |
+}
|
|
|
c480ed |
+
|
|
|
c480ed |
+
|
|
|
c480ed |
+static int
|
|
|
c480ed |
+virCgroupV1GetBlkioDeviceReadBps(virCgroupPtr group,
|
|
|
c480ed |
+ const char *path,
|
|
|
c480ed |
+ unsigned long long *rbps)
|
|
|
c480ed |
+{
|
|
|
c480ed |
+ VIR_AUTOFREE(char *) str = NULL;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (virCgroupGetValueForBlkDev(group,
|
|
|
c480ed |
+ VIR_CGROUP_CONTROLLER_BLKIO,
|
|
|
c480ed |
+ "blkio.throttle.read_bps_device",
|
|
|
c480ed |
+ path,
|
|
|
c480ed |
+ &str) < 0)
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (!str) {
|
|
|
c480ed |
+ *rbps = 0;
|
|
|
c480ed |
+ } else if (virStrToLong_ull(str, NULL, 10, rbps) < 0) {
|
|
|
c480ed |
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
c480ed |
+ _("Unable to parse '%s' as an integer"),
|
|
|
c480ed |
+ str);
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+
|
|
|
c480ed |
+ return 0;
|
|
|
c480ed |
+}
|
|
|
c480ed |
+
|
|
|
c480ed |
+
|
|
|
c480ed |
virCgroupBackend virCgroupV1Backend = {
|
|
|
c480ed |
.type = VIR_CGROUP_BACKEND_TYPE_V1,
|
|
|
c480ed |
|
|
|
c480ed |
@@ -1314,6 +1362,8 @@ virCgroupBackend virCgroupV1Backend = {
|
|
|
c480ed |
.getBlkioDeviceReadIops = virCgroupV1GetBlkioDeviceReadIops,
|
|
|
c480ed |
.setBlkioDeviceWriteIops = virCgroupV1SetBlkioDeviceWriteIops,
|
|
|
c480ed |
.getBlkioDeviceWriteIops = virCgroupV1GetBlkioDeviceWriteIops,
|
|
|
c480ed |
+ .setBlkioDeviceReadBps = virCgroupV1SetBlkioDeviceReadBps,
|
|
|
c480ed |
+ .getBlkioDeviceReadBps = virCgroupV1GetBlkioDeviceReadBps,
|
|
|
c480ed |
};
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
--
|
|
|
c480ed |
2.22.0
|
|
|
c480ed |
|