|
Pablo Greco |
40546a |
From 75e53d9323c069ece39b40a99675425967ac2d62 Mon Sep 17 00:00:00 2001
|
|
Pablo Greco |
40546a |
Message-Id: <75e53d9323c069ece39b40a99675425967ac2d62@dist-git>
|
|
Pablo Greco |
40546a |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
Pablo Greco |
40546a |
Date: Mon, 1 Jul 2019 17:06:49 +0200
|
|
Pablo Greco |
40546a |
Subject: [PATCH] vircgroup: extract virCgroupV1SetMemory
|
|
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 53f43deb0dfa666cb8c614cabbf5add075ccc33f)
|
|
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: <d24181f343e9a9ca60165d1f936cc9ec9c0616ec.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 | 20 +-------------------
|
|
Pablo Greco |
40546a |
src/util/vircgroupbackend.h | 6 ++++++
|
|
Pablo Greco |
40546a |
src/util/vircgroupv1.c | 28 ++++++++++++++++++++++++++++
|
|
Pablo Greco |
40546a |
3 files changed, 35 insertions(+), 19 deletions(-)
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
|
|
Pablo Greco |
40546a |
index 684bce4997..4053c65939 100644
|
|
Pablo Greco |
40546a |
--- a/src/util/vircgroup.c
|
|
Pablo Greco |
40546a |
+++ b/src/util/vircgroup.c
|
|
Pablo Greco |
40546a |
@@ -1593,25 +1593,7 @@ virCgroupGetMemoryUnlimitedKB(void)
|
|
Pablo Greco |
40546a |
int
|
|
Pablo Greco |
40546a |
virCgroupSetMemory(virCgroupPtr group, unsigned long long kb)
|
|
Pablo Greco |
40546a |
{
|
|
Pablo Greco |
40546a |
- unsigned long long maxkb = VIR_DOMAIN_MEMORY_PARAM_UNLIMITED;
|
|
Pablo Greco |
40546a |
-
|
|
Pablo Greco |
40546a |
- if (kb > maxkb) {
|
|
Pablo Greco |
40546a |
- virReportError(VIR_ERR_INVALID_ARG,
|
|
Pablo Greco |
40546a |
- _("Memory '%llu' must be less than %llu"),
|
|
Pablo Greco |
40546a |
- kb, maxkb);
|
|
Pablo Greco |
40546a |
- return -1;
|
|
Pablo Greco |
40546a |
- }
|
|
Pablo Greco |
40546a |
-
|
|
Pablo Greco |
40546a |
- if (kb == maxkb)
|
|
Pablo Greco |
40546a |
- return virCgroupSetValueI64(group,
|
|
Pablo Greco |
40546a |
- VIR_CGROUP_CONTROLLER_MEMORY,
|
|
Pablo Greco |
40546a |
- "memory.limit_in_bytes",
|
|
Pablo Greco |
40546a |
- -1);
|
|
Pablo Greco |
40546a |
- else
|
|
Pablo Greco |
40546a |
- return virCgroupSetValueU64(group,
|
|
Pablo Greco |
40546a |
- VIR_CGROUP_CONTROLLER_MEMORY,
|
|
Pablo Greco |
40546a |
- "memory.limit_in_bytes",
|
|
Pablo Greco |
40546a |
- kb << 10);
|
|
Pablo Greco |
40546a |
+ VIR_CGROUP_BACKEND_CALL(group, setMemory, -1, kb);
|
|
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 67e795a2b7..e1f75c5c31 100644
|
|
Pablo Greco |
40546a |
--- a/src/util/vircgroupbackend.h
|
|
Pablo Greco |
40546a |
+++ b/src/util/vircgroupbackend.h
|
|
Pablo Greco |
40546a |
@@ -210,6 +210,10 @@ typedef int
|
|
Pablo Greco |
40546a |
const char *path,
|
|
Pablo Greco |
40546a |
unsigned long long *wbps);
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
+typedef int
|
|
Pablo Greco |
40546a |
+(*virCgroupSetMemoryCB)(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
+ unsigned long long kb);
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
struct _virCgroupBackend {
|
|
Pablo Greco |
40546a |
virCgroupBackendType type;
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
@@ -248,6 +252,8 @@ struct _virCgroupBackend {
|
|
Pablo Greco |
40546a |
virCgroupGetBlkioDeviceReadBpsCB getBlkioDeviceReadBps;
|
|
Pablo Greco |
40546a |
virCgroupSetBlkioDeviceWriteBpsCB setBlkioDeviceWriteBps;
|
|
Pablo Greco |
40546a |
virCgroupGetBlkioDeviceWriteBpsCB getBlkioDeviceWriteBps;
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ virCgroupSetMemoryCB setMemory;
|
|
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 c044414dfd..17a4d67972 100644
|
|
Pablo Greco |
40546a |
--- a/src/util/vircgroupv1.c
|
|
Pablo Greco |
40546a |
+++ b/src/util/vircgroupv1.c
|
|
Pablo Greco |
40546a |
@@ -1378,6 +1378,32 @@ virCgroupV1GetBlkioDeviceWriteBps(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
}
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
+static int
|
|
Pablo Greco |
40546a |
+virCgroupV1SetMemory(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
+ unsigned long long kb)
|
|
Pablo Greco |
40546a |
+{
|
|
Pablo Greco |
40546a |
+ unsigned long long maxkb = VIR_DOMAIN_MEMORY_PARAM_UNLIMITED;
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ if (kb > maxkb) {
|
|
Pablo Greco |
40546a |
+ virReportError(VIR_ERR_INVALID_ARG,
|
|
Pablo Greco |
40546a |
+ _("Memory '%llu' must be less than %llu"),
|
|
Pablo Greco |
40546a |
+ kb, maxkb);
|
|
Pablo Greco |
40546a |
+ return -1;
|
|
Pablo Greco |
40546a |
+ }
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ if (kb == maxkb)
|
|
Pablo Greco |
40546a |
+ return virCgroupSetValueI64(group,
|
|
Pablo Greco |
40546a |
+ VIR_CGROUP_CONTROLLER_MEMORY,
|
|
Pablo Greco |
40546a |
+ "memory.limit_in_bytes",
|
|
Pablo Greco |
40546a |
+ -1);
|
|
Pablo Greco |
40546a |
+ else
|
|
Pablo Greco |
40546a |
+ return virCgroupSetValueU64(group,
|
|
Pablo Greco |
40546a |
+ VIR_CGROUP_CONTROLLER_MEMORY,
|
|
Pablo Greco |
40546a |
+ "memory.limit_in_bytes",
|
|
Pablo Greco |
40546a |
+ kb << 10);
|
|
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 |
@@ -1414,6 +1440,8 @@ virCgroupBackend virCgroupV1Backend = {
|
|
Pablo Greco |
40546a |
.getBlkioDeviceReadBps = virCgroupV1GetBlkioDeviceReadBps,
|
|
Pablo Greco |
40546a |
.setBlkioDeviceWriteBps = virCgroupV1SetBlkioDeviceWriteBps,
|
|
Pablo Greco |
40546a |
.getBlkioDeviceWriteBps = virCgroupV1GetBlkioDeviceWriteBps,
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ .setMemory = virCgroupV1SetMemory,
|
|
Pablo Greco |
40546a |
};
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
--
|
|
Pablo Greco |
40546a |
2.22.0
|
|
Pablo Greco |
40546a |
|