From nobody Wed May 15 18:29:22 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=1695907269; cv=none; d=zohomail.com; s=zohoarc; b=RCACqt9Zr5bSfK5YmOgGqru2aL4pXII9F9GVp7WeWKS+0N5hhDYXqSbvFgiv1KMLPx27oyPy/FIdWPGdDc53AkyIzUiHdxxfp4YKbE6G3DuTTKqRY5jSQSFc2hERWPENcKU5dtxHH2qzgVMe3vuhwu7kKSmng/Cc+J7PE6f0axQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907269; 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=5oAWhlcLQfW619HpWV3P5IP8t48Hfx8FGdpvvaUqDdo=; b=UFmyc5g/DdXb189i2eG7H7Kje2Cru6r8Yb8LNYdi+S6hY2mQ5fmN4F4j+2SgTO8IsUQePqd39plBgxIQUfXoSWme0LSDTYJXhaHzFkv52jfflNAM1J9IBeyDG0CNgpxRCCrhuA64CBYZxNjHuyd7aG1wz35Xerxwg4WHaAOIgPI= 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 1695907268987402.3315990127942; Thu, 28 Sep 2023 06:21:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwX-0003XJ-Ra; Thu, 28 Sep 2023 09:20: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 1qlqwQ-0003RX-Cf for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:31 -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 1qlqwL-00088S-KW for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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-327-_1ix4ZxSONOWAu9yF5-ENw-1; Thu, 28 Sep 2023 09:20:21 -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 004951C00D07; Thu, 28 Sep 2023 13:20:21 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D0473400E89; Thu, 28 Sep 2023 13:20:20 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id C2AA021E6904; Thu, 28 Sep 2023 15:20:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907224; 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=5oAWhlcLQfW619HpWV3P5IP8t48Hfx8FGdpvvaUqDdo=; b=GnWokn8Bmv8t8LRaIboQyUDvTb3R/Pd2NN0rm6dtv0HDy/l+VDSaxII+QRLZNr0FjOmpvo 6UNGdF07Dkp3FRZKMZjPpRmtBWsiS6uspHknuMdSStQaYugRL4iqT8ILlE3+Qh2YHTwFny 9D6IZ5TzY1axn1IbAGm/CuTTVQ+PBFU= X-MC-Unique: _1ix4ZxSONOWAu9yF5-ENw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 01/53] migration/rdma: Clean up qemu_rdma_poll()'s return type Date: Thu, 28 Sep 2023 15:19:27 +0200 Message-ID: <20230928132019.2544702-2-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: 1695907269522100002 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 Reviewed-by: Juan Quintela --- migration/rdma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index a2a3db35b1..6ceddd044c 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 Wed May 15 18:29:22 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=1695907423; cv=none; d=zohomail.com; s=zohoarc; b=Sd5B3K9PWFhhivHwTOQgYuji6Gm7pLL7VVKmidg1x/ijn6m4OTKUoTK80Pr20SXE2KV/po+v5bNzzBXLv11riDdFtgNYI9mLRUdPKCjcvnetwwbG3rUma/OrEg8hUu521due/HoOWYZDdkpMEU/KKM91Qb7PI7jBDm9QiaZ9Ga4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907423; 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=L9OZQJyiF8oNbsBSqapJS/KBO//bQiQb+UY4ZVkYyWw=; b=Vctle0g2QquBTU3Ti4NgF12DX8udo3pZ3ylb6BK953unAKJvZHD9aEkjUazFuT4QTSqP6nYrlT0e8O0Y9c1fcegteVBDEbSjvrjSfw2fVP0N7KSPPl9depsD7fvMtDH2p2soQM6Y3i2/ruoMQJ4dluhnQxo2gTZgITqvKwGvaRk= 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 1695907423437478.76494201022774; Thu, 28 Sep 2023 06:23:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwY-0003ZP-OJ; Thu, 28 Sep 2023 09:20: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 1qlqwQ-0003Qy-67 for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:31 -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 1qlqwL-00088O-Gu for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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-214-RQTa1MLiP5asSTJCzvPqzQ-1; Thu, 28 Sep 2023 09:20:21 -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 F2FC1280A9B6; Thu, 28 Sep 2023 13:20:20 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D04E540C6E76; Thu, 28 Sep 2023 13:20:20 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id C5D1421E6905; Thu, 28 Sep 2023 15:20:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907224; 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=L9OZQJyiF8oNbsBSqapJS/KBO//bQiQb+UY4ZVkYyWw=; b=Z4G2BP4aI+qhvHFxLMXtakjvN/IbjyHD8dMIRluhmOz+tSqOlgbRO2VywwU2gvMS2iIIe2 EHnVDFg1zMEUImXMACyyl8l9VQQhCz6niedvtX0+Z8zdebLWsoUTl01WdiPD8gpszWXu8d p+Z6ZN4I4dpfEebTnRN5JtPtRNDAHCM= X-MC-Unique: RQTa1MLiP5asSTJCzvPqzQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 02/53] migration/rdma: Clean up qemu_rdma_data_init()'s return type Date: Thu, 28 Sep 2023 15:19:28 +0200 Message-ID: <20230928132019.2544702-3-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: 1695907425189100003 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 Reviewed-by: Juan Quintela --- migration/rdma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration/rdma.c b/migration/rdma.c index 6ceddd044c..934771496c 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 Wed May 15 18:29:22 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=1695907269; cv=none; d=zohomail.com; s=zohoarc; b=kFcaU5GXkU9fuzz+40s90v+Fkd+U+CVs7SFptTSU/wwFzOr/O61TxX8LvPBg2G4RgGJhPpm+aaIHkJlGlkyoPzzKeevTVe0wgUBTzZ3IZwbDYjfiZUo0EbMnUYvqBzKd3/WxVL5TP1hDvKiGtbVJNUIzhzw+PBfP9DUZGsdLOHg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907269; 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=wNq1asJOBFR4V42YaVHEqOMsMLZtarjdgQ01mI52VO0=; b=gaRi4nMvEguB9vULqTczI7bSogPhIVoH2jW5bTwRp19Qi8O7rQrUNf2aoWbBliMkfxZ8d+ptcDyNQjAMAnWvcHRsI5zSR3hv9TZruOcE5/RMyl5ESvIFNUu3rQk+RFUk1P+YqpUUmBztndajW7ADtuWGvzdY4g004ztfSgerAyw= 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 1695907269029794.7156106168533; Thu, 28 Sep 2023 06:21:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwo-0003gt-Px; Thu, 28 Sep 2023 09:20:54 -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 1qlqwP-0003Q4-30 for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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 1qlqwL-00088V-Ff for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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-694-cPKnmjnJM9uqspseYHoElQ-1; Thu, 28 Sep 2023 09:20:21 -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 F420B185A79C; Thu, 28 Sep 2023 13:20:20 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D0217492B05; Thu, 28 Sep 2023 13:20:20 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id C8C6321E6906; Thu, 28 Sep 2023 15:20:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907224; 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=wNq1asJOBFR4V42YaVHEqOMsMLZtarjdgQ01mI52VO0=; b=MxVvujTn4LcVYmVkXyAQX7S5rYRtRNuAUhIBNpJyWiCNEboSzjU2gzLWpzku63R3CILI1B 3jwEPOoKd8qtgoh0QFCUl2biEHlkUBnwp26zTth7NVrhMwnBhxOL7SEGeUXDW5h2R/JUaZ PbkteeXIwxKfolllDfyeB6R/bK231f4= X-MC-Unique: cPKnmjnJM9uqspseYHoElQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 03/53] migration/rdma: Clean up rdma_delete_block()'s return type Date: Thu, 28 Sep 2023 15:19:29 +0200 Message-ID: <20230928132019.2544702-4-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 1695907269522100001 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 Reviewed-by: Juan Quintela --- migration/rdma.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 934771496c..d448c3e538 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 Wed May 15 18:29:22 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=1695907281; cv=none; d=zohomail.com; s=zohoarc; b=WEJ4+rJQUUA0twP0ttmatTsJSMFUWIP+U/3uP61ppkB75V3DX6Awu9gQ0N23QfNE9+0OKjmVBCOg58MYz0TmqbZeOM6d1keFtCWI+tkYe6j4GsXGe3drU/c0ONP2IQEf1h8rnpz304fh2uyTLXaMYnwKF2JKtIfXT1AgZD/vrKM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907281; 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=KEeeVZm9AaOV0Or78ev6HVkfS9Ubr0Zq6TCwrDBrVos=; b=Z9VeQ7nlSrqp0ZEzwZHRKNElPl3uja+Ve5Ymer2bFdDcDdTFjJz8HclieLYnIWSwQAMmj8ww9RTj+6wfkJY5OzblfoVDWlCwrxfWoAxiQRbfBLUBNoYJQxUc9dHRfA9VCR3NIxOnVoFokzgixbMCReU6Gk8stS6ESths6CB9wNQ= 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 1695907281589820.005510504057; Thu, 28 Sep 2023 06:21:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwb-0003am-50; Thu, 28 Sep 2023 09:20: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 1qlqwQ-0003S1-Ni for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:31 -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 1qlqwL-00088L-IS for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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-635-8xhUuKisOrmHyeCS1lvCrw-1; Thu, 28 Sep 2023 09:20:21 -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 1EAAF85A5BF; Thu, 28 Sep 2023 13:20:21 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D3B9340107B; Thu, 28 Sep 2023 13:20:20 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id CBED321E690B; Thu, 28 Sep 2023 15:20:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907224; 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=KEeeVZm9AaOV0Or78ev6HVkfS9Ubr0Zq6TCwrDBrVos=; b=ZP77EnK7ewo6cHhJQ0miDNwdOUus6W8vLZkbLiQG1lPStVgojQFGImZLPLVRe5Tgx0Exss 2V9ZH/0CcD5KbRDDK95JafTumL3B1Hah3Cfm6kYMAKrPypCQZBahB2zsXM76/2buuPv57f 1iEn9rN3YUI2BI2y0DADIQuqUPCJ56U= X-MC-Unique: 8xhUuKisOrmHyeCS1lvCrw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 04/53] migration/rdma: Drop fragile wr_id formatting Date: Thu, 28 Sep 2023 15:19:30 +0200 Message-ID: <20230928132019.2544702-5-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 1695907282400100001 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 Reviewed-by: Juan Quintela --- 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 d448c3e538..fc9eab0ff7 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 Wed May 15 18:29:22 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=1695907652; cv=none; d=zohomail.com; s=zohoarc; b=j847iE83mx13gsNz4KWd9uGowQntv96+oJLuB9Vep2XlGVVCI85kpCmNtzhBvd+MKs8fJueZkEewpzSt/GzM11/wXUjmjo209If9r909sG+AKarh/8SvxVRFA3E4PDLnzj+PXDzkwAIW1ZKyGlPpQ8/2ykzBmFgLPd6nmXpKu2g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907652; 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=N9wQsm5DvThCJ3wjMgNvzVGnTbbPqDrACESHr0MhFbI=; b=kbELMBqacS73vg6FivxGstJK82tu9CC/DpOhqHdW08Boql/kSPa5ULdHRHC/ZLEgM5nQvcGb7xtLORtso00Vb0lq4XUB0HBUvIMZZ4LBEZ6fp8H4MzAzYjzCNj4GSzTTm6ZBcb2S43NGKCMKaktN6lalM7eNgFAfjCeYSD7YEZA= 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 1695907652497527.0714854730619; Thu, 28 Sep 2023 06:27:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwn-0003gp-Fa; Thu, 28 Sep 2023 09:20:53 -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 1qlqwN-0003Oo-7R for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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 1qlqwL-00087a-3p for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:26 -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-104-I68eG5KtNZOrwa5xHczOfw-1; Thu, 28 Sep 2023 09:20:22 -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 0D80B101A550; Thu, 28 Sep 2023 13:20:22 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DE39A167F8; Thu, 28 Sep 2023 13:20:21 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id CEEFC21E690C; Thu, 28 Sep 2023 15:20:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907224; 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=N9wQsm5DvThCJ3wjMgNvzVGnTbbPqDrACESHr0MhFbI=; b=JR37uxij2IytF+XakftoAPSFVdVbBtLnQiCefc4DqWAevawwtvi5IJcx2hpfWkq76edBoM CPN2W3xlwWnNwaEdC8qk0uC1ljgPgb9kAxWhYkqhWf0M+u5CflNdwHu2xq7A2dOpnbzNXm EMjSEot4rq1GzC0mJlqcUcIZjd0xPYw= X-MC-Unique: I68eG5KtNZOrwa5xHczOfw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 05/53] migration/rdma: Consistently use uint64_t for work request IDs Date: Thu, 28 Sep 2023 15:19:31 +0200 Message-ID: <20230928132019.2544702-6-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 1695907652973100001 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 Reviewed-by: Juan Quintela --- 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 fc9eab0ff7..4289346617 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 Wed May 15 18:29:22 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=1695907588; cv=none; d=zohomail.com; s=zohoarc; b=BfeWPh8Vs2tDoQDoLAx9792c/bvt1bq0FfldpyS+qhprAPE11YwNqVvngvLY0RxobtvbLF6ltUWU1QBAbNUrZa8HkFBTo0fUBugb5tFn5wKbTV84NsPuKyCrMTJ7KgTHbJriaQcfV78n11BLdIDCC8CY2TBopU0WQTSFQTo+ZwU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907588; 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=ON7IO5ivCVC9AGVzZpLWa3v/90xMndv3sSh0NL3cuGg=; b=O5OpcS0L0uFqMrbucLIsDdoWySKudcXvW3a1l/6tAv9lE474K/p7LWqJ5GWub/+zkOSQUwTlLqU/u1vJnRLRRJk39JVmECzsho5V74uAymGiGgE5P/+KLf5zkx/9mpj06M96yPJkvdri0hWWaGWwz3Q5pXY0MZXeZueUPNau4CU= 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 1695907588748337.1833429311631; Thu, 28 Sep 2023 06:26:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwq-0003gy-22; Thu, 28 Sep 2023 09:20:56 -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 1qlqwS-0003TU-OB for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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 1qlqwM-0008An-E5 for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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-292-1nikscxFP7G4Wmu7KTTbzw-1; Thu, 28 Sep 2023 09:20:22 -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 0CC59280A9CB; Thu, 28 Sep 2023 13:20:22 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DE31114171B6; Thu, 28 Sep 2023 13:20:21 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id D1CB021E690E; Thu, 28 Sep 2023 15:20:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907225; 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=ON7IO5ivCVC9AGVzZpLWa3v/90xMndv3sSh0NL3cuGg=; b=RWvuccQB0vq7/htmRGM7zNh7GkuZU1Bi/bwAw7OLiMYjaAz6sB1+L7XoTVV+DmuPMOMxVr T7LTx4rcFFvuFjnaITOYJbGI/Nlao9SCjJVxwQkWwb8vQQOG4NleysF6OTEetA+654PsX9 JHFcPiFWZmBXDBVttRB68CVIcA5aV6k= X-MC-Unique: 1nikscxFP7G4Wmu7KTTbzw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 06/53] migration/rdma: Fix unwanted integer truncation Date: Thu, 28 Sep 2023 15:19:32 +0200 Message-ID: <20230928132019.2544702-7-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: 1695907589333100001 Content-Type: text/plain; charset="utf-8" qio_channel_rdma_readv() assigns the size_t value of qemu_rdma_fill() to an int variable before it adds it to @done / subtracts it from @want, both size_t. Truncation when qemu_rdma_fill() copies more than INT_MAX bytes. Seems vanishingly unlikely, but needs fixing all the same. Fixes: 6ddd2d76ca6f (migration: convert RDMA to use QIOChannel interface) Signed-off-by: Markus Armbruster Reviewed-by: Fabiano Rosas Reviewed-by: Juan Quintela Reviewed-by: Li Zhijian --- migration/rdma.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 4289346617..5f423f66f0 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -2852,7 +2852,7 @@ static ssize_t qio_channel_rdma_readv(QIOChannel *ioc, RDMAControlHeader head; int ret =3D 0; ssize_t i; - size_t done =3D 0; + size_t done =3D 0, len; =20 RCU_READ_LOCK_GUARD(); rdma =3D qatomic_rcu_read(&rioc->rdmain); @@ -2873,9 +2873,9 @@ static ssize_t qio_channel_rdma_readv(QIOChannel *ioc, * were given and dish out the bytes until we run * out of bytes. */ - ret =3D qemu_rdma_fill(rdma, data, want, 0); - done +=3D ret; - want -=3D ret; + len =3D qemu_rdma_fill(rdma, data, want, 0); + done +=3D len; + want -=3D len; /* Got what we needed, so go to next iovec */ if (want =3D=3D 0) { continue; @@ -2902,9 +2902,9 @@ static ssize_t qio_channel_rdma_readv(QIOChannel *ioc, /* * SEND was received with new bytes, now try again. */ - ret =3D qemu_rdma_fill(rdma, data, want, 0); - done +=3D ret; - want -=3D ret; + len =3D qemu_rdma_fill(rdma, data, want, 0); + done +=3D len; + want -=3D len; =20 /* Still didn't get enough, so lets just return */ if (want) { --=20 2.41.0 From nobody Wed May 15 18:29:22 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=1695907344; cv=none; d=zohomail.com; s=zohoarc; b=oEN/pjAsFdzqWk4RLAU/+e2FcBHEb5QXUxhNwa3Htl1IOLoCMNNHQ+snRc6qfpYBZhXhssMM6spiTMO+3RFLcapDLZ8Ys+FJm1sRUrqaQscli+1f9kMVtRomSG32UwK7cYjUjr9Nu8xz1sNzSJAncbD+b8FWJbM9Xhd0AxzQF9Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907344; 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=th5lF0fRy6siYS5ymE+c23iKQTUNVusJVFX4L1/R2LA=; b=irxXEKMHel3fdCkEwsGCz8278IxFlwE2W4HDZD43wIQOyzmDrT8Aj1/CN/2BNnwhvhcdpSXaoOsvhWpKVWeUmM5MGpHjocsFVEDiwvT47WbdKRVzbMg/w7632wTYOG6NMrBR3LfMaLfm44ovYS8GDJxNr6JBKDsihxesKTtRz74= 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 1695907344246764.7689991212472; Thu, 28 Sep 2023 06:22:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwe-0003dF-V7; Thu, 28 Sep 2023 09:20: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 1qlqwV-0003Vv-WB for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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 1qlqwN-0008Ev-Jy for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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-292-C6uWXKZBPE2rV64fhRhMeA-1; Thu, 28 Sep 2023 09:20:22 -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 0BE69101A53B; Thu, 28 Sep 2023 13:20:22 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DD39E492B05; Thu, 28 Sep 2023 13:20:21 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id D496B21E690F; Thu, 28 Sep 2023 15:20:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907226; 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=th5lF0fRy6siYS5ymE+c23iKQTUNVusJVFX4L1/R2LA=; b=IO1If0rbPVEOdtO9cO1n+ti1wCP3LYMDFSbshjbD0fJ+179ZrHPBuP2bRHi6NiS7KvBpXU wDFN9vzG/FZJhZnT4q5zqu5WuQIOC9YCEfoXryB9TgAmA7FStEQmAd7fSPJbgkaWxKnxee U2U968qXkTXOeMvvSvOXY1OGyQPz2AY= X-MC-Unique: C6uWXKZBPE2rV64fhRhMeA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 07/53] migration/rdma: Clean up two more harmless signed vs. unsigned issues Date: Thu, 28 Sep 2023 15:19:33 +0200 Message-ID: <20230928132019.2544702-8-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 1695907345425100001 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. While there, make qio_channel_rdma_readv() and qio_channel_rdma_writev() more consistent: change the former's @done to ssize_t, and delete the latter's useless initialization of @len. Signed-off-by: Markus Armbruster Reviewed-by: Fabiano Rosas Reviewed-by: Juan Quintela Reviewed-by: Li Zhijian --- migration/rdma.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 5f423f66f0..faca0ed998 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, @@ -2765,8 +2765,7 @@ static ssize_t qio_channel_rdma_writev(QIOChannel *io= c, RDMAContext *rdma; int ret; ssize_t done =3D 0; - size_t i; - size_t len =3D 0; + size_t i, len; =20 RCU_READ_LOCK_GUARD(); rdma =3D qatomic_rcu_read(&rioc->rdmaout); @@ -2851,8 +2850,8 @@ static ssize_t qio_channel_rdma_readv(QIOChannel *ioc, RDMAContext *rdma; RDMAControlHeader head; int ret =3D 0; - ssize_t i; - size_t done =3D 0, len; + ssize_t done =3D 0; + size_t i, len; =20 RCU_READ_LOCK_GUARD(); rdma =3D qatomic_rcu_read(&rioc->rdmain); --=20 2.41.0 From nobody Wed May 15 18:29:22 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=1695907269; cv=none; d=zohomail.com; s=zohoarc; b=FrTACBJvvtgpHcBPkJmXyDQHjx97mI3BVr3XhH6yJWblw/oHI1oSQBTBYLR38Dym1YhgLJM0BvLZQlS3woPhc4Z8pybhAxYGioPJeAovcIoh9wwn/ukfljTfdHeByarXIx/KcMXveoGYXXYq2N2Z5+3UwGhVT8HZ5b+svGy+XZA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907269; 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=fJHnRJ7KtjOIhcRxaLD/MZdghxbULJRVU5Sjz626hqQ=; b=T+tGyIMhFM2dWNSaxd3AT9/Q1COJvwAlufz5JaUfv+l+8gnJbBEtNpNpAh8uMQ9stWkb/bRLgEg3L4nVR76TOfIqC2QBBVscFNN4O1Qi7rW0ve6RHcopG6K57+2QLqXrZQlFd7rE7nc/4VmfmNlKn5BBPAfhK+VNSU0o4iAg+Cc= 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 1695907269358813.3832036816706; Thu, 28 Sep 2023 06:21:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwQ-0003Pr-0u; Thu, 28 Sep 2023 09:20:31 -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 1qlqwM-0003Oa-R3 for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:26 -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 1qlqwL-00087q-4f for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:26 -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-116-o7BUc3soPZKI8ER3GTCWuA-1; Thu, 28 Sep 2023 09:20:22 -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 24587101A590; Thu, 28 Sep 2023 13:20:22 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E8D06401025; Thu, 28 Sep 2023 13:20:21 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id D904921E6910; Thu, 28 Sep 2023 15:20:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907224; 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=fJHnRJ7KtjOIhcRxaLD/MZdghxbULJRVU5Sjz626hqQ=; b=S9zKDGjGRBmmp3MPp4REz0mDjo0alJd6VVd40aptv6WQQy72qZgTX7ju5vYIgP0/bdcCl9 4q9yqQgz7gNMqRDAWHBa05H+FaTzjM/oQXRkLbf04Q1MLkEyuW1xGeFGP4u8Yrxz6Nrmug HMtHj6o5byBr+IbnprASAJp9hUbzPPc= X-MC-Unique: o7BUc3soPZKI8ER3GTCWuA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 08/53] migration/rdma: Give qio_channel_rdma_source_funcs internal linkage Date: Thu, 28 Sep 2023 15:19:34 +0200 Message-ID: <20230928132019.2544702-9-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 1695907271411100009 Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster Reviewed-by: Fabiano Rosas Reviewed-by: Li Zhijian Reviewed-by: Juan Quintela --- migration/rdma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration/rdma.c b/migration/rdma.c index faca0ed998..0e991175f9 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -3056,7 +3056,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 Wed May 15 18:29:22 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=1695907408; cv=none; d=zohomail.com; s=zohoarc; b=HY0OO+BvZH/C1XsGsdMhcUx3DRFvRljvIIb4yRg7CXU9AW7FRpY+nU8AmXbVEmVA0GO/iFC3T/TFpdFr8LzdpqrW1KIW0582AHpqeZ3WccJEZVj3q/3fqW0Go6gqfPEDJgjiqtndgSN/0AIGjsZ1X47GVMTPz5tZWmLZ/G/nurU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907408; 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=uALX7FwbfXzQfp3EH9ucV/fvop/MkQ+iJY+cbp+0GRo=; b=I4yOyW0eK/WLA333MiLGYbRjQRjiZV/P3CVMZanYbkf/2bxoueW14aAqKVheIALfYH0/8/hHGSzs8RveLdi3VIZRqxdocPiUM257aJAvJv1/FRz+RqEPgkSpfiY5TWIL6mDAhLVgKOwIkTjAcTYzszGQ5diyGndoR9Z9jgJxf7A= 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 1695907408072414.6072726368733; Thu, 28 Sep 2023 06:23:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwi-0003ed-QY; Thu, 28 Sep 2023 09:20: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 1qlqwR-0003SN-Ez for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:31 -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 1qlqwL-00089j-VN for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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-63-789zOwwgMhqzvN1cVIqEmQ-1; Thu, 28 Sep 2023 09:20:22 -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 26A0C858280; Thu, 28 Sep 2023 13:20:22 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F1B231054FC3; Thu, 28 Sep 2023 13:20:21 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id DAE5721E6911; Thu, 28 Sep 2023 15:20:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907225; 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=uALX7FwbfXzQfp3EH9ucV/fvop/MkQ+iJY+cbp+0GRo=; b=B8A1ro4rLLisY7aiTsZidbN4QA1evKFsuXZnB+FKmq3B8oDbhbjQo+ICgN0smLgjN/PvDR /l9KKJNwocy+5n8OJEbqeiTm3B1HTa0CA+roocYv3tucgEt++C5prSQ6a8mtwRosnmfdyz 5xN60kWFYDVb9zvqp/zJ+vuXTmqx6P8= X-MC-Unique: 789zOwwgMhqzvN1cVIqEmQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 09/53] migration/rdma: Fix qemu_rdma_accept() to return failure on errors Date: Thu, 28 Sep 2023 15:19:35 +0200 Message-ID: <20230928132019.2544702-10-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 1695907409223100001 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 Reviewed-by: Juan Quintela --- migration/rdma.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 0e991175f9..94b828b45d 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 Wed May 15 18:29:22 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=1695907657; cv=none; d=zohomail.com; s=zohoarc; b=SYFg0LbukDySMbhrgT4TzT6rnmz/7R0UG+DzuIMyori5vqwgIUswMjozWPmKK8wbIfm48v1C2FTSXm9ZBPlm9dIaBk97Sh4OCS8hR/xsuXP/BZOcNpS9lDH6w472f00Q3OH/m7VSMHJsL2kOSTnb4+Cs7nQ2/e4NU3gBN+avgk4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907657; 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=h+IRfxaI2DhK3uI/sbN9+YgEC2D0NOSgYOhqn4uSoFA=; b=USVRyup5iShm00alr1FyT5msFZtx0nX7D3gO2x6rWjduLUAdayZJptAi0SwwjyxCKv5A24l3jyTdJpwSI4wSrV98xT63xHFJDhATy82x8hRyGhknixlqab4dE4kISiGHhKHXMighQIj34ZGm/qK1Xu03oyEg6uvp94jBBKTIgpQ= 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 1695907657089628.8675210883018; Thu, 28 Sep 2023 06:27:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwn-0003gn-7Z; Thu, 28 Sep 2023 09:20:53 -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 1qlqwO-0003Ps-JB for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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 1qlqwL-00087r-Am for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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-116-vW3wOWGQOwiLOpNPLP3TRQ-1; Thu, 28 Sep 2023 09:20:22 -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 275BD802C1A; Thu, 28 Sep 2023 13:20:22 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 033042026D4B; Thu, 28 Sep 2023 13:20:22 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id DDDD521E6912; Thu, 28 Sep 2023 15:20:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907224; 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=h+IRfxaI2DhK3uI/sbN9+YgEC2D0NOSgYOhqn4uSoFA=; b=UTl1JAyVkh5ZpoVbziBl7TGSlE+GmTcyIHwYl4+c3IyflG48YHZjCW3FLtGS2LzQfwc1kc TNz3FABYGgrcypmF1CMYc8Kr1yC8avMBsCNBi4E7RN9I2cO2S7d1JShH4M/VpJhzBd7no2 qBe53BKLq8MJrEoPViBIdwJkc3euIo8= X-MC-Unique: vW3wOWGQOwiLOpNPLP3TRQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 10/53] migration/rdma: Put @errp parameter last Date: Thu, 28 Sep 2023 15:19:36 +0200 Message-ID: <20230928132019.2544702-11-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 1695907659020100005 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 Reviewed-by: Juan Quintela --- migration/rdma.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 94b828b45d..176fe1a5f1 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 Wed May 15 18:29:22 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=1695907385; cv=none; d=zohomail.com; s=zohoarc; b=SLbVEcJHWULi/6641CpWMN2N5ZTwCDB7LZ7E58U6V59qjfR18srJ1t1MGsTVmbQqpjweXKnPOVUFEOWDQgOzWNrkbBxOvWNNN9GECnvx6QHNpl8P7Qr417/iKTKrdDPrJFukY7cX5fZZbVPpVr5bWH251NJwYoV4JcftOVVNzLE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907385; 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=lxK3GnnQQW4HaZmTR/EwmYQ8JkLBURQkkY1XY0uKZmU=; b=hLrnRte/3Tv2RPboAMmsPJtBNinMZ0CbzRCYaunngOWcuXJEJ0rss77u/JwwZfflryhhNwLSq09V8/yBCHybeNWHaqNJNdEx535rifzDEoo5t0hN9aWU/DQDiiNuAJczxzEhnmd+xyuvPTSSGFaHXecZNYFsEPjVUtwXLXgdOWw= 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 169590738542896.96360188258461; Thu, 28 Sep 2023 06:23:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwz-0003po-1z; Thu, 28 Sep 2023 09:21: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 1qlqwb-0003bI-U0 for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:42 -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 1qlqwP-0008GC-Ca for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:41 -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-318-36YkolvgNKu_xazYt7c0rA-1; Thu, 28 Sep 2023 09:20:22 -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 292AB1C00D19; Thu, 28 Sep 2023 13:20:22 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0698E2026D68; Thu, 28 Sep 2023 13:20:22 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id E0E4521E6913; Thu, 28 Sep 2023 15:20:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907227; 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=lxK3GnnQQW4HaZmTR/EwmYQ8JkLBURQkkY1XY0uKZmU=; b=OmEn99eCwBgSG6C2LvxOK2/pGhHtTtgeSt3SSt4mhLvhoT3nKQDIG5HkIYNE1FYmABc/t/ TJ9RRBllyM5iyKk9l7Y4ppBbbNr7p1YMzKwSlfKLXskmfohug9zMUrWwnt/eddOtIwAM5q NiHdYdDYqO5YNDclCCApD3F6wnFxgfQ= X-MC-Unique: 36YkolvgNKu_xazYt7c0rA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 11/53] migration/rdma: Eliminate error_propagate() Date: Thu, 28 Sep 2023 15:19:37 +0200 Message-ID: <20230928132019.2544702-12-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: 1695907386256100013 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 Reviewed-by: Juan Quintela --- migration/rdma.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 176fe1a5f1..380d550229 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 Wed May 15 18:29:22 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=1695907288; cv=none; d=zohomail.com; s=zohoarc; b=jQX+Lx75waANlNygYAfHTMA3cLtpVNtRJ9SB12pHrvhh3q8rRuXqN9YRaf2egmfPpVx5+a1gN5gV1HBrO0RzHZ1JAKSFyLQvNT2rdHjacHN1d1jqF7Fm5NB73iabf0KTuryafHqMB8wGmLzt8m6bti11oVXvoBmHIPT2dOCnLlQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907288; 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=bYHAUV1MXfGP0keAZkCToo4a7D7vXMfuOxjiDbfzpYg=; b=ecucfo3Qnr8hv5FSj68O/fYM0oe88uW8fBg5F96YBxyofA9ZlQ/edlWxwoTsPpWYNWAzYRig+knku8LmV6kcrPHvvMG6bnb/S3MSSQ0FcTGkeoZli3I66vskuTVLPI2pUQJkvtLJSFMW3nv3laLbai4drHhSaxX1ICQWfYQH5aM= 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 1695907288369678.0100258095781; Thu, 28 Sep 2023 06:21:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwZ-0003ZV-4r; Thu, 28 Sep 2023 09:20: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 1qlqwO-0003Py-QO for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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 1qlqwL-00087s-9D for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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-116-sllAm3XaMqWjWX1I4sqi4g-1; Thu, 28 Sep 2023 09:20:22 -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 2DDA5280A9D3; Thu, 28 Sep 2023 13:20:22 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0B7D840C200A; Thu, 28 Sep 2023 13:20:22 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id E3C0521E6914; Thu, 28 Sep 2023 15:20:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907224; 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=bYHAUV1MXfGP0keAZkCToo4a7D7vXMfuOxjiDbfzpYg=; b=XkanS1A+NW33BOtPPgc+CdJIYErGyfXvtnjBTmGpxmF5Wgp/TDZjFhzcrb5MlPgxI10NbG oT1vtS7yyJ4FH9pRLuIkZs9uMi2GY6GmaSvigLlfPf+Fru8YBpKq0ACjuvNVB6KUHBTKmm N8Z+6aRMPHIlxjlWOJtjn9V6jZ7TOAM= X-MC-Unique: sllAm3XaMqWjWX1I4sqi4g-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 12/53] migration/rdma: Drop rdma_add_block() error handling Date: Thu, 28 Sep 2023 15:19:38 +0200 Message-ID: <20230928132019.2544702-13-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: 1695907290045100003 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 Reviewed-by: Juan Quintela --- migration/rdma.c | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 380d550229..f2f811ace2 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 Wed May 15 18:29:22 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=1695907525; cv=none; d=zohomail.com; s=zohoarc; b=QghxU7oY/u17vXn3j5EcRuP+wyO3h48RmoLIVwp+MyssGys/kjb/pVLEVMIHwG7f//UO6FZ82yRl6UAN4Uo8JPzj6oVEdhuKjLbWBWoMhqGEEPwnxCeHB6KicFi7/66swSKCrt6kFjAKXNyQdg+TVbCWeX8czbmDwsso+x/hROI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907525; 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=yWxxOr88GmOzOaZGiZyjQenriNwOxYe0jtgr8xtVOEE=; b=Y4JTMT8jt03OcPN2FYlunNIjyJU+vmt60hduCbpV5891KCqSwtCFZhGpY5ReuRB3yH9oDZiz0UpKNCpnddOeDteKuFAaLTX1hH7MI1tkhXj0oJ5ccdBB4m/C053T+ruQy7PA7smPOt3OB8dosv6cSNT8N7VQBg9llsGkBAF1eho= 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 169590752542571.96637298546261; Thu, 28 Sep 2023 06:25:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwp-0003gx-G0; Thu, 28 Sep 2023 09:20:55 -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 1qlqwO-0003Pz-UW for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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 1qlqwL-00087o-9Q for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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-120-wLXKOnWIN7SioNk0kq6K7A-1; Thu, 28 Sep 2023 09:20:22 -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 3CC91280A9C3; Thu, 28 Sep 2023 13:20:22 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1A58510F1BE9; Thu, 28 Sep 2023 13:20:22 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id E698E21E6915; Thu, 28 Sep 2023 15:20:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907224; 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=yWxxOr88GmOzOaZGiZyjQenriNwOxYe0jtgr8xtVOEE=; b=gt3lBivAmHcDtcioAjzm7XoBcoYGKOU1jBYEZXNfTmjamPBrYh7f7MHCQef71gIvoZZyRU whbEAquJUPa5Pq9IY+JTgk0+qkMLFVUPfDMe+96vGwLO8pttDtgMf+ayMN1iuFebItI3Hp 6zvg4RXjzbAslqPCcVIayEX8rLt1CQg= X-MC-Unique: wLXKOnWIN7SioNk0kq6K7A-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 13/53] migration/rdma: Drop qemu_rdma_search_ram_block() error handling Date: Thu, 28 Sep 2023 15:19:39 +0200 Message-ID: <20230928132019.2544702-14-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: 1695907527059100002 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 Reviewed-by: Juan Quintela --- migration/rdma.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index f2f811ace2..7bea4d3947 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1231,15 +1231,13 @@ static int qemu_rdma_reg_whole_ram_blocks(RDMAConte= xt *rdma) * * Once the block is found, also identify which 'chunk' within that * block that the page belongs to. - * - * 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 +1249,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 +2317,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 Wed May 15 18:29:22 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=1695907484; cv=none; d=zohomail.com; s=zohoarc; b=C9yamTdlkf4lf8mOo1N82W4XpTieNK3LmrP20P5XCjKZ2hLdrHZKRcIAwFZSiXFlDgqDTiOsif5rEUrTBQCtV6/pvQkc2wZekvKfut/Xf8vNyAA+BYnZIe5z1JNTd2ZR8h/+qCd20HaePuelH6eKVWiE0qps+5hfO2HruJnrDZ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907484; 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=FEnX5LSTQ17/Hg9gfdq1/pjzHw7sZILu+IYLdvjzMO8=; b=bxrU6gTCD5xrCiSyH/W6qAK4W+k3a1V1ENTk8xVKsDmdia1E8XmmNx5BpDurtgtxOYCGpY0dpZB4USJodvyGAEjKTOFYF8H6gN2622/e6M3nA+Xx2Pr6DA7/HLdg52VbJ3rZjsXvbhqwMzncay5zrDq/oxqyQy12P62AMO9M+jw= 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 1695907484597642.8777430781828; Thu, 28 Sep 2023 06:24:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwt-0003k4-JK; Thu, 28 Sep 2023 09:20:59 -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 1qlqwW-0003W4-7R for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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 1qlqwM-0008Bf-Rn for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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-483-pFVWDaoYMzKMdD7Nsc8Z7g-1; Thu, 28 Sep 2023 09:20:22 -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 43254280A9C4; Thu, 28 Sep 2023 13:20:22 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 20AD2C154CA; Thu, 28 Sep 2023 13:20:22 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id E9AE621E6916; Thu, 28 Sep 2023 15:20:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907226; 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=FEnX5LSTQ17/Hg9gfdq1/pjzHw7sZILu+IYLdvjzMO8=; b=f29JgvwpYsncjmze3UUCsTZGSg3pok5o0sCxw1Vvfw7AVHCPNAMkdIjfBMfarqGWpGWrOv CjdCeeNoY2HeWmy5EsKs5sJ4u1KWA05M798J7L6AZiYOSebA2n3EykefRSo9njFZmNwKxp u6OnQjCV/ZVddcEDQ175dXcU1eLMlHw= X-MC-Unique: pFVWDaoYMzKMdD7Nsc8Z7g-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 14/53] migration/rdma: Make qemu_rdma_buffer_mergeable() return bool Date: Thu, 28 Sep 2023 15:19:40 +0200 Message-ID: <20230928132019.2544702-15-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=no 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: 1695907485474100001 Content-Type: text/plain; charset="utf-8" qemu_rdma_buffer_mergeable() is semantically a predicate. It returns int 0 or 1. Return bool instead, and fix the function name's spelling. Signed-off-by: Markus Armbruster Reviewed-by: Fabiano Rosas Reviewed-by: Li Zhijian Reviewed-by: Juan Quintela --- migration/rdma.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 7bea4d3947..73dd34d8f3 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -2244,7 +2244,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_mergeable(RDMAContext *rdma, uint64_t offset, uint64_t len) { RDMALocalBlock *block; @@ -2252,11 +2252,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]); @@ -2264,29 +2264,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 /* @@ -2309,7 +2309,7 @@ static int qemu_rdma_write(QEMUFile *f, RDMAContext *= rdma, int ret; =20 /* If we cannot merge it, we flush the current buffer first. */ - if (!qemu_rdma_buffer_mergable(rdma, current_addr, len)) { + if (!qemu_rdma_buffer_mergeable(rdma, current_addr, len)) { ret =3D qemu_rdma_write_flush(f, rdma); if (ret) { return ret; --=20 2.41.0 From nobody Wed May 15 18:29:22 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=1695907388; cv=none; d=zohomail.com; s=zohoarc; b=a2XcA49NiH+YaoVR41V6LWaUcnZiHE1yKCLPb4XUsrLH3ED8ULyReiAfU3HWkndP/27lbBQOQg2k+90oxmSJ2w7WHlflWg1FWrfbKEEKhfO2JfOTdcM291PYjS9CdHvGk8lB14GESTYWDMTogr2LBdR2SCA+LFF+akATkx38t/Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907388; 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=IC8hVAkFR7IaWFx2moP0xm/wKH/XLuUBX96s0XuZV2w=; b=jZvCNSa492iVuSbiAtpNgePBEI733hPAeDpIVr7jdP3swzyuwoCDiZPOVUBW1qPo4lyaA8NjZJ2cNc2Srf5lq5opXcCj8RB3+T2AaEBEXonElfeiI7lueSTq0ZKx1uMNeXWiQqaiZ0nzWBx1w9ITQDA2ZOuHAwlfM7Fw//V5Yqo= 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 1695907388092195.11980854832473; Thu, 28 Sep 2023 06:23:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwk-0003ez-Ok; Thu, 28 Sep 2023 09:20:50 -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 1qlqwb-0003bE-9v for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:42 -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 1qlqwP-0008GI-BV for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:40 -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-386-DZSz9mR6PqWngfZcumbgaw-1; Thu, 28 Sep 2023 09:20:23 -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 1602C85A5BD; Thu, 28 Sep 2023 13:20:23 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E816B492C37; Thu, 28 Sep 2023 13:20:22 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id EC94821E691A; Thu, 28 Sep 2023 15:20:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907228; 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=IC8hVAkFR7IaWFx2moP0xm/wKH/XLuUBX96s0XuZV2w=; b=PNhxE11hzvFfgzKj3g8KHtrMWsqQnO5Zf5I1ieCOZekI0GkMWLhjp7PTOOlgVJHWD9bV6I QrpVvKpV0HFLlsy2JEGq5ayefzo0XWHzl08q4UcQj85nQSL/ODD9/KFl9wz2rm3GY+z6Mz 8aWSUT6rTwT+DDfwcnfZLkiWArxx+ww= X-MC-Unique: DZSz9mR6PqWngfZcumbgaw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 15/53] migration/rdma: Use bool for two RDMAContext flags Date: Thu, 28 Sep 2023 15:19:41 +0200 Message-ID: <20230928132019.2544702-16-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 1695907388342100001 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 Reviewed-by: Juan Quintela --- migration/rdma.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 73dd34d8f3..28097ce604 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 Wed May 15 18:29:22 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=1695907590; cv=none; d=zohomail.com; s=zohoarc; b=QaZhydj3uCiiaadIwNxMXkW7+N/oe9gcdUYd//vkfXTebwI1etBg22Wwjo4e+t0reGkecMhB1qjBMiVgOpUxSiMROcx2ve7XoXFSl/5TSdxaRXU5YBrVDjgtWOrQPcFrVhlNW7c4YyMoTe6u9B9crY18kH4Oi4i2dygR9QcpElI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907590; 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=BU0uqGbP8qq4nNLIZgnbAmU0nErX6Kb3gxdo8hQggZ8=; b=KrWKO2tT9Ppnnvvm1lZ6cHVCepyCoplh0HF39Mut8XTOo58IBOpq3Ebv5skhYIzbpC6W5KCIhkjHx13WL6DRIkNa6hqO7R9CjWKVImkmmQI+sFlC3qr83dt2txbxjk+slp0yUg0sr5Um5ApSF0TXpstvQE7zJtTwAHCBl2nOjK4= 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 1695907590357159.44637703156855; Thu, 28 Sep 2023 06:26:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqww-0003n5-HL; Thu, 28 Sep 2023 09:21:02 -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 1qlqwW-0003Vw-0y for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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 1qlqwN-0008Ef-Jt for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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-164-YQtk4SzeML6LczlCsMGKvg-1; Thu, 28 Sep 2023 09:20:23 -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 32961381459B; Thu, 28 Sep 2023 13:20:23 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E8D27167F8; Thu, 28 Sep 2023 13:20:22 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id EF71921E691B; Thu, 28 Sep 2023 15:20:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907226; 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=BU0uqGbP8qq4nNLIZgnbAmU0nErX6Kb3gxdo8hQggZ8=; b=PJ8yC15SotzTn80zoNi+LKjQUBijp0S29AgtJ8boeWUGyDtPgPKy69DwfaZ+EKAR002Pmd ALoI78VM5xIw6bkFBA3+QFdkdXl1TdqCLKMa2KVHqcHfrHqRhcgWlFeRSDvHt8hHaIksUz 1+vdSDvTdaL0caq2oOzkhU0p5FpYY/o= X-MC-Unique: YQtk4SzeML6LczlCsMGKvg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 16/53] migration/rdma: Fix or document problematic uses of errno Date: Thu, 28 Sep 2023 15:19:42 +0200 Message-ID: <20230928132019.2544702-17-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: 1695907591809100013 Content-Type: text/plain; charset="utf-8" We use errno after calling Libibverbs functions that are not documented to set errno (manual page does not mention errno), or where the documentation is unclear ("returns [...] the value of errno on failure"). While this could be read as "sets errno and returns it", a glance at the source code[*] kills that hope: static inline int ibv_post_send(struct ibv_qp *qp, struct ibv_send_wr *= wr, struct ibv_send_wr **bad_wr) { return qp->context->ops.post_send(qp, wr, bad_wr); } The callback can be static int mana_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr, struct ibv_send_wr **bad) { /* This version of driver supports RAW QP only. * Posting WR is done directly in the application. */ return EOPNOTSUPP; } Neither of them touches errno. One of these errno uses is easy to fix, so do that now. Several more will go away later in the series; add temporary FIXME commments. Three will remain; add TODO comments. TODO, not FIXME, because the bug might be in Libibverbs documentation. [*] https://github.com/linux-rdma/rdma-core.git commit 55fa316b4b18f258d8ac1ceb4aa5a7a35b094dcf Signed-off-by: Markus Armbruster Reviewed-by: Juan Quintela Reviewed-by: Li Zhijian --- migration/rdma.c | 45 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 28097ce604..bba8c99fa9 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -853,6 +853,12 @@ static int qemu_rdma_broken_ipv6_kernel(struct ibv_con= text *verbs, Error **errp) =20 for (x =3D 0; x < num_devices; x++) { verbs =3D ibv_open_device(dev_list[x]); + /* + * ibv_open_device() is not documented to set errno. If + * it does, it's somebody else's doc bug. If it doesn't, + * the use of errno below is wrong. + * TODO Find out whether ibv_open_device() sets errno. + */ if (!verbs) { if (errno =3D=3D EPERM) { continue; @@ -1162,11 +1168,7 @@ static void qemu_rdma_advise_prefetch_mr(struct ibv_= pd *pd, uint64_t addr, ret =3D ibv_advise_mr(pd, advice, IBV_ADVISE_MR_FLAG_FLUSH, &sg_list, 1); /* ignore the error */ - if (ret) { - trace_qemu_rdma_advise_mr(name, len, addr, strerror(errno)); - } else { - trace_qemu_rdma_advise_mr(name, len, addr, "successed"); - } + trace_qemu_rdma_advise_mr(name, len, addr, strerror(ret)); #endif } =20 @@ -1183,7 +1185,12 @@ static int qemu_rdma_reg_whole_ram_blocks(RDMAContex= t *rdma) local->block[i].local_host_addr, local->block[i].length, access ); - + /* + * ibv_reg_mr() is not documented to set errno. If it does, + * it's somebody else's doc bug. If it doesn't, the use of + * errno below is wrong. + * TODO Find out whether ibv_reg_mr() sets errno. + */ if (!local->block[i].mr && errno =3D=3D ENOTSUP && rdma_support_odp(rdma->verbs)) { access |=3D IBV_ACCESS_ON_DEMAND; @@ -1291,6 +1298,12 @@ static int qemu_rdma_register_and_get_keys(RDMAConte= xt *rdma, trace_qemu_rdma_register_and_get_keys(len, chunk_start); =20 block->pmr[chunk] =3D ibv_reg_mr(rdma->pd, chunk_start, len, acces= s); + /* + * ibv_reg_mr() is not documented to set errno. If it does, + * it's somebody else's doc bug. If it doesn't, the use of + * errno below is wrong. + * TODO Find out whether ibv_reg_mr() sets errno. + */ if (!block->pmr[chunk] && errno =3D=3D ENOTSUP && rdma_support_odp(rdma->verbs)) { access |=3D IBV_ACCESS_ON_DEMAND; @@ -1408,6 +1421,11 @@ static int qemu_rdma_unregister_waiting(RDMAContext = *rdma) block->remote_keys[chunk] =3D 0; =20 if (ret !=3D 0) { + /* + * FIXME perror() is problematic, bcause ibv_dereg_mr() is + * not documented to set errno. Will go away later in + * this series. + */ perror("unregistration chunk failed"); return -ret; } @@ -1658,6 +1676,11 @@ static int qemu_rdma_block_for_wrid(RDMAContext *rdm= a, =20 ret =3D ibv_get_cq_event(ch, &cq, &cq_ctx); if (ret) { + /* + * FIXME perror() is problematic, because ibv_reg_mr() is + * not documented to set errno. Will go away later in + * this series. + */ perror("ibv_get_cq_event"); goto err_block_for_wrid; } @@ -2199,6 +2222,11 @@ retry: goto retry; =20 } else if (ret > 0) { + /* + * FIXME perror() is problematic, because whether + * ibv_post_send() sets errno is unclear. Will go away later + * in this series. + */ perror("rdma migration: post rdma write failed"); return -ret; } @@ -2559,6 +2587,11 @@ static int qemu_rdma_connect(RDMAContext *rdma, bool= return_path, ret =3D rdma_get_cm_event(rdma->channel, &cm_event); } if (ret) { + /* + * FIXME perror() is wrong, because + * qemu_get_cm_event_timeout() can fail without setting errno. + * Will go away later in this series. + */ perror("rdma_get_cm_event after rdma_connect"); ERROR(errp, "connecting to destination!"); goto err_rdma_source_connect; --=20 2.41.0 From nobody Wed May 15 18:29:22 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=1695907400; cv=none; d=zohomail.com; s=zohoarc; b=Pg52Gvz5pe2OnqStlUPyM96bIgR/34UixZxJ92Pslzh+1WpalsD58DaDyi6I+nX+WofIj1yIXNjpAfb2J2+JEVn4NozYXbQTYluhwile72EL8Q/hW563li2206SBCrlECWl1y4asCNseYPF8+/ObMAwybohMRkGVT3a4AhaBMoo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907400; 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=Xhv0iR70EFAMzLYG63rT+nkJ2YI2Zd9BNqX1D8yfljI=; b=aP/VNRY48f8GmiKgEjM7NTsU38tY4ZKfmTy6k0u2IIH3zgjlgEh4toTSfQHVK3z2eJWFSsgONBGTVe7qxPnZ9iGkMqUwFQpnWV5sVChORtp98Cy+h7LYQIZSZ3/Vwz2i8lUeYEuoZPaxOXdZjmJ7xZ514ntLe/nGduApvH+43SY= 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 1695907400286877.9087564224678; Thu, 28 Sep 2023 06:23:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwt-0003k1-8D; Thu, 28 Sep 2023 09:20:59 -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 1qlqwZ-0003a4-Bk for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:39 -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 1qlqwO-0008Fh-JG for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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-164-BmD9HoStNEK7lYPqV1uT1g-1; Thu, 28 Sep 2023 09:20:23 -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 32CFD38145A9; Thu, 28 Sep 2023 13:20:23 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E970B215670B; Thu, 28 Sep 2023 13:20:22 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id F273E21E691C; Thu, 28 Sep 2023 15:20:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907227; 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=Xhv0iR70EFAMzLYG63rT+nkJ2YI2Zd9BNqX1D8yfljI=; b=JBu/dLhiqlCPlXRyj+Rr3CEeEDlBGkGufdETYzYAiqDSjBbFFysb4QkAhPiXxk6rIKvdRo 3TsN1s8k5k87YFix2K7Pq8I4bQUcu2X3IpYgO7KlNhBnaD60mSyiC/skNFpgfQuGbwer1O B+P2zDZVpQ8Rmnaalpxw1vqoZaxjKA8= X-MC-Unique: BmD9HoStNEK7lYPqV1uT1g-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 17/53] migration/rdma: Ditch useless numeric error codes in error messages Date: Thu, 28 Sep 2023 15:19:43 +0200 Message-ID: <20230928132019.2544702-18-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: 1695907401034100039 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 rdma_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 Reviewed-by: Juan Quintela --- migration/rdma.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index bba8c99fa9..0d2d119e6a 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1476,7 +1476,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 @@ -2215,7 +2215,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 @@ -2800,7 +2800,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 @@ -2820,7 +2820,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 @@ -2910,7 +2910,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 @@ -3253,7 +3253,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 @@ -3280,7 +3280,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 @@ -3295,7 +3295,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 @@ -3470,13 +3470,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 Wed May 15 18:29:22 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=1695907282; cv=none; d=zohomail.com; s=zohoarc; b=fYEOSV1td322CRgxddi9bFv4ylrakTAsum+gWJalg/PX1RrW/EWA+OOV4Kh0D7YVzOr4d3JVNcZ0A2NJBK+C8tZS5fu/PNPoKn9m0VE5WtzYsifbvMNtBhTkb5gvgOp2r9lzF9rzcpe3716wzuWxKx20nVEkYSKxKIFo2bW9HrI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907282; 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=fSeyBBF83WKQT61d7meoz63CWSVi3+abXWDIn7AgGhU=; b=eI3TQrdXaRHCfAyaDVhENaAXflirO1Fki/wq/2MwIzwT0xUzS3FUL36xeD3NCe2Yptz2Vgp2/gbHDpFsWWLugMZWUw13lckglyqFcVdfaMW4QyJckSc1yyYWPYpGim46S2Wu33A64fGnbAdlipW4tqFOMQQeBj9cOtMDSvRjoUk= 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 1695907282955101.35519607638287; Thu, 28 Sep 2023 06:21:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwf-0003du-7o; Thu, 28 Sep 2023 09:20: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 1qlqwQ-0003Rk-Gn for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:31 -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 1qlqwL-00088n-Kq for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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-528-S0P1pZRrN5eUHxMY2lJWZg-1; Thu, 28 Sep 2023 09:20:23 -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 1B185858F1B; Thu, 28 Sep 2023 13:20:23 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ECBFC2156711; Thu, 28 Sep 2023 13:20:22 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 0149221E6880; Thu, 28 Sep 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907225; 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=fSeyBBF83WKQT61d7meoz63CWSVi3+abXWDIn7AgGhU=; b=fsSxO5oylVgu8P1UE3OWdAMN7E8mQ08ny0ej36gnM7KUMIbUsron0Cmm2NEgse9uVFcKCh 4lFvgRLrex/tj/uqNzu6vUs2aHo68L6vshg+h0fLTwYUF90OFsGZI4up4tYBPEOWeq38mH haRYxw5+HcDvVR1P1mzACqrnFl0Focc= X-MC-Unique: S0P1pZRrN5eUHxMY2lJWZg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 18/53] migration/rdma: Fix io_writev(), io_readv() methods to obey contract Date: Thu, 28 Sep 2023 15:19:44 +0200 Message-ID: <20230928132019.2544702-19-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 1695907284351100007 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 Reviewed-by: Juan Quintela --- migration/rdma.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 0d2d119e6a..fb89b89e80 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -2791,7 +2791,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 @@ -2877,7 +2881,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 Wed May 15 18:29:22 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=1695907430; cv=none; d=zohomail.com; s=zohoarc; b=WbmAw6DS9ejKWLiiijshQlldAT4yF18x1MAhiiQ7+UO72Rp2H6foyeuw0rEwWEdUEby8n2JojbHyw39FsUHvi7DpoUWzqnD8eiabsQYITL55ORfeflnaA2U7O/MdGBJZWMfjrVq1xNCfKHLRIUp0p0YtXA7xTijxTT4TIeSVa2Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907430; 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=AhiJD5fE0yfiatKoVxJaZ5ImEzU4sMv5Nv5hDwgJpSg=; b=lJhGuGWwz7Yxmm5oEk0hmHYrCmd46XvZDzgWA/ACFdPAl8D4d5IzCFT0u3N7Ow3AlHJqyS7RVznqnjk4xGZnOVte8vAK3HBncy9QflVIGlYfklEwGXvm08NxoVK9ycVxBV6D3JajZFw/+YLsmxlfesqLfa6JfWYeLJuDBva507w= 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 1695907430244913.0691874449928; Thu, 28 Sep 2023 06:23:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwp-0003gv-3S; Thu, 28 Sep 2023 09:20:55 -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 1qlqwS-0003TO-3s for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:33 -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 1qlqwM-0008A3-0q for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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-154-TiXj4_btM12ZswfJSd90GQ-1; Thu, 28 Sep 2023 09:20:23 -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 217461C05129; Thu, 28 Sep 2023 13:20:23 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F1D5814171B6; Thu, 28 Sep 2023 13:20:22 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 0441221E6882; Thu, 28 Sep 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907225; 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=AhiJD5fE0yfiatKoVxJaZ5ImEzU4sMv5Nv5hDwgJpSg=; b=a7Wz8CWPyyty8NQTGU8f0BG65sERkzn08Y9Z1buDms9V5XfN0hNdOhh98jO8yny6n0W0hD FtZOjUXIKiSrK5NTlxEBpFaUr3+Okwqp/MAfMwxwIEp6uWYOGnOzwmSp83rr6t+K7Yv3PB rdvlJefSGn5Ow1fAXSh3lekcSeTuE4k= X-MC-Unique: TiXj4_btM12ZswfJSd90GQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 19/53] migration/rdma: Replace dangerous macro CHECK_ERROR_STATE() Date: Thu, 28 Sep 2023 15:19:45 +0200 Message-ID: <20230928132019.2544702-20-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: 1695907432534100003 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 Reviewed-by: Juan Quintela --- migration/rdma.c | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index fb89b89e80..912cea6ad9 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; @@ -3250,7 +3248,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 @@ -3566,7 +3567,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 { @@ -3870,6 +3874,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; @@ -3881,7 +3886,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); @@ -3912,7 +3920,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 Wed May 15 18:29:22 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=1695907551; cv=none; d=zohomail.com; s=zohoarc; b=gK8NOwmIP3Jy9y9SExVYsAUkMs+JeST9JMg7BwparICNiHzFm26VztqmCj45m+aftnLU1WlhxKT3FtCOQOgNKN8/IxLbMvDxkHs/Mu/xPNkDvgTpgIry7KmJCDr9y0wuDSOWlCIBh2SRxWQlxPf+q/0HNBHA/aPC/ptAZpy3EVU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907551; 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=ehaLRGk4O96UuIOdMGOFYwXtp51PGkxsY9IwmDqAJgU=; b=eSwXQ4a4pI0W0YHdV+RmnkEEijn+BdV+yeRzVaQYUucW5JS98XHHVS158MgJpoSOfVYmu61DMdJk4JGWtXR1BdISCwbIkLbvy/GGxnG2ZxDW1obYa6hqADYxLQ/0dIWjFA9KnqRXRUu2ok98bZF6aMhPOzxC93ajsS6hWxvGVC8= 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 1695907551776876.9990074726451; Thu, 28 Sep 2023 06:25:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwx-0003nu-K5; Thu, 28 Sep 2023 09:21:03 -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 1qlqwW-0003Xl-SD for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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 1qlqwN-0008Ej-L4 for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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-191-PLbPkJuVO7OfZZy4_osMRA-1; Thu, 28 Sep 2023 09:20:23 -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 24A77185A790; Thu, 28 Sep 2023 13:20:23 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 02C6714171CA; Thu, 28 Sep 2023 13:20:23 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 071F721E6883; Thu, 28 Sep 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907226; 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=ehaLRGk4O96UuIOdMGOFYwXtp51PGkxsY9IwmDqAJgU=; b=QVONLp5DrpN3l2ll1rLwY5KvfPvUqv1GZLqRgPMNfcsMpvflN+rkRLTOP6WOTrWQ3MXPAr jRGM3R04jmP8Gnxpdrxdx5ZXLDTqbxHvjtQW+XVcSCErPDAyxOkXBhdtoaxEGXebi1DWpV kAHn2BJBUYFn7xpRDhKQjhv1VVKW9J0= X-MC-Unique: PLbPkJuVO7OfZZy4_osMRA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 20/53] migration/rdma: Fix qemu_rdma_broken_ipv6_kernel() to set error Date: Thu, 28 Sep 2023 15:19:46 +0200 Message-ID: <20230928132019.2544702-21-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 1695907553076100003 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 Reviewed-by: Juan Quintela --- migration/rdma.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/migration/rdma.c b/migration/rdma.c index 912cea6ad9..18905082a8 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -861,6 +861,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 Wed May 15 18:29:22 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=1695907319; cv=none; d=zohomail.com; s=zohoarc; b=g2P6SSlEQ9AIsGLTXioSP+bjQGTF0di5sCp/OjQf3T5bey2mfEqugFP7ovFivDAXtaT/1oh9Xrl5wVAaU+ylnEyv/9YRDarsukUkQVcm72mspDKYNqG06FOY/7TFxaYwOfF43O+HTlemUefHI8Z3CGtJi+Xivtzab1LmazaJPPg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907319; 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=gbjuCNFOlIyWuq7l+tpgIu35HIiBknqd5AnEOxYDjSQ=; b=O9h8cz5R1zLSJDkZPrprPaEO17L2cI8B/RbfxPjmX9cBWlhq/OfnW6PKvLzbCnSpvG/lpx/JF5sOqH0SLw6SU2ZBTQsMqmXEq+tlPGTLCH19qjYsmDfgAXkIIZaxtKch7yIDNJe9Q4vtcHdJV4/T2/mCReeGOFtAGBNDNBupSyo= 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 1695907319755372.8565611492113; Thu, 28 Sep 2023 06:21:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqws-0003jn-Ka; Thu, 28 Sep 2023 09:20:58 -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 1qlqwW-0003Wl-CG for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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 1qlqwN-0008F2-LD for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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-154-XGwfwOQgNsOUM_pdNvJtjQ-1; Thu, 28 Sep 2023 09:20:23 -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 2EB64858F1C; Thu, 28 Sep 2023 13:20:23 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0C9322026D4B; Thu, 28 Sep 2023 13:20:23 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 09F3821E6884; Thu, 28 Sep 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907227; 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=gbjuCNFOlIyWuq7l+tpgIu35HIiBknqd5AnEOxYDjSQ=; b=MdEBLaCMwa6LodXZP4vmH4KLi3PRyfSDAtjk27lG8kSo52wJBPi9MSoprrowQ/4fkqJ5Sc mJ3vp+a81ZwGinwaDyqopJTBdFfKDa1d74iW5MRQylaPQNmp4M4FMPbsbEjxMiGdy+UUeU mpClAVr2RIxIF/9b6AgsweizNb4yDko= X-MC-Unique: XGwfwOQgNsOUM_pdNvJtjQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 21/53] migration/rdma: Fix qemu_get_cm_event_timeout() to always set error Date: Thu, 28 Sep 2023 15:19:47 +0200 Message-ID: <20230928132019.2544702-22-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 1695907320852100001 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: Peter Xu Reviewed-by: Li Zhijian Reviewed-by: Juan Quintela --- migration/rdma.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 18905082a8..1a0ad44411 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -2535,7 +2535,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; @@ -2585,6 +2589,9 @@ static int qemu_rdma_connect(RDMAContext *rdma, bool = 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) { /* @@ -2593,7 +2600,6 @@ static int qemu_rdma_connect(RDMAContext *rdma, bool = return_path, * Will go away later in this series. */ 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 Wed May 15 18:29:22 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=1695907541; cv=none; d=zohomail.com; s=zohoarc; b=e9RdUH0JfYcwnZJSkMBLuePxCmCXYlrqF5Fe8P06Hh9+LnzsWDMj6m4HGDapdXV2MGKCO4ZGGMWJ6pv5BkALAMQEycY0pkSOWoy3gWO1jMJDnAP6gaVGxqB5CEK9VLLujZCCuaMdIAN+DBhHREcn6mepiJLoTjyO5a6dmzq1Gyk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907541; 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=6nItDBQipWI1KVfWI0FM3U4wxGX1WMpMYJQFIraiH60=; b=YY5UGwJYYtDv7OF7iXtqBeQqC23oB3hqF72lUxrX2nfrseEQsLExNmrs+113176vBbGHNg0I6QUD3DHShzg1mEQfj7+X9235q5eQokQmoCzYuaajhRMK5RXE89HTGEzjKDG9nlqasyvgtPTxTs9T1u2bp0YCale0ResCCdQ+FrI= 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 169590754135211.21509854199428; Thu, 28 Sep 2023 06:25:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqww-0003nN-Qt; Thu, 28 Sep 2023 09:21:02 -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 1qlqwb-0003bC-9C for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:42 -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 1qlqwP-0008G2-8x for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:39 -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-191-wzx2lZlHNfanOHaDYY7qkA-1; Thu, 28 Sep 2023 09:20:23 -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 37F7D18175A3; Thu, 28 Sep 2023 13:20:23 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 15D83492B16; Thu, 28 Sep 2023 13:20:23 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 0CED421E6885; Thu, 28 Sep 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907227; 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=6nItDBQipWI1KVfWI0FM3U4wxGX1WMpMYJQFIraiH60=; b=VnHIZFRjrCrr3ZgypZIaaXs47ODacngVXL+Min/MBPQR30zTA2vA2C4FCRaecHmhOWUN11 dSWMX53jubkF6NJ/qrTe3u0tUdafHuX0itSoJlz3epwNVl8TF3ZggWT2JghmzPB6rrrXzy FoCvh8823KjXnvBK34LWDvdItq2wtnU= X-MC-Unique: wzx2lZlHNfanOHaDYY7qkA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 22/53] migration/rdma: Drop dead qemu_rdma_data_init() code for !@host_port Date: Thu, 28 Sep 2023 15:19:48 +0200 Message-ID: <20230928132019.2544702-23-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 1695907542853100003 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 Reviewed-by: Fabiano Rosas Reviewed-by: Juan Quintela Reviewed-by: Li Zhijian --- migration/rdma.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 1a0ad44411..1ae2f87906 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -2747,25 +2747,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 Wed May 15 18:29:22 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=1695907471; cv=none; d=zohomail.com; s=zohoarc; b=WZVS4BC0Kl+czR4xISGpUesL+yZDaAz3cB07Stb+6VwYpQiw9TEuf/1ktCeofsVJqWhqGAUZ5s133p/g5bitxPd99aaQxBKeKkHjLedTPJ/t10UDf3nKjftw0ZvQoP1K/K+YLluJNHTIvB3BVhg02gLoyh49azJ9hk+OpXqjZU4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907471; 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=muVt9+mJK5tZ4PWTa88llBlGB24wRA8moVIF+LRy5u4=; b=RH08WeMJ3i77lm+0SP6yIDzwK3UmKB08dmioah7BQvqkUiHHzx/sRzuMBSgev/JR6nnAK/jQkjabdFJAIZyaZACKDkenvlHJz/A34mc90yml+y493lfPBA/qZekEp93ZrFkPryl4funBMkTi3nAPqzCRZC+4mY61XgLJcSVNsuc= 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 1695907471532933.9405326817753; Thu, 28 Sep 2023 06:24:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwi-0003eh-Ut; Thu, 28 Sep 2023 09:20: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 1qlqwZ-0003a6-CJ for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:39 -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 1qlqwO-0008Fd-9k for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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-530-2wNYGPSmMZ6WPNhGA2hhgQ-1; Thu, 28 Sep 2023 09:20:23 -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 55F47280A9D6; Thu, 28 Sep 2023 13:20:23 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 172CE1005E29; Thu, 28 Sep 2023 13:20:23 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 0FCFF21E6886; Thu, 28 Sep 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907227; 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=muVt9+mJK5tZ4PWTa88llBlGB24wRA8moVIF+LRy5u4=; b=dmzXkhRfiQJm3YCZuW9C4Kq/w3N9pe/rWOrSdkwvBxG6eiGgNgyc90GNwCc4Dxn4tTGTFs EUHaRdDLellTlQjho3NU0OpARfJAJFq+MXO6764OubZeeKi6wjVVOxS24TzWJZMuyF7vo4 x4Xb4liVWnw5hz/My7UDC/aDDw4thDY= X-MC-Unique: 2wNYGPSmMZ6WPNhGA2hhgQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 23/53] migration/rdma: Fix QEMUFileHooks method return values Date: Thu, 28 Sep 2023 15:19:49 +0200 Message-ID: <20230928132019.2544702-24-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: 1695907473307100001 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 Reviewed-by: Juan Quintela --- migration/rdma.c | 79 +++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 42 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 1ae2f87906..a58c2734e3 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -3250,12 +3250,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); @@ -3321,9 +3320,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); @@ -3569,12 +3569,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; @@ -3607,7 +3606,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 @@ -3619,7 +3618,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(); @@ -3640,7 +3639,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 @@ -3679,7 +3678,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; @@ -3706,7 +3705,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) { @@ -3716,7 +3715,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)); @@ -3732,7 +3731,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); @@ -3744,7 +3743,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 @@ -3761,7 +3760,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: @@ -3784,7 +3783,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--; @@ -3797,24 +3796,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: @@ -3836,7 +3834,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 */ @@ -3849,7 +3847,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; @@ -3879,7 +3877,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; @@ -3888,12 +3885,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); @@ -3922,12 +3918,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); @@ -3958,7 +3953,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); @@ -3981,7 +3976,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); @@ -3997,7 +3992,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; @@ -4017,7 +4012,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 Wed May 15 18:29:22 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=1695907518; cv=none; d=zohomail.com; s=zohoarc; b=PYBfYafxyEd3C5jaAuEv670wvj5yAHt9fvh4G8Xe4LlEeCGJ24QvQNLxEnenChbdFceKlxOuTAcLtayUI9DvprUDIBYAwT3tuVzSuetBQ3x03vOui5g9xOtdnBasZUyf93G+PvzHoEwrBZmIfwTMoqxm4+olkcbBZmeZDujq/S4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907518; 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=ez+XIiDjpsRBFgIlZjSn7S6XQQAuaYrDK2LrA6qGyYY=; b=Ks2AVsyLtbbjey5fK3i3ZfcVT9V28SQVJqzqUpFkQrQFQs9nbX9mBFWlorZo+wcfA0FuRJtnMKL2K5Z5kmxGsI1lpWc1TLU14jzX6AuuWN9fn37tZD2FD8OpVl3OUhI3lfZvHMrCfMu2luktLrsMNd8F20adidr6BhisoD86pIo= 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 1695907518005203.36263260883925; Thu, 28 Sep 2023 06:25:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwl-0003g2-S3; Thu, 28 Sep 2023 09:20:51 -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 1qlqwb-0003bF-Az for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:42 -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 1qlqwP-0008GE-Cb for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:40 -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-416-qpwxzt3mPia43twKrqpm0g-1; Thu, 28 Sep 2023 09:20:23 -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 44DC91C00BAB; Thu, 28 Sep 2023 13:20:23 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 20F8C2156711; Thu, 28 Sep 2023 13:20:23 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 12AC221E6887; Thu, 28 Sep 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907227; 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=ez+XIiDjpsRBFgIlZjSn7S6XQQAuaYrDK2LrA6qGyYY=; b=FveqWI+tVNGYaVs/vbGN6q0tBRc7PUzDfE60sm8reODyii86DBLgG1uPO2WL/o/H0WJVyJ fRrWgJqqZpWEurYO/DJx+21dEJNmXEpp7Nj/C4ssOAu48/bwbcveoUCdL18cRr1kNUjJaN 1zF95t+KGe2u1u722MzVPY8dZmxLpZE= X-MC-Unique: qpwxzt3mPia43twKrqpm0g-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 24/53] migration/rdma: Fix rdma_getaddrinfo() error checking Date: Thu, 28 Sep 2023 15:19:50 +0200 Message-ID: <20230928132019.2544702-25-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: 1695907518268100001 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 Reviewed-by: Juan Quintela --- migration/rdma.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index a58c2734e3..37399d31d2 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -941,14 +941,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 */ @@ -962,7 +962,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; } @@ -1004,7 +1004,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); @@ -1025,7 +1024,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); @@ -1040,7 +1038,7 @@ err_resolve_get_addr: err_resolve_create_id: rdma_destroy_event_channel(rdma->channel); rdma->channel =3D NULL; - return ret; + return -1; } =20 /* @@ -2675,7 +2673,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; } @@ -2719,7 +2717,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 Wed May 15 18:29:22 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=1695907632; cv=none; d=zohomail.com; s=zohoarc; b=RSHVy04Dmf6Nnk24howimAGjio0ri+WmjW4S7KedtYH0DqRlvBTyeNLRN+q2wYx8bStsjGdoKAR7pDfsi3t2xCSAZSy8Os0UpA7vRfymDFWLlFkaadQWdlryWTA++haCKMQL5O+T5Fr7ayGEHcoEMYsms6Q/49drHbaeOMqGPjw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907632; 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=85mmooIXWtXa6qrOGaGMexHSblqxd/XcXl7NVuqhh1Y=; b=Wgkt+FkB/VXDRVHeD/8Ef9J/n/3ZAnGr0rSUH7RYWBSGH/WMKT+rw990Z2qrwexLMWAaZkLO6MJFTa4NZesdVPrmADhchsB0b9mYH6EDO9LCScT+NY+ZWlAjUblWL7I8Jf5hQRBGf2uaKN9p0/Re4QAH31QwVcrpZPYCpW6B06w= 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 1695907632014800.867293946742; Thu, 28 Sep 2023 06:27:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqww-0003mJ-4O; Thu, 28 Sep 2023 09:21:02 -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 1qlqwb-0003bD-AL for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:42 -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 1qlqwP-0008Fo-6r for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:39 -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-265-dOYWrn-jP2CprVq3Mgmlqw-1; Thu, 28 Sep 2023 09:20:23 -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 6171A101AA68; Thu, 28 Sep 2023 13:20:23 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 22FEE14171B6; Thu, 28 Sep 2023 13:20:23 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 1591A21E6888; Thu, 28 Sep 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907227; 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=85mmooIXWtXa6qrOGaGMexHSblqxd/XcXl7NVuqhh1Y=; b=M8kZkMCTE069uayij1KqPFTeaq28XsKrjVxVVlVAXE8cKtmJ0d7ArhA+KjXiaZC+ZzcXZJ p0DYFHedYr226UM7W7mrM7SwP7TmB1UkfZ7TKILmVpj5RJT752DrU7E1eO27CfEbrSbuAT N2KQa6bIbGzpiibk/CBxyHjLT7TOdD8= X-MC-Unique: dOYWrn-jP2CprVq3Mgmlqw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 25/53] migration/rdma: Return -1 instead of negative errno code Date: Thu, 28 Sep 2023 15:19:51 +0200 Message-ID: <20230928132019.2544702-26-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 1695907632552100005 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 Reviewed-by: Juan Quintela --- migration/rdma.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 37399d31d2..4817f1ea10 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -863,14 +863,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) { @@ -895,7 +895,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 @@ -911,13 +911,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 @@ -1425,7 +1425,7 @@ static int qemu_rdma_unregister_waiting(RDMAContext *= rdma) * this series. */ perror("unregistration chunk failed"); - return -ret; + return -1; } rdma->total_registrations--; =20 @@ -1570,7 +1570,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= ," @@ -1578,7 +1578,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); } @@ -1591,18 +1591,18 @@ static int qemu_rdma_wait_comp_channel(RDMAContext = *rdma, * I don't trust errno from qemu_poll_ns */ error_report("%s: poll failed", __func__); - return -EPIPE; + return -1; } =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; } @@ -1772,7 +1772,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); @@ -1841,15 +1841,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; @@ -2113,7 +2113,7 @@ retry: (uint8_t *) &comp, NULL, NULL, NULL); =20 if (ret < 0) { - return -EIO; + return -1; } =20 stat64_add(&mig_stats.zero_pages, @@ -2148,7 +2148,7 @@ retry: &sge.lkey, NULL, chunk, chunk_start, chunk_end)) { error_report("cannot get lkey"); - return -EINVAL; + return -1; } =20 reg_result =3D (RDMARegisterResult *) @@ -2167,7 +2167,7 @@ retry: &sge.lkey, NULL, chunk, chunk_start, chunk_end)) { error_report("cannot get lkey!"); - return -EINVAL; + return -1; } } =20 @@ -2179,7 +2179,7 @@ retry: &sge.lkey, NULL, chun= k, chunk_start, chunk_en= d)) { error_report("cannot get lkey!"); - return -EINVAL; + return -1; } } =20 @@ -2226,7 +2226,7 @@ retry: * in this series. */ perror("rdma migration: post rdma write failed"); - return -ret; + return -1; } =20 set_bit(chunk, block->transit_bitmap); @@ -2950,14 +2950,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 Wed May 15 18:29:22 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=1695907475; cv=none; d=zohomail.com; s=zohoarc; b=gvSIvmdRRUeOW1lPTjMbDvB41nUJVJNYMwcKVme97HudY15miJpafDpRRVKrSejxgupn40/1GRo702dYvvHosMRqoZy8RezDH299PFSegobZd9ye2juWDQFMBTlq0urkXL0madsY/rGctfFw/VsnjkfbMhsp1xklOHiZKfxLPls= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907475; 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=1/RhVGVRlVdsQjYT/hn8AF7S+qYvZsa3u3+JiLMETQU=; b=AsinePYooL45OlMx7z47ZiCJwX2G9BwXG7Z0Ru+nL9UKt5tcHzNV+efPfW25oebI63Wn+yi9JG+PWw3DP/YOwluUht+kANCIvcdsaA3VFQGZ1RyuSt6wNS0vDoeW3xzozZY9tuwmf5pmRU+dKGPUMQYH+F9r5KM9f13N0e0tnPw= 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 1695907475355941.4693411295686; Thu, 28 Sep 2023 06:24:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwh-0003ec-AQ; Thu, 28 Sep 2023 09:20: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 1qlqwX-0003Xy-I0 for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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 1qlqwN-0008Et-MN for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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-400-9KbwOyfRPoOOExYFlmsmVg-1; Thu, 28 Sep 2023 09:20:23 -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 64272811E8E; Thu, 28 Sep 2023 13:20:23 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 25B6940C2064; Thu, 28 Sep 2023 13:20:23 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 1870121E688A; Thu, 28 Sep 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907226; 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=1/RhVGVRlVdsQjYT/hn8AF7S+qYvZsa3u3+JiLMETQU=; b=Y+d01kD/Jw2p1H7h5xxh/PAlJQ3N5p1wNbi9hic9crrkt+KnQ2nBOFpizb+1MrX1Uk9Cb3 jRSp2+nhPPBEs56BczqqrfSieWzUO4WKCkdrEol74+1PC+seydRsPsbmvOvFuE9ZZEDqNp TxF4krh9GootcGn3Pl5uG5DrqfTlqfw= X-MC-Unique: 9KbwOyfRPoOOExYFlmsmVg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 26/53] migration/rdma: Dumb down remaining int error values to -1 Date: Thu, 28 Sep 2023 15:19:52 +0200 Message-ID: <20230928132019.2544702-27-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 1695907477355100002 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 Reviewed-by: Juan Quintela --- migration/rdma.c | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 4817f1ea10..fe101236c4 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1434,7 +1434,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); @@ -1475,7 +1475,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; @@ -1604,7 +1604,7 @@ static int qemu_rdma_wait_comp_channel(RDMAContext *r= dma, if (rdma->received_error) { return -1; } - return rdma->error_state; + return -!!rdma->error_state; } =20 static struct ibv_comp_channel *to_channel(RDMAContext *rdma, uint64_t wri= d) @@ -1649,7 +1649,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; @@ -1723,7 +1723,7 @@ err_block_for_wrid: } =20 rdma->error_state =3D ret; - return ret; + return -1; } =20 /* @@ -1778,9 +1778,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 /* @@ -1822,7 +1823,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); @@ -1900,7 +1901,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 @@ -1912,7 +1913,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 @@ -1922,7 +1923,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 /* @@ -1932,7 +1933,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 /* @@ -1943,7 +1944,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 @@ -1952,7 +1953,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); @@ -1988,7 +1989,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 /* @@ -1998,7 +1999,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); @@ -2009,7 +2010,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; @@ -2082,7 +2083,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 @@ -2140,7 +2141,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. */ @@ -2214,7 +2215,7 @@ retry: if (ret < 0) { error_report("rdma migration: failed to make " "room in full send queue!"); - return ret; + return -1; } =20 goto retry; @@ -2256,7 +2257,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) { @@ -2338,7 +2339,7 @@ static int qemu_rdma_write(QEMUFile *f, RDMAContext *= rdma, if (!qemu_rdma_buffer_mergeable(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; @@ -3516,7 +3517,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 Wed May 15 18:29:22 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=1695907547; cv=none; d=zohomail.com; s=zohoarc; b=N/CE98Sw1vDTvfEt3TzCzGfACQcycBVg55thej3f8Bm255IsuDnyPUXylU+6cTOYn7iBZ/2wQ8+wNf80MhDgYYi8/ILhnLU2MHVicg+eKCmixT1dtOUcAKCN1BvsDBLsUf2LF2EzG+5CB2t4VHdz7U5524nb2ZCMhbe/YSC1lkM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907547; 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=+XBSUbeUcQ6TqxrAOOSaLrqlPPWjH713jSTenuIBROE=; b=MXJU8V04lLNnjLziolp8dPQxPTQ+VjGNyJKwGJCt8b8Qo1IqKTW1onqVMdylFJfPiEad5zqoVOf1tkjpdC+4Bbz+MxO2mvMQuiKbpPkIo7DlONPL+qqGL2+f9sqAiWzzcscALMuAmw3awsHiq0XSN1g95XDJvP4pvZaQ3Km79t8= 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 1695907547705101.17578249958069; Thu, 28 Sep 2023 06:25:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwo-0003gs-EG; Thu, 28 Sep 2023 09:20:54 -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 1qlqwf-0003dr-3h for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:45 -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 1qlqwQ-0008I0-II for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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-530-DDpddKduNr2uDyiPkezd0Q-1; Thu, 28 Sep 2023 09:20:23 -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 6C9B918175A8; Thu, 28 Sep 2023 13:20:23 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2DBB910EE6C9; Thu, 28 Sep 2023 13:20:23 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 1B6DD21E688B; Thu, 28 Sep 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907229; 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=+XBSUbeUcQ6TqxrAOOSaLrqlPPWjH713jSTenuIBROE=; b=NALAGDEbtDmRJOmij5cxCFY8husukfp/f4t+SThvhpqz0jwRJrmgAIJihBgHsl5Ku7FLGs /48l9AzSpTtYhhSzxSHzbf6QKYQpPewNkLE/XsUpwlt2kM7tJTeEa26amFtObku9C+sRyk sHM8PK9JiJv4RQZlVT1IK9P23r1Nmsw= X-MC-Unique: DDpddKduNr2uDyiPkezd0Q-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 27/53] migration/rdma: Replace int error_state by bool errored Date: Thu, 28 Sep 2023 15:19:53 +0200 Message-ID: <20230928132019.2544702-28-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 1695907549864100007 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 Reviewed-by: Juan Quintela --- migration/rdma.c | 66 ++++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index fe101236c4..d92be4869a 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; + bool 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) @@ -1547,7 +1547,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; @@ -1604,7 +1604,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) @@ -1722,7 +1722,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 @@ -2366,7 +2366,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, @@ -2652,14 +2652,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 @@ -2717,7 +2717,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 } @@ -2793,7 +2793,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; @@ -2805,7 +2805,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; } @@ -2825,7 +2825,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; } @@ -2883,7 +2883,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; @@ -2919,7 +2919,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; } @@ -3193,21 +3193,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; } @@ -3252,7 +3252,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 @@ -3321,7 +3321,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 @@ -3342,13 +3342,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); @@ -3514,7 +3514,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; @@ -3571,7 +3571,7 @@ static int qemu_rdma_registration_handle(QEMUFile *f) return -1; } =20 - if (check_error_state(rdma)) { + if (rdma_errored(rdma)) { return -1; } =20 @@ -3810,7 +3810,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 @@ -3887,7 +3887,7 @@ static int qemu_rdma_registration_start(QEMUFile *f, return -1; } =20 - if (check_error_state(rdma)) { + if (rdma_errored(rdma)) { return -1; } =20 @@ -3920,7 +3920,7 @@ static int qemu_rdma_registration_stop(QEMUFile *f, return -1; } =20 - if (check_error_state(rdma)) { + if (rdma_errored(rdma)) { return -1; } =20 @@ -3974,7 +3974,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 @@ -3990,7 +3990,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 @@ -4010,7 +4010,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 Wed May 15 18:29:22 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=1695907629; cv=none; d=zohomail.com; s=zohoarc; b=CHWahNr+0f65FoMCYCNfQ+jcdPxBuU28KiCskUeFuHJz0jF8NuOELScnhx6mnwh6Keph3d+R8EFL3k6sFlRUudQHl8vwOlA1j8qXrj3EgRZBaCYjJhHgX+JMlKABv5q4/4ZD7cxMQY85v/L0kqGzN/e1T06WDVDvRgZYvHBWPhc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907629; 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=EFRv12GNg6KBmUOKNaXYFzMwOCG24lFNbPGy3s8wZ7I=; b=c/5kaiYs5H8Wa9zvv5WLpP5Wy8SZJbT7nilZ9UTErZ4G5h8b4ZSFHFCaCZULI1P9343lQZGgjYMZMtXQYt55t4fg33Ax5il8uAQPwdfHSlx7TTpthCg/y3pywI7iXeSKUYABZCP/V7tcpRPPwWfx0kBI4mBsEISbb0hoseQXRLA= 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 1695907629442159.23492046368563; Thu, 28 Sep 2023 06:27:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwl-0003fK-0J; Thu, 28 Sep 2023 09:20:51 -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 1qlqwX-0003YT-TQ for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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 1qlqwN-0008FQ-UC for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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-400-QS_T2bSON6CtWpnm4OSwkA-1; Thu, 28 Sep 2023 09:20:23 -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 75477280A9CB; Thu, 28 Sep 2023 13:20:23 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 35C8814171CA; Thu, 28 Sep 2023 13:20:23 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 1E55021E688D; Thu, 28 Sep 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907227; 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=EFRv12GNg6KBmUOKNaXYFzMwOCG24lFNbPGy3s8wZ7I=; b=epoCsH4FbckmaSSB6ruj4DSIq5/IC5kXjEja7uKs30Wma6ytLISyrt/p35pUwg6bPspNtH VLLxjfzMcm2YBSevw1CtIYp2OvSZcdQbaPp2soeU384em0x0H9mBVzZwiezJJR1bed8etE KEDFMAyoNkBhr/QgZaDQbT6eIAtdMIY= X-MC-Unique: QS_T2bSON6CtWpnm4OSwkA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 28/53] migration/rdma: Drop superfluous assignments to @ret Date: Thu, 28 Sep 2023 15:19:54 +0200 Message-ID: <20230928132019.2544702-29-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: 1695907630510100002 Content-Type: text/plain; charset="utf-8" Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian Reviewed-by: Juan Quintela --- migration/rdma.c | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index d92be4869a..2af9395696 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1530,7 +1530,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() @@ -1635,7 +1635,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; @@ -1685,8 +1685,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 @@ -1733,7 +1732,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 { @@ -1890,7 +1889,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 @@ -2871,7 +2870,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; ssize_t done =3D 0; size_t i, len; =20 @@ -3371,7 +3370,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); @@ -3381,7 +3380,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 @@ -3394,7 +3392,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 @@ -3409,7 +3406,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 @@ -3442,7 +3438,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 @@ -3496,7 +3491,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 @@ -3559,7 +3553,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; @@ -3588,7 +3582,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 @@ -3604,7 +3597,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]); @@ -3703,7 +3695,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]); @@ -3713,7 +3704,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 + @@ -3729,7 +3719,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; } } @@ -3741,7 +3730,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; @@ -3781,7 +3769,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 @@ -3800,11 +3787,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); @@ -3908,7 +3893,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; @@ -4182,7 +4167,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 Wed May 15 18:29:22 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=1695907498; cv=none; d=zohomail.com; s=zohoarc; b=kGFtvawLkyyc8Wx4hMu/C+1Y8f7HFfL1ZD/NfqiCmKg8aeOVVNlO0FLZpXvI9If9X4nqPqkmdfF8UZPYQWX0H7hs6mWLO7+a+ggUJIGapmfHmo8ji2Uwp5O6cE+UYZqjyrP6D47R2nl134xNkf+sV4GrgdP2A0NsTxxRnxoUeOA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907498; 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=rAf9/S0ZojPplmxHbWVyVKT//hV1aoc1NmZNVRvV3+4=; b=iOEvNAu0NWZtBk5fP6x2BSIXnw0iqA4O4ZNb6fKvMKrjUariMQn3HQwmN/F7mu/30hxsAFKWbi5wHLxUkBnMm3XGCz6W8uUxRo/Dtq+N22766oF22FkNz+ZEGt1odV02iQ2HYw4myJVGh22segYwpKvxbTEXZcIf31OySTMzCmA= 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 1695907498705311.47878358188575; Thu, 28 Sep 2023 06:24:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwr-0003iB-1t; Thu, 28 Sep 2023 09:20:57 -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 1qlqwS-0003TT-G3 for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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 1qlqwM-0008AB-70 for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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-532-8mNYuNnVPzeZBIf9RSyT4w-1; Thu, 28 Sep 2023 09:20:23 -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 90A0980C8E4; Thu, 28 Sep 2023 13:20:23 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 361FA2026D17; Thu, 28 Sep 2023 13:20:23 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 212C821E6890; Thu, 28 Sep 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907225; 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=rAf9/S0ZojPplmxHbWVyVKT//hV1aoc1NmZNVRvV3+4=; b=CpSemj3DKi03kQW6AagnVV4J2qIgCS5aRc0XKw9juXxsFGDxw8pc/4q2RDRBRJSL+6NIxI ur8dCfaCuZwx4JGaqzFSEf1vYo7yvTK2ziCup3fCx3bETcoukJRJIztnoU1Uoo4T6XprVt hbw1Sn+hir+sYwOVnpK46tH6EmBA7HY= X-MC-Unique: 8mNYuNnVPzeZBIf9RSyT4w-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 29/53] migration/rdma: Check negative error values the same way everywhere Date: Thu, 28 Sep 2023 15:19:55 +0200 Message-ID: <20230928132019.2544702-30-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 1695907499364100001 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 Reviewed-by: Fabiano Rosas Reviewed-by: Juan Quintela --- migration/rdma.c | 82 ++++++++++++++++++++++++------------------------ 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 2af9395696..c57692e5a3 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -953,7 +953,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; } @@ -974,10 +974,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; } } @@ -994,7 +994,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; } @@ -1010,13 +1010,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; } @@ -1124,7 +1124,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 @@ -1567,7 +1567,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; @@ -1668,12 +1668,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) { /* * FIXME perror() is problematic, because ibv_reg_mr() is * not documented to set errno. Will go away later in @@ -1909,7 +1909,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; @@ -1920,7 +1920,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; } @@ -2007,7 +2007,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; } @@ -2337,7 +2337,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_mergeable(rdma, current_addr, len)) { ret =3D qemu_rdma_write_flush(f, rdma); - if (ret) { + if (ret < 0) { return -1; } rdma->current_length =3D 0; @@ -2467,12 +2467,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"); @@ -2480,7 +2480,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; } @@ -2497,7 +2497,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; @@ -2571,13 +2571,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; @@ -2591,7 +2591,7 @@ static int qemu_rdma_connect(RDMAContext *rdma, bool = return_path, ERROR(errp, "failed to get cm event"); } } - if (ret) { + if (ret < 0) { /* * FIXME perror() is wrong, because * qemu_get_cm_event_timeout() can fail without setting errno. @@ -2664,7 +2664,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; } @@ -2680,7 +2680,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; } @@ -2689,12 +2689,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; } } @@ -3334,7 +3334,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; } @@ -3374,7 +3374,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 @@ -3444,13 +3444,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; } @@ -3459,7 +3459,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; } @@ -3477,13 +3477,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; } @@ -3498,7 +3498,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; } @@ -3627,7 +3627,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; @@ -4088,7 +4088,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; } @@ -4132,7 +4132,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 @@ -4140,7 +4140,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; } @@ -4182,14 +4182,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 @@ -4204,13 +4204,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 Wed May 15 18:29:22 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=1695907652; cv=none; d=zohomail.com; s=zohoarc; b=W8/XqfBwsiRcvWY7VbKCqHkBYlQFDAlJ9LufQdQ2uecY/2mUQf8PCh04RbZ6nihku6wIseuMXIzUqtMknUQ0yRiX4yPFQTZr+LFAB23i/pKRZNftvWn2FDV/y9s6GLZHRzXqIEMBKuuUJ4rH8de1JOWpQOPuKm2yQMhs6RdeDrY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907652; 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=sG6Qx0S3rjdug66QRlVWtj2oS+HNlSyxhEJMsz5r45Q=; b=E8aSH4IQGjz1lb6V0ozCCFBLK/XHnfG8gyD0n5DdLrgOm8LGIG+ZJgcDBiMIC8TayYhE9TsR9THunMq9IlePeE6tT+srliMlgsOEkJq5YE2RV1upB+2aHy43cZYe6+Rr+tEZrAKregpUAk4SK1LoRRc1LITEt2rQUi2F+W0QN8I= 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 1695907652861205.09432631208074; Thu, 28 Sep 2023 06:27:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwn-0003gq-Fk; Thu, 28 Sep 2023 09:20:53 -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 1qlqwY-0003ZQ-TJ for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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 1qlqwO-0008Fc-IS for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:38 -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-530-e38rZNf6MnWXKR2mFBSgsg-1; Thu, 28 Sep 2023 09:20:23 -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 60ACA185A79C; Thu, 28 Sep 2023 13:20:23 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3E30114171CB; Thu, 28 Sep 2023 13:20:23 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 240D021E6892; Thu, 28 Sep 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907227; 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=sG6Qx0S3rjdug66QRlVWtj2oS+HNlSyxhEJMsz5r45Q=; b=HNuqG4fDG3JZdx7REBJI9Kv8puR8FLojXq25z56zfNw2lMKw1HWvgFiRdAX4VRotQlzPw3 gaHz0HVweJ1NRiVgENoXGPs5B5WBWTaNhZTw2ycelM+NHHdBBIKQB8KZ6ml97CqGJbWmeT /gx9QyjVRnICPs003AecmKvHRLKGg7M= X-MC-Unique: e38rZNf6MnWXKR2mFBSgsg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 30/53] migration/rdma: Plug a memory leak and improve a message Date: Thu, 28 Sep 2023 15:19:56 +0200 Message-ID: <20230928132019.2544702-31-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 1695907654954100006 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 Reviewed-by: Juan Quintela --- migration/rdma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index c57692e5a3..54f4a917be 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -2617,8 +2617,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 Wed May 15 18:29:22 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=1695907510; cv=none; d=zohomail.com; s=zohoarc; b=MRfByQjMKnQ6v9GPRQ5cbuQP8w498un9gc/pNcbv4xDBUdcxZ5lj3oRi53Gvt/LZv+2nLFDaPH4wj4Nerfzh7vdycNSu9/k1WD0pkIUxMNCILtET3ibHU+xXUcTmabJ8Ug3U//FRu+Ebx4rtLr9cM1VjOMnoKJ2QxdkJ0XjVmCQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907510; 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=qcQ/J9I0ol/gguZM6SVa/r+mqPmcL4J+CaYf2CzsCUA=; b=VEp2Aud21U7Z3k81C+balXnpq3bkIxvIYT7KpPajv/6WuDlMzSw6uye7grJdBvNKfDaGp8FyOqxowptmPNQu8XqFvHm1DIHCGs9YmExJuIOwq3cY2dmIK67U4IFXiIeFzGvPX2ANgp4WJxqVKk7Yvauu02yM7wZrDJdMxjhBBR0= 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 1695907510153768.6226273607753; Thu, 28 Sep 2023 06:25:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwq-0003hN-Fh; Thu, 28 Sep 2023 09:20:57 -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 1qlqwT-0003Tl-Nf for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:33 -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 1qlqwM-0008CJ-Ry for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:33 -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-190-kGx8_SbDMCq6qQrt6a4Lgg-1; Thu, 28 Sep 2023 09:20:23 -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 677E918175A2; Thu, 28 Sep 2023 13:20:23 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 45849C154CA; Thu, 28 Sep 2023 13:20:23 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 26E1621E6893; Thu, 28 Sep 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907226; 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=qcQ/J9I0ol/gguZM6SVa/r+mqPmcL4J+CaYf2CzsCUA=; b=CnT1CCXJjsF3vUtuCIUiByo/tF4OAX7Pdsegc0AyaeQecRJur84TQ/fYbvuqEYz0+v34oK enp+22NX/jDaU7xSfmEzte1TmKPFjEMWgs2w9/mjkoeix1NNz281VEN9EzZWh2IuB1I4o/ PfU140qZXTOkivgfcGjCTRNDrU1QFe8= X-MC-Unique: kGx8_SbDMCq6qQrt6a4Lgg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 31/53] migration/rdma: Delete inappropriate error_report() in macro ERROR() Date: Thu, 28 Sep 2023 15:19:57 +0200 Message-ID: <20230928132019.2544702-32-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 1695907512168100007 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 Reviewed-by: Juan Quintela --- migration/rdma.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 54f4a917be..128489e0ce 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 Wed May 15 18:29:22 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=1695907657; cv=none; d=zohomail.com; s=zohoarc; b=Kh+ad3umQqMOlc8q1b1ZE7/X/8ZB9DVMI551NROyCFVgEfWQSX8rH8y3mrxkZWSikw2W7yAy1PkIxuowUvOQmLipHFyaJ97Kq4Yt5vmw/lv7rZ5NfbwkNiZhKn8NroklhKlxcTMJmcLFV6ZblfbLQzfI1N+qPtGcLOoMR9pUhAk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907657; 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=VsQGbKnJrCYb9VJ13HO6krxaksX7ZCaOv+T0BQ6sNBc=; b=gTsetLpl305T7bODP67VQL4+SbIan1cyNdEiAEUacgxml765MBMzCgdVyoXJ3xO9r0pcAqotqL5idvm7gswi6vm4Q4TTSvTNoMNLULt+5UR8ZgCTt8JVBVeW26I/OvEmTqOznYDNLwFIFjrBhJIuVnaaYlR2AZp4kHCjCsFF/es= 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 1695907657771377.9031669434786; Thu, 28 Sep 2023 06:27:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwr-0003jB-Om; Thu, 28 Sep 2023 09:20:57 -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 1qlqwS-0003TV-P9 for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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 1qlqwM-0008AE-79 for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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-534-cS6K51cOMle5ofScp3CHQQ-1; Thu, 28 Sep 2023 09:20:24 -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 AF1F580C8F1; Thu, 28 Sep 2023 13:20:23 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 544F040C2070; Thu, 28 Sep 2023 13:20:23 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 29DAC21E6894; Thu, 28 Sep 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907225; 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=VsQGbKnJrCYb9VJ13HO6krxaksX7ZCaOv+T0BQ6sNBc=; b=hzFWPq6GY7BXsexEZUusEJxZxiHvr2F3gibckbhoCcFdeH2XK1HvOSsCfHoKRg1aem+8Ui Vq7sTFNSktQtkJpxeuwUVsjKUVV5FQd5qAwjXeiF6A4JjEzzNE6qT0UY3xFRzi7cOjt+RB ki2hnEEbSW+L0eow3kQUYIwK+TqcsMg= X-MC-Unique: cS6K51cOMle5ofScp3CHQQ-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 32/53] migration/rdma: Retire macro ERROR() Date: Thu, 28 Sep 2023 15:19:58 +0200 Message-ID: <20230928132019.2544702-33-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 1695907659040100006 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 Reviewed-by: Juan Quintela --- migration/rdma.c | 168 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 120 insertions(+), 48 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 128489e0ce..cbb6822dda 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. */ @@ -865,7 +858,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 @@ -888,9 +884,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; } } @@ -906,13 +905,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 @@ -936,21 +940,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 @@ -959,7 +969,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 @@ -982,7 +995,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: @@ -991,13 +1007,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; @@ -1007,18 +1028,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; } @@ -2469,15 +2497,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 @@ -2494,8 +2527,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; } } @@ -2523,19 +2559,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; } } @@ -2568,14 +2614,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 @@ -2584,7 +2634,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) { @@ -2599,7 +2651,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; } @@ -2646,14 +2700,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; } @@ -2661,7 +2719,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 @@ -2670,14 +2730,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) { @@ -2699,7 +2764,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 @@ -2751,7 +2818,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; } @@ -4137,7 +4207,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 Wed May 15 18:29:22 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=1695907533; cv=none; d=zohomail.com; s=zohoarc; b=JXDA5ttiKyIDHwuw9sDrlNyXZOVZ2Kr40zBPpkPCUIxJpMpuZe/6G08m4FIgiWu0BPoSC5yg9zZmFgjQX+PJbfpYwF2RHqK/CgmmnUR2zN0zf9sPXlkA/bwd5pO41jFV3C9jt1+cJEt70oXqCVculrCXMg2dYeN3AbQRDEYh6ks= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907533; 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=BsQyd+OvOUzUsvxd1zR5+KXoFdhuHdtHMg2Qq4Coo/o=; b=Q5c4JBOMy69fPvxVGhRx8J4QKlvXuxySPhKS3I7DtZeqcvqfPJCrr4sScK3SfJENUF6hEYwupUpLvOcmoO+u4voR/lVPox55fBUhl/Pd4Kda0t5Hl6NxHIhmOJTUTbKr5HtfxH/4Ys21IUEEH9vrEzempuUXl+z3oY82gcmFqKU= 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 1695907533921934.4724777245557; Thu, 28 Sep 2023 06:25:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwy-0003p3-F6; Thu, 28 Sep 2023 09:21:04 -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 1qlqwX-0003Y4-Kv for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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 1qlqwN-0008F7-TJ for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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-693-5V91TcmqMmW9EymSiL-wJA-1; Thu, 28 Sep 2023 09:20:24 -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 3DBDF802D35; Thu, 28 Sep 2023 13:20:24 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F321D401025; Thu, 28 Sep 2023 13:20:23 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 2CB8421E6895; Thu, 28 Sep 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907227; 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=BsQyd+OvOUzUsvxd1zR5+KXoFdhuHdtHMg2Qq4Coo/o=; b=EFwRdUbadQTSk1exivjrdFXoa3wj45FZwgVOLg+OHpqnDWe6lR90xADckUmK4XO7iKD2WJ mINYAOhUIx4Rmax2kYXQzQNFtbRn46OleJDWGVf/Z8yt8DGpDsDd9CSbI9G0RUdPXCsmon eLd5AZRf2HVuIdLB0Waqn6eWZLTpy6k= X-MC-Unique: 5V91TcmqMmW9EymSiL-wJA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 33/53] migration/rdma: Fix error handling around rdma_getaddrinfo() Date: Thu, 28 Sep 2023 15:19:59 +0200 Message-ID: <20230928132019.2544702-34-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 1695907535351100002 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 Reviewed-by: Juan Quintela --- migration/rdma.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index cbb6822dda..4fec6dbf86 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -932,6 +932,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]; @@ -976,7 +977,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); @@ -985,17 +989,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); } @@ -2687,6 +2695,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"; @@ -2745,7 +2754,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); @@ -2754,17 +2767,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 Wed May 15 18:29:22 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=1695907398; cv=none; d=zohomail.com; s=zohoarc; b=aXh9T7kEZq8LE3pSUB4CxZTZHOgOcPfTnKzZoaAjnTxsB95bWHldws2wY3HLsZ9N0liGx712nayjo5h2/95hG73jKMvcxtOC8fiqGErmxpZAy47kl/T6CYDl5L8svBEFEVpNhqaFIgAR3hnaEbICOjAml9tNJ4tW/pph2rcFF6Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907398; 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=iSv0Pu1IwbZy01gFu8V7gIoIIGwmYp2Ct+GrIbCBwN0=; b=UjtTzmJavck1gEmEhO0wDFbPvD0RAKpXW3ueCLsQ354eIx9Mud8G8Uoj4F27E3kdz7FTUxHIlBfJe2WBUdikdJAgVk5aX2oaI2DqtJqT/FmaKDXDaA9u0U4eFJC+CqZjmKykeh/br7WL/Pr2tUpcRJyPZU//Ar9vkLupIlruK1I= 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 1695907398640687.5639033060393; Thu, 28 Sep 2023 06:23:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqws-0003jf-DN; Thu, 28 Sep 2023 09:20:58 -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 1qlqwU-0003U2-FF for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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 1qlqwN-0008Ca-3k for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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-549-rqWfNp2YO3uyxxZWhcKRew-1; Thu, 28 Sep 2023 09:20:24 -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 5D2A33C13930; Thu, 28 Sep 2023 13:20:24 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 039B72156702; Thu, 28 Sep 2023 13:20:24 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 2F99021E6896; Thu, 28 Sep 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907226; 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=iSv0Pu1IwbZy01gFu8V7gIoIIGwmYp2Ct+GrIbCBwN0=; b=YikziM38kQFuIbBEmAGUlMdju+1I9H66TR2XbyU4DXQbLdk5TwpNKQukEAIqlmh2yjUS43 FkNHI4Nkuz7iicBztpBnwpp7YKXQD5QwUFj1/Qxu5hM1NgB4M64Tq2BoMPQBJWNg6ZSoEF c7aOSdgkfheK90UdJ8ZuCowuVcl23HA= X-MC-Unique: rqWfNp2YO3uyxxZWhcKRew-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 34/53] migration/rdma: Drop "@errp is clear" guards around error_setg() Date: Thu, 28 Sep 2023 15:20:00 +0200 Message-ID: <20230928132019.2544702-35-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: 1695907398986100029 Content-Type: text/plain; charset="utf-8" These guards are all redundant now. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian Reviewed-by: Juan Quintela --- migration/rdma.c | 164 +++++++++++++++-------------------------------- 1 file changed, 51 insertions(+), 113 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 4fec6dbf86..45e55178a8 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -858,10 +858,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 @@ -884,12 +882,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; } } @@ -905,18 +901,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 @@ -941,27 +933,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 @@ -970,10 +956,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 @@ -1015,18 +999,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; @@ -1036,25 +1016,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; } @@ -2505,20 +2479,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 @@ -2535,11 +2505,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; } } @@ -2567,29 +2535,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; } } @@ -2622,18 +2582,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 @@ -2642,9 +2598,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) { @@ -2659,9 +2613,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; } @@ -2709,18 +2661,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; } @@ -2728,9 +2676,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 @@ -2739,19 +2685,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 @@ -2835,10 +2777,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; } @@ -4224,9 +4164,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 Wed May 15 18:29:22 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=1695907605; cv=none; d=zohomail.com; s=zohoarc; b=YjVyMaCXcTqj8feHMVD7QwE7W4SXyeEIPASDpuERi4ewGUUdzTgaqSbT1oYW6Q1CSCqygUZ2lw2jxQn8NJkGvd+dGPLnaJIeQaZLVcVNFbXIJnNFfWCJ8Z0ocOWFPGXLjEDgsVRNFrXxg+KLRQXAd/kvbSCxgcMVmytI5mPZnDE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907605; 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=ndemwe3z5zclUdnSE9tbdQ8h6sDlqNR/d5G3ynncvD0=; b=VrKFrZgHLGLLOXC9HSHwoW7UJMqIqjAUBW561z36lIs5zQHvbGuApF/ztG8ZJlxAethijIk/J4MZQVucZhAFt2ScOitu831MKxOa8EwnBIPjiodUiBkzWxCNcAc7JoJSlv76pd5To6PhLN0jXfDekfW2gEEBp/JLfkEuG0xbL/E= 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 1695907605051435.18202202997304; Thu, 28 Sep 2023 06:26:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqww-0003n9-Ju; Thu, 28 Sep 2023 09:21:02 -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 1qlqwc-0003bM-1w for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:42 -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 1qlqwP-0008GQ-DY for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:41 -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-549-AA8ctfmuPC2Dl1Wk02UY0Q-1; Thu, 28 Sep 2023 09:20:24 -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 28271101A529; Thu, 28 Sep 2023 13:20:24 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 03B89C15BB8; Thu, 28 Sep 2023 13:20:24 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 3281921E6897; Thu, 28 Sep 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907228; 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=ndemwe3z5zclUdnSE9tbdQ8h6sDlqNR/d5G3ynncvD0=; b=V/pMvmZS/kp6oyPyqkZqv0HfuYCY4WfuqWfcAMHunF+Tq2gs3+fOszTqSDJnB5L3oY7Z7e cW+BDlvfAi1VMbxeeAqRyyssw1QlZdeZibvHKtYthD8CpUEovjap13BIDfMqG1cGCS3MsV Wb1NKD1cpPfM93ufCUV3UdNQLLjm1ss= X-MC-Unique: AA8ctfmuPC2Dl1Wk02UY0Q-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 35/53] migration/rdma: Convert qemu_rdma_exchange_recv() to Error Date: Thu, 28 Sep 2023 15:20:01 +0200 Message-ID: <20230928132019.2544702-36-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 1695907606088100003 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 Reviewed-by: Juan Quintela --- migration/rdma.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 45e55178a8..e0101422d9 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1978,7 +1978,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, @@ -1993,7 +1993,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 @@ -2004,6 +2004,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 @@ -2014,7 +2015,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 @@ -2938,11 +2939,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 @@ -3567,6 +3568,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; @@ -3596,9 +3598,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 Wed May 15 18:29:22 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=1695907640; cv=none; d=zohomail.com; s=zohoarc; b=Hi6/EORoAtCbJikrHwLdMXhwt78LMYCUq5TAHYalkCUopQyQ9mzX4zRJHzXtMV794fJvwNMS4SQPGEZ6qwGP8TXEX9qBGaUM6lgfQCqvV+2hxbyLykWQMekavFnh02XsgEs8HhPD97i+z/vPHIVRBPugJ1YhKI1R6rxcnhYU03E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907640; 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=T1wx3hMHdpTkfg39vM7M2+3mipLrjneXf1o32b87rbU=; b=AsR17eIXlbO63+mf48h5I4RLfwEY1UuMHgMdK076r9UVUuznvClNKg8rjuR/EpBSvN/mzUUEl6xcZX//Ul+WmnM6tjK9St/7iRZUXEx0qEmgZoLluyn1DiY5E/4upCzj5K83r2Livarplh0P/Wl2olmVNSpQ4RO6jBdOQ/RsbdY= 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 169590764036564.33070046455157; Thu, 28 Sep 2023 06:27:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwl-0003fL-13; Thu, 28 Sep 2023 09:20:51 -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 1qlqwb-0003bB-97 for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:42 -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 1qlqwP-0008GK-BO for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:40 -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-538-Tcauj3ymMYKLpDxsyGEGdA-1; Thu, 28 Sep 2023 09:20:24 -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 49FF93C1392C; Thu, 28 Sep 2023 13:20:24 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0BAF32026D4B; Thu, 28 Sep 2023 13:20:24 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 3557221E6898; Thu, 28 Sep 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907228; 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=T1wx3hMHdpTkfg39vM7M2+3mipLrjneXf1o32b87rbU=; b=aCdgEApRioOKgT1lSmBd9xRBi70FpuwNYEMVcmdZEnU2iTborXKh78/3m9uXG9FNg7V9C/ Mlr2macyj9H0i9q/kwLH/jz0+c3DbZGoHSmYOf1+AjtN9jXC951ol1G4G3+mOh6dLcPwmR p9ZGLw6S61kYEO0EZYffhEXq/i6oepY= X-MC-Unique: Tcauj3ymMYKLpDxsyGEGdA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 36/53] migration/rdma: Convert qemu_rdma_exchange_send() to Error Date: Thu, 28 Sep 2023 15:20:02 +0200 Message-ID: <20230928132019.2544702-37-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: 1695907640731100001 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 Reviewed-by: Juan Quintela --- migration/rdma.c | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index e0101422d9..f77bf1d453 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) @@ -1376,6 +1377,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]; @@ -1438,8 +1441,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 @@ -1893,7 +1897,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 @@ -1906,6 +1911,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; } } @@ -1916,7 +1922,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; } @@ -1927,7 +1933,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 @@ -1937,7 +1943,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 @@ -1949,6 +1955,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; } } @@ -1958,6 +1965,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 @@ -2032,6 +2040,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; @@ -2117,9 +2126,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 @@ -2145,8 +2155,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 @@ -2845,11 +2856,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 @@ -3917,6 +3928,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; @@ -3960,9 +3972,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 @@ -4013,9 +4026,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 Wed May 15 18:29:22 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=1695907885; cv=none; d=zohomail.com; s=zohoarc; b=Hhk0U73o6hNHRmsLDTf5OjH+NcjLZ9cuD1fOZptL8PcdzIpbFeLt5ktQ2d9s+RyOfxyNjebDe2INpTdW3jCnCf4K0rmv9Ap6GyZwXtL/3PdiBj2xS//fmkUnQiSOflh0uHZZAZl1452ty2Fmk4+d2erY4XS4r3p+8A3sp7bxpLU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907885; 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=gvSdTwT4YxNh7LQx8AAvRG7FkEwC6IT5b8c9oaYOX4E=; b=BLbAuzIeaHqgvxd2DDpmQdlwLVs/mhZFTp9M/fv7P9wiSN3BKBAQhbydUlIikf/Mq5B+XAqX0DO3fZFTo6w5uqWIZuO0DmuH19iFc/gNJdj6anGVNkQpx4DJzK+g5ZgVSjKUueubKVJzMOuAuCiH4IqaT9wYa/jS2aulAgrL2Gk= 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 1695907885133494.64601013088645; Thu, 28 Sep 2023 06:31:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlr67-0000A8-BE; Thu, 28 Sep 2023 09:30:31 -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 1qlr60-0008VC-Mk for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:30:26 -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 1qlr5y-0002AU-3P for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:30:23 -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-sEAK8owkPFqMG1RET1IzUw-1; Thu, 28 Sep 2023 09:30:19 -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 6745E8039C8; Thu, 28 Sep 2023 13:30:19 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2957B14171B6; Thu, 28 Sep 2023 13:30:19 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 3847821E6899; Thu, 28 Sep 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907821; 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=gvSdTwT4YxNh7LQx8AAvRG7FkEwC6IT5b8c9oaYOX4E=; b=b+AXfdpWNMYSjHQJBCpXb9ggfdbPmXL8MZrWVGyCX4VZI3mTHpn8BYtNz+RImHPdA+K51i x4S4cqlbK/6Je7q5D1DQCeuiDfdaoWveUQEblA86tFs2gLjz9+WGHVhgaWCsWN/Z4sKW+t RXZELBCo0G4D6+lEgH4JAE1h7EifV6k= X-MC-Unique: sEAK8owkPFqMG1RET1IzUw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 37/53] migration/rdma: Convert qemu_rdma_exchange_get_response() to Error Date: Thu, 28 Sep 2023 15:20:03 +0200 Message-ID: <20230928132019.2544702-38-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 1695907887486100003 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 Reviewed-by: Juan Quintela --- migration/rdma.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index f77bf1d453..2f6e22e1f2 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1824,14 +1824,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 @@ -1844,7 +1845,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); @@ -1854,11 +1855,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 @@ -1908,10 +1910,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; } } @@ -1962,10 +1964,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 @@ -2009,10 +2011,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 Wed May 15 18:29:22 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=1695907275; cv=none; d=zohomail.com; s=zohoarc; b=m2J+gri16J4iGV0Dj1nPLEqB5b3+jxnYI91h9R/tdqWJ4UfzkzCWr8qiqOwETwIYJTrYSCRKOAWWHGXUrsiyJ5G9iM2ERWHP7YcraFS4903xW15AWZxLxSkQrbsOkF6HmCmAVbW6UqtTUgoo0vobw0CkxC619rYoqbQD2lFXLJA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907275; 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=HBSYcgbMjpFLppiBSk+jEA/Y9CEn75eYRMPPawtwHNA=; b=OCj3jvsCiau75/GODxj2P3kQuMinJFWcZRMcIISw8n0erLDRJjvL/dvalqk4u1BZ2aWschlH1HT+/WKXfP52SMGy8KyhJH+//XH4H2YJIVRYWb3l/7WZzNenImBCKs+/nXavtv6A6jjLSbkK6HCC6Fti9ozapQovMP1jI16+INI= 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 1695907275427334.5015956912323; Thu, 28 Sep 2023 06:21:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwm-0003gk-Jx; Thu, 28 Sep 2023 09:20:52 -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 1qlqwb-0003bH-T7 for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:42 -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 1qlqwP-0008G9-Cj for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:41 -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-693-crh1dRODM0C25PAlP_TXCg-1; Thu, 28 Sep 2023 09:20:24 -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 2FD38811E7D; Thu, 28 Sep 2023 13:20:24 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0D302215670B; Thu, 28 Sep 2023 13:20:24 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 3B3CD21E689A; Thu, 28 Sep 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907227; 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=HBSYcgbMjpFLppiBSk+jEA/Y9CEn75eYRMPPawtwHNA=; b=Jtnc7d3fKwEYBoscY/owwxNR3y/wkwer0LJ5zOnwLCl2OdXEK31BAQeajGneH56Mg1gCwt hVaJ42O3ob0RhktRp8hLkJa4Y3Gr7boZronhvJ/XGYnPqUBALzdWIWwFsYhzYTJTEIZApr pw2Zb1DXuhIUc5JL94bNIj1OrjywnKI= X-MC-Unique: crh1dRODM0C25PAlP_TXCg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 38/53] migration/rdma: Convert qemu_rdma_reg_whole_ram_blocks() to Error Date: Thu, 28 Sep 2023 15:20:04 +0200 Message-ID: <20230928132019.2544702-39-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 1695907276880100001 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 Reviewed-by: Juan Quintela --- migration/rdma.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 2f6e22e1f2..fa15b1f6ce 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, @@ -1177,7 +1178,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; @@ -1217,16 +1218,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; @@ -1899,7 +1900,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; @@ -1955,9 +1957,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; } } @@ -3664,10 +3665,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 Wed May 15 18:29:22 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=1695907413; cv=none; d=zohomail.com; s=zohoarc; b=HmSb+O1pVZcPiOutbNI8G8w9ByFWKWm08Nh0AK137VjI+GgrlWX6vY6djmqElx6m/ieXL1bX+zN/NDFhEDNk8xcL4PtrrMW3zgiIcZGO1XhtH/6W5M/gxqHB13YDOh2SKtV/HSvH2FO53ebG2WG5Fxlt3D1mFNWJSiZ2sIhDuvY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907413; 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=3ksr/HVYGzKhafa0I1JJDTgH2G5To7XSy4BpXrCyEHE=; b=eQJLsrK+viy5WXlPEEUC1bd4N8rRbbfMj8ZaCvhEw5JG7W7rrdPLPm1v+d++HDilHdZ3qmIVwTnroGrPoX/CL/gUvlSF/MDHcTArXAR3zVzq1p7OmDPUNLHToSpCPa36bhMcG9ZjVskXi2v6otxtbJsqgfwy0C4vOOEviEaAssY= 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 1695907413019308.631569030312; Thu, 28 Sep 2023 06:23:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwt-0003k2-B7; Thu, 28 Sep 2023 09:20:59 -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 1qlqwZ-0003aK-Gi for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:40 -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 1qlqwP-0008G7-0i for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:39 -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-538-sGtg_R3gPt2LwvKPOKDY5g-1; Thu, 28 Sep 2023 09:20:24 -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 3BF6C802C1A; Thu, 28 Sep 2023 13:20:24 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 189152026D68; Thu, 28 Sep 2023 13:20:24 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 3E51821E689B; Thu, 28 Sep 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907227; 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=3ksr/HVYGzKhafa0I1JJDTgH2G5To7XSy4BpXrCyEHE=; b=HTey1V8+yosSqcxlnHdAPFwWDtWieDtgEx25pbd9/GI7++NyKKTrRWYPQCsDIEWvUe6omJ s84BQCg9s+OjkpHGQekFNurStTX+qeCMX1XCZdHUYmfynCOuTIyMLgvxZZTlUpNHCYmsRu hJSj/6LEolGpbtRvokDGzdhdbtNKa1s= X-MC-Unique: sGtg_R3gPt2LwvKPOKDY5g-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 39/53] migration/rdma: Convert qemu_rdma_write_flush() to Error Date: Thu, 28 Sep 2023 15:20:05 +0200 Message-ID: <20230928132019.2544702-40-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 1695907413565100002 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 Reviewed-by: Juan Quintela --- migration/rdma.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index fa15b1f6ce..feed8712bb 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -2264,7 +2264,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 @@ -2276,6 +2277,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 @@ -2349,6 +2351,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; @@ -2356,8 +2359,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_mergeable(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; @@ -2374,7 +2378,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; @@ -2839,10 +2846,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 @@ -2984,9 +2990,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 Wed May 15 18:29:22 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=1695907589; cv=none; d=zohomail.com; s=zohoarc; b=JA7DNckOcko7Awsmjf1R/lBOjbmxf67c/4nVvDcYtPzeFb1kV0NmArrDXZ0gbHopxV+5VN4I6EHuQFBmEpkf/o/lD+DHHNtff7PybieEi5ybjBGVcesBZ2nHEBYrF2apA2+3eG/BhuzuLl2voAJJshnrFybpWBQXaxmymGS91JA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907589; 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=MvoAxvYZaqo7bzchnP58oSUeeoRm4YLTIfoBKaMl0mM=; b=NmwheTITVA2S6jf1ubtgrGXS+ha2d4udpl8EcfbpIYBrQ0U+c8KgmyHmeJcs5ruL/ejj3R1KQA4767Sc0GVWS72VWdg8qTrsWAY/x51SPh07eB/kWYBcQUS+LjrnivumIU51DtR7iyFlTM+ixWprmGbWNHVsPPj+GjV6wV+NeLA= 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 1695907589446745.6749231346204; Thu, 28 Sep 2023 06:26:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwx-0003oA-W3; Thu, 28 Sep 2023 09:21:04 -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 1qlqwd-0003bi-9H for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:43 -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 1qlqwP-0008HW-N0 for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:42 -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-108-mVq5IydKNmyJdQxRrsr_Tg-1; Thu, 28 Sep 2023 09:20:24 -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 5C2CF280A9CD; Thu, 28 Sep 2023 13:20:24 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1D24F40C6E76; Thu, 28 Sep 2023 13:20:24 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 4153621E689C; Thu, 28 Sep 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907229; 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=MvoAxvYZaqo7bzchnP58oSUeeoRm4YLTIfoBKaMl0mM=; b=X+5HuliACwtm9kPvhW3rDEx3wbOWaxQPeiSka2OEJVBNtzBUtdf+oEend+yA0ONamyF8E9 MSs/SnTeBFbiFn/ed0eYrPnkhW02OVSo21UMoMFRLlYeMfSyrEeDKWtOvmfwj7L2QuLRMB ffRMp5y6ZzNXYgP4K9J2TCzsJ5VprO4= X-MC-Unique: mVq5IydKNmyJdQxRrsr_Tg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 40/53] migration/rdma: Convert qemu_rdma_write_one() to Error Date: Thu, 28 Sep 2023 15:20:06 +0200 Message-ID: <20230928132019.2544702-41-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: 1695907591789100011 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. Bonus: resolves a FIXME about problematic use of errno. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian Reviewed-by: Juan Quintela --- migration/rdma.c | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index feed8712bb..928d09d177 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -2040,9 +2040,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; @@ -2096,7 +2095,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); @@ -2128,10 +2127,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 @@ -2157,9 +2155,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 @@ -2167,7 +2164,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 @@ -2186,7 +2183,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; } } @@ -2198,7 +2195,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; } } @@ -2232,7 +2229,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; } @@ -2240,12 +2237,8 @@ retry: goto retry; =20 } else if (ret > 0) { - /* - * FIXME perror() is problematic, because whether - * ibv_post_send() sets errno is unclear. Will go away later - * in this series. - */ - perror("rdma migration: post rdma write failed"); + error_setg_errno(errp, ret, + "rdma migration: post rdma write failed"); return -1; } =20 @@ -2274,10 +2267,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 Wed May 15 18:29:22 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=1695907391; cv=none; d=zohomail.com; s=zohoarc; b=ivSmo+VlGac6EO6tT1yzcYt71edbPGsLdSJQxJDTX3PyGKx1mBi+irLTzsKpqjTpaad9V/whzMV0ck1D01RnavtUil50ByM0IA6fJ17x/IKbX7o7NNmYRTVQY/mhdfS9NIodihe5e0Fgl4yNfB0MW5VwcXtlY45f1I1lOVxmUuQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907391; 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=zGfVCDlbwT3XOsekU472kimfdR7tarx08HWXHpeP0D4=; b=OtD1kwa6HtnhlqTmlZnnn579aevMtycaYiic6cwIfmWTj0QF7Gk0kwSH1vbLIFvsiKIlQhIAeCuX0x8BrDgNXl5WMn0pYDfucflKmx/oy3dihxLRAwKVmI21ZAkKwxs024NMktSkVg/m2HyL6GVNxvAjNJsWVEGgwL9FPznShm0= 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 1695907391611612.6307054570964; Thu, 28 Sep 2023 06:23:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwu-0003kg-QL; Thu, 28 Sep 2023 09:21: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 1qlqwU-0003Tx-3w for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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 1qlqwN-0008CZ-5f for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:33 -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-355-WzVlIeHRND-RaYbRCdA44g-1; Thu, 28 Sep 2023 09:20:24 -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 4024B185A78E; Thu, 28 Sep 2023 13:20:24 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1C57A492C37; Thu, 28 Sep 2023 13:20:24 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 442B821E689D; Thu, 28 Sep 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907226; 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=zGfVCDlbwT3XOsekU472kimfdR7tarx08HWXHpeP0D4=; b=ZF/TdwTGmA0mImWTdKiZ5U2Rp3qY867I3bvez4RnUBirx860llgk5lRvB/dPhz9m5VBVTM htwBO1VZRbQYxLMdA/i2Mws5Y4M7OmFyGXNW8STQHqDYngRxoWv2bCNlWdgkT3LwP3r06e vV1GQAS4v1xTm+Clvn+tNxm+yL0loFg= X-MC-Unique: WzVlIeHRND-RaYbRCdA44g-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 41/53] migration/rdma: Convert qemu_rdma_write() to Error Date: Thu, 28 Sep 2023 15:20:07 +0200 Message-ID: <20230928132019.2544702-42-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 1695907391887100011 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 Reviewed-by: Juan Quintela --- migration/rdma.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 928d09d177..528f468dfb 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -2342,9 +2342,8 @@ static inline bool qemu_rdma_buffer_mergeable(RDMACon= text *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; @@ -2352,9 +2351,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_mergeable(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; @@ -2371,10 +2369,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; @@ -3275,6 +3270,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 @@ -3300,9 +3296,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 Wed May 15 18:29:22 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=1695907401; cv=none; d=zohomail.com; s=zohoarc; b=TF00YKgkyOTG3b3H3+Ha4cQFUQh+Yf8/eNjP85AOj38ztjJr4laRqhP9R4naqLhZ8PQkhqvctMTlkMcAEnm7b/a014FnDp58Z1nDr+U1LH8WQlKdqbKRHawTxaPQIIEoJoRPduhk4KcjBHOjr6tomsrB6NPF9j/k3/bZjUUx5Po= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907401; 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=dU6NTz0YatR+p/nSxRUODmmK9IcTghN7g+G8p1T3iGY=; b=LEu1TH5BfxWlLbOCnVybjX2Iy9+4yBmRIWL/YsINUgQZ62PwBa69JFa1OFpvSg2FK2lV2fXP5S3TZfdMZaSTrcXcnzJtD0WRzTLlDVpUC3+d+Cj0+jOgfK3EpcTP7/NTfz4fWZgfuVNQGDpXBmKmgmKjzvi9uvKZWIkZNBPEjYQ= 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 1695907401397853.8858617178034; Thu, 28 Sep 2023 06:23:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwu-0003k6-0E; Thu, 28 Sep 2023 09:21:00 -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 1qlqwf-0003ds-4e for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:45 -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 1qlqwP-0008Hf-S3 for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:43 -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-375-zYhS4oJKN8ymNs-RYGtieA-1; Thu, 28 Sep 2023 09:20:24 -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 5F9273806705; Thu, 28 Sep 2023 13:20:24 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 219D140C2064; Thu, 28 Sep 2023 13:20:24 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 4706B21E689E; Thu, 28 Sep 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907229; 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=dU6NTz0YatR+p/nSxRUODmmK9IcTghN7g+G8p1T3iGY=; b=Hb2b5yR4Lmxprn/SFcge4Rz7sz+/1AZPzVC9PCR9WhzFgWZDBRcXdkkhCJ3ASabA2E+H6J /sdJNvoTqk1xXLvLt0ojgsG+M/rDU/Lsszs8qR6q/MU+DmCKr9rCPeCdSgXWM2Oih0G10P Zj4HMGRcF8X4q6VD0nDAoelkKzRL1N8= X-MC-Unique: zYhS4oJKN8ymNs-RYGtieA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 42/53] migration/rdma: Convert qemu_rdma_post_send_control() to Error Date: Thu, 28 Sep 2023 15:20:08 +0200 Message-ID: <20230928132019.2544702-43-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: 1695907401991100043 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 528f468dfb..ce56ba9b40 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1741,7 +1741,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]; @@ -1781,13 +1782,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 @@ -1944,10 +1945,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 @@ -2001,10 +2001,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 @@ -2377,6 +2376,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) { @@ -2388,7 +2388,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); @@ -3700,10 +3702,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 @@ -3778,10 +3781,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; @@ -3813,10 +3816,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 Wed May 15 18:29:22 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=1695907382; cv=none; d=zohomail.com; s=zohoarc; b=BMZuSZnNjoiqE9dbAVNGC1zDO/Oz1sNX3k08Oo6mTqQbm0UskMNEchodAaQwBKIueH1L6kBNq5s17n+YPDG6TV/oCtk7DhceO0Lc3B5WMG/UXqPGW8jr8uTtqNxiUcj2TTH1IkL6/TRO5egdVG5w3wz767mg128Q4YEdBUrauJw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907382; 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=H0ZApXiJBmVA2+yluBuXW6/Hc8px7ssG3YQ2RDU3dCE=; b=BK7PEM7x1cEy/7mziXaQO5+6grlvbBvHTV/EQHAZv8+IYnEhIX5GzvURcEBnfX3j3xEx8assBNWBkZrTjOvRYtiMv3Ak9Z4mLS1oxLYLa1D+382LUj/9fSzG7WjXHQmiqy0miD+pv675fhGrGI1ZLCX8DkXgDuCwo4RNhfrP/QA= 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 1695907382607853.9151121473536; Thu, 28 Sep 2023 06:23:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqws-0003jl-I8; Thu, 28 Sep 2023 09:20:58 -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 1qlqwZ-0003ZW-3V for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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 1qlqwO-0008FL-4t for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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-551-1MPxTCxHMbGSbKp-6txDuw-1; Thu, 28 Sep 2023 09:20:25 -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 4EF82811E8F; Thu, 28 Sep 2023 13:20:24 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2CA2A2156711; Thu, 28 Sep 2023 13:20:24 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 49FFB21E689F; Thu, 28 Sep 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907227; 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=H0ZApXiJBmVA2+yluBuXW6/Hc8px7ssG3YQ2RDU3dCE=; b=BYxpOcPaJGpOvUFX9nH+fUp83tAj+4FiC3GiEiLOUVuq5klqu2fgxH/WMzYJBpDOjvN3tw j4bWPbwrwyp+aHLPnlHKqALiTAxKy4O14ZQM0KCXWyz1RaK58+1yfGrOwv+bS6MUGfLJhn QwRslW/BriW6Vcl1suzWJm/GWkA1zbc= X-MC-Unique: 1MPxTCxHMbGSbKp-6txDuw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 43/53] migration/rdma: Convert qemu_rdma_post_recv_control() to Error Date: Thu, 28 Sep 2023 15:20:09 +0200 Message-ID: <20230928132019.2544702-44-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 1695907384748100007 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 ce56ba9b40..336a960006 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1799,7 +1799,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 { @@ -1816,6 +1817,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 @@ -1925,10 +1927,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; } } @@ -1936,9 +1936,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 @@ -2022,9 +2021,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 @@ -2591,9 +2589,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 @@ -3397,6 +3394,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, @@ -3533,9 +3531,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 Wed May 15 18:29:22 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=1695907358; cv=none; d=zohomail.com; s=zohoarc; b=fIqA26sXiktJAZMBMMbMQnLBwK/v/xXpHJjU64MwnKGA+BpdQKZIU6mGqlS50uLhf7dSUX3w+5rv+vaOS1vti2uunfQ5vyp8F600RViUHG9qDCtYCKTTgpnmXJ5oI9jSmJFQDnKjjW9g1Mr6eSnviOsdNyN9FnKOtrHVE/vG5y4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907358; 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=Fi9I0N8egcy4maDFLCKyaxK1dBxF4FmOLc/Iqn3NDjA=; b=XdixgJNVUVcifdSELtD/R2ouf+jVKCklQ2ziFPEoRZ+h6Kdrl8IsQPbtFI5m4vcvEc79IoYylMFtrKRN0g9FL3rBOGER6yMxDTfbecs93i74MnU7sHjlGdSIswflCFFYVzxE8H0HtEOLGdX7Cpv7BQFn8VKiXRpizau9j8XA7Ug= 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 1695907358054610.6712161210498; Thu, 28 Sep 2023 06:22:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwu-0003kB-D6; Thu, 28 Sep 2023 09:21:00 -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 1qlqwb-0003bA-99 for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:42 -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 1qlqwP-0008GN-8Z for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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-304-s9n-qNcHMtiIrM4ukHd8vg-1; Thu, 28 Sep 2023 09:20:24 -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 624F0280A9D1; Thu, 28 Sep 2023 13:20:24 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3F4E010005D4; Thu, 28 Sep 2023 13:20:24 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 4CE4E21E68A0; Thu, 28 Sep 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907228; 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=Fi9I0N8egcy4maDFLCKyaxK1dBxF4FmOLc/Iqn3NDjA=; b=f6kHmz1O6V+pRY/+IBtJNeCcbXQj7PNcEn396WGYJF/AKdQr6k/qNlt4KvLWNK3a2txZk5 Y8k7g5+yNMdlVP+ZRCji7OYnkgc27GmJejtZpUMLmfH3UZyB9rIi/MdbMRNR2mIX4cG99Q OjQZfCQnjdTZWFP0gANhKiS5oQTQ6HQ= X-MC-Unique: s9n-qNcHMtiIrM4ukHd8vg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 44/53] migration/rdma: Convert qemu_rdma_alloc_pd_cq() to Error Date: Thu, 28 Sep 2023 15:20:10 +0200 Message-ID: <20230928132019.2544702-45-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: 1695907359853100001 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. The conversion loses a piece of advice on one of two failure paths: Your mlock() limits may be too low. Please check $ ulimit -a # and sear= ch for 'ulimit -l' in the output Not worth retaining. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian --- migration/rdma.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 336a960006..44d8202ad0 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1052,19 +1052,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 @@ -1074,21 +1074,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 @@ -2486,12 +2486,8 @@ 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"); goto err_rdma_source_init; } =20 @@ -3477,9 +3473,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 Wed May 15 18:29:22 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=1695907609; cv=none; d=zohomail.com; s=zohoarc; b=dihdkyz+L709McufOwuQA5EfkHBYWIYyJBbsA796AX03b3loAJ1DCdP8WVr9gb2eKPN/Nv/XUfpTxocJiAZ/9D9UlLYElMpW0pxeGjKB+ri/fvZnpjNvuGnyGyxMsyvI1JW72+WIJ5QXm4kiiqsXky5I0WzhsJpVMU3b/f81cpA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907609; 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=zwrbc/sWT2i6+HT1daIN7vFGiMWzyZGzx0MXJ09uwSM=; b=lHbFp1NnaGaoj6JUVxwwWd63JMLEGuOai4THzuffygLVR/fDpIxI4WpalMwPTKIzw5ermsYoAM6zfHC3k0R37CyLfi9FeEUCnYK1ewcA4+eMLRKV6MsBBZbITwre+Ff6VXhQnY+afeG0NQ3eEqavckYPWZf8DlGCzxFFCuO44eg= 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 1695907609456403.2994127501005; Thu, 28 Sep 2023 06:26:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwx-0003nx-L9; Thu, 28 Sep 2023 09:21:03 -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 1qlqwc-0003bh-Mt for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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 1qlqwP-0008Gr-HT for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:42 -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-693-fjo1U8faOnuocbsfOJ6rHA-1; Thu, 28 Sep 2023 09:20:24 -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 6C03C801779; Thu, 28 Sep 2023 13:20:24 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4A1A8C15BB8; Thu, 28 Sep 2023 13:20:24 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 4FD5721E68A1; Thu, 28 Sep 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907228; 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=zwrbc/sWT2i6+HT1daIN7vFGiMWzyZGzx0MXJ09uwSM=; b=AUy5W+yJ/eoRwod9RpgX01inStx0ddOit0BvjVHqfCf3ngscXPacTowTrjMEjHYsCe+XTg pBpPD93BVKXejLQD0o4r3v88XWDrCn9isF8ylbSAFeevE8NiEE8R9GMcbok3Nb9P+SWqhf Niq3i/6EiiSdtYgyHZTs7cVcCh1eI5M= X-MC-Unique: fjo1U8faOnuocbsfOJ6rHA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 45/53] migration/rdma: Silence qemu_rdma_resolve_host() Date: Thu, 28 Sep 2023 15:20:11 +0200 Message-ID: <20230928132019.2544702-46-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 1695907610133100002 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 44d8202ad0..5e21dfca53 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1009,7 +1009,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 Wed May 15 18:29:22 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=1695907656; cv=none; d=zohomail.com; s=zohoarc; b=bfClGEmuTCruMuFjawjG2qB7ndd1RzJwilY5LZnNwk2uFGeU5n3z99Mib9H8GO4guPR9pT5NHvcp/XDxruc6jHA4ExGAjOcMTEiUurLeyWzqFFjTCuftDqdKDpDsuphriVWxC+0/UfTY0aO24NMfOnNhiVKPy97EXMZbo+STpmk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907656; 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=dSbbh7b3IM8bH80t3W/RtJ9cNch0EcMObMQfYNRheuY=; b=lDFSzxtg6X1605XJ3whZh021arOUW0Bn/ZFHjXjIrpCLx+7ZS3+yh8chikBqw7+gNOXcjT/+Nnqtp64Zwl7Gr+7wZSKn79XU22eOYYjOxRw5fwg47YefgsXRx7c/ePdLeyYQMIiZcfUkeOHSCmuwO2WuuBkceLu9KP/OFqQsXAc= 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 169590765627338.77781549392148; Thu, 28 Sep 2023 06:27:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwr-0003jE-QA; Thu, 28 Sep 2023 09:20:57 -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 1qlqwV-0003UJ-2d for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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 1qlqwN-0008E2-F6 for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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-540-7qLXGBcXO9OpueMGYErWCg-1; Thu, 28 Sep 2023 09:20:24 -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 6E96B18175A5; Thu, 28 Sep 2023 13:20:24 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4C353167F8; Thu, 28 Sep 2023 13:20:24 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 52AC921E68A2; Thu, 28 Sep 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907226; 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=dSbbh7b3IM8bH80t3W/RtJ9cNch0EcMObMQfYNRheuY=; b=UprUS4v20tI8VPzBdQ59MD/4Kxht5EjjUR8LUntSRt6PI9u3teqNjqx5oQYcxGmRmK+i9J nAsV4ilu0teirudqh1Ua1POlrOcRk8wluzFwUbD/uE4tG+oPOy698RyjgRQGsW1cHb1x8P pknQQ9+V9ByD2zeN8n+jbyveWoD8CrQ= X-MC-Unique: 7qLXGBcXO9OpueMGYErWCg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 46/53] migration/rdma: Silence qemu_rdma_connect() Date: Thu, 28 Sep 2023 15:20:12 +0200 Message-ID: <20230928132019.2544702-47-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 1695907657794100003 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. Bonus: resolves a FIXME about problematic use of errno. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian --- migration/rdma.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 5e21dfca53..b85d5e60cb 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -2591,8 +2591,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 @@ -2601,21 +2601,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) { - /* - * FIXME perror() is wrong, because - * qemu_get_cm_event_timeout() can fail without setting errno. - * Will go away later in this series. - */ - 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 Wed May 15 18:29:22 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=1695907892; cv=none; d=zohomail.com; s=zohoarc; b=PgCsjXPW0zsW/g5/pUm2O40V9ufvl4A1ztixHiwNFLawtO6QwUl5Xhug0oilLafAWVyNKLUdcLLTmHN6ZxpSmqUwTqjWMuv5Ky8dB/TteeyzjFNDjP4ElEe5rG5tw/JYlNbQxuLN1aa61LV6JDsLmKHL14afpxObIY5SwwiMjjM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907892; 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=VdcwGt1+mpZaJdoWHalEtHFN28NCEbpdTXVENgpDBjc=; b=nb92i7LydY/OuI5/OJOx3AZqIXUOeCpJz/C712kgHYeLUX4nz/yzHhUcq4YSB8Y21vI+wYo/JTRJ8oN0vdZyNOFhOll/GwV2EjDDlXzKBCZD88fzMUnXL1tYWA/RBvPbCBY/6N5QYHY3Ubq+BdOXxkcVBaqzorRnqOtwaPutg2A= 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 169590789280453.341707724889375; Thu, 28 Sep 2023 06:31:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlr6A-0000JH-53; Thu, 28 Sep 2023 09:30: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 1qlr5y-0008Uk-NI for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:30:24 -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 1qlr5w-0002A2-VC for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:30: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-658-mQRndgcVOrazpNYwPQOvuw-1; Thu, 28 Sep 2023 09:30:18 -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 40DC78001EA; Thu, 28 Sep 2023 13:30:18 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1DDB7401025; Thu, 28 Sep 2023 13:30:18 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5578521E68A3; Thu, 28 Sep 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907820; 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=VdcwGt1+mpZaJdoWHalEtHFN28NCEbpdTXVENgpDBjc=; b=Lv8rYhdv1sRVbvz+s7X+dk/RazkTTUVDF7A4OLvDjfIZXb3V2x4QHq36CN0y0oPugQ0Gvu RHhYNtPs9lxmxVaPlieJzg1Ghc/83Mf22hW//ucvDomQ2eEpUs54A3HJMO0iFsvQOmSb/t Tw25pDJ5rzvCVxbu5epUJd94atD8N/A= X-MC-Unique: mQRndgcVOrazpNYwPQOvuw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 47/53] migration/rdma: Silence qemu_rdma_reg_control() Date: Thu, 28 Sep 2023 15:20:13 +0200 Message-ID: <20230928132019.2544702-48-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 1695907893849100005 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 b85d5e60cb..1ef1e9f3a5 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1360,7 +1360,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 Wed May 15 18:29:22 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=1695907839; cv=none; d=zohomail.com; s=zohoarc; b=Ah0I82+gdl9n2UlAhH0nkiSsZFo6dZ4Jxme4rNcLTKRqK30KFRy7sjtQJMyHFPIfP4FQn4Brk6RN7XLqYErFS1od/X544huo9KwccmekAnbi1f3Z1pV+G7ggvVCEmQIEhtGXPaxcKaJyr+bpDrdDtAFIG0pS6XRZ6UpSvMjB92o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907839; 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=HK1WIiqP3jQtURQF8jHLpWYhzbiIiYgQ5jVB9kZkAI4=; b=b6EMzNsvl4Fl5uNHpLDl9+j8GZ0v2x1wZTdp9q0dr/M3CsK3L9SvU02hRaWPokn/swmqDWXOsxxog9eUJjVhZ/BcLGZFtUz0LNNuQZqs6O0l27KNBbR8g6cE8q8ENt9zc8tjfeN8WoFR7aKnQ2giNTSAewHvOIHVS/LvAkwF9jc= 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 1695907839914778.7188218466757; Thu, 28 Sep 2023 06:30:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlr66-00006n-Ff; Thu, 28 Sep 2023 09:30:30 -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 1qlr5y-0008Tk-Ez for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:30: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 1qlr5w-0002A0-U4 for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:30: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-155-IxmKcJPcM5-JrvZi09krQg-1; Thu, 28 Sep 2023 09:30:18 -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 423A7101AA6D; Thu, 28 Sep 2023 13:30:18 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1DDC114171CA; Thu, 28 Sep 2023 13:30:18 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5854F21E68A4; Thu, 28 Sep 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907820; 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=HK1WIiqP3jQtURQF8jHLpWYhzbiIiYgQ5jVB9kZkAI4=; b=N14G4B3S05Dx0objF62S2ZGRHbK1BnYr+sQ86jotNcSBxPx8QqC6PUZzQqgO5e38r+wB3U vVKJNzdOXDkYQlRvfNAAZp3Fs3rbg+HZqEYcYn1bunuNexptas3lz5+qN4RuDj7gUIGvir u/zZTg2QFXIGzXnDbWOx3xRB7Zjpykc= X-MC-Unique: IxmKcJPcM5-JrvZi09krQg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 48/53] migration/rdma: Don't report received completion events as error Date: Thu, 28 Sep 2023 15:20:14 +0200 Message-ID: <20230928132019.2544702-49-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 1695907841413100001 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 1ef1e9f3a5..f4bb329671 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1582,11 +1582,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 Wed May 15 18:29:22 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=1695907863; cv=none; d=zohomail.com; s=zohoarc; b=MlJu3D21wSu3aqYPVWhr2c9zBsS5JKYA6xZ3CVYblZQzO0qWXznxjSrJaMoocaUEU1aPOX5M9V+Ck/ZHqRS6hDLeboqJk0f2obp6vDXUSSr+WWKZUplTPHGLFWX7VRgndRqGvpGjcG0I1d4bDWuBWfXE0dzJvtdLvA4zAG2qgRc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907863; 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=puNVjsA5MWcd8I5pM9KDRUcm2ONy0UJkA9zAUt+v/PM=; b=luW6ldRrC20B7vx9AshpT4trtI8xHydkg+c67fnRm91EcxDEiBZWXy2sa7zbM2Hcp8f5w3OzahMG98FNMCADPdPhDQUYlGEkMzE4VDx4BDBwSA3lsca0z8WHQkeS1w/cl51oz4rAddF8PQ2aDq9+1gUBmVrgnbJ8DIPmwKMm3Og= 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 1695907863627178.41262595831006; Thu, 28 Sep 2023 06:31:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlr6A-0000JE-4G; Thu, 28 Sep 2023 09:30: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 1qlr60-0008VG-Nu for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:30:26 -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 1qlr5y-0002Ac-HQ for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:30:24 -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-183-ac36gt0UNaKxXvMF-gjOxw-1; Thu, 28 Sep 2023 09:30:18 -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 425E18039CF; Thu, 28 Sep 2023 13:30:18 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1DE91178B5; Thu, 28 Sep 2023 13:30:18 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5B2E321E68A5; Thu, 28 Sep 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907821; 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=puNVjsA5MWcd8I5pM9KDRUcm2ONy0UJkA9zAUt+v/PM=; b=RSGOHXhDvrvWyRovEFpHVsO51tH5I+ug4jqb3vAbDPahBeDZJ0DuGCnXkPYB56YWax3Iey 0w8V3mfU8HX1gBlezztiw65ot/Dbhi8s47Te1nb3KHa/oezrXY2PQ7Ucpf3wNn6wO8xX30 A+hLPIx8nDkkDY2kGF9+K8rIqnoVH8M= X-MC-Unique: ac36gt0UNaKxXvMF-gjOxw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 49/53] migration/rdma: Silence qemu_rdma_block_for_wrid() Date: Thu, 28 Sep 2023 15:20:15 +0200 Message-ID: <20230928132019.2544702-50-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 1695907865177100007 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. Bonus: resolves a FIXME about problematic use of errno. Signed-off-by: Markus Armbruster Reviewed-by: Li Zhijian --- migration/rdma.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index f4bb329671..6c63f9c269 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1483,17 +1483,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 @@ -1577,16 +1572,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); @@ -1599,7 +1590,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 @@ -1683,12 +1673,6 @@ static int qemu_rdma_block_for_wrid(RDMAContext *rdm= a, =20 ret =3D ibv_get_cq_event(ch, &cq, &cq_ctx); if (ret < 0) { - /* - * FIXME perror() is problematic, because ibv_reg_mr() is - * not documented to set errno. Will go away later in - * this series. - */ - perror("ibv_get_cq_event"); goto err_block_for_wrid; } =20 --=20 2.41.0 From nobody Wed May 15 18:29:22 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=1695907546; cv=none; d=zohomail.com; s=zohoarc; b=FezVaOnSI+GoeJ6/9U8+xvM6buqKntHL3VyW4sI4pF4TRb9l4hSa6483JNKTna89io46xGB+bpWeaQaQnHvQbAd5rld+pdAQ6ehQQB7CJ8NuUhqr/dAWGY96COIgoED3QQFgq1fx+eipBJ/gFz7xg2u1aenABukUHaZ2HNshSlc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907546; 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=ghHgLUIvURwmGikhRFTWt9ONxwDm/FS8NpoQo04FRlM=; b=PqAetJ4c0+xYmc2gEtclDaQ/rCE3UD1WKD2VrXtlAR/8L/jDv8GAHBqJNgOV13cpIs3ROxAPfFd9mGVesrXMUFbtb0XowvXTLyu6j39OzSjugAM97EutG1er5stGUAd6oN42eN+82yTHZCLx3xGpvEVl7L8NNnpLIRClIH0s9JA= 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 1695907546888794.6988194222137; Thu, 28 Sep 2023 06:25:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwu-0003k7-4f; Thu, 28 Sep 2023 09:21:00 -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 1qlqwd-0003bg-I3 for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:44 -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 1qlqwP-0008Gl-FU for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:42 -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-375-H-5xaNKgNxCPyT85VSE3Rg-1; Thu, 28 Sep 2023 09:20:24 -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 771B33C147E3; Thu, 28 Sep 2023 13:20:24 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 554AC40C2070; Thu, 28 Sep 2023 13:20:24 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 5E11521E68A6; Thu, 28 Sep 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907228; 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=ghHgLUIvURwmGikhRFTWt9ONxwDm/FS8NpoQo04FRlM=; b=Djpqfr62mqEhX21tE5P+8rMif4KDUc1tZJBNPrTH9F9f370x7KcfvfpjFBAdzraw+YaA3m 5xgJm2q2ylT9lq+Yx15vilFuczkyXY4Xwio2zgz29hfUjU9EaodZAQ+zBqEgIpHyCVoT9K ECiNu21pWQup1Httf9pTIKC4vp6rJik= X-MC-Unique: H-5xaNKgNxCPyT85VSE3Rg-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 50/53] migration/rdma: Silence qemu_rdma_register_and_get_keys() Date: Thu, 28 Sep 2023 15:20:16 +0200 Message-ID: <20230928132019.2544702-51-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: 1695907548505100003 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 6c63f9c269..4e4d818460 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -1325,15 +1325,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 Wed May 15 18:29:22 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=1695907892; cv=none; d=zohomail.com; s=zohoarc; b=CUG2LY/PxIHfuFCGXXLa+eVo1ScQNE0GdQfU7St4BCRr41+ZZM2u3GLMxTNIPpiTqkfqelT0LpvvtAja5Iy4T0GNfY5mdyrsO3xGUT4DfgMqAtufmaxcLtEp0OUoJv9ggVLAZFSTt2NbybXk7DvWXLKjOlq2/pbUWon4MtogL/U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907892; 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=QbbKuX2C0YajtpZusWsKJXC+ho+rE+txMpKidZr5q5E=; b=PUIpb3Pbsm7fsJOpRbR5hgDmmfeOAJpytCFPezHNMwL5MHcOhBNqAEDUfthAMQk2do33Umxj/ZjBAiR1eEgvIwupDDthh/j3YU36gedcIn8cH3DDRvKY5kb3JE64oHDsj6++NH4Dww70TCTekMz7BfHkAGoGvKeGhMin0WKKhDw= 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 1695907892868346.8171779172985; Thu, 28 Sep 2023 06:31:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlr67-0000A3-9d; Thu, 28 Sep 2023 09:30:31 -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 1qlr60-0008VD-Mq for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:30:26 -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 1qlr5x-0002A5-3r for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:30:23 -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-647-cn0zZ7JSPMmyKN7Mhq1MxA-1; Thu, 28 Sep 2023 09:30:18 -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 414853C1F12F; Thu, 28 Sep 2023 13:30:18 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1DD6E492B16; Thu, 28 Sep 2023 13:30:18 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 60CEC21E68A7; Thu, 28 Sep 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907820; 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=QbbKuX2C0YajtpZusWsKJXC+ho+rE+txMpKidZr5q5E=; b=HaAvMFHdB89ufxAz//bfuRJckcCQH2AiotAcyebLcSrXC7yN2r3QlIkc0urbyweCtel2sC 5Hw3kwFUqb4WRDx+eCAtwiYwaVO5JrqgroWQs7iIQkJ8qPFq/rYBW1wjKuiKQZP4hF+XJa 98fewytRrbkGnc1dRhRpfSLGPalzy3U= X-MC-Unique: cn0zZ7JSPMmyKN7Mhq1MxA-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 51/53] migration/rdma: Downgrade qemu_rdma_cleanup() errors to warnings Date: Thu, 28 Sep 2023 15:20:17 +0200 Message-ID: <20230928132019.2544702-52-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: 1695907893301100003 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. Downgrade qemu_rdma_cleanup()'s errors to warnings. Signed-off-by: Markus Armbruster Reviewed-by: Fabiano Rosas Reviewed-by: Juan Quintela 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 4e4d818460..54b59d12b1 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -2358,9 +2358,9 @@ static void qemu_rdma_cleanup(RDMAContext *rdma) .type =3D RDMA_CONTROL_ERROR, .repeat =3D 1, }; - error_report("Early error. Sending error."); + warn_report("Early error. Sending error."); if (qemu_rdma_post_send_control(rdma, NULL, &head, &err) < 0) { - error_report_err(err); + warn_report_err(err); } } =20 --=20 2.41.0 From nobody Wed May 15 18:29:22 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=1695907490; cv=none; d=zohomail.com; s=zohoarc; b=bHBhcYt7/kASTD3NXOy1o1sRlULbNN/Ng2ZLTCwDnc0tqEnVEse9gg1DvQvgFg6PmPLuH3KZAGPOm40M0nH2pdwUImbnfgeQbRSyeuFD6AEBHba2z9PVbIubOVY/PC6FquwwWxQdWapgPtDJZ7V2jX9gLMNwFFplKFTKvyt/vPs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907490; 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=49Bv7Dofr5UvI14peediqqhFMTxEz9FQqsHe3ZrFKEQ=; b=jWhCAP7yxiZYF3k32Yv83tgrnK75G+i9ZIwIiClGA6q50M5px8BudXe7g8WoMnztl3nm0dOUPs57JAzHypDoimY/0MEavmLNoMOuXHDSJdRAcKmLkSCWYYdaO3L9T2yFmOqiEydNPM0RBtZgSDKEj6YHHoLhtr8hEwY6uKZeqUA= 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 1695907490038319.23458114839866; Thu, 28 Sep 2023 06:24:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlqwl-0003fp-Op; Thu, 28 Sep 2023 09:20:51 -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 1qlqwc-0003bU-80 for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20: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 1qlqwP-0008H0-F6 for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:20:42 -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-cRFlFpxtOHezMZ8-FcqH0g-1; Thu, 28 Sep 2023 09:20:25 -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 B6DC2280A9C4; Thu, 28 Sep 2023 13:20:24 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7921F40C6E76; Thu, 28 Sep 2023 13:20:24 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 6396A21E68A8; Thu, 28 Sep 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907228; 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=49Bv7Dofr5UvI14peediqqhFMTxEz9FQqsHe3ZrFKEQ=; b=XO24BobdsFMr2AgV7h1A3Jmf5JBH/RhdH1gRApn85fP2uPLSloRxZYo9N6BlrPxUx4a6bO i/SG/9+o5oAkSshI0CMLRU3QCcFBrsPh/mgF6J9mu1nFIKoDYI9FG0W99NzjOuME6Bv1ai Hs0C3DBwQetoQJPRgtkgQJzIPq01MEs= X-MC-Unique: cRFlFpxtOHezMZ8-FcqH0g-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 52/53] migration/rdma: Use error_report() & friends instead of stderr Date: Thu, 28 Sep 2023 15:20:18 +0200 Message-ID: <20230928132019.2544702-53-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 12 X-Spam_score: 1.2 X-Spam_bar: + X-Spam_report: (1.2 / 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, RCVD_IN_SBL_CSS=3.335, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: 1695907491893100002 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. Bonus: resolves a FIXME about problematic use of errno. Signed-off-by: Markus Armbruster Reviewed-by: Juan Quintela Reviewed-by: Li Zhijian --- migration/rdma.c | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 54b59d12b1..dba0802fca 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -877,12 +877,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" @@ -1418,12 +1418,8 @@ static int qemu_rdma_unregister_waiting(RDMAContext = *rdma) block->remote_keys[chunk] =3D 0; =20 if (ret !=3D 0) { - /* - * FIXME perror() is problematic, bcause ibv_dereg_mr() is - * not documented to set errno. Will go away later in - * this series. - */ - perror("unregistration chunk failed"); + error_report("unregistration chunk failed: %s", + strerror(ret)); return -1; } rdma->total_registrations--; @@ -3767,7 +3763,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 @@ -3956,10 +3953,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; } @@ -3972,10 +3969,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; } @@ -4091,7 +4089,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 @@ -4103,7 +4101,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 Wed May 15 18:29:22 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=1695907862; cv=none; d=zohomail.com; s=zohoarc; b=GXJ0xnl8Ews+LJMwdCqVvibhg9jh3kWLSHwabYB4q4iH1gq6VAEWbJFB+5F9HgHyP4TWnc1LBsTFnW/PmNOFAQhNN2OmxTB8zY24ghohk7A9y+wfXYpZO7UffufApxXNfWuAHqQMquSjoYnsIhucHk7Tj91bhOmrK8YCmVcNDWg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695907862; 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=qrXoSPX5ssSQmvEUQlU0T8b2aLThEpACW1OPVTv1Kcs=; b=Rmh2hWlZr3Ns1bCnKb2/48LvayHPeGSCpiSe53RvLR1DMGobl/Ky1SbZzrKWU1FlvKub1u+81vRw7Utb4mvivc5i+vfptN4KfGA2xGqv16qwf0SQDxBHhmMU/DT6jr/DttMkCHxhNrOd67rq0j9OmuRnXGtCAF23LhNdKn9OmMg= 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 1695907862733513.5714320932431; Thu, 28 Sep 2023 06:31:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qlr68-0000An-7n; Thu, 28 Sep 2023 09:30: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 1qlr60-0008VF-Ni for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:30:26 -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 1qlr5y-0002Aq-Td for qemu-devel@nongnu.org; Thu, 28 Sep 2023 09:30:24 -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-647-_7zJxEVuM42x_p7wEAjTSw-1; Thu, 28 Sep 2023 09:30:18 -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 601D1185A79B; Thu, 28 Sep 2023 13:30:18 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2158549BB9A; Thu, 28 Sep 2023 13:30:18 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 666D721E68A9; Thu, 28 Sep 2023 15:20:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695907822; 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=qrXoSPX5ssSQmvEUQlU0T8b2aLThEpACW1OPVTv1Kcs=; b=eYOL/znZ+XI0bSpKtxc3oRNdv1YgX2jAfm0Exq6py0FllMz8U1Cg6BR/KJJtHsc8eqWB8g IpkG6MHTHDwV2uiuN6FYcs+tGHi5zi89K9S/5HmMWCgYgvzCuSMiQHolLsaxxqeoJHuxGN iOJ1I/O88j5OMHs/W032ItPzeyH8I04= X-MC-Unique: _7zJxEVuM42x_p7wEAjTSw-1 From: Markus Armbruster To: qemu-devel@nongnu.org Cc: quintela@redhat.com, peterx@redhat.com, leobras@redhat.com, farosas@suse.de, lizhijian@fujitsu.com, eblake@redhat.com Subject: [PATCH v2 53/53] migration/rdma: Replace flawed device detail dump by tracing Date: Thu, 28 Sep 2023 15:20:19 +0200 Message-ID: <20230928132019.2544702-54-armbru@redhat.com> In-Reply-To: <20230928132019.2544702-1-armbru@redhat.com> References: <20230928132019.2544702-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: 1695907864505100004 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. Fixable, but the device detail dump is noise, except when troubleshooting. Tracing is a better fit. Similar function qemu_rdma_dump_id() was converted to tracing in commit 733252deb8b (Tracify migration/rdma.c). Convert qemu_rdma_dump_id(), too. While there, touch up qemu_rdma_dump_gid()'s outdated comment. Signed-off-by: Markus Armbruster Reviewed-by: Fabiano Rosas Reviewed-by: Juan Quintela Reviewed-by: Li Zhijian --- migration/rdma.c | 23 ++++++++--------------- migration/trace-events | 2 ++ 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index dba0802fca..07aef9a071 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -734,38 +734,31 @@ static void rdma_delete_block(RDMAContext *rdma, RDMA= LocalBlock *block) } =20 /* - * Put in the log file which RDMA device was opened and the details - * associated with that device. + * Trace RDMA device open, with device details. */ 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"); + trace_qemu_rdma_dump_id_failed(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", - who, + trace_qemu_rdma_dump_id(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 /* - * Put in the log file the RDMA gid addressing information, - * useful for folks who have trouble understanding the - * RDMA device hierarchy in the kernel. + * Trace RDMA gid addressing information. + * Useful for understanding the RDMA device hierarchy in the kernel. */ static void qemu_rdma_dump_gid(const char *who, struct rdma_cm_id *id) { diff --git a/migration/trace-events b/migration/trace-events index d733107ec6..4ce16ae866 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -213,6 +213,8 @@ qemu_rdma_close(void) "" qemu_rdma_connect_pin_all_requested(void) "" qemu_rdma_connect_pin_all_outcome(bool pin) "%d" qemu_rdma_dest_init_trying(const char *host, const char *ip) "%s =3D> %s" +qemu_rdma_dump_id_failed(const char *who) "%s RDMA Device opened, but can'= t query port information" +qemu_rdma_dump_id(const char *who, const char *name, const char *dev_name,= const char *dev_path, const char *ibdev_path, int transport, const char *t= ransport_name) "%s RDMA Device opened: kernel name %s uverbs device name %s= , infiniband_verbs class device path %s, infiniband class device path %s, t= ransport: (%d) %s" qemu_rdma_dump_gid(const char *who, const char *src, const char *dst) "%s = Source GID: %s, Dest GID: %s" qemu_rdma_exchange_get_response_start(const char *desc) "CONTROL: %s recei= ving..." qemu_rdma_exchange_get_response_none(const char *desc, int type) "Surprise= : got %s (%d)" --=20 2.41.0