Skip to content

Commit

Permalink
Merge pull request #534 from tasleson/prep_new_release
Browse files Browse the repository at this point in the history
Prep new release
  • Loading branch information
tasleson authored May 13, 2024
2 parents 5b1d9da + 90aaf7f commit 2ab6760
Show file tree
Hide file tree
Showing 19 changed files with 124 additions and 84 deletions.
20 changes: 0 additions & 20 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,6 @@ jobs:
- run:
command: cd libstoragemgmt && git checkout $GHBR && ./test/docker_ci_test.sh
no_output_timeout: 20m
el7:
docker:
- image: centos:7
environment:
GHURL: << pipeline.project.git_url >>
GHBR: << pipeline.git.branch >>
steps:
- run:
command: yum install -y git yum-plugin-copr
no_output_timeout: 20m
- run:
command: yum copr enable -y tasleson/ledmon-upstream
no_output_timeout: 20m
- run:
command: git clone $GHURL
no_output_timeout: 5m
- run:
command: cd libstoragemgmt && git checkout $GHBR && ./test/docker_ci_test.sh
no_output_timeout: 20m
el8:
docker:
- image: oraclelinux:8
Expand All @@ -63,5 +44,4 @@ workflows:
workflow:
jobs:
- fedora
- el7
- el8
8 changes: 8 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
News for libStorageMgmt

1.10.0: May 7 2024
* Fix hashlib.md5 usage
* Fix megaraid plugin for hba-mode
* Use ledmon library for controlling LED
* Add LED API interface for LED slot identifiers
* Fix megaraid plugin when no disks are attached
* smi-s plugin fix error message

1.9.8: Apr 17 2023
* FIPS correction
https://github.com/libstorage/libstoragemgmt/pull/528
Expand Down
1 change: 0 additions & 1 deletion c_binding/libsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,6 @@ int _sg_parse_vpd_83(char *err_msg, uint8_t *vpd_data,

(*dps)[*dp_count] = dp;
++*dp_count;
dp = NULL;
}

out:
Expand Down
1 change: 0 additions & 1 deletion c_binding/lsm_datatypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,6 @@ static lsm_string_list *standardize_init_list(lsm_string_list *initiators) {
break;
}
free(wwpn);
wwpn = NULL;
}
}
}
Expand Down
32 changes: 22 additions & 10 deletions c_binding/lsm_ipc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,15 @@ int Transport::msg_send(const std::string &msg, int &error_code) {
ssize_t msg_size = data.size();

while (written < msg_size) {
int wrote = send(s, data.c_str() + written, (msg_size - written),
MSG_NOSIGNAL); // Prevent SIGPIPE on write
ssize_t wrote =
send(s, data.c_str() + written, (msg_size - written),
MSG_NOSIGNAL); // Prevent SIGPIPE on write
if (wrote != -1) {
written += wrote;
ssize_t t = written;
if (__builtin_add_overflow(t, wrote, &written)) {
error_code = EOVERFLOW;
break;
}
} else {
error_code = errno;
break;
Expand All @@ -67,19 +72,23 @@ int Transport::msg_send(const std::string &msg, int &error_code) {
return rc;
}

static std::string string_read(int fd, size_t count, int &error_code) {
static std::string string_read(int fd, ssize_t count, int &error_code) {
char buff[4096];
size_t amount_read = 0;
ssize_t amount_read = 0;
std::string rc = "";

error_code = 0;

while (amount_read < count) {
ssize_t rd =
recv(fd, buff, std::min(sizeof(buff), (count - amount_read)),
MSG_WAITALL);
ssize_t rd = recv(
fd, buff, std::min((ssize_t)(sizeof(buff)), (count - amount_read)),
MSG_WAITALL);
if (rd > 0) {
amount_read += rd;
ssize_t t = amount_read;
if (__builtin_add_overflow(t, rd, &amount_read)) {
error_code = EOVERFLOW;
break;
}
rc += std::string(buff, rd);
} else {
error_code = errno;
Expand All @@ -101,7 +110,10 @@ std::string Transport::msg_recv(int &error_code) {
if (len.size() && error_code == 0) {
payload_len = strtoul(len.c_str(), NULL, 10);
if (payload_len < 0x80000000) { /* Should be big enough */
msg = string_read(s, payload_len, error_code);
ssize_t len = payload_len;
msg = string_read(s, len, error_code);
} else {
error_code = EOVERFLOW;
}
// fprintf(stderr, "<<< %s\n", msg.c_str());
}
Expand Down
19 changes: 12 additions & 7 deletions c_binding/lsm_local_disk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,7 @@ int ledlib_set(const char *disk_path, lsm_error **lsm_err, int led_state) {
desired_state = current_state;

switch (current_state) {
case LED_IBPI_PATTERN_LOCATE_AND_FAIL:
case LED_IBPI_PATTERN_LOCATE_AND_FAILED_DRIVE:
// Both LEDs currently illuminated
if (led_state == LSM_DISK_LED_STATUS_IDENT_OFF) {
desired_state = LED_IBPI_PATTERN_FAILED_DRIVE;
Expand All @@ -1142,7 +1142,7 @@ int ledlib_set(const char *disk_path, lsm_error **lsm_err, int led_state) {
desired_state = LED_IBPI_PATTERN_NORMAL;
break;
case LSM_DISK_LED_STATUS_FAULT_ON:
desired_state = LED_IBPI_PATTERN_LOCATE_AND_FAIL;
desired_state = LED_IBPI_PATTERN_LOCATE_AND_FAILED_DRIVE;
break;
case LSM_DISK_LED_STATUS_FAULT_OFF:
desired_state = current_state;
Expand All @@ -1153,7 +1153,7 @@ int ledlib_set(const char *disk_path, lsm_error **lsm_err, int led_state) {
// FAULT is currently on, IDENT off
switch (led_state) {
case LSM_DISK_LED_STATUS_IDENT_ON:
desired_state = LED_IBPI_PATTERN_LOCATE_AND_FAIL;
desired_state = LED_IBPI_PATTERN_LOCATE_AND_FAILED_DRIVE;
break;
case LSM_DISK_LED_STATUS_IDENT_OFF:
desired_state = current_state;
Expand Down Expand Up @@ -1244,6 +1244,8 @@ static void _sysfs_sas_addr_get(const char *blk_name, char *tp_sas_addr) {
_SG_T10_SPL_SAS_ADDR_LEN);

out:
/* ensure sas addr is always nul terminated */
tp_sas_addr[_SG_T10_SPL_SAS_ADDR_LEN - 1] = '\0';
free(sysfs_sas_path);
}

Expand Down Expand Up @@ -1271,6 +1273,8 @@ static int _sas_addr_get(char *err_msg, const char *disk_path,
}

out:
/* regardless of how to finish, ensure string is always null terminated */
tp_sas_addr[_SG_T10_SPL_SAS_ADDR_LEN - 1] = '\0';
if (fd >= 0)
close(fd);
return rc;
Expand Down Expand Up @@ -1302,7 +1306,7 @@ int LSM_DLL_EXPORT lsm_local_disk_led_status_get(const char *disk_path,
*led_status = 0;
led_state = led_slot_state(slot_entry);
switch (led_state) {
case LED_IBPI_PATTERN_LOCATE_AND_FAIL:
case LED_IBPI_PATTERN_LOCATE_AND_FAILED_DRIVE:
*led_status = LSM_DISK_LED_STATUS_IDENT_ON;
*led_status |= LSM_DISK_LED_STATUS_FAULT_ON;
break;
Expand Down Expand Up @@ -1536,6 +1540,7 @@ int lsm_led_slot_iterator_get(lsm_led_handle *handle,
if (led_rc != LED_STATUS_SUCCESS) {
*lsm_err = translate_led_to_lsm(
led_rc, "Unexpected return for 'led_slots_get'");
free(itr);
return LSM_ERR_LIB_BUG;
}

Expand Down Expand Up @@ -1606,7 +1611,7 @@ uint32_t lsm_led_slot_status_get(lsm_led_slot *slot) {
(LSM_DISK_LED_STATUS_FAULT_ON | LSM_DISK_LED_STATUS_IDENT_OFF);
break;
}
case (LED_IBPI_PATTERN_LOCATE_AND_FAIL): {
case (LED_IBPI_PATTERN_LOCATE_AND_FAILED_DRIVE): {
translated =
(LSM_DISK_LED_STATUS_IDENT_ON | LSM_DISK_LED_STATUS_FAULT_ON);
}
Expand Down Expand Up @@ -1643,7 +1648,7 @@ int lsm_led_slot_status_set(lsm_led_handle *handle, lsm_led_slot *slot,
break;
}
case (LSM_DISK_LED_STATUS_FAULT_ON): {
state = LED_IBPI_PATTERN_LOCATE_AND_FAIL;
state = LED_IBPI_PATTERN_LOCATE_AND_FAILED_DRIVE;
break;
}
case (LSM_DISK_LED_STATUS_IDENT_OFF): {
Expand All @@ -1668,7 +1673,7 @@ int lsm_led_slot_status_set(lsm_led_handle *handle, lsm_led_slot *slot,
break;
}
case (LSM_DISK_LED_STATUS_IDENT_ON | LSM_DISK_LED_STATUS_FAULT_ON): {
state = LED_IBPI_PATTERN_LOCATE_AND_FAIL;
state = LED_IBPI_PATTERN_LOCATE_AND_FAILED_DRIVE;
break;
}
default:
Expand Down
31 changes: 16 additions & 15 deletions c_binding/lsm_mgmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,16 +363,17 @@ int lsm_plugin_info_get(lsm_connect *c, char **desc, char **version,

if (!*desc || !*version) {
rc = LSM_ERR_NO_MEMORY;
free(*desc);
free(*version);
}
}
} catch (const ValueException &ve) {
rc = log_exception(c, LSM_ERR_PLUGIN_BUG, "Unexpected type", ve.what());
}

if (rc != LSM_ERR_OK) {
free(*desc);
*desc = NULL;
free(*version);
*version = NULL;
rc = log_exception(c, LSM_ERR_PLUGIN_BUG, "Unexpected type", ve.what());
}

return rc;
Expand Down Expand Up @@ -1064,8 +1065,8 @@ int lsm_volume_create(lsm_connect *c, lsm_pool *pool, const char *volumeName,

int rc = rpc(c, "volume_create", parameters, response);
if (LSM_ERR_OK == rc) {
*newVolume = (lsm_volume *)parse_job_response(c, response, rc, job,
(convert)value_to_volume);
*newVolume = (lsm_volume *)parse_job_response(
c, std::move(response), rc, job, (convert)value_to_volume);
}
return rc;
}
Expand Down Expand Up @@ -1094,7 +1095,7 @@ int lsm_volume_resize(lsm_connect *c, lsm_volume *volume, uint64_t newSize,
int rc = rpc(c, "volume_resize", parameters, response);
if (LSM_ERR_OK == rc) {
*resizedVolume = (lsm_volume *)parse_job_response(
c, response, rc, job, (convert)value_to_volume);
c, std::move(response), rc, job, (convert)value_to_volume);
}
return rc;
}
Expand Down Expand Up @@ -1127,7 +1128,7 @@ int lsm_volume_replicate(lsm_connect *c, lsm_pool *pool,
int rc = rpc(c, "volume_replicate", parameters, response);
if (LSM_ERR_OK == rc) {
*newReplicant = (lsm_volume *)parse_job_response(
c, response, rc, job, (convert)value_to_volume);
c, std::move(response), rc, job, (convert)value_to_volume);
}
return rc;
}
Expand Down Expand Up @@ -1363,7 +1364,7 @@ int lsm_access_group_create(lsm_connect *c, const char *name,

std::map<std::string, Value> p;
p["name"] = Value(name);
p["init_id"] = id;
p["init_id"] = std::move(id);
p["init_type"] = Value((int32_t)init_type);
p["system"] = system_to_value(system);
p["flags"] = Value(flags);
Expand Down Expand Up @@ -1428,7 +1429,7 @@ static int _lsm_ag_add_delete(lsm_connect *c, lsm_access_group *access_group,

std::map<std::string, Value> p;
p["access_group"] = access_group_to_value(access_group);
p["init_id"] = id;
p["init_id"] = std::move(id);
p["init_type"] = Value((int32_t)init_type);
p["flags"] = Value(flags);

Expand Down Expand Up @@ -1796,7 +1797,7 @@ int lsm_fs_create(lsm_connect *c, lsm_pool *pool, const char *name,

int rc = rpc(c, "fs_create", parameters, response);
if (LSM_ERR_OK == rc) {
*fs = (lsm_fs *)parse_job_response(c, response, rc, job,
*fs = (lsm_fs *)parse_job_response(c, std::move(response), rc, job,
(convert)value_to_fs);
}
return rc;
Expand Down Expand Up @@ -1842,7 +1843,7 @@ int lsm_fs_resize(lsm_connect *c, lsm_fs *fs, uint64_t new_size_bytes,

int rc = rpc(c, "fs_resize", parameters, response);
if (LSM_ERR_OK == rc) {
*rfs = (lsm_fs *)parse_job_response(c, response, rc, job,
*rfs = (lsm_fs *)parse_job_response(c, std::move(response), rc, job,
(convert)value_to_fs);
}
return rc;
Expand All @@ -1869,8 +1870,8 @@ int lsm_fs_clone(lsm_connect *c, lsm_fs *src_fs, const char *name,

int rc = rpc(c, "fs_clone", parameters, response);
if (LSM_ERR_OK == rc) {
*cloned_fs = (lsm_fs *)parse_job_response(c, response, rc, job,
(convert)value_to_fs);
*cloned_fs = (lsm_fs *)parse_job_response(c, std::move(response), rc,
job, (convert)value_to_fs);
}
return rc;
}
Expand Down Expand Up @@ -2046,8 +2047,8 @@ int lsm_fs_ss_create(lsm_connect *c, lsm_fs *fs, const char *name,

int rc = rpc(c, "fs_snapshot_create", parameters, response);
if (LSM_ERR_OK == rc) {
*snapshot = (lsm_fs_ss *)parse_job_response(c, response, rc, job,
(convert)value_to_ss);
*snapshot = (lsm_fs_ss *)parse_job_response(c, std::move(response), rc,
job, (convert)value_to_ss);
}
return rc;
}
Expand Down
7 changes: 7 additions & 0 deletions c_binding/lsm_value_jsmn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ static int inc_token(int current, int amount, int max) {
Value lsm_parse(jsmntok_t *tok, int start_tok, int end_tok, const char *j,
int *consumed) {

if (!tok) {
throw ValueException(
"Invalid parameter: lsm_parse param 'tok' is null");
}

int i = start_tok;

int len = tok[i].end - tok[i].start;
Expand Down Expand Up @@ -293,10 +298,12 @@ Value Payload::deserialize(const std::string &json_str) {
if (rc < 0) {
if (JSMN_ERROR_NOMEM == rc) {
free(tok);
tok = NULL;
num_tokens *= 2;
continue;
} else {
free(tok);
tok = NULL;
throw ValueException("In-valid json");
}
}
Expand Down
4 changes: 2 additions & 2 deletions c_binding/uri_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ inline struct uri parse(std::string uri) {
return rc;
}

rc.scheme = scheme_tmp;
rc.scheme = std::move(scheme_tmp);

auto remainder = uri.substr(req + 3);

Expand Down Expand Up @@ -157,7 +157,7 @@ inline struct uri parse(std::string uri) {
}

// Only part left should be host, which is a ipv4, hostname, or ipv6
rc.host = remainder;
rc.host = std::move(remainder);
rc.valid = true;
return rc;
}
Expand Down
12 changes: 3 additions & 9 deletions c_binding/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,12 @@ void _be_raw_to_hex(uint8_t *raw, size_t len, char *out) {
}

bool _file_exists(const char *path) {
int fd = -1;

assert(path != NULL);

fd = open(path, O_RDONLY);
if ((fd == -1) && (errno == ENOENT))
return false;

if (fd >= 0) {
close(fd);
if (access(path, F_OK) == 0) {
return true;
}
return true;
return false;
}

int _read_file(const char *path, uint8_t *buff, ssize_t *size,
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script.
dnl Copyright (C) 2011-2023 Red Hat, Inc.
dnl See COPYING.LIB for the License of this software

AC_INIT([libstoragemgmt],[1.9.8],[[email protected]],[],[https://github.com/libstorage/libstoragemgmt/])
AC_INIT([libstoragemgmt],[1.10.0],[[email protected]],[],[https://github.com/libstorage/libstoragemgmt/])
AC_CONFIG_SRCDIR([configure.ac])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_HEADERS([config.h])
Expand Down
Loading

0 comments on commit 2ab6760

Please sign in to comment.