From nobody Thu May 16 05:30:36 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16705918382841011.5223750321738; Fri, 9 Dec 2022 05:17:18 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p3dEw-0007kL-GI; Fri, 09 Dec 2022 08:16:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p3dEk-0007eT-39 for qemu-devel@nongnu.org; Fri, 09 Dec 2022 08:16:25 -0500 Received: from proxmox-new.maurer-it.com ([94.136.29.106]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p3dEi-0003w9-0L for qemu-devel@nongnu.org; Fri, 09 Dec 2022 08:16:21 -0500 Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id B0C6C43134; Fri, 9 Dec 2022 14:16:08 +0100 (CET) From: Fiona Ebner To: qemu-devel@nongnu.org Cc: dgilbert@redhat.com, quintela@redhat.com, chen.zhang@intel.com Subject: [PATCH] migration/rdma: fix return value for qio_channel_rdma_{readv, writev} Date: Fri, 9 Dec 2022 14:15:24 +0100 Message-Id: <20221209131524.219442-1-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=94.136.29.106; envelope-from=f.ebner@proxmox.com; helo=proxmox-new.maurer-it.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1670591840081100003 Content-Type: text/plain; charset="utf-8" upon errors. As the documentation in include/io/channel.h states, only -1 and QIO_CHANNEL_ERR_BLOCK should be returned upon error. Other values have the potential to confuse the call sites. error_setg is used rather than error_setg_errno, because there are certain code paths where -1 (as a non-errno) is propagated up (e.g. starting from qemu_rdma_block_for_wrid or qemu_rdma_post_recv_control) all the way to qio_channel_rdma_{readv,writev}. Similar to a216ec85b7 ("migration/channel-block: fix return value for qio_channel_block_{readv,writev}"). Suggested-by: Zhang Chen Signed-off-by: Fiona Ebner Reviewed-by: Juan Quintela --- I did only compile-test the patch, because I have no experience with RDMA. @Zhang Chen: In [0], besides qio_channel_rdma_writev/readv, you mentioned qio_channel_buffer_writev/readv and 'etc.', but I did only find the issue in the RDMA-specific implementation. [0]: https://lists.nongnu.org/archive/html/qemu-devel/2022-10/msg02636.html migration/rdma.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 94a55dd95b..0ba1668d70 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -2785,7 +2785,8 @@ static ssize_t qio_channel_rdma_writev(QIOChannel *io= c, rdma =3D qatomic_rcu_read(&rioc->rdmaout); =20 if (!rdma) { - return -EIO; + error_setg(errp, "RDMA control channel output is not set"); + return -1; } =20 CHECK_ERROR_STATE(); @@ -2797,7 +2798,8 @@ static ssize_t qio_channel_rdma_writev(QIOChannel *io= c, ret =3D qemu_rdma_write_flush(f, rdma); if (ret < 0) { rdma->error_state =3D ret; - return ret; + error_setg(errp, "qemu_rdma_write_flush returned %d", ret); + return -1; } =20 for (i =3D 0; i < niov; i++) { @@ -2816,7 +2818,8 @@ static ssize_t qio_channel_rdma_writev(QIOChannel *io= c, =20 if (ret < 0) { rdma->error_state =3D ret; - return ret; + error_setg(errp, "qemu_rdma_exchange_send returned %d", re= t); + return -1; } =20 data +=3D len; @@ -2867,7 +2870,8 @@ static ssize_t qio_channel_rdma_readv(QIOChannel *ioc, rdma =3D qatomic_rcu_read(&rioc->rdmain); =20 if (!rdma) { - return -EIO; + error_setg(errp, "RDMA control channel input is not set"); + return -1; } =20 CHECK_ERROR_STATE(); @@ -2903,7 +2907,8 @@ static ssize_t qio_channel_rdma_readv(QIOChannel *ioc, =20 if (ret < 0) { rdma->error_state =3D ret; - return ret; + error_setg(errp, "qemu_rdma_exchange_recv returned %d", ret); + return -1; } =20 /* --=20 2.30.2