From nobody Mon Feb 9 23:01:24 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=1683634091; cv=none; d=zohomail.com; s=zohoarc; b=aEd3WFTIjWklPesDv10CTM1UUaE5R6/aQvGxtTctORAX4vZW9wAqt7JI/eNjWwz5R6qpHdJ0HadJgG43zI22ZBxe5liV0iiHjUMEUsrICwY10bFccUbd8C5pmtVYflHVKXv+CSgpIzNYSRoWyOx1pLpYehGCK38F3syw9d/cOHQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683634091; 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=I5E0xL3kMgDYRotKkMDKzlI4ppNIn8Q5rpj8cg+vwoY=; b=ceyo1YBP+7EliaRzJ6Sacn7Z1nxxnqrSuu242Nv1J1mNXiHBQ/KM5rr/YOM3XdVGvEdNu+CMUdAxE7rsEuVD1kQe5mXZeo6sfy7XxMoVTPK3CPJej6npnGV7zB2w6gnJBNv3ctYA5fv4q3IgtEyvGmMw1dpecGKBD6BhpkT3BUc= 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 1683634091091394.8401932003985; Tue, 9 May 2023 05:08:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwM7d-0006Hi-7K; Tue, 09 May 2023 08:07:13 -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 1pwM7Z-0006GZ-UR for qemu-devel@nongnu.org; Tue, 09 May 2023 08:07:09 -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 1pwM7X-0007LF-Ev for qemu-devel@nongnu.org; Tue, 09 May 2023 08:07:09 -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-582-3unPtbcPP3CRElNMFfKLwA-1; Tue, 09 May 2023 08:07:05 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C345B84AF32 for ; Tue, 9 May 2023 12:07:04 +0000 (UTC) Received: from secure.mitica (unknown [10.39.193.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0716363F5F; Tue, 9 May 2023 12:07:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683634026; 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=I5E0xL3kMgDYRotKkMDKzlI4ppNIn8Q5rpj8cg+vwoY=; b=B8T+tGupvCKWyMoAMIZCgAhlnpdrtS8qNSXvln4ImAkz8JEFVlGfycJyfGtkpWxzxlhx4U MBz01hsysPJkysGzsVrpbxyPsxtIg/GMV8Lkp0QwoyrfLtXWO6WCB39zPVMVXN3lfnATCi QhT/WozsIQm1Iw+tO42iDMWEfV2eg0Q= X-MC-Unique: 3unPtbcPP3CRElNMFfKLwA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Leonardo Bras , Juan Quintela , Peter Xu Subject: [PATCH v3 02/10] migration/rdma: Unfold ram_control_before_iterate() Date: Tue, 9 May 2023 14:06:52 +0200 Message-Id: <20230509120700.78359-3-quintela@redhat.com> In-Reply-To: <20230509120700.78359-1-quintela@redhat.com> References: <20230509120700.78359-1-quintela@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=quintela@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_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: 1683634093162100006 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 | 6 ++---- migration/rdma.h | 6 ++++++ 5 files changed, 22 insertions(+), 21 deletions(-) diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 32ef5e9651..6243d6ac59 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -32,6 +32,7 @@ #include "trace.h" #include "options.h" #include "qapi/error.h" +#include "rdma.h" =20 #define IO_BUF_SIZE 32768 #define MAX_IOV_SIZE MIN_CONST(IOV_MAX, 64) @@ -302,18 +303,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 ed77996201..ced2202137 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -55,7 +55,6 @@ typedef int (QEMURamSaveFunc)(QEMUFile *f, size_t size); =20 typedef struct QEMUFileHooks { - QEMURamHookFunc *before_ram_iterate; QEMURamHookFunc *after_ram_iterate; QEMURamHookFunc *hook_ram_load; QEMURamSaveFunc *save_page; @@ -131,7 +130,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 1ab9900dda..a8acabe64c 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() */ @@ -3047,7 +3048,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)); @@ -3110,7 +3114,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; @@ -3216,7 +3223,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 93a1b8b5ad..421a061278 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -3864,13 +3864,12 @@ 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 (migration_in_postcopy()) { + if (!migrate_rdma () || migration_in_postcopy()) { return 0; } =20 @@ -4008,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