|
Pablo Greco |
40546a |
From af26c5b793fcd0206a105e75c6583ddfe57557c2 Mon Sep 17 00:00:00 2001
|
|
Pablo Greco |
40546a |
Message-Id: <af26c5b793fcd0206a105e75c6583ddfe57557c2@dist-git>
|
|
Pablo Greco |
40546a |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
Pablo Greco |
40546a |
Date: Mon, 1 Jul 2019 17:06:44 +0200
|
|
Pablo Greco |
40546a |
Subject: [PATCH] vircgroup: extract virCgroupV1(Set|Get)BlkioDeviceWeight
|
|
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 8f50f9ca24596c838082c7d8da4ffe7104d22b23)
|
|
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: <1ad5f481f00748a6808760b50f4d1d0116191073.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 | 36 +++-----------------------
|
|
Pablo Greco |
40546a |
src/util/vircgroupbackend.h | 12 +++++++++
|
|
Pablo Greco |
40546a |
src/util/vircgrouppriv.h | 6 +++++
|
|
Pablo Greco |
40546a |
src/util/vircgroupv1.c | 50 +++++++++++++++++++++++++++++++++++++
|
|
Pablo Greco |
40546a |
4 files changed, 71 insertions(+), 33 deletions(-)
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
|
|
Pablo Greco |
40546a |
index fd39144ed2..83ceb3a9cb 100644
|
|
Pablo Greco |
40546a |
--- a/src/util/vircgroup.c
|
|
Pablo Greco |
40546a |
+++ b/src/util/vircgroup.c
|
|
Pablo Greco |
40546a |
@@ -498,7 +498,7 @@ virCgroupGetValueStr(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
}
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
-static int
|
|
Pablo Greco |
40546a |
+int
|
|
Pablo Greco |
40546a |
virCgroupGetValueForBlkDev(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
int controller,
|
|
Pablo Greco |
40546a |
const char *key,
|
|
Pablo Greco |
40546a |
@@ -1501,19 +1501,7 @@ virCgroupSetBlkioDeviceWeight(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
const char *path,
|
|
Pablo Greco |
40546a |
unsigned int weight)
|
|
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%d", blkstr, weight) < 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.weight_device",
|
|
Pablo Greco |
40546a |
- str);
|
|
Pablo Greco |
40546a |
+ VIR_CGROUP_BACKEND_CALL(group, setBlkioDeviceWeight, -1, path, weight);
|
|
Pablo Greco |
40546a |
}
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
/**
|
|
Pablo Greco |
40546a |
@@ -1665,25 +1653,7 @@ virCgroupGetBlkioDeviceWeight(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
const char *path,
|
|
Pablo Greco |
40546a |
unsigned int *weight)
|
|
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.weight_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 |
- *weight = 0;
|
|
Pablo Greco |
40546a |
- } else if (virStrToLong_ui(str, NULL, 10, weight) < 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, getBlkioDeviceWeight, -1, path, weight);
|
|
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 e16d631a0f..aef2a87c61 100644
|
|
Pablo Greco |
40546a |
--- a/src/util/vircgroupbackend.h
|
|
Pablo Greco |
40546a |
+++ b/src/util/vircgroupbackend.h
|
|
Pablo Greco |
40546a |
@@ -160,6 +160,16 @@ typedef int
|
|
Pablo Greco |
40546a |
long long *requests_read,
|
|
Pablo Greco |
40546a |
long long *requests_write);
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
+typedef int
|
|
Pablo Greco |
40546a |
+(*virCgroupSetBlkioDeviceWeightCB)(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
+ const char *path,
|
|
Pablo Greco |
40546a |
+ unsigned int weight);
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+typedef int
|
|
Pablo Greco |
40546a |
+(*virCgroupGetBlkioDeviceWeightCB)(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
+ const char *path,
|
|
Pablo Greco |
40546a |
+ unsigned int *weight);
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
struct _virCgroupBackend {
|
|
Pablo Greco |
40546a |
virCgroupBackendType type;
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
@@ -188,6 +198,8 @@ struct _virCgroupBackend {
|
|
Pablo Greco |
40546a |
virCgroupGetBlkioWeightCB getBlkioWeight;
|
|
Pablo Greco |
40546a |
virCgroupGetBlkioIoServicedCB getBlkioIoServiced;
|
|
Pablo Greco |
40546a |
virCgroupGetBlkioIoDeviceServicedCB getBlkioIoDeviceServiced;
|
|
Pablo Greco |
40546a |
+ virCgroupSetBlkioDeviceWeightCB setBlkioDeviceWeight;
|
|
Pablo Greco |
40546a |
+ virCgroupGetBlkioDeviceWeightCB getBlkioDeviceWeight;
|
|
Pablo Greco |
40546a |
};
|
|
Pablo Greco |
40546a |
typedef struct _virCgroupBackend virCgroupBackend;
|
|
Pablo Greco |
40546a |
typedef virCgroupBackend *virCgroupBackendPtr;
|
|
Pablo Greco |
40546a |
diff --git a/src/util/vircgrouppriv.h b/src/util/vircgrouppriv.h
|
|
Pablo Greco |
40546a |
index 525c288a9a..3a968c1ce2 100644
|
|
Pablo Greco |
40546a |
--- a/src/util/vircgrouppriv.h
|
|
Pablo Greco |
40546a |
+++ b/src/util/vircgrouppriv.h
|
|
Pablo Greco |
40546a |
@@ -82,6 +82,12 @@ int virCgroupPartitionEscape(char **path);
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
char *virCgroupGetBlockDevString(const char *path);
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
+int virCgroupGetValueForBlkDev(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
+ int controller,
|
|
Pablo Greco |
40546a |
+ const char *key,
|
|
Pablo Greco |
40546a |
+ const char *path,
|
|
Pablo Greco |
40546a |
+ char **value);
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
int virCgroupNewPartition(const char *path,
|
|
Pablo Greco |
40546a |
bool create,
|
|
Pablo Greco |
40546a |
int controllers,
|
|
Pablo Greco |
40546a |
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
|
|
Pablo Greco |
40546a |
index 79c4812aef..1e5f38a2ee 100644
|
|
Pablo Greco |
40546a |
--- a/src/util/vircgroupv1.c
|
|
Pablo Greco |
40546a |
+++ b/src/util/vircgroupv1.c
|
|
Pablo Greco |
40546a |
@@ -1138,6 +1138,54 @@ virCgroupV1GetBlkioIoDeviceServiced(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
}
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
+static int
|
|
Pablo Greco |
40546a |
+virCgroupV1SetBlkioDeviceWeight(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
+ const char *path,
|
|
Pablo Greco |
40546a |
+ unsigned int weight)
|
|
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%d", blkstr, weight) < 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.weight_device",
|
|
Pablo Greco |
40546a |
+ str);
|
|
Pablo Greco |
40546a |
+}
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+static int
|
|
Pablo Greco |
40546a |
+virCgroupV1GetBlkioDeviceWeight(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
+ const char *path,
|
|
Pablo Greco |
40546a |
+ unsigned int *weight)
|
|
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.weight_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 |
+ *weight = 0;
|
|
Pablo Greco |
40546a |
+ } else if (virStrToLong_ui(str, NULL, 10, weight) < 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 |
@@ -1164,6 +1212,8 @@ virCgroupBackend virCgroupV1Backend = {
|
|
Pablo Greco |
40546a |
.getBlkioWeight = virCgroupV1GetBlkioWeight,
|
|
Pablo Greco |
40546a |
.getBlkioIoServiced = virCgroupV1GetBlkioIoServiced,
|
|
Pablo Greco |
40546a |
.getBlkioIoDeviceServiced = virCgroupV1GetBlkioIoDeviceServiced,
|
|
Pablo Greco |
40546a |
+ .setBlkioDeviceWeight = virCgroupV1SetBlkioDeviceWeight,
|
|
Pablo Greco |
40546a |
+ .getBlkioDeviceWeight = virCgroupV1GetBlkioDeviceWeight,
|
|
Pablo Greco |
40546a |
};
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
--
|
|
Pablo Greco |
40546a |
2.22.0
|
|
Pablo Greco |
40546a |
|