From nobody Fri May 17 10:13:48 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=1685471291; cv=none; d=zohomail.com; s=zohoarc; b=ZLUDSFGDltgY2Ike35Qas59W+yaxePZk/pZlqDnYgBOMFvF0uRAnuvZDupfWpkynTbd831tugf2BO6MKQDNS1pzvPriTnvprvQsIP8pd3PZJU7Fr6d41NXZ+C8/zF/u7hxs7RgweevZGtuwhuyKhSstQn2l+ZWSHbO41KD6mXC4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685471291; 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=1HIuK2JuDsuMAWMzDLOmEGJIdWcuvp6JGlclttbw8+Y=; b=ByijW5RSsLP+MAVwwSkk+PrfwidPTGUOZME63W7jsxrFW/yijk1vEWbo+UkohWmU5amw2dUVAUsgl86CiPd2FvhnZ2ACU4whghEwLw/Oo0m8WInjS5F8HWowOQc4Dy8waubiyC3sB9X1m3Af9LA+HiJseKyNchn+A7DARl0bmOE= 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 1685471291250924.0328602856978; Tue, 30 May 2023 11:28:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q442c-0001Uz-V8; Tue, 30 May 2023 14:25: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 1q442S-0001Mq-3E for qemu-devel@nongnu.org; Tue, 30 May 2023 14:25:44 -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 1q442O-0000bN-To for qemu-devel@nongnu.org; Tue, 30 May 2023 14:25: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-84-9bIncA-2OdKpmjhgnY0Y3A-1; Tue, 30 May 2023 14:25:35 -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 A1DB6800B2A; Tue, 30 May 2023 18:25:34 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8416517103; Tue, 30 May 2023 18:25:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685471136; 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=1HIuK2JuDsuMAWMzDLOmEGJIdWcuvp6JGlclttbw8+Y=; b=SJkMDvYa4WRN5MHwhoeacCCN0erYsrx+Z27lB3oEaBZCUwrT8m5bY8B7Qonttt0iTeEGsO x+lzMHRg8s7z1ceSfBWNCXgGBLLDgiH2jYQk2dSAWKJ0+qbivA2liFV9zfOKyQFJj0BYJ7 wFHG1TdnzvfMlKrL/NzJ9oCyeZTu3xs= X-MC-Unique: 9bIncA-2OdKpmjhgnY0Y3A-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Leonardo Bras , Peter Xu , Juan Quintela , Vladimir Sementsov-Ogievskiy Subject: [PULL 01/21] runstate: add runstate_get() Date: Tue, 30 May 2023 20:25:11 +0200 Message-Id: <20230530182531.6371-2-quintela@redhat.com> In-Reply-To: <20230530182531.6371-1-quintela@redhat.com> References: <20230530182531.6371-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: -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.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1685471292076100005 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy It's necessary to restore the state after failed/cancelled migration in further commit. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Juan Quintela Message-Id: <20230517123752.21615-2-vsementsov@yandex-team.ru> Signed-off-by: Juan Quintela --- include/sysemu/runstate.h | 1 + softmmu/runstate.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/include/sysemu/runstate.h b/include/sysemu/runstate.h index f3ed52548e..85f5d9a419 100644 --- a/include/sysemu/runstate.h +++ b/include/sysemu/runstate.h @@ -6,6 +6,7 @@ =20 bool runstate_check(RunState state); void runstate_set(RunState new_state); +RunState runstate_get(void); bool runstate_is_running(void); bool runstate_needs_reset(void); bool runstate_store(char *str, size_t size); diff --git a/softmmu/runstate.c b/softmmu/runstate.c index 2f2396c819..1e6f0bcecc 100644 --- a/softmmu/runstate.c +++ b/softmmu/runstate.c @@ -221,6 +221,11 @@ void runstate_set(RunState new_state) current_run_state =3D new_state; } =20 +RunState runstate_get(void) +{ + return current_run_state; +} + bool runstate_is_running(void) { return runstate_check(RUN_STATE_RUNNING); --=20 2.40.1 From nobody Fri May 17 10:13:48 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=1685471282; cv=none; d=zohomail.com; s=zohoarc; b=Vsnst0W4tPcLEC7SwLDRS/5+6jESRpyTmjWkZkY2GppGswHG4X4PaXPaDzxEDATtYo8Tk+X6imLSLEFL+/ofyL4+dOCXFDV5naf7/ot5Notp+ifL2rJD+aEBLWTG7dEBSHo7GWEEgguNKqZk94NU8HGXAwyz+VWPC/KY4x87vpI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685471282; 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=TF/SpRsVU0zyYX4JBUn+J3w91fUBxDQQEjMTghPFV0M=; b=cz6Cl0Svdd890Q9A7hHxhuplCqaqwV8zooFggxtjcF04E7ZRYbEUiHQehy3EP8jQEUl4awOwLF1XySbKuhe4nYNyuEgmUpNRA9JgJx7iTYjpERS6/od7xdCcY0QwPtk6C0uMm/xqIwpV+2yWV/Qbb59WsfKOo6CyvkT5aNxrskE= 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 1685471282364254.60557676875192; Tue, 30 May 2023 11:28:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q442d-0001VL-KF; Tue, 30 May 2023 14:25: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 1q442S-0001Ms-5B for qemu-devel@nongnu.org; Tue, 30 May 2023 14:25: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 1q442O-0000c4-TW for qemu-devel@nongnu.org; Tue, 30 May 2023 14:25:43 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.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-543-SGXtaUV9OcObuT8XAicHRw-1; Tue, 30 May 2023 14:25:36 -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 2E3A3380673C; Tue, 30 May 2023 18:25:36 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC27A421C5; Tue, 30 May 2023 18:25:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685471139; 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=TF/SpRsVU0zyYX4JBUn+J3w91fUBxDQQEjMTghPFV0M=; b=arPflB5GOvK91E+I5+65akraF7T64OgTUrDnPni6YnC+lcRUnCtMmrBZAaRbd9tkv6bJyf sD0t986CAn/lBVMDF9Aq3f13YBZS1ZnTMEdf2V/Vic0TTP89RrLWIU2knw2b36vd6JZHmE KFvchpmvgULE11651yBESDnIgaz0RtE= X-MC-Unique: SGXtaUV9OcObuT8XAicHRw-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Leonardo Bras , Peter Xu , Juan Quintela , Vladimir Sementsov-Ogievskiy Subject: [PULL 02/21] migration: never fail in global_state_store() Date: Tue, 30 May 2023 20:25:12 +0200 Message-Id: <20230530182531.6371-3-quintela@redhat.com> In-Reply-To: <20230530182531.6371-1-quintela@redhat.com> References: <20230530182531.6371-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.129.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.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1685471284046100003 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Actually global_state_store() can never fail. Let's get rid of extra error paths. To make things clear, use new runstate_get() and use same approach for global_state_store() and global_state_store_running(). Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Juan Quintela Message-Id: <20230517123752.21615-3-vsementsov@yandex-team.ru> Signed-off-by: Juan Quintela --- include/migration/global_state.h | 2 +- migration/global_state.c | 29 +++++++++++----------- migration/migration.c | 41 +++++++++++++++----------------- migration/savevm.c | 6 +---- 4 files changed, 35 insertions(+), 43 deletions(-) diff --git a/include/migration/global_state.h b/include/migration/global_st= ate.h index 945eb35d5b..d7c2cd3216 100644 --- a/include/migration/global_state.h +++ b/include/migration/global_state.h @@ -16,7 +16,7 @@ #include "qapi/qapi-types-run-state.h" =20 void register_global_state(void); -int global_state_store(void); +void global_state_store(void); void global_state_store_running(void); bool global_state_received(void); RunState global_state_get_runstate(void); diff --git a/migration/global_state.c b/migration/global_state.c index a33947ca32..4e2a9d8ec0 100644 --- a/migration/global_state.c +++ b/migration/global_state.c @@ -29,23 +29,22 @@ typedef struct { =20 static GlobalState global_state; =20 -int global_state_store(void) +static void global_state_do_store(RunState state) { - if (!runstate_store((char *)global_state.runstate, - sizeof(global_state.runstate))) { - error_report("runstate name too big: %s", global_state.runstate); - trace_migrate_state_too_big(); - return -EINVAL; - } - return 0; -} - -void global_state_store_running(void) -{ - const char *state =3D RunState_str(RUN_STATE_RUNNING); - assert(strlen(state) < sizeof(global_state.runstate)); + const char *state_str =3D RunState_str(state); + assert(strlen(state_str) < sizeof(global_state.runstate)); strpadcpy((char *)global_state.runstate, sizeof(global_state.runstate), - state, '\0'); + state_str, '\0'); +} + +void global_state_store(void) +{ + global_state_do_store(runstate_get()); +} + +void global_state_store_running(void) +{ + global_state_do_store(RUN_STATE_RUNNING); } =20 bool global_state_received(void) diff --git a/migration/migration.c b/migration/migration.c index 5de7f734b9..c75d5aa479 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2288,27 +2288,26 @@ static void migration_completion(MigrationState *s) s->downtime_start =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME); qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL); s->vm_was_running =3D runstate_is_running(); - ret =3D global_state_store(); + global_state_store(); =20 - if (!ret) { - ret =3D vm_stop_force_state(RUN_STATE_FINISH_MIGRATE); - trace_migration_completion_vm_stop(ret); - if (ret >=3D 0) { - ret =3D migration_maybe_pause(s, ¤t_active_state, - MIGRATION_STATUS_DEVICE); - } - if (ret >=3D 0) { - /* - * Inactivate disks except in COLO, and track that we - * have done so in order to remember to reactivate - * them if migration fails or is cancelled. - */ - s->block_inactive =3D !migrate_colo(); - migration_rate_set(RATE_LIMIT_DISABLED); - ret =3D qemu_savevm_state_complete_precopy(s->to_dst_file,= false, - s->block_inactive= ); - } + ret =3D vm_stop_force_state(RUN_STATE_FINISH_MIGRATE); + trace_migration_completion_vm_stop(ret); + if (ret >=3D 0) { + ret =3D migration_maybe_pause(s, ¤t_active_state, + MIGRATION_STATUS_DEVICE); } + if (ret >=3D 0) { + /* + * Inactivate disks except in COLO, and track that we + * have done so in order to remember to reactivate + * them if migration fails or is cancelled. + */ + s->block_inactive =3D !migrate_colo(); + migration_rate_set(RATE_LIMIT_DISABLED); + ret =3D qemu_savevm_state_complete_precopy(s->to_dst_file, fal= se, + s->block_inactive); + } + qemu_mutex_unlock_iothread(); =20 if (ret < 0) { @@ -3088,9 +3087,7 @@ static void *bg_migration_thread(void *opaque) qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL); s->vm_was_running =3D runstate_is_running(); =20 - if (global_state_store()) { - goto fail; - } + global_state_store(); /* Forcibly stop VM before saving state of vCPUs and devices */ if (vm_stop_force_state(RUN_STATE_PAUSED)) { goto fail; diff --git a/migration/savevm.c b/migration/savevm.c index 03795ce8dc..bc284087f9 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2919,11 +2919,7 @@ bool save_snapshot(const char *name, bool overwrite,= const char *vmstate, =20 saved_vm_running =3D runstate_is_running(); =20 - ret =3D global_state_store(); - if (ret) { - error_setg(errp, "Error saving global state"); - return false; - } + global_state_store(); vm_stop(RUN_STATE_SAVE_VM); =20 bdrv_drain_all_begin(); --=20 2.40.1 From nobody Fri May 17 10:13:48 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=1685471163; cv=none; d=zohomail.com; s=zohoarc; b=B/lbenm6szgDp1lMi/vfhIubVm+5Dr/wxo5J5ZFzZw1wClUQ/c99+DD6YK9lzi1IykxeMUaEt5Qc5V1jbIZtDHkqgcPcIXBhwk3/sLiIeCnbxvUzCKPFY0iHMpR6hAW5j0LDCyK74dlZvW5Rl5L0ywyZaWVz3Tdwj46e5JDlgHQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685471163; 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=NGtkd/VOEqR1Ouq/Wg8DwRbxBOulP2LrMmjMkxNN4GY=; b=guxskaB/DL4fDFt/HOAuanab7xphYEl9IBBmeT6kub53a9eVPzyCkNsOpFm0C93LEAEuMKhpQEtA2UTbo6W+LPl7URE3tkFTWXq9BAtZPRX6IyXCpH1qc0/NqBAoO6oqDpzjYtGY1C8SyWDWy42rtQ2DnezVxMlTApqI8667vdw= 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 1685471163329796.3134336965928; Tue, 30 May 2023 11:26:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q442W-0001RC-SH; Tue, 30 May 2023 14:25: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 1q442U-0001PG-3w for qemu-devel@nongnu.org; Tue, 30 May 2023 14:25:46 -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 1q442R-0000cv-S6 for qemu-devel@nongnu.org; Tue, 30 May 2023 14:25:45 -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-287-87UOXOyzPLGGO2EGhyAPGQ-1; Tue, 30 May 2023 14:25:37 -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 846A6185A78B; Tue, 30 May 2023 18:25:37 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 744D217103; Tue, 30 May 2023 18:25:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685471141; 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=NGtkd/VOEqR1Ouq/Wg8DwRbxBOulP2LrMmjMkxNN4GY=; b=aVXjpYWcpvnpjT92jejvlbeGjmboacbSOxqKp+Hj/0ELJHNq5UwJC011O/IYEWI3a8oF7B xk4BblZPH/tMjblfafYK8ecUlAQJ/awVf9p1kZLDrYUTBGynWEv24KU/hWXBnYqhRMQdTu emxr1VcRwWHEvKK9oOySmLsw85cCDiQ= X-MC-Unique: 87UOXOyzPLGGO2EGhyAPGQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Leonardo Bras , Peter Xu , Juan Quintela , Vladimir Sementsov-Ogievskiy Subject: [PULL 03/21] runstate: drop unused runstate_store() Date: Tue, 30 May 2023 20:25:13 +0200 Message-Id: <20230530182531.6371-4-quintela@redhat.com> In-Reply-To: <20230530182531.6371-1-quintela@redhat.com> References: <20230530182531.6371-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.129.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.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1685471163718100001 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy The function is unused since previous commit. Drop it. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Juan Quintela Message-Id: <20230517123752.21615-4-vsementsov@yandex-team.ru> Signed-off-by: Juan Quintela --- include/sysemu/runstate.h | 1 - softmmu/runstate.c | 12 ------------ 2 files changed, 13 deletions(-) diff --git a/include/sysemu/runstate.h b/include/sysemu/runstate.h index 85f5d9a419..7beb29c2e2 100644 --- a/include/sysemu/runstate.h +++ b/include/sysemu/runstate.h @@ -9,7 +9,6 @@ void runstate_set(RunState new_state); RunState runstate_get(void); bool runstate_is_running(void); bool runstate_needs_reset(void); -bool runstate_store(char *str, size_t size); =20 typedef void VMChangeStateHandler(void *opaque, bool running, RunState sta= te); =20 diff --git a/softmmu/runstate.c b/softmmu/runstate.c index 1e6f0bcecc..0370230a5e 100644 --- a/softmmu/runstate.c +++ b/softmmu/runstate.c @@ -175,18 +175,6 @@ bool runstate_check(RunState state) return current_run_state =3D=3D state; } =20 -bool runstate_store(char *str, size_t size) -{ - const char *state =3D RunState_str(current_run_state); - size_t len =3D strlen(state) + 1; - - if (len > size) { - return false; - } - memcpy(str, state, len); - return true; -} - static void runstate_init(void) { const RunStateTransition *p; --=20 2.40.1 From nobody Fri May 17 10:13:48 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=1685471307; cv=none; d=zohomail.com; s=zohoarc; b=OS/7blmS4DJGkB6zzue2D+7livMNdLD32N74abqfGUXWmaTfmUdPM8ZSx+itoWlwoxNsQeyN7kgvZPqD/sreEtYwFsBpEZUuOgofFFxG0ZlsL/+3/QifllpQKGqT6Y0ypF4YSCVMiQblaHbvs6LuB2w023RHeQuH/8Z1IWA/Tw4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685471307; 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=tj0cQwuOH13SAeW28WyCSad0nngr0wzVxNpQRkS9oRA=; b=bpHuB/GLMYm4ETBIlF6jPdEMVBqYRcfdi+7oQtlJIYnOqQ1yL5duYGm47gvv+/ioGIpNaTwtIronoHmVpbCZ1h7Y+wiC/7LqYC9dWxO2qZZFbYfxoMQ1Rjgw1NQZqmxUZ0L0rWC2Zo7Mdiltstycm9HE9qX7FI3SoKUeYRufrnM= 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 1685471307052971.6589257759624; Tue, 30 May 2023 11:28:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q442c-0001UY-7x; Tue, 30 May 2023 14:25: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 1q442U-0001P2-0v for qemu-devel@nongnu.org; Tue, 30 May 2023 14:25:46 -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 1q442R-0000cI-Rm for qemu-devel@nongnu.org; Tue, 30 May 2023 14:25:45 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.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-575-AIMsCqjPP3-CVcwWSXlD1g-1; Tue, 30 May 2023 14:25:39 -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 EAD171C05135; Tue, 30 May 2023 18:25:38 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id CAEF1421C3; Tue, 30 May 2023 18:25:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685471140; 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=tj0cQwuOH13SAeW28WyCSad0nngr0wzVxNpQRkS9oRA=; b=YZ/8MdBY1DIkZBvH3vQ6jy659k/zj3POIvjxGt17iRSAx7c8HkrtwALHYno+JNp86tZtYt KUYqNlp3EEd0a7OIfnP69bA0biU5QVvtGUj/oq++2OZ0luY2znSyyRVcYGD27pTWDJ73rA fdlkHJb12RBl0srs4XkxVqJQ18V1jj0= X-MC-Unique: AIMsCqjPP3-CVcwWSXlD1g-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Leonardo Bras , Peter Xu , Juan Quintela , Vladimir Sementsov-Ogievskiy Subject: [PULL 04/21] migration: switch from .vm_was_running to .vm_old_state Date: Tue, 30 May 2023 20:25:14 +0200 Message-Id: <20230530182531.6371-5-quintela@redhat.com> In-Reply-To: <20230530182531.6371-1-quintela@redhat.com> References: <20230530182531.6371-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.129.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.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1685471308787100001 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy No logic change here, only refactoring. That's a preparation for next commit where we finally restore the stopped vm state on migration failure or cancellation. Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Juan Quintela Message-Id: <20230517123752.21615-5-vsementsov@yandex-team.ru> Signed-off-by: Juan Quintela --- migration/migration.h | 9 ++++++--- migration/migration.c | 11 ++++++----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/migration/migration.h b/migration/migration.h index 48a46123a0..30c3e97635 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -25,6 +25,7 @@ #include "net/announce.h" #include "qom/object.h" #include "postcopy-ram.h" +#include "sysemu/runstate.h" =20 struct PostcopyBlocktimeContext; =20 @@ -317,12 +318,14 @@ struct MigrationState { int64_t expected_downtime; bool capabilities[MIGRATION_CAPABILITY__MAX]; int64_t setup_time; + /* - * Whether guest was running when we enter the completion stage. + * State before stopping the vm by vm_stop_force_state(). * If migration is interrupted by any reason, we need to continue - * running the guest on source. + * running the guest on source if it was running or restore its stopped + * state. */ - bool vm_was_running; + RunState vm_old_state; =20 /* Flag set once the migration has been asked to enter postcopy */ bool start_postcopy; diff --git a/migration/migration.c b/migration/migration.c index c75d5aa479..033162cda0 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1402,7 +1402,7 @@ void migrate_init(MigrationState *s) =20 s->start_time =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME); s->total_time =3D 0; - s->vm_was_running =3D false; + s->vm_old_state =3D -1; s->iteration_initial_bytes =3D 0; s->threshold_size =3D 0; } @@ -2287,7 +2287,8 @@ static void migration_completion(MigrationState *s) qemu_mutex_lock_iothread(); s->downtime_start =3D qemu_clock_get_ms(QEMU_CLOCK_REALTIME); qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL); - s->vm_was_running =3D runstate_is_running(); + + s->vm_old_state =3D runstate_get(); global_state_store(); =20 ret =3D vm_stop_force_state(RUN_STATE_FINISH_MIGRATE); @@ -2760,12 +2761,12 @@ static void migration_iteration_finish(MigrationSta= te *s) case MIGRATION_STATUS_COLO: assert(migrate_colo()); migrate_start_colo_process(s); - s->vm_was_running =3D true; + s->vm_old_state =3D RUN_STATE_RUNNING; /* Fallthrough */ case MIGRATION_STATUS_FAILED: case MIGRATION_STATUS_CANCELLED: case MIGRATION_STATUS_CANCELLING: - if (s->vm_was_running) { + if (s->vm_old_state =3D=3D RUN_STATE_RUNNING) { if (!runstate_check(RUN_STATE_SHUTDOWN)) { vm_start(); } @@ -3085,7 +3086,7 @@ static void *bg_migration_thread(void *opaque) * transition in vm_stop_force_state() we need to wakeup it up. */ qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER, NULL); - s->vm_was_running =3D runstate_is_running(); + s->vm_old_state =3D runstate_get(); =20 global_state_store(); /* Forcibly stop VM before saving state of vCPUs and devices */ --=20 2.40.1 From nobody Fri May 17 10:13:48 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=1685471157; cv=none; d=zohomail.com; s=zohoarc; b=GTQi3V5oYC9WhBw+dvl2pzh8JFaWsXnPJa5tNWza6IGEHx9RW0JqYciqoO1aEVuoYtzi0NbgxA5bAuFWSUnuWMHIY90vRnzTTyEr/woUcf0shBU4bsHnnbjZWRiYOcws/SMKOfeqmRSwdY/QRAGn2fiG5EEtpX2t2Jb1wlcx8YI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685471157; 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=I4gJ60Ealycyn+5Tv6j+hmZj9B87IXvu+mOtep4AFto=; b=DcDoDMfMssOiDgUsM1pGHB8suCtSBVyDnZleZQvNaL9nA/ZqK4r95gq7mNrSGYaWF7Rc47JEzAoJkgrzJTOfy5cGWuIDjMZXiDEOV5Wek3v21t/qI/770mIdmcGAiua+XF8S+j7LPHh2yTR/xogLBiVAlvC1Tj1KEPgf3E6O/gI= 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 1685471156990539.7159032435845; Tue, 30 May 2023 11:25:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q442Y-0001SE-Nu; Tue, 30 May 2023 14:25: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 1q442X-0001RF-05 for qemu-devel@nongnu.org; Tue, 30 May 2023 14:25:49 -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 1q442U-0000fE-AH for qemu-devel@nongnu.org; Tue, 30 May 2023 14:25:48 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.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-272-ZkMzmRB0N7m_24YW7JZrIA-1; Tue, 30 May 2023 14:25:41 -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 55A5A3C397C3; Tue, 30 May 2023 18:25:40 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3EA6A420A8; Tue, 30 May 2023 18:25:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685471145; 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=I4gJ60Ealycyn+5Tv6j+hmZj9B87IXvu+mOtep4AFto=; b=Wb6+oAIEL78ATvCLusX3Qzgb6o6MfzUI3iGnrKbikrGSeYmUJzU5zE/U8AMaLeu8UsriDF cAYLusMPK38ubpeEHYyKAEuz7x4l05kqQQ8EmMj0R9YZwmH4j9dFAPOAcnsLS6k+X9HhIC edDrw8JEVww2cMfNbSDwBg4T3K+E5UM= X-MC-Unique: ZkMzmRB0N7m_24YW7JZrIA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Leonardo Bras , Peter Xu , Juan Quintela , Vladimir Sementsov-Ogievskiy Subject: [PULL 05/21] migration: restore vmstate on migration failure Date: Tue, 30 May 2023 20:25:15 +0200 Message-Id: <20230530182531.6371-6-quintela@redhat.com> In-Reply-To: <20230530182531.6371-1-quintela@redhat.com> References: <20230530182531.6371-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: -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.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1685471157849100002 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy 1. Otherwise failed migration just drops guest-panicked state, which is not good for management software. 2. We do keep different paused states like guest-panicked during migration with help of global_state state. 3. We do restore running state on source when migration is cancelled or failed. 4. "postmigrate" state is documented as "guest is paused following a successful 'migrate'", so originally it's only for successful path and we never documented current behavior. Let's restore paused states like guest-panicked in case of cancel or fail too. Allow same transitions like for inmigrate state. This commit changes the behavior that was introduced by commit 42da5550d6 "migration: set state to post-migrate on failure" and provides a bit different fix on related https://bugzilla.redhat.com/show_bug.cgi?id=3D1355683 Signed-off-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Juan Quintela Message-Id: <20230517123752.21615-6-vsementsov@yandex-team.ru> Signed-off-by: Juan Quintela --- migration/migration.c | 2 +- softmmu/runstate.c | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 033162cda0..7c3425c6fe 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2772,7 +2772,7 @@ static void migration_iteration_finish(MigrationState= *s) } } else { if (runstate_check(RUN_STATE_FINISH_MIGRATE)) { - runstate_set(RUN_STATE_POSTMIGRATE); + runstate_set(s->vm_old_state); } } break; diff --git a/softmmu/runstate.c b/softmmu/runstate.c index 0370230a5e..1957caf73f 100644 --- a/softmmu/runstate.c +++ b/softmmu/runstate.c @@ -121,7 +121,13 @@ static const RunStateTransition runstate_transitions_d= ef[] =3D { { RUN_STATE_FINISH_MIGRATE, RUN_STATE_PAUSED }, { RUN_STATE_FINISH_MIGRATE, RUN_STATE_POSTMIGRATE }, { RUN_STATE_FINISH_MIGRATE, RUN_STATE_PRELAUNCH }, - { RUN_STATE_FINISH_MIGRATE, RUN_STATE_COLO}, + { RUN_STATE_FINISH_MIGRATE, RUN_STATE_COLO }, + { RUN_STATE_FINISH_MIGRATE, RUN_STATE_INTERNAL_ERROR }, + { RUN_STATE_FINISH_MIGRATE, RUN_STATE_IO_ERROR }, + { RUN_STATE_FINISH_MIGRATE, RUN_STATE_SHUTDOWN }, + { RUN_STATE_FINISH_MIGRATE, RUN_STATE_SUSPENDED }, + { RUN_STATE_FINISH_MIGRATE, RUN_STATE_WATCHDOG }, + { RUN_STATE_FINISH_MIGRATE, RUN_STATE_GUEST_PANICKED }, =20 { RUN_STATE_RESTORE_VM, RUN_STATE_RUNNING }, { RUN_STATE_RESTORE_VM, RUN_STATE_PRELAUNCH }, --=20 2.40.1 From nobody Fri May 17 10:13:48 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=1685471232; cv=none; d=zohomail.com; s=zohoarc; b=bxsOJDsUBc5rDTgGcGiMiSMOaxakLqqz8HA7tFhCRUz300o65JwaaCNaIzP/aXpZPAXhRyiy2PzFfwdP17srO8mALjcUD55IA0z50cjVDkPvBZkFD4bn/yOby3bkEsuzlfsHbXClxvL86DqIbRvzPSrnM8rtJgdndauzNZ1Fobc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685471232; 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=j428coaIRiHiCDE2P6IQUI8TpAu8vNrqJ4vgCs3KdUw=; b=B9Nybv9NtL7CBvItYlK/yvuKpLmpYq/HrF/xETYMnuDGu6IiHFRG2Jhu22T3C1EQmPdYZJJrUevw9uau3eGDtMbACoxkK7zIs02s9ha6xAzHpjGqA6xLTRamiiQZD3T25+rac/gk5bY/PkQ9qCJ9qlU2xNHhalXAzn8XbFpMdA4= 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 1685471232934201.11983648660885; Tue, 30 May 2023 11: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 1q442X-0001Rw-Vm; Tue, 30 May 2023 14:25: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 1q442V-0001QZ-Gm for qemu-devel@nongnu.org; Tue, 30 May 2023 14:25:47 -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 1q442S-0000da-6W for qemu-devel@nongnu.org; Tue, 30 May 2023 14:25:46 -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-605-YDoouwEwPsuPIdc2T-1yAw-1; Tue, 30 May 2023 14:25:42 -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 B8104811E85 for ; Tue, 30 May 2023 18:25:41 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9B7C417103; Tue, 30 May 2023 18:25:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685471143; 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=j428coaIRiHiCDE2P6IQUI8TpAu8vNrqJ4vgCs3KdUw=; b=AREMAd+Mv8nc+EPnBP9Mqwgl3sRZzc3cx7R2QqD8rE3AKfQ8ZKcPpWHzV2Ci8lDYF21fxn /tyL1ge9I2zJdHWYnj/984wcg5jGqrIHP+6vHuEhbstV1D/ZqWWXvm4c5zWexwmpBnvODI 5dWzwo3L95hUrQCp8aAUJ1lLBshGm/8= X-MC-Unique: YDoouwEwPsuPIdc2T-1yAw-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Leonardo Bras , Peter Xu , Juan Quintela Subject: [PULL 06/21] migration: Don't abuse qemu_file transferred for RDMA Date: Tue, 30 May 2023 20:25:16 +0200 Message-Id: <20230530182531.6371-7-quintela@redhat.com> In-Reply-To: <20230530182531.6371-1-quintela@redhat.com> References: <20230530182531.6371-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.129.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.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1685471234567100001 Content-Type: text/plain; charset="utf-8" Just create a variable for it, the same way that multifd does. This way it is safe to use for other thread, etc, etc. Reviewed-by: Leonardo Bras Signed-off-by: Juan Quintela Message-Id: <20230515195709.63843-11-quintela@redhat.com> --- migration/migration-stats.h | 4 ++++ migration/migration-stats.c | 5 +++-- migration/rdma.c | 22 ++++++++++++++++++++-- migration/trace-events | 2 +- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/migration/migration-stats.h b/migration/migration-stats.h index ac2260e987..2358caad63 100644 --- a/migration/migration-stats.h +++ b/migration/migration-stats.h @@ -89,6 +89,10 @@ typedef struct { * Maximum amount of data we can send in a cycle. */ Stat64 rate_limit_max; + /* + * Number of bytes sent through RDMA. + */ + Stat64 rdma_bytes; /* * Total number of bytes transferred. */ diff --git a/migration/migration-stats.c b/migration/migration-stats.c index f98c8260be..79eea8d865 100644 --- a/migration/migration-stats.c +++ b/migration/migration-stats.c @@ -61,8 +61,9 @@ void migration_rate_reset(QEMUFile *f) uint64_t migration_transferred_bytes(QEMUFile *f) { uint64_t multifd =3D stat64_get(&mig_stats.multifd_bytes); + uint64_t rdma =3D stat64_get(&mig_stats.rdma_bytes); uint64_t qemu_file =3D qemu_file_transferred(f); =20 - trace_migration_transferred_bytes(qemu_file, multifd); - return qemu_file + multifd; + trace_migration_transferred_bytes(qemu_file, multifd, rdma); + return qemu_file + multifd + rdma; } diff --git a/migration/rdma.c b/migration/rdma.c index 2e4dcff1c9..074456f9df 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -2122,9 +2122,18 @@ retry: return -EIO; } =20 + /* + * TODO: Here we are sending something, but we are not + * accounting for anything transferred. The following is = wrong: + * + * stat64_add(&mig_stats.rdma_bytes, sge.length); + * + * because we are using some kind of compression. I + * would think that head.len would be the more similar + * thing to a correct value. + */ stat64_add(&mig_stats.zero_pages, sge.length / qemu_target_page_size()); - return 1; } =20 @@ -2232,8 +2241,17 @@ retry: =20 set_bit(chunk, block->transit_bitmap); stat64_add(&mig_stats.normal_pages, sge.length / qemu_target_page_size= ()); + /* + * We are adding to transferred the amount of data written, but no + * overhead at all. I will asume that RDMA is magicaly and don't + * need to transfer (at least) the addresses where it wants to + * write the pages. Here it looks like it should be something + * like: + * sizeof(send_wr) + sge.length + * but this being RDMA, who knows. + */ + stat64_add(&mig_stats.rdma_bytes, sge.length); ram_transferred_add(sge.length); - qemu_file_credit_transfer(f, sge.length); rdma->total_writes++; =20 return 0; diff --git a/migration/trace-events b/migration/trace-events index cdaef7a1ea..54ae5653fd 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -187,7 +187,7 @@ process_incoming_migration_co_postcopy_end_main(void) "" postcopy_preempt_enabled(bool value) "%d" =20 # migration-stats -migration_transferred_bytes(uint64_t qemu_file, uint64_t multifd) "qemu_fi= le %" PRIu64 " multifd %" PRIu64 +migration_transferred_bytes(uint64_t qemu_file, uint64_t multifd, uint64_t= rdma) "qemu_file %" PRIu64 " multifd %" PRIu64 " RDMA %" PRIu64 =20 # channel.c migration_set_incoming_channel(void *ioc, const char *ioctype) "ioc=3D%p i= octype=3D%s" --=20 2.40.1 From nobody Fri May 17 10:13:48 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=1685471324; cv=none; d=zohomail.com; s=zohoarc; b=KW37dMM3WkMxrb+RKx74/SxP9HFOSXlCY8+af9qIVPRUXspz9Po3SYz4aWrna98Q4bO7HPz9N8gLeXaC17l+YqhdEqz5ykqIWDWl2Jc2gP5OIgSFam+tOO8WJIZ9Kt5Cu6OxGXhtX0qlBZKrytkoKsODZsLD2g0w1/0o0IMXFT4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685471324; 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=yNW9PNobDLu6GJDLCHZ/9WJVueQuyiQfsgeTSMQ289c=; b=X5oLJ73hZaDj2Ntj9/7BDY+kk4T80U/iQHammfWv3b5Shr4rxg9dPLrt4BjVgRfiKZdX182DCT1bBemgmgwUcyQ8aJDAzb7pLMlld0BXuWuJka7noU6w5YwTkqaY8+2GNrMlEJWF/VEv9dEQXWMLP/hHvriUnVFtb2vJZsJR0cY= 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 1685471324578712.2860169755221; Tue, 30 May 2023 11:28:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q442e-0001Xm-G7; Tue, 30 May 2023 14:25: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 1q442V-0001QY-Fw for qemu-devel@nongnu.org; Tue, 30 May 2023 14:25:47 -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 1q442T-0000em-Mf for qemu-devel@nongnu.org; Tue, 30 May 2023 14:25:47 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.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-675-fWYBRdB2MvGXePvgCMqxUA-1; Tue, 30 May 2023 14:25:43 -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 EC5A81C01E93 for ; Tue, 30 May 2023 18:25:42 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 094EE17103; Tue, 30 May 2023 18:25:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685471144; 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=yNW9PNobDLu6GJDLCHZ/9WJVueQuyiQfsgeTSMQ289c=; b=ECeB+/pkWNqfCy3VUH7fqiiSvc+uGQ1oy37nGQfw2esJthrHryltM5doOGWq69oECIcQvF fxRDFjqzxFMgBsSnDULiZjvEpfmLvsl7K5gzK7/g4ncRmTBDkFP67agwTuQhRqfozSpTv3 XV25GrL6v5sizP6LW08luuHreFtb8rY= X-MC-Unique: fWYBRdB2MvGXePvgCMqxUA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Leonardo Bras , Peter Xu , Juan Quintela Subject: [PULL 07/21] migration/RDMA: It is accounting for zero/normal pages in two places Date: Tue, 30 May 2023 20:25:17 +0200 Message-Id: <20230530182531.6371-8-quintela@redhat.com> In-Reply-To: <20230530182531.6371-1-quintela@redhat.com> References: <20230530182531.6371-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.129.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.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1685471326200100003 Content-Type: text/plain; charset="utf-8" Remove the one in control_save_page(). Reviewed-by: Leonardo Bras Signed-off-by: Juan Quintela Message-Id: <20230515195709.63843-12-quintela@redhat.com> --- migration/ram.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/migration/ram.c b/migration/ram.c index 88a6c82e63..40b8f9630d 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1162,13 +1162,6 @@ static bool control_save_page(PageSearchStatus *pss,= RAMBlock *block, if (ret =3D=3D RAM_SAVE_CONTROL_DELAYED) { return true; } - - if (bytes_xmit > 0) { - stat64_add(&mig_stats.normal_pages, 1); - } else if (bytes_xmit =3D=3D 0) { - stat64_add(&mig_stats.zero_pages, 1); - } - return true; } =20 --=20 2.40.1 From nobody Fri May 17 10:13:48 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=1685471291; cv=none; d=zohomail.com; s=zohoarc; b=jDeBUytmOVIqZZerVPzdJgQxes9JQ/nZ73p9Ma2TY6T6FtSi84KJp7IDR4oAtXWAv/ov9p6kK+rTPFyu57EvmrLRHeNjADlFET0+Gs4+iZmDVlAgu0GUEdETZpUNThCBqlXUJV5HAhS+o/D9tBm6YlfHADNzlEOc/wJ40lb9wXs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685471291; 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=4wODLwoVusHPSY8KrD+oYEbUxx0s3W1o0VmT4yG833g=; b=D08LbCEUM+8Fib7MYWmkceEVwVrfyeDg/Vg5UA15EgV03n5reHUTQ/yWgRhdWzFd4Gg6uK5RcQ4hqiXd1FmNJd1V3WZXSSnIhAyIFiGufs9wgK9pfP3IJ3UUCIucyOH4VPnU7j/5yzG10E1Y7bYMN7ktUBmv9syOc99vS1nyqz0= 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 1685471291177634.1940693731248; Tue, 30 May 2023 11:28:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q442d-0001VC-8z; Tue, 30 May 2023 14:25: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 1q442W-0001RE-Ud for qemu-devel@nongnu.org; Tue, 30 May 2023 14:25:48 -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 1q442V-0000hH-9C for qemu-devel@nongnu.org; Tue, 30 May 2023 14:25:48 -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-53-YXMk3COIM5mc1Hq7nthVlA-1; Tue, 30 May 2023 14:25:44 -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 29F35101A531 for ; Tue, 30 May 2023 18:25:44 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3CA51420A8; Tue, 30 May 2023 18:25:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685471145; 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=4wODLwoVusHPSY8KrD+oYEbUxx0s3W1o0VmT4yG833g=; b=NZ14u/i/vyBrhZDXfhi/NbZFuDbs/0giA45owtmwQsBwVSCZodXoGcaBgJ/BCe8gFRw4Mq gmjuXiswlmHZEFtRo/jlAnISvmLFZPeaWVqedWuDvJgIsAo9d/OJrtbTXjuR7ZGiNeyRXO vzkaZr1W53gC5BY2p9dKyNBWhk4K2S0= X-MC-Unique: YXMk3COIM5mc1Hq7nthVlA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Leonardo Bras , Peter Xu , Juan Quintela Subject: [PULL 08/21] migration/rdma: Remove QEMUFile parameter when not used Date: Tue, 30 May 2023 20:25:18 +0200 Message-Id: <20230530182531.6371-9-quintela@redhat.com> In-Reply-To: <20230530182531.6371-1-quintela@redhat.com> References: <20230530182531.6371-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.129.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.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1685471291480100002 Content-Type: text/plain; charset="utf-8" Reviewed-by: Leonardo Bras Signed-off-by: Juan Quintela Message-Id: <20230515195709.63843-13-quintela@redhat.com> --- migration/rdma.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index 074456f9df..416dec00a2 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -2027,7 +2027,7 @@ static int qemu_rdma_exchange_recv(RDMAContext *rdma,= RDMAControlHeader *head, * If we're using dynamic registration on the dest-side, we have to * send a registration command first. */ -static int qemu_rdma_write_one(QEMUFile *f, RDMAContext *rdma, +static int qemu_rdma_write_one(RDMAContext *rdma, int current_index, uint64_t current_addr, uint64_t length) { @@ -2263,7 +2263,7 @@ 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(RDMAContext *rdma) { int ret; =20 @@ -2271,7 +2271,7 @@ static int qemu_rdma_write_flush(QEMUFile *f, RDMACon= text *rdma) return 0; } =20 - ret =3D qemu_rdma_write_one(f, rdma, + ret =3D qemu_rdma_write_one(rdma, rdma->current_index, rdma->current_addr, rdma->current_length); =20 if (ret < 0) { @@ -2344,7 +2344,7 @@ static inline int qemu_rdma_buffer_mergable(RDMAConte= xt *rdma, * and only require that a batch gets acknowledged in the completion * queue instead of each individual chunk. */ -static int qemu_rdma_write(QEMUFile *f, RDMAContext *rdma, +static int qemu_rdma_write(RDMAContext *rdma, uint64_t block_offset, uint64_t offset, uint64_t len) { @@ -2355,7 +2355,7 @@ static int qemu_rdma_write(QEMUFile *f, RDMAContext *= rdma, =20 /* If we cannot merge it, we flush the current buffer first. */ if (!qemu_rdma_buffer_mergable(rdma, current_addr, len)) { - ret =3D qemu_rdma_write_flush(f, rdma); + ret =3D qemu_rdma_write_flush(rdma); if (ret) { return ret; } @@ -2377,7 +2377,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) { - return qemu_rdma_write_flush(f, rdma); + return qemu_rdma_write_flush(rdma); } =20 return 0; @@ -2798,7 +2798,6 @@ static ssize_t qio_channel_rdma_writev(QIOChannel *io= c, Error **errp) { QIOChannelRDMA *rioc =3D QIO_CHANNEL_RDMA(ioc); - QEMUFile *f =3D rioc->file; RDMAContext *rdma; int ret; ssize_t done =3D 0; @@ -2819,7 +2818,7 @@ static ssize_t qio_channel_rdma_writev(QIOChannel *io= c, * 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(rdma); if (ret < 0) { rdma->error_state =3D ret; error_setg(errp, "qemu_rdma_write_flush returned %d", ret); @@ -2958,11 +2957,11 @@ static ssize_t qio_channel_rdma_readv(QIOChannel *i= oc, /* * Block until all the outstanding chunks have been delivered by the hardw= are. */ -static int qemu_rdma_drain_cq(QEMUFile *f, RDMAContext *rdma) +static int qemu_rdma_drain_cq(RDMAContext *rdma) { int ret; =20 - if (qemu_rdma_write_flush(f, rdma) < 0) { + if (qemu_rdma_write_flush(rdma) < 0) { return -EIO; } =20 @@ -3272,7 +3271,7 @@ 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(rdma, block_offset, offset, size); if (ret < 0) { error_report("rdma migration: write error! %d", ret); goto err; @@ -3927,7 +3926,7 @@ static int qemu_rdma_registration_stop(QEMUFile *f, CHECK_ERROR_STATE(); =20 qemu_fflush(f); - ret =3D qemu_rdma_drain_cq(f, rdma); + ret =3D qemu_rdma_drain_cq(rdma); =20 if (ret < 0) { goto err; --=20 2.40.1 From nobody Fri May 17 10:13:48 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=1685471291; cv=none; d=zohomail.com; s=zohoarc; b=GXZQZWj0m+axZtC1xtwQttp9rXE9Y5EChyK3UE8DlKz9XKng9ChmjOt0TOPa2FcIlbz9tV92HzamwcoQDfnF2woyWTvqvJ97IlpcZtfxw6wZ7WAzUwNrDdpqukB8GjRnVG+o9qEjc6z8XrUVH/9aNr5Q0JCbbXiLfQjwxcNp0H8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685471291; 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=Fv3QM7Mnbic0ejea/6Xy0Y25ENFBbzElnOBcnKRS2AQ=; b=UVLj4MjraBZd5Jse4jz6yB4QiN1p2VmPPZGn7f53tU8ELoGZ687PIXg27pWWSO8R0miz7tA1kJXNpTSHtImB6qR264y7UyPVdjI5MHZhEy2i2/ZySQedKKrjN1LHsPd77NrL8tbUDI96WuiMVMOB8sAc4ojlyLa6+qGW0xGekAk= 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 1685471291081533.2861615898305; Tue, 30 May 2023 11:28:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q442m-0001e9-0T; Tue, 30 May 2023 14:26: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 1q442g-0001Zv-QY for qemu-devel@nongnu.org; Tue, 30 May 2023 14:25:59 -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 1q442e-0000ld-AQ for qemu-devel@nongnu.org; Tue, 30 May 2023 14:25:58 -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-185-8EnJ10HhO4-atbiUn72gYw-1; Tue, 30 May 2023 14:25:46 -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 5AADE811E7C for ; Tue, 30 May 2023 18:25:45 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6F327421C5; Tue, 30 May 2023 18:25:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685471155; 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=Fv3QM7Mnbic0ejea/6Xy0Y25ENFBbzElnOBcnKRS2AQ=; b=Nh9jQJFKB0gTHgUCWvmRE2TOmdZsTdR71tIWXDRZ/O/vI6v2O4d1L95xT7B0KehWFo6/l0 VXxyHsW2cCuEgaUKN5Mw7uS1kUFnGuVhqaOgiNQSzdp/ialuPmxOJCfYPnLp9CnUhXMstg 2lq8XZTUfH9LMzHmC90GlJdfdxnbGSQ= X-MC-Unique: 8EnJ10HhO4-atbiUn72gYw-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Leonardo Bras , Peter Xu , Juan Quintela Subject: [PULL 09/21] migration/rdma: Don't use imaginary transfers Date: Tue, 30 May 2023 20:25:19 +0200 Message-Id: <20230530182531.6371-10-quintela@redhat.com> In-Reply-To: <20230530182531.6371-1-quintela@redhat.com> References: <20230530182531.6371-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.129.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.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1685471291471100001 Content-Type: text/plain; charset="utf-8" RDMA protocol is completely asynchronous, so in qemu_rdma_save_page() they "invent" that a byte has been transferred. And then they call qemu_file_credit_transfer() and ram_transferred_add() with that byte. Just remove that calls as nothing has been sent. Reviewed-by: Leonardo Bras Signed-off-by: Juan Quintela Message-Id: <20230515195709.63843-14-quintela@redhat.com> --- migration/qemu-file.c | 5 +---- migration/ram.c | 1 - 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/migration/qemu-file.c b/migration/qemu-file.c index acc282654a..23a21e2331 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -346,13 +346,10 @@ size_t ram_control_save_page(QEMUFile *f, ram_addr_t = block_offset, =20 if (ret !=3D RAM_SAVE_CONTROL_DELAYED && ret !=3D RAM_SAVE_CONTROL_NOT_SUPP) { - if (bytes_sent && *bytes_sent > 0) { - qemu_file_credit_transfer(f, *bytes_sent); - } else if (ret < 0) { + if (ret < 0) { qemu_file_set_error(f, ret); } } - return ret; } =20 diff --git a/migration/ram.c b/migration/ram.c index 40b8f9630d..da0dfd7072 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1155,7 +1155,6 @@ static bool control_save_page(PageSearchStatus *pss, = RAMBlock *block, } =20 if (bytes_xmit) { - ram_transferred_add(bytes_xmit); *pages =3D 1; } =20 --=20 2.40.1 From nobody Fri May 17 10:13:48 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=1685471254; cv=none; d=zohomail.com; s=zohoarc; b=fLdkfvIa95RO7B+rA366EPkH+fjYjQilO7RbifdjwNk38Z91+GmFNpn0oLFBP9FF1Do7fEDrxtHnKRIdRhUkUzwyKVGlvpshRjFByTmcRc+S8tws5YSQw8+J7fsak5V/AUnbJcYDwA7+tnKIBQUneHu87QBg+Sv0skNzdid+znw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685471254; 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=tbUoddsPNoe5gy7NMccUErl69oDqAPliQC3C6nLKXrI=; b=NheMHfwXu4DA2EmwcnMZM4qqqMGIhYSOjyx/s9b7X7xhDueFPzE3q5nlOoI2ciVgzIGrBeNxFeoZQEkDJopetQ/P7yecKtiwfr2jbwp5/WDfH3sAlzzLQDiZhraq524yOHvO4iYctYTfqTSDVJviu/rOo7QAJDomAg9tUl/lR70= 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 1685471254890391.62452939617947; Tue, 30 May 2023 11:27:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q442b-0001UJ-Of; Tue, 30 May 2023 14:25: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 1q442Y-0001S6-C0 for qemu-devel@nongnu.org; Tue, 30 May 2023 14:25:50 -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 1q442W-0000iL-Ue for qemu-devel@nongnu.org; Tue, 30 May 2023 14:25:50 -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-76-F8fcGaJqMBmCvJR89W3C3Q-1; Tue, 30 May 2023 14:25:46 -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 8B0C785A5BA for ; Tue, 30 May 2023 18:25:46 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9EB3B17103; Tue, 30 May 2023 18:25:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685471148; 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=tbUoddsPNoe5gy7NMccUErl69oDqAPliQC3C6nLKXrI=; b=BdULoN4k8oTTC3NB+aPHMHo2ccNT10giLb1hnlr9+gQOF8HV+bvVMlouB2uh6lDkosrIdh OGw8OmWOnqtrbMLHe69mE67WY0o4EqUtu6O71voLq8rM9HajFOzQtklE9GqpfCpfnmTmqv TkX6GyhDZhG/sCPy/YO98jVuzafij9I= X-MC-Unique: F8fcGaJqMBmCvJR89W3C3Q-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Leonardo Bras , Peter Xu , Juan Quintela Subject: [PULL 10/21] migration: Remove unused qemu_file_credit_transfer() Date: Tue, 30 May 2023 20:25:20 +0200 Message-Id: <20230530182531.6371-11-quintela@redhat.com> In-Reply-To: <20230530182531.6371-1-quintela@redhat.com> References: <20230530182531.6371-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: -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.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1685471255326100001 Content-Type: text/plain; charset="utf-8" After this change, nothing abuses QEMUFile to account for data transferrefd during migration. Reviewed-by: Leonardo Bras Signed-off-by: Juan Quintela Message-Id: <20230515195709.63843-15-quintela@redhat.com> --- migration/qemu-file.h | 8 -------- migration/qemu-file.c | 5 ----- 2 files changed, 13 deletions(-) diff --git a/migration/qemu-file.h b/migration/qemu-file.h index e649718492..37f42315c7 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -122,14 +122,6 @@ bool qemu_file_buffer_empty(QEMUFile *file); */ int coroutine_mixed_fn qemu_peek_byte(QEMUFile *f, int offset); void qemu_file_skip(QEMUFile *f, int size); -/* - * qemu_file_credit_transfer: - * - * Report on a number of bytes that have been transferred - * out of band from the main file object I/O methods. This - * accounting information tracks the total migration traffic. - */ -void qemu_file_credit_transfer(QEMUFile *f, size_t size); int qemu_file_get_error_obj(QEMUFile *f, Error **errp); int qemu_file_get_error_obj_any(QEMUFile *f1, QEMUFile *f2, Error **errp); void qemu_file_set_error_obj(QEMUFile *f, int ret, Error *err); diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 23a21e2331..72e130631d 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -411,11 +411,6 @@ static ssize_t coroutine_mixed_fn qemu_fill_buffer(QEM= UFile *f) return len; } =20 -void qemu_file_credit_transfer(QEMUFile *f, size_t size) -{ - f->total_transferred +=3D size; -} - /** Closes the file * * Returns negative error value if any error happened on previous operatio= ns or --=20 2.40.1 From nobody Fri May 17 10:13:48 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=1685471262; cv=none; d=zohomail.com; s=zohoarc; b=K+IqDC7efAr6U4zK57fiKjgSzFw4kUhvzWiGvLsJYlGkTDel85kWI3pNrgYO4A3PUaqKB9UgoK3g6ktgi59NEonBfkLSgFucfMJ3/oKzCDSdEyXqieCCuSygJrjBZLpb9hfWkEzFzBZnv6kZeIYJpiNXilnTWs6I35UhWnWmsQI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685471262; 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=lnyAA9s9nlbOP4s4QiV5AOGRl4whSPxnpnIDwFHEs9I=; b=QQt5pIV4rjpGwMsrpoDEhJQMHAY15z5UTUD7Td1b/l15DikpOHAkhrEbG1mh+waKtiPSDtSuL1zS+N2ZmZywnZTM83dKqK1teXkJUvjq/kMMf3m9qEG8f5HwLQGGD1a0jfHjvHXnLm+QFLQhOdEfk7OLgTrzWNL2J9+DQ4TNvck= 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 1685471262311566.474411052951; Tue, 30 May 2023 11:27:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q442d-0001Vi-Tt; Tue, 30 May 2023 14:25: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 1q442a-0001TX-Qq for qemu-devel@nongnu.org; Tue, 30 May 2023 14:25:52 -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 1q442X-0000iy-TN for qemu-devel@nongnu.org; Tue, 30 May 2023 14:25:52 -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-447-Dmu0hhKWNzCQ4MOxsgTlTQ-1; Tue, 30 May 2023 14:25:48 -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 BDAB0185A78E for ; Tue, 30 May 2023 18:25:47 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id CFB97420A8; Tue, 30 May 2023 18:25:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685471149; 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=lnyAA9s9nlbOP4s4QiV5AOGRl4whSPxnpnIDwFHEs9I=; b=MAEQco5jtKJpkbJmIliuoQNkraLqB9N3UGrZqbfi11+OEq+gq1BZmJGSvBv1ih6c6vIzw1 PFpVr9yPD1FSt5Otze1QLpGzGP9ZOdZzuosPa8D6x3k1aPilDXLwiptX4e5g2eiG4OPPHS jWNNyOI7Gl91WUQ38KfMQp/NWacR1Os= X-MC-Unique: Dmu0hhKWNzCQ4MOxsgTlTQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Leonardo Bras , Peter Xu , Juan Quintela Subject: [PULL 11/21] migration/rdma: Simplify the function that saves a page Date: Tue, 30 May 2023 20:25:21 +0200 Message-Id: <20230530182531.6371-12-quintela@redhat.com> In-Reply-To: <20230530182531.6371-1-quintela@redhat.com> References: <20230530182531.6371-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.129.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.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1685471263990100007 Content-Type: text/plain; charset="utf-8" When we sent a page through QEMUFile hooks (RDMA) there are three posiblities: - We are not using RDMA. return RAM_SAVE_CONTROL_DELAYED and control_save_page() returns false to let anything else to proceed. - There is one error but we are using RDMA. Then we return a negative value, control_save_page() needs to return true. - Everything goes well and RDMA start the sent of the page asynchronously. It returns RAM_SAVE_CONTROL_DELAYED and we need to return 1 for ram_save_page_legacy. Clear? I know, I know, the interface is as bad as it gets. I think that now it is a bit clearer, but this needs to be done some other way. Reviewed-by: Leonardo Bras Signed-off-by: Juan Quintela Message-Id: <20230515195709.63843-16-quintela@redhat.com> --- migration/qemu-file.h | 14 ++++++-------- migration/qemu-file.c | 12 ++++++------ migration/ram.c | 10 +++------- migration/rdma.c | 19 +++---------------- 4 files changed, 18 insertions(+), 37 deletions(-) diff --git a/migration/qemu-file.h b/migration/qemu-file.h index 37f42315c7..ed77996201 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -49,11 +49,10 @@ typedef int (QEMURamHookFunc)(QEMUFile *f, uint64_t fla= gs, void *data); * This function allows override of where the RAM page * is saved (such as RDMA, for example.) */ -typedef size_t (QEMURamSaveFunc)(QEMUFile *f, - ram_addr_t block_offset, - ram_addr_t offset, - size_t size, - uint64_t *bytes_sent); +typedef int (QEMURamSaveFunc)(QEMUFile *f, + ram_addr_t block_offset, + ram_addr_t offset, + size_t size); =20 typedef struct QEMUFileHooks { QEMURamHookFunc *before_ram_iterate; @@ -146,9 +145,8 @@ void ram_control_load_hook(QEMUFile *f, uint64_t flags,= void *data); #define RAM_SAVE_CONTROL_NOT_SUPP -1000 #define RAM_SAVE_CONTROL_DELAYED -2000 =20 -size_t ram_control_save_page(QEMUFile *f, ram_addr_t block_offset, - ram_addr_t offset, size_t size, - uint64_t *bytes_sent); +int ram_control_save_page(QEMUFile *f, ram_addr_t block_offset, + ram_addr_t offset, size_t size); QIOChannel *qemu_file_get_ioc(QEMUFile *file); =20 #endif diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 72e130631d..32ef5e9651 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -336,14 +336,14 @@ void ram_control_load_hook(QEMUFile *f, uint64_t flag= s, void *data) } } =20 -size_t ram_control_save_page(QEMUFile *f, ram_addr_t block_offset, - ram_addr_t offset, size_t size, - uint64_t *bytes_sent) +int ram_control_save_page(QEMUFile *f, ram_addr_t block_offset, + ram_addr_t offset, size_t size) { if (f->hooks && f->hooks->save_page) { - int ret =3D f->hooks->save_page(f, block_offset, - offset, size, bytes_sent); - + int ret =3D f->hooks->save_page(f, block_offset, offset, size); + /* + * RAM_SAVE_CONTROL_* are negative values + */ if (ret !=3D RAM_SAVE_CONTROL_DELAYED && ret !=3D RAM_SAVE_CONTROL_NOT_SUPP) { if (ret < 0) { diff --git a/migration/ram.c b/migration/ram.c index da0dfd7072..eab0cb2710 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1144,23 +1144,19 @@ static int save_zero_page(PageSearchStatus *pss, QE= MUFile *f, RAMBlock *block, static bool control_save_page(PageSearchStatus *pss, RAMBlock *block, ram_addr_t offset, int *pages) { - uint64_t bytes_xmit =3D 0; int ret; =20 - *pages =3D -1; ret =3D ram_control_save_page(pss->pss_channel, block->offset, offset, - TARGET_PAGE_SIZE, &bytes_xmit); + TARGET_PAGE_SIZE); if (ret =3D=3D RAM_SAVE_CONTROL_NOT_SUPP) { return false; } =20 - if (bytes_xmit) { - *pages =3D 1; - } - if (ret =3D=3D RAM_SAVE_CONTROL_DELAYED) { + *pages =3D 1; return true; } + *pages =3D ret; return true; } =20 diff --git a/migration/rdma.c b/migration/rdma.c index 416dec00a2..12d3c23fdc 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -3239,13 +3239,12 @@ qio_channel_rdma_shutdown(QIOChannel *ioc, * * @size : Number of bytes to transfer * - * @bytes_sent : User-specificed pointer to indicate how many bytes were + * @pages_sent : User-specificed pointer to indicate how many pages were * sent. Usually, this will not be more than a few bytes = of * the protocol because most transfers are sent asynchron= ously. */ -static size_t qemu_rdma_save_page(QEMUFile *f, - ram_addr_t block_offset, ram_addr_t offs= et, - size_t size, uint64_t *bytes_sent) +static int qemu_rdma_save_page(QEMUFile *f, ram_addr_t block_offset, + ram_addr_t offset, size_t size) { QIOChannelRDMA *rioc =3D QIO_CHANNEL_RDMA(qemu_file_get_ioc(f)); RDMAContext *rdma; @@ -3277,18 +3276,6 @@ static size_t qemu_rdma_save_page(QEMUFile *f, goto err; } =20 - /* - * We always return 1 bytes because the RDMA - * protocol is completely asynchronous. We do not yet know - * whether an identified chunk is zero or not because we're - * waiting for other pages to potentially be merged with - * the current chunk. So, we have to call qemu_update_position() - * later on when the actual write occurs. - */ - if (bytes_sent) { - *bytes_sent =3D 1; - } - /* * Drain the Completion Queue if possible, but do not block, * just poll. --=20 2.40.1 From nobody Fri May 17 10:13:48 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=1685471315; cv=none; d=zohomail.com; s=zohoarc; b=QXDzv1s8i8M+GBU7QNki8FGqnz/idXkNO6nipVihg/5kI9l8IsO2YEhIpgbuVWQhZHGGoYbcQWHk7/C4OjTz5OuDDq9qCbHGBhxbti6Vb/wsn5k47VfzC48pS26rbBraU13pF+O94aawBKcDz2yx5oz18CftRQhdMOjNzayuUkM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685471315; 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=2TY2CO2Lcs363lXyY0wyAxUcLaDeBd8u1b0rResvmco=; b=dHNxxLDHIBiOokMOxGWlIq0Kc+/RnLX6t1VH7I23Nb1f/KnIQFLEjYWuhvGaOUmCUEUJxKu0GwBYWY5aR51iNMutVFMV4opoOlBWsMUl5x21gWYZ5OAtugkoQQnVpg1eO9HfNQ8a6MhsYaBwybuewQzsOGwuH6Mo1QwnDofYeMA= 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 1685471315612998.2923702278608; Tue, 30 May 2023 11:28:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q442d-0001VH-IZ; Tue, 30 May 2023 14:25: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 1q442b-0001UK-Rs for qemu-devel@nongnu.org; Tue, 30 May 2023 14:25:53 -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 1q442a-0000ja-By for qemu-devel@nongnu.org; Tue, 30 May 2023 14:25:53 -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-588-Ehj7AJ3ZMZ6mGqQcM8kr5Q-1; Tue, 30 May 2023 14:25:49 -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 0404C811E7F for ; Tue, 30 May 2023 18:25:49 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F01A17103; Tue, 30 May 2023 18:25:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685471150; 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=2TY2CO2Lcs363lXyY0wyAxUcLaDeBd8u1b0rResvmco=; b=BKa09yy3yZUDwrF7wOcXQivfdwH55Pdh5oLeu175j03mjXr7SQdDvax7A7jpKV4pooEaV0 uwdv1WDpvXOwhVZJCtFcok7RZqb/or0Xe2n/cIMip42n1RoKn0B4xGiZ45LxvQBTvSSDN4 MFha0pf47CDjU4JQVexhly4BYH9Z9zE= X-MC-Unique: Ehj7AJ3ZMZ6mGqQcM8kr5Q-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Leonardo Bras , Peter Xu , Juan Quintela Subject: [PULL 12/21] migration: Create migrate_rdma() Date: Tue, 30 May 2023 20:25:22 +0200 Message-Id: <20230530182531.6371-13-quintela@redhat.com> In-Reply-To: <20230530182531.6371-1-quintela@redhat.com> References: <20230530182531.6371-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: -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.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1685471317559100007 Content-Type: text/plain; charset="utf-8" Helper to say if we are doing a migration over rdma. Reviewed-by: Peter Xu Signed-off-by: Juan Quintela Message-Id: <20230509120700.78359-2-quintela@redhat.com> --- migration/migration.h | 3 +++ migration/options.h | 1 + migration/migration.c | 1 + migration/options.c | 7 +++++++ migration/rdma.c | 4 +++- 5 files changed, 15 insertions(+), 1 deletion(-) diff --git a/migration/migration.h b/migration/migration.h index 30c3e97635..7359572012 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -440,6 +440,9 @@ struct MigrationState { =20 /* QEMU_VM_VMDESCRIPTION content filled for all non-iterable devices. = */ JSONWriter *vmdesc; + + /* Is this a rdma migration */ + bool rdma_migration; }; =20 void migrate_set_state(int *state, int old_state, int new_state); diff --git a/migration/options.h b/migration/options.h index 45991af3c2..33a6bae93c 100644 --- a/migration/options.h +++ b/migration/options.h @@ -54,6 +54,7 @@ bool migrate_zero_copy_send(void); =20 bool migrate_multifd_flush_after_each_section(void); bool migrate_postcopy(void); +bool migrate_rdma(void); bool migrate_tls(void); =20 /* capabilities helpers */ diff --git a/migration/migration.c b/migration/migration.c index 7c3425c6fe..31d30a2ac5 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1405,6 +1405,7 @@ void migrate_init(MigrationState *s) s->vm_old_state =3D -1; s->iteration_initial_bytes =3D 0; s->threshold_size =3D 0; + s->rdma_migration =3D false; } =20 int migrate_add_blocker_internal(Error *reason, Error **errp) diff --git a/migration/options.c b/migration/options.c index b62ab30cd5..4b99811197 100644 --- a/migration/options.c +++ b/migration/options.c @@ -350,6 +350,13 @@ bool migrate_postcopy(void) return migrate_postcopy_ram() || migrate_dirty_bitmaps(); } =20 +bool migrate_rdma(void) +{ + MigrationState *s =3D migrate_get_current(); + + return s->rdma_migration; +} + bool migrate_tls(void) { MigrationState *s =3D migrate_get_current(); diff --git a/migration/rdma.c b/migration/rdma.c index 12d3c23fdc..c11863e614 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -4122,6 +4122,7 @@ void rdma_start_incoming_migration(const char *host_p= ort, Error **errp) int ret; RDMAContext *rdma; Error *local_err =3D NULL; + MigrationState *s =3D migrate_get_current(); =20 trace_rdma_start_incoming_migration(); =20 @@ -4152,7 +4153,7 @@ void rdma_start_incoming_migration(const char *host_p= ort, Error **errp) } =20 trace_rdma_start_incoming_migration_after_rdma_listen(); - + s->rdma_migration =3D true; qemu_set_fd_handler(rdma->channel->fd, rdma_accept_incoming_migration, NULL, (void *)(intptr_t)rdma); return; @@ -4228,6 +4229,7 @@ void rdma_start_outgoing_migration(void *opaque, =20 trace_rdma_start_outgoing_migration_after_rdma_connect(); =20 + s->rdma_migration =3D true; s->to_dst_file =3D qemu_fopen_rdma(rdma, "wb"); migrate_fd_connect(s, NULL); return; --=20 2.40.1 From nobody Fri May 17 10:13:48 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=1685471218; cv=none; d=zohomail.com; s=zohoarc; b=NnPcdAY7dd72yBhRepxMa/dEwjIdgAJPTdLrQRG9KwKy4fmSzGL/dyKd56tZrT90l7X7LPuX+fQa6v4IhRUKTV8JYj7juI7QrhEBXIZJ/m66iUQ5mC90rEOLRbkNUUvgRi+6mvUaVohOohzaMUYNUwD8Rz8MifICpkcYmr7VVkY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685471218; 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=zQW35MHS3TnLCcUdr3YI2k46h3xUpZF4dkCAIi4Iey8=; b=C8LzxGOKo5Dtr6geCSWfK8I/ON4F1TK9cYDgWDWogatOhCTdslCaDwMzhgAwtV2WTr0qx05w7CYjyaqCTQuZo50120DT4kY4nf9CRs5QF2heHWrD/wOeYzE7nw4xs3P4HRcUPEHHCpf/9fjMmVk7EE9VNSjjlUJHPjrUEnEBolo= 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 1685471218285347.3294468946425; Tue, 30 May 2023 11:26:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q442k-0001b5-0M; Tue, 30 May 2023 14:26: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 1q442g-0001Zt-Q7 for qemu-devel@nongnu.org; Tue, 30 May 2023 14:25:58 -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 1q442e-0000lM-5P for qemu-devel@nongnu.org; Tue, 30 May 2023 14:25:58 -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-477-m8psjPPKOHiwe8_rO7BE5w-1; Tue, 30 May 2023 14:25:54 -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 387B585A5BB for ; Tue, 30 May 2023 18:25:50 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 49D1917103; Tue, 30 May 2023 18:25:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685471155; 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=zQW35MHS3TnLCcUdr3YI2k46h3xUpZF4dkCAIi4Iey8=; b=RzZNI5PFf3bbmVWueRQV1le9KfkiknbrfJ1CN3iVm6J4hC/tOAzmHshMKwSV2GAAcssHBy 1+z4nxyfIPlW43Pxzkq2UNrCZa3cMZTGK/9gysWfUh85WYTCmw60EGay+k9oBpP7Zc2AIz puOAxSRwafoFp5t11039xm5DmrAXsWM= X-MC-Unique: m8psjPPKOHiwe8_rO7BE5w-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Leonardo Bras , Peter Xu , Juan Quintela Subject: [PULL 13/21] migration/rdma: Unfold ram_control_before_iterate() Date: Tue, 30 May 2023 20:25:23 +0200 Message-Id: <20230530182531.6371-14-quintela@redhat.com> In-Reply-To: <20230530182531.6371-1-quintela@redhat.com> References: <20230530182531.6371-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.129.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.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1685471219163100003 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() Reviewed-by: Peter Xu Signed-off-by: Juan Quintela Message-Id: <20230509120700.78359-3-quintela@redhat.com> --- migration/qemu-file.h | 2 -- migration/rdma.h | 7 +++++++ migration/qemu-file.c | 13 +------------ migration/ram.c | 16 +++++++++++++--- migration/rdma.c | 6 ++---- 5 files changed, 23 insertions(+), 21 deletions(-) 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/rdma.h b/migration/rdma.h index de2ba09dc5..670c67a8cb 100644 --- a/migration/rdma.h +++ b/migration/rdma.h @@ -22,4 +22,11 @@ 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 +static inline +int qemu_rdma_registration_start(QEMUFile *f, uint64_t flags) { return 0; } +#endif #endif 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/ram.c b/migration/ram.c index eab0cb2710..b070278796 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() */ @@ -3012,7 +3013,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)); @@ -3072,7 +3076,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; @@ -3177,7 +3184,10 @@ static int ram_save_complete(QEMUFile *f, void *opaq= ue) migration_bitmap_sync_precopy(rs, true); } =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 c11863e614..6ca89ff090 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -3863,13 +3863,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 @@ -4007,7 +4006,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, }; --=20 2.40.1 From nobody Fri May 17 10:13:48 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=1685471272; cv=none; d=zohomail.com; s=zohoarc; b=GQ7kaSaT2//CIkMzzY+LKiHKZrKyyb7mxDgL7AW3dNS0MKRV5AMXJBsEV2b1wBmNC7obLdeReP3nzbXgw+YqJ4iFjSo0R6iOic0U+JsQaEbRIXHU1u/7vVtT7Qj7BzU2RJAUgNtElkuJSNWO9vafdXZVH2Y0UJOZYLZGvqHEKIk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685471272; 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=/Zek4ebkL9sMmN+x0/HIdlPRp8/XFcjCXK4DuY/5N0s=; b=b4SHNmwtXHr+5Az1eVonB7J4rr9PCOcmA9NNpEi+gPwV1uj8KJUsBsdjoX8h19Rx3F+yHxU8jSiO90x2kPBnP3BvRcX3Ej9FbTrxxS+rKicX6DiosH2O/iO0snd8yJDbJVSS4ATY7WKuIUeP2V87pNvOXBLHJ3xkdTtIk3qU+0g= 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 1685471272466535.679880987519; Tue, 30 May 2023 11:27:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q442j-0001ao-Ci; Tue, 30 May 2023 14:26: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 1q442g-0001Zx-RJ for qemu-devel@nongnu.org; Tue, 30 May 2023 14:25:59 -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 1q442e-0000lZ-AD for qemu-devel@nongnu.org; Tue, 30 May 2023 14:25:58 -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-99-1Yjmp79FNom_EVDVvD0iFg-1; Tue, 30 May 2023 14:25:52 -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 28F39800141 for ; Tue, 30 May 2023 18:25:52 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7D68F17103; Tue, 30 May 2023 18:25:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685471155; 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=/Zek4ebkL9sMmN+x0/HIdlPRp8/XFcjCXK4DuY/5N0s=; b=O1PvCIMQrhLc6SqdKcgjFDq2i+piUl9FRMMVphwDcF0dmEEoohcHyllwVNOBzeeIJ5H/7h x1x3Ps4fyATybhpUFleOW3dLllT5kf8b3tVG2uSJ4w3yAG8SzY1em8VykJZW1LqE0+HcwV hojDnbQj4LfWxznnuXM9DsDC0n2ZY10= X-MC-Unique: 1Yjmp79FNom_EVDVvD0iFg-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Leonardo Bras , Peter Xu , Juan Quintela Subject: [PULL 14/21] migration/rdma: Unfold ram_control_after_iterate() Date: Tue, 30 May 2023 20:25:24 +0200 Message-Id: <20230530182531.6371-15-quintela@redhat.com> In-Reply-To: <20230530182531.6371-1-quintela@redhat.com> References: <20230530182531.6371-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.129.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.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1685471274022100003 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_stop() Reviewed-by: Peter Xu Signed-off-by: Juan Quintela Message-Id: <20230509120700.78359-4-quintela@redhat.com> --- migration/qemu-file.h | 2 -- migration/rdma.h | 3 +++ migration/qemu-file.c | 12 ------------ migration/ram.c | 17 ++++++++++++++--- migration/rdma.c | 6 ++---- 5 files changed, 19 insertions(+), 21 deletions(-) diff --git a/migration/qemu-file.h b/migration/qemu-file.h index ced2202137..323af5682f 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 *after_ram_iterate; QEMURamHookFunc *hook_ram_load; QEMURamSaveFunc *save_page; } QEMUFileHooks; @@ -130,7 +129,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_after_iterate(QEMUFile *f, uint64_t flags); void ram_control_load_hook(QEMUFile *f, uint64_t flags, void *data); =20 /* Whenever this is found in the data stream, the flags diff --git a/migration/rdma.h b/migration/rdma.h index 670c67a8cb..c13b94c782 100644 --- a/migration/rdma.h +++ b/migration/rdma.h @@ -25,8 +25,11 @@ 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); +int qemu_rdma_registration_stop(QEMUFile *f, uint64_t flags); #else static inline int qemu_rdma_registration_start(QEMUFile *f, uint64_t flags) { return 0; } +static inline +int qemu_rdma_registration_stop(QEMUFile *f, uint64_t flags) { return 0; } #endif #endif diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 6243d6ac59..918df83035 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -303,18 +303,6 @@ void qemu_fflush(QEMUFile *f) f->iovcnt =3D 0; } =20 -void ram_control_after_iterate(QEMUFile *f, uint64_t flags) -{ - int ret =3D 0; - - if (f->hooks && f->hooks->after_ram_iterate) { - ret =3D f->hooks->after_ram_iterate(f, flags, NULL); - if (ret < 0) { - qemu_file_set_error(f, ret); - } - } -} - void ram_control_load_hook(QEMUFile *f, uint64_t flags, void *data) { if (f->hooks && f->hooks->hook_ram_load) { diff --git a/migration/ram.c b/migration/ram.c index b070278796..c6fad7b0b3 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3017,7 +3017,11 @@ static int ram_save_setup(QEMUFile *f, void *opaque) if (ret < 0) { qemu_file_set_error(f, ret); } - ram_control_after_iterate(f, RAM_CONTROL_SETUP); + + ret =3D qemu_rdma_registration_stop(f, RAM_CONTROL_SETUP); + if (ret < 0) { + qemu_file_set_error(f, ret); + } =20 migration_ops =3D g_malloc0(sizeof(MigrationOps)); migration_ops->ram_save_target_page =3D ram_save_target_page_legacy; @@ -3136,7 +3140,10 @@ static int ram_save_iterate(QEMUFile *f, void *opaqu= e) * Must occur before EOS (or any QEMUFile operation) * because of RDMA protocol. */ - ram_control_after_iterate(f, RAM_CONTROL_ROUND); + ret =3D qemu_rdma_registration_stop(f, RAM_CONTROL_ROUND); + if (ret < 0) { + qemu_file_set_error(f, ret); + } =20 out: if (ret >=3D 0 @@ -3209,7 +3216,11 @@ static int ram_save_complete(QEMUFile *f, void *opaq= ue) qemu_mutex_unlock(&rs->bitmap_mutex); =20 ram_flush_compressed_data(rs); - ram_control_after_iterate(f, RAM_CONTROL_FINISH); + + int ret =3D qemu_rdma_registration_stop(f, RAM_CONTROL_FINISH); + if (ret < 0) { + qemu_file_set_error(f, ret); + } } =20 if (ret < 0) { diff --git a/migration/rdma.c b/migration/rdma.c index 6ca89ff090..8001dcb960 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -3891,15 +3891,14 @@ int qemu_rdma_registration_start(QEMUFile *f, uint6= 4_t flags) * Inform dest that dynamic registrations are done for now. * First, flush writes, if any. */ -static int qemu_rdma_registration_stop(QEMUFile *f, - uint64_t flags, void *data) +int qemu_rdma_registration_stop(QEMUFile *f, uint64_t flags) { 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; =20 - if (migration_in_postcopy()) { + if (!migrate_rdma() || migration_in_postcopy()) { return 0; } =20 @@ -4006,7 +4005,6 @@ static const QEMUFileHooks rdma_read_hooks =3D { }; =20 static const QEMUFileHooks rdma_write_hooks =3D { - .after_ram_iterate =3D qemu_rdma_registration_stop, .save_page =3D qemu_rdma_save_page, }; =20 --=20 2.40.1 From nobody Fri May 17 10:13:48 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=1685471173; cv=none; d=zohomail.com; s=zohoarc; b=kPFc9wHTiQBXUWhpy53hoKWjZHCU5Q2GhOYZZLleOiVEk8KUCfV20w8/gXl9XbjBci4LhGnO2bQfQ8qPJXpGH76a6mgpZPnBDCyO2PMw4NENWF7+iDMWSkfjCGrE+x08Q7SD/KaLdXR0k9PhWHNh9kN17ZmgzxCDlTO3OV4fZHQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685471173; 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=6yusL7CMhLDnGapYlqGQSNFa7qKwrUdftv22tiX0Nmk=; b=fSQPucvexwUvn51L3LeeT6fbjMZJUUwM4UdwQacrtGtSNrJDvT0SNDlqAk5pHZlN7pHdItdiR6lphGgEr+cJZMcoRMP9/aVFkE+ZG/JfYwR7rKeKg1M3qauS/GLL4XmEyQAFLIUq2JyhxBijIHijkzFc1nzv6KVqclWOAelAuAo= 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 1685471173817196.27488922819202; Tue, 30 May 2023 11:26:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q442h-0001a0-P6; Tue, 30 May 2023 14:25: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 1q442f-0001ZL-EC for qemu-devel@nongnu.org; Tue, 30 May 2023 14:25:57 -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 1q442d-0000lE-QY for qemu-devel@nongnu.org; Tue, 30 May 2023 14:25:57 -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-246-Dx15F4KOPSesB2VcO1QjoQ-1; Tue, 30 May 2023 14:25:53 -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 5FB0A85A5BA for ; Tue, 30 May 2023 18:25:53 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6F254420A8; Tue, 30 May 2023 18:25:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685471155; 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=6yusL7CMhLDnGapYlqGQSNFa7qKwrUdftv22tiX0Nmk=; b=YtOzC4DoCw2Ez3+OqzO1GKII5KBo/kk1CgyjPocu4atQcMjZ97ggyE2HqRarEgQ+np7Ej3 LqTylZM0M52JzleOTNCd9xYpDj/dvpdMPh0LmkmULJpz58w6V0q0P+2mhHTWJOgXtGS1v5 Qy04N5NogSUnrpr/HB45DYDx3Jz557I= X-MC-Unique: Dx15F4KOPSesB2VcO1QjoQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Leonardo Bras , Peter Xu , Juan Quintela Subject: [PULL 15/21] migration/rdma: Remove all uses of RAM_CONTROL_HOOK Date: Tue, 30 May 2023 20:25:25 +0200 Message-Id: <20230530182531.6371-16-quintela@redhat.com> In-Reply-To: <20230530182531.6371-1-quintela@redhat.com> References: <20230530182531.6371-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: -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.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1685471174280100002 Content-Type: text/plain; charset="utf-8" Instead of going trhough ram_control_load_hook(), call qemu_rdma_registration_handle() directly. Reviewed-by: Peter Xu Signed-off-by: Juan Quintela Message-Id: <20230509120700.78359-5-quintela@redhat.com> --- migration/qemu-file.h | 1 - migration/rdma.h | 3 +++ migration/ram.c | 5 ++++- migration/rdma.c | 9 +++++---- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/migration/qemu-file.h b/migration/qemu-file.h index 323af5682f..7cfc20825e 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -41,7 +41,6 @@ typedef int (QEMURamHookFunc)(QEMUFile *f, uint64_t flags= , void *data); */ #define RAM_CONTROL_SETUP 0 #define RAM_CONTROL_ROUND 1 -#define RAM_CONTROL_HOOK 2 #define RAM_CONTROL_FINISH 3 #define RAM_CONTROL_BLOCK_REG 4 =20 diff --git a/migration/rdma.h b/migration/rdma.h index c13b94c782..8bd277efb9 100644 --- a/migration/rdma.h +++ b/migration/rdma.h @@ -24,10 +24,13 @@ void rdma_start_incoming_migration(const char *host_por= t, Error **errp); =20 =20 #ifdef CONFIG_RDMA +int qemu_rdma_registration_handle(QEMUFile *f); int qemu_rdma_registration_start(QEMUFile *f, uint64_t flags); int qemu_rdma_registration_stop(QEMUFile *f, uint64_t flags); #else static inline +int qemu_rdma_registration_handle(QEMUFile *f) { return 0; } +static inline int qemu_rdma_registration_start(QEMUFile *f, uint64_t flags) { return 0; } static inline int qemu_rdma_registration_stop(QEMUFile *f, uint64_t flags) { return 0; } diff --git a/migration/ram.c b/migration/ram.c index c6fad7b0b3..6f0597814c 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -4024,7 +4024,10 @@ static int ram_load_precopy(QEMUFile *f) } break; case RAM_SAVE_FLAG_HOOK: - ram_control_load_hook(f, RAM_CONTROL_HOOK, NULL); + ret =3D qemu_rdma_registration_handle(f); + if (ret < 0) { + qemu_file_set_error(f, ret); + } break; default: error_report("Unknown combination of migration flags: 0x%x", f= lags); diff --git a/migration/rdma.c b/migration/rdma.c index 8001dcb960..a477985c6d 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -3530,7 +3530,7 @@ static int dest_ram_sort_func(const void *a, const vo= id *b) * * Keep doing this until the source tells us to stop. */ -static int qemu_rdma_registration_handle(QEMUFile *f) +int qemu_rdma_registration_handle(QEMUFile *f) { RDMAControlHeader reg_resp =3D { .len =3D sizeof(RDMARegisterResult), .type =3D RDMA_CONTROL_REGISTER_RESULT, @@ -3557,6 +3557,10 @@ static int qemu_rdma_registration_handle(QEMUFile *f) int count =3D 0; int i =3D 0; =20 + if (!migrate_rdma()) { + return 0; + } + RCU_READ_LOCK_GUARD(); rdma =3D qatomic_rcu_read(&rioc->rdmain); =20 @@ -3854,9 +3858,6 @@ static int rdma_load_hook(QEMUFile *f, uint64_t flags= , void *data) case RAM_CONTROL_BLOCK_REG: return rdma_block_notification_handle(f, data); =20 - case RAM_CONTROL_HOOK: - return qemu_rdma_registration_handle(f); - default: /* Shouldn't be called with any other values */ abort(); --=20 2.40.1 From nobody Fri May 17 10:13:48 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=1685471260; cv=none; d=zohomail.com; s=zohoarc; b=aBFPoa1Aheei0A6w3RkjIWD19G2wE51FTF4tUfzIAp458+4Ij8M0gE3DKfjntrUUfpiuHL6QXTvDkhn+mJt9JFGXaLr5nLTGNuSYYu5HekYdzkWltPMZn9izp4KZ9jXU0dn28bFM2bWvrjyB20Asqv4YdmQitz9KiRfWXeo7WRI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685471260; 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=juMTlFq6aztO1zifJvTk7H6W25YhECxOmC1Oq0eWK90=; b=mIcK4Hm55/c2ibHkCYSHkvuHnUhVTKJnvVwxap9JWuTEvTPXojtNJ6fEk8rpd8pwDLLGmLn/xEbV45tD3xW8tFS3qtfayxl8B5kGWcoZ3wT3ZUgNAqtjYlCEyUcRJ9HJR6VsPc5tCjanKEDuSz47VP2I78K6dhQdtFjIDLSEzDI= 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 1685471260497547.8273222811015; Tue, 30 May 2023 11:27:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q4430-0002AM-DR; Tue, 30 May 2023 14:26:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q442x-0001rx-Ng for qemu-devel@nongnu.org; Tue, 30 May 2023 14:26:16 -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 1q442h-0000nf-Um for qemu-devel@nongnu.org; Tue, 30 May 2023 14:26:15 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-329-QmP6QF-AMDCRbJv-S891pA-1; Tue, 30 May 2023 14:25:54 -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 936A385A5BA for ; Tue, 30 May 2023 18:25:54 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id A443B17103; Tue, 30 May 2023 18:25:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685471158; 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=juMTlFq6aztO1zifJvTk7H6W25YhECxOmC1Oq0eWK90=; b=ZEn5B/w+6RS1Ci8Wv5QH7UOJ7NDiOGBkPypRt2hWgte8YKM80It3N9eBKTSSTRQuELSyjg kUTO/jmqThPdcBLAGVLhmouv7NSOzbLNSmIj9STaTU0S5MLCY3keKHPW84v24Jr5qdtX8A P+GXeG69tTQlH0lcF8uWyHcPLm0oLRk= X-MC-Unique: QmP6QF-AMDCRbJv-S891pA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Leonardo Bras , Peter Xu , Juan Quintela Subject: [PULL 16/21] migration/rdma: Unfold hook_ram_load() Date: Tue, 30 May 2023 20:25:26 +0200 Message-Id: <20230530182531.6371-17-quintela@redhat.com> In-Reply-To: <20230530182531.6371-1-quintela@redhat.com> References: <20230530182531.6371-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.129.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.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, 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: 1685471262007100003 Content-Type: text/plain; charset="utf-8" There is only one flag called with: RAM_CONTROL_BLOCK_REG. Reviewed-by: Peter Xu Signed-off-by: Juan Quintela Message-Id: <20230509120700.78359-6-quintela@redhat.com> --- migration/qemu-file.h | 11 ----------- migration/rdma.h | 3 +++ migration/qemu-file.c | 10 ---------- migration/ram.c | 6 ++++-- migration/rdma.c | 29 +++++++++-------------------- 5 files changed, 16 insertions(+), 43 deletions(-) diff --git a/migration/qemu-file.h b/migration/qemu-file.h index 7cfc20825e..6791db6b08 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -29,20 +29,12 @@ #include "exec/cpu-common.h" #include "io/channel.h" =20 -/* - * This function provides hooks around different - * stages of RAM migration. - * 'data' is call specific data associated with the 'flags' value - */ -typedef int (QEMURamHookFunc)(QEMUFile *f, uint64_t flags, void *data); - /* * Constants used by ram_control_* hooks */ #define RAM_CONTROL_SETUP 0 #define RAM_CONTROL_ROUND 1 #define RAM_CONTROL_FINISH 3 -#define RAM_CONTROL_BLOCK_REG 4 =20 /* * This function allows override of where the RAM page @@ -54,7 +46,6 @@ typedef int (QEMURamSaveFunc)(QEMUFile *f, size_t size); =20 typedef struct QEMUFileHooks { - QEMURamHookFunc *hook_ram_load; QEMURamSaveFunc *save_page; } QEMUFileHooks; =20 @@ -128,8 +119,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_load_hook(QEMUFile *f, uint64_t flags, void *data); - /* Whenever this is found in the data stream, the flags * will be passed to ram_control_load_hook in the incoming-migration * side. This lets before_ram_iterate/after_ram_iterate add diff --git a/migration/rdma.h b/migration/rdma.h index 8bd277efb9..8df8b4089a 100644 --- a/migration/rdma.h +++ b/migration/rdma.h @@ -27,6 +27,7 @@ void rdma_start_incoming_migration(const char *host_port,= Error **errp); int qemu_rdma_registration_handle(QEMUFile *f); int qemu_rdma_registration_start(QEMUFile *f, uint64_t flags); int qemu_rdma_registration_stop(QEMUFile *f, uint64_t flags); +int rdma_block_notification_handle(QEMUFile *f, const char *name); #else static inline int qemu_rdma_registration_handle(QEMUFile *f) { return 0; } @@ -34,5 +35,7 @@ static inline int qemu_rdma_registration_start(QEMUFile *f, uint64_t flags) { return 0; } static inline int qemu_rdma_registration_stop(QEMUFile *f, uint64_t flags) { return 0; } +static inline +int rdma_block_notification_handle(QEMUFile *f, const char *name) { return= 0; } #endif #endif diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 918df83035..08bbc29e64 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -303,16 +303,6 @@ void qemu_fflush(QEMUFile *f) f->iovcnt =3D 0; } =20 -void ram_control_load_hook(QEMUFile *f, uint64_t flags, void *data) -{ - if (f->hooks && f->hooks->hook_ram_load) { - int ret =3D f->hooks->hook_ram_load(f, flags, data); - if (ret < 0) { - qemu_file_set_error(f, ret); - } - } -} - int ram_control_save_page(QEMUFile *f, ram_addr_t block_offset, ram_addr_t offset, size_t size) { diff --git a/migration/ram.c b/migration/ram.c index 6f0597814c..67d0f20368 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3975,8 +3975,10 @@ static int ram_load_precopy(QEMUFile *f) ret =3D -EINVAL; } } - ram_control_load_hook(f, RAM_CONTROL_BLOCK_REG, - block->idstr); + ret =3D rdma_block_notification_handle(f, block->idstr= ); + if (ret < 0) { + qemu_file_set_error(f, ret); + } } else { error_report("Unknown ramblock \"%s\", cannot " "accept migration", id); diff --git a/migration/rdma.c b/migration/rdma.c index a477985c6d..948e93256d 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -3811,20 +3811,22 @@ out: } =20 /* Destination: - * Called via a ram_control_load_hook during the initial RAM load section = which - * lists the RAMBlocks by name. This lets us know the order of the RAMBlo= cks - * on the source. - * We've already built our local RAMBlock list, but not yet sent the list = to - * the source. + * Called during the initial RAM load section which lists the + * RAMBlocks by name. This lets us know the order of the RAMBlocks on + * the source. We've already built our local RAMBlock list, but not + * yet sent the list to the source. */ -static int -rdma_block_notification_handle(QEMUFile *f, const char *name) +int rdma_block_notification_handle(QEMUFile *f, const char *name) { RDMAContext *rdma; QIOChannelRDMA *rioc =3D QIO_CHANNEL_RDMA(qemu_file_get_ioc(f)); int curr; int found =3D -1; =20 + if (!migrate_rdma()) { + return 0; + } + RCU_READ_LOCK_GUARD(); rdma =3D qatomic_rcu_read(&rioc->rdmain); =20 @@ -3852,18 +3854,6 @@ rdma_block_notification_handle(QEMUFile *f, const ch= ar *name) return 0; } =20 -static int rdma_load_hook(QEMUFile *f, uint64_t flags, void *data) -{ - switch (flags) { - case RAM_CONTROL_BLOCK_REG: - return rdma_block_notification_handle(f, data); - - default: - /* Shouldn't be called with any other values */ - abort(); - } -} - int qemu_rdma_registration_start(QEMUFile *f, uint64_t flags) { QIOChannelRDMA *rioc =3D QIO_CHANNEL_RDMA(qemu_file_get_ioc(f)); @@ -4002,7 +3992,6 @@ err: } =20 static const QEMUFileHooks rdma_read_hooks =3D { - .hook_ram_load =3D rdma_load_hook, }; =20 static const QEMUFileHooks rdma_write_hooks =3D { --=20 2.40.1 From nobody Fri May 17 10:13:48 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=1685471309; cv=none; d=zohomail.com; s=zohoarc; b=Q/P4LYiGXJo5cPsOLnwQvM6cLjk12aWR9FkUWJf0vTeKUsUlZfgFWxgAxpVik5mOq+dPmmzsdLZW2ycniK1XfG/uYp7y0xVwtnUeHbLwmLexT3Jz4WUcH70h3J+7dEyiZMcRD7Mh1EItzR9p075qzDFYXKoQZlCjZMSJQC86fUU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685471309; 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=/EDDcjIhTYszY8FKxqxH6kpFlFG9qBhY/ST8mNysln4=; b=eOoL47t4pqgp99MKkCtIZj2u3gapXSsltdwHszbGmpNdDjQpGHxa6RpQlSrUWNxekBwc8o410/WBjFH/69wfZxjBaAOoI60VS/dnvTmyXk+qtIIDe5q38P6L9huCchSFowewWc+d6Us7EH7qWcPz/DQjBHOII3Gz/zw1HJO3Avs= 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 1685471309423813.0385532636027; Tue, 30 May 2023 11:28:29 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q442o-0001gf-MV; Tue, 30 May 2023 14:26:06 -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 1q442j-0001b8-OJ for qemu-devel@nongnu.org; Tue, 30 May 2023 14:26:01 -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 1q442g-0000nJ-IZ for qemu-devel@nongnu.org; Tue, 30 May 2023 14:26:01 -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-128-UKLXyRv7OFesFDkFzvbmDQ-1; Tue, 30 May 2023 14:25:56 -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 C7941811E85 for ; Tue, 30 May 2023 18:25:55 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id D7B7E17103; Tue, 30 May 2023 18:25:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685471157; 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=/EDDcjIhTYszY8FKxqxH6kpFlFG9qBhY/ST8mNysln4=; b=SRVXW/ks1ST3BchNDXQBQSa0svabTI2wmHSoniaF/FV1GLGk7L0PE06505vIwLl4v1Yif/ l+1KSVHlMMQZiLqAT2m3AStbvKIlbBw+wEtjqsMCzU17NBDfXfAuhKNOwiNzmPyYfYY48v huMApxv9YvEXq9BK/fMUbzTUW9KThNo= X-MC-Unique: UKLXyRv7OFesFDkFzvbmDQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Leonardo Bras , Peter Xu , Juan Quintela Subject: [PULL 17/21] migration/rdma: Create rdma_control_save_page() Date: Tue, 30 May 2023 20:25:27 +0200 Message-Id: <20230530182531.6371-18-quintela@redhat.com> In-Reply-To: <20230530182531.6371-1-quintela@redhat.com> References: <20230530182531.6371-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: -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.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1685471310160100005 Content-Type: text/plain; charset="utf-8" The only user of ram_control_save_page() and save_page() hook was rdma. Just move the function to rdma.c, rename it to rdma_control_save_page(). Reviewed-by: Peter Xu Signed-off-by: Juan Quintela Message-Id: <20230509120700.78359-7-quintela@redhat.com> --- migration/qemu-file.h | 12 ------------ migration/rdma.h | 10 ++++++++++ migration/qemu-file.c | 20 -------------------- migration/ram.c | 4 ++-- migration/rdma.c | 20 +++++++++++++++++++- 5 files changed, 31 insertions(+), 35 deletions(-) diff --git a/migration/qemu-file.h b/migration/qemu-file.h index 6791db6b08..c43c410168 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -36,17 +36,7 @@ #define RAM_CONTROL_ROUND 1 #define RAM_CONTROL_FINISH 3 =20 -/* - * This function allows override of where the RAM page - * is saved (such as RDMA, for example.) - */ -typedef int (QEMURamSaveFunc)(QEMUFile *f, - ram_addr_t block_offset, - ram_addr_t offset, - size_t size); - typedef struct QEMUFileHooks { - QEMURamSaveFunc *save_page; } QEMUFileHooks; =20 QEMUFile *qemu_file_new_input(QIOChannel *ioc); @@ -129,8 +119,6 @@ int qemu_file_get_to_fd(QEMUFile *f, int fd, size_t siz= e); #define RAM_SAVE_CONTROL_NOT_SUPP -1000 #define RAM_SAVE_CONTROL_DELAYED -2000 =20 -int ram_control_save_page(QEMUFile *f, ram_addr_t block_offset, - ram_addr_t offset, size_t size); QIOChannel *qemu_file_get_ioc(QEMUFile *file); =20 #endif diff --git a/migration/rdma.h b/migration/rdma.h index 8df8b4089a..09a16c1e3c 100644 --- a/migration/rdma.h +++ b/migration/rdma.h @@ -17,6 +17,8 @@ #ifndef QEMU_MIGRATION_RDMA_H #define QEMU_MIGRATION_RDMA_H =20 +#include "exec/memory.h" + void rdma_start_outgoing_migration(void *opaque, const char *host_port, Error **errp); =20 @@ -28,6 +30,8 @@ int qemu_rdma_registration_handle(QEMUFile *f); int qemu_rdma_registration_start(QEMUFile *f, uint64_t flags); int qemu_rdma_registration_stop(QEMUFile *f, uint64_t flags); int rdma_block_notification_handle(QEMUFile *f, const char *name); +int rdma_control_save_page(QEMUFile *f, ram_addr_t block_offset, + ram_addr_t offset, size_t size); #else static inline int qemu_rdma_registration_handle(QEMUFile *f) { return 0; } @@ -37,5 +41,11 @@ static inline int qemu_rdma_registration_stop(QEMUFile *f, uint64_t flags) { return 0; } static inline int rdma_block_notification_handle(QEMUFile *f, const char *name) { return= 0; } +static inline +int rdma_control_save_page(QEMUFile *f, ram_addr_t block_offset, + ram_addr_t offset, size_t size) +{ + return RAM_SAVE_CONTROL_NOT_SUPP; +} #endif #endif diff --git a/migration/qemu-file.c b/migration/qemu-file.c index 08bbc29e64..a222daeaab 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -303,26 +303,6 @@ void qemu_fflush(QEMUFile *f) f->iovcnt =3D 0; } =20 -int ram_control_save_page(QEMUFile *f, ram_addr_t block_offset, - ram_addr_t offset, size_t size) -{ - if (f->hooks && f->hooks->save_page) { - int ret =3D f->hooks->save_page(f, block_offset, offset, size); - /* - * RAM_SAVE_CONTROL_* are negative values - */ - if (ret !=3D RAM_SAVE_CONTROL_DELAYED && - ret !=3D RAM_SAVE_CONTROL_NOT_SUPP) { - if (ret < 0) { - qemu_file_set_error(f, ret); - } - } - return ret; - } - - return RAM_SAVE_CONTROL_NOT_SUPP; -} - /* * Attempt to fill the buffer from the underlying file * Returns the number of bytes read, or negative value for an error. diff --git a/migration/ram.c b/migration/ram.c index 67d0f20368..19e5e93de8 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -1147,8 +1147,8 @@ static bool control_save_page(PageSearchStatus *pss, = RAMBlock *block, { int ret; =20 - ret =3D ram_control_save_page(pss->pss_channel, block->offset, offset, - TARGET_PAGE_SIZE); + ret =3D rdma_control_save_page(pss->pss_channel, block->offset, offset, + TARGET_PAGE_SIZE); if (ret =3D=3D RAM_SAVE_CONTROL_NOT_SUPP) { return false; } diff --git a/migration/rdma.c b/migration/rdma.c index 948e93256d..b506b86b47 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -3319,6 +3319,25 @@ err: return ret; } =20 +int rdma_control_save_page(QEMUFile *f, ram_addr_t block_offset, + ram_addr_t offset, size_t size) +{ + if (!migrate_rdma()) { + return RAM_SAVE_CONTROL_NOT_SUPP; + } + + int ret =3D qemu_rdma_save_page(f, block_offset, offset, size); + + if (ret !=3D RAM_SAVE_CONTROL_DELAYED && + ret !=3D RAM_SAVE_CONTROL_NOT_SUPP) { + if (ret < 0) { + qemu_file_set_error(f, ret); + } + } + return ret; +} + + static void rdma_accept_incoming_migration(void *opaque); =20 static void rdma_cm_poll_handler(void *opaque) @@ -3995,7 +4014,6 @@ static const QEMUFileHooks rdma_read_hooks =3D { }; =20 static const QEMUFileHooks rdma_write_hooks =3D { - .save_page =3D qemu_rdma_save_page, }; =20 =20 --=20 2.40.1 From nobody Fri May 17 10:13:48 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=1685471291; cv=none; d=zohomail.com; s=zohoarc; b=S+dxS8OAbh5S0usEzJGE+DXuIJ/30uHKRVOvCCrUziATOP5VX78bbfQoErPFCXzOFNBJ36cIkxVjgwtaqvv6IamaD/WfoUO3oWvt+O8ktW2jiXkYS0sEw7KhRHCW7cdabwJVqKv6scyCS6+YarCz6338+Yv47TNsEGnN7mJSo7c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685471291; 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=MXiaJLB0asswiz5Qce7G0O6vlzSxR/Ax4r2WPVp/2WM=; b=AJp9GgjvUvTNr2FEhLJbQEAJyR1E3k14s2c1Xl8b3mzUjIC1/q34a61hJLw+Qtly+hFP/f1PvJ7DNje2C5Ayap1pkNC4nPZ9+uzTDMoR1KBlocecZ4b9Gkx758QSJCVV9n4lg88hyl+WExky30VuK4ARpyDLMhJziUFBONf+Xjs= 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 1685471291529493.85292766583063; Tue, 30 May 2023 11:28:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q442o-0001gD-3w; Tue, 30 May 2023 14:26:06 -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 1q442j-0001b6-NN for qemu-devel@nongnu.org; Tue, 30 May 2023 14:26:01 -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 1q442h-0000oP-K1 for qemu-devel@nongnu.org; Tue, 30 May 2023 14:26:01 -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-513-9uG4xK8mPtepbC6l5E1gbw-1; Tue, 30 May 2023 14:25:57 -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 2E513101A531 for ; Tue, 30 May 2023 18:25:57 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3F7AD17103; Tue, 30 May 2023 18:25:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685471159; 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=MXiaJLB0asswiz5Qce7G0O6vlzSxR/Ax4r2WPVp/2WM=; b=iENXysOr+Wr8MH7QuQm2bfFGAQJr4MQ72HhYuecI23o3fzed+EX3hlzuzHbcNUnlFb7WT6 4aYeaw60de1bWGJxlWi6nJMFGz+KTX2ENqnvs+JE0KcIikwvZmJilgkm7PJypCWVbW11xj DdmNG4gMdaF1eNNIgEhsfLGJ2xuZF3g= X-MC-Unique: 9uG4xK8mPtepbC6l5E1gbw-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Leonardo Bras , Peter Xu , Juan Quintela Subject: [PULL 18/21] qemu-file: Remove QEMUFileHooks Date: Tue, 30 May 2023 20:25:28 +0200 Message-Id: <20230530182531.6371-19-quintela@redhat.com> In-Reply-To: <20230530182531.6371-1-quintela@redhat.com> References: <20230530182531.6371-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.129.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.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1685471293477100015 Content-Type: text/plain; charset="utf-8" The only user was rdma, and its use is gone. Reviewed-by: Peter Xu Signed-off-by: Juan Quintela Message-Id: <20230509120700.78359-8-quintela@redhat.com> --- migration/qemu-file.h | 4 ---- migration/qemu-file.c | 6 ------ migration/rdma.c | 9 --------- 3 files changed, 19 deletions(-) diff --git a/migration/qemu-file.h b/migration/qemu-file.h index c43c410168..c7c832d200 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -36,12 +36,8 @@ #define RAM_CONTROL_ROUND 1 #define RAM_CONTROL_FINISH 3 =20 -typedef struct QEMUFileHooks { -} QEMUFileHooks; - QEMUFile *qemu_file_new_input(QIOChannel *ioc); QEMUFile *qemu_file_new_output(QIOChannel *ioc); -void qemu_file_set_hooks(QEMUFile *f, const QEMUFileHooks *hooks); int qemu_fclose(QEMUFile *f); =20 /* diff --git a/migration/qemu-file.c b/migration/qemu-file.c index a222daeaab..c94b667726 100644 --- a/migration/qemu-file.c +++ b/migration/qemu-file.c @@ -38,7 +38,6 @@ #define MAX_IOV_SIZE MIN_CONST(IOV_MAX, 64) =20 struct QEMUFile { - const QEMUFileHooks *hooks; QIOChannel *ioc; bool is_writable; =20 @@ -147,11 +146,6 @@ QEMUFile *qemu_file_new_input(QIOChannel *ioc) return qemu_file_new_impl(ioc, false); } =20 -void qemu_file_set_hooks(QEMUFile *f, const QEMUFileHooks *hooks) -{ - f->hooks =3D hooks; -} - /* * Get last error for stream f with optional Error* * diff --git a/migration/rdma.c b/migration/rdma.c index b506b86b47..b85259263a 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -4010,13 +4010,6 @@ err: return ret; } =20 -static const QEMUFileHooks rdma_read_hooks =3D { -}; - -static const QEMUFileHooks rdma_write_hooks =3D { -}; - - static void qio_channel_rdma_finalize(Object *obj) { QIOChannelRDMA *rioc =3D QIO_CHANNEL_RDMA(obj); @@ -4075,12 +4068,10 @@ static QEMUFile *qemu_fopen_rdma(RDMAContext *rdma,= const char *mode) rioc->file =3D qemu_file_new_output(QIO_CHANNEL(rioc)); rioc->rdmaout =3D rdma; rioc->rdmain =3D rdma->return_path; - qemu_file_set_hooks(rioc->file, &rdma_write_hooks); } else { rioc->file =3D qemu_file_new_input(QIO_CHANNEL(rioc)); rioc->rdmain =3D rdma; rioc->rdmaout =3D rdma->return_path; - qemu_file_set_hooks(rioc->file, &rdma_read_hooks); } =20 return rioc->file; --=20 2.40.1 From nobody Fri May 17 10:13:48 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=1685471328; cv=none; d=zohomail.com; s=zohoarc; b=BowhgwDsNMg8CXtOW0yZ7HrSb0vXvy3yH7+9WpDW5ccOnDYatQ+79ZO7xCsOy0bS9MgxGCLckqLFcqhWYLWwXNL9iLBkyBJDr0OqLy/aWNX+YcLN5F6zu41TkAZPmdViN8eh6jx3hW3LAJpF5AtBp3mEQrqYJO6+grvAaZljZVo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685471328; 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=wJgii+DxQK6AS54w6B6AqK9RDxgcqJLgYpExZNNhmHc=; b=PYMn6GJjKMKwBQHy0p50Ho3WAczA4NWrcWDH8mPfxYQW0jpDPiJtR3HhjxzaSElER20XRMYz/ccr900ofoUOIGbgD8aHIHuJKsS8OMOZ69mqhiBSKH6jpgzgl2foqoQvfeN3QXy1w1N81ZHt48vLqxT1DE5aNSFcV4Fi2YvWhM8= 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 1685471328892346.75534740564365; Tue, 30 May 2023 11:28:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q442p-0001hL-Cz; Tue, 30 May 2023 14:26:07 -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 1q442l-0001dU-4D for qemu-devel@nongnu.org; Tue, 30 May 2023 14:26:03 -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 1q442j-0000pf-95 for qemu-devel@nongnu.org; Tue, 30 May 2023 14:26:02 -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-280-fQzHDlBWMWukJKeRBZxoZQ-1; Tue, 30 May 2023 14:25:58 -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 6223F101A531 for ; Tue, 30 May 2023 18:25:58 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 73A8417103; Tue, 30 May 2023 18:25:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685471160; 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=wJgii+DxQK6AS54w6B6AqK9RDxgcqJLgYpExZNNhmHc=; b=CRhkwXazcbxMu70peANa+wb2PGKQKwwoEFJVti+nH2jgm/9FlNzaD2TuvxpLIn7a7ez3Cl z9JppQsQa2wXkHIhok9iWN80WorpyeJUzRLUylV9M7jJi2eMkrXkNzwNGJt2EupMu5Lv7q 9YWDOjnfNEwlJUk35tjY1l8AGTXgDeQ= X-MC-Unique: fQzHDlBWMWukJKeRBZxoZQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Leonardo Bras , Peter Xu , Juan Quintela Subject: [PULL 19/21] migration/rdma: Move rdma constants from qemu-file.h to rdma.h Date: Tue, 30 May 2023 20:25:29 +0200 Message-Id: <20230530182531.6371-20-quintela@redhat.com> In-Reply-To: <20230530182531.6371-1-quintela@redhat.com> References: <20230530182531.6371-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: -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.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1685471330205100003 Content-Type: text/plain; charset="utf-8" Reviewed-by: Peter Xu Signed-off-by: Juan Quintela Message-Id: <20230509120700.78359-9-quintela@redhat.com> --- migration/qemu-file.h | 17 ----------------- migration/rdma.h | 16 ++++++++++++++++ migration/ram.c | 2 +- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/migration/qemu-file.h b/migration/qemu-file.h index c7c832d200..83b8fb10de 100644 --- a/migration/qemu-file.h +++ b/migration/qemu-file.h @@ -29,13 +29,6 @@ #include "exec/cpu-common.h" #include "io/channel.h" =20 -/* - * Constants used by ram_control_* hooks - */ -#define RAM_CONTROL_SETUP 0 -#define RAM_CONTROL_ROUND 1 -#define RAM_CONTROL_FINISH 3 - QEMUFile *qemu_file_new_input(QIOChannel *ioc); QEMUFile *qemu_file_new_output(QIOChannel *ioc); int qemu_fclose(QEMUFile *f); @@ -105,16 +98,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 -/* Whenever this is found in the data stream, the flags - * will be passed to ram_control_load_hook in the incoming-migration - * side. This lets before_ram_iterate/after_ram_iterate add - * transport-specific sections to the RAM migration data. - */ -#define RAM_SAVE_FLAG_HOOK 0x80 - -#define RAM_SAVE_CONTROL_NOT_SUPP -1000 -#define RAM_SAVE_CONTROL_DELAYED -2000 - QIOChannel *qemu_file_get_ioc(QEMUFile *file); =20 #endif diff --git a/migration/rdma.h b/migration/rdma.h index 09a16c1e3c..1ff3718a76 100644 --- a/migration/rdma.h +++ b/migration/rdma.h @@ -24,6 +24,22 @@ 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 +/* + * Constants used by rdma return codes + */ +#define RAM_CONTROL_SETUP 0 +#define RAM_CONTROL_ROUND 1 +#define RAM_CONTROL_FINISH 3 + +/* + * Whenever this is found in the data stream, the flags + * will be passed to rdma functions in the incoming-migration + * side. + */ +#define RAM_SAVE_FLAG_HOOK 0x80 + +#define RAM_SAVE_CONTROL_NOT_SUPP -1000 +#define RAM_SAVE_CONTROL_DELAYED -2000 =20 #ifdef CONFIG_RDMA int qemu_rdma_registration_handle(QEMUFile *f); diff --git a/migration/ram.c b/migration/ram.c index 19e5e93de8..83da952823 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -86,7 +86,7 @@ #define RAM_SAVE_FLAG_EOS 0x10 #define RAM_SAVE_FLAG_CONTINUE 0x20 #define RAM_SAVE_FLAG_XBZRLE 0x40 -/* 0x80 is reserved in qemu-file.h for RAM_SAVE_FLAG_HOOK */ +/* 0x80 is reserved in rdma.h for RAM_SAVE_FLAG_HOOK */ #define RAM_SAVE_FLAG_COMPRESS_PAGE 0x100 #define RAM_SAVE_FLAG_MULTIFD_FLUSH 0x200 /* We can't use any flag that is bigger than 0x200 */ --=20 2.40.1 From nobody Fri May 17 10:13:48 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=1685471177; cv=none; d=zohomail.com; s=zohoarc; b=aKvCNxbaRjUIT/W095Eth7IKk9GyB7v0qbWz/FaH2P+q6zm+ccGFN16eopNpVtU+NAs5DEEg72crc+/oB6y29425tFwfUFfy+PqDodlCRASikG+gP7D0skz26QEgKcnw2vQ/js96k/mO03LLtPMv6avJ5jG4MXwm+hgTOM93G54= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685471177; 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=lm1x6px+SXqyY8UbgKGwy0JTnRbU6KWcusYV5Rpx5z8=; b=J/oDUURT3ozmyzLP6yXNBfO2BrbxQKy3sCYGYP7JSsRlu2KpwgPD18jOaLqDZMrgThn0JGRzx1RRtE1rWZUVE/5+nbUMSyoTqdekxOnvhcBA2Tr3uZD1TYNQtK3oRQbwZ0FFAD+VvqkTN1UD/tZv9CCuY1BGadHA+EIwPd6+8NE= 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 1685471177708348.79256247739943; Tue, 30 May 2023 11:26:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q442s-0001iD-2G; Tue, 30 May 2023 14:26:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q442o-0001ga-J4 for qemu-devel@nongnu.org; Tue, 30 May 2023 14:26:06 -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 1q442l-0000t2-Iq for qemu-devel@nongnu.org; Tue, 30 May 2023 14:26:06 -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-106-_ykEDK7uMUCbkN9omjOx2g-1; Tue, 30 May 2023 14:26:00 -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 BA4BF85A5BA for ; Tue, 30 May 2023 18:25:59 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id A7E69420A8; Tue, 30 May 2023 18:25:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685471162; 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=lm1x6px+SXqyY8UbgKGwy0JTnRbU6KWcusYV5Rpx5z8=; b=P+qfQjA3z+s2IJt+cOZAG2ZTb6QHwbbeBTsrA5ATaeiQYc92iFOp219rA5tfJpzferpB6D zQSTCSjMbSmDAdtqo4gST7hLG2QgK5CEtKJcJi8ZVFVjN36XwQ+WwUrl6jwdE1VzmgsJQu NgWNiIirDjHjpjA+B6hCDFLbHniEa9g= X-MC-Unique: _ykEDK7uMUCbkN9omjOx2g-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Leonardo Bras , Peter Xu , Juan Quintela Subject: [PULL 20/21] migration/rdma: Remove qemu_ prefix from exported functions Date: Tue, 30 May 2023 20:25:30 +0200 Message-Id: <20230530182531.6371-21-quintela@redhat.com> In-Reply-To: <20230530182531.6371-1-quintela@redhat.com> References: <20230530182531.6371-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: -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.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1685471179764100007 Content-Type: text/plain; charset="utf-8" Functions are long enough even without this. Reviewed-by: Peter Xu Signed-off-by: Juan Quintela Message-Id: <20230509120700.78359-10-quintela@redhat.com> --- migration/rdma.h | 12 ++++++------ migration/ram.c | 14 +++++++------- migration/rdma.c | 40 +++++++++++++++++++--------------------- migration/trace-events | 28 ++++++++++++++-------------- 4 files changed, 46 insertions(+), 48 deletions(-) diff --git a/migration/rdma.h b/migration/rdma.h index 1ff3718a76..30b15b4466 100644 --- a/migration/rdma.h +++ b/migration/rdma.h @@ -42,19 +42,19 @@ void rdma_start_incoming_migration(const char *host_por= t, Error **errp); #define RAM_SAVE_CONTROL_DELAYED -2000 =20 #ifdef CONFIG_RDMA -int qemu_rdma_registration_handle(QEMUFile *f); -int qemu_rdma_registration_start(QEMUFile *f, uint64_t flags); -int qemu_rdma_registration_stop(QEMUFile *f, uint64_t flags); +int rdma_registration_handle(QEMUFile *f); +int rdma_registration_start(QEMUFile *f, uint64_t flags); +int rdma_registration_stop(QEMUFile *f, uint64_t flags); int rdma_block_notification_handle(QEMUFile *f, const char *name); int rdma_control_save_page(QEMUFile *f, ram_addr_t block_offset, ram_addr_t offset, size_t size); #else static inline -int qemu_rdma_registration_handle(QEMUFile *f) { return 0; } +int rdma_registration_handle(QEMUFile *f) { return 0; } static inline -int qemu_rdma_registration_start(QEMUFile *f, uint64_t flags) { return 0; } +int rdma_registration_start(QEMUFile *f, uint64_t flags) { return 0; } static inline -int qemu_rdma_registration_stop(QEMUFile *f, uint64_t flags) { return 0; } +int rdma_registration_stop(QEMUFile *f, uint64_t flags) { return 0; } static inline int rdma_block_notification_handle(QEMUFile *f, const char *name) { return= 0; } static inline diff --git a/migration/ram.c b/migration/ram.c index 83da952823..87fc504674 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -3013,12 +3013,12 @@ static int ram_save_setup(QEMUFile *f, void *opaque) } } =20 - ret =3D qemu_rdma_registration_start(f, RAM_CONTROL_SETUP); + ret =3D rdma_registration_start(f, RAM_CONTROL_SETUP); if (ret < 0) { qemu_file_set_error(f, ret); } =20 - ret =3D qemu_rdma_registration_stop(f, RAM_CONTROL_SETUP); + ret =3D rdma_registration_stop(f, RAM_CONTROL_SETUP); if (ret < 0) { qemu_file_set_error(f, ret); } @@ -3080,7 +3080,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) /* Read version before ram_list.blocks */ smp_rmb(); =20 - ret =3D qemu_rdma_registration_start(f, RAM_CONTROL_ROUND); + ret =3D rdma_registration_start(f, RAM_CONTROL_ROUND); if (ret < 0) { qemu_file_set_error(f, ret); } @@ -3140,7 +3140,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) * Must occur before EOS (or any QEMUFile operation) * because of RDMA protocol. */ - ret =3D qemu_rdma_registration_stop(f, RAM_CONTROL_ROUND); + ret =3D rdma_registration_stop(f, RAM_CONTROL_ROUND); if (ret < 0) { qemu_file_set_error(f, ret); } @@ -3191,7 +3191,7 @@ static int ram_save_complete(QEMUFile *f, void *opaqu= e) migration_bitmap_sync_precopy(rs, true); } =20 - ret =3D qemu_rdma_registration_start(f, RAM_CONTROL_FINISH); + ret =3D rdma_registration_start(f, RAM_CONTROL_FINISH); if (ret < 0) { qemu_file_set_error(f, ret); } @@ -3217,7 +3217,7 @@ static int ram_save_complete(QEMUFile *f, void *opaqu= e) =20 ram_flush_compressed_data(rs); =20 - int ret =3D qemu_rdma_registration_stop(f, RAM_CONTROL_FINISH); + int ret =3D rdma_registration_stop(f, RAM_CONTROL_FINISH); if (ret < 0) { qemu_file_set_error(f, ret); } @@ -4026,7 +4026,7 @@ static int ram_load_precopy(QEMUFile *f) } break; case RAM_SAVE_FLAG_HOOK: - ret =3D qemu_rdma_registration_handle(f); + ret =3D rdma_registration_handle(f); if (ret < 0) { qemu_file_set_error(f, ret); } diff --git a/migration/rdma.c b/migration/rdma.c index b85259263a..cf0681575d 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -3549,7 +3549,7 @@ static int dest_ram_sort_func(const void *a, const vo= id *b) * * Keep doing this until the source tells us to stop. */ -int qemu_rdma_registration_handle(QEMUFile *f) +int rdma_registration_handle(QEMUFile *f) { RDMAControlHeader reg_resp =3D { .len =3D sizeof(RDMARegisterResult), .type =3D RDMA_CONTROL_REGISTER_RESULT, @@ -3591,7 +3591,7 @@ int qemu_rdma_registration_handle(QEMUFile *f) =20 local =3D &rdma->local_ram_blocks; do { - trace_qemu_rdma_registration_handle_wait(); + trace_rdma_registration_handle_wait(); =20 ret =3D qemu_rdma_exchange_recv(rdma, &head, RDMA_CONTROL_NONE); =20 @@ -3611,9 +3611,9 @@ int qemu_rdma_registration_handle(QEMUFile *f) comp =3D (RDMACompress *) rdma->wr_data[idx].control_curr; network_to_compress(comp); =20 - trace_qemu_rdma_registration_handle_compress(comp->length, - comp->block_idx, - comp->offset); + trace_rdma_registration_handle_compress(comp->length, + comp->block_idx, + comp->offset); if (comp->block_idx >=3D rdma->local_ram_blocks.nb_blocks) { error_report("rdma: 'compress' bad block index %u (vs %d)", (unsigned int)comp->block_idx, @@ -3630,11 +3630,11 @@ int qemu_rdma_registration_handle(QEMUFile *f) break; =20 case RDMA_CONTROL_REGISTER_FINISHED: - trace_qemu_rdma_registration_handle_finished(); + trace_rdma_registration_handle_finished(); goto out; =20 case RDMA_CONTROL_RAM_BLOCKS_REQUEST: - trace_qemu_rdma_registration_handle_ram_blocks(); + trace_rdma_registration_handle_ram_blocks(); =20 /* Sort our local RAM Block list so it's the same as the sourc= e, * we can do this since we've filled in a src_index in the list @@ -3674,7 +3674,7 @@ int qemu_rdma_registration_handle(QEMUFile *f) rdma->dest_blocks[i].length =3D local->block[i].length; =20 dest_block_to_network(&rdma->dest_blocks[i]); - trace_qemu_rdma_registration_handle_ram_blocks_loop( + trace_rdma_registration_handle_ram_blocks_loop( local->block[i].block_name, local->block[i].offset, local->block[i].length, @@ -3696,7 +3696,7 @@ int qemu_rdma_registration_handle(QEMUFile *f) =20 break; case RDMA_CONTROL_REGISTER_REQUEST: - trace_qemu_rdma_registration_handle_register(head.repeat); + trace_rdma_registration_handle_register(head.repeat); =20 reg_resp.repeat =3D head.repeat; registers =3D (RDMARegister *) rdma->wr_data[idx].control_curr; @@ -3710,7 +3710,7 @@ int qemu_rdma_registration_handle(QEMUFile *f) =20 reg_result =3D &results[count]; =20 - trace_qemu_rdma_registration_handle_register_loop(count, + trace_rdma_registration_handle_register_loop(count, reg->current_index, reg->key.current_addr, reg->c= hunks); =20 if (reg->current_index >=3D rdma->local_ram_blocks.nb_bloc= ks) { @@ -3762,8 +3762,7 @@ int qemu_rdma_registration_handle(QEMUFile *f) =20 reg_result->host_addr =3D (uintptr_t)block->local_host_add= r; =20 - trace_qemu_rdma_registration_handle_register_rkey( - reg_result->rke= y); + trace_rdma_registration_handle_register_rkey(reg_result->r= key); =20 result_to_network(reg_result); } @@ -3777,7 +3776,7 @@ int qemu_rdma_registration_handle(QEMUFile *f) } break; case RDMA_CONTROL_UNREGISTER_REQUEST: - trace_qemu_rdma_registration_handle_unregister(head.repeat); + trace_rdma_registration_handle_unregister(head.repeat); unreg_resp.repeat =3D head.repeat; registers =3D (RDMARegister *) rdma->wr_data[idx].control_curr; =20 @@ -3785,7 +3784,7 @@ int qemu_rdma_registration_handle(QEMUFile *f) reg =3D ®isters[count]; network_to_register(reg); =20 - trace_qemu_rdma_registration_handle_unregister_loop(count, + trace_rdma_registration_handle_unregister_loop(count, reg->current_index, reg->key.chunk); =20 block =3D &(rdma->local_ram_blocks.block[reg->current_inde= x]); @@ -3801,8 +3800,7 @@ int qemu_rdma_registration_handle(QEMUFile *f) =20 rdma->total_registrations--; =20 - trace_qemu_rdma_registration_handle_unregister_success( - reg->key.chunk); + trace_rdma_registration_handle_unregister_success(reg->key= .chunk); } =20 ret =3D qemu_rdma_post_send_control(rdma, NULL, &unreg_resp); @@ -3873,7 +3871,7 @@ int rdma_block_notification_handle(QEMUFile *f, const= char *name) return 0; } =20 -int qemu_rdma_registration_start(QEMUFile *f, uint64_t flags) +int rdma_registration_start(QEMUFile *f, uint64_t flags) { QIOChannelRDMA *rioc =3D QIO_CHANNEL_RDMA(qemu_file_get_ioc(f)); RDMAContext *rdma; @@ -3890,7 +3888,7 @@ int qemu_rdma_registration_start(QEMUFile *f, uint64_= t flags) =20 CHECK_ERROR_STATE(); =20 - trace_qemu_rdma_registration_start(flags); + trace_rdma_registration_start(flags); qemu_put_be64(f, RAM_SAVE_FLAG_HOOK); qemu_fflush(f); =20 @@ -3901,7 +3899,7 @@ int qemu_rdma_registration_start(QEMUFile *f, uint64_= t flags) * Inform dest that dynamic registrations are done for now. * First, flush writes, if any. */ -int qemu_rdma_registration_stop(QEMUFile *f, uint64_t flags) +int rdma_registration_stop(QEMUFile *f, uint64_t flags) { QIOChannelRDMA *rioc =3D QIO_CHANNEL_RDMA(qemu_file_get_ioc(f)); RDMAContext *rdma; @@ -3933,7 +3931,7 @@ int qemu_rdma_registration_stop(QEMUFile *f, uint64_t= flags) int reg_result_idx, i, nb_dest_blocks; =20 head.type =3D RDMA_CONTROL_RAM_BLOCKS_REQUEST; - trace_qemu_rdma_registration_stop_ram(); + trace_rdma_registration_stop_ram(); =20 /* * Make sure that we parallelize the pinning on both sides. @@ -3995,7 +3993,7 @@ int qemu_rdma_registration_stop(QEMUFile *f, uint64_t= flags) } } =20 - trace_qemu_rdma_registration_stop(flags); + trace_rdma_registration_stop(flags); =20 head.type =3D RDMA_CONTROL_REGISTER_FINISHED; ret =3D qemu_rdma_exchange_send(rdma, &head, NULL, NULL, NULL, NULL); diff --git a/migration/trace-events b/migration/trace-events index 54ae5653fd..5ad9d9edbe 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -224,20 +224,6 @@ 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" qemu_rdma_advise_mr(const char *name, uint32_t len, uint64_t addr, const c= har *res) "Try to advise block %s prefetch at %" PRIu32 "@0x%" PRIx64 ": %s" -qemu_rdma_registration_handle_compress(int64_t length, int index, int64_t = offset) "Zapping zero chunk: %" PRId64 " bytes, index %d, offset %" PRId64 -qemu_rdma_registration_handle_finished(void) "" -qemu_rdma_registration_handle_ram_blocks(void) "" -qemu_rdma_registration_handle_ram_blocks_loop(const char *name, uint64_t o= ffset, uint64_t length, void *local_host_addr, unsigned int src_index) "%s:= @0x%" PRIx64 "/%" PRIu64 " host:@%p src_index: %u" -qemu_rdma_registration_handle_register(int requests) "%d requests" -qemu_rdma_registration_handle_register_loop(int req, int index, uint64_t a= ddr, uint64_t chunks) "Registration request (%d): index %d, current_addr %"= PRIu64 " chunks: %" PRIu64 -qemu_rdma_registration_handle_register_rkey(int rkey) "0x%x" -qemu_rdma_registration_handle_unregister(int requests) "%d requests" -qemu_rdma_registration_handle_unregister_loop(int count, int index, uint64= _t chunk) "Unregistration request (%d): index %d, chunk %" PRIu64 -qemu_rdma_registration_handle_unregister_success(uint64_t chunk) "%" PRIu64 -qemu_rdma_registration_handle_wait(void) "" -qemu_rdma_registration_start(uint64_t flags) "%" PRIu64 -qemu_rdma_registration_stop(uint64_t flags) "%" PRIu64 -qemu_rdma_registration_stop_ram(void) "" qemu_rdma_resolve_host_trying(const char *host, const char *ip) "Trying %s= =3D> %s" qemu_rdma_signal_unregister_append(uint64_t chunk, int pos) "Appending unr= egister chunk %" PRIu64 " at position %d" qemu_rdma_signal_unregister_already(uint64_t chunk) "Unregister chunk %" P= RIu64 " already in queue" @@ -256,6 +242,20 @@ qemu_rdma_write_one_zero(uint64_t chunk, int len, int = index, int64_t offset) "En rdma_add_block(const char *block_name, int block, uint64_t addr, uint64_t = offset, uint64_t len, uint64_t end, uint64_t bits, int chunks) "Added Block= : '%s':%d, addr: %" PRIu64 ", offset: %" PRIu64 " length: %" PRIu64 " end: = %" PRIu64 " bits %" PRIu64 " chunks %d" rdma_block_notification_handle(const char *name, int index) "%s at %d" rdma_delete_block(void *block, uint64_t addr, uint64_t offset, uint64_t le= n, uint64_t end, uint64_t bits, int chunks) "Deleted Block: %p, addr: %" PR= Iu64 ", offset: %" PRIu64 " length: %" PRIu64 " end: %" PRIu64 " bits %" PR= Iu64 " chunks %d" +rdma_registration_handle_compress(int64_t length, int index, int64_t offse= t) "Zapping zero chunk: %" PRId64 " bytes, index %d, offset %" PRId64 +rdma_registration_handle_finished(void) "" +rdma_registration_handle_ram_blocks(void) "" +rdma_registration_handle_ram_blocks_loop(const char *name, uint64_t offset= , uint64_t length, void *local_host_addr, unsigned int src_index) "%s: @0x%= " PRIx64 "/%" PRIu64 " host:@%p src_index: %u" +rdma_registration_handle_register(int requests) "%d requests" +rdma_registration_handle_register_loop(int req, int index, uint64_t addr, = uint64_t chunks) "Registration request (%d): index %d, current_addr %" PRIu= 64 " chunks: %" PRIu64 +rdma_registration_handle_register_rkey(int rkey) "0x%x" +rdma_registration_handle_unregister(int requests) "%d requests" +rdma_registration_handle_unregister_loop(int count, int index, uint64_t ch= unk) "Unregistration request (%d): index %d, chunk %" PRIu64 +rdma_registration_handle_unregister_success(uint64_t chunk) "%" PRIu64 +rdma_registration_handle_wait(void) "" +rdma_registration_start(uint64_t flags) "%" PRIu64 +rdma_registration_stop(uint64_t flags) "%" PRIu64 +rdma_registration_stop_ram(void) "" rdma_start_incoming_migration(void) "" rdma_start_incoming_migration_after_dest_init(void) "" rdma_start_incoming_migration_after_rdma_listen(void) "" --=20 2.40.1 From nobody Fri May 17 10:13:48 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=1685471313; cv=none; d=zohomail.com; s=zohoarc; b=IQC8m3coNtMvLxsMbWIROZCS/2oLoOJZ/bLUSdXaWt47D7IrCUwMR+le11qrzAIvitqLiLl+lb0T4zECjOrPZ4KegM1VcFvteSgWoFmzwtxtCo07sJkwp9eDEqli0fVai4Bzs3uUhVAHrW3L7gBcdn5nN9uTfd1hCzjbJN+xGEU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685471313; 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=+tx/4HjH10zbER9X9JRjNA48x+P+0ib4/FRHyZB6gfc=; b=JChbcGWperTz/lbjWjYJst0qyLz85NhuCI5E9zwgVc7bCVEC5/bSwtlEJbUtUoYlnnMe+rxkeJZpzp3My6L77lpcKC9ZMFZXgwbsOk6/JEbJbPCqkp3l8XQW9UL0O8h0jI2ozhevMfHZiPlEmedcPXn/lD+2AlL0//uiz+pWrgU= 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 1685471313001255.2205502153812; Tue, 30 May 2023 11:28:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q442o-0001gu-QG; Tue, 30 May 2023 14:26:06 -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 1q442m-0001fk-OM for qemu-devel@nongnu.org; Tue, 30 May 2023 14:26:04 -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 1q442l-0000sq-At for qemu-devel@nongnu.org; Tue, 30 May 2023 14:26:04 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.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-317-EWIsWKq2N4-pqhJfq0ncbg-1; Tue, 30 May 2023 14:26:01 -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 ECEF729AA386 for ; Tue, 30 May 2023 18:26:00 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A5A017103; Tue, 30 May 2023 18:25:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685471162; 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=+tx/4HjH10zbER9X9JRjNA48x+P+0ib4/FRHyZB6gfc=; b=EHwEDSm8u+Tx8ROMSU0gvbs6AkaSUyLcjNh7Ao10Hs5AzRZaMRk47PFBUateu46OoEp7VY dgRvOKIvvZt+wAh2FLxR6pCKrk2U2xzcJV3xWRnq/ZXm4QcvwX3sbk0gjJjBELTrI+dxpb R/ZR6vbsP/LoVExOoFwHz09oMEDt3L0= X-MC-Unique: EWIsWKq2N4-pqhJfq0ncbg-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Leonardo Bras , Peter Xu , Juan Quintela Subject: [PULL 21/21] migration/rdma: Check sooner if we are in postcopy for save_page() Date: Tue, 30 May 2023 20:25:31 +0200 Message-Id: <20230530182531.6371-22-quintela@redhat.com> In-Reply-To: <20230530182531.6371-1-quintela@redhat.com> References: <20230530182531.6371-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.129.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.167, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: 1685471313521100001 Content-Type: text/plain; charset="utf-8" Reviewed-by: Peter Xu Signed-off-by: Juan Quintela Message-Id: <20230509120700.78359-11-quintela@redhat.com> --- migration/rdma.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/migration/rdma.c b/migration/rdma.c index cf0681575d..f912a31b45 100644 --- a/migration/rdma.c +++ b/migration/rdma.c @@ -3250,10 +3250,6 @@ static int qemu_rdma_save_page(QEMUFile *f, ram_addr= _t block_offset, RDMAContext *rdma; int ret; =20 - if (migration_in_postcopy()) { - return RAM_SAVE_CONTROL_NOT_SUPP; - } - RCU_READ_LOCK_GUARD(); rdma =3D qatomic_rcu_read(&rioc->rdmaout); =20 @@ -3322,7 +3318,7 @@ err: int rdma_control_save_page(QEMUFile *f, ram_addr_t block_offset, ram_addr_t offset, size_t size) { - if (!migrate_rdma()) { + if (!migrate_rdma() || migration_in_postcopy()) { return RAM_SAVE_CONTROL_NOT_SUPP; } =20 --=20 2.40.1