[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 32/65] migration/rdma: Return -1 instead of negative errno code
|
From: |
Juan Quintela |
|
Subject: |
[PULL 32/65] migration/rdma: Return -1 instead of negative errno code |
|
Date: |
Wed, 11 Oct 2023 11:21:30 +0200 |
From: Markus Armbruster <armbru@redhat.com>
Several functions return negative errno codes on failure. Callers
check for specific codes exactly never. For some of the functions,
callers couldn't check even if they wanted to, because the functions
also return negative values that aren't errno codes, leaving readers
confused on what the function actually returns.
Clean up and simplify: return -1 instead of negative errno code.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Li Zhijian <lizhijian@fujitsu.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Juan Quintela <quintela@redhat.com>
Message-ID: <20230928132019.2544702-26-armbru@redhat.com>
---
migration/rdma.c | 44 ++++++++++++++++++++++----------------------
1 file changed, 22 insertions(+), 22 deletions(-)
diff --git a/migration/rdma.c b/migration/rdma.c
index dd0b073792..bc39b7ab2e 100644
--- a/migration/rdma.c
+++ b/migration/rdma.c
@@ -863,14 +863,14 @@ static int qemu_rdma_broken_ipv6_kernel(struct
ibv_context *verbs, Error **errp)
} else {
error_setg_errno(errp, errno,
"could not open RDMA device context");
- return -EINVAL;
+ return -1;
}
}
if (ibv_query_port(verbs, 1, &port_attr)) {
ibv_close_device(verbs);
ERROR(errp, "Could not query initial IB port");
- return -EINVAL;
+ return -1;
}
if (port_attr.link_layer == IBV_LINK_LAYER_INFINIBAND) {
@@ -895,7 +895,7 @@ static int qemu_rdma_broken_ipv6_kernel(struct ibv_context
*verbs, Error **errp)
ERROR(errp, "You only have RoCE / iWARP devices in your
systems"
" and your management software has specified
'[::]'"
", but IPv6 over RoCE / iWARP is not supported in
Linux.");
- return -ENONET;
+ return -1;
}
}
@@ -911,13 +911,13 @@ static int qemu_rdma_broken_ipv6_kernel(struct
ibv_context *verbs, Error **errp)
/* IB ports start with 1, not 0 */
if (ibv_query_port(verbs, 1, &port_attr)) {
ERROR(errp, "Could not query initial IB port");
- return -EINVAL;
+ return -1;
}
if (port_attr.link_layer == IBV_LINK_LAYER_ETHERNET) {
ERROR(errp, "Linux kernel's RoCE / iWARP does not support IPv6 "
"(but patches on linux-rdma in progress)");
- return -ENONET;
+ return -1;
}
#endif
@@ -1425,7 +1425,7 @@ static int qemu_rdma_unregister_waiting(RDMAContext *rdma)
* this series.
*/
perror("unregistration chunk failed");
- return -ret;
+ return -1;
}
rdma->total_registrations--;
@@ -1570,7 +1570,7 @@ static int qemu_rdma_wait_comp_channel(RDMAContext *rdma,
if (ret) {
error_report("failed to get cm event while wait "
"completion channel");
- return -EPIPE;
+ return -1;
}
error_report("receive cm event while wait comp channel,"
@@ -1578,7 +1578,7 @@ static int qemu_rdma_wait_comp_channel(RDMAContext *rdma,
if (cm_event->event == RDMA_CM_EVENT_DISCONNECTED ||
cm_event->event == RDMA_CM_EVENT_DEVICE_REMOVAL) {
rdma_ack_cm_event(cm_event);
- return -EPIPE;
+ return -1;
}
rdma_ack_cm_event(cm_event);
}
@@ -1591,18 +1591,18 @@ static int qemu_rdma_wait_comp_channel(RDMAContext
*rdma,
* I don't trust errno from qemu_poll_ns
*/
error_report("%s: poll failed", __func__);
- return -EPIPE;
+ return -1;
}
if (migrate_get_current()->state == MIGRATION_STATUS_CANCELLING) {
/* Bail out and let the cancellation happen */
- return -EPIPE;
+ return -1;
}
}
}
if (rdma->received_error) {
- return -EPIPE;
+ return -1;
}
return rdma->error_state;
}
@@ -1772,7 +1772,7 @@ static int qemu_rdma_post_send_control(RDMAContext *rdma,
uint8_t *buf,
if (ret > 0) {
error_report("Failed to use post IB SEND for control");
- return -ret;
+ return -1;
}
ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_SEND_CONTROL, NULL);
@@ -1841,15 +1841,15 @@ static int qemu_rdma_exchange_get_response(RDMAContext
*rdma,
if (head->type == RDMA_CONTROL_ERROR) {
rdma->received_error = true;
}
- return -EIO;
+ return -1;
}
if (head->len > RDMA_CONTROL_MAX_BUFFER - sizeof(*head)) {
error_report("too long length: %d", head->len);
- return -EINVAL;
+ return -1;
}
if (sizeof(*head) + head->len != byte_len) {
error_report("Malformed length: %d byte_len %d", head->len, byte_len);
- return -EINVAL;
+ return -1;
}
return 0;
@@ -2115,7 +2115,7 @@ retry:
(uint8_t *) &comp, NULL, NULL, NULL);
if (ret < 0) {
- return -EIO;
+ return -1;
}
/*
@@ -2159,7 +2159,7 @@ retry:
&sge.lkey, NULL, chunk,
chunk_start, chunk_end)) {
error_report("cannot get lkey");
- return -EINVAL;
+ return -1;
}
reg_result = (RDMARegisterResult *)
@@ -2178,7 +2178,7 @@ retry:
&sge.lkey, NULL, chunk,
chunk_start, chunk_end)) {
error_report("cannot get lkey!");
- return -EINVAL;
+ return -1;
}
}
@@ -2190,7 +2190,7 @@ retry:
&sge.lkey, NULL, chunk,
chunk_start, chunk_end)) {
error_report("cannot get lkey!");
- return -EINVAL;
+ return -1;
}
}
@@ -2237,7 +2237,7 @@ retry:
* in this series.
*/
perror("rdma migration: post rdma write failed");
- return -ret;
+ return -1;
}
set_bit(chunk, block->transit_bitmap);
@@ -2969,14 +2969,14 @@ static int qemu_rdma_drain_cq(RDMAContext *rdma)
int ret;
if (qemu_rdma_write_flush(rdma) < 0) {
- return -EIO;
+ return -1;
}
while (rdma->nb_sent) {
ret = qemu_rdma_block_for_wrid(rdma, RDMA_WRID_RDMA_WRITE, NULL);
if (ret < 0) {
error_report("rdma migration: complete polling error!");
- return -EIO;
+ return -1;
}
}
--
2.41.0
- [PULL 23/65] migration/rdma: Fix or document problematic uses of errno, (continued)
- [PULL 23/65] migration/rdma: Fix or document problematic uses of errno, Juan Quintela, 2023/10/11
- [PULL 24/65] migration/rdma: Ditch useless numeric error codes in error messages, Juan Quintela, 2023/10/11
- [PULL 31/65] migration/rdma: Fix rdma_getaddrinfo() error checking, Juan Quintela, 2023/10/11
- [PULL 34/65] migration/rdma: Replace int error_state by bool errored, Juan Quintela, 2023/10/11
- [PULL 33/65] migration/rdma: Dumb down remaining int error values to -1, Juan Quintela, 2023/10/11
- [PULL 22/65] migration/rdma: Use bool for two RDMAContext flags, Juan Quintela, 2023/10/11
- [PULL 25/65] migration/rdma: Fix io_writev(), io_readv() methods to obey contract, Juan Quintela, 2023/10/11
- [PULL 29/65] migration/rdma: Drop dead qemu_rdma_data_init() code for !@host_port, Juan Quintela, 2023/10/11
- [PULL 30/65] migration/rdma: Fix QEMUFileHooks method return values, Juan Quintela, 2023/10/11
- [PULL 26/65] migration/rdma: Replace dangerous macro CHECK_ERROR_STATE(), Juan Quintela, 2023/10/11
- [PULL 32/65] migration/rdma: Return -1 instead of negative errno code,
Juan Quintela <=
- [PULL 27/65] migration/rdma: Fix qemu_rdma_broken_ipv6_kernel() to set error, Juan Quintela, 2023/10/11
- [PULL 37/65] migration/rdma: Plug a memory leak and improve a message, Juan Quintela, 2023/10/11
- [PULL 36/65] migration/rdma: Check negative error values the same way everywhere, Juan Quintela, 2023/10/11
- [PULL 35/65] migration/rdma: Drop superfluous assignments to @ret, Juan Quintela, 2023/10/11
- [PULL 38/65] migration/rdma: Delete inappropriate error_report() in macro ERROR(), Juan Quintela, 2023/10/11
- [PULL 41/65] migration/rdma: Drop "@errp is clear" guards around error_setg(), Juan Quintela, 2023/10/11
- [PULL 43/65] migration/rdma: Convert qemu_rdma_exchange_send() to Error, Juan Quintela, 2023/10/11
- [PULL 39/65] migration/rdma: Retire macro ERROR(), Juan Quintela, 2023/10/11
- [PULL 44/65] migration/rdma: Convert qemu_rdma_exchange_get_response() to Error, Juan Quintela, 2023/10/11
- [PULL 40/65] migration/rdma: Fix error handling around rdma_getaddrinfo(), Juan Quintela, 2023/10/11