Merge pull request #1274 from pdebski21/try_add_missing_cache_id_param

Add core, try-add script missing core-id parameter fix
This commit is contained in:
Robert Baldyga 2022-07-14 12:37:57 +02:00 committed by GitHub
commit d72cdf5251
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -1640,6 +1640,11 @@ int add_core(unsigned int cache_id, unsigned int core_id, const char *core_devic
const char *core_path; /* core path sent down to kernel */
const char *user_core_path; /* core path provided by user */
if (try_add && core_id == OCF_CORE_ID_INVALID) {
cas_printf(LOG_ERR, "Option '--core-id' is missing\n");
return FAILURE;
}
/* Check if core device provided is valid */
fd = open(core_device, 0);
if (fd < 0) {

View File

@ -1179,7 +1179,10 @@ int cache_mngt_prepare_core_cfg(struct ocf_mngt_core_config *cfg,
if (strnlen(cmd_info->core_path_name, MAX_STR_LEN) >= MAX_STR_LEN)
return -OCF_ERR_INVAL;
if (cmd_info->try_add && cmd_info->core_id == OCF_CORE_MAX)
return -OCF_ERR_INVAL;
result = mngt_get_cache_by_id(cas_ctx, cmd_info->cache_id, &cache);
if (result && result != -OCF_ERR_CACHE_NOT_EXIST) {
return result;