Support devicemapper
Signed-off-by: WangFengTu <wangfengtu@huawei.com>
This commit is contained in:
parent
368f9f2ca0
commit
4fabc9ffbf
@ -141,11 +141,9 @@ message LoadImageResponose {
|
|||||||
message GraphdriverStatusRequest {}
|
message GraphdriverStatusRequest {}
|
||||||
|
|
||||||
message GraphdriverStatusResponse {
|
message GraphdriverStatusResponse {
|
||||||
string backing_fs = 1;
|
string status = 1;
|
||||||
bool supports_d_type = 2;
|
string errmsg = 2;
|
||||||
bool native_overlay_diff = 3;
|
uint32 cc = 3;
|
||||||
string errmsg = 4;
|
|
||||||
uint32 cc = 5;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message ContainerFsUsageRequest {
|
message ContainerFsUsageRequest {
|
||||||
|
|||||||
@ -376,6 +376,8 @@ message InfoResponse {
|
|||||||
string http_proxy = 20;
|
string http_proxy = 20;
|
||||||
string https_proxy = 21;
|
string https_proxy = 21;
|
||||||
string no_proxy = 22;
|
string no_proxy = 22;
|
||||||
|
string driver_name = 23;
|
||||||
|
string driver_status = 24;
|
||||||
}
|
}
|
||||||
|
|
||||||
message UpdateRequest {
|
message UpdateRequest {
|
||||||
|
|||||||
@ -26,6 +26,31 @@ const char g_cmd_info_usage[] = "info";
|
|||||||
|
|
||||||
struct client_arguments g_cmd_info_args = {};
|
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)
|
static void client_info_server(const struct isula_info_response *response)
|
||||||
{
|
{
|
||||||
printf("Containers: %u\n", (unsigned int)(response->containers_num));
|
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) {
|
if (response->version != NULL) {
|
||||||
printf("Server Version: %s\n", response->version);
|
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) {
|
if (response->logging_driver != NULL) {
|
||||||
printf("Logging Driver: %s\n", response->logging_driver);
|
printf("Logging Driver: %s\n", response->logging_driver);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -105,6 +105,7 @@ public:
|
|||||||
}
|
}
|
||||||
response->total_mem = gresponse->total_mem();
|
response->total_mem = gresponse->total_mem();
|
||||||
get_proxy_info_from_grpc(response, gresponse);
|
get_proxy_info_from_grpc(response, gresponse);
|
||||||
|
get_driver_info_from_grpc(response, gresponse);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -150,6 +151,16 @@ private:
|
|||||||
response->no_proxy = util_strdup_s(gresponse->no_proxy().c_str());
|
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,
|
class ContainerCreate : public ClientBase<ContainerService, ContainerService::Stub, isula_create_request, CreateRequest,
|
||||||
|
|||||||
@ -843,11 +843,9 @@ public:
|
|||||||
}
|
}
|
||||||
resp->server_errono = gresp->cc();
|
resp->server_errono = gresp->cc();
|
||||||
|
|
||||||
if (!gresp->backing_fs().empty()) {
|
if (!gresp->status().empty()) {
|
||||||
resp->backing_fs = util_strdup_s(gresp->backing_fs().c_str());
|
resp->status = util_strdup_s(gresp->status().c_str());
|
||||||
}
|
}
|
||||||
resp->supports_d_type = gresp->supports_d_type();
|
|
||||||
resp->native_overlay_diff = gresp->native_overlay_diff();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -463,8 +463,8 @@ void free_isula_storage_status_response(struct isula_storage_status_response *pt
|
|||||||
if (ptr == NULL) {
|
if (ptr == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
free(ptr->backing_fs);
|
free(ptr->status);
|
||||||
ptr->backing_fs = NULL;
|
ptr->status = NULL;
|
||||||
free(ptr->errmsg);
|
free(ptr->errmsg);
|
||||||
ptr->errmsg = NULL;
|
ptr->errmsg = NULL;
|
||||||
free(ptr);
|
free(ptr);
|
||||||
|
|||||||
@ -223,9 +223,7 @@ struct isula_storage_status_request {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct isula_storage_status_response {
|
struct isula_storage_status_response {
|
||||||
char *backing_fs;
|
char *status;
|
||||||
bool supports_d_type;
|
|
||||||
bool native_overlay_diff;
|
|
||||||
|
|
||||||
char *errmsg;
|
char *errmsg;
|
||||||
uint32_t cc;
|
uint32_t cc;
|
||||||
|
|||||||
@ -218,6 +218,8 @@ private:
|
|||||||
|
|
||||||
int pack_proxy_info_to_grpc(const host_info_response *response, InfoResponse *gresponse);
|
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);
|
int logs_request_from_grpc(const LogsRequest *grequest, struct isulad_logs_request **request);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -110,6 +110,10 @@ int ContainerServiceImpl::info_response_to_grpc(const host_info_response *respon
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pack_driver_info_to_grpc(response, gresponse)) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1109,4 +1113,20 @@ int ContainerServiceImpl::pack_proxy_info_to_grpc(const host_info_response *resp
|
|||||||
return 0;
|
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;
|
||||||
|
}
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <limits.h>
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
@ -266,6 +267,30 @@ int util_parse_byte_size_string(const char *s, int64_t *converted)
|
|||||||
return ret;
|
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)
|
static char **util_shrink_array(char **orig_array, size_t new_size)
|
||||||
{
|
{
|
||||||
char **new_array = NULL;
|
char **new_array = NULL;
|
||||||
|
|||||||
@ -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_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,
|
// 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
|
// 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);
|
char **util_string_split(const char *src_str, char _sep);
|
||||||
|
|||||||
@ -1745,6 +1745,8 @@ void free_im_storage_status_response(im_storage_status_response *ptr)
|
|||||||
}
|
}
|
||||||
free(ptr->backing_fs);
|
free(ptr->backing_fs);
|
||||||
ptr->backing_fs = NULL;
|
ptr->backing_fs = NULL;
|
||||||
|
free(ptr->status);
|
||||||
|
ptr->status = NULL;
|
||||||
free(ptr);
|
free(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -55,8 +55,7 @@ typedef struct {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *backing_fs;
|
char *backing_fs;
|
||||||
bool supports_d_type;
|
char *status;
|
||||||
bool native_overlay_diff;
|
|
||||||
} im_storage_status_response;
|
} im_storage_status_response;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|||||||
@ -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);
|
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;
|
ret = 0;
|
||||||
*count = i;
|
*count = i;
|
||||||
out:
|
out:
|
||||||
|
|||||||
@ -20,11 +20,58 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "log.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);
|
char *pstart = NULL;
|
||||||
resp->supports_d_type = iresp->supports_d_type;
|
char *pend = NULL;
|
||||||
resp->native_overlay_diff = iresp->native_overlay_diff;
|
|
||||||
|
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)
|
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;
|
ret = -1;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
pack_im_response(iresp, resp);
|
ret = pack_im_response(iresp, resp);
|
||||||
|
if (ret != 0) {
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
free_isula_storage_status_response(iresp);
|
free_isula_storage_status_response(iresp);
|
||||||
|
|||||||
@ -58,73 +58,6 @@ bool oci_detect(const char *image_name)
|
|||||||
return oci_image_exist(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 *get_last_part(char **parts)
|
||||||
{
|
{
|
||||||
char *last_part = NULL;
|
char *last_part = NULL;
|
||||||
|
|||||||
@ -24,7 +24,6 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int pack_storage_status_response(const char *stdout_buffer, im_storage_status_response *resp);
|
|
||||||
char *oci_normalize_image_name(const char *name);
|
char *oci_normalize_image_name(const char *name);
|
||||||
|
|
||||||
bool oci_detect(const char *image_name);
|
bool oci_detect(const char *image_name);
|
||||||
|
|||||||
@ -62,6 +62,12 @@
|
|||||||
"no_proxy": {
|
"no_proxy": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"driver_name": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"driver_status": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
"cc": {
|
"cc": {
|
||||||
"type": "uint32"
|
"type": "uint32"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -529,6 +529,8 @@ struct isula_info_response {
|
|||||||
char *http_proxy;
|
char *http_proxy;
|
||||||
char *https_proxy;
|
char *https_proxy;
|
||||||
char *no_proxy;
|
char *no_proxy;
|
||||||
|
char *driver_name;
|
||||||
|
char *driver_status;
|
||||||
uint32_t total_mem;
|
uint32_t total_mem;
|
||||||
uint32_t containers_num;
|
uint32_t containers_num;
|
||||||
uint32_t c_running;
|
uint32_t c_running;
|
||||||
|
|||||||
@ -198,6 +198,8 @@ static int isulad_info_cb(const host_info_request *request, host_info_response *
|
|||||||
struct utsname u;
|
struct utsname u;
|
||||||
im_image_count_request *im_request = NULL;
|
im_image_count_request *im_request = NULL;
|
||||||
char *rootpath = NULL;
|
char *rootpath = NULL;
|
||||||
|
char *graph_driver = NULL;
|
||||||
|
struct graphdriver_status *driver_status = NULL;
|
||||||
|
|
||||||
DAEMON_CLEAR_ERRMSG();
|
DAEMON_CLEAR_ERRMSG();
|
||||||
|
|
||||||
@ -228,6 +230,19 @@ static int isulad_info_cb(const host_info_request *request, host_info_response *
|
|||||||
}
|
}
|
||||||
#ifdef ENABLE_OCI_IMAGE
|
#ifdef ENABLE_OCI_IMAGE
|
||||||
im_request->type = util_strdup_s(IMAGE_TYPE_OCI);
|
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
|
#endif
|
||||||
images_num = im_get_image_count(im_request);
|
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)->http_proxy = util_strdup_s(http_proxy);
|
||||||
(*response)->https_proxy = util_strdup_s(https_proxy);
|
(*response)->https_proxy = util_strdup_s(https_proxy);
|
||||||
(*response)->no_proxy = util_strdup_s(no_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:
|
pack_response:
|
||||||
if (*response != NULL) {
|
if (*response != NULL) {
|
||||||
(*response)->cc = cc;
|
(*response)->cc = cc;
|
||||||
}
|
}
|
||||||
free(rootpath);
|
free(rootpath);
|
||||||
|
free(graph_driver);
|
||||||
|
free_graphdriver_status(driver_status);
|
||||||
free(huge_page_size);
|
free(huge_page_size);
|
||||||
free(operating_system);
|
free(operating_system);
|
||||||
free_im_image_count_request(im_request);
|
free_im_image_count_request(im_request);
|
||||||
|
|||||||
@ -1,14 +1,17 @@
|
|||||||
# get current directory sources files
|
# get current directory sources files
|
||||||
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} local_graphdriver_srcs)
|
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} local_graphdriver_srcs)
|
||||||
add_subdirectory(overlay2)
|
add_subdirectory(overlay2)
|
||||||
|
add_subdirectory(devmapper)
|
||||||
|
|
||||||
set(GRAPHDRIVER_SRCS
|
set(GRAPHDRIVER_SRCS
|
||||||
${local_graphdriver_srcs}
|
${local_graphdriver_srcs}
|
||||||
${OVERLAY2_SRCS}
|
${OVERLAY2_SRCS}
|
||||||
|
${DEVMAPPER_SRCS}
|
||||||
PARENT_SCOPE
|
PARENT_SCOPE
|
||||||
)
|
)
|
||||||
set(GRAPHDRIVER_INCS
|
set(GRAPHDRIVER_INCS
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/overlay2
|
${CMAKE_CURRENT_SOURCE_DIR}/overlay2
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/devmapper
|
||||||
PARENT_SCOPE
|
PARENT_SCOPE
|
||||||
)
|
)
|
||||||
|
|||||||
7
src/services/graphdriver/devmapper/CMakeLists.txt
Normal file
7
src/services/graphdriver/devmapper/CMakeLists.txt
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# get current directory sources files
|
||||||
|
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} local_devmapper_srcs)
|
||||||
|
|
||||||
|
set(DEVMAPPER_SRCS
|
||||||
|
${local_devmapper_srcs}
|
||||||
|
PARENT_SCOPE
|
||||||
|
)
|
||||||
94
src/services/graphdriver/devmapper/driver_devmapper.c
Normal file
94
src/services/graphdriver/devmapper/driver_devmapper.c
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
34
src/services/graphdriver/devmapper/driver_devmapper.h
Normal file
34
src/services/graphdriver/devmapper/driver_devmapper.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* 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
|
||||||
@ -20,6 +20,7 @@
|
|||||||
#include <linux/limits.h>
|
#include <linux/limits.h>
|
||||||
|
|
||||||
#include "driver_overlay2.h"
|
#include "driver_overlay2.h"
|
||||||
|
#include "driver_devmapper.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "libisulad.h"
|
#include "libisulad.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
@ -35,8 +36,18 @@ static const struct graphdriver_ops g_overlay2_ops = {
|
|||||||
.is_quota_options = overlay2_is_quota_options,
|
.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[] = {
|
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);
|
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->backing_fs = util_strdup_s(resp->backing_fs);
|
||||||
status->supports_d_type = resp->supports_d_type;
|
status->status = util_strdup_s(resp->status);
|
||||||
status->native_overlay_diff = resp->native_overlay_diff;
|
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
free_out:
|
free_out:
|
||||||
@ -178,6 +188,7 @@ void free_graphdriver_status(struct graphdriver_status *status)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
free(status->backing_fs);
|
free(status->backing_fs);
|
||||||
|
free(status->status);
|
||||||
free(status);
|
free(status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -41,8 +41,7 @@ struct graphdriver {
|
|||||||
|
|
||||||
struct graphdriver_status {
|
struct graphdriver_status {
|
||||||
char *backing_fs;
|
char *backing_fs;
|
||||||
bool supports_d_type;
|
char *status;
|
||||||
bool native_overlay_diff;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct graphdriver *graphdriver_init(const char *name, char **storage_opts, size_t storage_opts_len);
|
struct graphdriver *graphdriver_init(const char *name, char **storage_opts, size_t storage_opts_len);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user