From nobody Wed Feb 11 02:07:33 2026 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=1683120014; cv=none; d=zohomail.com; s=zohoarc; b=jB0f6cWrIKhgNUACkTtjsnSDJI/YeYw6oWsn5/nKTWTmKZS/ic7Y7ly3rpVixCzniOoIoIzAx4vRCjMmcu3QVQwP3cCXJVzU1B6m1FKaylQDQGld7Pf7d0lrCMwMKoBmJziNwBUbFb12VmhOsy21rsFEvlmdAd4qzotAVaGNVzw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683120014; h=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=82GKF6jBsZ6yZicTA6C03KmhNS2Tm23Lf/xYhoERaSw=; b=eNFW2lBbQEdKjt2YgxiGtx3ZFv+aXG414dxHPEgMIVvWl7dgMXxxRj9tFbue/UkbxuNbHsevyLX4vrFTNOTYHXtZ7eINWrZonSl79/B3d7rgGNkxSelI4t/4q0GtSLOdhlhRaqrt1KIRmcyhBf7Xgz3M14ZxMJGciJGceYVyoeA= 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 1683120014934723.2289935859776; Wed, 3 May 2023 06:20:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1puCNv-0005QG-EA; Wed, 03 May 2023 09:19:08 -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 1puCNi-0005Nz-TI for qemu-devel@nongnu.org; Wed, 03 May 2023 09:18:55 -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 1puCNh-0006jf-7q for qemu-devel@nongnu.org; Wed, 03 May 2023 09:18:54 -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-596-PGI94O9_PJOU3fmUawc2NQ-1; Wed, 03 May 2023 09:18:51 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EBDAE811E7B for ; Wed, 3 May 2023 13:18:50 +0000 (UTC) Received: from secure.mitica (unknown [10.39.193.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC51DC15BAD; Wed, 3 May 2023 13:18:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683119932; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=82GKF6jBsZ6yZicTA6C03KmhNS2Tm23Lf/xYhoERaSw=; b=WpVAtH2vpZsSnQtZJ2BmvuO0G1cU8w9+/y0bkjAfYfMC9SutP1VCw9Hgbib6D+TZNV6oYH lG2o9x47x3JPfElmaQM3XIImJbphozWkdAQH2+k84xXWSy4s/R9QmDme30qCabjlKIVgxV GL4sBvyGcqpvx3GsOQtV1Z05en0RiXU= X-MC-Unique: PGI94O9_PJOU3fmUawc2NQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Peter Xu , Juan Quintela , Leonardo Bras Subject: [PATCH v2 02/16] migration/rdma: Unfold ram_control_before_iterate() Date: Wed, 3 May 2023 15:18:33 +0200 Message-Id: <20230503131847.11603-3-quintela@redhat.com> In-Reply-To: <20230503131847.11603-1-quintela@redhat.com> References: <20230503131847.11603-1-quintela@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=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -22 X-Spam_score: -2.3 X-Spam_bar: -- X-Spam_report: (-2.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.161, 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_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: 1683120017125100003 Content-Type: text/plain; charset="utf-8" Once there: - Remove unused data parameter - unfold it in its callers. - change all callers to call qemu_rdma_registration_start() Signed-off-by: Juan Quintela --- migration/qemu-file.c | 13 +------------ migration/qemu-file.h | 2 -- migration/ram.c | 16 +++++++++++++--- migration/rdma.c | 8 +++++--- migration/rdma.h | 6 ++++++ 5 files changed, 25 insertions(+), 20 deletions(-) diff --git a/migration/qemu-file.c b/migration/qemu-file.c index ee04240a21..b6dca23706 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -30,6 +30,7 @@ #include "qemu-file.h" #include "trace.h" #include "qapi/error.h" +#include "rdma.h" =20 #define IO_BUF_SIZE 32768 #define MAX_IOV_SIZE MIN_CONST(IOV_MAX, 64) @@ -314,18 +315,6 @@ void qemu_fflush(QEMUFile *f) f->iovcnt =3D 0; } =20 -void ram_control_before_iterate(QEMUFile *f, uint64_t flags) -{ - int ret =3D 0; - - if (f->hooks && f->hooks->before_ram_iterate) { - ret =3D f->hooks->before_ram_iterate(f, flags, NULL); - if (ret < 0) { - qemu_file_set_error(f, ret); - } - } -} - void ram_control_after_iterate(QEMUFile *f, uint64_t flags) { int ret =3D 0; diff --git a/migration/qemu-file.h b/migration/qemu-file.h index d16cd50448..c898c5c537 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -56,7 +56,6 @@ typedef size_t (QEMURamSaveFunc)(QEMUFile *f, uint64_t *bytes_sent); =20 typedef struct QEMUFileHooks { - QEMURamHookFunc *before_ram_iterate; QEMURamHookFunc *after_ram_iterate; QEMURamHookFunc *hook_ram_load; QEMURamSaveFunc *save_page; @@ -150,7 +149,6 @@ void qemu_fflush(QEMUFile *f); void qemu_file_set_blocking(QEMUFile *f, bool block); int qemu_file_get_to_fd(QEMUFile *f, int fd, size_t size); =20 -void ram_control_before_iterate(QEMUFile *f, uint64_t flags); void ram_control_after_iterate(QEMUFile *f, uint64_t flags); void ram_control_load_hook(QEMUFile *f, uint64_t flags, void *data); =20 diff --git a/migration/ram.c b/migration/ram.c index 7d81c4a39e..ce5dfc3c86 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -58,6 +58,7 @@ #include "qemu/iov.h" #include "multifd.h" #include "sysemu/runstate.h" +#include "rdma.h" #include "options.h" =20 #include "hw/boards.h" /* for machine_dump_guest_core() */ @@ -3277,7 +3278,10 @@ static int ram_save_setup(QEMUFile *f, void *opaque) } } =20 - ram_control_before_iterate(f, RAM_CONTROL_SETUP); + ret =3D qemu_rdma_registration_start(f, RAM_CONTROL_SETUP); + if (ret < 0) { + qemu_file_set_error(f, ret); + } ram_control_after_iterate(f, RAM_CONTROL_SETUP); =20 migration_ops =3D g_malloc0(sizeof(MigrationOps)); @@ -3337,7 +3341,10 @@ static int ram_save_iterate(QEMUFile *f, void *opaqu= e) /* Read version before ram_list.blocks */ smp_rmb(); =20 - ram_control_before_iterate(f, RAM_CONTROL_ROUND); + ret =3D qemu_rdma_registration_start(f, RAM_CONTROL_ROUND); + if (ret < 0) { + qemu_file_set_error(f, ret); + } =20 t0 =3D qemu_clock_get_ns(QEMU_CLOCK_REALTIME); i =3D 0; @@ -3442,7 +3449,10 @@ static int ram_save_complete(QEMUFile *f, void *opaq= ue) migration_bitmap_sync_precopy(rs); } =20 - ram_control_before_iterate(f, RAM_CONTROL_FINISH); + ret =3D qemu_rdma_registration_start(f, RAM_CONTROL_FINISH); + if (ret < 0) { + qemu_file_set_error(f, ret); + } =20 /* try transferring iterative blocks of memory */ =20 diff --git a/migration/rdma.c b/migration/rdma.c index b026e98519..d8a194ff26 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -3860,12 +3860,15 @@ static int rdma_load_hook(QEMUFile *f, uint64_t fla= gs, void *data) } } =20 -static int qemu_rdma_registration_start(QEMUFile *f, - uint64_t flags, void *data) +int qemu_rdma_registration_start(QEMUFile *f, uint64_t flags) { QIOChannelRDMA *rioc =3D QIO_CHANNEL_RDMA(qemu_file_get_ioc(f)); RDMAContext *rdma; =20 + if (!migrate_rdma()) { + return 0; + } + RCU_READ_LOCK_GUARD(); rdma =3D qatomic_rcu_read(&rioc->rdmaout); if (!rdma) { @@ -4004,7 +4007,6 @@ static const QEMUFileHooks rdma_read_hooks =3D { }; =20 static const QEMUFileHooks rdma_write_hooks =3D { - .before_ram_iterate =3D qemu_rdma_registration_start, .after_ram_iterate =3D qemu_rdma_registration_stop, .save_page =3D qemu_rdma_save_page, }; diff --git a/migration/rdma.h b/migration/rdma.h index de2ba09dc5..901c829c8b 100644 --- a/migration/rdma.h +++ b/migration/rdma.h @@ -22,4 +22,10 @@ void rdma_start_outgoing_migration(void *opaque, const c= har *host_port, =20 void rdma_start_incoming_migration(const char *host_port, Error **errp); =20 + +#ifdef CONFIG_RDMA +int qemu_rdma_registration_start(QEMUFile *f, uint64_t flags); +#else +int qemu_rdma_registration_start(QEMUFile *f, uint64_t flags) { return 0; } +#endif #endif --=20 2.40.0