Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
iSulad
提交
d1c33623
I
iSulad
项目概览
openeuler
/
iSulad
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
iSulad
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d1c33623
编写于
9月 04, 2020
作者:
L
lifeng68
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
blk_io: refact blk_bps_device and add blkio.weight.device
Signed-off-by:
N
lifeng68
<
lifeng68@huawei.com
>
上级
ca40f7e8
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
60 addition
and
91 deletion
+60
-91
src/client/connect/pack_config.c
src/client/connect/pack_config.c
+36
-77
src/cmd/isula/base/create.h
src/cmd/isula/base/create.h
+14
-0
src/daemon/modules/spec/specs_mount.c
src/daemon/modules/spec/specs_mount.c
+10
-14
未找到文件。
src/client/connect/pack_config.c
浏览文件 @
d1c33623
...
...
@@ -356,9 +356,8 @@ static int check_parsed_device(const host_config_devices_element *device_map)
}
if
(
!
util_file_exists
(
device_map
->
path_on_host
))
{
COMMAND_ERROR
(
"Error gathering device information while adding device
\"
%s
\"
,stat %s:no such file or directory"
,
device_map
->
path_on_host
,
device_map
->
path_on_host
);
COMMAND_ERROR
(
"Error gathering device information while adding device
\"
%s
\"
,stat %s:no such file or directory"
,
device_map
->
path_on_host
,
device_map
->
path_on_host
);
ret
=
-
1
;
goto
out
;
}
...
...
@@ -439,7 +438,8 @@ static int check_ulimit_input(const char *val)
if
(
val
[
0
]
==
'='
||
val
[
strlen
(
val
)
-
1
]
==
'='
)
{
COMMAND_ERROR
(
"Invalid ulimit argument:
\"
%s
\"
, delimiter '=' can't"
" be the first or the last character"
,
val
);
" be the first or the last character"
,
val
);
ret
=
-
1
;
}
...
...
@@ -484,7 +484,7 @@ static int parse_soft_hard_ulimit(const char *val, char **limitvals, size_t limi
goto
out
;
}
}
else
{
*
hard
=
*
soft
;
// default to soft in case no hard was set
*
hard
=
*
soft
;
// default to soft in case no hard was set
}
out:
return
ret
;
...
...
@@ -547,7 +547,8 @@ static host_config_ulimits_element *parse_ulimit(const char *val)
if
(
parts
[
1
][
0
]
==
':'
||
parts
[
1
][
strlen
(
parts
[
1
])
-
1
]
==
':'
)
{
COMMAND_ERROR
(
"Invalid ulimit value:
\"
%s
\"
, delimiter ':' can't be the first"
" or the last character"
,
val
);
" or the last character"
,
val
);
ret
=
-
1
;
goto
out
;
}
...
...
@@ -560,8 +561,7 @@ static host_config_ulimits_element *parse_ulimit(const char *val)
}
if
(
limitvals_len
>
2
)
{
COMMAND_ERROR
(
"Too many limit value arguments - %s, can only have up to two, `soft[:hard]`"
,
parts
[
1
]);
COMMAND_ERROR
(
"Too many limit value arguments - %s, can only have up to two, `soft[:hard]`"
,
parts
[
1
]);
ret
=
-
1
;
goto
out
;
}
...
...
@@ -739,19 +739,19 @@ static int pack_hostconfig_cgroup(host_config *dstconfig, const isula_host_confi
return
ret
;
}
static
host_config_blkio_weight_device_element
*
pack_blkio_weight_devices
(
const
char
*
devices
)
static
defs_blkio_weight_device
*
pack_blkio_weight_devices
(
const
char
*
devices
)
{
char
**
tmp_str
=
NULL
;
unsigned
int
weight
=
0
;
size_t
tmp_str_len
=
0
;
host_config_blkio_weight_device_element
*
weight_dev
=
NULL
;
defs_blkio_weight_device
*
weight_dev
=
NULL
;
if
(
devices
==
NULL
||
!
strcmp
(
devices
,
""
))
{
COMMAND_ERROR
(
"Weight devices can't be empty"
);
return
NULL
;
}
weight_dev
=
util_common_calloc_s
(
sizeof
(
host_config_blkio_weight_device_element
));
weight_dev
=
util_common_calloc_s
(
sizeof
(
defs_blkio_weight_device
));
if
(
weight_dev
==
NULL
)
{
ERROR
(
"Out of memory"
);
return
NULL
;
...
...
@@ -793,7 +793,7 @@ static host_config_blkio_weight_device_element *pack_blkio_weight_devices(const
erro_out:
util_free_array
(
tmp_str
);
free_
host_config_blkio_weight_device_element
(
weight_dev
);
free_
defs_blkio_weight_device
(
weight_dev
);
return
NULL
;
}
...
...
@@ -817,7 +817,8 @@ static int parse_blkio_throttle_bps_device(const char *device, char **path, cons
if
(
util_parse_byte_size_string
(
split
[
1
],
(
int64_t
*
)
rate
)
!=
0
)
{
COMMAND_ERROR
(
"invalid rate for device: %s. The correct format is <device-path>:<number>[<unit>]."
" Number must be a positive integer. Unit is optional and can be kb, mb, or gb"
,
device
);
" Number must be a positive integer. Unit is optional and can be kb, mb, or gb"
,
device
);
ret
=
-
1
;
goto
out
;
}
...
...
@@ -829,19 +830,19 @@ out:
}
// validate that the specified string has a valid device-rate format.
static
host_config_blkio_device_read_bps_element
*
pack_throttle_read
_bps_device
(
const
char
*
device
)
static
defs_blkio_device
*
pack_throttle
_bps_device
(
const
char
*
device
)
{
char
*
path
=
NULL
;
uint64_t
rate
=
0
;
host_config_blkio_device_read_bps_element
*
read_
bps_dev
=
NULL
;
defs_blkio_device
*
bps_dev
=
NULL
;
if
(
device
==
NULL
||
!
strcmp
(
device
,
""
))
{
COMMAND_ERROR
(
"blkio throttle read bps device can't be empty"
);
return
NULL
;
}
read_bps_dev
=
util_common_calloc_s
(
sizeof
(
host_config_blkio_device_read_bps_element
));
if
(
read_
bps_dev
==
NULL
)
{
bps_dev
=
util_common_calloc_s
(
sizeof
(
defs_blkio_device
));
if
(
bps_dev
==
NULL
)
{
ERROR
(
"Out of memory"
);
return
NULL
;
}
...
...
@@ -850,47 +851,14 @@ static host_config_blkio_device_read_bps_element *pack_throttle_read_bps_device(
goto
error_out
;
}
read_
bps_dev
->
path
=
path
;
read_
bps_dev
->
rate
=
rate
;
bps_dev
->
path
=
path
;
bps_dev
->
rate
=
rate
;
return
read_
bps_dev
;
return
bps_dev
;
error_out:
free
(
path
);
free_host_config_blkio_device_read_bps_element
(
read_bps_dev
);
return
NULL
;
}
// validate that the specified string has a valid device-rate format.
static
host_config_blkio_device_write_bps_element
*
pack_throttle_write_bps_device
(
const
char
*
device
)
{
char
*
path
=
NULL
;
uint64_t
rate
=
0
;
host_config_blkio_device_write_bps_element
*
write_bps_dev
=
NULL
;
if
(
device
==
NULL
||
!
strcmp
(
device
,
""
))
{
COMMAND_ERROR
(
"blkio throttle write bps device can't be empty"
);
return
NULL
;
}
write_bps_dev
=
util_common_calloc_s
(
sizeof
(
host_config_blkio_device_write_bps_element
));
if
(
write_bps_dev
==
NULL
)
{
ERROR
(
"Out of memory"
);
return
NULL
;
}
if
(
parse_blkio_throttle_bps_device
(
device
,
&
path
,
&
rate
)
!=
0
)
{
goto
error_out
;
}
write_bps_dev
->
path
=
path
;
write_bps_dev
->
rate
=
rate
;
return
write_bps_dev
;
error_out:
free
(
path
);
free_host_config_blkio_device_write_bps_element
(
write_bps_dev
);
free_defs_blkio_device
(
bps_dev
);
return
NULL
;
}
...
...
@@ -1218,8 +1186,7 @@ static int append_seccomp_to_security_opts(const char *full_opt, const char *sec
seccomp_spec
=
get_seccomp_security_opt_spec
(
seccomp_file
);
if
(
seccomp_spec
==
NULL
)
{
ERROR
(
"Failed to parse docker format seccomp specification file
\"
%s
\"
, error message: %s"
,
seccomp_file
,
err
);
ERROR
(
"Failed to parse docker format seccomp specification file
\"
%s
\"
, error message: %s"
,
seccomp_file
,
err
);
COMMAND_ERROR
(
"failed to parse seccomp file: %s"
,
seccomp_file
);
ret
=
-
1
;
goto
out
;
...
...
@@ -1340,8 +1307,7 @@ int generate_storage_opts(host_config **dstconfig, const isula_host_config_t *sr
goto
out
;
}
for
(
j
=
0
;
j
<
srcconfig
->
storage_opts
->
len
;
j
++
)
{
ret
=
append_json_map_string_string
((
*
dstconfig
)
->
storage_opt
,
srcconfig
->
storage_opts
->
keys
[
j
],
ret
=
append_json_map_string_string
((
*
dstconfig
)
->
storage_opt
,
srcconfig
->
storage_opts
->
keys
[
j
],
srcconfig
->
storage_opts
->
values
[
j
]);
if
(
ret
!=
0
)
{
ERROR
(
"Append map failed"
);
...
...
@@ -1421,14 +1387,14 @@ static int generate_blkio_weight_device(host_config **dstconfig, const isula_hos
goto
out
;
}
if
(
srcconfig
->
blkio_weight_device_len
>
SIZE_MAX
/
sizeof
(
host_config_blkio_weight_device_element
*
))
{
if
(
srcconfig
->
blkio_weight_device_len
>
SIZE_MAX
/
sizeof
(
defs_blkio_weight_device
*
))
{
ERROR
(
"Too many blkio weight devies to get!"
);
ret
=
-
1
;
goto
out
;
}
(
*
dstconfig
)
->
blkio_weight_device
=
util_common_calloc_s
(
srcconfig
->
blkio_weight_device_len
*
sizeof
(
host_config_blkio_weight_device_element
*
));
util_common_calloc_s
(
srcconfig
->
blkio_weight_device_len
*
sizeof
(
defs_blkio_weight_device
*
));
if
((
*
dstconfig
)
->
blkio_weight_device
==
NULL
)
{
ret
=
-
1
;
goto
out
;
...
...
@@ -1461,23 +1427,21 @@ static int generate_blkio_throttle_read_bps_device(host_config **dstconfig, cons
goto
out
;
}
if
(
srcconfig
->
blkio_throttle_read_bps_device_len
>
SIZE_MAX
/
sizeof
(
host_config_blkio_device_read_bps_element
*
))
{
if
(
srcconfig
->
blkio_throttle_read_bps_device_len
>
SIZE_MAX
/
sizeof
(
defs_blkio_device
*
))
{
ERROR
(
"Too many blkio throttle read bps devies to get!"
);
ret
=
-
1
;
goto
out
;
}
(
*
dstconfig
)
->
blkio_device_read_bps
=
util_common_calloc_s
(
srcconfig
->
blkio_throttle_read_bps_device_len
*
sizeof
(
host_config_blkio_device_read_bps_element
*
));
util_common_calloc_s
(
srcconfig
->
blkio_throttle_read_bps_device_len
*
sizeof
(
defs_blkio_device
*
));
if
((
*
dstconfig
)
->
blkio_device_read_bps
==
NULL
)
{
ret
=
-
1
;
goto
out
;
}
for
(
i
=
0
;
i
<
srcconfig
->
blkio_throttle_read_bps_device_len
;
i
++
)
{
(
*
dstconfig
)
->
blkio_device_read_bps
[(
*
dstconfig
)
->
blkio_device_read_bps_len
]
=
pack_throttle_
read_
bps_device
(
srcconfig
->
blkio_throttle_read_bps_device
[
i
]);
pack_throttle_bps_device
(
srcconfig
->
blkio_throttle_read_bps_device
[
i
]);
if
((
*
dstconfig
)
->
blkio_device_read_bps
[(
*
dstconfig
)
->
blkio_device_read_bps_len
]
==
NULL
)
{
ERROR
(
"Failed to get blkio throttle read bps devices"
);
ret
=
-
1
;
...
...
@@ -1503,23 +1467,21 @@ static int generate_blkio_throttle_write_bps_device(host_config **dstconfig, con
goto
out
;
}
if
(
srcconfig
->
blkio_throttle_write_bps_device_len
>
SIZE_MAX
/
sizeof
(
host_config_blkio_device_write_bps_element
*
))
{
if
(
srcconfig
->
blkio_throttle_write_bps_device_len
>
SIZE_MAX
/
sizeof
(
defs_blkio_device
*
))
{
ERROR
(
"Too many blkio throttle write bps devies to get!"
);
ret
=
-
1
;
goto
out
;
}
(
*
dstconfig
)
->
blkio_device_write_bps
=
util_common_calloc_s
(
srcconfig
->
blkio_throttle_write_bps_device_len
*
sizeof
(
host_config_blkio_device_write_bps_element
*
));
(
*
dstconfig
)
->
blkio_device_write_bps
=
util_common_calloc_s
(
srcconfig
->
blkio_throttle_write_bps_device_len
*
sizeof
(
defs_blkio_device
*
));
if
((
*
dstconfig
)
->
blkio_device_write_bps
==
NULL
)
{
ret
=
-
1
;
goto
out
;
}
for
(
i
=
0
;
i
<
srcconfig
->
blkio_throttle_write_bps_device_len
;
i
++
)
{
(
*
dstconfig
)
->
blkio_device_write_bps
[(
*
dstconfig
)
->
blkio_device_write_bps_len
]
=
pack_throttle_
write_
bps_device
(
srcconfig
->
blkio_throttle_write_bps_device
[
i
]);
pack_throttle_bps_device
(
srcconfig
->
blkio_throttle_write_bps_device
[
i
]);
if
((
*
dstconfig
)
->
blkio_device_write_bps
[(
*
dstconfig
)
->
blkio_device_write_bps_len
]
==
NULL
)
{
ERROR
(
"Failed to get blkio throttle write bps devices"
);
ret
=
-
1
;
...
...
@@ -2017,9 +1979,8 @@ out:
return
ret
;
}
static
int
pack_custom_with_health_check
(
container_config
*
container_spec
,
const
isula_container_config_t
*
custom_conf
,
bool
have_health_settings
,
defs_health_check
*
health_config
)
static
int
pack_custom_with_health_check
(
container_config
*
container_spec
,
const
isula_container_config_t
*
custom_conf
,
bool
have_health_settings
,
defs_health_check
*
health_config
)
{
int
ret
=
0
;
...
...
@@ -2150,8 +2111,7 @@ out:
}
/* translate create_custom_config to container_config */
static
int
pack_container_custom_config
(
container_config
*
container_spec
,
const
isula_container_config_t
*
custom_conf
)
static
int
pack_container_custom_config
(
container_config
*
container_spec
,
const
isula_container_config_t
*
custom_conf
)
{
int
ret
=
-
1
;
...
...
@@ -2240,4 +2200,3 @@ out:
return
ret
;
}
src/cmd/isula/base/create.h
浏览文件 @
d1c33623
...
...
@@ -415,6 +415,20 @@ extern "C" {
"Namespaced kernel param options for system container (default [])", \
NULL }, \
{ CMD_OPT_TYPE_CALLBACK, false, "ulimit", 0, &(cmdargs).custom_conf.ulimits, "Ulimit options (default [])", \
command_append_array }, \
{ CMD_OPT_TYPE_CALLBACK, \
false, \
"blkio-weight", \
0, \
&(cmdargs).cr.blkio_weight, \
"Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0)", \
command_convert_u16 }, \
{ CMD_OPT_TYPE_CALLBACK, \
false, \
"blkio-weight-device", \
0, \
&(cmdargs).custom_conf.weight_devices, \
"Block IO weight (relative device weight) (default []), format: DEVICE_NAME:WEIGHT", \
command_append_array },
#define CREATE_EXTEND_OPTIONS(cmdargs) \
...
...
src/daemon/modules/spec/specs_mount.c
浏览文件 @
d1c33623
...
...
@@ -899,7 +899,7 @@ out:
return
ret
;
}
static
int
get_weight_devices_from_path
(
const
host_config_blkio_weight_device_element
*
weight_dev
,
static
int
get_weight_devices_from_path
(
const
defs_blkio_weight_device
*
weight_dev
,
defs_block_io_device_weight
*
spec_weight_dev
)
{
int
ret
=
0
;
...
...
@@ -929,7 +929,7 @@ static int get_weight_devices_from_path(const host_config_blkio_weight_device_el
}
static
int
merge_host_config_blk_weight_device
(
defs_block_io_device_weight
**
out_spec_weight_dev
,
const
host_config_blkio_weight_device_element
*
weight_dev
)
const
defs_blkio_weight_device
*
weight_dev
)
{
int
ret
=
0
;
defs_block_io_device_weight
*
spec_weight_dev
=
NULL
;
...
...
@@ -958,7 +958,7 @@ out:
return
ret
;
}
static
int
get_read_bps_devices_from_path
(
const
host_config_blkio_device_read_bps_element
*
read_bps_dev
,
static
int
get_read_bps_devices_from_path
(
const
defs_blkio_device
*
read_bps_dev
,
defs_block_io_device_throttle
*
spec_read_bps_dev
)
{
int
ret
=
0
;
...
...
@@ -984,7 +984,7 @@ static int get_read_bps_devices_from_path(const host_config_blkio_device_read_bp
}
static
int
merge_host_config_blk_read_bps_device
(
defs_block_io_device_throttle
**
out_spec_read_bps_dev
,
const
host_config_blkio_device_read_bps_element
*
blkio_device_read_bps
)
const
defs_blkio_device
*
blkio_device_read_bps
)
{
int
ret
=
0
;
defs_block_io_device_throttle
*
spec_read_bps_dev
=
NULL
;
...
...
@@ -1013,7 +1013,7 @@ out:
return
ret
;
}
static
int
get_write_bps_devices_from_path
(
const
host_config_blkio_device_write_bps_element
*
write_bps_dev
,
static
int
get_write_bps_devices_from_path
(
const
defs_blkio_device
*
write_bps_dev
,
defs_block_io_device_throttle
*
spec_write_bps_dev
)
{
int
ret
=
0
;
...
...
@@ -1038,9 +1038,8 @@ static int get_write_bps_devices_from_path(const host_config_blkio_device_write_
return
0
;
}
static
int
merge_host_config_blk_write_bps_device
(
defs_block_io_device_throttle
**
out_spec_write_bps_dev
,
const
host_config_blkio_device_write_bps_element
*
blkio_device_write_bps
)
static
int
merge_host_config_blk_write_bps_device
(
defs_block_io_device_throttle
**
out_spec_write_bps_dev
,
const
defs_blkio_device
*
blkio_device_write_bps
)
{
int
ret
=
0
;
defs_block_io_device_throttle
*
spec_write_bps_dev
=
NULL
;
...
...
@@ -1583,8 +1582,7 @@ out:
return
ret
;
}
static
int
merge_blkio_weight_device
(
oci_runtime_spec
*
oci_spec
,
host_config_blkio_weight_device_element
**
blkio_weight_device
,
static
int
merge_blkio_weight_device
(
oci_runtime_spec
*
oci_spec
,
defs_blkio_weight_device
**
blkio_weight_device
,
size_t
blkio_weight_device_len
)
{
int
ret
=
0
;
...
...
@@ -1633,8 +1631,7 @@ out:
return
ret
;
}
static
int
merge_blkio_read_bps_device
(
oci_runtime_spec
*
oci_spec
,
host_config_blkio_device_read_bps_element
**
blkio_read_bps_device
,
static
int
merge_blkio_read_bps_device
(
oci_runtime_spec
*
oci_spec
,
defs_blkio_device
**
blkio_read_bps_device
,
size_t
throttle_read_bps_device_len
)
{
int
ret
=
0
;
...
...
@@ -1687,8 +1684,7 @@ out:
return
ret
;
}
static
int
merge_blkio_write_bps_device
(
oci_runtime_spec
*
oci_spec
,
host_config_blkio_device_write_bps_element
**
blkio_write_bps_device
,
static
int
merge_blkio_write_bps_device
(
oci_runtime_spec
*
oci_spec
,
defs_blkio_device
**
blkio_write_bps_device
,
size_t
throttle_write_bps_device_len
)
{
int
ret
=
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录