Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
iSulad
提交
f75abd02
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,发现更多精彩内容 >>
提交
f75abd02
编写于
4月 03, 2020
作者:
L
LiFeng
提交者:
lifeng68
7月 25, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
driver: refact init progress
Signed-off-by:
N
LiFeng
<
lifeng68@huawei.com
>
上级
89a3dcbb
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
83 addition
and
148 deletion
+83
-148
src/cmd/isulad/main.c
src/cmd/isulad/main.c
+47
-3
src/config/isulad_config.c
src/config/isulad_config.c
+1
-79
src/config/isulad_config.h
src/config/isulad_config.h
+0
-4
src/image/oci/global_config.c
src/image/oci/global_config.c
+0
-52
src/image/oci/oci_images_store.c
src/image/oci/oci_images_store.c
+2
-1
src/image/oci/storage/layer_store/graphdriver/driver.c
src/image/oci/storage/layer_store/graphdriver/driver.c
+6
-7
src/image/oci/storage/layer_store/graphdriver/driver.h
src/image/oci/storage/layer_store/graphdriver/driver.h
+2
-2
src/image/oci/storage/storage.c
src/image/oci/storage/storage.c
+21
-0
src/image/oci/storage/storage.h
src/image/oci/storage/storage.h
+4
-0
未找到文件。
src/cmd/isulad/main.c
浏览文件 @
f75abd02
...
...
@@ -45,6 +45,7 @@
#include "engine.h"
#include "utils.h"
#include "isulad_config.h"
#include "storage.h"
#include "image.h"
#include "sysinfo.h"
#include "verify.h"
...
...
@@ -1090,6 +1091,51 @@ out:
return
ret
;
}
static
int
storage_module_init_helper
(
const
struct
service_arguments
*
args
)
{
int
ret
=
0
;
struct
storage_module_init_options
*
storage_opts
=
NULL
;
storage_opts
=
util_common_calloc_s
(
sizeof
(
struct
storage_module_init_options
));
if
(
storage_opts
==
NULL
)
{
ERROR
(
"Memory out"
);
ret
=
-
1
;
goto
out
;
}
storage_opts
->
driver_name
=
util_strdup_s
(
args
->
json_confs
->
storage_driver
);
storage_opts
->
storage_root
=
util_path_join
(
args
->
json_confs
->
graph
,
GRAPH_ROOTPATH_NAME
);
if
(
storage_opts
->
storage_root
==
NULL
)
{
ERROR
(
"Failed to get storage root dir"
);
ret
=
-
1
;
goto
out
;
}
storage_opts
->
storage_run_root
=
util_path_join
(
args
->
json_confs
->
state
,
GRAPH_ROOTPATH_NAME
);
if
(
storage_opts
->
storage_run_root
==
NULL
)
{
ERROR
(
"Failed to get storage run root dir"
);
ret
=
-
1
;
goto
out
;
}
if
(
dup_array_of_strings
((
const
char
**
)
args
->
json_confs
->
storage_opts
,
args
->
json_confs
->
storage_opts_len
,
&
storage_opts
->
driver_opts
,
&
storage_opts
->
driver_opts_len
)
!=
0
)
{
ERROR
(
"Failed to get storage storage opts"
);
ret
=
-
1
;
goto
out
;
}
if
(
storage_module_init
(
storage_opts
)
!=
0
)
{
ERROR
(
"Failed to init storage module"
);
ret
=
-
1
;
goto
out
;
}
out:
free_storage_module_init_options
(
storage_opts
);
return
ret
;
}
static
int
isulad_server_init_common
()
{
int
ret
=
-
1
;
...
...
@@ -1112,9 +1158,7 @@ static int isulad_server_init_common()
}
#ifdef ENABLE_OCI_IMAGE
if
(
graphdriver_init
(
args
->
json_confs
->
storage_driver
,
args
->
json_confs
->
graph
,
args
->
json_confs
->
storage_opts
,
args
->
json_confs
->
storage_opts_len
)
!=
0
)
{
if
(
storage_module_init_helper
(
args
)
!=
0
)
{
goto
out
;
}
#endif
...
...
src/config/isulad_config.c
浏览文件 @
f75abd02
...
...
@@ -30,9 +30,9 @@
#include "isulad_config.h"
#include "sysinfo.h"
#include "libisulad.h"
#include "storage.h"
#define ENGINE_ROOTPATH_NAME "engines"
#define GRAPH_ROOTPATH_NAME "storage"
#define GRAPH_ROOTPATH_CHECKED_FLAG "NEED_CHECK"
#define INCREMENT_INTREVAL 2
...
...
@@ -215,45 +215,6 @@ free_out:
return
epath
;
}
/* conf get graph rootpath */
char
*
conf_get_graph_rootpath
()
{
char
*
epath
=
NULL
;
char
*
rootpath
=
NULL
;
size_t
len
;
rootpath
=
conf_get_isulad_rootdir
();
if
(
rootpath
==
NULL
)
{
ERROR
(
"Get rootpath failed"
);
return
epath
;
}
if
(
strlen
(
rootpath
)
>
(
SIZE_MAX
-
strlen
(
GRAPH_ROOTPATH_NAME
))
-
2
)
{
ERROR
(
"Root path is too long"
);
goto
free_out
;
}
len
=
strlen
(
rootpath
)
+
1
+
strlen
(
GRAPH_ROOTPATH_NAME
)
+
1
;
if
(
len
>
PATH_MAX
)
{
ERROR
(
"The size of path exceeds the limit"
);
goto
free_out
;
}
epath
=
util_common_calloc_s
(
len
);
if
(
epath
==
NULL
)
{
ERROR
(
"Out of memory"
);
goto
free_out
;
}
int
nret
=
snprintf
(
epath
,
len
,
"%s/%s"
,
rootpath
,
GRAPH_ROOTPATH_NAME
);
if
(
nret
<
0
||
(
size_t
)
nret
>=
len
)
{
ERROR
(
"Sprintf graph path failed"
);
free
(
epath
);
epath
=
NULL
;
}
free_out:
free
(
rootpath
);
return
epath
;
}
/* conf get graph checked flag file path */
char
*
conf_get_graph_check_flag_file
()
{
...
...
@@ -293,45 +254,6 @@ free_out:
return
epath
;
}
/* conf get graph run path */
char
*
conf_get_graph_run_path
()
{
char
*
epath
=
NULL
;
char
*
rootpath
=
NULL
;
size_t
len
;
rootpath
=
conf_get_isulad_statedir
();
if
(
rootpath
==
NULL
)
{
ERROR
(
"Get rootpath failed"
);
return
epath
;
}
if
(
strlen
(
rootpath
)
>
(
SIZE_MAX
-
strlen
(
GRAPH_ROOTPATH_NAME
))
-
2
)
{
ERROR
(
"Root path is too long"
);
goto
free_out
;
}
len
=
strlen
(
rootpath
)
+
1
+
strlen
(
GRAPH_ROOTPATH_NAME
)
+
1
;
if
(
len
>
PATH_MAX
)
{
ERROR
(
"The size of path exceeds the limit"
);
goto
free_out
;
}
epath
=
util_common_calloc_s
(
len
);
if
(
epath
==
NULL
)
{
ERROR
(
"Out of memory"
);
goto
free_out
;
}
int
nret
=
snprintf
(
epath
,
len
,
"%s/%s"
,
rootpath
,
GRAPH_ROOTPATH_NAME
);
if
(
nret
<
0
||
(
size_t
)
nret
>=
len
)
{
ERROR
(
"Sprintf graph run path failed"
);
free
(
epath
);
epath
=
NULL
;
}
free_out:
free
(
rootpath
);
return
epath
;
}
/* conf get routine rootdir */
char
*
conf_get_routine_rootdir
(
const
char
*
runtime
)
{
...
...
src/config/isulad_config.h
浏览文件 @
f75abd02
...
...
@@ -72,10 +72,6 @@ unsigned int conf_get_start_timeout();
int
init_cgroups_path
(
const
char
*
path
,
int
recursive_depth
);
char
*
conf_get_graph_rootpath
();
char
*
conf_get_graph_run_path
();
char
**
conf_get_storage_opts
();
char
**
conf_get_insecure_registry_list
();
...
...
src/image/oci/global_config.c
浏览文件 @
f75abd02
...
...
@@ -28,50 +28,6 @@ static int pack_global_graph_driver(const char * const *options, bool ignore_sto
}
#endif
static
int
pack_global_graph_root
(
const
char
*
const
*
options
,
char
*
params
[],
size_t
*
count
)
{
int
ret
=
-
1
;
char
*
graph_root
=
NULL
;
size_t
i
=
0
;
i
=
*
count
;
graph_root
=
conf_get_graph_rootpath
();
if
(
graph_root
==
NULL
)
{
COMMAND_ERROR
(
"Failed to get graph root directory"
);
goto
out
;
}
add_array_kv
(
params
,
PARAM_NUM
,
&
i
,
options
[
GB_OPTION_GRAPH_ROOT
],
graph_root
);
ret
=
0
;
*
count
=
i
;
out:
free
(
graph_root
);
return
ret
;
}
static
int
pack_global_graph_run
(
const
char
*
const
*
options
,
char
*
params
[],
size_t
*
count
)
{
int
ret
=
-
1
;
char
*
graph_run
=
NULL
;
size_t
i
=
0
;
i
=
*
count
;
graph_run
=
conf_get_graph_run_path
();
if
(
graph_run
==
NULL
)
{
COMMAND_ERROR
(
"Failed to get graph run directory"
);
goto
out
;
}
add_array_kv
(
params
,
PARAM_NUM
,
&
i
,
options
[
GB_OPTION_RUN_ROOT
],
graph_run
);
ret
=
0
;
*
count
=
i
;
out:
free
(
graph_run
);
return
ret
;
}
static
char
*
adapt_log_level
()
{
#define LOG_LEVEL_MAX 5
...
...
@@ -193,14 +149,6 @@ int pack_global_options(const char * const *options, char *params[], size_t *cou
i
=
*
count
;
if
(
pack_global_graph_root
(
options
,
params
,
&
i
)
!=
0
)
{
goto
out
;
}
if
(
pack_global_graph_run
(
options
,
params
,
&
i
)
!=
0
)
{
goto
out
;
}
#ifdef ENABLE_OCI_IMAGE
if
(
pack_global_graph_driver
(
options
,
ignore_storage_opt_size
,
params
,
&
i
)
!=
0
)
{
goto
out
;
...
...
src/image/oci/oci_images_store.c
浏览文件 @
f75abd02
...
...
@@ -324,7 +324,8 @@ static void remove_graph_root()
int
ret
=
0
;
char
*
graph_root
=
NULL
;
graph_root
=
conf_get_graph_rootpath
();
//TODO replce funtion with storge module uninstall
//graph_root = conf_get_graph_rootpath();
if
(
graph_root
==
NULL
)
{
ERROR
(
"Failed to get image graph root path"
);
return
;
...
...
src/image/oci/storage/layer_store/graphdriver/driver.c
浏览文件 @
f75abd02
...
...
@@ -60,19 +60,18 @@ static struct graphdriver g_drivers[] = {
static
const
size_t
g_numdrivers
=
sizeof
(
g_drivers
)
/
sizeof
(
struct
graphdriver
);
int
graphdriver_init
(
const
char
*
name
,
const
char
*
isulad_root
,
char
**
storage_opts
,
size_t
storage_opts_len
)
int
graphdriver_init
(
struct
storage_module_init_options
*
opts
)
{
int
ret
=
0
;
size_t
i
=
0
;
char
driver_home
[
PATH_MAX
]
=
{
0
};
if
(
name
==
NULL
||
storage_opts
==
NULL
||
isulad_root
==
NULL
)
{
if
(
opts
==
NULL
||
opts
->
storage_root
==
NULL
||
opts
->
driver_name
==
NULL
)
{
ret
=
-
1
;
goto
out
;
}
int
nret
=
snprintf
(
driver_home
,
PATH_MAX
,
"%s/%s
/%s"
,
isulad_root
,
"storage"
,
name
);
int
nret
=
snprintf
(
driver_home
,
PATH_MAX
,
"%s/%s
"
,
opts
->
storage_root
,
opts
->
driver_
name
);
if
(
nret
<
0
||
(
size_t
)
nret
>=
PATH_MAX
)
{
ERROR
(
"Sprintf graph driver path failed"
);
ret
=
-
1
;
...
...
@@ -80,8 +79,8 @@ int graphdriver_init(const char *name, const char *isulad_root, char **storage_o
}
for
(
i
=
0
;
i
<
g_numdrivers
;
i
++
)
{
if
(
strcmp
(
name
,
g_drivers
[
i
].
name
)
==
0
)
{
if
(
g_drivers
[
i
].
ops
->
init
(
&
g_drivers
[
i
],
driver_home
,
(
const
char
**
)
storage_opts
,
storage
_opts_len
)
!=
0
)
{
if
(
strcmp
(
opts
->
driver_
name
,
g_drivers
[
i
].
name
)
==
0
)
{
if
(
g_drivers
[
i
].
ops
->
init
(
&
g_drivers
[
i
],
driver_home
,
(
const
char
**
)
opts
->
driver_opts
,
opts
->
driver
_opts_len
)
!=
0
)
{
ret
=
-
1
;
goto
out
;
}
...
...
@@ -91,7 +90,7 @@ int graphdriver_init(const char *name, const char *isulad_root, char **storage_o
}
if
(
i
==
g_numdrivers
)
{
ERROR
(
"unsupported driver %s"
,
name
);
ERROR
(
"unsupported driver %s"
,
opts
->
driver_
name
);
ret
=
-
1
;
goto
out
;
}
...
...
src/image/oci/storage/layer_store/graphdriver/driver.h
浏览文件 @
f75abd02
...
...
@@ -22,6 +22,7 @@
#include "json_common.h"
#include "console.h"
#include "driver_overlay2_types.h"
#include "storage.h"
#ifdef __cplusplus
extern
"C"
{
...
...
@@ -89,8 +90,7 @@ struct graphdriver {
struct
overlay_options
*
overlay_opts
;
};
int
graphdriver_init
(
const
char
*
name
,
const
char
*
isulad_root
,
char
**
storage_opts
,
size_t
storage_opts_len
);
int
graphdriver_init
(
struct
storage_module_init_options
*
opts
);
int
graphdriver_create_rw
(
const
char
*
id
,
const
char
*
parent
,
struct
driver_create_opts
*
create_opts
);
...
...
src/image/oci/storage/storage.c
浏览文件 @
f75abd02
...
...
@@ -332,3 +332,24 @@ out:
return
ret
;
}
void
free_storage_module_init_options
(
struct
storage_module_init_options
*
opts
)
{
if
(
opts
==
NULL
)
{
return
;
}
free
(
opts
->
driver_name
);
opts
->
driver_name
=
NULL
;
free
(
opts
->
storage_root
);
opts
->
storage_root
=
NULL
;
free
(
opts
->
storage_run_root
);
opts
->
storage_run_root
=
NULL
;
util_free_array_by_len
(
opts
->
driver_opts
,
opts
->
driver_opts_len
);
opts
->
driver_opts
=
NULL
;
opts
->
driver_opts_len
=
0
;
free
(
opts
);
}
\ No newline at end of file
src/image/oci/storage/storage.h
浏览文件 @
f75abd02
...
...
@@ -25,6 +25,8 @@
extern
"C"
{
#endif
#define GRAPH_ROOTPATH_NAME "storage"
struct
layer
{
char
*
id
;
char
*
parent
;
...
...
@@ -59,6 +61,8 @@ struct storage_img_create_options {
int
storage_module_init
(
struct
storage_module_init_options
*
opts
);
void
free_storage_module_init_options
(
struct
storage_module_init_options
*
opts
);
int
storage_layer_create
(
const
char
*
layer_id
,
const
char
*
parent_id
,
bool
writeable
,
const
char
*
layer_data_path
);
struct
layer
*
storage_layer_get
(
const
char
*
id
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录