|
Pablo Greco |
40546a |
From a9c415edc1bc386ac6f4be91e98fe23469b62011 Mon Sep 17 00:00:00 2001
|
|
Pablo Greco |
40546a |
Message-Id: <a9c415edc1bc386ac6f4be91e98fe23469b62011@dist-git>
|
|
Pablo Greco |
40546a |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
Pablo Greco |
40546a |
Date: Mon, 1 Jul 2019 17:06:48 +0200
|
|
Pablo Greco |
40546a |
Subject: [PATCH] vircgroup: extract virCgroupV1(Set|Get)BlkioDeviceWriteBps
|
|
Pablo Greco |
40546a |
MIME-Version: 1.0
|
|
Pablo Greco |
40546a |
Content-Type: text/plain; charset=UTF-8
|
|
Pablo Greco |
40546a |
Content-Transfer-Encoding: 8bit
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
|
|
Pablo Greco |
40546a |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
Pablo Greco |
40546a |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
Pablo Greco |
40546a |
(cherry picked from commit 02fe32d3aa965b21342bc2dee245e6e8e5ca8bf7)
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
Conflicts:
|
|
Pablo Greco |
40546a |
src/util/vircgroup.c - missing commit 34e9c29357
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
Pablo Greco |
40546a |
Message-Id: <3bbdc28fe71070c8e351679a17d6889b866b46fd.1561993100.git.phrdina@redhat.com>
|
|
Pablo Greco |
40546a |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
Pablo Greco |
40546a |
---
|
|
Pablo Greco |
40546a |
src/util/vircgroup.c | 34 ++-----------------------
|
|
Pablo Greco |
40546a |
src/util/vircgroupbackend.h | 12 +++++++++
|
|
Pablo Greco |
40546a |
src/util/vircgroupv1.c | 50 +++++++++++++++++++++++++++++++++++++
|
|
Pablo Greco |
40546a |
3 files changed, 64 insertions(+), 32 deletions(-)
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
|
|
Pablo Greco |
40546a |
index ab587ea306..684bce4997 100644
|
|
Pablo Greco |
40546a |
--- a/src/util/vircgroup.c
|
|
Pablo Greco |
40546a |
+++ b/src/util/vircgroup.c
|
|
Pablo Greco |
40546a |
@@ -1435,19 +1435,7 @@ virCgroupSetBlkioDeviceWriteBps(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
const char *path,
|
|
Pablo Greco |
40546a |
unsigned long long wbps)
|
|
Pablo Greco |
40546a |
{
|
|
Pablo Greco |
40546a |
- VIR_AUTOFREE(char *) str = NULL;
|
|
Pablo Greco |
40546a |
- VIR_AUTOFREE(char *) blkstr = NULL;
|
|
Pablo Greco |
40546a |
-
|
|
Pablo Greco |
40546a |
- if (!(blkstr = virCgroupGetBlockDevString(path)))
|
|
Pablo Greco |
40546a |
- return -1;
|
|
Pablo Greco |
40546a |
-
|
|
Pablo Greco |
40546a |
- if (virAsprintf(&str, "%s%llu", blkstr, wbps) < 0)
|
|
Pablo Greco |
40546a |
- return -1;
|
|
Pablo Greco |
40546a |
-
|
|
Pablo Greco |
40546a |
- return virCgroupSetValueStr(group,
|
|
Pablo Greco |
40546a |
- VIR_CGROUP_CONTROLLER_BLKIO,
|
|
Pablo Greco |
40546a |
- "blkio.throttle.write_bps_device",
|
|
Pablo Greco |
40546a |
- str);
|
|
Pablo Greco |
40546a |
+ VIR_CGROUP_BACKEND_CALL(group, setBlkioDeviceWriteBps, -1, path, wbps);
|
|
Pablo Greco |
40546a |
}
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
@@ -1529,25 +1517,7 @@ virCgroupGetBlkioDeviceWriteBps(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
const char *path,
|
|
Pablo Greco |
40546a |
unsigned long long *wbps)
|
|
Pablo Greco |
40546a |
{
|
|
Pablo Greco |
40546a |
- VIR_AUTOFREE(char *) str = NULL;
|
|
Pablo Greco |
40546a |
-
|
|
Pablo Greco |
40546a |
- if (virCgroupGetValueForBlkDev(group,
|
|
Pablo Greco |
40546a |
- VIR_CGROUP_CONTROLLER_BLKIO,
|
|
Pablo Greco |
40546a |
- "blkio.throttle.write_bps_device",
|
|
Pablo Greco |
40546a |
- path,
|
|
Pablo Greco |
40546a |
- &str) < 0)
|
|
Pablo Greco |
40546a |
- return -1;
|
|
Pablo Greco |
40546a |
-
|
|
Pablo Greco |
40546a |
- if (!str) {
|
|
Pablo Greco |
40546a |
- *wbps = 0;
|
|
Pablo Greco |
40546a |
- } else if (virStrToLong_ull(str, NULL, 10, wbps) < 0) {
|
|
Pablo Greco |
40546a |
- virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
Pablo Greco |
40546a |
- _("Unable to parse '%s' as an integer"),
|
|
Pablo Greco |
40546a |
- str);
|
|
Pablo Greco |
40546a |
- return -1;
|
|
Pablo Greco |
40546a |
- }
|
|
Pablo Greco |
40546a |
-
|
|
Pablo Greco |
40546a |
- return 0;
|
|
Pablo Greco |
40546a |
+ VIR_CGROUP_BACKEND_CALL(group, getBlkioDeviceWriteBps, -1, path, wbps);
|
|
Pablo Greco |
40546a |
}
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
/**
|
|
Pablo Greco |
40546a |
diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h
|
|
Pablo Greco |
40546a |
index 3f1055a5d8..67e795a2b7 100644
|
|
Pablo Greco |
40546a |
--- a/src/util/vircgroupbackend.h
|
|
Pablo Greco |
40546a |
+++ b/src/util/vircgroupbackend.h
|
|
Pablo Greco |
40546a |
@@ -200,6 +200,16 @@ typedef int
|
|
Pablo Greco |
40546a |
const char *path,
|
|
Pablo Greco |
40546a |
unsigned long long *rbps);
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
+typedef int
|
|
Pablo Greco |
40546a |
+(*virCgroupSetBlkioDeviceWriteBpsCB)(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
+ const char *path,
|
|
Pablo Greco |
40546a |
+ unsigned long long wbps);
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+typedef int
|
|
Pablo Greco |
40546a |
+(*virCgroupGetBlkioDeviceWriteBpsCB)(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
+ const char *path,
|
|
Pablo Greco |
40546a |
+ unsigned long long *wbps);
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
struct _virCgroupBackend {
|
|
Pablo Greco |
40546a |
virCgroupBackendType type;
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
@@ -236,6 +246,8 @@ struct _virCgroupBackend {
|
|
Pablo Greco |
40546a |
virCgroupGetBlkioDeviceWriteIopsCB getBlkioDeviceWriteIops;
|
|
Pablo Greco |
40546a |
virCgroupSetBlkioDeviceReadBpsCB setBlkioDeviceReadBps;
|
|
Pablo Greco |
40546a |
virCgroupGetBlkioDeviceReadBpsCB getBlkioDeviceReadBps;
|
|
Pablo Greco |
40546a |
+ virCgroupSetBlkioDeviceWriteBpsCB setBlkioDeviceWriteBps;
|
|
Pablo Greco |
40546a |
+ virCgroupGetBlkioDeviceWriteBpsCB getBlkioDeviceWriteBps;
|
|
Pablo Greco |
40546a |
};
|
|
Pablo Greco |
40546a |
typedef struct _virCgroupBackend virCgroupBackend;
|
|
Pablo Greco |
40546a |
typedef virCgroupBackend *virCgroupBackendPtr;
|
|
Pablo Greco |
40546a |
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
|
|
Pablo Greco |
40546a |
index e5663ccfb9..c044414dfd 100644
|
|
Pablo Greco |
40546a |
--- a/src/util/vircgroupv1.c
|
|
Pablo Greco |
40546a |
+++ b/src/util/vircgroupv1.c
|
|
Pablo Greco |
40546a |
@@ -1330,6 +1330,54 @@ virCgroupV1GetBlkioDeviceReadBps(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
}
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
+static int
|
|
Pablo Greco |
40546a |
+virCgroupV1SetBlkioDeviceWriteBps(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
+ const char *path,
|
|
Pablo Greco |
40546a |
+ unsigned long long wbps)
|
|
Pablo Greco |
40546a |
+{
|
|
Pablo Greco |
40546a |
+ VIR_AUTOFREE(char *) str = NULL;
|
|
Pablo Greco |
40546a |
+ VIR_AUTOFREE(char *) blkstr = NULL;
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ if (!(blkstr = virCgroupGetBlockDevString(path)))
|
|
Pablo Greco |
40546a |
+ return -1;
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ if (virAsprintf(&str, "%s%llu", blkstr, wbps) < 0)
|
|
Pablo Greco |
40546a |
+ return -1;
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ return virCgroupSetValueStr(group,
|
|
Pablo Greco |
40546a |
+ VIR_CGROUP_CONTROLLER_BLKIO,
|
|
Pablo Greco |
40546a |
+ "blkio.throttle.write_bps_device",
|
|
Pablo Greco |
40546a |
+ str);
|
|
Pablo Greco |
40546a |
+}
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+static int
|
|
Pablo Greco |
40546a |
+virCgroupV1GetBlkioDeviceWriteBps(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
+ const char *path,
|
|
Pablo Greco |
40546a |
+ unsigned long long *wbps)
|
|
Pablo Greco |
40546a |
+{
|
|
Pablo Greco |
40546a |
+ VIR_AUTOFREE(char *) str = NULL;
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ if (virCgroupGetValueForBlkDev(group,
|
|
Pablo Greco |
40546a |
+ VIR_CGROUP_CONTROLLER_BLKIO,
|
|
Pablo Greco |
40546a |
+ "blkio.throttle.write_bps_device",
|
|
Pablo Greco |
40546a |
+ path,
|
|
Pablo Greco |
40546a |
+ &str) < 0)
|
|
Pablo Greco |
40546a |
+ return -1;
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ if (!str) {
|
|
Pablo Greco |
40546a |
+ *wbps = 0;
|
|
Pablo Greco |
40546a |
+ } else if (virStrToLong_ull(str, NULL, 10, wbps) < 0) {
|
|
Pablo Greco |
40546a |
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
Pablo Greco |
40546a |
+ _("Unable to parse '%s' as an integer"),
|
|
Pablo Greco |
40546a |
+ str);
|
|
Pablo Greco |
40546a |
+ return -1;
|
|
Pablo Greco |
40546a |
+ }
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ return 0;
|
|
Pablo Greco |
40546a |
+}
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
virCgroupBackend virCgroupV1Backend = {
|
|
Pablo Greco |
40546a |
.type = VIR_CGROUP_BACKEND_TYPE_V1,
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
@@ -1364,6 +1412,8 @@ virCgroupBackend virCgroupV1Backend = {
|
|
Pablo Greco |
40546a |
.getBlkioDeviceWriteIops = virCgroupV1GetBlkioDeviceWriteIops,
|
|
Pablo Greco |
40546a |
.setBlkioDeviceReadBps = virCgroupV1SetBlkioDeviceReadBps,
|
|
Pablo Greco |
40546a |
.getBlkioDeviceReadBps = virCgroupV1GetBlkioDeviceReadBps,
|
|
Pablo Greco |
40546a |
+ .setBlkioDeviceWriteBps = virCgroupV1SetBlkioDeviceWriteBps,
|
|
Pablo Greco |
40546a |
+ .getBlkioDeviceWriteBps = virCgroupV1GetBlkioDeviceWriteBps,
|
|
Pablo Greco |
40546a |
};
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
--
|
|
Pablo Greco |
40546a |
2.22.0
|
|
Pablo Greco |
40546a |
|