|
|
c480ed |
From 0528d90148bcacba3fdbaa831ba89e043da94790 Mon Sep 17 00:00:00 2001
|
|
|
c480ed |
Message-Id: <0528d90148bcacba3fdbaa831ba89e043da94790@dist-git>
|
|
|
c480ed |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
Date: Mon, 1 Jul 2019 17:06:45 +0200
|
|
|
c480ed |
Subject: [PATCH] vircgroup: extract virCgroupV1(Set|Get)BlkioDeviceReadIops
|
|
|
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 dfaf5c6de1afa04fee1d9d97e79925fcc63682de)
|
|
|
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: <52a494fa2de2835abd887d804f4047febc87bb60.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 83ceb3a9cb..b8cbd95e0c 100644
|
|
|
c480ed |
--- a/src/util/vircgroup.c
|
|
|
c480ed |
+++ b/src/util/vircgroup.c
|
|
|
c480ed |
@@ -1385,19 +1385,7 @@ virCgroupSetBlkioDeviceReadIops(virCgroupPtr group,
|
|
|
c480ed |
const char *path,
|
|
|
c480ed |
unsigned int riops)
|
|
|
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%u", blkstr, riops) < 0)
|
|
|
c480ed |
- return -1;
|
|
|
c480ed |
-
|
|
|
c480ed |
- return virCgroupSetValueStr(group,
|
|
|
c480ed |
- VIR_CGROUP_CONTROLLER_BLKIO,
|
|
|
c480ed |
- "blkio.throttle.read_iops_device",
|
|
|
c480ed |
- str);
|
|
|
c480ed |
+ VIR_CGROUP_BACKEND_CALL(group, setBlkioDeviceReadIops, -1, path, riops);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
@@ -1517,25 +1505,7 @@ virCgroupGetBlkioDeviceReadIops(virCgroupPtr group,
|
|
|
c480ed |
const char *path,
|
|
|
c480ed |
unsigned int *riops)
|
|
|
c480ed |
{
|
|
|
c480ed |
- VIR_AUTOFREE(char *) str = NULL;
|
|
|
c480ed |
-
|
|
|
c480ed |
- if (virCgroupGetValueForBlkDev(group,
|
|
|
c480ed |
- VIR_CGROUP_CONTROLLER_BLKIO,
|
|
|
c480ed |
- "blkio.throttle.read_iops_device",
|
|
|
c480ed |
- path,
|
|
|
c480ed |
- &str) < 0)
|
|
|
c480ed |
- return -1;
|
|
|
c480ed |
-
|
|
|
c480ed |
- if (!str) {
|
|
|
c480ed |
- *riops = 0;
|
|
|
c480ed |
- } else if (virStrToLong_ui(str, NULL, 10, riops) < 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, getBlkioDeviceReadIops, -1, path, riops);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
/**
|
|
|
c480ed |
diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h
|
|
|
c480ed |
index aef2a87c61..0b7b4db1a4 100644
|
|
|
c480ed |
--- a/src/util/vircgroupbackend.h
|
|
|
c480ed |
+++ b/src/util/vircgroupbackend.h
|
|
|
c480ed |
@@ -170,6 +170,16 @@ typedef int
|
|
|
c480ed |
const char *path,
|
|
|
c480ed |
unsigned int *weight);
|
|
|
c480ed |
|
|
|
c480ed |
+typedef int
|
|
|
c480ed |
+(*virCgroupSetBlkioDeviceReadIopsCB)(virCgroupPtr group,
|
|
|
c480ed |
+ const char *path,
|
|
|
c480ed |
+ unsigned int riops);
|
|
|
c480ed |
+
|
|
|
c480ed |
+typedef int
|
|
|
c480ed |
+(*virCgroupGetBlkioDeviceReadIopsCB)(virCgroupPtr group,
|
|
|
c480ed |
+ const char *path,
|
|
|
c480ed |
+ unsigned int *riops);
|
|
|
c480ed |
+
|
|
|
c480ed |
struct _virCgroupBackend {
|
|
|
c480ed |
virCgroupBackendType type;
|
|
|
c480ed |
|
|
|
c480ed |
@@ -200,6 +210,8 @@ struct _virCgroupBackend {
|
|
|
c480ed |
virCgroupGetBlkioIoDeviceServicedCB getBlkioIoDeviceServiced;
|
|
|
c480ed |
virCgroupSetBlkioDeviceWeightCB setBlkioDeviceWeight;
|
|
|
c480ed |
virCgroupGetBlkioDeviceWeightCB getBlkioDeviceWeight;
|
|
|
c480ed |
+ virCgroupSetBlkioDeviceReadIopsCB setBlkioDeviceReadIops;
|
|
|
c480ed |
+ virCgroupGetBlkioDeviceReadIopsCB getBlkioDeviceReadIops;
|
|
|
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 1e5f38a2ee..47b0c13f38 100644
|
|
|
c480ed |
--- a/src/util/vircgroupv1.c
|
|
|
c480ed |
+++ b/src/util/vircgroupv1.c
|
|
|
c480ed |
@@ -1186,6 +1186,54 @@ virCgroupV1GetBlkioDeviceWeight(virCgroupPtr group,
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
+static int
|
|
|
c480ed |
+virCgroupV1SetBlkioDeviceReadIops(virCgroupPtr group,
|
|
|
c480ed |
+ const char *path,
|
|
|
c480ed |
+ unsigned int riops)
|
|
|
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%u", blkstr, riops) < 0)
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ return virCgroupSetValueStr(group,
|
|
|
c480ed |
+ VIR_CGROUP_CONTROLLER_BLKIO,
|
|
|
c480ed |
+ "blkio.throttle.read_iops_device",
|
|
|
c480ed |
+ str);
|
|
|
c480ed |
+}
|
|
|
c480ed |
+
|
|
|
c480ed |
+
|
|
|
c480ed |
+static int
|
|
|
c480ed |
+virCgroupV1GetBlkioDeviceReadIops(virCgroupPtr group,
|
|
|
c480ed |
+ const char *path,
|
|
|
c480ed |
+ unsigned int *riops)
|
|
|
c480ed |
+{
|
|
|
c480ed |
+ VIR_AUTOFREE(char *) str = NULL;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (virCgroupGetValueForBlkDev(group,
|
|
|
c480ed |
+ VIR_CGROUP_CONTROLLER_BLKIO,
|
|
|
c480ed |
+ "blkio.throttle.read_iops_device",
|
|
|
c480ed |
+ path,
|
|
|
c480ed |
+ &str) < 0)
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (!str) {
|
|
|
c480ed |
+ *riops = 0;
|
|
|
c480ed |
+ } else if (virStrToLong_ui(str, NULL, 10, riops) < 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 |
@@ -1214,6 +1262,8 @@ virCgroupBackend virCgroupV1Backend = {
|
|
|
c480ed |
.getBlkioIoDeviceServiced = virCgroupV1GetBlkioIoDeviceServiced,
|
|
|
c480ed |
.setBlkioDeviceWeight = virCgroupV1SetBlkioDeviceWeight,
|
|
|
c480ed |
.getBlkioDeviceWeight = virCgroupV1GetBlkioDeviceWeight,
|
|
|
c480ed |
+ .setBlkioDeviceReadIops = virCgroupV1SetBlkioDeviceReadIops,
|
|
|
c480ed |
+ .getBlkioDeviceReadIops = virCgroupV1GetBlkioDeviceReadIops,
|
|
|
c480ed |
};
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
--
|
|
|
c480ed |
2.22.0
|
|
|
c480ed |
|