From 9a6afb11705b5bd6332289d226fae783ffcc0e1d Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Thu, 28 Sep 2023 15:19:35 +0200 Subject: [PATCH] migration/rdma: Fix qemu_rdma_accept() to return failure on errors qemu_rdma_accept() returns 0 in some cases even when it didn't complete its job due to errors. Impact is not obvious. I figure the caller will soon fail again with a misleading error message. Fix it to return -1 on any failure. Signed-off-by: Markus Armbruster Reviewed-by: Fabiano Rosas Reviewed-by: Li Zhijian Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela Message-ID: <20230928132019.2544702-10-armbru@redhat.com> --- migration/rdma.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 1159f990af..8fd1b314b5 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -3360,6 +3360,7 @@ static int qemu_rdma_accept(RDMAContext *rdma) if (cm_event->event != RDMA_CM_EVENT_CONNECT_REQUEST) { rdma_ack_cm_event(cm_event); + ret = -1; goto err_rdma_dest_wait; } @@ -3372,6 +3373,7 @@ static int qemu_rdma_accept(RDMAContext *rdma) rdma_return_path = qemu_rdma_data_init(rdma->host_port, NULL); if (rdma_return_path == NULL) { rdma_ack_cm_event(cm_event); + ret = -1; goto err_rdma_dest_wait; } @@ -3383,10 +3385,11 @@ static int qemu_rdma_accept(RDMAContext *rdma) network_to_caps(&cap); if (cap.version < 1 || cap.version > RDMA_CONTROL_VERSION_CURRENT) { - error_report("Unknown source RDMA version: %d, bailing...", - cap.version); - rdma_ack_cm_event(cm_event); - goto err_rdma_dest_wait; + error_report("Unknown source RDMA version: %d, bailing...", + cap.version); + rdma_ack_cm_event(cm_event); + ret = -1; + goto err_rdma_dest_wait; } /* @@ -3416,9 +3419,10 @@ static int qemu_rdma_accept(RDMAContext *rdma) if (!rdma->verbs) { rdma->verbs = verbs; } else if (rdma->verbs != verbs) { - error_report("ibv context not matching %p, %p!", rdma->verbs, - verbs); - goto err_rdma_dest_wait; + error_report("ibv context not matching %p, %p!", rdma->verbs, + verbs); + ret = -1; + goto err_rdma_dest_wait; } qemu_rdma_dump_id("dest_init", verbs); @@ -3475,6 +3479,7 @@ static int qemu_rdma_accept(RDMAContext *rdma) if (cm_event->event != RDMA_CM_EVENT_ESTABLISHED) { error_report("rdma_accept not event established"); rdma_ack_cm_event(cm_event); + ret = -1; goto err_rdma_dest_wait; } -- 2.11.4.GIT