182 lines
6.1 KiB
Diff
182 lines
6.1 KiB
Diff
From 0528d90148bcacba3fdbaa831ba89e043da94790 Mon Sep 17 00:00:00 2001
|
|
Message-Id: <0528d90148bcacba3fdbaa831ba89e043da94790@dist-git>
|
|
From: Pavel Hrdina <phrdina@redhat.com>
|
|
Date: Mon, 1 Jul 2019 17:06:45 +0200
|
|
Subject: [PATCH] vircgroup: extract virCgroupV1(Set|Get)BlkioDeviceReadIops
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
|
|
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
(cherry picked from commit dfaf5c6de1afa04fee1d9d97e79925fcc63682de)
|
|
|
|
Conflicts:
|
|
src/util/vircgroup.c - missing commit 34e9c29357
|
|
|
|
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
|
|
|
|
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
Message-Id: <52a494fa2de2835abd887d804f4047febc87bb60.1561993100.git.phrdina@redhat.com>
|
|
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
---
|
|
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 83ceb3a9cb..b8cbd95e0c 100644
|
|
--- a/src/util/vircgroup.c
|
|
+++ b/src/util/vircgroup.c
|
|
@@ -1385,19 +1385,7 @@ virCgroupSetBlkioDeviceReadIops(virCgroupPtr group,
|
|
const char *path,
|
|
unsigned int riops)
|
|
{
|
|
- VIR_AUTOFREE(char *) str = NULL;
|
|
- VIR_AUTOFREE(char *) blkstr = NULL;
|
|
-
|
|
- if (!(blkstr = virCgroupGetBlockDevString(path)))
|
|
- return -1;
|
|
-
|
|
- if (virAsprintf(&str, "%s%u", blkstr, riops) < 0)
|
|
- return -1;
|
|
-
|
|
- return virCgroupSetValueStr(group,
|
|
- VIR_CGROUP_CONTROLLER_BLKIO,
|
|
- "blkio.throttle.read_iops_device",
|
|
- str);
|
|
+ VIR_CGROUP_BACKEND_CALL(group, setBlkioDeviceReadIops, -1, path, riops);
|
|
}
|
|
|
|
|
|
@@ -1517,25 +1505,7 @@ virCgroupGetBlkioDeviceReadIops(virCgroupPtr group,
|
|
const char *path,
|
|
unsigned int *riops)
|
|
{
|
|
- VIR_AUTOFREE(char *) str = NULL;
|
|
-
|
|
- if (virCgroupGetValueForBlkDev(group,
|
|
- VIR_CGROUP_CONTROLLER_BLKIO,
|
|
- "blkio.throttle.read_iops_device",
|
|
- path,
|
|
- &str) < 0)
|
|
- return -1;
|
|
-
|
|
- if (!str) {
|
|
- *riops = 0;
|
|
- } else if (virStrToLong_ui(str, NULL, 10, riops) < 0) {
|
|
- virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
- _("Unable to parse '%s' as an integer"),
|
|
- str);
|
|
- return -1;
|
|
- }
|
|
-
|
|
- return 0;
|
|
+ VIR_CGROUP_BACKEND_CALL(group, getBlkioDeviceReadIops, -1, path, riops);
|
|
}
|
|
|
|
/**
|
|
diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h
|
|
index aef2a87c61..0b7b4db1a4 100644
|
|
--- a/src/util/vircgroupbackend.h
|
|
+++ b/src/util/vircgroupbackend.h
|
|
@@ -170,6 +170,16 @@ typedef int
|
|
const char *path,
|
|
unsigned int *weight);
|
|
|
|
+typedef int
|
|
+(*virCgroupSetBlkioDeviceReadIopsCB)(virCgroupPtr group,
|
|
+ const char *path,
|
|
+ unsigned int riops);
|
|
+
|
|
+typedef int
|
|
+(*virCgroupGetBlkioDeviceReadIopsCB)(virCgroupPtr group,
|
|
+ const char *path,
|
|
+ unsigned int *riops);
|
|
+
|
|
struct _virCgroupBackend {
|
|
virCgroupBackendType type;
|
|
|
|
@@ -200,6 +210,8 @@ struct _virCgroupBackend {
|
|
virCgroupGetBlkioIoDeviceServicedCB getBlkioIoDeviceServiced;
|
|
virCgroupSetBlkioDeviceWeightCB setBlkioDeviceWeight;
|
|
virCgroupGetBlkioDeviceWeightCB getBlkioDeviceWeight;
|
|
+ virCgroupSetBlkioDeviceReadIopsCB setBlkioDeviceReadIops;
|
|
+ virCgroupGetBlkioDeviceReadIopsCB getBlkioDeviceReadIops;
|
|
};
|
|
typedef struct _virCgroupBackend virCgroupBackend;
|
|
typedef virCgroupBackend *virCgroupBackendPtr;
|
|
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
|
|
index 1e5f38a2ee..47b0c13f38 100644
|
|
--- a/src/util/vircgroupv1.c
|
|
+++ b/src/util/vircgroupv1.c
|
|
@@ -1186,6 +1186,54 @@ virCgroupV1GetBlkioDeviceWeight(virCgroupPtr group,
|
|
}
|
|
|
|
|
|
+static int
|
|
+virCgroupV1SetBlkioDeviceReadIops(virCgroupPtr group,
|
|
+ const char *path,
|
|
+ unsigned int riops)
|
|
+{
|
|
+ VIR_AUTOFREE(char *) str = NULL;
|
|
+ VIR_AUTOFREE(char *) blkstr = NULL;
|
|
+
|
|
+ if (!(blkstr = virCgroupGetBlockDevString(path)))
|
|
+ return -1;
|
|
+
|
|
+ if (virAsprintf(&str, "%s%u", blkstr, riops) < 0)
|
|
+ return -1;
|
|
+
|
|
+ return virCgroupSetValueStr(group,
|
|
+ VIR_CGROUP_CONTROLLER_BLKIO,
|
|
+ "blkio.throttle.read_iops_device",
|
|
+ str);
|
|
+}
|
|
+
|
|
+
|
|
+static int
|
|
+virCgroupV1GetBlkioDeviceReadIops(virCgroupPtr group,
|
|
+ const char *path,
|
|
+ unsigned int *riops)
|
|
+{
|
|
+ VIR_AUTOFREE(char *) str = NULL;
|
|
+
|
|
+ if (virCgroupGetValueForBlkDev(group,
|
|
+ VIR_CGROUP_CONTROLLER_BLKIO,
|
|
+ "blkio.throttle.read_iops_device",
|
|
+ path,
|
|
+ &str) < 0)
|
|
+ return -1;
|
|
+
|
|
+ if (!str) {
|
|
+ *riops = 0;
|
|
+ } else if (virStrToLong_ui(str, NULL, 10, riops) < 0) {
|
|
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
+ _("Unable to parse '%s' as an integer"),
|
|
+ str);
|
|
+ return -1;
|
|
+ }
|
|
+
|
|
+ return 0;
|
|
+}
|
|
+
|
|
+
|
|
virCgroupBackend virCgroupV1Backend = {
|
|
.type = VIR_CGROUP_BACKEND_TYPE_V1,
|
|
|
|
@@ -1214,6 +1262,8 @@ virCgroupBackend virCgroupV1Backend = {
|
|
.getBlkioIoDeviceServiced = virCgroupV1GetBlkioIoDeviceServiced,
|
|
.setBlkioDeviceWeight = virCgroupV1SetBlkioDeviceWeight,
|
|
.getBlkioDeviceWeight = virCgroupV1GetBlkioDeviceWeight,
|
|
+ .setBlkioDeviceReadIops = virCgroupV1SetBlkioDeviceReadIops,
|
|
+ .getBlkioDeviceReadIops = virCgroupV1GetBlkioDeviceReadIops,
|
|
};
|
|
|
|
|
|
--
|
|
2.22.0
|
|
|