Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
iSulad
提交
025712e7
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,发现更多精彩内容 >>
提交
025712e7
编写于
1月 20, 2020
作者:
W
WangFengTu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support devicemapper
Signed-off-by:
N
WangFengTu
<
wangfengtu@huawei.com
>
上级
5d51de78
变更
26
隐藏空白更改
内联
并排
Showing
26 changed file
with
347 addition
and
94 deletion
+347
-94
src/api/image_client/isula_image.proto
src/api/image_client/isula_image.proto
+3
-5
src/api/services/containers/container.proto
src/api/services/containers/container.proto
+2
-0
src/cmd/isula/information/info.c
src/cmd/isula/information/info.c
+31
-0
src/connect/client/grpc/grpc_containers_client.cc
src/connect/client/grpc/grpc_containers_client.cc
+11
-0
src/connect/client/grpc/grpc_isula_image_client.cc
src/connect/client/grpc/grpc_isula_image_client.cc
+2
-4
src/connect/client/isula_image_connect.c
src/connect/client/isula_image_connect.c
+2
-2
src/connect/client/isula_image_connect.h
src/connect/client/isula_image_connect.h
+1
-3
src/connect/service/grpc/grpc_containers_service.h
src/connect/service/grpc/grpc_containers_service.h
+2
-0
src/connect/service/grpc/grpc_containers_service_private.cc
src/connect/service/grpc/grpc_containers_service_private.cc
+20
-0
src/cutils/utils_string.c
src/cutils/utils_string.c
+25
-0
src/cutils/utils_string.h
src/cutils/utils_string.h
+2
-0
src/image/image.c
src/image/image.c
+2
-0
src/image/image.h
src/image/image.h
+1
-2
src/image/oci/global_config.c
src/image/oci/global_config.c
+6
-0
src/image/oci/isula_storage_status.c
src/image/oci/isula_storage_status.c
+55
-5
src/image/oci/oci_common_operators.c
src/image/oci/oci_common_operators.c
+0
-67
src/image/oci/oci_common_operators.h
src/image/oci/oci_common_operators.h
+0
-1
src/json/schema/schema/host/info-response.json
src/json/schema/schema/host/info-response.json
+6
-0
src/libisula.h
src/libisula.h
+2
-0
src/services/execution/execute/execution_information.c
src/services/execution/execute/execution_information.c
+21
-0
src/services/graphdriver/CMakeLists.txt
src/services/graphdriver/CMakeLists.txt
+3
-0
src/services/graphdriver/devmapper/CMakeLists.txt
src/services/graphdriver/devmapper/CMakeLists.txt
+7
-0
src/services/graphdriver/devmapper/driver_devmapper.c
src/services/graphdriver/devmapper/driver_devmapper.c
+94
-0
src/services/graphdriver/devmapper/driver_devmapper.h
src/services/graphdriver/devmapper/driver_devmapper.h
+34
-0
src/services/graphdriver/driver.c
src/services/graphdriver/driver.c
+14
-3
src/services/graphdriver/driver.h
src/services/graphdriver/driver.h
+1
-2
未找到文件。
src/api/image_client/isula_image.proto
浏览文件 @
025712e7
...
...
@@ -141,11 +141,9 @@ message LoadImageResponose {
message
GraphdriverStatusRequest
{}
message
GraphdriverStatusResponse
{
string
backing_fs
=
1
;
bool
supports_d_type
=
2
;
bool
native_overlay_diff
=
3
;
string
errmsg
=
4
;
uint32
cc
=
5
;
string
status
=
1
;
string
errmsg
=
2
;
uint32
cc
=
3
;
}
message
ContainerFsUsageRequest
{
...
...
src/api/services/containers/container.proto
浏览文件 @
025712e7
...
...
@@ -376,6 +376,8 @@ message InfoResponse {
string
http_proxy
=
20
;
string
https_proxy
=
21
;
string
no_proxy
=
22
;
string
driver_name
=
23
;
string
driver_status
=
24
;
}
message
UpdateRequest
{
...
...
src/cmd/isula/information/info.c
浏览文件 @
025712e7
...
...
@@ -26,6 +26,31 @@ const char g_cmd_info_usage[] = "info";
struct
client_arguments
g_cmd_info_args
=
{};
static
void
print_with_space
(
const
char
*
info
)
{
size_t
i
=
0
;
size_t
size
=
0
;
bool
print_space
=
true
;
if
(
info
==
NULL
)
{
return
;
}
size
=
strlen
(
info
);
for
(
i
=
0
;
i
<
size
;
i
++
)
{
if
(
print_space
)
{
printf
(
" "
);
print_space
=
false
;
}
if
(
info
[
i
]
==
'\n'
)
{
print_space
=
true
;
}
printf
(
"%c"
,
info
[
i
]);
}
return
;
}
static
void
client_info_server
(
const
struct
isula_info_response
*
response
)
{
printf
(
"Containers: %u
\n
"
,
(
unsigned
int
)(
response
->
containers_num
));
...
...
@@ -36,6 +61,12 @@ static void client_info_server(const struct isula_info_response *response)
if
(
response
->
version
!=
NULL
)
{
printf
(
"Server Version: %s
\n
"
,
response
->
version
);
}
if
(
response
->
driver_name
!=
NULL
)
{
printf
(
"Storage Driver: %s
\n
"
,
response
->
driver_name
);
}
if
(
response
->
driver_status
!=
NULL
)
{
print_with_space
(
response
->
driver_status
);
}
if
(
response
->
logging_driver
!=
NULL
)
{
printf
(
"Logging Driver: %s
\n
"
,
response
->
logging_driver
);
}
...
...
src/connect/client/grpc/grpc_containers_client.cc
浏览文件 @
025712e7
...
...
@@ -105,6 +105,7 @@ public:
}
response
->
total_mem
=
gresponse
->
total_mem
();
get_proxy_info_from_grpc
(
response
,
gresponse
);
get_driver_info_from_grpc
(
response
,
gresponse
);
return
0
;
}
...
...
@@ -150,6 +151,16 @@ private:
response
->
no_proxy
=
util_strdup_s
(
gresponse
->
no_proxy
().
c_str
());
}
}
void
get_driver_info_from_grpc
(
isula_info_response
*
response
,
InfoResponse
*
gresponse
)
{
if
(
!
gresponse
->
driver_name
().
empty
())
{
response
->
driver_name
=
util_strdup_s
(
gresponse
->
driver_name
().
c_str
());
}
if
(
!
gresponse
->
driver_status
().
empty
())
{
response
->
driver_status
=
util_strdup_s
(
gresponse
->
driver_status
().
c_str
());
}
}
};
class
ContainerCreate
:
public
ClientBase
<
ContainerService
,
ContainerService
::
Stub
,
isula_create_request
,
CreateRequest
,
...
...
src/connect/client/grpc/grpc_isula_image_client.cc
浏览文件 @
025712e7
...
...
@@ -843,11 +843,9 @@ public:
}
resp
->
server_errono
=
gresp
->
cc
();
if
(
!
gresp
->
backing_f
s
().
empty
())
{
resp
->
backing_fs
=
util_strdup_s
(
gresp
->
backing_f
s
().
c_str
());
if
(
!
gresp
->
statu
s
().
empty
())
{
resp
->
status
=
util_strdup_s
(
gresp
->
statu
s
().
c_str
());
}
resp
->
supports_d_type
=
gresp
->
supports_d_type
();
resp
->
native_overlay_diff
=
gresp
->
native_overlay_diff
();
return
0
;
}
...
...
src/connect/client/isula_image_connect.c
浏览文件 @
025712e7
...
...
@@ -463,8 +463,8 @@ void free_isula_storage_status_response(struct isula_storage_status_response *pt
if
(
ptr
==
NULL
)
{
return
;
}
free
(
ptr
->
backing_f
s
);
ptr
->
backing_f
s
=
NULL
;
free
(
ptr
->
statu
s
);
ptr
->
statu
s
=
NULL
;
free
(
ptr
->
errmsg
);
ptr
->
errmsg
=
NULL
;
free
(
ptr
);
...
...
src/connect/client/isula_image_connect.h
浏览文件 @
025712e7
...
...
@@ -223,9 +223,7 @@ struct isula_storage_status_request {
};
struct
isula_storage_status_response
{
char
*
backing_fs
;
bool
supports_d_type
;
bool
native_overlay_diff
;
char
*
status
;
char
*
errmsg
;
uint32_t
cc
;
...
...
src/connect/service/grpc/grpc_containers_service.h
浏览文件 @
025712e7
...
...
@@ -218,6 +218,8 @@ private:
int
pack_proxy_info_to_grpc
(
const
host_info_response
*
response
,
InfoResponse
*
gresponse
);
int
pack_driver_info_to_grpc
(
const
host_info_response
*
response
,
InfoResponse
*
gresponse
);
int
logs_request_from_grpc
(
const
LogsRequest
*
grequest
,
struct
isulad_logs_request
**
request
);
};
...
...
src/connect/service/grpc/grpc_containers_service_private.cc
浏览文件 @
025712e7
...
...
@@ -110,6 +110,10 @@ int ContainerServiceImpl::info_response_to_grpc(const host_info_response *respon
return
-
1
;
}
if
(
pack_driver_info_to_grpc
(
response
,
gresponse
))
{
return
-
1
;
}
return
0
;
}
...
...
@@ -1109,4 +1113,20 @@ int ContainerServiceImpl::pack_proxy_info_to_grpc(const host_info_response *resp
return
0
;
}
int
ContainerServiceImpl
::
pack_driver_info_to_grpc
(
const
host_info_response
*
response
,
InfoResponse
*
gresponse
)
{
if
(
response
==
nullptr
)
{
gresponse
->
set_cc
(
ISULAD_ERR_MEMOUT
);
return
0
;
}
if
(
response
->
driver_name
!=
nullptr
)
{
gresponse
->
set_driver_name
(
response
->
driver_name
);
}
if
(
response
->
driver_status
!=
nullptr
)
{
gresponse
->
set_driver_status
(
response
->
driver_status
);
}
return
0
;
}
src/cutils/utils_string.c
浏览文件 @
025712e7
...
...
@@ -18,6 +18,7 @@
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include "utils.h"
#include "log.h"
...
...
@@ -266,6 +267,30 @@ int util_parse_byte_size_string(const char *s, int64_t *converted)
return
ret
;
}
int
util_parse_percent_string
(
const
char
*
s
,
long
*
converted
)
{
char
*
dup
=
NULL
;
if
(
s
==
NULL
||
converted
==
NULL
||
s
[
0
]
==
0
||
strlen
(
s
)
<
2
||
s
[
strlen
(
s
)
-
1
]
!=
'%'
)
{
return
-
EINVAL
;
}
dup
=
util_strdup_s
(
s
);
if
(
dup
==
NULL
)
{
return
-
ENOMEM
;
}
dup
[
strlen
(
dup
)
-
1
]
=
0
;
*
converted
=
strtol
(
dup
,
NULL
,
10
);
if
((
errno
==
ERANGE
&&
(
*
converted
==
LONG_MAX
||
*
converted
==
LONG_MIN
))
||
(
errno
!=
0
&&
*
converted
==
0
)
||
*
converted
<
0
||
*
converted
>=
100
)
{
free
(
dup
);
return
-
EINVAL
;
}
free
(
dup
);
return
0
;
}
static
char
**
util_shrink_array
(
char
**
orig_array
,
size_t
new_size
)
{
char
**
new_array
=
NULL
;
...
...
src/cutils/utils_string.h
浏览文件 @
025712e7
...
...
@@ -35,6 +35,8 @@ char *strings_to_upper(const char *str);
int
util_parse_byte_size_string
(
const
char
*
s
,
int64_t
*
converted
);
int
util_parse_percent_string
(
const
char
*
s
,
long
*
converted
);
// Breaks src_str into an array of string according to _sep,
// note that two or more contiguous delimiter bytes is considered to be a single delimiter
char
**
util_string_split
(
const
char
*
src_str
,
char
_sep
);
...
...
src/image/image.c
浏览文件 @
025712e7
...
...
@@ -1745,6 +1745,8 @@ void free_im_storage_status_response(im_storage_status_response *ptr)
}
free
(
ptr
->
backing_fs
);
ptr
->
backing_fs
=
NULL
;
free
(
ptr
->
status
);
ptr
->
status
=
NULL
;
free
(
ptr
);
}
...
...
src/image/image.h
浏览文件 @
025712e7
...
...
@@ -55,8 +55,7 @@ typedef struct {
typedef
struct
{
char
*
backing_fs
;
bool
supports_d_type
;
bool
native_overlay_diff
;
char
*
status
;
}
im_storage_status_response
;
typedef
struct
{
...
...
src/image/oci/global_config.c
浏览文件 @
025712e7
...
...
@@ -58,6 +58,12 @@ static int pack_global_graph_driver(const char * const *options, bool ignore_sto
add_array_kv
(
params
,
PARAM_NUM
,
&
i
,
options
[
GB_OPTION_DRIVER_OPTIONS
],
*
p
);
}
if
(
strcmp
(
graph_driver
,
"devicemapper"
)
==
0
)
{
// option "test=false" is used when devicemapper thinpool is created automatically by iSulad-kit.
// Make "test" always be true to avoid config check as we always create thinpool manually.
add_array_kv
(
params
,
PARAM_NUM
,
&
i
,
options
[
GB_OPTION_DRIVER_OPTIONS
],
"test=true"
);
}
ret
=
0
;
*
count
=
i
;
out:
...
...
src/image/oci/isula_storage_status.c
浏览文件 @
025712e7
...
...
@@ -20,11 +20,58 @@
#include "utils.h"
#include "log.h"
static
void
pack_im_response
(
const
struct
isula_storage_status_response
*
iresp
,
im_storage_status_response
*
resp
)
// format: [status xx: val]
static
int
get_graphdriver_status_line_value
(
const
char
*
line
,
char
**
start
,
char
**
end
)
{
resp
->
backing_fs
=
util_strdup_s
(
iresp
->
backing_fs
);
resp
->
supports_d_type
=
iresp
->
supports_d_type
;
resp
->
native_overlay_diff
=
iresp
->
native_overlay_diff
;
char
*
pstart
=
NULL
;
char
*
pend
=
NULL
;
pstart
=
strchr
(
line
,
':'
);
if
(
pstart
==
NULL
)
{
ERROR
(
"Invalid output: %s"
,
line
);
return
-
1
;
}
pstart
++
;
if
(
*
pstart
!=
' '
)
{
ERROR
(
"Invalid output: %s"
,
line
);
return
-
1
;
}
pstart
++
;
pend
=
strchr
(
pstart
,
'\n'
);
if
(
pend
==
NULL
)
{
ERROR
(
"Invalid output: %s"
,
pstart
);
return
-
1
;
}
*
pend
++
=
'\0'
;
*
start
=
pstart
;
*
end
=
pend
;
return
0
;
}
static
int
pack_im_response
(
const
struct
isula_storage_status_response
*
iresp
,
im_storage_status_response
*
resp
)
{
char
*
pstart
=
NULL
;
char
*
pend
=
NULL
;
if
(
iresp
->
status
==
NULL
)
{
ERROR
(
"Storage status response status NULL"
);
isulad_set_error_message
(
"Storage status response NULL"
);
return
-
1
;
}
resp
->
status
=
util_strdup_s
(
iresp
->
status
);
// Backing Filesystem: extfs
if
(
get_graphdriver_status_line_value
(
iresp
->
status
,
&
pstart
,
&
pend
)
!=
0
)
{
ERROR
(
"Get backing filesystem from status failed. status:%s"
,
iresp
->
status
);
isulad_set_error_message
(
"Get backing filesystem from status failed"
);
return
-
1
;
}
resp
->
backing_fs
=
util_strdup_s
(
pstart
);
return
0
;
}
int
isula_do_storage_status
(
im_storage_status_response
*
resp
)
...
...
@@ -71,7 +118,10 @@ int isula_do_storage_status(im_storage_status_response *resp)
ret
=
-
1
;
goto
out
;
}
pack_im_response
(
iresp
,
resp
);
ret
=
pack_im_response
(
iresp
,
resp
);
if
(
ret
!=
0
)
{
goto
out
;
}
out:
free_isula_storage_status_response
(
iresp
);
...
...
src/image/oci/oci_common_operators.c
浏览文件 @
025712e7
...
...
@@ -58,73 +58,6 @@ bool oci_detect(const char *image_name)
return
oci_image_exist
(
image_name
);
}
// format: [status xx: val]
static
int
get_graphdriver_status_line_value
(
const
char
*
line
,
char
**
start
,
char
**
end
)
{
char
*
pstart
=
NULL
;
char
*
pend
=
NULL
;
pstart
=
strchr
(
line
,
':'
);
if
(
pstart
==
NULL
)
{
ERROR
(
"Invalid output: %s"
,
line
);
return
-
1
;
}
pstart
++
;
if
(
*
pstart
!=
' '
)
{
ERROR
(
"Invalid output: %s"
,
line
);
return
-
1
;
}
pstart
++
;
pend
=
strchr
(
pstart
,
'\n'
);
if
(
pend
==
NULL
)
{
ERROR
(
"Invalid output: %s"
,
pstart
);
return
-
1
;
}
*
pend
++
=
'\0'
;
*
start
=
pstart
;
*
end
=
pend
;
return
0
;
}
int
pack_storage_status_response
(
const
char
*
stdout_buffer
,
im_storage_status_response
*
resp
)
{
char
*
pstart
=
NULL
;
char
*
pend
=
NULL
;
int
nret
=
-
1
;
// Backing Filesystem: extfs
if
(
get_graphdriver_status_line_value
(
stdout_buffer
,
&
pstart
,
&
pend
)
!=
0
)
{
goto
free_out
;
}
resp
->
backing_fs
=
util_strdup_s
(
pstart
);
// Supports d_type: true
if
(
get_graphdriver_status_line_value
(
pend
,
&
pstart
,
&
pend
)
!=
0
)
{
goto
free_out
;
}
nret
=
util_str_to_bool
(
pstart
,
&
resp
->
supports_d_type
);
if
(
nret
<
0
)
{
ERROR
(
"Invalid output: %s"
,
pstart
);
goto
free_out
;
}
// Native Overlay Diff: true
if
(
get_graphdriver_status_line_value
(
pend
,
&
pstart
,
&
pend
)
!=
0
)
{
goto
free_out
;
}
nret
=
util_str_to_bool
(
pstart
,
&
resp
->
native_overlay_diff
);
if
(
nret
<
0
)
{
ERROR
(
"Invalid output: %s"
,
pstart
);
goto
free_out
;
}
nret
=
0
;
free_out:
return
nret
;
}
char
*
get_last_part
(
char
**
parts
)
{
char
*
last_part
=
NULL
;
...
...
src/image/oci/oci_common_operators.h
浏览文件 @
025712e7
...
...
@@ -24,7 +24,6 @@
extern
"C"
{
#endif
int
pack_storage_status_response
(
const
char
*
stdout_buffer
,
im_storage_status_response
*
resp
);
char
*
oci_normalize_image_name
(
const
char
*
name
);
bool
oci_detect
(
const
char
*
image_name
);
...
...
src/json/schema/schema/host/info-response.json
浏览文件 @
025712e7
...
...
@@ -62,6 +62,12 @@
"no_proxy"
:
{
"type"
:
"string"
},
"driver_name"
:
{
"type"
:
"string"
},
"driver_status"
:
{
"type"
:
"string"
},
"cc"
:
{
"type"
:
"uint32"
},
...
...
src/libisula.h
浏览文件 @
025712e7
...
...
@@ -529,6 +529,8 @@ struct isula_info_response {
char
*
http_proxy
;
char
*
https_proxy
;
char
*
no_proxy
;
char
*
driver_name
;
char
*
driver_status
;
uint32_t
total_mem
;
uint32_t
containers_num
;
uint32_t
c_running
;
...
...
src/services/execution/execute/execution_information.c
浏览文件 @
025712e7
...
...
@@ -198,6 +198,8 @@ static int isulad_info_cb(const host_info_request *request, host_info_response *
struct
utsname
u
;
im_image_count_request
*
im_request
=
NULL
;
char
*
rootpath
=
NULL
;
char
*
graph_driver
=
NULL
;
struct
graphdriver_status
*
driver_status
=
NULL
;
DAEMON_CLEAR_ERRMSG
();
...
...
@@ -228,6 +230,19 @@ static int isulad_info_cb(const host_info_request *request, host_info_response *
}
#ifdef ENABLE_OCI_IMAGE
im_request
->
type
=
util_strdup_s
(
IMAGE_TYPE_OCI
);
graph_driver
=
conf_get_isulad_storage_driver
();
if
(
graph_driver
==
NULL
)
{
ERROR
(
"Failed to get graph driver name info!"
);
goto
pack_response
;
}
driver_status
=
graphdriver_get_status
();
if
(
driver_status
==
NULL
)
{
ERROR
(
"Failed to get graph driver status info!"
);
cc
=
ISULAD_ERR_EXEC
;
goto
pack_response
;
}
#endif
images_num
=
im_get_image_count
(
im_request
);
...
...
@@ -308,12 +323,18 @@ static int isulad_info_cb(const host_info_request *request, host_info_response *
(
*
response
)
->
http_proxy
=
util_strdup_s
(
http_proxy
);
(
*
response
)
->
https_proxy
=
util_strdup_s
(
https_proxy
);
(
*
response
)
->
no_proxy
=
util_strdup_s
(
no_proxy
);
#ifdef ENABLE_OCI_IMAGE
(
*
response
)
->
driver_name
=
util_strdup_s
(
graph_driver
);
(
*
response
)
->
driver_status
=
util_strdup_s
(
driver_status
->
status
);
#endif
pack_response:
if
(
*
response
!=
NULL
)
{
(
*
response
)
->
cc
=
cc
;
}
free
(
rootpath
);
free
(
graph_driver
);
free_graphdriver_status
(
driver_status
);
free
(
huge_page_size
);
free
(
operating_system
);
free_im_image_count_request
(
im_request
);
...
...
src/services/graphdriver/CMakeLists.txt
浏览文件 @
025712e7
# get current directory sources files
aux_source_directory
(
${
CMAKE_CURRENT_SOURCE_DIR
}
local_graphdriver_srcs
)
add_subdirectory
(
overlay2
)
add_subdirectory
(
devmapper
)
set
(
GRAPHDRIVER_SRCS
${
local_graphdriver_srcs
}
${
OVERLAY2_SRCS
}
${
DEVMAPPER_SRCS
}
PARENT_SCOPE
)
set
(
GRAPHDRIVER_INCS
${
CMAKE_CURRENT_SOURCE_DIR
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/overlay2
${
CMAKE_CURRENT_SOURCE_DIR
}
/devmapper
PARENT_SCOPE
)
src/services/graphdriver/devmapper/CMakeLists.txt
0 → 100644
浏览文件 @
025712e7
# get current directory sources files
aux_source_directory
(
${
CMAKE_CURRENT_SOURCE_DIR
}
local_devmapper_srcs
)
set
(
DEVMAPPER_SRCS
${
local_devmapper_srcs
}
PARENT_SCOPE
)
src/services/graphdriver/devmapper/driver_devmapper.c
0 → 100644
浏览文件 @
025712e7
/******************************************************************************
* Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
* iSulad licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
* Author: wangfengtu
* Create: 2020-01-19
* Description: provide devicemapper graphdriver function definition
******************************************************************************/
#include "driver_devmapper.h"
#include <string.h>
#include <stdlib.h>
#include <limits.h>
#include "libisulad.h"
#include "utils.h"
#define DM_LOG_FATAL 2
#define DM_LOG_DEBUG 7
int
devmapper_init
(
struct
graphdriver
*
driver
)
{
return
0
;
}
bool
devmapper_is_quota_options
(
struct
graphdriver
*
driver
,
const
char
*
option
)
{
return
false
;
}
int
devmapper_parse_options
(
struct
graphdriver
*
driver
,
const
char
**
options
,
size_t
options_len
)
{
size_t
i
=
0
;
for
(
i
=
0
;
options
!=
NULL
&&
i
<
options_len
;
i
++
)
{
char
*
dup
=
NULL
;
char
*
p
=
NULL
;
char
*
val
=
NULL
;
int
ret
=
0
;
dup
=
util_strdup_s
(
options
[
i
]);
if
(
dup
==
NULL
)
{
isulad_set_error_message
(
"Out of memory"
);
return
-
1
;
}
p
=
strchr
(
dup
,
'='
);
if
(
!
p
)
{
isulad_set_error_message
(
"Unable to parse key/value option: '%s'"
,
dup
);
free
(
dup
);
return
-
1
;
}
*
p
=
'\0'
;
val
=
p
+
1
;
if
(
strcasecmp
(
dup
,
"dm.fs"
)
==
0
)
{
if
(
strcmp
(
val
,
"ext4"
))
{
isulad_set_error_message
(
"Invalid filesystem: '%s': not supported"
,
val
);
ret
=
-
1
;
}
}
else
if
(
strcasecmp
(
dup
,
"dm.thinpooldev"
)
==
0
)
{
if
(
!
strcmp
(
val
,
""
))
{
isulad_set_error_message
(
"Invalid thinpool device, it must not be empty"
);
ret
=
-
1
;
}
}
else
if
(
strcasecmp
(
dup
,
"dm.min_free_space"
)
==
0
)
{
long
converted
=
0
;
ret
=
util_parse_percent_string
(
val
,
&
converted
);
if
(
ret
!=
0
)
{
isulad_set_error_message
(
"Invalid min free space: '%s': %s"
,
val
,
strerror
(
-
ret
));
}
}
else
if
(
strcasecmp
(
dup
,
"dm.basesize"
)
==
0
)
{
int64_t
converted
=
0
;
ret
=
util_parse_byte_size_string
(
val
,
&
converted
);
if
(
ret
!=
0
)
{
isulad_set_error_message
(
"Invalid size: '%s': %s"
,
val
,
strerror
(
-
ret
));
}
}
else
if
(
strcasecmp
(
dup
,
"dm.mkfsarg"
)
==
0
||
strcasecmp
(
dup
,
"dm.mountopt"
)
==
0
)
{
/* We have no way to check validation here, validation is checked when using them. */
}
else
{
isulad_set_error_message
(
"devicemapper: unknown option: '%s'"
,
dup
);
ret
=
-
1
;
}
free
(
dup
);
if
(
ret
!=
0
)
{
return
ret
;
}
}
return
0
;
}
src/services/graphdriver/devmapper/driver_devmapper.h
0 → 100644
浏览文件 @
025712e7
/******************************************************************************
* Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.
* iSulad licensed under the Mulan PSL v1.
* You can use this software according to the terms and conditions of the Mulan PSL v1.
* You may obtain a copy of Mulan PSL v1 at:
* http://license.coscl.org.cn/MulanPSL
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
* PURPOSE.
* See the Mulan PSL v1 for more details.
* Author: wangfengtu
* Create: 2020-01-19
* Description: provide devicemapper graphdriver function definition
******************************************************************************/
#ifndef __GRAPHDRIVER_DEVMAPPER_H
#define __GRAPHDRIVER_DEVMAPPER_H
#include "driver.h"
#ifdef __cplusplus
extern
"C"
{
#endif
int
devmapper_init
(
struct
graphdriver
*
driver
);
int
devmapper_parse_options
(
struct
graphdriver
*
driver
,
const
char
**
options
,
size_t
options_len
);
bool
devmapper_is_quota_options
(
struct
graphdriver
*
driver
,
const
char
*
option
);
#ifdef __cplusplus
}
#endif
#endif
src/services/graphdriver/driver.c
浏览文件 @
025712e7
...
...
@@ -20,6 +20,7 @@
#include <linux/limits.h>
#include "driver_overlay2.h"
#include "driver_devmapper.h"
#include "utils.h"
#include "libisulad.h"
#include "log.h"
...
...
@@ -35,8 +36,18 @@ static const struct graphdriver_ops g_overlay2_ops = {
.
is_quota_options
=
overlay2_is_quota_options
,
};
/* devicemapper */
#define DRIVER_DEVMAPPER_NAME "devicemapper"
static
const
struct
graphdriver_ops
g_devmapper_ops
=
{
.
init
=
devmapper_init
,
.
parse_options
=
devmapper_parse_options
,
.
is_quota_options
=
devmapper_is_quota_options
,
};
static
struct
graphdriver
g_drivers
[]
=
{
{.
name
=
DRIVER_OVERLAY2_NAME
,
.
ops
=
&
g_overlay2_ops
}
{.
name
=
DRIVER_OVERLAY2_NAME
,
.
ops
=
&
g_overlay2_ops
},
{.
name
=
DRIVER_DEVMAPPER_NAME
,
.
ops
=
&
g_devmapper_ops
}
};
static
const
size_t
g_numdrivers
=
sizeof
(
g_drivers
)
/
sizeof
(
struct
graphdriver
);
...
...
@@ -101,8 +112,7 @@ struct graphdriver_status *graphdriver_get_status(void)
}
status
->
backing_fs
=
util_strdup_s
(
resp
->
backing_fs
);
status
->
supports_d_type
=
resp
->
supports_d_type
;
status
->
native_overlay_diff
=
resp
->
native_overlay_diff
;
status
->
status
=
util_strdup_s
(
resp
->
status
);
ret
=
0
;
free_out:
...
...
@@ -178,6 +188,7 @@ void free_graphdriver_status(struct graphdriver_status *status)
return
;
}
free
(
status
->
backing_fs
);
free
(
status
->
status
);
free
(
status
);
}
src/services/graphdriver/driver.h
浏览文件 @
025712e7
...
...
@@ -41,8 +41,7 @@ struct graphdriver {
struct
graphdriver_status
{
char
*
backing_fs
;
bool
supports_d_type
;
bool
native_overlay_diff
;
char
*
status
;
};
struct
graphdriver
*
graphdriver_init
(
const
char
*
name
,
char
**
storage_opts
,
size_t
storage_opts_len
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录