summaryrefslogtreecommitdiff
path: root/0031-cgroup-v2-does-not-support-isulad-setting-cpu_rt-opt.patch
blob: ecca55acdf2a9beb0874fa354a2127cb1172ea54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
From 8e11a1eea62cb8061f1613379ff83bd9a721fa50 Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Wed, 31 Jan 2024 18:10:46 +0800
Subject: [PATCH 31/43] cgroup v2 does not support isulad setting cpu_rt
 options

Signed-off-by: zhongtao <zhongtao17@huawei.com>
---
 src/cmd/isulad/isulad_commands.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/src/cmd/isulad/isulad_commands.c b/src/cmd/isulad/isulad_commands.c
index 5fb55689..619e36d1 100644
--- a/src/cmd/isulad/isulad_commands.c
+++ b/src/cmd/isulad/isulad_commands.c
@@ -34,6 +34,7 @@
 #include "utils_verify.h"
 #include "opt_ulimit.h"
 #include "opt_log.h"
+#include "sysinfo.h"
 
 const char isulad_desc[] = "GLOBAL OPTIONS:";
 const char isulad_usage[] = "[global options]";
@@ -411,6 +412,33 @@ out:
     return ret;
 }
 
+static int check_args_cpu_rt(const struct service_arguments *args)
+{
+    int ret = 0;
+    __isula_auto_sysinfo_t sysinfo_t *sysinfo = NULL;
+
+    sysinfo = get_sys_info(true);
+    if (sysinfo == NULL) {
+        COMMAND_ERROR("Failed to get system info");
+        ERROR("Failed to get system info");
+        return -1;
+    }
+
+    if (!(sysinfo->cgcpuinfo.cpu_rt_period) && args->json_confs->cpu_rt_period != 0) {
+        COMMAND_ERROR("Invalid --cpu-rt-period: Your kernel does not support cgroup rt period");
+        ERROR("Invalid --cpu-rt-period: Your kernel does not support cgroup rt period");
+        return -1;
+    }
+
+    if (!(sysinfo->cgcpuinfo.cpu_rt_runtime) && args->json_confs->cpu_rt_runtime != 0) {
+        COMMAND_ERROR("Invalid --cpu-rt-runtime: Your kernel does not support cgroup rt runtime");
+        ERROR("Invalid --cpu-rt-runtime: Your kernel does not support cgroup rt runtime");
+        return -1;
+    }
+
+    return ret;
+}
+
 int check_args(struct service_arguments *args)
 {
     int ret = 0;
@@ -471,6 +499,10 @@ int check_args(struct service_arguments *args)
         goto out;
     }
 
+    if (check_args_cpu_rt(args) != 0) {
+        ret = -1;
+        goto out;
+    }
 out:
     return ret;
 }
-- 
2.34.1