From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048226; cv=none; d=zohomail.com; s=zohoarc; b=X2G+3dqabmTRmsk/PLFKbbT317HrQ9jqJ6jEc6zWHlP6QimxVyOm39zIUIkXfLfVMKgYmWXT9E17afjz+P7aK1B62+sUM13SamdUtOaGrjgD5a3vkSeBBbP4rBoEfsyZe3Y5de0TM16i8namfiyzZRMCWNdLJPwZIOpjtrIy+4c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048226; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3Iw/MzsniQ/8kSaSn4X/GtXwiw48W8H3+MwRBmMxBBs=; b=TRKbKeqh5tXhnOW00zq+C4vBLJr80zVc/H3ffh6ngRqb5+48xHSVKpxgHduDCIXpUd+uHrLKgtcR9x6seVfATPCEKwwApm+o7e6zWCKfjVzOvrjCrK0pj+C3osQz862qcgBe5ccunodmrpcPunnDGd0rgtaqYodKTG5tVvm8bXU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048226003236.9365918354282; Mon, 18 Sep 2023 07:43:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFS7-0002sG-T1; Mon, 18 Sep 2023 10:42:20 -0400 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 1qiFS2-0002rh-QI for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS0-0002Yg-3M for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:13 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-412-TiTZ2J4SMY6qly5ZIwxUFQ-1; Mon, 18 Sep 2023 10:42:08 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 16AD7800883 for ; Mon, 18 Sep 2023 14:42:08 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E903B40C6EA8 for ; Mon, 18 Sep 2023 14:42:07 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id E060721E6901; Mon, 18 Sep 2023 16:42:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048129; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3Iw/MzsniQ/8kSaSn4X/GtXwiw48W8H3+MwRBmMxBBs=; b=gNfnYXaORbTK3YagtdSVQTonwpMC3N2QFQnrB3RU7fbotMbCEtY9QAsf5KR4iMO1msP61e QuWWFdV6tOivRrc+T0p9m+KmtehQuNdHpZtrkoYyGYVYyw/3FcEBDK6S2pRLW7W1QYewL6 3a3gmxX2AzA7lqbbDfKXrtjoQzbRe/A= X-MC-Unique: TiTZ2J4SMY6qly5ZIwxUFQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 01/52] migration/rdma: Clean up qemu_rdma_poll()'s return type Date: Mon, 18 Sep 2023 16:41:15 +0200 Message-ID: <20230918144206.560120-2-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048226970100001 Content-Type: text/plain; charset="utf-8" qemu_rdma_poll()'s return type is uint64_t, even though it returns 0, -1, or @ret, which is int. Its callers assign the return value to int variables, then check whether it's negative. Unclean. Return int instead. Signed-off-by: Markus Armbruster Reviewed-by: Fabiano Rosas Reviewed-by: Li Zhijian --- migration/rdma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index ca430d319d..544d83be7e 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1469,8 +1469,8 @@ static uint64_t qemu_rdma_make_wrid(uint64_t wr_id, u= int64_t index, * (of any kind) has completed. * Return the work request ID that completed. */ -static uint64_t qemu_rdma_poll(RDMAContext *rdma, struct ibv_cq *cq, - uint64_t *wr_id_out, uint32_t *byte_len) +static int qemu_rdma_poll(RDMAContext *rdma, struct ibv_cq *cq, + uint64_t *wr_id_out, uint32_t *byte_len) { int ret; struct ibv_wc wc; --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048213; cv=none; d=zohomail.com; s=zohoarc; b=QQ+QBXW37mFC4IT8t3gNW618I0rKOlcGtKdvptbQMiqJqraJRVZPtuFYo/DANgDsFt98WkTiNfjYE4kQkZpx+4lkjlgBCn7pvQw+Z0xLUJzkuxCxwHJyPx7KZ9af8kVx9fVEGPiiEZmbLP2Nupg3pOaFLZoeCFUr+VpuENfY614= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048213; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rCGxSHuWGPFauDO78J2cjgmvZQU9Lb4U+fA74G/EWJo=; b=m2iiqhXMlWgFmyfW6rfygFvwktO5CaGUku0h8h77wx/uNOvz+2SdAJRGR4FvITMzPdhpVAKFeMsBoHi14KYyFARQ+YqSZO285i0EElvPf3wQk1myYXfLZOKMiD1KX6PrlEv9LXVsRQzd0zmFIyydButvzmFaMV8KGlfwEeXn5po= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048213678470.02357532253154; Mon, 18 Sep 2023 07:43:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFSF-0002uy-76; Mon, 18 Sep 2023 10:42:27 -0400 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 1qiFSA-0002t2-DY for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS0-0002Yh-3h for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:22 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-297-20ST3Oq7MNOk7BsJi2wFCA-1; Mon, 18 Sep 2023 10:42:08 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 17EEC811E7E for ; Mon, 18 Sep 2023 14:42:08 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EA0FC140E950 for ; Mon, 18 Sep 2023 14:42:07 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id E308521E6904; Mon, 18 Sep 2023 16:42:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048130; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rCGxSHuWGPFauDO78J2cjgmvZQU9Lb4U+fA74G/EWJo=; b=Ia6iHavNAZq23lccxKv6KN5M4xxlFsotsd1nbp35PizcpNpqJuWE+MdGlR51F2AoxtdrpS nIdS9xq5S9OWYRb2pwV/IWkKxR61ySdr1vsX3yuVfzNiBW43t/OUcSzsPOO3e+mm3n8Xa+ 88Br/Fd+PR4qw5ftL+5rXxiwd6pej70= X-MC-Unique: 20ST3Oq7MNOk7BsJi2wFCA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 02/52] migration/rdma: Clean up qemu_rdma_data_init()'s return type Date: Mon, 18 Sep 2023 16:41:16 +0200 Message-ID: <20230918144206.560120-3-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048215074100011 Content-Type: text/plain; charset="utf-8" qemu_rdma_data_init() return type is void *. It actually returns RDMAContext *, and all its callers assign the value to an RDMAContext *. Unclean. Return RDMAContext * instead. Signed-off-by: Markus Armbruster Reviewed-by: Fabiano Rosas Reviewed-by: Li Zhijian --- migration/rdma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration/rdma.c b/migration/rdma.c index 544d83be7e..3b9e21f8de 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -2739,7 +2739,7 @@ static void qemu_rdma_return_path_dest_init(RDMAConte= xt *rdma_return_path, rdma_return_path->is_return_path =3D true; } =20 -static void *qemu_rdma_data_init(const char *host_port, Error **errp) +static RDMAContext *qemu_rdma_data_init(const char *host_port, Error **err= p) { RDMAContext *rdma =3D NULL; InetSocketAddress *addr; --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048643; cv=none; d=zohomail.com; s=zohoarc; b=S7+DzdQzYkf6zAwjjbP9459f0BmXy2mgLVX9xkT65duZHff6VjFjJC+g4PCSaT0mVfxce26sGIiFpc7UrRhBptXTzN8qFeVksu7qYYSG30Jdy6bRu1343/OiQidtGSx4GJ/CkVgHruMlYINfjdY8Q/WQDpfRMMpTXvkJeba9xlQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048643; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=80wzI07F/vBfJq+6JDGB1yJg2AyjK5HMXn7NuHI3+EY=; b=l3ldb1uQ3PdN09RVhMGRLXmVuV1aYbwmpSCxW87+OamXVtEcDkzVEK1mj92SMdRsm7f+AeOxkCBUR1vv09ur/L4n+lgJ+iMQpcC2jjxaFa4+PAGLhQzLzWBiki0Q2kSqpgSaoZ0Q6G/xHhW8wSfWxjsTa+mn/+MrVrP1+BSPSGE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169504864317763.88005907977015; Mon, 18 Sep 2023 07:50:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFST-00035E-71; Mon, 18 Sep 2023 10:42:41 -0400 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 1qiFSJ-0002wq-QN for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS2-0002Yl-MM for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:30 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-91-ifa3oQh1PpqDKADfnoPkDw-1; Mon, 18 Sep 2023 10:42:08 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1716D945923 for ; Mon, 18 Sep 2023 14:42:08 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E8FCC1005E27 for ; Mon, 18 Sep 2023 14:42:07 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id E5D0A21E6905; Mon, 18 Sep 2023 16:42:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048130; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=80wzI07F/vBfJq+6JDGB1yJg2AyjK5HMXn7NuHI3+EY=; b=R7ZS13IaXVMnOMa/lv1IWaGm/SxVLrSWPK+q70guDM5uOWE8y8wAErKNQobTOXtuFrNq8Z kZ/l3dYbAHf6KlTtrXwQtjCZenAI3lCbY355CTr86RksDKXZXdrf5GjwxkhbTBpxH/H0Pw AJoINxNLxbjBFfqSo+SELghzW8sbruw= X-MC-Unique: ifa3oQh1PpqDKADfnoPkDw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 03/52] migration/rdma: Clean up rdma_delete_block()'s return type Date: Mon, 18 Sep 2023 16:41:17 +0200 Message-ID: <20230918144206.560120-4-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048644930100005 Content-Type: text/plain; charset="utf-8" rdma_delete_block() always returns 0, which its only caller ignores. Return void instead. Signed-off-by: Markus Armbruster Reviewed-by: Fabiano Rosas Reviewed-by: Li Zhijian --- migration/rdma.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 3b9e21f8de..320c291a96 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -668,7 +668,7 @@ static int qemu_rdma_init_ram_blocks(RDMAContext *rdma) * Note: If used outside of cleanup, the caller must ensure that the desti= nation * block structures are also updated */ -static int rdma_delete_block(RDMAContext *rdma, RDMALocalBlock *block) +static void rdma_delete_block(RDMAContext *rdma, RDMALocalBlock *block) { RDMALocalBlocks *local =3D &rdma->local_ram_blocks; RDMALocalBlock *old =3D local->block; @@ -754,8 +754,6 @@ static int rdma_delete_block(RDMAContext *rdma, RDMALoc= alBlock *block) &local->block[x]); } } - - return 0; } =20 /* --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048643; cv=none; d=zohomail.com; s=zohoarc; b=EdyyA1i2szrXRlLDbK7/JJndynCP3Fq87XxdatdXij9GoFe3NwYFucmTL/rd1j0rMP8iftB+aF9mF1szvb2cLDxC7+iQlKmeH5sZGoC/Vetk92kmthpd0U3kIituBRLI6FIggVY72LwvAe+6Jt+a96WaBo3zNRhSulWGnn8enwc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048643; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kqC2Z2GnwKzykYWxLpg0IIWmm6cKsvX9bBS5zkxf7BM=; b=FWamY7H/kwcNGANfH0pIZSZ6cyDCAVDpcfr5IG660IfZkZ2O0U2wXE3vSCf6670WRv1f1sZ5NnsyGui63k9nHdqQT6Q/0mrNH8Dasj+W6htCFib1TU/7s+i1Fb+/2uw6d0wV9qGDKKdZ/b8xYv8N7arqd0w+0Yz4qypOw6ZtfII= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048643306298.8389339411076; Mon, 18 Sep 2023 07:50:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFT5-0003In-2T; Mon, 18 Sep 2023 10:43:20 -0400 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 1qiFSQ-00032S-7j for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS3-0002Yo-KP for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:37 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-82-ju_RBuxCMommHLTEaZ1Q3A-1; Mon, 18 Sep 2023 10:42:08 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3FBCA85829B for ; Mon, 18 Sep 2023 14:42:08 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F33321C554 for ; Mon, 18 Sep 2023 14:42:07 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id E8E4221E6906; Mon, 18 Sep 2023 16:42:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048130; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kqC2Z2GnwKzykYWxLpg0IIWmm6cKsvX9bBS5zkxf7BM=; b=hhBZ5tk6ldENR20BXa3cEdeYy4UDydQCbLRV7mlWc+RgJ0C8mRDoi3XR813Nbqfzyzsv42 sHXz2Pahv+VVyzgImrdxtXdeYv9O9N9vIJWGspJv4YxYN+LNUq8O0Z8G2n7J4PbB6jVeHm aGAHzhlpVPBXdkcvPgz9uAT+459CJrc= X-MC-Unique: ju_RBuxCMommHLTEaZ1Q3A-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 04/52] migration/rdma: Drop fragile wr_id formatting Date: Mon, 18 Sep 2023 16:41:18 +0200 Message-ID: <20230918144206.560120-5-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048643894100001 Content-Type: text/plain; charset="utf-8" wrid_desc[] uses 4001 pointers to map four integer values to strings. print_wrid() accesses wrid_desc[] out of bounds when passed a negative argument. It returns null for values 2..1999 and 2001..3999. qemu_rdma_poll() and qemu_rdma_block_for_wrid() print wrid_desc[wr_id] and passes print_wrid(wr_id) to tracepoints. Could conceivably crash trying to format a null string. I believe access out of bounds is not possible. Not worth cleaning up. Dumb down to show just numeric wr_id. Signed-off-by: Markus Armbruster Reviewed-by: Fabiano Rosas Reviewed-by: Li Zhijian --- migration/rdma.c | 32 +++++++------------------------- migration/trace-events | 8 ++++---- 2 files changed, 11 insertions(+), 29 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 320c291a96..cda22be3f7 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -133,13 +133,6 @@ enum { RDMA_WRID_RECV_CONTROL =3D 4000, }; =20 -static const char *wrid_desc[] =3D { - [RDMA_WRID_NONE] =3D "NONE", - [RDMA_WRID_RDMA_WRITE] =3D "WRITE RDMA", - [RDMA_WRID_SEND_CONTROL] =3D "CONTROL SEND", - [RDMA_WRID_RECV_CONTROL] =3D "CONTROL RECV", -}; - /* * Work request IDs for IB SEND messages only (not RDMA writes). * This is used by the migration protocol to transmit @@ -535,7 +528,6 @@ static void network_to_result(RDMARegisterResult *resul= t) result->host_addr =3D ntohll(result->host_addr); }; =20 -const char *print_wrid(int wrid); static int qemu_rdma_exchange_send(RDMAContext *rdma, RDMAControlHeader *h= ead, uint8_t *data, RDMAControlHeader *resp, int *resp_idx, @@ -1362,14 +1354,6 @@ static int qemu_rdma_reg_control(RDMAContext *rdma, = int idx) return -1; } =20 -const char *print_wrid(int wrid) -{ - if (wrid >=3D RDMA_WRID_RECV_CONTROL) { - return wrid_desc[RDMA_WRID_RECV_CONTROL]; - } - return wrid_desc[wrid]; -} - /* * Perform a non-optimized memory unregistration after every transfer * for demonstration purposes, only if pin-all is not requested. @@ -1491,15 +1475,15 @@ static int qemu_rdma_poll(RDMAContext *rdma, struct= ibv_cq *cq, if (wc.status !=3D IBV_WC_SUCCESS) { fprintf(stderr, "ibv_poll_cq wc.status=3D%d %s!\n", wc.status, ibv_wc_status_str(wc.status)); - fprintf(stderr, "ibv_poll_cq wrid=3D%s!\n", wrid_desc[wr_id]); + fprintf(stderr, "ibv_poll_cq wrid=3D%" PRIu64 "!\n", wr_id); =20 return -1; } =20 if (rdma->control_ready_expected && (wr_id >=3D RDMA_WRID_RECV_CONTROL)) { - trace_qemu_rdma_poll_recv(wrid_desc[RDMA_WRID_RECV_CONTROL], - wr_id - RDMA_WRID_RECV_CONTROL, wr_id, rdma->nb_sent); + trace_qemu_rdma_poll_recv(wr_id - RDMA_WRID_RECV_CONTROL, wr_id, + rdma->nb_sent); rdma->control_ready_expected =3D 0; } =20 @@ -1510,7 +1494,7 @@ static int qemu_rdma_poll(RDMAContext *rdma, struct i= bv_cq *cq, (wc.wr_id & RDMA_WRID_BLOCK_MASK) >> RDMA_WRID_BLOCK_SHIFT; RDMALocalBlock *block =3D &(rdma->local_ram_blocks.block[index]); =20 - trace_qemu_rdma_poll_write(print_wrid(wr_id), wr_id, rdma->nb_sent, + trace_qemu_rdma_poll_write(wr_id, rdma->nb_sent, index, chunk, block->local_host_addr, (void *)(uintptr_t)block->remote_host_a= ddr); =20 @@ -1520,7 +1504,7 @@ static int qemu_rdma_poll(RDMAContext *rdma, struct i= bv_cq *cq, rdma->nb_sent--; } } else { - trace_qemu_rdma_poll_other(print_wrid(wr_id), wr_id, rdma->nb_sent= ); + trace_qemu_rdma_poll_other(wr_id, rdma->nb_sent); } =20 *wr_id_out =3D wc.wr_id; @@ -1665,8 +1649,7 @@ static int qemu_rdma_block_for_wrid(RDMAContext *rdma= , int wrid_requested, break; } if (wr_id !=3D wrid_requested) { - trace_qemu_rdma_block_for_wrid_miss(print_wrid(wrid_requested), - wrid_requested, print_wrid(wr_id), wr_id); + trace_qemu_rdma_block_for_wrid_miss(wrid_requested, wr_id); } } =20 @@ -1705,8 +1688,7 @@ static int qemu_rdma_block_for_wrid(RDMAContext *rdma= , int wrid_requested, break; } if (wr_id !=3D wrid_requested) { - trace_qemu_rdma_block_for_wrid_miss(print_wrid(wrid_reques= ted), - wrid_requested, print_wrid(wr_id), wr_i= d); + trace_qemu_rdma_block_for_wrid_miss(wrid_requested, wr_id); } } =20 diff --git a/migration/trace-events b/migration/trace-events index 4666f19325..b78808f28b 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -207,7 +207,7 @@ qemu_rdma_accept_incoming_migration(void) "" qemu_rdma_accept_incoming_migration_accepted(void) "" qemu_rdma_accept_pin_state(bool pin) "%d" qemu_rdma_accept_pin_verbsc(void *verbs) "Verbs context after listen: %p" -qemu_rdma_block_for_wrid_miss(const char *wcompstr, int wcomp, const char = *gcompstr, uint64_t req) "A Wanted wrid %s (%d) but got %s (%" PRIu64 ")" +qemu_rdma_block_for_wrid_miss(int wcomp, uint64_t req) "A Wanted wrid %d b= ut got %" PRIu64 qemu_rdma_cleanup_disconnect(void) "" qemu_rdma_close(void) "" qemu_rdma_connect_pin_all_requested(void) "" @@ -221,9 +221,9 @@ qemu_rdma_exchange_send_waiting(const char *desc) "Wait= ing for response %s" qemu_rdma_exchange_send_received(const char *desc) "Response %s received." qemu_rdma_fill(size_t control_len, size_t size) "RDMA %zd of %zd bytes alr= eady in buffer" qemu_rdma_init_ram_blocks(int blocks) "Allocated %d local ram block struct= ures" -qemu_rdma_poll_recv(const char *compstr, int64_t comp, int64_t id, int sen= t) "completion %s #%" PRId64 " received (%" PRId64 ") left %d" -qemu_rdma_poll_write(const char *compstr, int64_t comp, int left, uint64_t= block, uint64_t chunk, void *local, void *remote) "completions %s (%" PRId= 64 ") left %d, block %" PRIu64 ", chunk: %" PRIu64 " %p %p" -qemu_rdma_poll_other(const char *compstr, int64_t comp, int left) "other c= ompletion %s (%" PRId64 ") received left %d" +qemu_rdma_poll_recv(int64_t comp, int64_t id, int sent) "completion %" PRI= d64 " received (%" PRId64 ") left %d" +qemu_rdma_poll_write(int64_t comp, int left, uint64_t block, uint64_t chun= k, void *local, void *remote) "completions %" PRId64 " left %d, block %" PR= Iu64 ", chunk: %" PRIu64 " %p %p" +qemu_rdma_poll_other(int64_t comp, int left) "other completion %" PRId64 "= received left %d" qemu_rdma_post_send_control(const char *desc) "CONTROL: sending %s.." qemu_rdma_register_and_get_keys(uint64_t len, void *start) "Registering %"= PRIu64 " bytes @ %p" qemu_rdma_register_odp_mr(const char *name) "Try to register On-Demand Pag= ing memory region: %s" --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048316; cv=none; d=zohomail.com; s=zohoarc; b=IFkDhBajB15hzUI9SHW7LkwwX+e2LoeXjg5qFjZWfPr4WVp5g/pLUEaCF5Fp8w1kaxa6e66FcSvTHsM/pq0+aNgeM9k3s+hP8NeewgqCUTmI7WCImxpt0coabjByqYGE/Yx3O5V8SpAWnCaatZre02nBPEprj4JsGC/WBhiakcs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048316; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rQjjegCMyCfUF3K78NUViyNdd6EV848yUG0Dl9X+n5k=; b=eOn0UYHqTbG2csUhJRuTDmOJ5zLc5iTXrwazyF4ontPKQ0d2SVjz8y+hjIUpn9RqcxxjeAfYJkcKqMKp0LVCfvplKaKDM7JOZxedGhf5fW7E9crod6zDcBqO0+/7HLy37uOBAHyE/meU7NgRt+bEGzU3GbGEJn1dswhqMWKDZ70= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048315899351.51359823820815; Mon, 18 Sep 2023 07:45:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFSo-0003Ak-Nl; Mon, 18 Sep 2023 10:43:05 -0400 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 1qiFSK-0002x1-Ot for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS2-0002aW-Mw for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:31 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-124-3bGbgNkgPPuC-fuv0qxyxA-1; Mon, 18 Sep 2023 10:42:09 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2475C3C025C2 for ; Mon, 18 Sep 2023 14:42:09 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 01B5A170E4 for ; Mon, 18 Sep 2023 14:42:09 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id ED00E21E690B; Mon, 18 Sep 2023 16:42:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048131; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rQjjegCMyCfUF3K78NUViyNdd6EV848yUG0Dl9X+n5k=; b=UisAwxuGROY2Cvs+0PAl6u6/h6DOncoXUl7YU0isaumfUOmyPBvXFAgHMXcLJINxlUCWC8 jw6czvczQsNOkalUFksQYM/zmu28sYeyb48+CEAIZI7raTTay29dRajgBF/h8kPkNqTS3J mB9U1gjbjFvyOfm/kmmQ0kducx2mujs= X-MC-Unique: 3bGbgNkgPPuC-fuv0qxyxA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 05/52] migration/rdma: Consistently use uint64_t for work request IDs Date: Mon, 18 Sep 2023 16:41:19 +0200 Message-ID: <20230918144206.560120-6-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048317334100003 Content-Type: text/plain; charset="utf-8" We use int instead of uint64_t in a few places. Change them to uint64_t. This cleans up a comparison of signed qemu_rdma_block_for_wrid() parameter @wrid_requested with unsigned @wr_id. Harmless, because the actual arguments are non-negative enumeration constants. Signed-off-by: Markus Armbruster Reviewed-by: Fabiano Rosas Reviewed-by: Li Zhijian --- migration/rdma.c | 7 ++++--- migration/trace-events | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index cda22be3f7..4328610a4c 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1599,13 +1599,13 @@ static int qemu_rdma_wait_comp_channel(RDMAContext = *rdma, return rdma->error_state; } =20 -static struct ibv_comp_channel *to_channel(RDMAContext *rdma, int wrid) +static struct ibv_comp_channel *to_channel(RDMAContext *rdma, uint64_t wri= d) { return wrid < RDMA_WRID_RECV_CONTROL ? rdma->send_comp_channel : rdma->recv_comp_channel; } =20 -static struct ibv_cq *to_cq(RDMAContext *rdma, int wrid) +static struct ibv_cq *to_cq(RDMAContext *rdma, uint64_t wrid) { return wrid < RDMA_WRID_RECV_CONTROL ? rdma->send_cq : rdma->recv_cq; } @@ -1623,7 +1623,8 @@ static struct ibv_cq *to_cq(RDMAContext *rdma, int wr= id) * completions only need to be recorded, but do not actually * need further processing. */ -static int qemu_rdma_block_for_wrid(RDMAContext *rdma, int wrid_requested, +static int qemu_rdma_block_for_wrid(RDMAContext *rdma, + uint64_t wrid_requested, uint32_t *byte_len) { int num_cq_events =3D 0, ret =3D 0; diff --git a/migration/trace-events b/migration/trace-events index b78808f28b..d733107ec6 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -207,7 +207,7 @@ qemu_rdma_accept_incoming_migration(void) "" qemu_rdma_accept_incoming_migration_accepted(void) "" qemu_rdma_accept_pin_state(bool pin) "%d" qemu_rdma_accept_pin_verbsc(void *verbs) "Verbs context after listen: %p" -qemu_rdma_block_for_wrid_miss(int wcomp, uint64_t req) "A Wanted wrid %d b= ut got %" PRIu64 +qemu_rdma_block_for_wrid_miss(uint64_t wcomp, uint64_t req) "A Wanted wrid= %" PRIu64 " but got %" PRIu64 qemu_rdma_cleanup_disconnect(void) "" qemu_rdma_close(void) "" qemu_rdma_connect_pin_all_requested(void) "" @@ -221,9 +221,9 @@ qemu_rdma_exchange_send_waiting(const char *desc) "Wait= ing for response %s" qemu_rdma_exchange_send_received(const char *desc) "Response %s received." qemu_rdma_fill(size_t control_len, size_t size) "RDMA %zd of %zd bytes alr= eady in buffer" qemu_rdma_init_ram_blocks(int blocks) "Allocated %d local ram block struct= ures" -qemu_rdma_poll_recv(int64_t comp, int64_t id, int sent) "completion %" PRI= d64 " received (%" PRId64 ") left %d" -qemu_rdma_poll_write(int64_t comp, int left, uint64_t block, uint64_t chun= k, void *local, void *remote) "completions %" PRId64 " left %d, block %" PR= Iu64 ", chunk: %" PRIu64 " %p %p" -qemu_rdma_poll_other(int64_t comp, int left) "other completion %" PRId64 "= received left %d" +qemu_rdma_poll_recv(uint64_t comp, int64_t id, int sent) "completion %" PR= Iu64 " received (%" PRId64 ") left %d" +qemu_rdma_poll_write(uint64_t comp, int left, uint64_t block, uint64_t chu= nk, void *local, void *remote) "completions %" PRIu64 " left %d, block %" P= RIu64 ", chunk: %" PRIu64 " %p %p" +qemu_rdma_poll_other(uint64_t comp, int left) "other completion %" PRIu64 = " received left %d" qemu_rdma_post_send_control(const char *desc) "CONTROL: sending %s.." qemu_rdma_register_and_get_keys(uint64_t len, void *start) "Registering %"= PRIu64 " bytes @ %p" qemu_rdma_register_odp_mr(const char *name) "Try to register On-Demand Pag= ing memory region: %s" --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048584; cv=none; d=zohomail.com; s=zohoarc; b=J+dOIcb8na6l0+vQNcbgmbFrts2gFUd0gx/6PZzAC52b6y3zj1OXjkrSudICfd6Ul45qxKo0cJqsLBweGwnCFDBnfJYtb20mAbh4vYexzCQS/wWwFwlM3E2+4dlYpmGtvytqbEwgDtjOkGuVOOLom89kDlGo31m0CDGJ9Rm096A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048584; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=r3YFq6ZYnpRRZBWPjb4B2QXVYn/9fVVoiH9j7gD/gR4=; b=CQ1psWUOZKl/zIsPToSUqx/i2Qpns4CVl/UUDTdRum5GQj+lzeAOe2nqhrRGPEna6yTSbkI2E4DTw+HdEvAiyyfyYgogXEVHv0tdZZ89QCaNtgLqSuEPmaaxJiFX7NfJmV+PY0lh7uw3/M1uU1WezZZTIl/0EsNaYGczLu9bQHg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048584139573.7086570306385; Mon, 18 Sep 2023 07:49:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFSP-00031z-Mq; Mon, 18 Sep 2023 10:42:37 -0400 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 1qiFSG-0002vq-QA for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS0-0002aB-77 for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:28 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-185-kHKx9dROPhiw3pCW5gRiog-1; Mon, 18 Sep 2023 10:42:09 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 233D529AA3BF for ; Mon, 18 Sep 2023 14:42:09 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0117C1005E27 for ; Mon, 18 Sep 2023 14:42:09 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id EEC5F21E690C; Mon, 18 Sep 2023 16:42:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048131; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r3YFq6ZYnpRRZBWPjb4B2QXVYn/9fVVoiH9j7gD/gR4=; b=OM40Cb5/hiWE47h/CISEuyVJNDIgqH9KUn0cA45wJ8Ubj00XUi4btktd79B+MVtT3jRKLE +5I9Ga4kk8p/ryyxdlbrv13/T6uxlIHRfR4UuaS8tvsOl+wCrjom27tQYGXR8l1jALaq0B cpFP2zH3F1i3CvY5xeD9lxbxLf0pAMs= X-MC-Unique: kHKx9dROPhiw3pCW5gRiog-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 06/52] migration/rdma: Clean up two more harmless signed vs. unsigned issues Date: Mon, 18 Sep 2023 16:41:20 +0200 Message-ID: <20230918144206.560120-7-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048586361100007 Content-Type: text/plain; charset="utf-8" qemu_rdma_exchange_get_response() compares int parameter @expecting with uint32_t head->type. Actual arguments are non-negative enumeration constants, RDMAControlHeader uint32_t member type, or qemu_rdma_exchange_recv() int parameter expecting. Actual arguments for the latter are non-negative enumeration constants. Change both parameters to uint32_t. In qio_channel_rdma_readv(), loop control variable @i is ssize_t, and counts from 0 up to @niov, which is size_t. Change @i to size_t. Signed-off-by: Markus Armbruster Reviewed-by: Fabiano Rosas --- migration/rdma.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 4328610a4c..e3b8d0506c 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1801,7 +1801,7 @@ static int qemu_rdma_post_recv_control(RDMAContext *r= dma, int idx) * Block and wait for a RECV control channel message to arrive. */ static int qemu_rdma_exchange_get_response(RDMAContext *rdma, - RDMAControlHeader *head, int expecting, int idx) + RDMAControlHeader *head, uint32_t expecting, int idx) { uint32_t byte_len; int ret =3D qemu_rdma_block_for_wrid(rdma, RDMA_WRID_RECV_CONTROL + id= x, @@ -1959,7 +1959,7 @@ static int qemu_rdma_exchange_send(RDMAContext *rdma,= RDMAControlHeader *head, * control-channel message. */ static int qemu_rdma_exchange_recv(RDMAContext *rdma, RDMAControlHeader *h= ead, - int expecting) + uint32_t expecting) { RDMAControlHeader ready =3D { .len =3D 0, @@ -2851,7 +2851,7 @@ static ssize_t qio_channel_rdma_readv(QIOChannel *ioc, RDMAContext *rdma; RDMAControlHeader head; int ret =3D 0; - ssize_t i; + size_t i; size_t done =3D 0; =20 RCU_READ_LOCK_GUARD(); --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048244; cv=none; d=zohomail.com; s=zohoarc; b=TOT7nzMikqR//h0Ja2DfWQSvZOytFCI2CGgkTvZDsAULz+S71xmkNGGYcOcNIOb/uLv8c69qoY0WX+g1OpEmE75abbl7Kt9u1ZnQEpuCwoIpYpuP5ArmJ7eKZ0tIdgjIrtcFCCPAC5kYBteJJijmZoj+ZmClXgKqvfUmsXP9avM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048244; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PqCmEOXvPUnDsJO77Wfsx4lk6Y5voRF2k5XMSdkLBUM=; b=M3foF3uwKxZidxA0qXGhYJRmT0SMzB0JnAqslD4MSfluy2XGf/n/90x1ERmo9/lCevMd1bVdwtpwwmQYCbLcsZKKwkOjz9FaVDN8RA9be1ROr9WBjP6uS7hMP0Udpw+ICGGgGv8re7UQ4Ge4Ez/qoLNREddqsafBWMh22OW3EuI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048244750579.6693933885277; Mon, 18 Sep 2023 07:44:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFSZ-00038J-Px; Mon, 18 Sep 2023 10:42:48 -0400 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 1qiFSK-0002x4-Ow for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS2-0002aJ-EA for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:32 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-401-DIWortF1Ola164F14fxktA-1; Mon, 18 Sep 2023 10:42:09 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2333685A5BD for ; Mon, 18 Sep 2023 14:42:09 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 01B8140C2064 for ; Mon, 18 Sep 2023 14:42:09 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id F1A5721E690E; Mon, 18 Sep 2023 16:42:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048131; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PqCmEOXvPUnDsJO77Wfsx4lk6Y5voRF2k5XMSdkLBUM=; b=bR9owTCyrWgQfZ0JXGl0B+5Flu07ATTLhxAYQIIysY59zJFb6413XTmhQoRpVcMBcaWwnx YSvQ2H/3nvT8zzc3rnHuBWQrDUEWHlqnJd1OjP7SKVpzwEO2bjdMMz3TmON3RVGD7r47mK TlKyoCqipeHevGie3cQhGTrHLeXJMDc= X-MC-Unique: DIWortF1Ola164F14fxktA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 07/52] migration/rdma: Give qio_channel_rdma_source_funcs internal linkage Date: Mon, 18 Sep 2023 16:41:21 +0200 Message-ID: <20230918144206.560120-8-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048246846100003 Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster Reviewed-by: Fabiano Rosas Reviewed-by: Li Zhijian --- migration/rdma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration/rdma.c b/migration/rdma.c index e3b8d0506c..177d73a2ba 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -3057,7 +3057,7 @@ qio_channel_rdma_source_finalize(GSource *source) object_unref(OBJECT(ssource->rioc)); } =20 -GSourceFuncs qio_channel_rdma_source_funcs =3D { +static GSourceFuncs qio_channel_rdma_source_funcs =3D { qio_channel_rdma_source_prepare, qio_channel_rdma_source_check, qio_channel_rdma_source_dispatch, --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048644; cv=none; d=zohomail.com; s=zohoarc; b=TbQ4zDI5cia8GyILVt3n1o1+wCGYp34c4J6aGGZIWXqADL70dpQG4Tp5C4Yli7bznuTFVvFWDNr44/lhcjbhpaP5U5KyJ9d3cnjQqp2q4j1zfj/R2rhf2M3OJB1F6DmsBMmXQZdmWM2zHRWKsvnhbfCHpTqOK36DJAYeVKgFb/o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048644; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+gKm2qrf+GH5KZE38eTbjf2ovKGdCdKcFO05pLacnCo=; b=SRehlLV2fmHv6wsnEuguD4Ed+6qIL5PZZJMO7Vg2e7cE4jPqO5Jv0v/dAxD2OL9o5cusaKGBCjTiWYvRdzKaDz1Mfyjt5JPhVb5W5Q3FOWYbBuQ9XtoMUp7bYzr6mJQ76qEHAGjlzqBkyygz9mumGHTMxS9PqIXosALiqDcrtX4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16950486447301019.047514061557; Mon, 18 Sep 2023 07:50:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFSU-00035U-No; Mon, 18 Sep 2023 10:42:42 -0400 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 1qiFSO-00030W-8y for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS2-0002aU-RH for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:35 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-185-u_0F94rWOrW6LcneloqyIg-1; Mon, 18 Sep 2023 10:42:09 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 244731C05144 for ; Mon, 18 Sep 2023 14:42:09 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 01F6B20268CC for ; Mon, 18 Sep 2023 14:42:09 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 004DC21E690F; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048131; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+gKm2qrf+GH5KZE38eTbjf2ovKGdCdKcFO05pLacnCo=; b=FChVYoQNFjbbAZMMoyV0i8fY132BqWVvk/s6IobG7iRJky7P4EryMSDbOlwjglVuwrHD/c Zoq8c3exVQAFXgtJLuPdGutu4jF246HuVntSONqr00dxJHBkhqjt81NmqD9pMVvfPBhc3/ igVP6TbvDKcTaoNgdMNAp9i+mqNVGYI= X-MC-Unique: u_0F94rWOrW6LcneloqyIg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 08/52] migration/rdma: Fix qemu_rdma_accept() to return failure on errors Date: Mon, 18 Sep 2023 16:41:22 +0200 Message-ID: <20230918144206.560120-9-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048645968100011 Content-Type: text/plain; charset="utf-8" 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 --- migration/rdma.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 177d73a2ba..4339fcc7b2 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -3352,6 +3352,7 @@ static int qemu_rdma_accept(RDMAContext *rdma) =20 if (cm_event->event !=3D RDMA_CM_EVENT_CONNECT_REQUEST) { rdma_ack_cm_event(cm_event); + ret =3D -1; goto err_rdma_dest_wait; } =20 @@ -3364,6 +3365,7 @@ static int qemu_rdma_accept(RDMAContext *rdma) rdma_return_path =3D qemu_rdma_data_init(rdma->host_port, NULL); if (rdma_return_path =3D=3D NULL) { rdma_ack_cm_event(cm_event); + ret =3D -1; goto err_rdma_dest_wait; } =20 @@ -3375,10 +3377,11 @@ static int qemu_rdma_accept(RDMAContext *rdma) network_to_caps(&cap); =20 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 =3D -1; + goto err_rdma_dest_wait; } =20 /* @@ -3408,9 +3411,10 @@ static int qemu_rdma_accept(RDMAContext *rdma) if (!rdma->verbs) { rdma->verbs =3D verbs; } else if (rdma->verbs !=3D 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 =3D -1; + goto err_rdma_dest_wait; } =20 qemu_rdma_dump_id("dest_init", verbs); @@ -3467,6 +3471,7 @@ static int qemu_rdma_accept(RDMAContext *rdma) if (cm_event->event !=3D RDMA_CM_EVENT_ESTABLISHED) { error_report("rdma_accept not event established"); rdma_ack_cm_event(cm_event); + ret =3D -1; goto err_rdma_dest_wait; } =20 --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048516; cv=none; d=zohomail.com; s=zohoarc; b=buBkp0ejgIXOYlzelAYS+7SXNRQjSJQhtL86N0UoRtCfDL7Syynzdwm7UQgVuxf+2Vnmfa9GX0pQdMoTkcCEv54LE4FGF4F8bI7a8Q74lHuJCUilt99eHLtVrgMhSp0LwKBxqsXI0lpc1EM1L4CvACuZzOKqtiEcqh1Ql5Uf9EY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048516; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+GuWSGE7zxNvVSCuNA8qH/BysLhGCrLP8dSZ5tIdTtw=; b=C/7M4xIVusXVxntVYajIPp61/qjrdO8rAwZIdv3OzLsEtOZM5aWBzrdJjmN7M68tpb/YbavtqhPsTWE8Id+uGXDZcVGFiXqnCRVQ4e/StwjFNcot9dz0aQxpt3vxh5/MHGyT/NPmcKZPiYOoApwKmK5ZCXs1eSYqLdEIwEI+MKs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048516881729.6131408005986; Mon, 18 Sep 2023 07:48:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFSY-00038A-94; Mon, 18 Sep 2023 10:42:46 -0400 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 1qiFSH-0002vz-8U for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS2-0002a6-KM for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:28 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-96-1-egC8rdNluzZOJGjXXgLA-1; Mon, 18 Sep 2023 10:42:09 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 267683800BA6 for ; Mon, 18 Sep 2023 14:42:09 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 04BD21005E28 for ; Mon, 18 Sep 2023 14:42:09 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 0347921E6910; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048131; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+GuWSGE7zxNvVSCuNA8qH/BysLhGCrLP8dSZ5tIdTtw=; b=JwXj8bU/7O6/bHLRm3njK3+Rw6QaK5IBJXCH+byI9B8oqr+3Mt2Es0u82gmMJLNfv30tHi i/QGgnWamj+iAU7DHy123kGscI7yT96PpamTCNDiNLXFG3aCUp/ZBQUBBym7hOX38BVRnf TFtOZ1e97GPtsDOo3PzLqcWNFlTqiU0= X-MC-Unique: 1-egC8rdNluzZOJGjXXgLA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 09/52] migration/rdma: Put @errp parameter last Date: Mon, 18 Sep 2023 16:41:23 +0200 Message-ID: <20230918144206.560120-10-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048518863100015 Content-Type: text/plain; charset="utf-8" include/qapi/error.h demands: * - Functions that use Error to report errors have an Error **errp * parameter. It should be the last parameter, except for functions * taking variable arguments. qemu_rdma_connect() does not conform. Clean it up. Signed-off-by: Markus Armbruster Reviewed-by: Fabiano Rosas Reviewed-by: Li Zhijian --- migration/rdma.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 4339fcc7b2..2b40bbcbb0 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -2532,7 +2532,8 @@ static int qemu_get_cm_event_timeout(RDMAContext *rdm= a, } } =20 -static int qemu_rdma_connect(RDMAContext *rdma, Error **errp, bool return_= path) +static int qemu_rdma_connect(RDMAContext *rdma, bool return_path, + Error **errp) { RDMACapabilities cap =3D { .version =3D RDMA_CONTROL_VERSION_CURRENT, @@ -4175,7 +4176,7 @@ void rdma_start_outgoing_migration(void *opaque, } =20 trace_rdma_start_outgoing_migration_after_rdma_source_init(); - ret =3D qemu_rdma_connect(rdma, errp, false); + ret =3D qemu_rdma_connect(rdma, false, errp); =20 if (ret) { goto err; @@ -4196,7 +4197,7 @@ void rdma_start_outgoing_migration(void *opaque, goto return_path_err; } =20 - ret =3D qemu_rdma_connect(rdma_return_path, errp, true); + ret =3D qemu_rdma_connect(rdma_return_path, true, errp); =20 if (ret) { goto return_path_err; --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048540; cv=none; d=zohomail.com; s=zohoarc; b=lt0JoImTnmou8M8ErbdEe8p8k5irwMuZ9WZaS/brsnxoz0rYHCQyrTb/31MVs6rT2k7LOY0aRgP0qY3CKsSnBAjDmNyQpiFW5MqRLzBwCmirv3iKabII0jkDC9aR9oPezlv/nG95biAJFtW+sMDqU1UZzc6dkVYwdQd38zcIRZ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048540; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rLAXsPvTYg40VSa2kAHh0ona3CBYtNksrIdR7NytkLg=; b=da+l/9pgQXw1VYKmMfWW4McPLLDhhleGvJy7R2iyOXpYy4rw1cRU5gBuV1MQkCwwHI+szxAFXFp4OrNgrm9GYCnwCD9IVUS9/wohJbFEJV8d5eoyKAg4Q85d4h3qWaX9eJgk/6iJtLJNtB0Hmg8N8NXFeEJlZif8N+IrwTMyDy4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048539861615.7201727958687; Mon, 18 Sep 2023 07:48:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFSR-00033z-KK; Mon, 18 Sep 2023 10:42:39 -0400 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 1qiFSH-0002w0-QZ for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS2-0002aL-IV for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:29 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-92-m_5eTfx5OzixZC0nlBFZ3w-1; Mon, 18 Sep 2023 10:42:09 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3C42129AA2C8 for ; Mon, 18 Sep 2023 14:42:09 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1A45D20268D0 for ; Mon, 18 Sep 2023 14:42:09 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 0627421E6911; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048131; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rLAXsPvTYg40VSa2kAHh0ona3CBYtNksrIdR7NytkLg=; b=dnVxLb/EnDZnVWo1r9kzEN2erI4InTOu3ovt2kC5d77I6g9UBJAXwa4nv0ihPEf4Q014di rDBBpVqgThirlnx0TsQj6bYe0VBdvjW63uVZLrsAAD1+C1ZdOCybCAho9dnOdw0y5/uQ9U 9aOswVaJrTMpf2vF2nq3ek87dgSXPjM= X-MC-Unique: m_5eTfx5OzixZC0nlBFZ3w-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 10/52] migration/rdma: Eliminate error_propagate() Date: Mon, 18 Sep 2023 16:41:24 +0200 Message-ID: <20230918144206.560120-11-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048541137100003 Content-Type: text/plain; charset="utf-8" When all we do with an Error we receive into a local variable is propagating to somewhere else, we can just as well receive it there right away. Signed-off-by: Markus Armbruster Reviewed-by: Fabiano Rosas Reviewed-by: Li Zhijian --- migration/rdma.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 2b40bbcbb0..960fff5860 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -2445,7 +2445,6 @@ static void qemu_rdma_cleanup(RDMAContext *rdma) static int qemu_rdma_source_init(RDMAContext *rdma, bool pin_all, Error **= errp) { int ret, idx; - Error *local_err =3D NULL, **temp =3D &local_err; =20 /* * Will be validated against destination's actual capabilities @@ -2453,14 +2452,14 @@ static int qemu_rdma_source_init(RDMAContext *rdma,= bool pin_all, Error **errp) */ rdma->pin_all =3D pin_all; =20 - ret =3D qemu_rdma_resolve_host(rdma, temp); + ret =3D qemu_rdma_resolve_host(rdma, errp); if (ret) { goto err_rdma_source_init; } =20 ret =3D qemu_rdma_alloc_pd_cq(rdma); if (ret) { - ERROR(temp, "rdma migration: error allocating pd and cq! Your mloc= k()" + ERROR(errp, "rdma migration: error allocating pd and cq! Your mloc= k()" " limits may be too low. Please check $ ulimit -a # an= d " "search for 'ulimit -l' in the output"); goto err_rdma_source_init; @@ -2468,13 +2467,13 @@ static int qemu_rdma_source_init(RDMAContext *rdma,= bool pin_all, Error **errp) =20 ret =3D qemu_rdma_alloc_qp(rdma); if (ret) { - ERROR(temp, "rdma migration: error allocating qp!"); + ERROR(errp, "rdma migration: error allocating qp!"); goto err_rdma_source_init; } =20 ret =3D qemu_rdma_init_ram_blocks(rdma); if (ret) { - ERROR(temp, "rdma migration: error initializing ram blocks!"); + ERROR(errp, "rdma migration: error initializing ram blocks!"); goto err_rdma_source_init; } =20 @@ -2489,7 +2488,7 @@ static int qemu_rdma_source_init(RDMAContext *rdma, b= ool pin_all, Error **errp) for (idx =3D 0; idx < RDMA_WRID_MAX; idx++) { ret =3D qemu_rdma_reg_control(rdma, idx); if (ret) { - ERROR(temp, "rdma migration: error registering %d control!", + ERROR(errp, "rdma migration: error registering %d control!", idx); goto err_rdma_source_init; } @@ -2498,7 +2497,6 @@ static int qemu_rdma_source_init(RDMAContext *rdma, b= ool pin_all, Error **errp) return 0; =20 err_rdma_source_init: - error_propagate(errp, local_err); qemu_rdma_cleanup(rdma); return -1; } @@ -4103,7 +4101,6 @@ void rdma_start_incoming_migration(const char *host_p= ort, Error **errp) { int ret; RDMAContext *rdma; - Error *local_err =3D NULL; =20 trace_rdma_start_incoming_migration(); =20 @@ -4113,13 +4110,12 @@ void rdma_start_incoming_migration(const char *host= _port, Error **errp) return; } =20 - rdma =3D qemu_rdma_data_init(host_port, &local_err); + rdma =3D qemu_rdma_data_init(host_port, errp); if (rdma =3D=3D NULL) { goto err; } =20 - ret =3D qemu_rdma_dest_init(rdma, &local_err); - + ret =3D qemu_rdma_dest_init(rdma, errp); if (ret) { goto err; } @@ -4142,7 +4138,6 @@ void rdma_start_incoming_migration(const char *host_p= ort, Error **errp) cleanup_rdma: qemu_rdma_cleanup(rdma); err: - error_propagate(errp, local_err); if (rdma) { g_free(rdma->host); g_free(rdma->host_port); --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048619; cv=none; d=zohomail.com; s=zohoarc; b=iX/s2jjXzw7kFbYK4tcPOiYm0Y+6h64FrHviPbHCDG57on4YrG1+AmWeNUTu12ze1n+2DVywHov2yeH031yASx6F3/nTOGLB/+n2lmqLDx+1Qpr6crmZfvuHkKbMIIgOgFbaT+jsyGYO/02dYfvRnqWZu2fkqPfcj67prwbq9SM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048619; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CaZ0rOeVOeTdJlqiSpGYpItPgtwHBNWjsvsMWQtxwlc=; b=UwQokLk7qjdxhT2gm+xxeDFZJ+8tueL1gTFyuyPWMhxLElj09weH/iAMB1AN55gCVHdjV3VBYXQoQgqJFAGZbkps9Ez7Zid0YcH8UlZXjxXKdQnLMnfaZR4MlQ0hi2UAhRBqSL3B3uy7pU/r6RlY2EzvpeHqD5yX9XvI7Ceu7ok= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048619652147.4694839178751; Mon, 18 Sep 2023 07:50:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFSU-00035J-4p; Mon, 18 Sep 2023 10:42:42 -0400 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 1qiFSN-0002y8-E1 for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS2-0002ae-Oj for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:33 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-401-gznIVLpNM-mQudfpjTsaFQ-1; Mon, 18 Sep 2023 10:42:09 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 41DF93800BA8 for ; Mon, 18 Sep 2023 14:42:09 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1FDEF140E950 for ; Mon, 18 Sep 2023 14:42:09 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 08F4A21E6912; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048131; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CaZ0rOeVOeTdJlqiSpGYpItPgtwHBNWjsvsMWQtxwlc=; b=OqjzCntgOJ9ltpzVu4DYqMWa9Im/ELZflAMs4ocZJt9vGsBaU9EoZIPSmSui1fEgtGjd0r +5CuFJN4wsQ/+FyrXeU/jh+8coHvAfIECBTrf0AEPgJHTby/vce4adhJ7Wy1ls/3Sn11oc hQ44WujLYh6bT1j2RWHD1ar1337lbYQ= X-MC-Unique: gznIVLpNM-mQudfpjTsaFQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 11/52] migration/rdma: Drop rdma_add_block() error handling Date: Mon, 18 Sep 2023 16:41:25 +0200 Message-ID: <20230918144206.560120-12-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048620363100001 Content-Type: text/plain; charset="utf-8" rdma_add_block() can't fail. Return void, and drop the unreachable error handling. Signed-off-by: Markus Armbruster Reviewed-by: Fabiano Rosas Reviewed-by: Li Zhijian --- migration/rdma.c | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 960fff5860..2b0f9d52d8 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -559,9 +559,9 @@ static inline uint8_t *ram_chunk_end(const RDMALocalBlo= ck *rdma_ram_block, return result; } =20 -static int rdma_add_block(RDMAContext *rdma, const char *block_name, - void *host_addr, - ram_addr_t block_offset, uint64_t length) +static void rdma_add_block(RDMAContext *rdma, const char *block_name, + void *host_addr, + ram_addr_t block_offset, uint64_t length) { RDMALocalBlocks *local =3D &rdma->local_ram_blocks; RDMALocalBlock *block; @@ -615,8 +615,6 @@ static int rdma_add_block(RDMAContext *rdma, const char= *block_name, block->nb_chunks); =20 local->nb_blocks++; - - return 0; } =20 /* @@ -630,7 +628,8 @@ static int qemu_rdma_init_one_block(RAMBlock *rb, void = *opaque) void *host_addr =3D qemu_ram_get_host_addr(rb); ram_addr_t block_offset =3D qemu_ram_get_offset(rb); ram_addr_t length =3D qemu_ram_get_used_length(rb); - return rdma_add_block(opaque, block_name, host_addr, block_offset, len= gth); + rdma_add_block(opaque, block_name, host_addr, block_offset, length); + return 0; } =20 /* @@ -638,7 +637,7 @@ static int qemu_rdma_init_one_block(RAMBlock *rb, void = *opaque) * identify chunk boundaries inside each RAMBlock and also be referenced * during dynamic page registration. */ -static int qemu_rdma_init_ram_blocks(RDMAContext *rdma) +static void qemu_rdma_init_ram_blocks(RDMAContext *rdma) { RDMALocalBlocks *local =3D &rdma->local_ram_blocks; int ret; @@ -646,14 +645,11 @@ static int qemu_rdma_init_ram_blocks(RDMAContext *rdm= a) assert(rdma->blockmap =3D=3D NULL); memset(local, 0, sizeof *local); ret =3D foreach_not_ignored_block(qemu_rdma_init_one_block, rdma); - if (ret) { - return ret; - } + assert(!ret); trace_qemu_rdma_init_ram_blocks(local->nb_blocks); rdma->dest_blocks =3D g_new0(RDMADestBlock, rdma->local_ram_blocks.nb_blocks); local->init =3D true; - return 0; } =20 /* @@ -2471,11 +2467,7 @@ static int qemu_rdma_source_init(RDMAContext *rdma, = bool pin_all, Error **errp) goto err_rdma_source_init; } =20 - ret =3D qemu_rdma_init_ram_blocks(rdma); - if (ret) { - ERROR(errp, "rdma migration: error initializing ram blocks!"); - goto err_rdma_source_init; - } + qemu_rdma_init_ram_blocks(rdma); =20 /* Build the hash that maps from offset to RAMBlock */ rdma->blockmap =3D g_hash_table_new(g_direct_hash, g_direct_equal); @@ -3430,11 +3422,7 @@ static int qemu_rdma_accept(RDMAContext *rdma) goto err_rdma_dest_wait; } =20 - ret =3D qemu_rdma_init_ram_blocks(rdma); - if (ret) { - error_report("rdma migration: error initializing ram blocks!"); - goto err_rdma_dest_wait; - } + qemu_rdma_init_ram_blocks(rdma); =20 for (idx =3D 0; idx < RDMA_WRID_MAX; idx++) { ret =3D qemu_rdma_reg_control(rdma, idx); --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048592; cv=none; d=zohomail.com; s=zohoarc; b=nDhXeWhFnrR9HxC3aLIpetiVrUXmHRajo0oBrgLoUWX13owWol4R9PH+QfvU9bZDDAbmEalZwXEPZqPRB1o9tLdeWCypxxPQ4YK6yOVo/XxBGJfxtlc7mZBfxYAZTr90w729TEy111ai0Li/dB8NvJkRA8ZCxtffTAR4X/l11zo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048592; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pepCr2yk+wfEvOitliZG/utwoxvVW0Go0qMMH0tFqHs=; b=Xp2Lgwxx8DwWBZM2E7f0H8GL4ufGiURhIOnXsoRkVdF3kTBt4H1rBLt3uJwUKk3UHCDCPrGtbOTBSLKpwZSuVkusUql+xvlcKOf7+dmbAA9/xDWkjIeV9Z2pFHtgkFratn50C5z7jkeFqACf6BdblWvT5njg3d4KHe6YVO3MBag= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048592272863.6789728055488; Mon, 18 Sep 2023 07:49:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFSA-0002t0-Ea; Mon, 18 Sep 2023 10:42:22 -0400 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 1qiFS2-0002ri-QI for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS0-0002Zx-3U for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:13 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-92-xBQ85uWbO42x-xnY-qcHOQ-1; Mon, 18 Sep 2023 10:42:09 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4A93F855310 for ; Mon, 18 Sep 2023 14:42:09 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2892C20268CC for ; Mon, 18 Sep 2023 14:42:09 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 0BE2521E6913; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048130; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pepCr2yk+wfEvOitliZG/utwoxvVW0Go0qMMH0tFqHs=; b=PTKs30mnn1bf43Mbor1fW4DxK+CGxpP73Zbq6pgRCagdOUlGIw2nzpnC3l4PZ3QSQMz+VO Vp/BQLSu4VikMjlZXNh2K+P48qcdpoAbUWtbPJhUnhxh0PXxK2SX9R8E+p4wWrTgJ9vSFb Kr7bQe7n1bO/OyxEbVig9TNX/C9krZ4= X-MC-Unique: xBQ85uWbO42x-xnY-qcHOQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 12/52] migration/rdma: Drop qemu_rdma_search_ram_block() error handling Date: Mon, 18 Sep 2023 16:41:26 +0200 Message-ID: <20230918144206.560120-13-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048594023100007 Content-Type: text/plain; charset="utf-8" qemu_rdma_search_ram_block() can't fail. Return void, and drop the unreachable error handling. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian --- migration/rdma.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 2b0f9d52d8..98520a42b4 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1234,12 +1234,12 @@ static int qemu_rdma_reg_whole_ram_blocks(RDMAConte= xt *rdma) * * This search cannot fail or the migration will fail. */ -static int qemu_rdma_search_ram_block(RDMAContext *rdma, - uintptr_t block_offset, - uint64_t offset, - uint64_t length, - uint64_t *block_index, - uint64_t *chunk_index) +static void qemu_rdma_search_ram_block(RDMAContext *rdma, + uintptr_t block_offset, + uint64_t offset, + uint64_t length, + uint64_t *block_index, + uint64_t *chunk_index) { uint64_t current_addr =3D block_offset + offset; RDMALocalBlock *block =3D g_hash_table_lookup(rdma->blockmap, @@ -1251,8 +1251,6 @@ static int qemu_rdma_search_ram_block(RDMAContext *rd= ma, *block_index =3D block->index; *chunk_index =3D ram_chunk_index(block->local_host_addr, block->local_host_addr + (current_addr - block->offset)); - - return 0; } =20 /* @@ -2321,12 +2319,8 @@ static int qemu_rdma_write(QEMUFile *f, RDMAContext = *rdma, rdma->current_length =3D 0; rdma->current_addr =3D current_addr; =20 - ret =3D qemu_rdma_search_ram_block(rdma, block_offset, - offset, len, &index, &chunk); - if (ret) { - error_report("ram block search failed"); - return ret; - } + qemu_rdma_search_ram_block(rdma, block_offset, + offset, len, &index, &chunk); rdma->current_index =3D index; rdma->current_chunk =3D chunk; } --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048327; cv=none; d=zohomail.com; s=zohoarc; b=LNW2usBMml6jDuJfJMQNmChcmFqpQJqIq3sG2wo/RQxtHp2OYrwWE/3MaGjkdMS6GENqnfUk8OlyDA6nHcRNHlwKNrUjRvciSPWVmXoo9vbzKFqhY4gyTGixh+wVj3MDDJKgdKdAvbSd+gI/QLIsFSvlfZRvkS7fWLDaFY+fkzg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048327; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aJm19gRF1BeP3FlRLLg1oF19qpeBGox3CvwduF1S/+Y=; b=NwMwoUnkTImAONOGLLabN2cDQbXAnIoYNpumorQMlxjSGi98dYRbKD9xtgX7fzH7QP0zkCzUQFit1i18WCzbJWB69GNUAdsufgnzHYNcxi0mi3O+NQFOEDnQpk0UvqUhgmej62Lk1Vrmy9IVoGJ38uQv8Z0GcOhjMlm8sy+s9Rc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048327357358.18876730459033; Mon, 18 Sep 2023 07:45:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFSw-0003D6-Ng; Mon, 18 Sep 2023 10:43:10 -0400 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 1qiFSK-0002x0-PB for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS2-0002aG-NR for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:32 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-483-mQAznEE5NaWBQaqkQt9F7A-1; Mon, 18 Sep 2023 10:42:09 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4984429AA2C9 for ; Mon, 18 Sep 2023 14:42:09 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 27D8F10F1BE7 for ; Mon, 18 Sep 2023 14:42:09 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 0EB5721E6914; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048131; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aJm19gRF1BeP3FlRLLg1oF19qpeBGox3CvwduF1S/+Y=; b=IuofjNPO26VeXvCxE5onIBZ8ghTzzBsVrqA/Pn2+E+7FHKg8o2rQGDZ88JJyl9v1cDm/nx AbzwrFn/217jiDUYS5C40u8Ijg8tRRJY0xvACaEapzXX/a7ehz5J1chFh/xPbZ4eFDAFbh tSJisc+clgqvwhcmAfyrFmCYXtKCvZk= X-MC-Unique: mQAznEE5NaWBQaqkQt9F7A-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 13/52] migration/rdma: Make qemu_rdma_buffer_mergable() return bool Date: Mon, 18 Sep 2023 16:41:27 +0200 Message-ID: <20230918144206.560120-14-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048328426100011 Content-Type: text/plain; charset="utf-8" qemu_rdma_buffer_mergable() is semantically a predicate. It returns int 0 or 1. Return bool instead. Signed-off-by: Markus Armbruster Reviewed-by: Fabiano Rosas Reviewed-by: Li Zhijian --- migration/rdma.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 98520a42b4..97715dbd78 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -2246,7 +2246,7 @@ static int qemu_rdma_write_flush(QEMUFile *f, RDMACon= text *rdma) return 0; } =20 -static inline int qemu_rdma_buffer_mergable(RDMAContext *rdma, +static inline bool qemu_rdma_buffer_mergable(RDMAContext *rdma, uint64_t offset, uint64_t len) { RDMALocalBlock *block; @@ -2254,11 +2254,11 @@ static inline int qemu_rdma_buffer_mergable(RDMACon= text *rdma, uint8_t *chunk_end; =20 if (rdma->current_index < 0) { - return 0; + return false; } =20 if (rdma->current_chunk < 0) { - return 0; + return false; } =20 block =3D &(rdma->local_ram_blocks.block[rdma->current_index]); @@ -2266,29 +2266,29 @@ static inline int qemu_rdma_buffer_mergable(RDMACon= text *rdma, chunk_end =3D ram_chunk_end(block, rdma->current_chunk); =20 if (rdma->current_length =3D=3D 0) { - return 0; + return false; } =20 /* * Only merge into chunk sequentially. */ if (offset !=3D (rdma->current_addr + rdma->current_length)) { - return 0; + return false; } =20 if (offset < block->offset) { - return 0; + return false; } =20 if ((offset + len) > (block->offset + block->length)) { - return 0; + return false; } =20 if ((host_addr + len) > chunk_end) { - return 0; + return false; } =20 - return 1; + return true; } =20 /* --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048706; cv=none; d=zohomail.com; s=zohoarc; b=QhWQCih8P5bak+NnmR4Spx2TC2WrEtzUHo56FKJbss7cPQHgfBNcXme72Fv1aMJKO8zXcmKLWRyg+qzGuvJySS5qfvkcjoj4oOjQFWm/xUL/T5jCBwnbQRWpqsyccQJ/BWC+HltWn1bBdxY4i6E+evc1p2/ebjJzqX5pB4ZPshw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048706; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yYvmrlPLuBNVSwKQ7adAQsn1lGE6cQOL8Y59t899Zak=; b=Hj5zB8LnnMk9XXSkyWXGfgIH9GWuKu10W6fumUw3BW2QscIdvW60Cx8zq/15Xmyt9PgjNB6iiE+tHuD18s8/1TIlza5mrEKy/Gvk8J/JQbsfu/ka1A7KX+1fvoTLJTmA0YvlIdSsmi9JBK1qa++LFfVRtmj7gJqf8zPOYK7ER8o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048706574738.1303440795562; Mon, 18 Sep 2023 07:51:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFSV-00035g-C6; Mon, 18 Sep 2023 10:42:43 -0400 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 1qiFSF-0002vf-Gx for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS0-0002aN-4M for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:27 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-187-j2wMl4t_PM2dn-GAjzsmtw-1; Mon, 18 Sep 2023 10:42:09 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5058B3800BA5 for ; Mon, 18 Sep 2023 14:42:09 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2DB0E1C646 for ; Mon, 18 Sep 2023 14:42:09 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 11BF921E6915; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048131; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yYvmrlPLuBNVSwKQ7adAQsn1lGE6cQOL8Y59t899Zak=; b=Pdrci5KGBnD9XikPpNowVIDV0GuVvKy7+DgMxgo/EVHkPolf5fDGdmn6oKHH1AOdrPTVW6 13gC7bxx/+69VInMFkd4lt90fbdrNKuDW/sgBtmBDNdXPuYbqPwenY/2Ot263+BHJYDgEj +xxLW8yWjkfO2aOjsgpEJWfKTq6FR9Y= X-MC-Unique: j2wMl4t_PM2dn-GAjzsmtw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 14/52] migration/rdma: Use bool for two RDMAContext flags Date: Mon, 18 Sep 2023 16:41:28 +0200 Message-ID: <20230918144206.560120-15-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048708708100001 Content-Type: text/plain; charset="utf-8" @error_reported and @received_error are flags. The latter is even assigned bool true. Change them from int to bool. Signed-off-by: Markus Armbruster Reviewed-by: Fabiano Rosas Reviewed-by: Li Zhijian --- migration/rdma.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 97715dbd78..c02a1c83b2 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -91,7 +91,7 @@ static uint32_t known_capabilities =3D RDMA_CAPABILITY_PI= N_ALL; if (!rdma->error_reported) { \ error_report("RDMA is in an error state waiting migration"= \ " to abort!"); \ - rdma->error_reported =3D 1; \ + rdma->error_reported =3D true; \ } \ return rdma->error_state; \ } \ @@ -365,8 +365,8 @@ typedef struct RDMAContext { * and remember the error state. */ int error_state; - int error_reported; - int received_error; + bool error_reported; + bool received_error; =20 /* * Description of ram blocks used throughout the code. --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048585; cv=none; d=zohomail.com; s=zohoarc; b=YsyJQrxt6Rf5S+tXxa6/hhioiuHjPTGc+hsLj4xNH5rUWnaQ5bzYZzwW1ZWhlXSA4vJIwtrqFs+MXduA7UI/uCP7mRHLnt5X4jWfY4QhgQGRfQHgSTjCFVzHs7KHmBwA8DDm1vi9rbog8xHW/sVymOze4qvqZ5G9dR/l0XRSNE4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048585; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZcWti18dwwllfL572IZaMCvlHY/GDW+tOkthQ2IfWIQ=; b=EYEVrpssECBRpcGHQPQ+TbXOZz0gE0MLcmqBhfzzIqMjJ1ZRpfMearled7u4WWR40kJmCYuxFMi5X4a/rfhSy3v+0YWgkVHp17d8koKFgyXf0BF4s086P7fwzodS2nalBdQ+booxeiM4HcPynQbnXQlQ414PI7caPa3CffpK87g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048585013194.087284928357; Mon, 18 Sep 2023 07:49:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFSR-00032D-2P; Mon, 18 Sep 2023 10:42:39 -0400 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 1qiFSI-0002w2-46 for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS2-0002au-Lj for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:29 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-198-YQ2NbDiHM4KDqL6iTze1Ig-1; Mon, 18 Sep 2023 10:42:10 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 481823C0E442 for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0B13340C6EBF for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 14A4521E6916; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048132; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZcWti18dwwllfL572IZaMCvlHY/GDW+tOkthQ2IfWIQ=; b=YyyUjcsx13PixOdxir36SDAkt68xbXcStr/kDh6mHPx0DSWdx2MAvAMyoSfhOxnOEi6iGu bHGw+SV6Ukr3igKxAJfg0cNfo3p3b0wnuOqvnbe7hwEnYjaFeVBM6xTaDFvzmg6ltEW6m5 zRsNrhwMtN7AuXMukB2aBCR8nimg+64= X-MC-Unique: YQ2NbDiHM4KDqL6iTze1Ig-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 15/52] migration/rdma: Ditch useless numeric error codes in error messages Date: Mon, 18 Sep 2023 16:41:29 +0200 Message-ID: <20230918144206.560120-16-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048585775100002 Content-Type: text/plain; charset="utf-8" Several error messages include numeric error codes returned by failed functions: * ibv_poll_cq() returns an unspecified negative value. Useless. * rdma_accept and rmda_get_cm_event() return -1. Useless. * qemu_rdma_poll() returns either -1 or an unspecified negative value. Useless. * qemu_rdma_block_for_wrid(), qemu_rdma_write_flush(), qemu_rdma_exchange_send(), qemu_rdma_exchange_recv(), qemu_rdma_write() return a negative value that may or may not be an errno value. While reporting human-readable errno information (which a number is not) can be useful, reporting an error code that may or may not be an errno value is useless. Drop these error codes from the error messages. Signed-off-by: Markus Armbruster Reviewed-by: Fabiano Rosas Reviewed-by: Li Zhijian --- migration/rdma.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index c02a1c83b2..2173cb076f 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1460,7 +1460,7 @@ static int qemu_rdma_poll(RDMAContext *rdma, struct i= bv_cq *cq, } =20 if (ret < 0) { - error_report("ibv_poll_cq return %d", ret); + error_report("ibv_poll_cq failed"); return ret; } =20 @@ -2194,7 +2194,7 @@ retry: ret =3D qemu_rdma_block_for_wrid(rdma, RDMA_WRID_RDMA_WRITE, NULL); if (ret < 0) { error_report("rdma migration: failed to make " - "room in full send queue! %d", ret); + "room in full send queue!"); return ret; } =20 @@ -2770,7 +2770,7 @@ 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; - error_setg(errp, "qemu_rdma_write_flush returned %d", ret); + error_setg(errp, "qemu_rdma_write_flush failed"); return -1; } =20 @@ -2790,7 +2790,7 @@ static ssize_t qio_channel_rdma_writev(QIOChannel *io= c, =20 if (ret < 0) { rdma->error_state =3D ret; - error_setg(errp, "qemu_rdma_exchange_send returned %d", re= t); + error_setg(errp, "qemu_rdma_exchange_send failed"); return -1; } =20 @@ -2880,7 +2880,7 @@ static ssize_t qio_channel_rdma_readv(QIOChannel *ioc, =20 if (ret < 0) { rdma->error_state =3D ret; - error_setg(errp, "qemu_rdma_exchange_recv returned %d", ret); + error_setg(errp, "qemu_rdma_exchange_recv failed"); return -1; } =20 @@ -3222,7 +3222,7 @@ static size_t qemu_rdma_save_page(QEMUFile *f, */ ret =3D qemu_rdma_write(f, rdma, block_offset, offset, size); if (ret < 0) { - error_report("rdma migration: write error! %d", ret); + error_report("rdma migration: write error"); goto err; } =20 @@ -3249,7 +3249,7 @@ static size_t qemu_rdma_save_page(QEMUFile *f, uint64_t wr_id, wr_id_in; int ret =3D qemu_rdma_poll(rdma, rdma->recv_cq, &wr_id_in, NULL); if (ret < 0) { - error_report("rdma migration: polling error! %d", ret); + error_report("rdma migration: polling error"); goto err; } =20 @@ -3264,7 +3264,7 @@ static size_t qemu_rdma_save_page(QEMUFile *f, uint64_t wr_id, wr_id_in; int ret =3D qemu_rdma_poll(rdma, rdma->send_cq, &wr_id_in, NULL); if (ret < 0) { - error_report("rdma migration: polling error! %d", ret); + error_report("rdma migration: polling error"); goto err; } =20 @@ -3439,13 +3439,13 @@ static int qemu_rdma_accept(RDMAContext *rdma) =20 ret =3D rdma_accept(rdma->cm_id, &conn_param); if (ret) { - error_report("rdma_accept returns %d", ret); + error_report("rdma_accept failed"); goto err_rdma_dest_wait; } =20 ret =3D rdma_get_cm_event(rdma->channel, &cm_event); if (ret) { - error_report("rdma_accept get_cm_event failed %d", ret); + error_report("rdma_accept get_cm_event failed"); goto err_rdma_dest_wait; } =20 --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048682; cv=none; d=zohomail.com; s=zohoarc; b=lu3YM8cJms65MG0qbwkqF3x4uJGc7n16vg1H6EW9hYDMuaQFGRV9XQbWw8ngU2ynHgZ01CU3rPwhZEcKmSZngpBJxE7TDVZRDOfhoxrp68X/hiWLQ2PpyCGz0iDm4FpkwGPfik6WS6DuRqOn7kmTYG98jH8XHqWmcSEF+SvhpNk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048682; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3yqLeYQ+wzrOKTYBgpuJP4VgHhHFEjpE7p+Go3JCE+g=; b=YpbGOLah+cTUPVow/zWYkNEUxwFKnE2F9jwL87zpJ14O4bX27mJLPNGWPpNoL/+gXMDrOenRoH00DGUQbM3+g9LLW+dZEaEjcbg35B+2LFfikGAKQcpKqvCW9C1+R8JObtAm649gf7RZ7Y/A8Hqu09xUMURQZYQUJwghGC1rk1g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048682415380.81722688237494; Mon, 18 Sep 2023 07:51:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFTR-000511-E9; Mon, 18 Sep 2023 10:43:41 -0400 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 1qiFSw-0003Cb-9x for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:43:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFSt-0002uz-7T for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:43:08 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-222-9m3l8agwMAaArqX3ga3IYg-1; Mon, 18 Sep 2023 10:42:22 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2D80418175A4 for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0C11C2156702 for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 177E021E691A; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048185; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3yqLeYQ+wzrOKTYBgpuJP4VgHhHFEjpE7p+Go3JCE+g=; b=ZlDGhUDa04ck1qiik4vTWVdzJzc/RIH3YybUiES7uc1YdEeuyeTOVb4QiuMjNksigIKW3w mQ+TLJud/r4iJzA21c8+7W4PmhCCtSSf7SDvQdJlLHSyOgRCmXrdt6nuk9qepVihy2MHoN WCp0fSX2uZThkUnZ/rVHi1GMBuSd4fA= X-MC-Unique: 9m3l8agwMAaArqX3ga3IYg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 16/52] migration/rdma: Fix io_writev(), io_readv() methods to obey contract Date: Mon, 18 Sep 2023 16:41:30 +0200 Message-ID: <20230918144206.560120-17-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048684507100011 Content-Type: text/plain; charset="utf-8" QIOChannelClass methods qio_channel_rdma_readv() and qio_channel_rdma_writev() violate their method contract when rdma->error_state is non-zero: 1. They return whatever is in rdma->error_state then. Only -1 will be fine. -2 will be misinterpreted as "would block". Anything less than -2 isn't defined in the contract. A positive value would be misinterpreted as success, but I believe that's not actually possible. 2. They neglect to set an error then. If something up the call stack dereferences the error when failure is returned, it will crash. If it ignores the return value and checks the error instead, it will miss the error. Crap like this happens when return statements hide in macros, especially when their uses are far away from the definition. I elected not to investigate how callers are impacted. Expand the two bad macro uses, so we can set an error and return -1. The next commit will then get rid of the macro altogether. Signed-off-by: Markus Armbruster Reviewed-by: Fabiano Rosas Reviewed-by: Li Zhijian --- migration/rdma.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 2173cb076f..30e6dff875 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -2761,7 +2761,11 @@ static ssize_t qio_channel_rdma_writev(QIOChannel *i= oc, return -1; } =20 - CHECK_ERROR_STATE(); + if (rdma->error_state) { + error_setg(errp, + "RDMA is in an error state waiting migration to abort!"= ); + return -1; + } =20 /* * Push out any writes that @@ -2847,7 +2851,11 @@ static ssize_t qio_channel_rdma_readv(QIOChannel *io= c, return -1; } =20 - CHECK_ERROR_STATE(); + if (rdma->error_state) { + error_setg(errp, + "RDMA is in an error state waiting migration to abort!"= ); + return -1; + } =20 for (i =3D 0; i < niov; i++) { size_t want =3D iov[i].iov_len; --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048628; cv=none; d=zohomail.com; s=zohoarc; b=cNndqDQ+l6DrM59WpTbaKg9L2/De6FaW1y4OcSWVymkbDn/Y5pVVUYTnTenI+jyAsIsOhvYhJtuH/K4UvyElNnXDNLpvP1+hcLDpdFVbodO5GrtjNaiemc4+kPADaQvae7IHtioPKljd1peW/gHRtVicx2Z937mLd4JQWwVIVEM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048628; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KICyPLkmvqj/30Z29ko6BQBtIIMhvIUkvS/e3H8ki4c=; b=lDXJccgYCpT5NcwhdVMfwU26XgN6IoI5gsjWCGM4VgeMtYNkMyTflxED96f7JgG0otHRGr0POmNMglfH8QCQJQURuVuERJRkjy1WJgq1XdmKBlAWw9TRkHd/j1jlAlcJuPauc6VOwlFXlakkhT0AHRYZYpqq+JKaLMbT1Jl5XX8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048628804391.4002987885052; Mon, 18 Sep 2023 07:50:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFT5-0003JH-Lf; Mon, 18 Sep 2023 10:43:19 -0400 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 1qiFSN-0002yC-FL for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS2-0002bA-PI for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:33 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-158--GzE2ERKMZyDi4WHFD9RPA-1; Mon, 18 Sep 2023 10:42:10 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 310303C00088 for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0F323140E950 for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 1A75521E691B; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048132; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KICyPLkmvqj/30Z29ko6BQBtIIMhvIUkvS/e3H8ki4c=; b=YcifMSrLTlkJL8QnLwDv91UszF3ELiABbeEBFL7eEJv+nYEQPGQ0pI+mxI02q48jgd7Luu Si+wOWto1QWeTSu2U0r0hj7jlm2FELU4w+1q+Nmu0qdU9oMfHFH9WFt9DEzf6BPa86VpF7 9RN7b7CigLNwx5BqbJjP84vn2hlmEqY= X-MC-Unique: -GzE2ERKMZyDi4WHFD9RPA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 17/52] migration/rdma: Replace dangerous macro CHECK_ERROR_STATE() Date: Mon, 18 Sep 2023 16:41:31 +0200 Message-ID: <20230918144206.560120-18-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048629435100001 Content-Type: text/plain; charset="utf-8" Hiding return statements in macros is a bad idea. Use a function instead, and open code the return part. Signed-off-by: Markus Armbruster Reviewed-by: Fabiano Rosas Reviewed-by: Li Zhijian --- migration/rdma.c | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 30e6dff875..be66f53489 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -85,18 +85,6 @@ */ static uint32_t known_capabilities =3D RDMA_CAPABILITY_PIN_ALL; =20 -#define CHECK_ERROR_STATE() \ - do { \ - if (rdma->error_state) { \ - if (!rdma->error_reported) { \ - error_report("RDMA is in an error state waiting migration"= \ - " to abort!"); \ - rdma->error_reported =3D true; \ - } \ - return rdma->error_state; \ - } \ - } while (0) - /* * A work request ID is 64-bits and we split up these bits * into 3 parts: @@ -451,6 +439,16 @@ typedef struct QEMU_PACKED { uint64_t chunks; /* how many sequential chunks to register = */ } RDMARegister; =20 +static int check_error_state(RDMAContext *rdma) +{ + if (rdma->error_state && !rdma->error_reported) { + error_report("RDMA is in an error state waiting migration" + " to abort!"); + rdma->error_reported =3D true; + } + return rdma->error_state; +} + static void register_to_network(RDMAContext *rdma, RDMARegister *reg) { RDMALocalBlock *local_block; @@ -3219,7 +3217,10 @@ static size_t qemu_rdma_save_page(QEMUFile *f, return -EIO; } =20 - CHECK_ERROR_STATE(); + ret =3D check_error_state(rdma); + if (ret) { + return ret; + } =20 qemu_fflush(f); =20 @@ -3535,7 +3536,10 @@ static int qemu_rdma_registration_handle(QEMUFile *f) return -EIO; } =20 - CHECK_ERROR_STATE(); + ret =3D check_error_state(rdma); + if (ret) { + return ret; + } =20 local =3D &rdma->local_ram_blocks; do { @@ -3839,6 +3843,7 @@ static int qemu_rdma_registration_start(QEMUFile *f, { QIOChannelRDMA *rioc =3D QIO_CHANNEL_RDMA(qemu_file_get_ioc(f)); RDMAContext *rdma; + int ret; =20 if (migration_in_postcopy()) { return 0; @@ -3850,7 +3855,10 @@ static int qemu_rdma_registration_start(QEMUFile *f, return -EIO; } =20 - CHECK_ERROR_STATE(); + ret =3D check_error_state(rdma); + if (ret) { + return ret; + } =20 trace_qemu_rdma_registration_start(flags); qemu_put_be64(f, RAM_SAVE_FLAG_HOOK); @@ -3881,7 +3889,10 @@ static int qemu_rdma_registration_stop(QEMUFile *f, return -EIO; } =20 - CHECK_ERROR_STATE(); + ret =3D check_error_state(rdma); + if (ret) { + return ret; + } =20 qemu_fflush(f); ret =3D qemu_rdma_drain_cq(f, rdma); --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048444; cv=none; d=zohomail.com; s=zohoarc; b=T74SS4Gqdsz4mtlBD62GyLRSzFHolFVTiUovIRTIUgr9vYC+4avnxISp4ony2vm6exVbWrMBAWaYHIYZudm4Oz9uDye90dCarHASfVYCzyReomQWwIk3fUw9jZpSunWMBiUnAsHDAcdNu35Mt1mwfO7fPlLysp92/BTLQ8qyNJQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048444; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bpdGgm08OVsmJH6IiROCStU+xrwCAY2JKPxcwal44OQ=; b=Fz0+YCofff/S1i5bNsGFe82TEVYIa3DxsBa4G+6d2X48Z+NzOWiJjHrxvD3WdK3K0Pmq9ZdAy+DNSUohRK+7Syc+WqAxLepinvDnQ5+zttPHi8WlbHqdLmYTtQeQJ2aZhnLZWuRn7ehEMDZZXFoAUNOa54zd6dgx4n4R0DydEL0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16950484445387.753794163294515; Mon, 18 Sep 2023 07:47:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFSS-00035A-FI; Mon, 18 Sep 2023 10:42:40 -0400 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 1qiFSN-0002yH-HX for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS2-0002b0-QP for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:34 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-493-ChTB11BYPT2_dJPKw_JPlQ-1; Mon, 18 Sep 2023 10:42:10 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2E5081C0514B for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0C2414021A9 for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 1D2B721E691C; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048132; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bpdGgm08OVsmJH6IiROCStU+xrwCAY2JKPxcwal44OQ=; b=BpLq1+M/DWoOahYIUL/9aBvZvDfRkTuk016IMtgQvd7inCsNF5OK5MOZ6EDYXjUXJzEpWc xsUo1+gz6WC+r2BSrA2FWAiCjBzBcaAB0+5kw+0zPvzW9lifZMbelhC58hyp1BgtY915oK pG7e/7xdrdmRgesZQqiLwAbuf02KqCw= X-MC-Unique: ChTB11BYPT2_dJPKw_JPlQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 18/52] migration/rdma: Fix qemu_rdma_broken_ipv6_kernel() to set error Date: Mon, 18 Sep 2023 16:41:32 +0200 Message-ID: <20230918144206.560120-19-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048446623100009 Content-Type: text/plain; charset="utf-8" qemu_rdma_resolve_host() and qemu_rdma_dest_init() try addresses until they find on that works. If none works, they return the first Error set by qemu_rdma_broken_ipv6_kernel(), or else return a generic one. qemu_rdma_broken_ipv6_kernel() neglects to set an Error when ibv_open_device() fails. If a later address fails differently, we use that Error instead, or else the generic one. Harmless enough, but needs fixing all the same. Signed-off-by: Markus Armbruster Reviewed-by: Fabiano Rosas Reviewed-by: Li Zhijian --- migration/rdma.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/migration/rdma.c b/migration/rdma.c index be66f53489..08cd186385 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -855,6 +855,8 @@ static int qemu_rdma_broken_ipv6_kernel(struct ibv_cont= ext *verbs, Error **errp) if (errno =3D=3D EPERM) { continue; } else { + error_setg_errno(errp, errno, + "could not open RDMA device context"); return -EINVAL; } } --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048509; cv=none; d=zohomail.com; s=zohoarc; b=ZrtgOfYUo8e3A+0nza6IXyuCQdTgONKMdbAzHJp0fRghhDvww08t86aAYlJX49xoHtYdMv4sQK5hmAqHH0tz6EHE+p8XNOApbojzeBlVzqb9C4PSgtxCkigZtT3uPH9f4gXJCIUVxUCeqEQs5YQAKqPICxhFvpHGIg6VnFBROSM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048509; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jSr+anHdxk2uJGfweDbjBtw6bdH7EJatp1kCgdQaJcA=; b=LcyYk7LbVxi07lJozMZr11xhE/5I5Sj0osIByw58F9GdsITY+Q/SE3SOSBH25H/L2Nl2qFDFFTXoVXRQ7Az4SIIGX681EDDQY1e3Yj6rkds+T8/NfNi61cbS9Eh5ib7saoNlVLN6YB4kv18naRumy5ClkKmeJnLDlOm0Ff52Ncs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048509975816.0984540166221; Mon, 18 Sep 2023 07:48:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFSR-000348-RH; Mon, 18 Sep 2023 10:42:39 -0400 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 1qiFSK-0002x3-P3 for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS2-0002b2-Mn for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:31 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-571-GkmEk1q_NByvy6793O7hRA-1; Mon, 18 Sep 2023 10:42:10 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 310EF101B041 for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0F77910EE859 for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 2022621E6880; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048132; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jSr+anHdxk2uJGfweDbjBtw6bdH7EJatp1kCgdQaJcA=; b=I9ixiQnu3lFmM6hRzHlDoiVfscUQwgiBljUEUy+3p/OFbdbQOEtxjiq+Y4HQ7ZnDB/QRSr Z8k3zFS/KheY5vsjd+keVJmDOSh+OpjLZd73o63NFEL0DZiz6FmorfqK16is67jDCvw21U K0V4mCHN8Y4IGLLipaiyeILMVx7TRCM= X-MC-Unique: GkmEk1q_NByvy6793O7hRA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 19/52] migration/rdma: Fix qemu_get_cm_event_timeout() to always set error Date: Mon, 18 Sep 2023 16:41:33 +0200 Message-ID: <20230918144206.560120-20-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048511064100003 Content-Type: text/plain; charset="utf-8" qemu_get_cm_event_timeout() neglects to set an error when it fails because rdma_get_cm_event() fails. Harmless, as its caller qemu_rdma_connect() substitutes a generic error then. Fix it anyway. qemu_rdma_connect() also sets the generic error when its own call of rdma_get_cm_event() fails. Make the error handling more obvious: set a specific error right after rdma_get_cm_event() fails. Delete the generic error. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian Reviewed-by: Peter Xu --- migration/rdma.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 08cd186385..d3dc162363 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -2509,7 +2509,11 @@ static int qemu_get_cm_event_timeout(RDMAContext *rd= ma, ERROR(errp, "failed to poll cm event, errno=3D%i", errno); return -1; } else if (poll_fd.revents & POLLIN) { - return rdma_get_cm_event(rdma->channel, cm_event); + if (rdma_get_cm_event(rdma->channel, cm_event) < 0) { + ERROR(errp, "failed to get cm event"); + return -1; + } + return 0; } else { ERROR(errp, "no POLLIN event, revent=3D%x", poll_fd.revents); return -1; @@ -2559,10 +2563,12 @@ static int qemu_rdma_connect(RDMAContext *rdma, boo= l return_path, ret =3D qemu_get_cm_event_timeout(rdma, &cm_event, 5000, errp); } else { ret =3D rdma_get_cm_event(rdma->channel, &cm_event); + if (ret < 0) { + ERROR(errp, "failed to get cm event"); + } } if (ret) { perror("rdma_get_cm_event after rdma_connect"); - ERROR(errp, "connecting to destination!"); goto err_rdma_source_connect; } =20 --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048327; cv=none; d=zohomail.com; s=zohoarc; b=ZPUw45hz2ktt6efqwpCq5KbVvXZUNaWoM3dR/9ZhCpQ1jIpemgSiMjI/TifQCieIOv+ild7E7mMx5d3R6Fv9Kz/+Kkzpr/7U8zaqy4bsGt7QjwmF+dt5n1KmWbaaKXDRVlynp7y4DMXuUeqLjHAtnguMcEYAlF4EhSNJkVf45BU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048327; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mkPGhjLhvKknGBeX6UOrQzLJAqexuQGYBb4RhgGzqoQ=; b=ct+Y4GRLfVX0bc+5Amdewkd0rVanWthkldU55X1Ik1ZxM1wNRWa3XPwaAm6QfjRIapb1JNFdvZMecMnT6fTISI/rwJgva2+6Xu8u2cWjcrrcmyyuwaAc/29ULNjvGyjNm6ngQecBTWUWzY3eO7kgJXXUUmkz+Zj9+w6YbxiDDoo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048327500970.1546231895329; Mon, 18 Sep 2023 07:45:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFSN-0002yo-P7; Mon, 18 Sep 2023 10:42:35 -0400 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 1qiFSE-0002v0-A9 for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS2-0002ar-Iw for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:26 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-176-1-S9yRZOO6qbKmBko38-xg-1; Mon, 18 Sep 2023 10:42:10 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 324BB29AA2C6 for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 10BCB20268CC for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 22F1321E6882; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048132; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mkPGhjLhvKknGBeX6UOrQzLJAqexuQGYBb4RhgGzqoQ=; b=gpdqjsdoTLN1GIVTkRwJlk97TarfqGtcOc1pTuZI7xU0voi2Z9wQ6cRkDFoP9IeXwctSBk pOVlGpMvhWGWtpTLwK20AmuGV1s5+pyIgdJ59/0DVGQROJKVyQ+R6NpYpb+r+PPKCY1x// M+QSQTvqn4tKlke/ABkJ5xGwc24hZao= X-MC-Unique: 1-S9yRZOO6qbKmBko38-xg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 20/52] migration/rdma: Drop dead qemu_rdma_data_init() code for !@host_port Date: Mon, 18 Sep 2023 16:41:34 +0200 Message-ID: <20230918144206.560120-21-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048329308100023 Content-Type: text/plain; charset="utf-8" qemu_rdma_data_init() neglects to set an Error when it fails because @host_port is null. Fortunately, no caller passes null, so this is merely a latent bug. Drop the flawed code handling null argument. Signed-off-by: Markus Armbruster --- migration/rdma.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index d3dc162363..cc59155a50 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -2716,25 +2716,22 @@ static RDMAContext *qemu_rdma_data_init(const char = *host_port, Error **errp) RDMAContext *rdma =3D NULL; InetSocketAddress *addr; =20 - if (host_port) { - rdma =3D g_new0(RDMAContext, 1); - rdma->current_index =3D -1; - rdma->current_chunk =3D -1; + rdma =3D g_new0(RDMAContext, 1); + rdma->current_index =3D -1; + rdma->current_chunk =3D -1; =20 - addr =3D g_new(InetSocketAddress, 1); - if (!inet_parse(addr, host_port, NULL)) { - rdma->port =3D atoi(addr->port); - rdma->host =3D g_strdup(addr->host); - rdma->host_port =3D g_strdup(host_port); - } else { - ERROR(errp, "bad RDMA migration address '%s'", host_port); - g_free(rdma); - rdma =3D NULL; - } - - qapi_free_InetSocketAddress(addr); + addr =3D g_new(InetSocketAddress, 1); + if (!inet_parse(addr, host_port, NULL)) { + rdma->port =3D atoi(addr->port); + rdma->host =3D g_strdup(addr->host); + rdma->host_port =3D g_strdup(host_port); + } else { + ERROR(errp, "bad RDMA migration address '%s'", host_port); + g_free(rdma); + rdma =3D NULL; } =20 + qapi_free_InetSocketAddress(addr); return rdma; } =20 --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048798; cv=none; d=zohomail.com; s=zohoarc; b=BcbmYm+0u3PZTpDbjuXA4yFtWxkFMuvy2Txg05HcLEBCuoC4MG5+TfkYKxKPCrALsAGpaR4kiFsrPOCJ3/+IAE/qtJp7W8w/NdIGv6q9+TXitQfezPOgmKfpzdswyxd2M300EFRXAK3LBiviu3NKxO70MTg3jUCSF1oXH7Xzhpo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048798; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HQ61j2Zgip8o1cN4xMcrEYRa/ZV8n/yZ2vZdVFbDNtA=; b=SvAzBaJbXy4g+NDb3YN1+sDcUga7CrK9Htb1znBjEhYqUSuwktUpFSyOblGidHSzET60pkfAi8Iimo7VAlyplfes2GBQpZaPdtIEsXLRX3OXQAGzDyLBemlqcgx8guzO6x1gDF6TBjwNbWiXDlfv4HWE1gWDU+/8fKuidJE9XZg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048798102466.04568141378525; Mon, 18 Sep 2023 07:53:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFT4-0003Hf-E8; Mon, 18 Sep 2023 10:43:18 -0400 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 1qiFSV-00035j-Hg for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS5-0002cZ-6r for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:43 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-329-gkQ-I8lQNLGkn2rdOrxPXg-1; Mon, 18 Sep 2023 10:42:11 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 55AFF85A5BD for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 165B040C2064 for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 25C1821E6883; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048133; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HQ61j2Zgip8o1cN4xMcrEYRa/ZV8n/yZ2vZdVFbDNtA=; b=eWWfA6oyz56K6Jt4BegFNlmeryT3+gN0qoj9I83MJSeSyfrrcjB9oE1HM4SOCgfFL2WG7k WSfPGk/3wNYRqLWJx4XKI/yK4VyaLTDwoxjt7m5oEfWGeBDlh+ApzJFB0i7NZ3qvTE6oUc DXeMWiq2FmNQp0ObtULweXK2TROk+Ro= X-MC-Unique: gkQ-I8lQNLGkn2rdOrxPXg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 21/52] migration/rdma: Fix QEMUFileHooks method return values Date: Mon, 18 Sep 2023 16:41:35 +0200 Message-ID: <20230918144206.560120-22-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048798476100001 Content-Type: text/plain; charset="utf-8" The QEMUFileHooks methods don't come with a written contract. Digging through the code calling them, we find: * save_page(): Negative values RAM_SAVE_CONTROL_DELAYED and RAM_SAVE_CONTROL_NOT_SUPP are special. Any other negative value is an unspecified error. qemu_rdma_save_page() returns -EIO or rdma->error_state on error. I believe the latter is always negative. Nothing stops either of them to clash with the special values, though. Feels unlikely, but fix it anyway to return only the special values and -1. * before_ram_iterate(), after_ram_iterate(): Negative value means error. qemu_rdma_registration_start() and qemu_rdma_registration_stop() comply as far as I can tell. Make them comply *obviously*, by returning -1 on error. * hook_ram_load: Negative value means error. rdma_load_hook() already returns -1 on error. Leave it alone. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian --- migration/rdma.c | 79 +++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 42 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index cc59155a50..46b5859268 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -3219,12 +3219,11 @@ static size_t qemu_rdma_save_page(QEMUFile *f, rdma =3D qatomic_rcu_read(&rioc->rdmaout); =20 if (!rdma) { - return -EIO; + return -1; } =20 - ret =3D check_error_state(rdma); - if (ret) { - return ret; + if (check_error_state(rdma)) { + return -1; } =20 qemu_fflush(f); @@ -3290,9 +3289,10 @@ static size_t qemu_rdma_save_page(QEMUFile *f, } =20 return RAM_SAVE_CONTROL_DELAYED; + err: rdma->error_state =3D ret; - return ret; + return -1; } =20 static void rdma_accept_incoming_migration(void *opaque); @@ -3538,12 +3538,11 @@ static int qemu_rdma_registration_handle(QEMUFile *= f) rdma =3D qatomic_rcu_read(&rioc->rdmain); =20 if (!rdma) { - return -EIO; + return -1; } =20 - ret =3D check_error_state(rdma); - if (ret) { - return ret; + if (check_error_state(rdma)) { + return -1; } =20 local =3D &rdma->local_ram_blocks; @@ -3576,7 +3575,7 @@ static int qemu_rdma_registration_handle(QEMUFile *f) (unsigned int)comp->block_idx, rdma->local_ram_blocks.nb_blocks); ret =3D -EIO; - goto out; + goto err; } block =3D &(rdma->local_ram_blocks.block[comp->block_idx]); =20 @@ -3588,7 +3587,7 @@ static int qemu_rdma_registration_handle(QEMUFile *f) =20 case RDMA_CONTROL_REGISTER_FINISHED: trace_qemu_rdma_registration_handle_finished(); - goto out; + return 0; =20 case RDMA_CONTROL_RAM_BLOCKS_REQUEST: trace_qemu_rdma_registration_handle_ram_blocks(); @@ -3609,7 +3608,7 @@ static int qemu_rdma_registration_handle(QEMUFile *f) if (ret) { error_report("rdma migration: error dest " "registering ram blocks"); - goto out; + goto err; } } =20 @@ -3648,7 +3647,7 @@ static int qemu_rdma_registration_handle(QEMUFile *f) =20 if (ret < 0) { error_report("rdma migration: error sending remote info"); - goto out; + goto err; } =20 break; @@ -3675,7 +3674,7 @@ static int qemu_rdma_registration_handle(QEMUFile *f) (unsigned int)reg->current_index, rdma->local_ram_blocks.nb_blocks); ret =3D -ENOENT; - goto out; + goto err; } block =3D &(rdma->local_ram_blocks.block[reg->current_inde= x]); if (block->is_ram_block) { @@ -3685,7 +3684,7 @@ static int qemu_rdma_registration_handle(QEMUFile *f) block->block_name, block->offset, reg->key.current_addr); ret =3D -ERANGE; - goto out; + goto err; } host_addr =3D (block->local_host_addr + (reg->key.current_addr - block->offset)); @@ -3701,7 +3700,7 @@ static int qemu_rdma_registration_handle(QEMUFile *f) " chunk: %" PRIx64, block->block_name, reg->key.chunk); ret =3D -ERANGE; - goto out; + goto err; } } chunk_start =3D ram_chunk_start(block, chunk); @@ -3713,7 +3712,7 @@ static int qemu_rdma_registration_handle(QEMUFile *f) chunk, chunk_start, chunk_end)) { error_report("cannot get rkey"); ret =3D -EINVAL; - goto out; + goto err; } reg_result->rkey =3D tmp_rkey; =20 @@ -3730,7 +3729,7 @@ static int qemu_rdma_registration_handle(QEMUFile *f) =20 if (ret < 0) { error_report("Failed to send control buffer"); - goto out; + goto err; } break; case RDMA_CONTROL_UNREGISTER_REQUEST: @@ -3753,7 +3752,7 @@ static int qemu_rdma_registration_handle(QEMUFile *f) if (ret !=3D 0) { perror("rdma unregistration chunk failed"); ret =3D -ret; - goto out; + goto err; } =20 rdma->total_registrations--; @@ -3766,24 +3765,23 @@ static int qemu_rdma_registration_handle(QEMUFile *= f) =20 if (ret < 0) { error_report("Failed to send control buffer"); - goto out; + goto err; } break; case RDMA_CONTROL_REGISTER_RESULT: error_report("Invalid RESULT message at dest."); ret =3D -EIO; - goto out; + goto err; default: error_report("Unknown control message %s", control_desc(head.t= ype)); ret =3D -EIO; - goto out; + goto err; } } while (1); -out: - if (ret < 0) { - rdma->error_state =3D ret; - } - return ret; + +err: + rdma->error_state =3D ret; + return -1; } =20 /* Destination: @@ -3805,7 +3803,7 @@ rdma_block_notification_handle(QEMUFile *f, const cha= r *name) rdma =3D qatomic_rcu_read(&rioc->rdmain); =20 if (!rdma) { - return -EIO; + return -1; } =20 /* Find the matching RAMBlock in our local list */ @@ -3818,7 +3816,7 @@ rdma_block_notification_handle(QEMUFile *f, const cha= r *name) =20 if (found =3D=3D -1) { error_report("RAMBlock '%s' not found on destination", name); - return -ENOENT; + return -1; } =20 rdma->local_ram_blocks.block[curr].src_index =3D rdma->next_src_index; @@ -3848,7 +3846,6 @@ static int qemu_rdma_registration_start(QEMUFile *f, { QIOChannelRDMA *rioc =3D QIO_CHANNEL_RDMA(qemu_file_get_ioc(f)); RDMAContext *rdma; - int ret; =20 if (migration_in_postcopy()) { return 0; @@ -3857,12 +3854,11 @@ static int qemu_rdma_registration_start(QEMUFile *f, RCU_READ_LOCK_GUARD(); rdma =3D qatomic_rcu_read(&rioc->rdmaout); if (!rdma) { - return -EIO; + return -1; } =20 - ret =3D check_error_state(rdma); - if (ret) { - return ret; + if (check_error_state(rdma)) { + return -1; } =20 trace_qemu_rdma_registration_start(flags); @@ -3891,12 +3887,11 @@ static int qemu_rdma_registration_stop(QEMUFile *f, RCU_READ_LOCK_GUARD(); rdma =3D qatomic_rcu_read(&rioc->rdmaout); if (!rdma) { - return -EIO; + return -1; } =20 - ret =3D check_error_state(rdma); - if (ret) { - return ret; + if (check_error_state(rdma)) { + return -1; } =20 qemu_fflush(f); @@ -3927,7 +3922,7 @@ static int qemu_rdma_registration_stop(QEMUFile *f, qemu_rdma_reg_whole_ram_blocks : NULL); if (ret < 0) { fprintf(stderr, "receiving remote info!"); - return ret; + return -1; } =20 nb_dest_blocks =3D resp.len / sizeof(RDMADestBlock); @@ -3950,7 +3945,7 @@ static int qemu_rdma_registration_stop(QEMUFile *f, "not identical on both the source and destination.", local->nb_blocks, nb_dest_blocks); rdma->error_state =3D -EINVAL; - return -EINVAL; + return -1; } =20 qemu_rdma_move_header(rdma, reg_result_idx, &resp); @@ -3966,7 +3961,7 @@ static int qemu_rdma_registration_stop(QEMUFile *f, local->block[i].length, rdma->dest_blocks[i].length); rdma->error_state =3D -EINVAL; - return -EINVAL; + return -1; } local->block[i].remote_host_addr =3D rdma->dest_blocks[i].remote_host_addr; @@ -3986,7 +3981,7 @@ static int qemu_rdma_registration_stop(QEMUFile *f, return 0; err: rdma->error_state =3D ret; - return ret; + return -1; } =20 static const QEMUFileHooks rdma_read_hooks =3D { --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048441; cv=none; d=zohomail.com; s=zohoarc; b=aywvYtVA2GXJsqtMIhXRsUg6ppfpK+z04WQdwgfY1tSVW8Ul/sAbtg6uP+orlmbb2SMfrzqW/pUeIqLFLmn51YjgX6ESTXZsRlMcyOogd16MWYe/6Gob0VgKxrwEpMVXqkS2OKdtnJR3UPjEnRjYsN/HL8Gk/UhOYIEfhD+GF3E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048441; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eAje1BXP335t8Hh1NicKNHmRtT7M/Hvb5QECq0HzuKM=; b=a8N5Lp5WLsXx3Pxx4zOFKctFuBVZSZIZLiX7gK35SDB6WqK8Cq8QZCq9COqEqyNTJFz6iCwsAm98mb2RutZlfqwA/TsZRROIJabO0NT8bL2tzN1ygi4tLGBM5PeK26x73JAndlcJjT6qy68epvIV1UYDXwsuaDsbzF51j+NDTHg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048441877215.6044218097676; Mon, 18 Sep 2023 07:47:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFTK-0003xg-Am; Mon, 18 Sep 2023 10:43:34 -0400 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 1qiFSw-0003Ca-9r for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:43:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFSr-0002uY-4n for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:43:07 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-222-PJT_eUhoOraED6AbNRLHBg-1; Mon, 18 Sep 2023 10:42:18 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3B81A8001EA for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1A4E61005E27 for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 288E321E6884; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048174; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eAje1BXP335t8Hh1NicKNHmRtT7M/Hvb5QECq0HzuKM=; b=PeP80dsAl7QxQ6AzXYZzsbAJcQODrtd8sqv04FBe7RarPUOVsbe7VCU2ssl6Kdk7/L5d82 6lpKt35OdsiNDaTXoYoS2j9R9pTAJ+wd9yXT6jUyXkJpc+hId4lOC5QjuPUxLJ8h18tEOo jGcpm5RGPcG0+vDhtNzHYdlmhaD2nAE= X-MC-Unique: PJT_eUhoOraED6AbNRLHBg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 22/52] migration/rdma: Fix rdma_getaddrinfo() error checking Date: Mon, 18 Sep 2023 16:41:36 +0200 Message-ID: <20230918144206.560120-23-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 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=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048443430100003 Content-Type: text/plain; charset="utf-8" rdma_getaddrinfo() returns 0 on success. On error, it returns one of the EAI_ error codes like getaddrinfo() does, or -1 with errno set. This is broken by design: POSIX implicitly specifies the EAI_ error codes to be non-zero, no more. They could clash with -1. Nothing we can do about this design flaw. Both callers of rdma_getaddrinfo() only recognize negative values as error. Works only because systems elect to make the EAI_ error codes negative. Best not to rely on that: change the callers to treat any non-zero value as failure. Also change them to return -1 instead of the value received from getaddrinfo() on failure, to avoid positive error values. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian --- migration/rdma.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 46b5859268..3421ae0796 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -935,14 +935,14 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, = Error **errp) =20 if (rdma->host =3D=3D NULL || !strcmp(rdma->host, "")) { ERROR(errp, "RDMA hostname has not been set"); - return -EINVAL; + return -1; } =20 /* create CM channel */ rdma->channel =3D rdma_create_event_channel(); if (!rdma->channel) { ERROR(errp, "could not create CM channel"); - return -EINVAL; + return -1; } =20 /* create CM id */ @@ -956,7 +956,7 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Er= ror **errp) port_str[15] =3D '\0'; =20 ret =3D rdma_getaddrinfo(rdma->host, port_str, NULL, &res); - if (ret < 0) { + if (ret) { ERROR(errp, "could not rdma_getaddrinfo address %s", rdma->host); goto err_resolve_get_addr; } @@ -998,7 +998,6 @@ route: rdma_event_str(cm_event->event)); error_report("rdma_resolve_addr"); rdma_ack_cm_event(cm_event); - ret =3D -EINVAL; goto err_resolve_get_addr; } rdma_ack_cm_event(cm_event); @@ -1019,7 +1018,6 @@ route: ERROR(errp, "result not equal to event_route_resolved: %s", rdma_event_str(cm_event->event)); rdma_ack_cm_event(cm_event); - ret =3D -EINVAL; goto err_resolve_get_addr; } rdma_ack_cm_event(cm_event); @@ -1034,7 +1032,7 @@ err_resolve_get_addr: err_resolve_create_id: rdma_destroy_event_channel(rdma->channel); rdma->channel =3D NULL; - return ret; + return -1; } =20 /* @@ -2644,7 +2642,7 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Err= or **errp) port_str[15] =3D '\0'; =20 ret =3D rdma_getaddrinfo(rdma->host, port_str, NULL, &res); - if (ret < 0) { + if (ret) { ERROR(errp, "could not rdma_getaddrinfo address %s", rdma->host); goto err_dest_init_bind_addr; } @@ -2688,7 +2686,7 @@ err_dest_init_create_listen_id: rdma_destroy_event_channel(rdma->channel); rdma->channel =3D NULL; rdma->error_state =3D ret; - return ret; + return -1; =20 } =20 --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048572; cv=none; d=zohomail.com; s=zohoarc; b=JmJ9UTrvo3oLisjViOk4Y7j108rb4UgaqSuq1uvkV/2t2e8olIPlxpDycD8bxo82Q2EEczyLhKJdDe8jtHymFMzg6Ze0qrncF/K+ppXUMSL4ToKm0JNg0cp8CvLyCCXhan0UhniNZP6UUcu3JpbG2qJi7CsAtBSHiFC/0VpiZ5U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048572; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5+za+ZGq27q3ww++zQ0Kbau7vv/Tr1MLqchzMa7lJqM=; b=nBbl5A8AtFonnskdfyQbOj4BhtvhWjzSR3cd3/qretLtyJtRvEuSFj0oyY5Y3rOTweOVeEwurLJQYqMbriY4iqwMisj/5tm71+h0j+v3+WjjshXBCs/M5pLi9Wfe75jetsAo6pUwfPLtNKv2ZNbZoASlvW2HyOUPlsZTs7EOsvg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16950485721001007.9320341335693; Mon, 18 Sep 2023 07:49:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFTM-0004Sb-Vc; Mon, 18 Sep 2023 10:43:37 -0400 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 1qiFSQ-00032y-K3 for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS3-0002be-KD for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:38 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-178-lcXtbXtHM-uEK4B68r0hNQ-1; Mon, 18 Sep 2023 10:42:10 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 41D7B29AA3BD for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 200E0492B16 for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 2B53921E6885; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048133; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5+za+ZGq27q3ww++zQ0Kbau7vv/Tr1MLqchzMa7lJqM=; b=O/GjJeJu3mFJldEr0b5zNlGKNQntR8x2Z+0OlCfN2ec1CWITFONj6eq2kkloNdGQoT8She 2az/aFAfOhEbu2cMcrOACvb05urQwIdbUiHwU7EwPFtFS9zITnGZKrTxEqEFILzXF5X6EC q8k2+GThknTk9aXoznlqNCgA2Vi5wD8= X-MC-Unique: lcXtbXtHM-uEK4B68r0hNQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 23/52] migration/rdma: Clean up qemu_rdma_wait_comp_channel()'s error value Date: Mon, 18 Sep 2023 16:41:37 +0200 Message-ID: <20230918144206.560120-24-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048572822100001 Content-Type: text/plain; charset="utf-8" qemu_rdma_wait_comp_channel() returns 0 on success, and either -1 or rdma->error_state on failure. Callers actually expect a negative error value. I believe rdma->error_state can't be positive, but let's make things more obvious by simply returning -1 on any failure. Signed-off-by: Markus Armbruster --- migration/rdma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration/rdma.c b/migration/rdma.c index 3421ae0796..efbb3c7754 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1588,7 +1588,7 @@ static int qemu_rdma_wait_comp_channel(RDMAContext *r= dma, if (rdma->received_error) { return -EPIPE; } - return rdma->error_state; + return -!!rdma->error_state; } =20 static struct ibv_comp_channel *to_channel(RDMAContext *rdma, uint64_t wri= d) --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048798; cv=none; d=zohomail.com; s=zohoarc; b=cQiUCQG/bocoxfk0RH/DOiz2tuM1fD5o3l/XQhYLJRa7SSx13l87oPPcit/OJoPiBAeJXCaKABmmcNvxV+/PjxsjGiSWwXwKVsXhuUDAmvGwIWk/xsutQTNPW8b2/zWEfq9/jBnkieqb0UEkWvkQCnLKAxpSY23y0K57cCvRfwA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048798; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=A/pQwlA5/88DqjoZAaKjQ6Z2V9aa+vA72DV9LshQIek=; b=LtJvxWKTLtI5x4xaXvJYbcN//bIFMbB1VI/jaBmaFeSIWWNDSqRsJXCYxrvAZqLYb4ErLxjnupVGn+2suRtLGIyGzWs7rJLTjvsa3e2+LTtluEb834SmEZcZAZg9wiPHDfU3Z1iD2UAWRVs10DCSWl2JOspX4sm/bB1eZt2A3E8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048798762289.3022475204373; Mon, 18 Sep 2023 07:53:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFSV-00035f-Bg; Mon, 18 Sep 2023 10:42:43 -0400 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 1qiFSO-00030j-Cz for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS2-0002aw-Qz for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:36 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-541-sRu-9fazOmqA_RMRnN4ULw-1; Mon, 18 Sep 2023 10:42:10 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6326E3C0E440 for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2521A492C37 for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 2E35C21E6886; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048132; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=A/pQwlA5/88DqjoZAaKjQ6Z2V9aa+vA72DV9LshQIek=; b=YYQugAerQwfYzuOtBf0WnLzNY/JS70glkQeu2aAOWocSZ9R3alKV8ttVnyNAL+y5FLUKF3 gq6qMWu5Q5SGg/KMpnkUz4JgAgA4hByAKGfz0nSC/pvFrfoBYG+Zc2zXK/c5tyrTxyROXL klBEcg98S+gnKeWL0YBHzjFnNIbACI0= X-MC-Unique: sRu-9fazOmqA_RMRnN4ULw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 24/52] migration/rdma: Return -1 instead of negative errno code Date: Mon, 18 Sep 2023 16:41:38 +0200 Message-ID: <20230918144206.560120-25-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048800485100007 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Li Zhijian --- migration/rdma.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index efbb3c7754..d0af258468 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -857,14 +857,14 @@ static int qemu_rdma_broken_ipv6_kernel(struct ibv_co= ntext *verbs, Error **errp) } else { error_setg_errno(errp, errno, "could not open RDMA device context"); - return -EINVAL; + return -1; } } =20 if (ibv_query_port(verbs, 1, &port_attr)) { ibv_close_device(verbs); ERROR(errp, "Could not query initial IB port"); - return -EINVAL; + return -1; } =20 if (port_attr.link_layer =3D=3D IBV_LINK_LAYER_INFINIBAND) { @@ -889,7 +889,7 @@ static int qemu_rdma_broken_ipv6_kernel(struct ibv_cont= ext *verbs, Error **errp) ERROR(errp, "You only have RoCE / iWARP devices in your sy= stems" " and your management software has specified '= [::]'" ", but IPv6 over RoCE / iWARP is not supported= in Linux."); - return -ENONET; + return -1; } } =20 @@ -905,13 +905,13 @@ static int qemu_rdma_broken_ipv6_kernel(struct ibv_co= ntext *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; } =20 if (port_attr.link_layer =3D=3D 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; } =20 #endif @@ -1409,7 +1409,7 @@ static int qemu_rdma_unregister_waiting(RDMAContext *= rdma) =20 if (ret !=3D 0) { perror("unregistration chunk failed"); - return -ret; + return -1; } rdma->total_registrations--; =20 @@ -1554,7 +1554,7 @@ static int qemu_rdma_wait_comp_channel(RDMAContext *r= dma, if (ret) { error_report("failed to get cm event while wait " "completion channel"); - return -EPIPE; + return -1; } =20 error_report("receive cm event while wait comp channel= ," @@ -1562,7 +1562,7 @@ static int qemu_rdma_wait_comp_channel(RDMAContext *r= dma, if (cm_event->event =3D=3D RDMA_CM_EVENT_DISCONNECTED = || cm_event->event =3D=3D RDMA_CM_EVENT_DEVICE_REMOVA= L) { rdma_ack_cm_event(cm_event); - return -EPIPE; + return -1; } rdma_ack_cm_event(cm_event); } @@ -1575,18 +1575,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; } =20 if (migrate_get_current()->state =3D=3D MIGRATION_STATUS_CANCE= LLING) { /* Bail out and let the cancellation happen */ - return -EPIPE; + return -1; } } } =20 if (rdma->received_error) { - return -EPIPE; + return -1; } return -!!rdma->error_state; } @@ -1751,7 +1751,7 @@ static int qemu_rdma_post_send_control(RDMAContext *r= dma, uint8_t *buf, =20 if (ret > 0) { error_report("Failed to use post IB SEND for control"); - return -ret; + return -1; } =20 ret =3D qemu_rdma_block_for_wrid(rdma, RDMA_WRID_SEND_CONTROL, NULL); @@ -1820,15 +1820,15 @@ static int qemu_rdma_exchange_get_response(RDMACont= ext *rdma, if (head->type =3D=3D RDMA_CONTROL_ERROR) { rdma->received_error =3D 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 !=3D byte_len) { error_report("Malformed length: %d byte_len %d", head->len, byte_l= en); - return -EINVAL; + return -1; } =20 return 0; @@ -2092,7 +2092,7 @@ retry: (uint8_t *) &comp, NULL, NULL, NULL); =20 if (ret < 0) { - return -EIO; + return -1; } =20 stat64_add(&mig_stats.zero_pages, @@ -2127,7 +2127,7 @@ retry: &sge.lkey, NULL, chunk, chunk_start, chunk_end)) { error_report("cannot get lkey"); - return -EINVAL; + return -1; } =20 reg_result =3D (RDMARegisterResult *) @@ -2146,7 +2146,7 @@ retry: &sge.lkey, NULL, chunk, chunk_start, chunk_end)) { error_report("cannot get lkey!"); - return -EINVAL; + return -1; } } =20 @@ -2158,7 +2158,7 @@ retry: &sge.lkey, NULL, chun= k, chunk_start, chunk_en= d)) { error_report("cannot get lkey!"); - return -EINVAL; + return -1; } } =20 @@ -2200,7 +2200,7 @@ retry: =20 } else if (ret > 0) { perror("rdma migration: post rdma write failed"); - return -ret; + return -1; } =20 set_bit(chunk, block->transit_bitmap); @@ -2920,14 +2920,14 @@ static int qemu_rdma_drain_cq(QEMUFile *f, RDMACont= ext *rdma) int ret; =20 if (qemu_rdma_write_flush(f, rdma) < 0) { - return -EIO; + return -1; } =20 while (rdma->nb_sent) { ret =3D 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; } } =20 --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048294; cv=none; d=zohomail.com; s=zohoarc; b=RtkyahWyHled0ZN9tvF9A3Wjs71zvmWgvWuGEk7TFskYJgWiOMwwS+4BRBjSGtRCPOm+nPT0Hlo4pVwoF1MSQc6yYisj0O2o3vxdA1eviuuuQknvKcGiwxIK2VGxszv0Qw5Ap3y+4qaNOrQ8HgLCst+AmcuWcn67SS0zLDilKGc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048294; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=D+kR7wA8Z1+2AA5LRtU9j3o2Sy/Y0eHC9q/nH7PbZOs=; b=TvDBM/nHncr1eyAgFRjFQq2wN+sIjr8C0k7IqWDZkA6boU9Syf02Nyr3uir538JtUojkfxlCy2foLUJR11oecqUoed5RApdHzg/A0wNEM3bumWkqsIf90G07a6w3mBVEoA3mQsOj06zD+PPY1xWyhxPGKEOq5nLOBuysikuxBck= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048294120569.9496754919187; Mon, 18 Sep 2023 07:44:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFTF-0003YT-FP; Mon, 18 Sep 2023 10:43:32 -0400 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 1qiFSO-00030e-9I for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS2-0002bM-Qq for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:35 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-341-Y4zHFK4fP1Wea0tYiNIupw-1; Mon, 18 Sep 2023 10:42:10 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6A3DC29AA3BF for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2B72C4A9B13 for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 314CF21E6887; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048132; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=D+kR7wA8Z1+2AA5LRtU9j3o2Sy/Y0eHC9q/nH7PbZOs=; b=Kv7xe1qR0csWGBQU1EIjXiEe1gqCq4yCYf0IoTezhDg41EDEIrxg6Y7QOldAl6yl6qHIpw k2YDvBlyiLOXbf9WWZtRbDMjITNzR8UNu+rWHJkXMfAFY3zjMr9Qs2tTehOHrke8YmOFYj vbCRXIvCSu/3CaXub0c4DNfJ3h0bMek= X-MC-Unique: Y4zHFK4fP1Wea0tYiNIupw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 25/52] migration/rdma: Dumb down remaining int error values to -1 Date: Mon, 18 Sep 2023 16:41:39 +0200 Message-ID: <20230918144206.560120-26-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048295474100001 Content-Type: text/plain; charset="utf-8" This is just to make the error value more obvious. Callers don't mind. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian --- migration/rdma.c | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index d0af258468..ad314cc10a 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1418,7 +1418,7 @@ static int qemu_rdma_unregister_waiting(RDMAContext *= rdma) ret =3D qemu_rdma_exchange_send(rdma, &head, (uint8_t *) ®, &resp, NULL, NULL); if (ret < 0) { - return ret; + return -1; } =20 trace_qemu_rdma_unregister_waiting_complete(chunk); @@ -1459,7 +1459,7 @@ static int qemu_rdma_poll(RDMAContext *rdma, struct i= bv_cq *cq, =20 if (ret < 0) { error_report("ibv_poll_cq failed"); - return ret; + return -1; } =20 wr_id =3D wc.wr_id & RDMA_WRID_TYPE_MASK; @@ -1633,7 +1633,7 @@ static int qemu_rdma_block_for_wrid(RDMAContext *rdma, while (wr_id !=3D wrid_requested) { ret =3D qemu_rdma_poll(rdma, poll_cq, &wr_id_in, byte_len); if (ret < 0) { - return ret; + return -1; } =20 wr_id =3D wr_id_in & RDMA_WRID_TYPE_MASK; @@ -1702,7 +1702,7 @@ err_block_for_wrid: } =20 rdma->error_state =3D ret; - return ret; + return -1; } =20 /* @@ -1757,9 +1757,10 @@ static int qemu_rdma_post_send_control(RDMAContext *= rdma, uint8_t *buf, ret =3D qemu_rdma_block_for_wrid(rdma, RDMA_WRID_SEND_CONTROL, NULL); if (ret < 0) { error_report("rdma migration: send polling control error"); + return -1; } =20 - return ret; + return 0; } =20 /* @@ -1801,7 +1802,7 @@ static int qemu_rdma_exchange_get_response(RDMAContex= t *rdma, =20 if (ret < 0) { error_report("rdma migration: recv polling control error!"); - return ret; + return -1; } =20 network_to_control((void *) rdma->wr_data[idx].control); @@ -1879,7 +1880,7 @@ static int qemu_rdma_exchange_send(RDMAContext *rdma,= RDMAControlHeader *head, ret =3D qemu_rdma_exchange_get_response(rdma, &resp, RDMA_CONTROL_READY, RDMA_WRID_R= EADY); if (ret < 0) { - return ret; + return -1; } } =20 @@ -1891,7 +1892,7 @@ static int qemu_rdma_exchange_send(RDMAContext *rdma,= RDMAControlHeader *head, if (ret) { error_report("rdma migration: error posting" " extra control recv for anticipated result!"); - return ret; + return -1; } } =20 @@ -1901,7 +1902,7 @@ static int qemu_rdma_exchange_send(RDMAContext *rdma,= RDMAControlHeader *head, ret =3D qemu_rdma_post_recv_control(rdma, RDMA_WRID_READY); if (ret) { error_report("rdma migration: error posting first control recv!"); - return ret; + return -1; } =20 /* @@ -1911,7 +1912,7 @@ static int qemu_rdma_exchange_send(RDMAContext *rdma,= RDMAControlHeader *head, =20 if (ret < 0) { error_report("Failed to send control buffer!"); - return ret; + return -1; } =20 /* @@ -1922,7 +1923,7 @@ static int qemu_rdma_exchange_send(RDMAContext *rdma,= RDMAControlHeader *head, trace_qemu_rdma_exchange_send_issue_callback(); ret =3D callback(rdma); if (ret < 0) { - return ret; + return -1; } } =20 @@ -1931,7 +1932,7 @@ static int qemu_rdma_exchange_send(RDMAContext *rdma,= RDMAControlHeader *head, resp->type, RDMA_WRID_DATA); =20 if (ret < 0) { - return ret; + return -1; } =20 qemu_rdma_move_header(rdma, RDMA_WRID_DATA, resp); @@ -1967,7 +1968,7 @@ static int qemu_rdma_exchange_recv(RDMAContext *rdma,= RDMAControlHeader *head, =20 if (ret < 0) { error_report("Failed to send control buffer!"); - return ret; + return -1; } =20 /* @@ -1977,7 +1978,7 @@ static int qemu_rdma_exchange_recv(RDMAContext *rdma,= RDMAControlHeader *head, expecting, RDMA_WRID_READY); =20 if (ret < 0) { - return ret; + return -1; } =20 qemu_rdma_move_header(rdma, RDMA_WRID_READY, head); @@ -1988,7 +1989,7 @@ static int qemu_rdma_exchange_recv(RDMAContext *rdma,= RDMAControlHeader *head, ret =3D qemu_rdma_post_recv_control(rdma, RDMA_WRID_READY); if (ret) { error_report("rdma migration: error posting second control recv!"); - return ret; + return -1; } =20 return 0; @@ -2061,7 +2062,7 @@ retry: "block %d chunk %" PRIu64 " current %" PRIu64 " len %" PRIu64 " %d", current_index, chunk, sge.addr, length, rdma->nb_sent); - return ret; + return -1; } } =20 @@ -2119,7 +2120,7 @@ retry: ret =3D qemu_rdma_exchange_send(rdma, &head, (uint8_t *) ®, &resp, ®_result_idx, NULL); if (ret < 0) { - return ret; + return -1; } =20 /* try to overlap this single registration with the one we sen= t. */ @@ -2193,7 +2194,7 @@ retry: if (ret < 0) { error_report("rdma migration: failed to make " "room in full send queue!"); - return ret; + return -1; } =20 goto retry; @@ -2230,7 +2231,7 @@ static int qemu_rdma_write_flush(QEMUFile *f, RDMACon= text *rdma) rdma->current_index, rdma->current_addr, rdma->current_length); =20 if (ret < 0) { - return ret; + return -1; } =20 if (ret =3D=3D 0) { @@ -2312,7 +2313,7 @@ static int qemu_rdma_write(QEMUFile *f, RDMAContext *= rdma, if (!qemu_rdma_buffer_mergable(rdma, current_addr, len)) { ret =3D qemu_rdma_write_flush(f, rdma); if (ret) { - return ret; + return -1; } rdma->current_length =3D 0; rdma->current_addr =3D current_addr; @@ -3485,7 +3486,7 @@ err_rdma_dest_wait: rdma->error_state =3D ret; qemu_rdma_cleanup(rdma); g_free(rdma_return_path); - return ret; + return -1; } =20 static int dest_ram_sort_func(const void *a, const void *b) --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048514; cv=none; d=zohomail.com; s=zohoarc; b=VD4tAjjdCAufS3jQZX24wK62qta0hVp8FYTW4sXQV0hO6JEP3LrtpxCNmvWbIdnWzdVce0NAUAuzcUISko7A7JKNVkurBxRyIHLcAU8RiCAU54IdEg4wZ/nhbCpSDdlnEwOHt7o/+jle9Db6e+7jdk50k2qZPFJVnkx+YAXXbIk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048514; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IrNnSh8+IHIVPaW/qP+RDKnXdtNzmzzrM/G8PvBfdCw=; b=P8e3IATyiwBui7nAKzUNSUZe0Hq2o6l5j/HkFOfQmTLL4oxr+y2dt5I3OL4K0Z5MIfRdRDCFCSUCFzz+VRUlZivQzqNviMrHybRO+o0SeRicN5fwNmKjgTFfxMkZwaD758GOu0FuFdX30seccXemvPn2yLJdHmKLvd3auN0wDEI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048514641197.45261419761403; Mon, 18 Sep 2023 07:48:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFT7-0003Jg-6z; Mon, 18 Sep 2023 10:43:21 -0400 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 1qiFSQ-00032H-1b for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS3-0002cp-0t for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:37 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-202-HILKO8dONXK-Ig3qmdxldQ-1; Mon, 18 Sep 2023 10:42:10 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6946294592C for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2B30E40C200A for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 342CF21E6888; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048134; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IrNnSh8+IHIVPaW/qP+RDKnXdtNzmzzrM/G8PvBfdCw=; b=hy4giUKoW3zIISlCXx3/34tUuQ5ImcT1xJ3IvENxXT1K76NJabduDwPolEMS+tjSwvGqET 8q+21LXN4s9wCBhxL1FrxYG5O8TePl3hvT/mqmvmKvttfdtG7jnRerfksGgjuasrJMxv4i KgGibgaaUCq6ZFcpaCJu5ApEh7sr/bU= X-MC-Unique: HILKO8dONXK-Ig3qmdxldQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 26/52] migration/rdma: Replace int error_state by bool errored Date: Mon, 18 Sep 2023 16:41:40 +0200 Message-ID: <20230918144206.560120-27-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048516687100005 Content-Type: text/plain; charset="utf-8" All we do with the value of RDMAContext member @error_state is test whether it's zero. Change to bool and rename to @errored. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian --- migration/rdma.c | 66 ++++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index ad314cc10a..85f6b274bf 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -352,7 +352,7 @@ typedef struct RDMAContext { * memory registration, then do not attempt any future work * and remember the error state. */ - int error_state; + int errored; bool error_reported; bool received_error; =20 @@ -439,14 +439,14 @@ typedef struct QEMU_PACKED { uint64_t chunks; /* how many sequential chunks to register = */ } RDMARegister; =20 -static int check_error_state(RDMAContext *rdma) +static bool rdma_errored(RDMAContext *rdma) { - if (rdma->error_state && !rdma->error_reported) { + if (rdma->errored && !rdma->error_reported) { error_report("RDMA is in an error state waiting migration" " to abort!"); rdma->error_reported =3D true; } - return rdma->error_state; + return rdma->errored; } =20 static void register_to_network(RDMAContext *rdma, RDMARegister *reg) @@ -1531,7 +1531,7 @@ static int qemu_rdma_wait_comp_channel(RDMAContext *r= dma, * But we need to be able to handle 'cancel' or an error * without hanging forever. */ - while (!rdma->error_state && !rdma->received_error) { + while (!rdma->errored && !rdma->received_error) { GPollFD pfds[2]; pfds[0].fd =3D comp_channel->fd; pfds[0].events =3D G_IO_IN | G_IO_HUP | G_IO_ERR; @@ -1588,7 +1588,7 @@ static int qemu_rdma_wait_comp_channel(RDMAContext *r= dma, if (rdma->received_error) { return -1; } - return -!!rdma->error_state; + return -rdma->errored; } =20 static struct ibv_comp_channel *to_channel(RDMAContext *rdma, uint64_t wri= d) @@ -1701,7 +1701,7 @@ err_block_for_wrid: ibv_ack_cq_events(cq, num_cq_events); } =20 - rdma->error_state =3D ret; + rdma->errored =3D true; return -1; } =20 @@ -2340,7 +2340,7 @@ static void qemu_rdma_cleanup(RDMAContext *rdma) int idx; =20 if (rdma->cm_id && rdma->connected) { - if ((rdma->error_state || + if ((rdma->errored || migrate_get_current()->state =3D=3D MIGRATION_STATUS_CANCELLI= NG) && !rdma->received_error) { RDMAControlHeader head =3D { .len =3D 0, @@ -2621,14 +2621,14 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, E= rror **errp) =20 if (!rdma->host || !rdma->host[0]) { ERROR(errp, "RDMA host is not set!"); - rdma->error_state =3D -EINVAL; + rdma->errored =3D true; return -1; } /* create CM channel */ rdma->channel =3D rdma_create_event_channel(); if (!rdma->channel) { ERROR(errp, "could not create rdma event channel"); - rdma->error_state =3D -EINVAL; + rdma->errored =3D true; return -1; } =20 @@ -2686,7 +2686,7 @@ err_dest_init_bind_addr: err_dest_init_create_listen_id: rdma_destroy_event_channel(rdma->channel); rdma->channel =3D NULL; - rdma->error_state =3D ret; + rdma->errored =3D true; return -1; =20 } @@ -2763,7 +2763,7 @@ static ssize_t qio_channel_rdma_writev(QIOChannel *io= c, return -1; } =20 - if (rdma->error_state) { + if (rdma->errored) { error_setg(errp, "RDMA is in an error state waiting migration to abort!"= ); return -1; @@ -2775,7 +2775,7 @@ 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; + rdma->errored =3D true; error_setg(errp, "qemu_rdma_write_flush failed"); return -1; } @@ -2795,7 +2795,7 @@ static ssize_t qio_channel_rdma_writev(QIOChannel *io= c, ret =3D qemu_rdma_exchange_send(rdma, &head, data, NULL, NULL,= NULL); =20 if (ret < 0) { - rdma->error_state =3D ret; + rdma->errored =3D true; error_setg(errp, "qemu_rdma_exchange_send failed"); return -1; } @@ -2853,7 +2853,7 @@ static ssize_t qio_channel_rdma_readv(QIOChannel *ioc, return -1; } =20 - if (rdma->error_state) { + if (rdma->errored) { error_setg(errp, "RDMA is in an error state waiting migration to abort!"= ); return -1; @@ -2889,7 +2889,7 @@ static ssize_t qio_channel_rdma_readv(QIOChannel *ioc, ret =3D qemu_rdma_exchange_recv(rdma, &head, RDMA_CONTROL_QEMU_FIL= E); =20 if (ret < 0) { - rdma->error_state =3D ret; + rdma->errored =3D true; error_setg(errp, "qemu_rdma_exchange_recv failed"); return -1; } @@ -3162,21 +3162,21 @@ qio_channel_rdma_shutdown(QIOChannel *ioc, switch (how) { case QIO_CHANNEL_SHUTDOWN_READ: if (rdmain) { - rdmain->error_state =3D -1; + rdmain->errored =3D true; } break; case QIO_CHANNEL_SHUTDOWN_WRITE: if (rdmaout) { - rdmaout->error_state =3D -1; + rdmaout->errored =3D true; } break; case QIO_CHANNEL_SHUTDOWN_BOTH: default: if (rdmain) { - rdmain->error_state =3D -1; + rdmain->errored =3D true; } if (rdmaout) { - rdmaout->error_state =3D -1; + rdmaout->errored =3D true; } break; } @@ -3221,7 +3221,7 @@ static size_t qemu_rdma_save_page(QEMUFile *f, return -1; } =20 - if (check_error_state(rdma)) { + if (rdma_errored(rdma)) { return -1; } =20 @@ -3290,7 +3290,7 @@ static size_t qemu_rdma_save_page(QEMUFile *f, return RAM_SAVE_CONTROL_DELAYED; =20 err: - rdma->error_state =3D ret; + rdma->errored =3D true; return -1; } =20 @@ -3311,13 +3311,13 @@ static void rdma_cm_poll_handler(void *opaque) =20 if (cm_event->event =3D=3D RDMA_CM_EVENT_DISCONNECTED || cm_event->event =3D=3D RDMA_CM_EVENT_DEVICE_REMOVAL) { - if (!rdma->error_state && + if (!rdma->errored && migration_incoming_get_current()->state !=3D MIGRATION_STATUS_COMPLETED) { error_report("receive cm event, cm event is %d", cm_event->eve= nt); - rdma->error_state =3D -EPIPE; + rdma->errored =3D true; if (rdma->return_path) { - rdma->return_path->error_state =3D -EPIPE; + rdma->return_path->errored =3D true; } } rdma_ack_cm_event(cm_event); @@ -3483,7 +3483,7 @@ static int qemu_rdma_accept(RDMAContext *rdma) return 0; =20 err_rdma_dest_wait: - rdma->error_state =3D ret; + rdma->errored =3D true; qemu_rdma_cleanup(rdma); g_free(rdma_return_path); return -1; @@ -3540,7 +3540,7 @@ static int qemu_rdma_registration_handle(QEMUFile *f) return -1; } =20 - if (check_error_state(rdma)) { + if (rdma_errored(rdma)) { return -1; } =20 @@ -3779,7 +3779,7 @@ static int qemu_rdma_registration_handle(QEMUFile *f) } while (1); =20 err: - rdma->error_state =3D ret; + rdma->errored =3D true; return -1; } =20 @@ -3856,7 +3856,7 @@ static int qemu_rdma_registration_start(QEMUFile *f, return -1; } =20 - if (check_error_state(rdma)) { + if (rdma_errored(rdma)) { return -1; } =20 @@ -3889,7 +3889,7 @@ static int qemu_rdma_registration_stop(QEMUFile *f, return -1; } =20 - if (check_error_state(rdma)) { + if (rdma_errored(rdma)) { return -1; } =20 @@ -3943,7 +3943,7 @@ static int qemu_rdma_registration_stop(QEMUFile *f, "Your QEMU command line parameters are probably " "not identical on both the source and destination.", local->nb_blocks, nb_dest_blocks); - rdma->error_state =3D -EINVAL; + rdma->errored =3D true; return -1; } =20 @@ -3959,7 +3959,7 @@ static int qemu_rdma_registration_stop(QEMUFile *f, "vs %" PRIu64, local->block[i].block_name, i, local->block[i].length, rdma->dest_blocks[i].length); - rdma->error_state =3D -EINVAL; + rdma->errored =3D true; return -1; } local->block[i].remote_host_addr =3D @@ -3979,7 +3979,7 @@ static int qemu_rdma_registration_stop(QEMUFile *f, =20 return 0; err: - rdma->error_state =3D ret; + rdma->errored =3D true; return -1; } =20 --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048327; cv=none; d=zohomail.com; s=zohoarc; b=OknVveSkAh4uQfsKtqYBHG1p4BikaMNKh8eXs/v9+mCUjpd9in1esH/sz3b7EVK99SXTa4enl1KiQ3BCwJ4L1GqPk0uYlysNHPbsL3kVKAooxCVeC5J0ghmGWWPn8J/AeWszvQeX/U+EpVKLcmTg6u4hpqtjbEMrVvomNIxaVdo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048327; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0pMzbKeYA2mBaiKQm70INKSazOiYyzJPBPalzfExC70=; b=ZXX4JWdo5Md2NxgRVraw9bchbpiNQY2PqUvT7joUmqe6GfwOJ4A5PCh6w4A41r1cMQ9nmKgosJb5SPamRtej/1o01AsTScEeMajPo0xfgQ4P2LAKva40LyrrVXziE5+7Wx++P7BhKA674pg1YKE/HtVqZ27wMu0um56/3os8vFw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048327355667.3652813482779; Mon, 18 Sep 2023 07:45:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFSO-00030F-6l; Mon, 18 Sep 2023 10:42:36 -0400 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 1qiFSD-0002tH-4K for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS2-0002bL-Ie for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:24 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-252-uV2CpbFcNIOk13b4nX4yDw-1; Mon, 18 Sep 2023 10:42:10 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6FF233800BB3 for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 320CFC15BB8 for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 372E121E688A; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048132; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0pMzbKeYA2mBaiKQm70INKSazOiYyzJPBPalzfExC70=; b=gSCZtYbOPNjumeQIqIoeDmX99Mw8avQo1MpPPDBxzvj/yNwMdY02ZeVvQ0/xr2dfUVJgg3 /6b2PTMO3PbHvp3ik/zaTXuDaGy9ffTsz8DFO5BnHbiuj08wT0LMnwFAlgO/zpdFFmyypU IGJTNXZSsdD0cErbgmXJZSxZHM9U528= X-MC-Unique: uV2CpbFcNIOk13b4nX4yDw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 27/52] migration/rdma: Drop superfluous assignments to @ret Date: Mon, 18 Sep 2023 16:41:41 +0200 Message-ID: <20230918144206.560120-28-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048328155100005 Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian --- migration/rdma.c | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 85f6b274bf..62d95b7d2c 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1514,7 +1514,7 @@ static int qemu_rdma_wait_comp_channel(RDMAContext *r= dma, struct ibv_comp_channel *comp_chann= el) { struct rdma_cm_event *cm_event; - int ret =3D -1; + int ret; =20 /* * Coroutine doesn't start until migration_fd_process_incoming() @@ -1619,7 +1619,7 @@ static int qemu_rdma_block_for_wrid(RDMAContext *rdma, uint64_t wrid_requested, uint32_t *byte_len) { - int num_cq_events =3D 0, ret =3D 0; + int num_cq_events =3D 0, ret; struct ibv_cq *cq; void *cq_ctx; uint64_t wr_id =3D RDMA_WRID_NONE, wr_id_in; @@ -1664,8 +1664,7 @@ static int qemu_rdma_block_for_wrid(RDMAContext *rdma, =20 num_cq_events++; =20 - ret =3D -ibv_req_notify_cq(cq, 0); - if (ret) { + if (ibv_req_notify_cq(cq, 0)) { goto err_block_for_wrid; } =20 @@ -1712,7 +1711,7 @@ err_block_for_wrid: static int qemu_rdma_post_send_control(RDMAContext *rdma, uint8_t *buf, RDMAControlHeader *head) { - int ret =3D 0; + int ret; RDMAWorkRequestData *wr =3D &rdma->wr_data[RDMA_WRID_CONTROL]; struct ibv_send_wr *bad_wr; struct ibv_sge sge =3D { @@ -1869,7 +1868,7 @@ static int qemu_rdma_exchange_send(RDMAContext *rdma,= RDMAControlHeader *head, int *resp_idx, int (*callback)(RDMAContext *rdma)) { - int ret =3D 0; + int ret; =20 /* * Wait until the dest is ready before attempting to deliver the messa= ge @@ -2841,7 +2840,7 @@ static ssize_t qio_channel_rdma_readv(QIOChannel *ioc, QIOChannelRDMA *rioc =3D QIO_CHANNEL_RDMA(ioc); RDMAContext *rdma; RDMAControlHeader head; - int ret =3D 0; + int ret; size_t i; size_t done =3D 0; =20 @@ -3340,7 +3339,7 @@ static int qemu_rdma_accept(RDMAContext *rdma) RDMAContext *rdma_return_path =3D NULL; struct rdma_cm_event *cm_event; struct ibv_context *verbs; - int ret =3D -EINVAL; + int ret; int idx; =20 ret =3D rdma_get_cm_event(rdma->channel, &cm_event); @@ -3350,7 +3349,6 @@ static int qemu_rdma_accept(RDMAContext *rdma) =20 if (cm_event->event !=3D RDMA_CM_EVENT_CONNECT_REQUEST) { rdma_ack_cm_event(cm_event); - ret =3D -1; goto err_rdma_dest_wait; } =20 @@ -3363,7 +3361,6 @@ static int qemu_rdma_accept(RDMAContext *rdma) rdma_return_path =3D qemu_rdma_data_init(rdma->host_port, NULL); if (rdma_return_path =3D=3D NULL) { rdma_ack_cm_event(cm_event); - ret =3D -1; goto err_rdma_dest_wait; } =20 @@ -3378,7 +3375,6 @@ static int qemu_rdma_accept(RDMAContext *rdma) error_report("Unknown source RDMA version: %d, bailing...", cap.version); rdma_ack_cm_event(cm_event); - ret =3D -1; goto err_rdma_dest_wait; } =20 @@ -3411,7 +3407,6 @@ static int qemu_rdma_accept(RDMAContext *rdma) } else if (rdma->verbs !=3D verbs) { error_report("ibv context not matching %p, %p!", rdma->verbs, verbs); - ret =3D -1; goto err_rdma_dest_wait; } =20 @@ -3465,7 +3460,6 @@ static int qemu_rdma_accept(RDMAContext *rdma) if (cm_event->event !=3D RDMA_CM_EVENT_ESTABLISHED) { error_report("rdma_accept not event established"); rdma_ack_cm_event(cm_event); - ret =3D -1; goto err_rdma_dest_wait; } =20 @@ -3528,7 +3522,7 @@ static int qemu_rdma_registration_handle(QEMUFile *f) static RDMARegisterResult results[RDMA_CONTROL_MAX_COMMANDS_PER_MESSAG= E]; RDMALocalBlock *block; void *host_addr; - int ret =3D 0; + int ret; int idx =3D 0; int count =3D 0; int i =3D 0; @@ -3557,7 +3551,6 @@ static int qemu_rdma_registration_handle(QEMUFile *f) if (head.repeat > RDMA_CONTROL_MAX_COMMANDS_PER_MESSAGE) { error_report("rdma: Too many requests in this message (%d)." "Bailing.", head.repeat); - ret =3D -EIO; break; } =20 @@ -3573,7 +3566,6 @@ static int qemu_rdma_registration_handle(QEMUFile *f) error_report("rdma: 'compress' bad block index %u (vs %d)", (unsigned int)comp->block_idx, rdma->local_ram_blocks.nb_blocks); - ret =3D -EIO; goto err; } block =3D &(rdma->local_ram_blocks.block[comp->block_idx]); @@ -3672,7 +3664,6 @@ static int qemu_rdma_registration_handle(QEMUFile *f) error_report("rdma: 'register' bad block index %u (vs = %d)", (unsigned int)reg->current_index, rdma->local_ram_blocks.nb_blocks); - ret =3D -ENOENT; goto err; } block =3D &(rdma->local_ram_blocks.block[reg->current_inde= x]); @@ -3682,7 +3673,6 @@ static int qemu_rdma_registration_handle(QEMUFile *f) " offset: %" PRIx64 " current_addr: %" PRIx64, block->block_name, block->offset, reg->key.current_addr); - ret =3D -ERANGE; goto err; } host_addr =3D (block->local_host_addr + @@ -3698,7 +3688,6 @@ static int qemu_rdma_registration_handle(QEMUFile *f) error_report("rdma: bad chunk for block %s" " chunk: %" PRIx64, block->block_name, reg->key.chunk); - ret =3D -ERANGE; goto err; } } @@ -3710,7 +3699,6 @@ static int qemu_rdma_registration_handle(QEMUFile *f) (uintptr_t)host_addr, NULL, &tmp_rkey, chunk, chunk_start, chunk_end)) { error_report("cannot get rkey"); - ret =3D -EINVAL; goto err; } reg_result->rkey =3D tmp_rkey; @@ -3750,7 +3738,6 @@ static int qemu_rdma_registration_handle(QEMUFile *f) =20 if (ret !=3D 0) { perror("rdma unregistration chunk failed"); - ret =3D -ret; goto err; } =20 @@ -3769,11 +3756,9 @@ static int qemu_rdma_registration_handle(QEMUFile *f) break; case RDMA_CONTROL_REGISTER_RESULT: error_report("Invalid RESULT message at dest."); - ret =3D -EIO; goto err; default: error_report("Unknown control message %s", control_desc(head.t= ype)); - ret =3D -EIO; goto err; } } while (1); @@ -3877,7 +3862,7 @@ static int qemu_rdma_registration_stop(QEMUFile *f, QIOChannelRDMA *rioc =3D QIO_CHANNEL_RDMA(qemu_file_get_ioc(f)); RDMAContext *rdma; RDMAControlHeader head =3D { .len =3D 0, .repeat =3D 1 }; - int ret =3D 0; + int ret; =20 if (migration_in_postcopy()) { return 0; @@ -4151,7 +4136,7 @@ void rdma_start_outgoing_migration(void *opaque, MigrationState *s =3D opaque; RDMAContext *rdma_return_path =3D NULL; RDMAContext *rdma; - int ret =3D 0; + int ret; =20 /* Avoid ram_block_discard_disable(), cannot change during migration. = */ if (ram_block_discard_is_required()) { --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048550; cv=none; d=zohomail.com; s=zohoarc; b=Q5gvE+qE9WWQ85SXyLVnV/jG1JpeY7/Vd2P7Y+iUJAGIO5/bQSHgZyEpnONbQtO3gbLIp6gxykRseGby8xJfYFTF3UVQraP/1UdrcAozL2ZrSAai+jfalkPv7oTafnDkl2TlZ4IT1T6eBdyk9S9ujXP5O85mDEBxAL5okzQ4SrA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048550; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ooSw5XQ9Uexwquu9yFVpETBvwFnVBespYIJTmG1qCHc=; b=XmHt+BXYp3nCOPhU4MItmxCvOhMxwdjzlmP0QbJ6gse406trQmzb+lyfW/l8LD/Vg5btWXrA/vXO5vxPkwbKajiX4qgwDXPYjMFkJ9UCeTrkDp/x7Mnf4auoSjmd09Sa1Tp/0brlOJT352OTO5DlfR61yGDr7yw2lWTXgf/94J0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048550261253.98981281859915; Mon, 18 Sep 2023 07:49:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFSX-00037l-Vc; Mon, 18 Sep 2023 10:42:46 -0400 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 1qiFSK-0002x5-V6 for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS2-0002cT-NZ for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:32 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-270-fVD2gPUyOs2xNRdAKo0KLA-1; Mon, 18 Sep 2023 10:42:12 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8C7B7811E8E for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 326581C5BB for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 3A30021E688B; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048133; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ooSw5XQ9Uexwquu9yFVpETBvwFnVBespYIJTmG1qCHc=; b=cHIY1KByz7v3eJFCsoUPognIfLuowH0mBit/8v8MFDLdHDNwlilrE2DmHAv6AiJqxdxPTA g4IfxnBa1h4UamaLQUzXnL3AC0aIqs9J4MJOQaxXqQgrlxDcmPMzPqiFqcIyfXb7CXdgmj eRejupChjWJKee0I3EFG727/YZokHD4= X-MC-Unique: fVD2gPUyOs2xNRdAKo0KLA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 28/52] migration/rdma: Check negative error values the same way everywhere Date: Mon, 18 Sep 2023 16:41:42 +0200 Message-ID: <20230918144206.560120-29-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048551417100007 Content-Type: text/plain; charset="utf-8" When a function returns 0 on success, negative value on error, checking for non-zero suffices, but checking for negative is clearer. So do that. Signed-off-by: Markus Armbruster --- migration/rdma.c | 82 ++++++++++++++++++++++++------------------------ 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 62d95b7d2c..6c643a1b30 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -947,7 +947,7 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, Er= ror **errp) =20 /* create CM id */ ret =3D rdma_create_id(rdma->channel, &rdma->cm_id, NULL, RDMA_PS_TCP); - if (ret) { + if (ret < 0) { ERROR(errp, "could not create channel id"); goto err_resolve_create_id; } @@ -968,10 +968,10 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, = Error **errp) =20 ret =3D rdma_resolve_addr(rdma->cm_id, NULL, e->ai_dst_addr, RDMA_RESOLVE_TIMEOUT_MS); - if (!ret) { + if (ret >=3D 0) { if (e->ai_family =3D=3D AF_INET6) { ret =3D qemu_rdma_broken_ipv6_kernel(rdma->cm_id->verbs, e= rrp); - if (ret) { + if (ret < 0) { continue; } } @@ -988,7 +988,7 @@ route: qemu_rdma_dump_gid("source_resolve_addr", rdma->cm_id); =20 ret =3D rdma_get_cm_event(rdma->channel, &cm_event); - if (ret) { + if (ret < 0) { ERROR(errp, "could not perform event_addr_resolved"); goto err_resolve_get_addr; } @@ -1004,13 +1004,13 @@ route: =20 /* resolve route */ ret =3D rdma_resolve_route(rdma->cm_id, RDMA_RESOLVE_TIMEOUT_MS); - if (ret) { + if (ret < 0) { ERROR(errp, "could not resolve rdma route"); goto err_resolve_get_addr; } =20 ret =3D rdma_get_cm_event(rdma->channel, &cm_event); - if (ret) { + if (ret < 0) { ERROR(errp, "could not perform event_route_resolved"); goto err_resolve_get_addr; } @@ -1118,7 +1118,7 @@ static int qemu_rdma_alloc_qp(RDMAContext *rdma) attr.qp_type =3D IBV_QPT_RC; =20 ret =3D rdma_create_qp(rdma->cm_id, rdma->pd, &attr); - if (ret) { + if (ret < 0) { return -1; } =20 @@ -1551,7 +1551,7 @@ static int qemu_rdma_wait_comp_channel(RDMAContext *r= dma, =20 if (pfds[1].revents) { ret =3D rdma_get_cm_event(rdma->channel, &cm_event); - if (ret) { + if (ret < 0) { error_report("failed to get cm event while wait " "completion channel"); return -1; @@ -1652,12 +1652,12 @@ static int qemu_rdma_block_for_wrid(RDMAContext *rd= ma, =20 while (1) { ret =3D qemu_rdma_wait_comp_channel(rdma, ch); - if (ret) { + if (ret < 0) { goto err_block_for_wrid; } =20 ret =3D ibv_get_cq_event(ch, &cq, &cq_ctx); - if (ret) { + if (ret < 0) { perror("ibv_get_cq_event"); goto err_block_for_wrid; } @@ -1888,7 +1888,7 @@ static int qemu_rdma_exchange_send(RDMAContext *rdma,= RDMAControlHeader *head, */ if (resp) { ret =3D qemu_rdma_post_recv_control(rdma, RDMA_WRID_DATA); - if (ret) { + if (ret < 0) { error_report("rdma migration: error posting" " extra control recv for anticipated result!"); return -1; @@ -1899,7 +1899,7 @@ static int qemu_rdma_exchange_send(RDMAContext *rdma,= RDMAControlHeader *head, * Post a WR to replace the one we just consumed for the READY message. */ ret =3D qemu_rdma_post_recv_control(rdma, RDMA_WRID_READY); - if (ret) { + if (ret < 0) { error_report("rdma migration: error posting first control recv!"); return -1; } @@ -1986,7 +1986,7 @@ static int qemu_rdma_exchange_recv(RDMAContext *rdma,= RDMAControlHeader *head, * Post a new RECV work request to replace the one we just consumed. */ ret =3D qemu_rdma_post_recv_control(rdma, RDMA_WRID_READY); - if (ret) { + if (ret < 0) { error_report("rdma migration: error posting second control recv!"); return -1; } @@ -2311,7 +2311,7 @@ static int qemu_rdma_write(QEMUFile *f, RDMAContext *= rdma, /* If we cannot merge it, we flush the current buffer first. */ if (!qemu_rdma_buffer_mergable(rdma, current_addr, len)) { ret =3D qemu_rdma_write_flush(f, rdma); - if (ret) { + if (ret < 0) { return -1; } rdma->current_length =3D 0; @@ -2441,12 +2441,12 @@ static int qemu_rdma_source_init(RDMAContext *rdma,= bool pin_all, Error **errp) rdma->pin_all =3D pin_all; =20 ret =3D qemu_rdma_resolve_host(rdma, errp); - if (ret) { + if (ret < 0) { goto err_rdma_source_init; } =20 ret =3D qemu_rdma_alloc_pd_cq(rdma); - if (ret) { + if (ret < 0) { ERROR(errp, "rdma migration: error allocating pd and cq! Your mloc= k()" " limits may be too low. Please check $ ulimit -a # an= d " "search for 'ulimit -l' in the output"); @@ -2454,7 +2454,7 @@ static int qemu_rdma_source_init(RDMAContext *rdma, b= ool pin_all, Error **errp) } =20 ret =3D qemu_rdma_alloc_qp(rdma); - if (ret) { + if (ret < 0) { ERROR(errp, "rdma migration: error allocating qp!"); goto err_rdma_source_init; } @@ -2471,7 +2471,7 @@ static int qemu_rdma_source_init(RDMAContext *rdma, b= ool pin_all, Error **errp) =20 for (idx =3D 0; idx < RDMA_WRID_MAX; idx++) { ret =3D qemu_rdma_reg_control(rdma, idx); - if (ret) { + if (ret < 0) { ERROR(errp, "rdma migration: error registering %d control!", idx); goto err_rdma_source_init; @@ -2545,13 +2545,13 @@ static int qemu_rdma_connect(RDMAContext *rdma, boo= l return_path, caps_to_network(&cap); =20 ret =3D qemu_rdma_post_recv_control(rdma, RDMA_WRID_READY); - if (ret) { + if (ret < 0) { ERROR(errp, "posting second control recv"); goto err_rdma_source_connect; } =20 ret =3D rdma_connect(rdma->cm_id, &conn_param); - if (ret) { + if (ret < 0) { perror("rdma_connect"); ERROR(errp, "connecting to destination!"); goto err_rdma_source_connect; @@ -2565,7 +2565,7 @@ static int qemu_rdma_connect(RDMAContext *rdma, bool = return_path, ERROR(errp, "failed to get cm event"); } } - if (ret) { + if (ret < 0) { perror("rdma_get_cm_event after rdma_connect"); goto err_rdma_source_connect; } @@ -2633,7 +2633,7 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Err= or **errp) =20 /* create CM id */ ret =3D rdma_create_id(rdma->channel, &listen_id, NULL, RDMA_PS_TCP); - if (ret) { + if (ret < 0) { ERROR(errp, "could not create cm_id!"); goto err_dest_init_create_listen_id; } @@ -2649,7 +2649,7 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Err= or **errp) =20 ret =3D rdma_set_option(listen_id, RDMA_OPTION_ID, RDMA_OPTION_ID_REUS= EADDR, &reuse, sizeof reuse); - if (ret) { + if (ret < 0) { ERROR(errp, "Error: could not set REUSEADDR option"); goto err_dest_init_bind_addr; } @@ -2658,12 +2658,12 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, E= rror **errp) &((struct sockaddr_in *) e->ai_dst_addr)->sin_addr, ip, sizeof= ip); trace_qemu_rdma_dest_init_trying(rdma->host, ip); ret =3D rdma_bind_addr(listen_id, e->ai_dst_addr); - if (ret) { + if (ret < 0) { continue; } if (e->ai_family =3D=3D AF_INET6) { ret =3D qemu_rdma_broken_ipv6_kernel(listen_id->verbs, errp); - if (ret) { + if (ret < 0) { continue; } } @@ -3303,7 +3303,7 @@ static void rdma_cm_poll_handler(void *opaque) MigrationIncomingState *mis =3D migration_incoming_get_current(); =20 ret =3D rdma_get_cm_event(rdma->channel, &cm_event); - if (ret) { + if (ret < 0) { error_report("get_cm_event failed %d", errno); return; } @@ -3343,7 +3343,7 @@ static int qemu_rdma_accept(RDMAContext *rdma) int idx; =20 ret =3D rdma_get_cm_event(rdma->channel, &cm_event); - if (ret) { + if (ret < 0) { goto err_rdma_dest_wait; } =20 @@ -3413,13 +3413,13 @@ static int qemu_rdma_accept(RDMAContext *rdma) qemu_rdma_dump_id("dest_init", verbs); =20 ret =3D qemu_rdma_alloc_pd_cq(rdma); - if (ret) { + if (ret < 0) { error_report("rdma migration: error allocating pd and cq!"); goto err_rdma_dest_wait; } =20 ret =3D qemu_rdma_alloc_qp(rdma); - if (ret) { + if (ret < 0) { error_report("rdma migration: error allocating qp!"); goto err_rdma_dest_wait; } @@ -3428,7 +3428,7 @@ static int qemu_rdma_accept(RDMAContext *rdma) =20 for (idx =3D 0; idx < RDMA_WRID_MAX; idx++) { ret =3D qemu_rdma_reg_control(rdma, idx); - if (ret) { + if (ret < 0) { error_report("rdma: error registering %d control", idx); goto err_rdma_dest_wait; } @@ -3446,13 +3446,13 @@ static int qemu_rdma_accept(RDMAContext *rdma) } =20 ret =3D rdma_accept(rdma->cm_id, &conn_param); - if (ret) { + if (ret < 0) { error_report("rdma_accept failed"); goto err_rdma_dest_wait; } =20 ret =3D rdma_get_cm_event(rdma->channel, &cm_event); - if (ret) { + if (ret < 0) { error_report("rdma_accept get_cm_event failed"); goto err_rdma_dest_wait; } @@ -3467,7 +3467,7 @@ static int qemu_rdma_accept(RDMAContext *rdma) rdma->connected =3D true; =20 ret =3D qemu_rdma_post_recv_control(rdma, RDMA_WRID_READY); - if (ret) { + if (ret < 0) { error_report("rdma migration: error posting second control recv"); goto err_rdma_dest_wait; } @@ -3596,7 +3596,7 @@ static int qemu_rdma_registration_handle(QEMUFile *f) =20 if (rdma->pin_all) { ret =3D qemu_rdma_reg_whole_ram_blocks(rdma); - if (ret) { + if (ret < 0) { error_report("rdma migration: error dest " "registering ram blocks"); goto err; @@ -4057,7 +4057,7 @@ static void rdma_accept_incoming_migration(void *opaq= ue) trace_qemu_rdma_accept_incoming_migration(); ret =3D qemu_rdma_accept(rdma); =20 - if (ret) { + if (ret < 0) { fprintf(stderr, "RDMA ERROR: Migration initialization failed\n"); return; } @@ -4101,7 +4101,7 @@ void rdma_start_incoming_migration(const char *host_p= ort, Error **errp) } =20 ret =3D qemu_rdma_dest_init(rdma, errp); - if (ret) { + if (ret < 0) { goto err; } =20 @@ -4109,7 +4109,7 @@ void rdma_start_incoming_migration(const char *host_p= ort, Error **errp) =20 ret =3D rdma_listen(rdma->listen_id, 5); =20 - if (ret) { + if (ret < 0) { ERROR(errp, "listening on socket!"); goto cleanup_rdma; } @@ -4151,14 +4151,14 @@ void rdma_start_outgoing_migration(void *opaque, =20 ret =3D qemu_rdma_source_init(rdma, migrate_rdma_pin_all(), errp); =20 - if (ret) { + if (ret < 0) { goto err; } =20 trace_rdma_start_outgoing_migration_after_rdma_source_init(); ret =3D qemu_rdma_connect(rdma, false, errp); =20 - if (ret) { + if (ret < 0) { goto err; } =20 @@ -4173,13 +4173,13 @@ void rdma_start_outgoing_migration(void *opaque, ret =3D qemu_rdma_source_init(rdma_return_path, migrate_rdma_pin_all(), errp); =20 - if (ret) { + if (ret < 0) { goto return_path_err; } =20 ret =3D qemu_rdma_connect(rdma_return_path, true, errp); =20 - if (ret) { + if (ret < 0) { goto return_path_err; } =20 --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048535; cv=none; d=zohomail.com; s=zohoarc; b=ab2LQz1o/bQczB2A02W8qnCwlPGHH4+CfEPXBSdI7k0BIPYlAcwWcMI+cZB07nD6BK/KkkSiXfaGwNblKN5jVNNSZ/Bx02RGS1a4xUceXjVX00npSjkWgGVYmtoyAonAJcS1JddeBO8hVWJFMXmhVbHjWRfe7oNzRDgII0tDP0A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048535; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MekCpRJ0UTZUfcihTqFMKa+lcRtdtyas5aHLXosjyqA=; b=RdT4gLAuLfymayIL/m+mTh0D8h1DMqygp7/95AjhdWq7/QatVA4DZ7exSjm1QAj1IAq7MGzTsUaW2TF7jiJI28xjgig6UPROWZqo35ueBQNek6VIFhdVLcC1zDVe69uVtuX502p02XZEJy1XlvRmWtzTZkR0yhXmQd+t7xFysOI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048535034275.06899001905265; Mon, 18 Sep 2023 07:48:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFSx-0003Dz-QQ; Mon, 18 Sep 2023 10:43:11 -0400 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 1qiFSN-0002yD-GF for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS2-0002bJ-Pf for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:34 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-202-BJ4Bh03JOAu4thYOemANpg-1; Mon, 18 Sep 2023 10:42:10 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 563C129AA2C5 for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 33EC6C154CA for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 3CE1321E6890; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048132; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MekCpRJ0UTZUfcihTqFMKa+lcRtdtyas5aHLXosjyqA=; b=UDdtbCbcNni2sRkyHXVT7a005a+po1i/6GO48nIn/NVIaj0/v07I0U6mrfakekWIFBfJwu +0kkyKNvCywH8MazW5LdvS0yg/n8kokcZYX1JaG6mC4Ovu4YD7JwFcWXIwctt29em7Drow cYRxAgN2uP+/Gujxmjr+lsRT12puqmI= X-MC-Unique: BJ4Bh03JOAu4thYOemANpg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 29/52] migration/rdma: Plug a memory leak and improve a message Date: Mon, 18 Sep 2023 16:41:43 +0200 Message-ID: <20230918144206.560120-30-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048536934100013 Content-Type: text/plain; charset="utf-8" When migration capability @rdma-pin-all is true, but the server cannot honor it, qemu_rdma_connect() calls macro ERROR(), then returns success. ERROR() sets an error. Since qemu_rdma_connect() returns success, its caller rdma_start_outgoing_migration() duly assumes @errp is still clear. The Error object leaks. ERROR() additionally reports the situation to the user as an error: RDMA ERROR: Server cannot support pinning all memory. Will register mem= ory dynamically. Is this an error or not? It actually isn't; we disable @rdma-pin-all and carry on. "Correcting" the user's configuration decisions that way feels problematic, but that's a topic for another day. Replace ERROR() by warn_report(). This plugs the memory leak, and emits a clearer message to the user. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian --- migration/rdma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 6c643a1b30..d52de857c5 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -2586,8 +2586,8 @@ static int qemu_rdma_connect(RDMAContext *rdma, bool = return_path, * and disable them otherwise. */ if (rdma->pin_all && !(cap.flags & RDMA_CAPABILITY_PIN_ALL)) { - ERROR(errp, "Server cannot support pinning all memory. " - "Will register memory dynamically."); + warn_report("RDMA: Server cannot support pinning all memory. " + "Will register memory dynamically."); rdma->pin_all =3D false; } =20 --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048532; cv=none; d=zohomail.com; s=zohoarc; b=T1TvpQq1J4bsa5sq4nGkGG4DGbkuuS7fMJpYa0DreG/+rGDLdhHn5RA2QpSbFKMOldIQ6OLEtDKO3is++YOYp4845Z15YY9vk/ydj0RuJqBFFhVpquSEb3pYDr9+NLb7LVA+8NSEWmKVAVAG3hbJtsoj9NubOtO7MUZ+62BsIKk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048532; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LbCL39iFDXO2Ks6B/LPZC7VMXtx0EmFe5Orkqt96KBE=; b=KedKr7wV73Upv7z8gB4fLx35qmN0THX/Di9ZM5ttaPWH+/OS9WRaq2t3EAz0j6pZI9ftsi7kVWDaiDZhqIwgv9mN1sJEMSL8h1AytFR9rRI7WSQPAjrV6kr4e8rh7NY1m7UKi3hZ9GUbPfnew8M8PlWzJeWz1iWGMnNHpX3ZQss= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048532479463.1908680695557; Mon, 18 Sep 2023 07:48:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFSX-00036x-5i; Mon, 18 Sep 2023 10:42:45 -0400 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 1qiFSP-00031w-GE for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS2-0002bF-J9 for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:37 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-341--fyAMWO6PFWdRnLNr5Hsrw-1; Mon, 18 Sep 2023 10:42:10 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5AEB2811E8F for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 37CAB2156701 for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 3FBF321E6892; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048132; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LbCL39iFDXO2Ks6B/LPZC7VMXtx0EmFe5Orkqt96KBE=; b=Fh3VG1G2gEPod4e2wmY0yIiqsCJBnD3CjU2xPiVrp5Knt68+xP12RyBiduknxL7gKoJ1gr ijigiGbH7MmZqqxaXkKSXrjwCNmaecToO0k8pmHQMi1kB3zf+EBBceWLyQKdfnw2nKv4vh Q8+33XzDSUQv3lVAEP8IReAyQyrhjes= X-MC-Unique: -fyAMWO6PFWdRnLNr5Hsrw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 30/52] migration/rdma: Delete inappropriate error_report() in macro ERROR() Date: Mon, 18 Sep 2023 16:41:44 +0200 Message-ID: <20230918144206.560120-31-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048532865100001 Content-Type: text/plain; charset="utf-8" Functions that use an Error **errp parameter to return errors should not also report them to the user, because reporting is the caller's job. When the caller does, the error is reported twice. When it doesn't (because it recovered from the error), there is no error to report, i.e. the report is bogus. Macro ERROR() violates this principle. Delete the error_report() there. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian Tested-by: Li Zhijian --- migration/rdma.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index d52de857c5..be31694d4f 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -40,12 +40,8 @@ #include "options.h" #include =20 -/* - * Print and error on both the Monitor and the Log file. - */ #define ERROR(errp, fmt, ...) \ do { \ - fprintf(stderr, "RDMA ERROR: " fmt "\n", ## __VA_ARGS__); \ if (errp && (*(errp) =3D=3D NULL)) { \ error_setg(errp, "RDMA ERROR: " fmt, ## __VA_ARGS__); \ } \ --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048514; cv=none; d=zohomail.com; s=zohoarc; b=H/dOsrV3TYtk6ZH73e4ILsHiYqVQg4mwLJ61l/rcIIPCdnlTvbtIt1phclnSj88pPINVQR1vpbqNQBZrCU5X6/Q2Y5DlVfIkkuuOTX66PJ0BDvPqeE2XBNMTgu2canlZCyrA7w24fSg5edVEQtZjOun1kYVySeVcbw6ZrMzX5yg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048514; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lnBjhSC/3GPfyTVkp9EdCLWua8G5Rk0xH3nuRyXXXFs=; b=LANb9BPzxDr7r8jtI2Va+wcYFpOz8hn3qEzk1wAP5GfEXGV8QbDfEB0lnAQllzDwWdvobf3d17l8pDKr/Py1hmER7cTe1uCq3ODbYOBvPcFXiSnj787cikaFxOjoZ2ij82ZTsj4I+FWfn38/1q23cQR4IEKge8Q6XGHwfx0RUaI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048514189100.61961780967908; Mon, 18 Sep 2023 07:48:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFSy-0003EH-0K; Mon, 18 Sep 2023 10:43:12 -0400 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 1qiFSN-0002yF-H9 for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS2-0002bR-O5 for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:33 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-208-tW5FmdM2O-2IkGSNdnT6YQ-1; Mon, 18 Sep 2023 10:42:10 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 947093800BB6 for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 397854011E4 for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 42C1121E6893; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048132; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lnBjhSC/3GPfyTVkp9EdCLWua8G5Rk0xH3nuRyXXXFs=; b=hFXm/sc3oT2V/aVkPpgNnznu2nvJiKcLl/BiaZjnHiPYT4+GC6hKOv0Fgms3zuhEMCr4u+ ubAA8anW8znW/QO+JjvbbnA4+/HDS3/N8hOVW61z8EipW+JizfW5+M1G7nK1csq8Z2tf6S xaSV2Sq/RC+gT88m/r3xuTwzV0GF2fg= X-MC-Unique: tW5FmdM2O-2IkGSNdnT6YQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 31/52] migration/rdma: Retire macro ERROR() Date: Mon, 18 Sep 2023 16:41:45 +0200 Message-ID: <20230918144206.560120-32-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048514817100002 Content-Type: text/plain; charset="utf-8" ERROR() has become "error_setg() unless an error has been set already". Hiding the conditional in the macro is in the way of further work. Replace the macro uses by their expansion, and delete the macro. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian --- migration/rdma.c | 168 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 120 insertions(+), 48 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index be31694d4f..df5b3a8e2c 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -40,13 +40,6 @@ #include "options.h" #include =20 -#define ERROR(errp, fmt, ...) \ - do { \ - if (errp && (*(errp) =3D=3D NULL)) { \ - error_setg(errp, "RDMA ERROR: " fmt, ## __VA_ARGS__); \ - } \ - } while (0) - #define RDMA_RESOLVE_TIMEOUT_MS 10000 =20 /* Do not merge data if larger than this. */ @@ -859,7 +852,10 @@ static int qemu_rdma_broken_ipv6_kernel(struct ibv_con= text *verbs, Error **errp) =20 if (ibv_query_port(verbs, 1, &port_attr)) { ibv_close_device(verbs); - ERROR(errp, "Could not query initial IB port"); + if (errp && !*errp) { + error_setg(errp, + "RDMA ERROR: Could not query initial IB por= t"); + } return -1; } =20 @@ -882,9 +878,12 @@ static int qemu_rdma_broken_ipv6_kernel(struct ibv_con= text *verbs, Error **errp) " migrate over the IB fabric until the ker= nel " " fixes the bug.\n"); } else { - ERROR(errp, "You only have RoCE / iWARP devices in your sy= stems" - " and your management software has specified '= [::]'" - ", but IPv6 over RoCE / iWARP is not supported= in Linux."); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: " + "You only have RoCE / iWARP devices in your= systems" + " and your management software has specifie= d '[::]'" + ", but IPv6 over RoCE / iWARP is not suppor= ted in Linux."); + } return -1; } } @@ -900,13 +899,18 @@ static int qemu_rdma_broken_ipv6_kernel(struct ibv_co= ntext *verbs, Error **errp) =20 /* IB ports start with 1, not 0 */ if (ibv_query_port(verbs, 1, &port_attr)) { - ERROR(errp, "Could not query initial IB port"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: Could not query initial IB port"= ); + } return -1; } =20 if (port_attr.link_layer =3D=3D IBV_LINK_LAYER_ETHERNET) { - ERROR(errp, "Linux kernel's RoCE / iWARP does not support IPv6 " - "(but patches on linux-rdma in progress)"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: " + "Linux kernel's RoCE / iWARP does not support IPv6 " + "(but patches on linux-rdma in progress)"); + } return -1; } =20 @@ -930,21 +934,27 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, = Error **errp) struct rdma_addrinfo *e; =20 if (rdma->host =3D=3D NULL || !strcmp(rdma->host, "")) { - ERROR(errp, "RDMA hostname has not been set"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: RDMA hostname has not been set"); + } return -1; } =20 /* create CM channel */ rdma->channel =3D rdma_create_event_channel(); if (!rdma->channel) { - ERROR(errp, "could not create CM channel"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: could not create CM channel"); + } return -1; } =20 /* create CM id */ ret =3D rdma_create_id(rdma->channel, &rdma->cm_id, NULL, RDMA_PS_TCP); if (ret < 0) { - ERROR(errp, "could not create channel id"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: could not create channel id"); + } goto err_resolve_create_id; } =20 @@ -953,7 +963,10 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, E= rror **errp) =20 ret =3D rdma_getaddrinfo(rdma->host, port_str, NULL, &res); if (ret) { - ERROR(errp, "could not rdma_getaddrinfo address %s", rdma->host); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: could not rdma_getaddrinfo addre= ss %s", + rdma->host); + } goto err_resolve_get_addr; } =20 @@ -976,7 +989,10 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, E= rror **errp) } =20 rdma_freeaddrinfo(res); - ERROR(errp, "could not resolve address %s", rdma->host); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: could not resolve address %s", + rdma->host); + } goto err_resolve_get_addr; =20 route: @@ -985,13 +1001,18 @@ route: =20 ret =3D rdma_get_cm_event(rdma->channel, &cm_event); if (ret < 0) { - ERROR(errp, "could not perform event_addr_resolved"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: could not perform event_addr_res= olved"); + } goto err_resolve_get_addr; } =20 if (cm_event->event !=3D RDMA_CM_EVENT_ADDR_RESOLVED) { - ERROR(errp, "result not equal to event_addr_resolved %s", - rdma_event_str(cm_event->event)); + if (errp && !*errp) { + error_setg(errp, + "RDMA ERROR: result not equal to event_addr_resolve= d %s", + rdma_event_str(cm_event->event)); + } error_report("rdma_resolve_addr"); rdma_ack_cm_event(cm_event); goto err_resolve_get_addr; @@ -1001,18 +1022,25 @@ route: /* resolve route */ ret =3D rdma_resolve_route(rdma->cm_id, RDMA_RESOLVE_TIMEOUT_MS); if (ret < 0) { - ERROR(errp, "could not resolve rdma route"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: could not resolve rdma route"); + } goto err_resolve_get_addr; } =20 ret =3D rdma_get_cm_event(rdma->channel, &cm_event); if (ret < 0) { - ERROR(errp, "could not perform event_route_resolved"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: could not perform event_route_re= solved"); + } goto err_resolve_get_addr; } if (cm_event->event !=3D RDMA_CM_EVENT_ROUTE_RESOLVED) { - ERROR(errp, "result not equal to event_route_resolved: %s", - rdma_event_str(cm_event->event)); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: " + "result not equal to event_route_resolved: %s", + rdma_event_str(cm_event->event)); + } rdma_ack_cm_event(cm_event); goto err_resolve_get_addr; } @@ -2443,15 +2471,20 @@ static int qemu_rdma_source_init(RDMAContext *rdma,= bool pin_all, Error **errp) =20 ret =3D qemu_rdma_alloc_pd_cq(rdma); if (ret < 0) { - ERROR(errp, "rdma migration: error allocating pd and cq! Your mloc= k()" - " limits may be too low. Please check $ ulimit -a # an= d " - "search for 'ulimit -l' in the output"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: " + "rdma migration: error allocating pd and cq! Your m= lock()" + " limits may be too low. Please check $ ulimit -a #= and " + "search for 'ulimit -l' in the output"); + } goto err_rdma_source_init; } =20 ret =3D qemu_rdma_alloc_qp(rdma); if (ret < 0) { - ERROR(errp, "rdma migration: error allocating qp!"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: rdma migration: error allocating= qp!"); + } goto err_rdma_source_init; } =20 @@ -2468,8 +2501,11 @@ static int qemu_rdma_source_init(RDMAContext *rdma, = bool pin_all, Error **errp) for (idx =3D 0; idx < RDMA_WRID_MAX; idx++) { ret =3D qemu_rdma_reg_control(rdma, idx); if (ret < 0) { - ERROR(errp, "rdma migration: error registering %d control!", - idx); + if (errp && !*errp) { + error_setg(errp, + "RDMA ERROR: rdma migration: error registering = %d control!", + idx); + } goto err_rdma_source_init; } } @@ -2497,19 +2533,29 @@ static int qemu_get_cm_event_timeout(RDMAContext *r= dma, } while (ret < 0 && errno =3D=3D EINTR); =20 if (ret =3D=3D 0) { - ERROR(errp, "poll cm event timeout"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: poll cm event timeout"); + } return -1; } else if (ret < 0) { - ERROR(errp, "failed to poll cm event, errno=3D%i", errno); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: failed to poll cm event, errno= =3D%i", + errno); + } return -1; } else if (poll_fd.revents & POLLIN) { if (rdma_get_cm_event(rdma->channel, cm_event) < 0) { - ERROR(errp, "failed to get cm event"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: failed to get cm event"); + } return -1; } return 0; } else { - ERROR(errp, "no POLLIN event, revent=3D%x", poll_fd.revents); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: no POLLIN event, revent=3D%x", + poll_fd.revents); + } return -1; } } @@ -2542,14 +2588,18 @@ static int qemu_rdma_connect(RDMAContext *rdma, boo= l return_path, =20 ret =3D qemu_rdma_post_recv_control(rdma, RDMA_WRID_READY); if (ret < 0) { - ERROR(errp, "posting second control recv"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: posting second control recv"); + } goto err_rdma_source_connect; } =20 ret =3D rdma_connect(rdma->cm_id, &conn_param); if (ret < 0) { perror("rdma_connect"); - ERROR(errp, "connecting to destination!"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: connecting to destination!"); + } goto err_rdma_source_connect; } =20 @@ -2558,7 +2608,9 @@ static int qemu_rdma_connect(RDMAContext *rdma, bool = return_path, } else { ret =3D rdma_get_cm_event(rdma->channel, &cm_event); if (ret < 0) { - ERROR(errp, "failed to get cm event"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: failed to get cm event"); + } } } if (ret < 0) { @@ -2568,7 +2620,9 @@ static int qemu_rdma_connect(RDMAContext *rdma, bool = return_path, =20 if (cm_event->event !=3D RDMA_CM_EVENT_ESTABLISHED) { error_report("rdma_get_cm_event !=3D EVENT_ESTABLISHED after rdma_= connect"); - ERROR(errp, "connecting to destination!"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: connecting to destination!"); + } rdma_ack_cm_event(cm_event); goto err_rdma_source_connect; } @@ -2615,14 +2669,18 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, E= rror **errp) } =20 if (!rdma->host || !rdma->host[0]) { - ERROR(errp, "RDMA host is not set!"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: RDMA host is not set!"); + } rdma->errored =3D true; return -1; } /* create CM channel */ rdma->channel =3D rdma_create_event_channel(); if (!rdma->channel) { - ERROR(errp, "could not create rdma event channel"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: could not create rdma event chan= nel"); + } rdma->errored =3D true; return -1; } @@ -2630,7 +2688,9 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Err= or **errp) /* create CM id */ ret =3D rdma_create_id(rdma->channel, &listen_id, NULL, RDMA_PS_TCP); if (ret < 0) { - ERROR(errp, "could not create cm_id!"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: could not create cm_id!"); + } goto err_dest_init_create_listen_id; } =20 @@ -2639,14 +2699,19 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, E= rror **errp) =20 ret =3D rdma_getaddrinfo(rdma->host, port_str, NULL, &res); if (ret) { - ERROR(errp, "could not rdma_getaddrinfo address %s", rdma->host); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: could not rdma_getaddrinfo addre= ss %s", + rdma->host); + } goto err_dest_init_bind_addr; } =20 ret =3D rdma_set_option(listen_id, RDMA_OPTION_ID, RDMA_OPTION_ID_REUS= EADDR, &reuse, sizeof reuse); if (ret < 0) { - ERROR(errp, "Error: could not set REUSEADDR option"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: Error: could not set REUSEADDR o= ption"); + } goto err_dest_init_bind_addr; } for (e =3D res; e !=3D NULL; e =3D e->ai_next) { @@ -2668,7 +2733,9 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Err= or **errp) =20 rdma_freeaddrinfo(res); if (!e) { - ERROR(errp, "Error: could not rdma_bind_addr!"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: Error: could not rdma_bind_addr!= "); + } goto err_dest_init_bind_addr; } =20 @@ -2720,7 +2787,10 @@ static RDMAContext *qemu_rdma_data_init(const char *= host_port, Error **errp) rdma->host =3D g_strdup(addr->host); rdma->host_port =3D g_strdup(host_port); } else { - ERROR(errp, "bad RDMA migration address '%s'", host_port); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: bad RDMA migration address '%s'", + host_port); + } g_free(rdma); rdma =3D NULL; } @@ -4106,7 +4176,9 @@ void rdma_start_incoming_migration(const char *host_p= ort, Error **errp) ret =3D rdma_listen(rdma->listen_id, 5); =20 if (ret < 0) { - ERROR(errp, "listening on socket!"); + if (errp && !*errp) { + error_setg(errp, "RDMA ERROR: listening on socket!"); + } goto cleanup_rdma; } =20 --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048446; cv=none; d=zohomail.com; s=zohoarc; b=jMQn2m8a2nS0zFc+uvP2yDavtLXpi2UXkLMGk2UUTllyn3Wp0t20qx5v/7U8Wr7hIqUgNKtu3VK97EbeFi6EEWKmwb5LEa78TkkhPXFdW6QOYITKzC245W3xVPJqA/mbCMIZhGep/kFcwKBER2nR8nGe/ZQHFBZLGZcDsq+dbLk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048446; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vMM5P4bD7tAkGhNWVfycrZuYg29wkQEKEmlaj/k2jkA=; b=SNxchfRca9jonGeOvBGOlz5aYoCYQKi02aDXiitNkjrtUHxzGDLw9EzTdZnNsGEozTFH6JWh1AWiSkchIJZBwIWd6JLdGVcTFyEQIi+L6BevyAkQgERQZEChLf3Cnc2CCdsfo4eHnJTo8quM1NkgvbYWOtT2aImBvQvzz5HFSc4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048446498452.27575690342337; Mon, 18 Sep 2023 07:47:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFSS-00034B-9g; Mon, 18 Sep 2023 10:42:40 -0400 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 1qiFSJ-0002wr-Qx for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS2-0002bh-Lt for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:31 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-341-qmi8fE6XMhqeBMC0qcA9JQ-1; Mon, 18 Sep 2023 10:42:11 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7B9A83C025C5 for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3E1AF2156702 for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 4596121E6894; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048133; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vMM5P4bD7tAkGhNWVfycrZuYg29wkQEKEmlaj/k2jkA=; b=gUpL4DgKPpVGY8rrsPIYXeYaT+xYyePYQSECpTyr63wVraKDWiqirON9TRsZAYU8SE/XXf l4kRkwQigjQpyT6suoXKs5LItE8Lr/qG8PVqdMmmhdSOlSOMWoKp9Ds7SoZ/gNip6O4zqW PhlYIa62jShsVIl//Qrt3pJKuqb3PMU= X-MC-Unique: qmi8fE6XMhqeBMC0qcA9JQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 32/52] migration/rdma: Fix error handling around rdma_getaddrinfo() Date: Mon, 18 Sep 2023 16:41:46 +0200 Message-ID: <20230918144206.560120-33-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048447360100010 Content-Type: text/plain; charset="utf-8" qemu_rdma_resolve_host() and qemu_rdma_dest_init() iterate over addresses to find one that works, holding onto the first Error from qemu_rdma_broken_ipv6_kernel() for use when no address works. Issues: 1. If @errp was &error_abort or &error_fatal, we'd terminate instead of trying the next address. Can't actually happen, since no caller passes these arguments. 2. When @errp is a pointer to a variable containing NULL, and qemu_rdma_broken_ipv6_kernel() fails, the variable no longer contains NULL. Subsequent iterations pass it again, violating Error usage rules. Dangerous, as setting an error would then trip error_setv()'s assertion. Works only because qemu_rdma_broken_ipv6_kernel() and the code following the loops carefully avoids setting a second error. 3. If qemu_rdma_broken_ipv6_kernel() fails, and then a later iteration finds a working address, @errp still holds the first error from qemu_rdma_broken_ipv6_kernel(). If we then run into another error, we report the qemu_rdma_broken_ipv6_kernel() failure instead. 4. If we don't run into another error, we leak the Error object. Use a local error variable, and propagate to @errp. This fixes 3. and also cleans up 1 and partly 2. Free this error when we have a working address. This fixes 4. Pass the local error variable to qemu_rdma_broken_ipv6_kernel() only until it fails. Pass null on any later iterations. This cleans up the remainder of 2. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian --- migration/rdma.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index df5b3a8e2c..d29affe410 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -926,6 +926,7 @@ static int qemu_rdma_broken_ipv6_kernel(struct ibv_cont= ext *verbs, Error **errp) */ static int qemu_rdma_resolve_host(RDMAContext *rdma, Error **errp) { + Error *err =3D NULL; int ret; struct rdma_addrinfo *res; char port_str[16]; @@ -970,7 +971,10 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, E= rror **errp) goto err_resolve_get_addr; } =20 + /* Try all addresses, saving the first error in @err */ for (e =3D res; e !=3D NULL; e =3D e->ai_next) { + Error **local_errp =3D err ? NULL : &err; + inet_ntop(e->ai_family, &((struct sockaddr_in *) e->ai_dst_addr)->sin_addr, ip, sizeof= ip); trace_qemu_rdma_resolve_host_trying(rdma->host, ip); @@ -979,17 +983,21 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, = Error **errp) RDMA_RESOLVE_TIMEOUT_MS); if (ret >=3D 0) { if (e->ai_family =3D=3D AF_INET6) { - ret =3D qemu_rdma_broken_ipv6_kernel(rdma->cm_id->verbs, e= rrp); + ret =3D qemu_rdma_broken_ipv6_kernel(rdma->cm_id->verbs, + local_errp); if (ret < 0) { continue; } } + error_free(err); goto route; } } =20 rdma_freeaddrinfo(res); - if (errp && !*errp) { + if (err) { + error_propagate(errp, err); + } else { error_setg(errp, "RDMA ERROR: could not resolve address %s", rdma->host); } @@ -2656,6 +2664,7 @@ err_rdma_source_connect: =20 static int qemu_rdma_dest_init(RDMAContext *rdma, Error **errp) { + Error *err =3D NULL; int ret, idx; struct rdma_cm_id *listen_id; char ip[40] =3D "unknown"; @@ -2714,7 +2723,11 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Er= ror **errp) } goto err_dest_init_bind_addr; } + + /* Try all addresses, saving the first error in @err */ for (e =3D res; e !=3D NULL; e =3D e->ai_next) { + Error **local_errp =3D err ? NULL : &err; + inet_ntop(e->ai_family, &((struct sockaddr_in *) e->ai_dst_addr)->sin_addr, ip, sizeof= ip); trace_qemu_rdma_dest_init_trying(rdma->host, ip); @@ -2723,17 +2736,21 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, E= rror **errp) continue; } if (e->ai_family =3D=3D AF_INET6) { - ret =3D qemu_rdma_broken_ipv6_kernel(listen_id->verbs, errp); + ret =3D qemu_rdma_broken_ipv6_kernel(listen_id->verbs, + local_errp); if (ret < 0) { continue; } } + error_free(err); break; } =20 rdma_freeaddrinfo(res); if (!e) { - if (errp && !*errp) { + if (err) { + error_propagate(errp, err); + } else { error_setg(errp, "RDMA ERROR: Error: could not rdma_bind_addr!= "); } goto err_dest_init_bind_addr; --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048213; cv=none; d=zohomail.com; s=zohoarc; b=JGcj2NjvpasOsDliojMj1eguJYLIqgn/Cd4nPRdamJOGb4hlb8oFUXjuYhdX69fP9oHDRdsVwdpTa8CuGRbPdhTcQ8BHOPPUFPcpHMyuwTsuf1UzRgnriAVkp5p7qoPEWub52P0168ol9hVIGtbv1asUBLaIAf4SrN34/5Ls0y4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048213; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mfbNMHp4BPlTVbRuD5c1c/wdQ195dV1K9Pq5WQMIfIc=; b=RrMAotWy8kDqr6WSjruALxLEEnKVAwxULwvI7PRjBIWJXnYe52J4+Tty02TYU6uognh41aK5NYO1rQV29iYLwDdIkswWHgAwSD5dEYFKh+jwzGkpOndVS2gmsBGK3obq3Fjb0aUKmgDBKA8qMyyx+tkvcW2yNEjsSRXK+h+ZAiM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048213935882.0288945576195; Mon, 18 Sep 2023 07:43:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFSW-00036b-U8; Mon, 18 Sep 2023 10:42:44 -0400 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 1qiFSG-0002vl-3c for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS2-0002cC-J9 for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:27 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-64-pjDR_SLWNbuHOrq3ZXzIiA-1; Mon, 18 Sep 2023 10:42:11 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B27D5101B044 for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5893D1CBC0 for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 48B3321E6895; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048133; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mfbNMHp4BPlTVbRuD5c1c/wdQ195dV1K9Pq5WQMIfIc=; b=cph5lG16ujFagkeN0oRe4kWNM1iExuRPvB7ahT4kkShRbtQaUI8N2uLhMW/W50KVPTjN+x 5ngx+gm3lWV4KbLTHY+6qCFfH6B6Sb53oazcveTBuAh2iDS3AtzrN3BpoaDivJsnF7fIGx QDuOviHP306X0As8W7bCxeaaAajfT/0= X-MC-Unique: pjDR_SLWNbuHOrq3ZXzIiA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 33/52] migration/rdma: Drop "@errp is clear" guards around error_setg() Date: Mon, 18 Sep 2023 16:41:47 +0200 Message-ID: <20230918144206.560120-34-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048214646100009 Content-Type: text/plain; charset="utf-8" These guards are all redundant now. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian --- migration/rdma.c | 164 +++++++++++++++-------------------------------- 1 file changed, 51 insertions(+), 113 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index d29affe410..c88cd1f468 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -852,10 +852,8 @@ static int qemu_rdma_broken_ipv6_kernel(struct ibv_con= text *verbs, Error **errp) =20 if (ibv_query_port(verbs, 1, &port_attr)) { ibv_close_device(verbs); - if (errp && !*errp) { - error_setg(errp, - "RDMA ERROR: Could not query initial IB por= t"); - } + error_setg(errp, + "RDMA ERROR: Could not query initial IB port"); return -1; } =20 @@ -878,12 +876,10 @@ static int qemu_rdma_broken_ipv6_kernel(struct ibv_co= ntext *verbs, Error **errp) " migrate over the IB fabric until the ker= nel " " fixes the bug.\n"); } else { - if (errp && !*errp) { - error_setg(errp, "RDMA ERROR: " - "You only have RoCE / iWARP devices in your= systems" - " and your management software has specifie= d '[::]'" - ", but IPv6 over RoCE / iWARP is not suppor= ted in Linux."); - } + error_setg(errp, "RDMA ERROR: " + "You only have RoCE / iWARP devices in your sys= tems" + " and your management software has specified '[= ::]'" + ", but IPv6 over RoCE / iWARP is not supported = in Linux."); return -1; } } @@ -899,18 +895,14 @@ static int qemu_rdma_broken_ipv6_kernel(struct ibv_co= ntext *verbs, Error **errp) =20 /* IB ports start with 1, not 0 */ if (ibv_query_port(verbs, 1, &port_attr)) { - if (errp && !*errp) { - error_setg(errp, "RDMA ERROR: Could not query initial IB port"= ); - } + error_setg(errp, "RDMA ERROR: Could not query initial IB port"); return -1; } =20 if (port_attr.link_layer =3D=3D IBV_LINK_LAYER_ETHERNET) { - if (errp && !*errp) { - error_setg(errp, "RDMA ERROR: " - "Linux kernel's RoCE / iWARP does not support IPv6 " - "(but patches on linux-rdma in progress)"); - } + error_setg(errp, "RDMA ERROR: " + "Linux kernel's RoCE / iWARP does not support IPv6 " + "(but patches on linux-rdma in progress)"); return -1; } =20 @@ -935,27 +927,21 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, = Error **errp) struct rdma_addrinfo *e; =20 if (rdma->host =3D=3D NULL || !strcmp(rdma->host, "")) { - if (errp && !*errp) { - error_setg(errp, "RDMA ERROR: RDMA hostname has not been set"); - } + error_setg(errp, "RDMA ERROR: RDMA hostname has not been set"); return -1; } =20 /* create CM channel */ rdma->channel =3D rdma_create_event_channel(); if (!rdma->channel) { - if (errp && !*errp) { - error_setg(errp, "RDMA ERROR: could not create CM channel"); - } + error_setg(errp, "RDMA ERROR: could not create CM channel"); return -1; } =20 /* create CM id */ ret =3D rdma_create_id(rdma->channel, &rdma->cm_id, NULL, RDMA_PS_TCP); if (ret < 0) { - if (errp && !*errp) { - error_setg(errp, "RDMA ERROR: could not create channel id"); - } + error_setg(errp, "RDMA ERROR: could not create channel id"); goto err_resolve_create_id; } =20 @@ -964,10 +950,8 @@ static int qemu_rdma_resolve_host(RDMAContext *rdma, E= rror **errp) =20 ret =3D rdma_getaddrinfo(rdma->host, port_str, NULL, &res); if (ret) { - if (errp && !*errp) { - error_setg(errp, "RDMA ERROR: could not rdma_getaddrinfo addre= ss %s", - rdma->host); - } + error_setg(errp, "RDMA ERROR: could not rdma_getaddrinfo address %= s", + rdma->host); goto err_resolve_get_addr; } =20 @@ -1009,18 +993,14 @@ route: =20 ret =3D rdma_get_cm_event(rdma->channel, &cm_event); if (ret < 0) { - if (errp && !*errp) { - error_setg(errp, "RDMA ERROR: could not perform event_addr_res= olved"); - } + error_setg(errp, "RDMA ERROR: could not perform event_addr_resolve= d"); goto err_resolve_get_addr; } =20 if (cm_event->event !=3D RDMA_CM_EVENT_ADDR_RESOLVED) { - if (errp && !*errp) { - error_setg(errp, - "RDMA ERROR: result not equal to event_addr_resolve= d %s", - rdma_event_str(cm_event->event)); - } + error_setg(errp, + "RDMA ERROR: result not equal to event_addr_resolved %s= ", + rdma_event_str(cm_event->event)); error_report("rdma_resolve_addr"); rdma_ack_cm_event(cm_event); goto err_resolve_get_addr; @@ -1030,25 +1010,19 @@ route: /* resolve route */ ret =3D rdma_resolve_route(rdma->cm_id, RDMA_RESOLVE_TIMEOUT_MS); if (ret < 0) { - if (errp && !*errp) { - error_setg(errp, "RDMA ERROR: could not resolve rdma route"); - } + error_setg(errp, "RDMA ERROR: could not resolve rdma route"); goto err_resolve_get_addr; } =20 ret =3D rdma_get_cm_event(rdma->channel, &cm_event); if (ret < 0) { - if (errp && !*errp) { - error_setg(errp, "RDMA ERROR: could not perform event_route_re= solved"); - } + error_setg(errp, "RDMA ERROR: could not perform event_route_resolv= ed"); goto err_resolve_get_addr; } if (cm_event->event !=3D RDMA_CM_EVENT_ROUTE_RESOLVED) { - if (errp && !*errp) { - error_setg(errp, "RDMA ERROR: " - "result not equal to event_route_resolved: %s", - rdma_event_str(cm_event->event)); - } + error_setg(errp, "RDMA ERROR: " + "result not equal to event_route_resolved: %s", + rdma_event_str(cm_event->event)); rdma_ack_cm_event(cm_event); goto err_resolve_get_addr; } @@ -2479,20 +2453,16 @@ static int qemu_rdma_source_init(RDMAContext *rdma,= bool pin_all, Error **errp) =20 ret =3D qemu_rdma_alloc_pd_cq(rdma); if (ret < 0) { - if (errp && !*errp) { - error_setg(errp, "RDMA ERROR: " - "rdma migration: error allocating pd and cq! Your m= lock()" - " limits may be too low. Please check $ ulimit -a #= and " - "search for 'ulimit -l' in the output"); - } + error_setg(errp, "RDMA ERROR: " + "rdma migration: error allocating pd and cq! Your mlock= ()" + " limits may be too low. Please check $ ulimit -a # and= " + "search for 'ulimit -l' in the output"); goto err_rdma_source_init; } =20 ret =3D qemu_rdma_alloc_qp(rdma); if (ret < 0) { - if (errp && !*errp) { - error_setg(errp, "RDMA ERROR: rdma migration: error allocating= qp!"); - } + error_setg(errp, "RDMA ERROR: rdma migration: error allocating qp!= "); goto err_rdma_source_init; } =20 @@ -2509,11 +2479,9 @@ static int qemu_rdma_source_init(RDMAContext *rdma, = bool pin_all, Error **errp) for (idx =3D 0; idx < RDMA_WRID_MAX; idx++) { ret =3D qemu_rdma_reg_control(rdma, idx); if (ret < 0) { - if (errp && !*errp) { - error_setg(errp, - "RDMA ERROR: rdma migration: error registering = %d control!", - idx); - } + error_setg(errp, + "RDMA ERROR: rdma migration: error registering %d c= ontrol!", + idx); goto err_rdma_source_init; } } @@ -2541,29 +2509,21 @@ static int qemu_get_cm_event_timeout(RDMAContext *r= dma, } while (ret < 0 && errno =3D=3D EINTR); =20 if (ret =3D=3D 0) { - if (errp && !*errp) { - error_setg(errp, "RDMA ERROR: poll cm event timeout"); - } + error_setg(errp, "RDMA ERROR: poll cm event timeout"); return -1; } else if (ret < 0) { - if (errp && !*errp) { - error_setg(errp, "RDMA ERROR: failed to poll cm event, errno= =3D%i", - errno); - } + error_setg(errp, "RDMA ERROR: failed to poll cm event, errno=3D%i", + errno); return -1; } else if (poll_fd.revents & POLLIN) { if (rdma_get_cm_event(rdma->channel, cm_event) < 0) { - if (errp && !*errp) { - error_setg(errp, "RDMA ERROR: failed to get cm event"); - } + error_setg(errp, "RDMA ERROR: failed to get cm event"); return -1; } return 0; } else { - if (errp && !*errp) { - error_setg(errp, "RDMA ERROR: no POLLIN event, revent=3D%x", - poll_fd.revents); - } + error_setg(errp, "RDMA ERROR: no POLLIN event, revent=3D%x", + poll_fd.revents); return -1; } } @@ -2596,18 +2556,14 @@ static int qemu_rdma_connect(RDMAContext *rdma, boo= l return_path, =20 ret =3D qemu_rdma_post_recv_control(rdma, RDMA_WRID_READY); if (ret < 0) { - if (errp && !*errp) { - error_setg(errp, "RDMA ERROR: posting second control recv"); - } + error_setg(errp, "RDMA ERROR: posting second control recv"); goto err_rdma_source_connect; } =20 ret =3D rdma_connect(rdma->cm_id, &conn_param); if (ret < 0) { perror("rdma_connect"); - if (errp && !*errp) { - error_setg(errp, "RDMA ERROR: connecting to destination!"); - } + error_setg(errp, "RDMA ERROR: connecting to destination!"); goto err_rdma_source_connect; } =20 @@ -2616,9 +2572,7 @@ static int qemu_rdma_connect(RDMAContext *rdma, bool = return_path, } else { ret =3D rdma_get_cm_event(rdma->channel, &cm_event); if (ret < 0) { - if (errp && !*errp) { - error_setg(errp, "RDMA ERROR: failed to get cm event"); - } + error_setg(errp, "RDMA ERROR: failed to get cm event"); } } if (ret < 0) { @@ -2628,9 +2582,7 @@ static int qemu_rdma_connect(RDMAContext *rdma, bool = return_path, =20 if (cm_event->event !=3D RDMA_CM_EVENT_ESTABLISHED) { error_report("rdma_get_cm_event !=3D EVENT_ESTABLISHED after rdma_= connect"); - if (errp && !*errp) { - error_setg(errp, "RDMA ERROR: connecting to destination!"); - } + error_setg(errp, "RDMA ERROR: connecting to destination!"); rdma_ack_cm_event(cm_event); goto err_rdma_source_connect; } @@ -2678,18 +2630,14 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, E= rror **errp) } =20 if (!rdma->host || !rdma->host[0]) { - if (errp && !*errp) { - error_setg(errp, "RDMA ERROR: RDMA host is not set!"); - } + error_setg(errp, "RDMA ERROR: RDMA host is not set!"); rdma->errored =3D true; return -1; } /* create CM channel */ rdma->channel =3D rdma_create_event_channel(); if (!rdma->channel) { - if (errp && !*errp) { - error_setg(errp, "RDMA ERROR: could not create rdma event chan= nel"); - } + error_setg(errp, "RDMA ERROR: could not create rdma event channel"= ); rdma->errored =3D true; return -1; } @@ -2697,9 +2645,7 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, Err= or **errp) /* create CM id */ ret =3D rdma_create_id(rdma->channel, &listen_id, NULL, RDMA_PS_TCP); if (ret < 0) { - if (errp && !*errp) { - error_setg(errp, "RDMA ERROR: could not create cm_id!"); - } + error_setg(errp, "RDMA ERROR: could not create cm_id!"); goto err_dest_init_create_listen_id; } =20 @@ -2708,19 +2654,15 @@ static int qemu_rdma_dest_init(RDMAContext *rdma, E= rror **errp) =20 ret =3D rdma_getaddrinfo(rdma->host, port_str, NULL, &res); if (ret) { - if (errp && !*errp) { - error_setg(errp, "RDMA ERROR: could not rdma_getaddrinfo addre= ss %s", - rdma->host); - } + error_setg(errp, "RDMA ERROR: could not rdma_getaddrinfo address %= s", + rdma->host); goto err_dest_init_bind_addr; } =20 ret =3D rdma_set_option(listen_id, RDMA_OPTION_ID, RDMA_OPTION_ID_REUS= EADDR, &reuse, sizeof reuse); if (ret < 0) { - if (errp && !*errp) { - error_setg(errp, "RDMA ERROR: Error: could not set REUSEADDR o= ption"); - } + error_setg(errp, "RDMA ERROR: Error: could not set REUSEADDR optio= n"); goto err_dest_init_bind_addr; } =20 @@ -2804,10 +2746,8 @@ static RDMAContext *qemu_rdma_data_init(const char *= host_port, Error **errp) rdma->host =3D g_strdup(addr->host); rdma->host_port =3D g_strdup(host_port); } else { - if (errp && !*errp) { - error_setg(errp, "RDMA ERROR: bad RDMA migration address '%s'", - host_port); - } + error_setg(errp, "RDMA ERROR: bad RDMA migration address '%s'", + host_port); g_free(rdma); rdma =3D NULL; } @@ -4193,9 +4133,7 @@ void rdma_start_incoming_migration(const char *host_p= ort, Error **errp) ret =3D rdma_listen(rdma->listen_id, 5); =20 if (ret < 0) { - if (errp && !*errp) { - error_setg(errp, "RDMA ERROR: listening on socket!"); - } + error_setg(errp, "RDMA ERROR: listening on socket!"); goto cleanup_rdma; } =20 --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048481; cv=none; d=zohomail.com; s=zohoarc; b=A3X8rpXb+ZNiGIyhn0OahBQ1bn8j08lPSZpaK3ktivAisMIoK8iV/92rMid7Vdc1WJbA/YFWhC9lf5M7uokWwkwNONi/U+LwvCv8H5uUYLxwUnuLwPb7VvpKK+9rY43e2QMf4NPacbk9ltcDoeX28UOZ+5QGr4nuntQMbkpSu6k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048481; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ao1lL2fUsrg7+XgQqlyGegTRchK9OqkMocZDWWo+amg=; b=FHxBtvj+MCpXYl/ciZ4r4vHy8CyqM8OBmVtblKrR/W43axca953lKveHKo+BUcNUJD4ciOFaQwagFpU5bIefZRNO+/CcqSTLTjlR6DVKaksmgeO5UlPJYDeMd/nG6Q2nE5hExEwC8GnBKcKBIRDacoEvFO/M0mVZFQizEwQUArU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048481951239.3033795472968; Mon, 18 Sep 2023 07:48:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFSy-0003EF-0m; Mon, 18 Sep 2023 10:43:12 -0400 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 1qiFSO-00030k-Cq for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS2-0002bn-RJ for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:36 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-270-R-nFck-qN_66qwqy37Lfog-1; Mon, 18 Sep 2023 10:42:10 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 88744858286 for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 66283140E964 for ; Mon, 18 Sep 2023 14:42:10 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 4B7FC21E6896; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048133; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ao1lL2fUsrg7+XgQqlyGegTRchK9OqkMocZDWWo+amg=; b=GAZN/3lUyI2g7HW31+pOhkboIbg/V10VNjV6cpyd6+vIiL1tGRxWfGDCGjFR1XJF38E66c v4G5WaTD4PFYj6LO30mAV68DjDT6eC7jZRLxuV3ClrJya62pWkJfKoR0jujzPGrr/+cfAs EPDagcYhHR6rSeRkfmgKhkqROqt6BAs= X-MC-Unique: R-nFck-qN_66qwqy37Lfog-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 34/52] migration/rdma: Convert qemu_rdma_exchange_recv() to Error Date: Mon, 18 Sep 2023 16:41:48 +0200 Message-ID: <20230918144206.560120-35-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048482769100001 Content-Type: text/plain; charset="utf-8" Functions that use an Error **errp parameter to return errors should not also report them to the user, because reporting is the caller's job. When the caller does, the error is reported twice. When it doesn't (because it recovered from the error), there is no error to report, i.e. the report is bogus. qio_channel_rdma_readv() violates this principle: it calls error_report() via qemu_rdma_exchange_recv(). I elected not to investigate how callers handle the error, i.e. precise impact is not known. Clean this up by converting qemu_rdma_exchange_recv() to Error. Necessitates setting an error when qemu_rdma_exchange_get_response() failed. Since this error will go away later in this series, simply use "FIXME temporary error message" there. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian --- migration/rdma.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index c88cd1f468..50546b3a27 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1957,7 +1957,7 @@ static int qemu_rdma_exchange_send(RDMAContext *rdma,= RDMAControlHeader *head, * control-channel message. */ static int qemu_rdma_exchange_recv(RDMAContext *rdma, RDMAControlHeader *h= ead, - uint32_t expecting) + uint32_t expecting, Error **errp) { RDMAControlHeader ready =3D { .len =3D 0, @@ -1972,7 +1972,7 @@ static int qemu_rdma_exchange_recv(RDMAContext *rdma,= RDMAControlHeader *head, ret =3D qemu_rdma_post_send_control(rdma, NULL, &ready); =20 if (ret < 0) { - error_report("Failed to send control buffer!"); + error_setg(errp, "Failed to send control buffer!"); return -1; } =20 @@ -1983,6 +1983,7 @@ static int qemu_rdma_exchange_recv(RDMAContext *rdma,= RDMAControlHeader *head, expecting, RDMA_WRID_READY); =20 if (ret < 0) { + error_setg(errp, "FIXME temporary error message"); return -1; } =20 @@ -1993,7 +1994,7 @@ static int qemu_rdma_exchange_recv(RDMAContext *rdma,= RDMAControlHeader *head, */ ret =3D qemu_rdma_post_recv_control(rdma, RDMA_WRID_READY); if (ret < 0) { - error_report("rdma migration: error posting second control recv!"); + error_setg(errp, "rdma migration: error posting second control rec= v!"); return -1; } =20 @@ -2908,11 +2909,11 @@ static ssize_t qio_channel_rdma_readv(QIOChannel *i= oc, /* We've got nothing at all, so lets wait for * more to arrive */ - ret =3D qemu_rdma_exchange_recv(rdma, &head, RDMA_CONTROL_QEMU_FIL= E); + ret =3D qemu_rdma_exchange_recv(rdma, &head, RDMA_CONTROL_QEMU_FIL= E, + errp); =20 if (ret < 0) { rdma->errored =3D true; - error_setg(errp, "qemu_rdma_exchange_recv failed"); return -1; } =20 @@ -3536,6 +3537,7 @@ static int qemu_rdma_registration_handle(QEMUFile *f) RDMAControlHeader blocks =3D { .type =3D RDMA_CONTROL_RAM_BLOCKS_RESUL= T, .repeat =3D 1 }; QIOChannelRDMA *rioc =3D QIO_CHANNEL_RDMA(qemu_file_get_ioc(f)); + Error *err =3D NULL; RDMAContext *rdma; RDMALocalBlocks *local; RDMAControlHeader head; @@ -3565,9 +3567,10 @@ static int qemu_rdma_registration_handle(QEMUFile *f) do { trace_qemu_rdma_registration_handle_wait(); =20 - ret =3D qemu_rdma_exchange_recv(rdma, &head, RDMA_CONTROL_NONE); + ret =3D qemu_rdma_exchange_recv(rdma, &head, RDMA_CONTROL_NONE, &e= rr); =20 if (ret < 0) { + error_report_err(err); break; } =20 --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048534; cv=none; d=zohomail.com; s=zohoarc; b=fh7wIucXrFr6hsRRGu7PBo25Q7Wg+6P+rcvherZRTeQzuZ/U2oX3l4Rnj/GFZIMMIF1JPZzSLbfanWhwU0y/GMtcHqLnkyU1EHV1QLU/tXVs2rUSTtt2kAA8018y7qJA3LnCuLe+Aj/uIH96kUSqvVQP7I2rLdwSmp6E1dRUCws= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048534; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rwH8QnP++s+4eSMvIgUbs1Tl/BaN4sBzdF4fSv77DHc=; b=M8jibCN7Lg8nGEAUNg4i9md76Dzt5+0acRjBc34aC2qCKcK8Zal0TSjQ8fAqY+q+0oJSmeIVEwHglMsVqProFTsQkOz125iWmuGuA8QvmnmHRbAbYuEfawAMtK4Vy3MwtCY0mxU1XKHZrDrc1YQNycF9puFB3xs8Sq8YbAknv6g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048534186400.1016382144261; Mon, 18 Sep 2023 07:48:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFT1-0003HE-C5; Mon, 18 Sep 2023 10:43:16 -0400 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 1qiFSP-00032C-UZ for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS2-0002c6-TB for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:37 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-58-BxhD0-aOOCe3gjOQfqSi8w-1; Mon, 18 Sep 2023 10:42:11 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 54B263800BAA for ; Mon, 18 Sep 2023 14:42:11 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 16543140E950 for ; Mon, 18 Sep 2023 14:42:11 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 4E85A21E6897; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048133; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rwH8QnP++s+4eSMvIgUbs1Tl/BaN4sBzdF4fSv77DHc=; b=aN/nSdO0tamBUAumPzvoPqmao2XLcU+HPuFA+OYT4BxYeQWw1nyiADQV4Oo0Y88xPfMyao om3XCuqOwPKs9kqxH+f2mJzX/ojh3tlDjcUHOT6pCm/tOO42oRaJp7hn+8e1LdIWqc+OY/ 61GcQfl/KFaWguDMtoufto0qEOIDcEM= X-MC-Unique: BxhD0-aOOCe3gjOQfqSi8w-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 35/52] migration/rdma: Convert qemu_rdma_exchange_send() to Error Date: Mon, 18 Sep 2023 16:41:49 +0200 Message-ID: <20230918144206.560120-36-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048534908100007 Content-Type: text/plain; charset="utf-8" Functions that use an Error **errp parameter to return errors should not also report them to the user, because reporting is the caller's job. When the caller does, the error is reported twice. When it doesn't (because it recovered from the error), there is no error to report, i.e. the report is bogus. qio_channel_rdma_writev() violates this principle: it calls error_report() via qemu_rdma_exchange_send(). I elected not to investigate how callers handle the error, i.e. precise impact is not known. Clean this up by converting qemu_rdma_exchange_send() to Error. Necessitates setting an error when qemu_rdma_post_recv_control(), callback(), or qemu_rdma_exchange_get_response() failed. Since these errors will go away later in this series, simply use "FIXME temporary error message" there. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian --- migration/rdma.c | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 50546b3a27..c1bfc20824 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -518,7 +518,8 @@ static void network_to_result(RDMARegisterResult *resul= t) static int qemu_rdma_exchange_send(RDMAContext *rdma, RDMAControlHeader *h= ead, uint8_t *data, RDMAControlHeader *resp, int *resp_idx, - int (*callback)(RDMAContext *rdma)); + int (*callback)(RDMAContext *rdma), + Error **errp); =20 static inline uint64_t ram_chunk_index(const uint8_t *start, const uint8_t *host) @@ -1365,6 +1366,8 @@ static int qemu_rdma_reg_control(RDMAContext *rdma, i= nt idx) */ static int qemu_rdma_unregister_waiting(RDMAContext *rdma) { + Error *err =3D NULL; + while (rdma->unregistrations[rdma->unregister_current]) { int ret; uint64_t wr_id =3D rdma->unregistrations[rdma->unregister_current]; @@ -1422,8 +1425,9 @@ static int qemu_rdma_unregister_waiting(RDMAContext *= rdma) reg.key.chunk =3D chunk; register_to_network(rdma, ®); ret =3D qemu_rdma_exchange_send(rdma, &head, (uint8_t *) ®, - &resp, NULL, NULL); + &resp, NULL, NULL, &err); if (ret < 0) { + error_report_err(err); return -1; } =20 @@ -1872,7 +1876,8 @@ static void qemu_rdma_move_header(RDMAContext *rdma, = int idx, static int qemu_rdma_exchange_send(RDMAContext *rdma, RDMAControlHeader *h= ead, uint8_t *data, RDMAControlHeader *resp, int *resp_idx, - int (*callback)(RDMAContext *rdma)) + int (*callback)(RDMAContext *rdma), + Error **errp) { int ret; =20 @@ -1885,6 +1890,7 @@ static int qemu_rdma_exchange_send(RDMAContext *rdma,= RDMAControlHeader *head, ret =3D qemu_rdma_exchange_get_response(rdma, &resp, RDMA_CONTROL_READY, RDMA_WRID_R= EADY); if (ret < 0) { + error_setg(errp, "FIXME temporary error message"); return -1; } } @@ -1895,7 +1901,7 @@ static int qemu_rdma_exchange_send(RDMAContext *rdma,= RDMAControlHeader *head, if (resp) { ret =3D qemu_rdma_post_recv_control(rdma, RDMA_WRID_DATA); if (ret < 0) { - error_report("rdma migration: error posting" + error_setg(errp, "rdma migration: error posting" " extra control recv for anticipated result!"); return -1; } @@ -1906,7 +1912,7 @@ static int qemu_rdma_exchange_send(RDMAContext *rdma,= RDMAControlHeader *head, */ ret =3D qemu_rdma_post_recv_control(rdma, RDMA_WRID_READY); if (ret < 0) { - error_report("rdma migration: error posting first control recv!"); + error_setg(errp, "rdma migration: error posting first control recv= !"); return -1; } =20 @@ -1916,7 +1922,7 @@ static int qemu_rdma_exchange_send(RDMAContext *rdma,= RDMAControlHeader *head, ret =3D qemu_rdma_post_send_control(rdma, data, head); =20 if (ret < 0) { - error_report("Failed to send control buffer!"); + error_setg(errp, "Failed to send control buffer!"); return -1; } =20 @@ -1928,6 +1934,7 @@ static int qemu_rdma_exchange_send(RDMAContext *rdma,= RDMAControlHeader *head, trace_qemu_rdma_exchange_send_issue_callback(); ret =3D callback(rdma); if (ret < 0) { + error_setg(errp, "FIXME temporary error message"); return -1; } } @@ -1937,6 +1944,7 @@ static int qemu_rdma_exchange_send(RDMAContext *rdma,= RDMAControlHeader *head, resp->type, RDMA_WRID_DATA); =20 if (ret < 0) { + error_setg(errp, "FIXME temporary error message"); return -1; } =20 @@ -2011,6 +2019,7 @@ static int qemu_rdma_write_one(QEMUFile *f, RDMAConte= xt *rdma, int current_index, uint64_t current_addr, uint64_t length) { + Error *err =3D NULL; struct ibv_sge sge; struct ibv_send_wr send_wr =3D { 0 }; struct ibv_send_wr *bad_wr; @@ -2096,9 +2105,10 @@ retry: =20 compress_to_network(rdma, &comp); ret =3D qemu_rdma_exchange_send(rdma, &head, - (uint8_t *) &comp, NULL, NULL, NULL); + (uint8_t *) &comp, NULL, NULL, NULL, &err); =20 if (ret < 0) { + error_report_err(err); return -1; } =20 @@ -2124,8 +2134,9 @@ retry: =20 register_to_network(rdma, ®); ret =3D qemu_rdma_exchange_send(rdma, &head, (uint8_t *) ®, - &resp, ®_result_idx, NULL); + &resp, ®_result_idx, NULL, &err); if (ret < 0) { + error_report_err(err); return -1; } =20 @@ -2815,11 +2826,11 @@ static ssize_t qio_channel_rdma_writev(QIOChannel *= ioc, head.len =3D len; head.type =3D RDMA_CONTROL_QEMU_FILE; =20 - ret =3D qemu_rdma_exchange_send(rdma, &head, data, NULL, NULL,= NULL); + ret =3D qemu_rdma_exchange_send(rdma, &head, + data, NULL, NULL, NULL, errp); =20 if (ret < 0) { rdma->errored =3D true; - error_setg(errp, "qemu_rdma_exchange_send failed"); return -1; } =20 @@ -3886,6 +3897,7 @@ static int qemu_rdma_registration_stop(QEMUFile *f, uint64_t flags, void *data) { QIOChannelRDMA *rioc =3D QIO_CHANNEL_RDMA(qemu_file_get_ioc(f)); + Error *err =3D NULL; RDMAContext *rdma; RDMAControlHeader head =3D { .len =3D 0, .repeat =3D 1 }; int ret; @@ -3929,9 +3941,10 @@ static int qemu_rdma_registration_stop(QEMUFile *f, */ ret =3D qemu_rdma_exchange_send(rdma, &head, NULL, &resp, ®_result_idx, rdma->pin_all ? - qemu_rdma_reg_whole_ram_blocks : NULL); + qemu_rdma_reg_whole_ram_blocks : NULL, + &err); if (ret < 0) { - fprintf(stderr, "receiving remote info!"); + error_report_err(err); return -1; } =20 @@ -3982,9 +3995,10 @@ static int qemu_rdma_registration_stop(QEMUFile *f, trace_qemu_rdma_registration_stop(flags); =20 head.type =3D RDMA_CONTROL_REGISTER_FINISHED; - ret =3D qemu_rdma_exchange_send(rdma, &head, NULL, NULL, NULL, NULL); + ret =3D qemu_rdma_exchange_send(rdma, &head, NULL, NULL, NULL, NULL, &= err); =20 if (ret < 0) { + error_report_err(err); goto err; } =20 --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048228; cv=none; d=zohomail.com; s=zohoarc; b=BFN+a7yMoTOr+Q+6LrjgaBcUCu1bGa8I9wQeorxv2i6jDbiHLwJnfZQxDtSfnCiuOX+irU3EV0zeBxvei1uq0+BARGd18PSdCU8GVGO/r2fspXMvC99yQAYPXf4Z3TfDtwPfvaLFweLh3l7kIrxCeUro1pFdUEBqKkg632LH/Ao= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048228; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zTd0nFuSXMi15aFG04AQzwAjGWlgaSRd4zJUd/YPLiU=; b=PfFxKvrTiry1CqHx5baU+YvTNE2VVqjX2+fVcuDqKbxYvNIrwO4F4Jb7GbrgqmJftKjVXOsYnQ9fTe0cgAg/rKiYY36i8oW02wDJqfVk7N4NEqIuBx4mKm48BuMuBNUYnopkbwL6q8Y4cCqnTrXkYNDYWOSaMmHPgrSHrHFNiK8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048228552164.31099172131223; Mon, 18 Sep 2023 07:43:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFSw-0003D3-N1; Mon, 18 Sep 2023 10:43:10 -0400 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 1qiFSN-0002yG-Gc for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS2-0002bZ-Qk for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:35 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-346-qkXjfjVnPrKFK7jXarm_lA-1; Mon, 18 Sep 2023 10:42:11 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 58204185A79B for ; Mon, 18 Sep 2023 14:42:11 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 17D1C492B16 for ; Mon, 18 Sep 2023 14:42:11 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5150A21E6898; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048133; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zTd0nFuSXMi15aFG04AQzwAjGWlgaSRd4zJUd/YPLiU=; b=MSh5YJruHKamQ7XkIZ46rZo7Ojn6rVHnw8uGA/uSATCJwL2xAKIqhAlXAMr7z5kAsTKgEb 6XM7NESorHl4KslUiEiiI/uRYk5/Z36UFu2Rcg3zXdZeeYiLgOkoPAZsfI4hzr6vK9A1N9 jiqH3+1gAWxEfxK+tgM80RrLR+P1uTc= X-MC-Unique: qkXjfjVnPrKFK7jXarm_lA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 36/52] migration/rdma: Convert qemu_rdma_exchange_get_response() to Error Date: Mon, 18 Sep 2023 16:41:50 +0200 Message-ID: <20230918144206.560120-37-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048228967100005 Content-Type: text/plain; charset="utf-8" Functions that use an Error **errp parameter to return errors should not also report them to the user, because reporting is the caller's job. When the caller does, the error is reported twice. When it doesn't (because it recovered from the error), there is no error to report, i.e. the report is bogus. qemu_rdma_exchange_send() and qemu_rdma_exchange_recv() violate this principle: they call error_report() via qemu_rdma_exchange_get_response(). I elected not to investigate how callers handle the error, i.e. precise impact is not known. Clean this up by converting qemu_rdma_exchange_get_response() to Error. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian --- migration/rdma.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index c1bfc20824..34f05dd541 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1803,14 +1803,15 @@ static int qemu_rdma_post_recv_control(RDMAContext = *rdma, int idx) * Block and wait for a RECV control channel message to arrive. */ static int qemu_rdma_exchange_get_response(RDMAContext *rdma, - RDMAControlHeader *head, uint32_t expecting, int idx) + RDMAControlHeader *head, uint32_t expecting, int idx, + Error **errp) { uint32_t byte_len; int ret =3D qemu_rdma_block_for_wrid(rdma, RDMA_WRID_RECV_CONTROL + id= x, &byte_len); =20 if (ret < 0) { - error_report("rdma migration: recv polling control error!"); + error_setg(errp, "rdma migration: recv polling control error!"); return -1; } =20 @@ -1823,7 +1824,7 @@ static int qemu_rdma_exchange_get_response(RDMAContex= t *rdma, trace_qemu_rdma_exchange_get_response_none(control_desc(head->type= ), head->type); } else if (head->type !=3D expecting || head->type =3D=3D RDMA_CONTROL= _ERROR) { - error_report("Was expecting a %s (%d) control message" + error_setg(errp, "Was expecting a %s (%d) control message" ", but got: %s (%d), length: %d", control_desc(expecting), expecting, control_desc(head->type), head->type, head->len); @@ -1833,11 +1834,12 @@ static int qemu_rdma_exchange_get_response(RDMACont= ext *rdma, return -1; } if (head->len > RDMA_CONTROL_MAX_BUFFER - sizeof(*head)) { - error_report("too long length: %d", head->len); + error_setg(errp, "too long length: %d", head->len); return -1; } if (sizeof(*head) + head->len !=3D byte_len) { - error_report("Malformed length: %d byte_len %d", head->len, byte_l= en); + error_setg(errp, "Malformed length: %d byte_len %d", + head->len, byte_len); return -1; } =20 @@ -1887,10 +1889,10 @@ static int qemu_rdma_exchange_send(RDMAContext *rdm= a, RDMAControlHeader *head, */ if (rdma->control_ready_expected) { RDMAControlHeader resp; - ret =3D qemu_rdma_exchange_get_response(rdma, - &resp, RDMA_CONTROL_READY, RDMA_WRID_R= EADY); + ret =3D qemu_rdma_exchange_get_response(rdma, &resp, + RDMA_CONTROL_READY, + RDMA_WRID_READY, errp); if (ret < 0) { - error_setg(errp, "FIXME temporary error message"); return -1; } } @@ -1941,10 +1943,10 @@ static int qemu_rdma_exchange_send(RDMAContext *rdm= a, RDMAControlHeader *head, =20 trace_qemu_rdma_exchange_send_waiting(control_desc(resp->type)); ret =3D qemu_rdma_exchange_get_response(rdma, resp, - resp->type, RDMA_WRID_DATA); + resp->type, RDMA_WRID_DATA, + errp); =20 if (ret < 0) { - error_setg(errp, "FIXME temporary error message"); return -1; } =20 @@ -1988,10 +1990,9 @@ static int qemu_rdma_exchange_recv(RDMAContext *rdma= , RDMAControlHeader *head, * Block and wait for the message. */ ret =3D qemu_rdma_exchange_get_response(rdma, head, - expecting, RDMA_WRID_READY); + expecting, RDMA_WRID_READY, errp= ); =20 if (ret < 0) { - error_setg(errp, "FIXME temporary error message"); return -1; } =20 --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048213; cv=none; d=zohomail.com; s=zohoarc; b=PdJ+jRyOVv7t9gEo1z98S9vyLdUNIcCHc1lO+Ibth+6iqR7u+Y9Bdq4BA9e1FOSX0QhikXt9owWCRDsX6o3YICK2/MquMentZzhWYKUVL6DPRW3UhE0sGmpRjMFXUNqpdyXYBpSc2Q5BobnJKRgTTZpjnEMiMeSdEd+NzVgwhvo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048213; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7MApSIXztGIM+tcru6Og1yrkSbHciTo3hLqnYsgHxO8=; b=RwlVy/1g/ILk4O6PynteWIo1vkLoryFz3YH0OFhg2nrTw9cvGHEiW642c8jH+p4s3HC181PGTK7U833Jv4TdP4kpNqx3DUVVFb9Hg55AQ3MsYd+ZIEoUs6w+++I3GTmBiJJwhLlUkrkPSilARMFWNaSadI9WRu4I0LD7mUlAy3Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048213120653.2726531092177; Mon, 18 Sep 2023 07:43:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFSl-00039H-LW; Mon, 18 Sep 2023 10:43:01 -0400 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 1qiFSI-0002wO-UJ for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS2-0002c1-Lt for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:30 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-44-OoM7SdsZPk21N8YS5IDgow-1; Mon, 18 Sep 2023 10:42:11 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3D4703800BA2 for ; Mon, 18 Sep 2023 14:42:11 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1A64549BB9A for ; Mon, 18 Sep 2023 14:42:11 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5425821E6899; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048133; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7MApSIXztGIM+tcru6Og1yrkSbHciTo3hLqnYsgHxO8=; b=GudNxwaocXXlGb72oyFetX11dJqfKfajkdRur8PDSqF/xLu1Wrb4txvIGgdE39/Oca5m6y U81iZmTpBy5/fEv9BZrLLwFTXj+Ji2b5+uUxzxHPULFUFpTc0ujt3wWnRIrg1hX4IIAYwx R95+l9hgqWJHfrkAP+LnMfRrhB0X0c8= X-MC-Unique: OoM7SdsZPk21N8YS5IDgow-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 37/52] migration/rdma: Convert qemu_rdma_reg_whole_ram_blocks() to Error Date: Mon, 18 Sep 2023 16:41:51 +0200 Message-ID: <20230918144206.560120-38-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048213998100004 Content-Type: text/plain; charset="utf-8" Functions that use an Error **errp parameter to return errors should not also report them to the user, because reporting is the caller's job. When the caller does, the error is reported twice. When it doesn't (because it recovered from the error), there is no error to report, i.e. the report is bogus. qemu_rdma_exchange_send() violates this principle: it calls error_report() via callback qemu_rdma_reg_whole_ram_blocks(). I elected not to investigate how callers handle the error, i.e. precise impact is not known. Clean this up by converting the callback to Error. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian --- migration/rdma.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 34f05dd541..f1cd659a1f 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -518,7 +518,8 @@ static void network_to_result(RDMARegisterResult *resul= t) static int qemu_rdma_exchange_send(RDMAContext *rdma, RDMAControlHeader *h= ead, uint8_t *data, RDMAControlHeader *resp, int *resp_idx, - int (*callback)(RDMAContext *rdma), + int (*callback)(RDMAContext *rdma, + Error **errp), Error **errp); =20 static inline uint64_t ram_chunk_index(const uint8_t *start, @@ -1175,7 +1176,7 @@ static void qemu_rdma_advise_prefetch_mr(struct ibv_p= d *pd, uint64_t addr, #endif } =20 -static int qemu_rdma_reg_whole_ram_blocks(RDMAContext *rdma) +static int qemu_rdma_reg_whole_ram_blocks(RDMAContext *rdma, Error **errp) { int i; RDMALocalBlocks *local =3D &rdma->local_ram_blocks; @@ -1210,16 +1211,16 @@ static int qemu_rdma_reg_whole_ram_blocks(RDMAConte= xt *rdma) } =20 if (!local->block[i].mr) { - perror("Failed to register local dest ram block!"); - break; + error_setg_errno(errp, errno, + "Failed to register local dest ram block!"); + goto err; } rdma->total_registrations++; } =20 - if (i >=3D local->nb_blocks) { - return 0; - } + return 0; =20 +err: for (i--; i >=3D 0; i--) { ibv_dereg_mr(local->block[i].mr); local->block[i].mr =3D NULL; @@ -1878,7 +1879,8 @@ static void qemu_rdma_move_header(RDMAContext *rdma, = int idx, static int qemu_rdma_exchange_send(RDMAContext *rdma, RDMAControlHeader *h= ead, uint8_t *data, RDMAControlHeader *resp, int *resp_idx, - int (*callback)(RDMAContext *rdma), + int (*callback)(RDMAContext *rdma, + Error **errp), Error **errp) { int ret; @@ -1934,9 +1936,8 @@ static int qemu_rdma_exchange_send(RDMAContext *rdma,= RDMAControlHeader *head, if (resp) { if (callback) { trace_qemu_rdma_exchange_send_issue_callback(); - ret =3D callback(rdma); + ret =3D callback(rdma, errp); if (ret < 0) { - error_setg(errp, "FIXME temporary error message"); return -1; } } @@ -3633,10 +3634,9 @@ static int qemu_rdma_registration_handle(QEMUFile *f) } =20 if (rdma->pin_all) { - ret =3D qemu_rdma_reg_whole_ram_blocks(rdma); + ret =3D qemu_rdma_reg_whole_ram_blocks(rdma, &err); if (ret < 0) { - error_report("rdma migration: error dest " - "registering ram blocks"); + error_report_err(err); goto err; } } --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048326; cv=none; d=zohomail.com; s=zohoarc; b=S3CJJXp3LfuiyI9Sn75l8EL/Om97umUL/h/IJoOJrKp/mx7A6FystFgE+tZrNpJWZG1NzM/M+4vAhEwN8o5NiPv608THKmutB0nRNFMyqG0PK23+UeEUfvMvuxJdrtKTR9llFbES9iQDlSGSWjGofD1ll+xLhOtWW8eseN+JC6M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048326; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BL9WYdXxTscBZywRpqYSAaoVP+1Fl8ztB8ed+TAoURg=; b=acD25uoT/zfNrNOhgeP+Dm1dw759YhxhproxcDT6bCTZOe1ExBR07ASYggflkl6ZYjwhRJwH5Lw2oF/41zgPHL/6RTbHF6Cy8vDGBSO8H++5MrpxxEtKYgD0XCzpf9hLPOsl+vGXd8wMtG3OMsK9Lef2IZPZkQuMwbKEPe6+7yU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048326841633.8789897702497; Mon, 18 Sep 2023 07:45:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFTK-0003xi-C8; Mon, 18 Sep 2023 10:43:34 -0400 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 1qiFSP-000322-N0 for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS2-0002bm-JZ for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:37 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-44-3bQHLdr5NW2a03fj9rz65g-1; Mon, 18 Sep 2023 10:42:11 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3BCDA3800BA1 for ; Mon, 18 Sep 2023 14:42:11 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 18E744011E4 for ; Mon, 18 Sep 2023 14:42:11 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 570FF21E689A; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048133; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BL9WYdXxTscBZywRpqYSAaoVP+1Fl8ztB8ed+TAoURg=; b=OJAd/sT/wJlNSXF4Yo9vBkRpb0R8n+wHJhic0prW9ElN1MSSBSFMqfMIsDfCI+3PEHzsyf uLIl5PCxBenPvNWDsDFDK7STQ35PvaxFcE2w5ibq1EsIR/xdIDRWariS+tnCZ91TCiy72d FOO1KvHuQhfTJb2/k9AfRbeWWrYtrxo= X-MC-Unique: 3bQHLdr5NW2a03fj9rz65g-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 38/52] migration/rdma: Convert qemu_rdma_write_flush() to Error Date: Mon, 18 Sep 2023 16:41:52 +0200 Message-ID: <20230918144206.560120-39-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048327368100003 Content-Type: text/plain; charset="utf-8" Functions that use an Error **errp parameter to return errors should not also report them to the user, because reporting is the caller's job. When the caller does, the error is reported twice. When it doesn't (because it recovered from the error), there is no error to report, i.e. the report is bogus. qio_channel_rdma_writev() violates this principle: it calls error_report() via qemu_rdma_write_flush(). I elected not to investigate how callers handle the error, i.e. precise impact is not known. Clean this up by converting qemu_rdma_write_flush() to Error. Necessitates setting an error when qemu_rdma_write_one() failed. Since this error will go away later in this series, simply use "FIXME temporary error message" there. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian --- migration/rdma.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index f1cd659a1f..c3c33fe242 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -2238,7 +2238,8 @@ retry: * We support sending out multiple chunks at the same time. * Not all of them need to get signaled in the completion queue. */ -static int qemu_rdma_write_flush(QEMUFile *f, RDMAContext *rdma) +static int qemu_rdma_write_flush(QEMUFile *f, RDMAContext *rdma, + Error **errp) { int ret; =20 @@ -2250,6 +2251,7 @@ static int qemu_rdma_write_flush(QEMUFile *f, RDMACon= text *rdma) rdma->current_index, rdma->current_addr, rdma->current_length); =20 if (ret < 0) { + error_setg(errp, "FIXME temporary error message"); return -1; } =20 @@ -2323,6 +2325,7 @@ static int qemu_rdma_write(QEMUFile *f, RDMAContext *= rdma, uint64_t block_offset, uint64_t offset, uint64_t len) { + Error *err =3D NULL; uint64_t current_addr =3D block_offset + offset; uint64_t index =3D rdma->current_index; uint64_t chunk =3D rdma->current_chunk; @@ -2330,8 +2333,9 @@ static int qemu_rdma_write(QEMUFile *f, RDMAContext *= rdma, =20 /* If we cannot merge it, we flush the current buffer first. */ if (!qemu_rdma_buffer_mergable(rdma, current_addr, len)) { - ret =3D qemu_rdma_write_flush(f, rdma); + ret =3D qemu_rdma_write_flush(f, rdma, &err); if (ret < 0) { + error_report_err(err); return -1; } rdma->current_length =3D 0; @@ -2348,7 +2352,10 @@ static int qemu_rdma_write(QEMUFile *f, RDMAContext = *rdma, =20 /* flush it if buffer is too large */ if (rdma->current_length >=3D RDMA_MERGE_MAX) { - return qemu_rdma_write_flush(f, rdma); + if (qemu_rdma_write_flush(f, rdma, &err) < 0) { + error_report_err(err); + return -1; + } } =20 return 0; @@ -2809,10 +2816,9 @@ static ssize_t qio_channel_rdma_writev(QIOChannel *i= oc, * Push out any writes that * we're queued up for VM's ram. */ - ret =3D qemu_rdma_write_flush(f, rdma); + ret =3D qemu_rdma_write_flush(f, rdma, errp); if (ret < 0) { rdma->errored =3D true; - error_setg(errp, "qemu_rdma_write_flush failed"); return -1; } =20 @@ -2954,9 +2960,11 @@ static ssize_t qio_channel_rdma_readv(QIOChannel *io= c, */ static int qemu_rdma_drain_cq(QEMUFile *f, RDMAContext *rdma) { + Error *err =3D NULL; int ret; =20 - if (qemu_rdma_write_flush(f, rdma) < 0) { + if (qemu_rdma_write_flush(f, rdma, &err) < 0) { + error_report_err(err); return -1; } =20 --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048754; cv=none; d=zohomail.com; s=zohoarc; b=Kbk8Y4fvt8hKVeng/mgrUhiHyUTCWzh1U48WQU4LTg/VwuuZqynLqLrl63nLAHuSr3ulccduOzubGaYyyEN60mRllVQo0DwcyAiY7h2EOSGwwWgDp8tExMGlGH96sOhWAgvBzoBbxywUHeeuwnhy/vtndZtNNYam4U94ArUcQv0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048754; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rZZEVEpp7qTVI0/l9SeWztvjOBzkaHnlyrpbosDXOuo=; b=bENuk1iQ2VVX9iM9J0iePQ8SORrKH+aHu70yTiI9lqDMlXzjc2i7V7LDOEzgJLNxQQDSM9q0vAu4tznhu4LI8KDYxzfZglOZS3EmDQKA4k8VfxeMB6+cBoWS/xrKUp/SKR0CcY2oIktQoc+Kf3VbXlEYDzKGW0hA1svGY+FU3V0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048754276974.152878815015; Mon, 18 Sep 2023 07:52:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFSU-00035I-4E; Mon, 18 Sep 2023 10:42:42 -0400 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 1qiFSN-0002yJ-IO for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS2-0002bq-PY for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:34 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-435-8CjOMPGaNJqVlTvdd1UajQ-1; Mon, 18 Sep 2023 10:42:11 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5814A3800BAB for ; Mon, 18 Sep 2023 14:42:11 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1A329140E953 for ; Mon, 18 Sep 2023 14:42:11 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 59E0021E689B; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048133; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rZZEVEpp7qTVI0/l9SeWztvjOBzkaHnlyrpbosDXOuo=; b=JGJAcFy7f7m55ULdFyu8cF0gPjxO2nNLhU4imvHLd2YUSPi7rjIPC1avJVK938wCKFr5Zo R2Ecj5F4/sx3+Ss2qHoa0xCSlw2/8j93nh1sIbQ9Ng+TNWz0jQAw83ea9WB/p/25hmqbTj H/4ad+jgQhAgSHK7Uq13oUYS+z6LnZQ= X-MC-Unique: 8CjOMPGaNJqVlTvdd1UajQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 39/52] migration/rdma: Convert qemu_rdma_write_one() to Error Date: Mon, 18 Sep 2023 16:41:53 +0200 Message-ID: <20230918144206.560120-40-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048755582100003 Content-Type: text/plain; charset="utf-8" Functions that use an Error **errp parameter to return errors should not also report them to the user, because reporting is the caller's job. When the caller does, the error is reported twice. When it doesn't (because it recovered from the error), there is no error to report, i.e. the report is bogus. qemu_rdma_write_flush() violates this principle: it calls error_report() via qemu_rdma_write_one(). I elected not to investigate how callers handle the error, i.e. precise impact is not known. Clean this up by converting qemu_rdma_write_one() to Error. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian --- migration/rdma.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index c3c33fe242..9b8cbadfcd 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -2019,9 +2019,8 @@ static int qemu_rdma_exchange_recv(RDMAContext *rdma,= RDMAControlHeader *head, */ static int qemu_rdma_write_one(QEMUFile *f, RDMAContext *rdma, int current_index, uint64_t current_addr, - uint64_t length) + uint64_t length, Error **errp) { - Error *err =3D NULL; struct ibv_sge sge; struct ibv_send_wr send_wr =3D { 0 }; struct ibv_send_wr *bad_wr; @@ -2075,7 +2074,7 @@ retry: ret =3D qemu_rdma_block_for_wrid(rdma, RDMA_WRID_RDMA_WRITE, NULL); =20 if (ret < 0) { - error_report("Failed to Wait for previous write to complete " + error_setg(errp, "Failed to Wait for previous write to complet= e " "block %d chunk %" PRIu64 " current %" PRIu64 " len %" PRIu64 " %d", current_index, chunk, sge.addr, length, rdma->nb_sent); @@ -2107,10 +2106,9 @@ retry: =20 compress_to_network(rdma, &comp); ret =3D qemu_rdma_exchange_send(rdma, &head, - (uint8_t *) &comp, NULL, NULL, NULL, &err); + (uint8_t *) &comp, NULL, NULL, NULL, errp); =20 if (ret < 0) { - error_report_err(err); return -1; } =20 @@ -2136,9 +2134,8 @@ retry: =20 register_to_network(rdma, ®); ret =3D qemu_rdma_exchange_send(rdma, &head, (uint8_t *) ®, - &resp, ®_result_idx, NULL, &err); + &resp, ®_result_idx, NULL, errp); if (ret < 0) { - error_report_err(err); return -1; } =20 @@ -2146,7 +2143,7 @@ retry: if (qemu_rdma_register_and_get_keys(rdma, block, sge.addr, &sge.lkey, NULL, chunk, chunk_start, chunk_end)) { - error_report("cannot get lkey"); + error_setg(errp, "cannot get lkey"); return -1; } =20 @@ -2165,7 +2162,7 @@ retry: if (qemu_rdma_register_and_get_keys(rdma, block, sge.addr, &sge.lkey, NULL, chunk, chunk_start, chunk_end)) { - error_report("cannot get lkey!"); + error_setg(errp, "cannot get lkey!"); return -1; } } @@ -2177,7 +2174,7 @@ retry: if (qemu_rdma_register_and_get_keys(rdma, block, sge.addr, &sge.lkey, NULL, chun= k, chunk_start, chunk_en= d)) { - error_report("cannot get lkey!"); + error_setg(errp, "cannot get lkey!"); return -1; } } @@ -2211,7 +2208,7 @@ retry: trace_qemu_rdma_write_one_queue_full(); ret =3D qemu_rdma_block_for_wrid(rdma, RDMA_WRID_RDMA_WRITE, NULL); if (ret < 0) { - error_report("rdma migration: failed to make " + error_setg(errp, "rdma migration: failed to make " "room in full send queue!"); return -1; } @@ -2219,7 +2216,7 @@ retry: goto retry; =20 } else if (ret > 0) { - perror("rdma migration: post rdma write failed"); + error_setg(errp, "rdma migration: post rdma write failed"); return -1; } =20 @@ -2248,10 +2245,10 @@ static int qemu_rdma_write_flush(QEMUFile *f, RDMAC= ontext *rdma, } =20 ret =3D qemu_rdma_write_one(f, rdma, - rdma->current_index, rdma->current_addr, rdma->current_length); + rdma->current_index, rdma->current_addr, rdma->current_length, + errp); =20 if (ret < 0) { - error_setg(errp, "FIXME temporary error message"); return -1; } =20 --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048346; cv=none; d=zohomail.com; s=zohoarc; b=VinQQDuvZntG78+bckeTYLCgPurDfd1DCGt2XZsgoFmPwFryU6Z653uC8ovnAKCEGaCFB1/ff+8SXL/wBWCU489ayP3Q6LGv0iu3seSq3SE8a3aUhi07lV7mQe8hU9sTxahl8BVa1h9qlc3nSmM0W00IImc+FeaJeGVL7HEx0qQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048346; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YeBT8Hn8XJQ6c1Y79NelGYSFYQUD6nVYE8uS3ifobCE=; b=U4EF6sh8rwlvnVR6EzABdFG2fGCFNmkATlaVVaCNp23fwJC2RWMx7XyUPXad+O8tPfv6FRLFYUW45YFnY+EAUXr3y6IBPPYM/4CoQcM6GUKBpp0XZsgkDX4uXTdzEkDmaXj30IEDiioZ98UKtphOmyQmgmyA08a8rPQnJc7/RD8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048346145352.60836068244976; Mon, 18 Sep 2023 07:45:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFSo-0003Af-O6; Mon, 18 Sep 2023 10:43:05 -0400 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 1qiFSJ-0002wp-QU for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS2-0002c3-MX for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:31 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-551-RlD1gWOHM5eeBopOOxGVEQ-1; Mon, 18 Sep 2023 10:42:11 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 468913800BA4 for ; Mon, 18 Sep 2023 14:42:11 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 247CE40C2064 for ; Mon, 18 Sep 2023 14:42:11 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5CB1F21E689C; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048133; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YeBT8Hn8XJQ6c1Y79NelGYSFYQUD6nVYE8uS3ifobCE=; b=hneHU3+wS1wcbku/rhxwTqOoTML0owKhvmzb+RSWMlU1viP2MJ7YFJh5ca/XEuMqKvYTE1 a2ImfShFcoYUyDGMErOhAbI/qkADti4SuUhlH2KbTtZOavxKUd9j5I0+2h9DOvTnUI3O4v lzlpoEv1ZV3k9OA9mXmsGl+Gs8YUmkw= X-MC-Unique: RlD1gWOHM5eeBopOOxGVEQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 40/52] migration/rdma: Convert qemu_rdma_write() to Error Date: Mon, 18 Sep 2023 16:41:54 +0200 Message-ID: <20230918144206.560120-41-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048348466100003 Content-Type: text/plain; charset="utf-8" Just for consistency with qemu_rdma_write_one() and qemu_rdma_write_flush(), and for slightly simpler code. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian --- migration/rdma.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 9b8cbadfcd..5bb78a6ad8 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -2320,9 +2320,8 @@ static inline bool qemu_rdma_buffer_mergable(RDMACont= ext *rdma, */ static int qemu_rdma_write(QEMUFile *f, RDMAContext *rdma, uint64_t block_offset, uint64_t offset, - uint64_t len) + uint64_t len, Error **errp) { - Error *err =3D NULL; uint64_t current_addr =3D block_offset + offset; uint64_t index =3D rdma->current_index; uint64_t chunk =3D rdma->current_chunk; @@ -2330,9 +2329,8 @@ static int qemu_rdma_write(QEMUFile *f, RDMAContext *= rdma, =20 /* If we cannot merge it, we flush the current buffer first. */ if (!qemu_rdma_buffer_mergable(rdma, current_addr, len)) { - ret =3D qemu_rdma_write_flush(f, rdma, &err); + ret =3D qemu_rdma_write_flush(f, rdma, errp); if (ret < 0) { - error_report_err(err); return -1; } rdma->current_length =3D 0; @@ -2349,10 +2347,7 @@ static int qemu_rdma_write(QEMUFile *f, RDMAContext = *rdma, =20 /* flush it if buffer is too large */ if (rdma->current_length >=3D RDMA_MERGE_MAX) { - if (qemu_rdma_write_flush(f, rdma, &err) < 0) { - error_report_err(err); - return -1; - } + return qemu_rdma_write_flush(f, rdma, errp); } =20 return 0; @@ -3248,6 +3243,7 @@ static size_t qemu_rdma_save_page(QEMUFile *f, size_t size, uint64_t *bytes_sent) { QIOChannelRDMA *rioc =3D QIO_CHANNEL_RDMA(qemu_file_get_ioc(f)); + Error *err =3D NULL; RDMAContext *rdma; int ret; =20 @@ -3273,9 +3269,9 @@ static size_t qemu_rdma_save_page(QEMUFile *f, * is full, or the page doesn't belong to the current chunk, * an actual RDMA write will occur and a new chunk will be formed. */ - ret =3D qemu_rdma_write(f, rdma, block_offset, offset, size); + ret =3D qemu_rdma_write(f, rdma, block_offset, offset, size, &err); if (ret < 0) { - error_report("rdma migration: write error"); + error_report_err(err); goto err; } =20 --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048259; cv=none; d=zohomail.com; s=zohoarc; b=j4cn/KvB7Sf9TTTz6UOZYs9TWfUVKl8XERXCqY+S5GlXEA0CkcTR2OcfhXi5KPNyd1HJimlkktDMAZkDfMwt9L9zjNTRoVP1p3OshPHsAr2RZ/1KgtsB+zXRBVW/FcsCGjWob1BvAgk2gtTl3Q/F+Oi3az/CdVd+6KTmasVX/aQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048259; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gyIs05Vmg5052oN38M2vvAtrF7PzWB5DOCSy6J1aRl0=; b=ZxTFzFV5BO9Ssf+zE6FEMBEUEf+zBG2TMk8XIVrkjnvhA5Pg22CPh7NgVHl2dNTYbw2zAf+Icaqlveme+QQ3LKyTlDwSAoy3sWcCGXZiimeoadhEZ/mPuMMzGp3bN2C505OMUekzRCcytcLU8L77vDTIdBwUzONRZ0L9oq2H1ho= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048259078328.5163718968265; Mon, 18 Sep 2023 07:44:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFTE-0003Ji-3p; Mon, 18 Sep 2023 10:43:28 -0400 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 1qiFSN-0002y7-DT for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS2-0002cP-Pl for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:34 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-378-EKF7P39GN_SxDcX4Qis6Ng-1; Mon, 18 Sep 2023 10:42:12 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 681923800BB2 for ; Mon, 18 Sep 2023 14:42:11 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2A9C34021A9 for ; Mon, 18 Sep 2023 14:42:11 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5F96D21E689D; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048133; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gyIs05Vmg5052oN38M2vvAtrF7PzWB5DOCSy6J1aRl0=; b=huah6RHZcc7iAvy7vDlolnat1pgICprWuH4Q8KVX5I5Sld6N2zeseNwHA+cW/V0w8ypi0C /go9D47BW/MGsUQtW0L2GUhGFvIaVuLP8pio5ox5J1TIQe5qha0bZ1AJH3YHkrkD7qRrY/ wn9mAUppkpWdPE06RUHQvLTus9Xk3to= X-MC-Unique: EKF7P39GN_SxDcX4Qis6Ng-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 41/52] migration/rdma: Convert qemu_rdma_post_send_control() to Error Date: Mon, 18 Sep 2023 16:41:55 +0200 Message-ID: <20230918144206.560120-42-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048261160100003 Content-Type: text/plain; charset="utf-8" Functions that use an Error **errp parameter to return errors should not also report them to the user, because reporting is the caller's job. When the caller does, the error is reported twice. When it doesn't (because it recovered from the error), there is no error to report, i.e. the report is bogus. qemu_rdma_exchange_send() violates this principle: it calls error_report() via qemu_rdma_post_send_control(). I elected not to investigate how callers handle the error, i.e. precise impact is not known. Clean this up by converting qemu_rdma_post_send_control() to Error. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian --- migration/rdma.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 5bb78a6ad8..25caf67aac 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1720,7 +1720,8 @@ err_block_for_wrid: * containing some data and block until the post completes. */ static int qemu_rdma_post_send_control(RDMAContext *rdma, uint8_t *buf, - RDMAControlHeader *head) + RDMAControlHeader *head, + Error **errp) { int ret; RDMAWorkRequestData *wr =3D &rdma->wr_data[RDMA_WRID_CONTROL]; @@ -1760,13 +1761,13 @@ static int qemu_rdma_post_send_control(RDMAContext = *rdma, uint8_t *buf, ret =3D ibv_post_send(rdma->qp, &send_wr, &bad_wr); =20 if (ret > 0) { - error_report("Failed to use post IB SEND for control"); + error_setg(errp, "Failed to use post IB SEND for control"); return -1; } =20 ret =3D qemu_rdma_block_for_wrid(rdma, RDMA_WRID_SEND_CONTROL, NULL); if (ret < 0) { - error_report("rdma migration: send polling control error"); + error_setg(errp, "rdma migration: send polling control error"); return -1; } =20 @@ -1923,10 +1924,9 @@ static int qemu_rdma_exchange_send(RDMAContext *rdma= , RDMAControlHeader *head, /* * Deliver the control message that was requested. */ - ret =3D qemu_rdma_post_send_control(rdma, data, head); + ret =3D qemu_rdma_post_send_control(rdma, data, head, errp); =20 if (ret < 0) { - error_setg(errp, "Failed to send control buffer!"); return -1; } =20 @@ -1980,10 +1980,9 @@ static int qemu_rdma_exchange_recv(RDMAContext *rdma= , RDMAControlHeader *head, /* * Inform the source that we're ready to receive a message. */ - ret =3D qemu_rdma_post_send_control(rdma, NULL, &ready); + ret =3D qemu_rdma_post_send_control(rdma, NULL, &ready, errp); =20 if (ret < 0) { - error_setg(errp, "Failed to send control buffer!"); return -1; } =20 @@ -2355,6 +2354,7 @@ static int qemu_rdma_write(QEMUFile *f, RDMAContext *= rdma, =20 static void qemu_rdma_cleanup(RDMAContext *rdma) { + Error *err =3D NULL; int idx; =20 if (rdma->cm_id && rdma->connected) { @@ -2366,7 +2366,9 @@ static void qemu_rdma_cleanup(RDMAContext *rdma) .repeat =3D 1, }; error_report("Early error. Sending error."); - qemu_rdma_post_send_control(rdma, NULL, &head); + if (qemu_rdma_post_send_control(rdma, NULL, &head, &err) < 0) { + error_report_err(err); + } } =20 rdma_disconnect(rdma->cm_id); @@ -3673,10 +3675,11 @@ static int qemu_rdma_registration_handle(QEMUFile *= f) =20 =20 ret =3D qemu_rdma_post_send_control(rdma, - (uint8_t *) rdma->dest_blocks, &bl= ocks); + (uint8_t *) rdma->dest_blocks, &blocks, + &err); =20 if (ret < 0) { - error_report("rdma migration: error sending remote info"); + error_report_err(err); goto err; } =20 @@ -3751,10 +3754,10 @@ static int qemu_rdma_registration_handle(QEMUFile *= f) } =20 ret =3D qemu_rdma_post_send_control(rdma, - (uint8_t *) results, ®_resp); + (uint8_t *) results, ®_resp, &err); =20 if (ret < 0) { - error_report("Failed to send control buffer"); + error_report_err(err); goto err; } break; @@ -3786,10 +3789,10 @@ static int qemu_rdma_registration_handle(QEMUFile *= f) reg->key.chunk); } =20 - ret =3D qemu_rdma_post_send_control(rdma, NULL, &unreg_resp); + ret =3D qemu_rdma_post_send_control(rdma, NULL, &unreg_resp, &= err); =20 if (ret < 0) { - error_report("Failed to send control buffer"); + error_report_err(err); goto err; } break; --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048397; cv=none; d=zohomail.com; s=zohoarc; b=SMo4gGAFl9BoTxwpghEyBS3aFHJaQj2CmmsELLoC2S0Fd3Z5afoN2UYp/DeAMDJGlb+0Y2dUIQl9N1Wx3t3Y82lw+ZetyX6pv5lAW9BDW0ht62g2qzKcWFiByX9Ck1Pz3xCtmfWsikcC/iW1PK1FuJ+SGSXzBxMNwx2gaQBzoCc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048397; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zejLdMwDMP+tVjE4lYej6MTtHi0RJ0bmWoM7imLV3NQ=; b=gsgG6q3VVOwjXVXtGu3Xxstryh2qNX7XJmYx1D/tJQfCbJveZ7H7V3bsfPB0B8W23jrZt6FJvWnIzDq9cKAsObf+LpmrbPSPb861aU96QMB7nrvOVVkEgmB00+eRq3hjV4z/uHwSER+NdmFjKRNOSP+m0ISFW/H4wv9ezbydzVs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048397535775.5212920582145; Mon, 18 Sep 2023 07:46:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFSW-00035n-5Z; Mon, 18 Sep 2023 10:42:44 -0400 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 1qiFSO-00031d-QA for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS2-0002bc-RN for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:36 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-553-7pzGYtcRP5qmiHE4is6orw-1; Mon, 18 Sep 2023 10:42:11 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 52CA6945920 for ; Mon, 18 Sep 2023 14:42:11 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 304CF4A9B13 for ; Mon, 18 Sep 2023 14:42:11 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 6259721E689E; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048133; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zejLdMwDMP+tVjE4lYej6MTtHi0RJ0bmWoM7imLV3NQ=; b=AUb7VLpHpmllcxG15wAOHk33HDjVXe2AAHWo93b1ops9Z+x2L5vndf/Y918djrL8CVKMwv 7YaySOxc2ylzNBx4tfatZiV6FTkuL/+TjJrnbzNHW7Es6lVHOJQmAJAAIFeKCaONl/Lzk9 UtKxOi8ObsKAV7k7GxCPZX8luXLNyb8= X-MC-Unique: 7pzGYtcRP5qmiHE4is6orw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 42/52] migration/rdma: Convert qemu_rdma_post_recv_control() to Error Date: Mon, 18 Sep 2023 16:41:56 +0200 Message-ID: <20230918144206.560120-43-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 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=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048399319100001 Content-Type: text/plain; charset="utf-8" Just for symmetry with qemu_rdma_post_send_control(). Error messages lose detail I consider of no use to users. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian --- migration/rdma.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 25caf67aac..a727aa35d1 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1778,7 +1778,8 @@ static int qemu_rdma_post_send_control(RDMAContext *r= dma, uint8_t *buf, * Post a RECV work request in anticipation of some future receipt * of data on the control channel. */ -static int qemu_rdma_post_recv_control(RDMAContext *rdma, int idx) +static int qemu_rdma_post_recv_control(RDMAContext *rdma, int idx, + Error **errp) { struct ibv_recv_wr *bad_wr; struct ibv_sge sge =3D { @@ -1795,6 +1796,7 @@ static int qemu_rdma_post_recv_control(RDMAContext *r= dma, int idx) =20 =20 if (ibv_post_recv(rdma->qp, &recv_wr, &bad_wr)) { + error_setg(errp, "error posting control recv"); return -1; } =20 @@ -1904,10 +1906,8 @@ static int qemu_rdma_exchange_send(RDMAContext *rdma= , RDMAControlHeader *head, * If the user is expecting a response, post a WR in anticipation of i= t. */ if (resp) { - ret =3D qemu_rdma_post_recv_control(rdma, RDMA_WRID_DATA); + ret =3D qemu_rdma_post_recv_control(rdma, RDMA_WRID_DATA, errp); if (ret < 0) { - error_setg(errp, "rdma migration: error posting" - " extra control recv for anticipated result!"); return -1; } } @@ -1915,9 +1915,8 @@ static int qemu_rdma_exchange_send(RDMAContext *rdma,= RDMAControlHeader *head, /* * Post a WR to replace the one we just consumed for the READY message. */ - ret =3D qemu_rdma_post_recv_control(rdma, RDMA_WRID_READY); + ret =3D qemu_rdma_post_recv_control(rdma, RDMA_WRID_READY, errp); if (ret < 0) { - error_setg(errp, "rdma migration: error posting first control recv= !"); return -1; } =20 @@ -2001,9 +2000,8 @@ static int qemu_rdma_exchange_recv(RDMAContext *rdma,= RDMAControlHeader *head, /* * Post a new RECV work request to replace the one we just consumed. */ - ret =3D qemu_rdma_post_recv_control(rdma, RDMA_WRID_READY); + ret =3D qemu_rdma_post_recv_control(rdma, RDMA_WRID_READY, errp); if (ret < 0) { - error_setg(errp, "rdma migration: error posting second control rec= v!"); return -1; } =20 @@ -2569,9 +2567,8 @@ static int qemu_rdma_connect(RDMAContext *rdma, bool = return_path, =20 caps_to_network(&cap); =20 - ret =3D qemu_rdma_post_recv_control(rdma, RDMA_WRID_READY); + ret =3D qemu_rdma_post_recv_control(rdma, RDMA_WRID_READY, errp); if (ret < 0) { - error_setg(errp, "RDMA ERROR: posting second control recv"); goto err_rdma_source_connect; } =20 @@ -3370,6 +3367,7 @@ static void rdma_cm_poll_handler(void *opaque) =20 static int qemu_rdma_accept(RDMAContext *rdma) { + Error *err =3D NULL; RDMACapabilities cap; struct rdma_conn_param conn_param =3D { .responder_resources =3D 2, @@ -3506,9 +3504,9 @@ static int qemu_rdma_accept(RDMAContext *rdma) rdma_ack_cm_event(cm_event); rdma->connected =3D true; =20 - ret =3D qemu_rdma_post_recv_control(rdma, RDMA_WRID_READY); + ret =3D qemu_rdma_post_recv_control(rdma, RDMA_WRID_READY, &err); if (ret < 0) { - error_report("rdma migration: error posting second control recv"); + error_report_err(err); goto err_rdma_dest_wait; } =20 --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048443; cv=none; d=zohomail.com; s=zohoarc; b=Na1fnQxqGdSoi2rI93xXw+G4xOPxtIZgbFkSXpOWqc/b+DwahbICuIb1eXi3mQZV/QeNF9udINzO+pbjToEVixogSX/5Yav0FG44dkOD1/2S7c7DFXToh6GsSsxu/ds1a1I7LMdulz1+GdtNnoOhtuHX6b8MfM8Rm9MJIp4RsWM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048443; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YI/OMHLXFF4aXnulbCN0A1lX7JYLV9NOHEBehNJYtCM=; b=PXIvRLSLDVN01ST6dINdHX/cQ0o/8hWaukYPPVkXYWyyOwKAnCq5g4zx3ovrgWqM3EvF2NIF1eQKN30/N06cgJwnp8tyiYxk8BWOAkIQBclSEVtFbwsCtsz4uZJ1Eb+AcE2EOExpBnDevXvtmi+kzWDzBbrBm4GXVs2cA6X84Qw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169504844380864.73796967548242; Mon, 18 Sep 2023 07:47:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFSQ-00032x-LJ; Mon, 18 Sep 2023 10:42:38 -0400 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 1qiFSN-0002yI-Gk for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS2-0002ch-O5 for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:33 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-561-JW1Sz2MpNHWlyFZQ7QG9iA-1; Mon, 18 Sep 2023 10:42:12 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7C2C53800BA6 for ; Mon, 18 Sep 2023 14:42:11 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3EB7C40C6EA8 for ; Mon, 18 Sep 2023 14:42:11 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 6547F21E689F; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048134; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YI/OMHLXFF4aXnulbCN0A1lX7JYLV9NOHEBehNJYtCM=; b=NtmLMFhYKXITGJQOBWae5iqjizfXvk9h5Xzgb0ByZs9chvzcaM81UgOe8a4tmCfvINCO2I jWC1YNNHl10A3SexCqq5V14ViY+lm2Wa6M0QecMyHt2et7CuTgA8n3X2vMHKEet4Hu0CZJ YdT9ubxn95jV563P+qYqeBMhfsvv890= X-MC-Unique: JW1Sz2MpNHWlyFZQ7QG9iA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 43/52] migration/rdma: Convert qemu_rdma_alloc_pd_cq() to Error Date: Mon, 18 Sep 2023 16:41:57 +0200 Message-ID: <20230918144206.560120-44-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048446032100007 Content-Type: text/plain; charset="utf-8" Functions that use an Error **errp parameter to return errors should not also report them to the user, because reporting is the caller's job. When the caller does, the error is reported twice. When it doesn't (because it recovered from the error), there is no error to report, i.e. the report is bogus. qemu_rdma_source_init() violates this principle: it calls error_report() via qemu_rdma_alloc_pd_cq(). I elected not to investigate how callers handle the error, i.e. precise impact is not known. Clean this up by converting qemu_rdma_alloc_pd_cq() to Error. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian --- migration/rdma.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index a727aa35d1..41f0ae4ddb 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1046,19 +1046,19 @@ err_resolve_create_id: /* * Create protection domain and completion queues */ -static int qemu_rdma_alloc_pd_cq(RDMAContext *rdma) +static int qemu_rdma_alloc_pd_cq(RDMAContext *rdma, Error **errp) { /* allocate pd */ rdma->pd =3D ibv_alloc_pd(rdma->verbs); if (!rdma->pd) { - error_report("failed to allocate protection domain"); + error_setg(errp, "failed to allocate protection domain"); return -1; } =20 /* create receive completion channel */ rdma->recv_comp_channel =3D ibv_create_comp_channel(rdma->verbs); if (!rdma->recv_comp_channel) { - error_report("failed to allocate receive completion channel"); + error_setg(errp, "failed to allocate receive completion channel"); goto err_alloc_pd_cq; } =20 @@ -1068,21 +1068,21 @@ static int qemu_rdma_alloc_pd_cq(RDMAContext *rdma) rdma->recv_cq =3D ibv_create_cq(rdma->verbs, (RDMA_SIGNALED_SEND_MAX *= 3), NULL, rdma->recv_comp_channel, 0); if (!rdma->recv_cq) { - error_report("failed to allocate receive completion queue"); + error_setg(errp, "failed to allocate receive completion queue"); goto err_alloc_pd_cq; } =20 /* create send completion channel */ rdma->send_comp_channel =3D ibv_create_comp_channel(rdma->verbs); if (!rdma->send_comp_channel) { - error_report("failed to allocate send completion channel"); + error_setg(errp, "failed to allocate send completion channel"); goto err_alloc_pd_cq; } =20 rdma->send_cq =3D ibv_create_cq(rdma->verbs, (RDMA_SIGNALED_SEND_MAX *= 3), NULL, rdma->send_comp_channel, 0); if (!rdma->send_cq) { - error_report("failed to allocate send completion queue"); + error_setg(errp, "failed to allocate send completion queue"); goto err_alloc_pd_cq; } =20 @@ -2451,6 +2451,7 @@ static void qemu_rdma_cleanup(RDMAContext *rdma) =20 static int qemu_rdma_source_init(RDMAContext *rdma, bool pin_all, Error **= errp) { + ERRP_GUARD(); int ret, idx; =20 /* @@ -2464,12 +2465,12 @@ static int qemu_rdma_source_init(RDMAContext *rdma,= bool pin_all, Error **errp) goto err_rdma_source_init; } =20 - ret =3D qemu_rdma_alloc_pd_cq(rdma); + ret =3D qemu_rdma_alloc_pd_cq(rdma, errp); if (ret < 0) { - error_setg(errp, "RDMA ERROR: " - "rdma migration: error allocating pd and cq! Your mlock= ()" - " limits may be too low. Please check $ ulimit -a # and= " - "search for 'ulimit -l' in the output"); + error_append_hint(errp, + "Your mlock() limits may be too low. " + "Please check $ ulimit -a # and " + "search for 'ulimit -l' in the output\n"); goto err_rdma_source_init; } =20 @@ -3450,9 +3451,9 @@ static int qemu_rdma_accept(RDMAContext *rdma) =20 qemu_rdma_dump_id("dest_init", verbs); =20 - ret =3D qemu_rdma_alloc_pd_cq(rdma); + ret =3D qemu_rdma_alloc_pd_cq(rdma, &err); if (ret < 0) { - error_report("rdma migration: error allocating pd and cq!"); + error_report_err(err); goto err_rdma_dest_wait; } =20 --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048326; cv=none; d=zohomail.com; s=zohoarc; b=h+REaNNmIGxoIBc8XJ0WsvaieGvBaJRpvzuF0sjxa5Tair/c8E+QlrXtOJgbETIp3UZOJWF+1yjCsSt+kKdj/SFkPvnLZ6usPu4q64JSbYquMD1/q71lTpdWvj14Ya3t9os5O2luvoApLd1fArg+buBXch9m7+EjpZfebA3M+0A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048326; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=a0V8ad4bZ0AfvBGwm9pLsga4NfMnC2GHO7+bozWeQjk=; b=nzglBHwFDtgrfmUALj3qO4do+kQ33ncKS6edq7DwxYU3YMuSN1J1y5ryEQSON2O83eIkZTaNX6TGcOG20hfxbTofYQO0r2C8RO5DOXvWk8DTBgc9BksWHU8kfsT0Aqnk/XqS/OsgFIl7GqlSjeUkLPC/sf2QwDcvTU6VEtZkznI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048326433192.0254828920771; Mon, 18 Sep 2023 07:45:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFSS-00035B-KD; Mon, 18 Sep 2023 10:42:40 -0400 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 1qiFSN-0002yE-Gm for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS2-0002bs-PL for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:33 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-553-O8nPUsccMYGoGmb7JBzSLA-1; Mon, 18 Sep 2023 10:42:11 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5FDEA3800BAD for ; Mon, 18 Sep 2023 14:42:11 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3E68C2156702 for ; Mon, 18 Sep 2023 14:42:11 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 680F721E68A0; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048133; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a0V8ad4bZ0AfvBGwm9pLsga4NfMnC2GHO7+bozWeQjk=; b=BsinaZ5dyE8q8tHM7CETy+pEzn5RbsuTEG1Y5wKaMhrdnFh/6JiMOKwOPjKbZG6tXx0qAs lNWondgXlS2Y17DbH5Q++cGyzwgtmfHmUIi7arIBY9QseZ2LSfiXAJMS2ZIswTJB182hkB 1kTz3pr29zoum6aeu3S51dkwKtgJXf4= X-MC-Unique: O8nPUsccMYGoGmb7JBzSLA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 44/52] migration/rdma: Silence qemu_rdma_resolve_host() Date: Mon, 18 Sep 2023 16:41:58 +0200 Message-ID: <20230918144206.560120-45-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048327209100001 Content-Type: text/plain; charset="utf-8" Functions that use an Error **errp parameter to return errors should not also report them to the user, because reporting is the caller's job. When the caller does, the error is reported twice. When it doesn't (because it recovered from the error), there is no error to report, i.e. the report is bogus. qemu_rdma_resolve_host() violates this principle: it calls error_report(). Clean this up: drop error_report(). Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian --- migration/rdma.c | 1 - 1 file changed, 1 deletion(-) diff --git a/migration/rdma.c b/migration/rdma.c index 41f0ae4ddb..0e365db06a 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1003,7 +1003,6 @@ route: error_setg(errp, "RDMA ERROR: result not equal to event_addr_resolved %s= ", rdma_event_str(cm_event->event)); - error_report("rdma_resolve_addr"); rdma_ack_cm_event(cm_event); goto err_resolve_get_addr; } --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048583; cv=none; d=zohomail.com; s=zohoarc; b=P8ryJPJHD+lsZiN+MokJxayEevis3Umdsc+K0DfHxSyo8NzPzMdOVJLYjYxKgvmjefoN17TuAeYRhYZftivkS4316MX9V9jksprZXLq/QEJBx1PiibQcbSiV6yaPg8+A5VqC+5Q6g51W5FJFiyYYP1uX1TOQ+xirJgUrBHn1rSY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048583; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PkB838LQ80iGjBq0Z1G6oMwvf09DZSThxOjEipkPMjY=; b=XSY4RT8WdhYSCv8+eP8OkZaAr+gEatzJ2ecqufZroAbJ4xAmluyFCoefRag0yLj+pRQ1t4wUhEq/Xl3Aw8zcMXIH6U4S7NAqOcUFQs6AOp+qcHGTYpWH6XyHk1rruqZ5nfU9ZzFYFD7OBUTa2iLugufsxAOl5pUPDfpdKz8zdHs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048583831571.4077221794239; Mon, 18 Sep 2023 07:49:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFYE-0001Km-Oh; Mon, 18 Sep 2023 10:48:38 -0400 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 1qiFYA-00013F-K7 for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:48:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFY9-0003ti-0t for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:48:34 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-107-fPVssOxcPie3VH7rVuNWzg-1; Mon, 18 Sep 2023 10:48:28 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1288A858F1D for ; Mon, 18 Sep 2023 14:48:28 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E2AA740C2070 for ; Mon, 18 Sep 2023 14:48:27 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 6ACE421E68A1; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048510; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PkB838LQ80iGjBq0Z1G6oMwvf09DZSThxOjEipkPMjY=; b=aHIKoblwpRf5iyH6uWHARQjKIHGErm2XYaY0TcEzchcuzA59tqmz10IIEEEI/MGNvZdEiu 1eaEeZWAaaxPWDAeRUZKdr/1SHBdbkHmDQSHQviHPrwoATlVfkoJIUaL2W/MbubPsymlu6 VuPIofAtfg095+LA+pvf/p55fL0KwLk= X-MC-Unique: fPVssOxcPie3VH7rVuNWzg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 45/52] migration/rdma: Silence qemu_rdma_connect() Date: Mon, 18 Sep 2023 16:41:59 +0200 Message-ID: <20230918144206.560120-46-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 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=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048585928100005 Content-Type: text/plain; charset="utf-8" Functions that use an Error **errp parameter to return errors should not also report them to the user, because reporting is the caller's job. When the caller does, the error is reported twice. When it doesn't (because it recovered from the error), there is no error to report, i.e. the report is bogus. qemu_rdma_connect() violates this principle: it calls error_report() and perror(). I elected not to investigate how callers handle the error, i.e. precise impact is not known. Clean this up: replace perror() by changing error_setg() to error_setg_errno(), and drop error_report(). I believe the callers' error reports suffice then. If they don't, we need to convert to Error instead. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian --- migration/rdma.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 0e365db06a..bf4e67d68d 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -2574,8 +2574,8 @@ static int qemu_rdma_connect(RDMAContext *rdma, bool = return_path, =20 ret =3D rdma_connect(rdma->cm_id, &conn_param); if (ret < 0) { - perror("rdma_connect"); - error_setg(errp, "RDMA ERROR: connecting to destination!"); + error_setg_errno(errp, errno, + "RDMA ERROR: connecting to destination!"); goto err_rdma_source_connect; } =20 @@ -2584,16 +2584,15 @@ static int qemu_rdma_connect(RDMAContext *rdma, boo= l return_path, } else { ret =3D rdma_get_cm_event(rdma->channel, &cm_event); if (ret < 0) { - error_setg(errp, "RDMA ERROR: failed to get cm event"); + error_setg_errno(errp, errno, + "RDMA ERROR: failed to get cm event"); } } if (ret < 0) { - perror("rdma_get_cm_event after rdma_connect"); goto err_rdma_source_connect; } =20 if (cm_event->event !=3D RDMA_CM_EVENT_ESTABLISHED) { - error_report("rdma_get_cm_event !=3D EVENT_ESTABLISHED after rdma_= connect"); error_setg(errp, "RDMA ERROR: connecting to destination!"); rdma_ack_cm_event(cm_event); goto err_rdma_source_connect; --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048213; cv=none; d=zohomail.com; s=zohoarc; b=Z/m08kQKnC1MCIeJ08y6WQj1yz1sH85E/pa+R3SPmSwA4Xu32Q1v5w70Ae21MW4WoiHCuhQIWOFA564eCEfYXq7f/zYvgokaY335zPd6klMzLOEqu/9JvKFno4eiF4Osdy2F7s/JByJLAkSMab2fZXrBpDnpXVPimS7a2HbS4mo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048213; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=t+uSdvD0vGADmU9LxBEHeOhKEvalmwxVnK5KlVpbwJ4=; b=IChsvTD9fD/JCDkaEpuOKlX3ZlBJG+sW9xe/5ff7ul4e7eG9WaNgMtux7EFWzrFvbpx7dXrZbp0z1xrDz/0pfTCV/og54wHfDVtQ1qcDD6Qbkd/s6vee5vWxdD+s29SM5lw9By++pO1PuJkvXFY2xGtbBh2Np1GcLH2DMPmwlrY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048213206376.5473918059979; Mon, 18 Sep 2023 07:43:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFSN-0002zd-Tf; Mon, 18 Sep 2023 10:42:35 -0400 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 1qiFSG-0002vp-N7 for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS2-0002c7-Jj for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:28 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-649-QM0V1hWJNPupIQ6FIggDqg-1; Mon, 18 Sep 2023 10:42:11 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6D5B818175A0 for ; Mon, 18 Sep 2023 14:42:11 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4B17820268CC for ; Mon, 18 Sep 2023 14:42:11 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 6DC7C21E68A2; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048133; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=t+uSdvD0vGADmU9LxBEHeOhKEvalmwxVnK5KlVpbwJ4=; b=IilSFdaF5qWw7esV1jzvFfEm3DYhdyy7GfZeNQJ0F2Ig3y0qpyxE9NSpef4q7UkmYC2m2f kqKsbuiBi9KVoeUyo6cFwcZIq9jfSR/h4pS4kE/r9sp0ob9wuIIr7nzjkfANN7BmfWOFra vcL214zU9WT8Tjpsk1/9gnt3yPZc5qY= X-MC-Unique: QM0V1hWJNPupIQ6FIggDqg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 46/52] migration/rdma: Silence qemu_rdma_reg_control() Date: Mon, 18 Sep 2023 16:42:00 +0200 Message-ID: <20230918144206.560120-47-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048214046100007 Content-Type: text/plain; charset="utf-8" Functions that use an Error **errp parameter to return errors should not also report them to the user, because reporting is the caller's job. When the caller does, the error is reported twice. When it doesn't (because it recovered from the error), there is no error to report, i.e. the report is bogus. qemu_rdma_source_init() and qemu_rdma_accept() violate this principle: they call error_report() via qemu_rdma_reg_control(). I elected not to investigate how callers handle the error, i.e. precise impact is not known. Clean this up by dropping the error reporting from qemu_rdma_reg_control(). I believe the callers' error reports suffice. If they don't, we need to convert to Error instead. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian --- migration/rdma.c | 1 - 1 file changed, 1 deletion(-) diff --git a/migration/rdma.c b/migration/rdma.c index bf4e67d68d..29ad8ae832 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1349,7 +1349,6 @@ static int qemu_rdma_reg_control(RDMAContext *rdma, i= nt idx) rdma->total_registrations++; return 0; } - error_report("qemu_rdma_reg_control failed"); return -1; } =20 --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048591; cv=none; d=zohomail.com; s=zohoarc; b=MnSuSThXysR4pTIPByUqNEKmkP3WKLrlGDQ95w+rjKti8gR9rPydsnC04WBsuzgoR0rjmFZ31EGpBu0M3/TM3Mve2t3wlfdPYKxlzht6biVUUJfcn/GWYwPUaKRXWxYu9Yi1c74xvxCck/mwxLfz8F4uor0GYzNf0YsROLBmMZg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048591; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=o4iN1IVfHnvGYWeAYUK0yp7hr3KfCg53nWbg5V2IAxo=; b=AYy9RpS4lfAvBA2gbMeldfJvUZVeNR+fnk9UrBDwT4tAszGA6ZEfFUnEys574sRH6nGOYoiwrebbmRRy71moSSwfzvpXOThNfdwaGFjSWmAz0qffqg2Hr/oVT04/1v5wc9i4Sd4ESZau7DQYZ0An9TyF9wgoHsdk415uzpYFx7Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048591082653.9874854511295; Mon, 18 Sep 2023 07:49:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFSP-000326-Rg; Mon, 18 Sep 2023 10:42:37 -0400 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 1qiFSH-0002w1-Uw for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS2-0002bw-KH for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:29 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-437-yn3vAOi7PaOG9ZIOniCJXQ-1; Mon, 18 Sep 2023 10:42:11 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 731C729AA2C0 for ; Mon, 18 Sep 2023 14:42:11 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 51D7D2156701 for ; Mon, 18 Sep 2023 14:42:11 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 7088A21E68A3; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048133; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=o4iN1IVfHnvGYWeAYUK0yp7hr3KfCg53nWbg5V2IAxo=; b=Mwf+iJaQebPG81RJSXq9RwHoFoEejwqES87CzRFM4Ho0jZ86NvvtvRK77HhLR54o/8HiWM WXsjSe6SuzBDOqwXMUqqGXGrUwfcyc/GOHUSDja/9lUoyWGlKVWEMR4GVzfLHP0pYNtY5u xSb+lyJtY+7VekCf7ESxTJ3AAe6D1Us= X-MC-Unique: yn3vAOi7PaOG9ZIOniCJXQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 47/52] migration/rdma: Don't report received completion events as error Date: Mon, 18 Sep 2023 16:42:01 +0200 Message-ID: <20230918144206.560120-48-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048593292100005 Content-Type: text/plain; charset="utf-8" When qemu_rdma_wait_comp_channel() receives an event from the completion channel, it reports an error "receive cm event while wait comp channel,cm event is T", where T is the numeric event type. However, the function fails only when T is a disconnect or device removal. Events other than these two are not actually an error, and reporting them as an error is wrong. If we need to report them to the user, we should use something else, and what to use depends on why we need to report them to the user. For now, report this error only when the function actually fails. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian --- migration/rdma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 29ad8ae832..cbf5e6b9a8 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1566,11 +1566,11 @@ static int qemu_rdma_wait_comp_channel(RDMAContext = *rdma, return -1; } =20 - error_report("receive cm event while wait comp channel= ," - "cm event is %d", cm_event->event); if (cm_event->event =3D=3D RDMA_CM_EVENT_DISCONNECTED = || cm_event->event =3D=3D RDMA_CM_EVENT_DEVICE_REMOVA= L) { rdma_ack_cm_event(cm_event); + error_report("receive cm event while wait comp cha= nnel," + "cm event is %d", cm_event->event); return -1; } rdma_ack_cm_event(cm_event); --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048550; cv=none; d=zohomail.com; s=zohoarc; b=SsHSQxdS0QJ2HO3SavWGgFsIoWsZ84xar39GYJBvYjZvHKMyLX4xY0sGixXkUqrwYdttw7lamh1Rh1TUseD9u/lbm/sMVpdZPfW1sxZBgpBxeejqNtiy9RuC5ow0GGz/Fz1xq02p7gMImbmV4CwoyTX4PW+zkcM8Up40WCr3R+c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048550; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=a/4H8ipMzlqKesV3+ytiA59TNqpomYQHxsCepo1ZLLA=; b=Oh+iid2EunKeE6a8YZynyT1hqIIGWURmhrMRCeAIIqdBL9EyeCZtM+zDHhplzccJwIN2s/vP4rYQExvSl612WMJTu38Qtgx5u5W0iAti88anOKI0tQ8x0T/SCu0yQiGvNBWcEziH+PNKWZkbt4fXZHLviy3Abrs3zQ0i/B3VuJg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048550148672.5396745973233; Mon, 18 Sep 2023 07:49:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFYG-0001e5-0G; Mon, 18 Sep 2023 10:48:40 -0400 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 1qiFYA-000130-JD for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:48:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFY9-0003tq-1C for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:48:34 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-332-Uoqc45ADMhm2pnYXwM98nA-1; Mon, 18 Sep 2023 10:48:28 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 117E91C0514C for ; Mon, 18 Sep 2023 14:48:28 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E26AA40C6EBF for ; Mon, 18 Sep 2023 14:48:27 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 737F621E68A4; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048510; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a/4H8ipMzlqKesV3+ytiA59TNqpomYQHxsCepo1ZLLA=; b=COvu6bncNeTKzdL9dK2Lz3yXDMrN2qQ5FW5QBMtH2WsnMKNqYtIj9Etd59P/6icqAHc+Uq 8Ca74BsvNdsvv7Bu6u2pda0CbWt9D84HBG4LM0lqO2vqoqAS+iwnIKm2HBBKl5k7VlxpGc dKd2rGx5PeLX11IN2fZHtRzmM4MGkQc= X-MC-Unique: Uoqc45ADMhm2pnYXwM98nA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 48/52] migration/rdma: Silence qemu_rdma_block_for_wrid() Date: Mon, 18 Sep 2023 16:42:02 +0200 Message-ID: <20230918144206.560120-49-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048550363100001 Content-Type: text/plain; charset="utf-8" Functions that use an Error **errp parameter to return errors should not also report them to the user, because reporting is the caller's job. When the caller does, the error is reported twice. When it doesn't (because it recovered from the error), there is no error to report, i.e. the report is bogus. qemu_rdma_post_send_control(), qemu_rdma_exchange_get_response(), and qemu_rdma_write_one() violate this principle: they call error_report(), fprintf(stderr, ...), and perror() via qemu_rdma_block_for_wrid(), qemu_rdma_poll(), and qemu_rdma_wait_comp_channel(). I elected not to investigate how callers handle the error, i.e. precise impact is not known. Clean this up by dropping the error reporting from qemu_rdma_poll(), qemu_rdma_wait_comp_channel(), and qemu_rdma_block_for_wrid(). I believe the callers' error reports suffice. If they don't, we need to convert to Error instead. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian --- migration/rdma.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index cbf5e6b9a8..99dccdeae5 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1467,17 +1467,12 @@ static int qemu_rdma_poll(RDMAContext *rdma, struct= ibv_cq *cq, } =20 if (ret < 0) { - error_report("ibv_poll_cq failed"); return -1; } =20 wr_id =3D wc.wr_id & RDMA_WRID_TYPE_MASK; =20 if (wc.status !=3D IBV_WC_SUCCESS) { - fprintf(stderr, "ibv_poll_cq wc.status=3D%d %s!\n", - wc.status, ibv_wc_status_str(wc.status)); - fprintf(stderr, "ibv_poll_cq wrid=3D%" PRIu64 "!\n", wr_id); - return -1; } =20 @@ -1561,16 +1556,12 @@ static int qemu_rdma_wait_comp_channel(RDMAContext = *rdma, if (pfds[1].revents) { ret =3D rdma_get_cm_event(rdma->channel, &cm_event); if (ret < 0) { - error_report("failed to get cm event while wait " - "completion channel"); return -1; } =20 if (cm_event->event =3D=3D RDMA_CM_EVENT_DISCONNECTED = || cm_event->event =3D=3D RDMA_CM_EVENT_DEVICE_REMOVA= L) { rdma_ack_cm_event(cm_event); - error_report("receive cm event while wait comp cha= nnel," - "cm event is %d", cm_event->event); return -1; } rdma_ack_cm_event(cm_event); @@ -1583,7 +1574,6 @@ static int qemu_rdma_wait_comp_channel(RDMAContext *r= dma, default: /* Error of some type - * I don't trust errno from qemu_poll_ns */ - error_report("%s: poll failed", __func__); return -1; } =20 @@ -1667,7 +1657,6 @@ static int qemu_rdma_block_for_wrid(RDMAContext *rdma, =20 ret =3D ibv_get_cq_event(ch, &cq, &cq_ctx); if (ret < 0) { - perror("ibv_get_cq_event"); goto err_block_for_wrid; } =20 --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048575; cv=none; d=zohomail.com; s=zohoarc; b=G9jgqr/pPl74q3ORbfTQ+PkxTp5v+P9ZT1a7NkN9dMyNDeZ8KEGdssq6SqbFYR0kUlTugk2NcxAwkrOb9AGd46+cCNwi3FaE+ucXjUYp3ISHQrClub//LTzLlPJw4lCjX9lNe6/+IkSm+wGhhZdeWmF7JtWt6J7IMzwPp05E0Eg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048575; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kr4twT3wrBXLNLMNlfE6rORiC5bX1E81kwVPErSeXLc=; b=HZMSF/jQo3abrZiuBktzmRAVUlBbyb+KYd4NSN6zkUJlHBwnVjXRmCYB1Fjb6QnmLoin88r/vwNzXFqDq6FzseiUyEgrqZUFBQkHp8Cc2ga+bIet1wHszMS8+S9T6ZiusD6BPnyoUJqpfDOlNMW7QdkjCoFc7GUMbJklkbbGk68= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048575481597.2349225597876; Mon, 18 Sep 2023 07:49:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFYH-0001lU-EC; Mon, 18 Sep 2023 10:48:41 -0400 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 1qiFYB-0001EP-V4 for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:48:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFY9-0003te-1F for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:48:35 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-677-Aq15r855MAmpYZ8gvkpH6Q-1; Mon, 18 Sep 2023 10:48:28 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1047F3C025C2 for ; Mon, 18 Sep 2023 14:48:28 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E25EC1C64A for ; Mon, 18 Sep 2023 14:48:27 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 7653621E68A5; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048509; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kr4twT3wrBXLNLMNlfE6rORiC5bX1E81kwVPErSeXLc=; b=ZsVVS0uTuZBAWzhfajTMLe92cT5clkyMlxYzHmNnyyJpqcZVDt/xIM6LKGU5F8WKKexdDN K0+HMVuRmV4ZMTgJaB0z31XYOD+xITS/a/OBPY8ID0mBHk493lSK6tTelwWBN6y/igT5yZ ftjQZz0DZ4rDb1QR2W9Hv5pVmykFZQo= X-MC-Unique: Aq15r855MAmpYZ8gvkpH6Q-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 49/52] migration/rdma: Silence qemu_rdma_register_and_get_keys() Date: Mon, 18 Sep 2023 16:42:03 +0200 Message-ID: <20230918144206.560120-50-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048577633100001 Content-Type: text/plain; charset="utf-8" Functions that use an Error **errp parameter to return errors should not also report them to the user, because reporting is the caller's job. When the caller does, the error is reported twice. When it doesn't (because it recovered from the error), there is no error to report, i.e. the report is bogus. qemu_rdma_write_one() violates this principle: it reports errors to stderr via qemu_rdma_register_and_get_keys(). I elected not to investigate how callers handle the error, i.e. precise impact is not known. Clean this up: silence qemu_rdma_register_and_get_keys(). I believe the caller's error reports suffice. If they don't, we need to convert to Error instead. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian --- migration/rdma.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 99dccdeae5..d9f80ef390 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1314,15 +1314,6 @@ static int qemu_rdma_register_and_get_keys(RDMAConte= xt *rdma, } } if (!block->pmr[chunk]) { - perror("Failed to register chunk!"); - fprintf(stderr, "Chunk details: block: %d chunk index %d" - " start %" PRIuPTR " end %" PRIuPTR - " host %" PRIuPTR - " local %" PRIuPTR " registrations: %d\n", - block->index, chunk, (uintptr_t)chunk_start, - (uintptr_t)chunk_end, host_addr, - (uintptr_t)block->local_host_addr, - rdma->total_registrations); return -1; } rdma->total_registrations++; --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048516; cv=none; d=zohomail.com; s=zohoarc; b=AebhCfUCqJervw4ekKGkPFHZIZX7mwHIx1v3KkPE7tdZxugt0mExIOUF9EvsLlKHzkMfPpJN5/gexfXaxs3A5GERXMAX3vJYts5oLnE99GGDkjEXoaNhT9ONHF7OZMozfKryt3lXfJIQWdqriHXT0lZyz5kSTFQJq2LV3gFdUns= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048516; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=B/TC5Y2oxTiibwuc1GydJCqyd+rgVsD/zALBhavh4/M=; b=Hv02tpByjWS7Tx+0JcH14hCIO8MxAsrafkZ3GcSauKNspg7jYo/KTrukje0s5aNIIWqiZj3sCCzeQd7ogNoOBVT4nswRZ/kCbMopivNTJW+DkiQkZO8qomBo04S4TcJCTnSBAEJme6FpyhATpc1uP9Wwwo4M+t+cBPZdph/tBzE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048516718439.9465239325565; Mon, 18 Sep 2023 07:48:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFSw-0003Cg-Hw; Mon, 18 Sep 2023 10:43:10 -0400 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 1qiFSR-00033y-GL for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS5-0002cd-Ch for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:39 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-553-IgAWWjvuNvKulofssAwSVw-1; Mon, 18 Sep 2023 10:42:12 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 85A4F29AA2C6 for ; Mon, 18 Sep 2023 14:42:11 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 63DDDC15BB8 for ; Mon, 18 Sep 2023 14:42:11 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 791F821E68A6; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048133; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=B/TC5Y2oxTiibwuc1GydJCqyd+rgVsD/zALBhavh4/M=; b=CvG+fhDRJbyTDpwaRGjwmTvwoKaeis8SQstEwVwIXXkg/+FILMs7dtQMO8/F/T0Mi6Hf74 EJlf1wbYIy7i/+EbRFrlzjTL4DQ/wQ6n6kiWx9jjOB0mZ7Vp1pOcKz27u/ybwO4LltkNLR vnmjiVon8W/OCWqsVL1brrre6pkecS8= X-MC-Unique: IgAWWjvuNvKulofssAwSVw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 50/52] migration/rdma: Silence qemu_rdma_cleanup() Date: Mon, 18 Sep 2023 16:42:04 +0200 Message-ID: <20230918144206.560120-51-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048517262100009 Content-Type: text/plain; charset="utf-8" Functions that use an Error **errp parameter to return errors should not also report them to the user, because reporting is the caller's job. When the caller does, the error is reported twice. When it doesn't (because it recovered from the error), there is no error to report, i.e. the report is bogus. qemu_rdma_source_init(), qemu_rdma_connect(), rdma_start_incoming_migration(), and rdma_start_outgoing_migration() violate this principle: they call error_report() via qemu_rdma_cleanup(). Moreover, qemu_rdma_cleanup() can't fail. It is called on error paths, and QIOChannel close and finalization. Are the conditions it reports really errors? I doubt it. Clean this up: silence qemu_rdma_cleanup(). I believe that's fine for all these callers. If it isn't, we need to convert to Error instead. Signed-off-by: Markus Armbruster --- migration/rdma.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index d9f80ef390..be2db7946d 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -2330,7 +2330,6 @@ static int qemu_rdma_write(QEMUFile *f, RDMAContext *= rdma, =20 static void qemu_rdma_cleanup(RDMAContext *rdma) { - Error *err =3D NULL; int idx; =20 if (rdma->cm_id && rdma->connected) { @@ -2341,10 +2340,7 @@ static void qemu_rdma_cleanup(RDMAContext *rdma) .type =3D RDMA_CONTROL_ERROR, .repeat =3D 1, }; - error_report("Early error. Sending error."); - if (qemu_rdma_post_send_control(rdma, NULL, &head, &err) < 0) { - error_report_err(err); - } + qemu_rdma_post_send_control(rdma, NULL, &head, NULL); } =20 rdma_disconnect(rdma->cm_id); --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048326; cv=none; d=zohomail.com; s=zohoarc; b=chN0IXPRLmZcUQdW652Qw7mJPHA1NpSwmFFMdinpT8Hk6AjFzJVNL9yJLJHkI/o30/8hfdKLq3WMxfzIB31RPUFcN/DJKxei+mDkWVfc7215bnaIa9st7AWD9DmraunjJP+xCsg3zGVM2xbrl1c9sLRNEYvZAWxpwsUT9LLSxXE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048326; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NRk/3BTFIROz8GcoW0l4/ksxZbWN2cMvLtnkZKAhwPM=; b=TLafspXfc2uxmA/0ddcpAw3lutYTC6/ANfY3ApUg6+64tJ1py5rU+9WiYxtrNkDMdT9JzK02XwBWBH29Y62rM0VBWiBHZrSMnsy0/264C5SA3KKqhW/gYIORGW8GqC3J2L5t3jN5tzPTtJjqjLVROj4Kyh+EmEhdmdiHAHpRtv0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048326430830.6965128871792; Mon, 18 Sep 2023 07:45:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFTO-0004jW-Rs; Mon, 18 Sep 2023 10:43:39 -0400 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 1qiFSR-00033f-4s for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFS5-0002d4-3X for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:42:38 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-557-iqIkvRiHNYuRPak8uz84xQ-1; Mon, 18 Sep 2023 10:42:12 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AF04A1C05152 for ; Mon, 18 Sep 2023 14:42:11 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 713CD20268CC for ; Mon, 18 Sep 2023 14:42:11 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 7C2C921E68A7; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048134; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NRk/3BTFIROz8GcoW0l4/ksxZbWN2cMvLtnkZKAhwPM=; b=c59vMhRsSUp9cfT0s1Vq3ExDIHvfQzgKZw82b6qI8YwKWz5EROcAaOuIeLdHLJQtTLALg3 wAecxWdNVuT1TvX3mDt7XfpkON4yTKzwxVYiwo6EYxQF+9Umk5zgAVt61We/3zDhiIM2iF MiQvFD9prRtOhq1d5NFguqYlDaeV3xg= X-MC-Unique: iqIkvRiHNYuRPak8uz84xQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 51/52] migration/rdma: Use error_report() & friends instead of stderr Date: Mon, 18 Sep 2023 16:42:05 +0200 Message-ID: <20230918144206.560120-52-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048328272100007 Content-Type: text/plain; charset="utf-8" error_report() obeys -msg, reports the current error location if any, and reports to the current monitor if any. Reporting to stderr directly with fprintf() or perror() is wrong, because it loses all this. Fix the offenders. Signed-off-by: Markus Armbruster --- migration/rdma.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index be2db7946d..9e9904984e 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -871,12 +871,12 @@ static int qemu_rdma_broken_ipv6_kernel(struct ibv_co= ntext *verbs, Error **errp) =20 if (roce_found) { if (ib_found) { - fprintf(stderr, "WARN: migrations may fail:" - " IPv6 over RoCE / iWARP in linux" - " is broken. But since you appear to have = a" - " mixed RoCE / IB environment, be sure to = only" - " migrate over the IB fabric until the ker= nel " - " fixes the bug.\n"); + warn_report("WARN: migrations may fail:" + " IPv6 over RoCE / iWARP in linux" + " is broken. But since you appear to have a" + " mixed RoCE / IB environment, be sure to only" + " migrate over the IB fabric until the kernel " + " fixes the bug."); } else { error_setg(errp, "RDMA ERROR: " "You only have RoCE / iWARP devices in your sys= tems" @@ -1407,7 +1407,8 @@ static int qemu_rdma_unregister_waiting(RDMAContext *= rdma) block->remote_keys[chunk] =3D 0; =20 if (ret !=3D 0) { - perror("unregistration chunk failed"); + error_report("unregistration chunk failed: %s", + strerror(errno)); return -1; } rdma->total_registrations--; @@ -3751,7 +3752,8 @@ static int qemu_rdma_registration_handle(QEMUFile *f) block->pmr[reg->key.chunk] =3D NULL; =20 if (ret !=3D 0) { - perror("rdma unregistration chunk failed"); + error_report("rdma unregistration chunk failed: %s", + strerror(errno)); goto err; } =20 @@ -3940,10 +3942,10 @@ static int qemu_rdma_registration_stop(QEMUFile *f, */ =20 if (local->nb_blocks !=3D nb_dest_blocks) { - fprintf(stderr, "ram blocks mismatch (Number of blocks %d vs %= d) " - "Your QEMU command line parameters are probably " - "not identical on both the source and destination.", - local->nb_blocks, nb_dest_blocks); + error_report("ram blocks mismatch (Number of blocks %d vs %d)", + local->nb_blocks, nb_dest_blocks); + error_printf("Your QEMU command line parameters are probably " + "not identical on both the source and destination= ."); rdma->errored =3D true; return -1; } @@ -3956,10 +3958,11 @@ static int qemu_rdma_registration_stop(QEMUFile *f, =20 /* We require that the blocks are in the same order */ if (rdma->dest_blocks[i].length !=3D local->block[i].length) { - fprintf(stderr, "Block %s/%d has a different length %" PRI= u64 - "vs %" PRIu64, local->block[i].block_name, i, - local->block[i].length, - rdma->dest_blocks[i].length); + error_report("Block %s/%d has a different length %" PRIu64 + "vs %" PRIu64, + local->block[i].block_name, i, + local->block[i].length, + rdma->dest_blocks[i].length); rdma->errored =3D true; return -1; } @@ -4075,7 +4078,7 @@ static void rdma_accept_incoming_migration(void *opaq= ue) ret =3D qemu_rdma_accept(rdma); =20 if (ret < 0) { - fprintf(stderr, "RDMA ERROR: Migration initialization failed\n"); + error_report("RDMA ERROR: Migration initialization failed"); return; } =20 @@ -4087,7 +4090,7 @@ static void rdma_accept_incoming_migration(void *opaq= ue) =20 f =3D rdma_new_input(rdma); if (f =3D=3D NULL) { - fprintf(stderr, "RDMA ERROR: could not open RDMA for input\n"); + error_report("RDMA ERROR: could not open RDMA for input"); qemu_rdma_cleanup(rdma); return; } --=20 2.41.0 From nobody Fri May 17 11:59:05 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695048563; cv=none; d=zohomail.com; s=zohoarc; b=Fj+5vzDOfhD1LkNLyeH2YP/MkKQPJ3IN8/rCkgj3kHilQmtGbArM2e7FTKtPl4U5FBI2CE+rjjcHSRs8tGDseZXOlNCcMA0b7yDO1ky+nNfPAdzhRwE7sVb0VteFyQUQV1oA8Xi/ehuyFmuyFSdMgTqX90feMTrJGrO6XSsEiYQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695048563; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5Vh8j/4nj2m+S9egdULAIS1abfgrtBCZZqvvhqp5OSU=; b=YSSecF6wECqrmm8n0XSP8OXiNpxSVBa/O4CKy/mVWcH7QuGjRSBizlMkbQ3RG3AJOKbknGa0a6DC3dhRj/Q7li+x5nV8uY8FuXPikmKVAW4G4gblZXtpN1VU+XyHsa812vqmGYkwjmSTml5wLymPgDLMYnKz4iuYioJRzuem9q4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695048563364970.8017432714672; Mon, 18 Sep 2023 07:49:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qiFYF-0001dL-Ra; Mon, 18 Sep 2023 10:48:39 -0400 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 1qiFYB-0001Et-VT for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:48:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qiFY9-0003tl-1d for qemu-devel@nongnu.org; Mon, 18 Sep 2023 10:48:35 -0400 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-107-oItKdOPfPSSns9DfXDOpHg-1; Mon, 18 Sep 2023 10:48:28 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 11A661C0514D for ; Mon, 18 Sep 2023 14:48:28 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E24461C646 for ; Mon, 18 Sep 2023 14:48:27 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 7F15221E68A8; Mon, 18 Sep 2023 16:42:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695048510; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5Vh8j/4nj2m+S9egdULAIS1abfgrtBCZZqvvhqp5OSU=; b=DXk9AdcXC7A8uigNQGcPN4avwrSFU9JU+vRi0uK2ZVVcNe4FrIlwSfVJHP+8vHquAaPweT OTJ+LxIBt0fMozVMKK0bZtQi1NAMBwgS4P8pJXVVBhLp63Hnz3HCiuOjPeOssiDfjmneXi oAXGHEbhH97sPjYxpA2RN5d6Ufu6cXM= X-MC-Unique: oItKdOPfPSSns9DfXDOpHg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com Subject: [PATCH 52/52] migration/rdma: Fix how we show device details on open Date: Mon, 18 Sep 2023 16:42:06 +0200 Message-ID: <20230918144206.560120-53-armbru@redhat.com> In-Reply-To: <20230918144206.560120-1-armbru@redhat.com> References: <20230918144206.560120-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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=170.10.129.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695048563628100001 Content-Type: text/plain; charset="utf-8" qemu_rdma_dump_id() dumps RDMA device details to stdout. rdma_start_outgoing_migration() calls it via qemu_rdma_source_init() and qemu_rdma_resolve_host() to show source device details. rdma_start_incoming_migration() arranges its call via rdma_accept_incoming_migration() and qemu_rdma_accept() to show destination device details. Two issues: 1. rdma_start_outgoing_migration() can run in HMP context. The information should arguably go the monitor, not stdout. 2. ibv_query_port() failure is reported as error. Its callers remain unaware of this failure (qemu_rdma_dump_id() can't fail), so reporting this to the user as an error is problematic. Use qemu_printf() instead of printf() and error_report(). Signed-off-by: Markus Armbruster --- migration/rdma.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 9e9904984e..8c84fbab7a 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -30,6 +30,7 @@ #include "qemu/sockets.h" #include "qemu/bitmap.h" #include "qemu/coroutine.h" +#include "qemu/qemu-print.h" #include "exec/memory.h" #include #include @@ -742,24 +743,25 @@ static void qemu_rdma_dump_id(const char *who, struct= ibv_context *verbs) struct ibv_port_attr port; =20 if (ibv_query_port(verbs, 1, &port)) { - error_report("Failed to query port information"); + qemu_printf("%s RDMA Device opened, but can't query port informati= on", + who); return; } =20 - printf("%s RDMA Device opened: kernel name %s " - "uverbs device name %s, " - "infiniband_verbs class device path %s, " - "infiniband class device path %s, " - "transport: (%d) %s\n", + qemu_printf("%s RDMA Device opened: kernel name %s " + "uverbs device name %s, " + "infiniband_verbs class device path %s, " + "infiniband class device path %s, " + "transport: (%d) %s\n", who, verbs->device->name, verbs->device->dev_name, verbs->device->dev_path, verbs->device->ibdev_path, port.link_layer, - (port.link_layer =3D=3D IBV_LINK_LAYER_INFINIBAND) ? "Infi= niband" : - ((port.link_layer =3D=3D IBV_LINK_LAYER_ETHERNET) - ? "Ethernet" : "Unknown")); + port.link_layer =3D=3D IBV_LINK_LAYER_INFINIBAND ? "Infini= band" + : port.link_layer =3D=3D IBV_LINK_LAYER_ETHERNET ? "Ethern= et" + : "Unknown"); } =20 /* --=20 2.41.0