From nobody Mon May 12 15:10:20 2025 Delivered-To: importer2@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+importer2=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=T+Sfe1uxw1HEYSj8RulEJ2rmMOWCTbfaj+Yf4SYk+v1ZPzWZduJW9nEfxhzcrWabfs1QzjZL/ShMEy9LBz3+qUB8RcdPNPimfUiX8G/YdrnpOnBXzoWL4JFnV/iP3iO6r4F+6oIq2AkkGNRhYC4jhccgQP9a8iA64WQidB1kH6U= 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=hxc2oqPmIb1mwhO9ALG39J7xJ6N28uqMonq1A511SqYXCW3aFuhY2RCwZk4lt275ltYzXNxTUSnmYBVxvxzYPuZcd9xaU3qDqLUbvJJpCXHfg93Q55y2g8WG6/TKon1KeDzOiCda2lb8B2lEPnbpEnWuLZ0kUm8DezdxZhxnngY= 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+importer2=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 1695907547714375.50686572024847; 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+importer2=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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695907549091100005 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