From nobody Mon May 20 13:24:58 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=1685447865; cv=none; d=zohomail.com; s=zohoarc; b=BQ57CYb2yuiDWRq7hk1+cpYly3eFKnfkWEkJWi7hNan7TOrljb4XPy8ITxgfy04GcAYeXqp8ccHqwwPhomLNG7aXGghneo+dd+QDHMtqG7H1OSm9HgH6KS+2syZoYVmiibHq1RW5tD0I0ikhudOrPa9d0WE/xuSuK8fEerokUbY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685447865; 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=GErGIa4mPj3I6hf9ga7rRtLgOzGOxsMurrD6AIWzM/mYbijHlspA7vR+e5OInfkxT8RPmZdRDHWOzJOQqvPLTQd35fDMuQcwu6NtB197PDJCi/V3iG8T5EONrGc90kZlBK1387HVs2nGv2Y9Uil3+0vBixrL0dR+60q0z2BP6e0= 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 1685447865779870.3514249234559; Tue, 30 May 2023 04:57:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q3xw6-00055J-60; Tue, 30 May 2023 07:54:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q3xw4-00050T-Ok for qemu-devel@nongnu.org; Tue, 30 May 2023 07:54: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 1q3xw2-000085-0B for qemu-devel@nongnu.org; Tue, 30 May 2023 07:54:44 -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-383-rFhsRH_fOeKKnUp29h6rnA-1; Tue, 30 May 2023 07:54:33 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2F1DC1C0150D; Tue, 30 May 2023 11:54:33 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id B4D2540C6EC4; Tue, 30 May 2023 11:54:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685447679; 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=MsyRpgbrDIqofNcrCPtzod+hCTt8OcOrMjlaYjgwrrhs5As+q+TksX+0oxvVwaboEoEcYq 4Z1T7PdQgf+uuRz7HvIfcSCqt+B8MYP2qHHJHNmv4cPTQF0GBNdRCWSb8IOwL1vnmfRc2t 9f1iNJfzNQ7NubCCP4LIV9u9QHwc5qg= X-MC-Unique: rFhsRH_fOeKKnUp29h6rnA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Juan Quintela , Paolo Bonzini , Peter Xu , Leonardo Bras , Vladimir Sementsov-Ogievskiy Subject: [PULL 01/21] runstate: add runstate_get() Date: Tue, 30 May 2023 13:54:09 +0200 Message-Id: <20230530115429.1998-2-quintela@redhat.com> In-Reply-To: <20230530115429.1998-1-quintela@redhat.com> References: <20230530115429.1998-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=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: 1685447867300100003 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 Mon May 20 13:24:58 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=1685447851; cv=none; d=zohomail.com; s=zohoarc; b=ReTcwB1vPpjk7J1mkPDnOWIdtL5M2fzjIheo6Mnng8yMI/jFdyuJxaBA/6ZMxgjKA6WMDRYiQYA56ByuZNCIyKjXSC31Micmlcxqm8KXVpMte2vkZLVVA3sNtESN1YbN+8Fo2tTZ4wsq11ll3HQYiMT+em2h3HMC9lhG11QVRTo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685447851; 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=KbZZYV6HRr2FOoxf5CJ9uTL4ta0q/hpFp8pAdI4/ptlt27RrutK7LJPc4ZWJC0oDG+epPsz8rNDKaKISHWBEXNZ/7JJCa9gaGWpSuqokZP0idK7EAZruN2GBMJbfTznlYRP1fSblZJLb0dvzYeL5k08LxUwaRy1d9DIyXKgLQrc= 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 1685447851565645.2443456760077; Tue, 30 May 2023 04:57:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q3xwE-00059s-10; Tue, 30 May 2023 07:54: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 1q3xw2-0004wS-3l for qemu-devel@nongnu.org; Tue, 30 May 2023 07:54:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q3xvx-00007b-DO for qemu-devel@nongnu.org; Tue, 30 May 2023 07:54:38 -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-640-_KPJCKj2Pmu-kGjRabEWAQ-1; Tue, 30 May 2023 07:54:35 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ADBD53C0C886; Tue, 30 May 2023 11:54:34 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 768F840C6EC4; Tue, 30 May 2023 11:54:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685447676; 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=e7gkB+Zr5UqSQIjXpWUQYYPom/AXt7QakW7cuVDFXUctsR8xbAydVyyFgz0OCt9D82xCDv VAucYz32SUgdDPZJJ6MhvEbFyXQCVhZpDEop7YAaMhwXxTZvGtJoHClq52bFSw9Bdd5IsL jbgTslTDEYrr/a+oMX6ziL0nLCqe8/4= X-MC-Unique: _KPJCKj2Pmu-kGjRabEWAQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Juan Quintela , Paolo Bonzini , Peter Xu , Leonardo Bras , Vladimir Sementsov-Ogievskiy Subject: [PULL 02/21] migration: never fail in global_state_store() Date: Tue, 30 May 2023 13:54:10 +0200 Message-Id: <20230530115429.1998-3-quintela@redhat.com> In-Reply-To: <20230530115429.1998-1-quintela@redhat.com> References: <20230530115429.1998-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=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: 1685447853424100001 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 Mon May 20 13:24:58 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=1685447774; cv=none; d=zohomail.com; s=zohoarc; b=Jd+9KSRnbXy45+tqTzBjhX6nf/ZLGVNy2nKzttcvInQFsdPi3fPXcwBv0AKtY5YFczJdzjz9fcjMNU35V4CRPUrbgovVAVCN9hNh9DfELf9WWjrEt2sGc1g4XTsGs4PU/jsOMvMkRlWftjOHugvI4gBHTh3AVB6Vy4alHcJCB44= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685447774; 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=nVRhNz63NFUpyW2EOyFCGpqSRB/azwi/LyfJMwCy7jMH72casgVxVNYobdpFWNfVisgWnvSlqMGR2EUCIVtUXGdpJwfhN7il3PhnsraDG7H7tXILfrf1/FCO9N2gd8g/4nIL+/KgsQljJt5jxQ6LbHO74ONKeGGULJGlbu4U258= 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 1685447774738453.0143565534007; Tue, 30 May 2023 04:56:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q3xw4-0004xI-5D; Tue, 30 May 2023 07:54:44 -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 1q3xw3-0004x0-Fu for qemu-devel@nongnu.org; Tue, 30 May 2023 07:54:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q3xw1-000081-Sm for qemu-devel@nongnu.org; Tue, 30 May 2023 07:54: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-315-dUm1BA_gPRSLarvldQhxtQ-1; Tue, 30 May 2023 07:54:36 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 16A25381D1EC; Tue, 30 May 2023 11:54:36 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0168E40C6EC4; Tue, 30 May 2023 11:54:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685447679; 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=JSKFyHioB7PdxnFUYSXg9EC3tdOPN3u74R6sGl74LpEn7MsLZvPjShiHyWMrMqK4HsNWwM YQ6I/3yDdTiVe9LjhZh4kv7nNo94UylcMXfWwkxLzG9U9C0xHbngmPdZ5VKqk6PvoDaDud gGQS6/vO23URIF1F21eNh5olgpIfeQk= X-MC-Unique: dUm1BA_gPRSLarvldQhxtQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Juan Quintela , Paolo Bonzini , Peter Xu , Leonardo Bras , Vladimir Sementsov-Ogievskiy Subject: [PULL 03/21] runstate: drop unused runstate_store() Date: Tue, 30 May 2023 13:54:11 +0200 Message-Id: <20230530115429.1998-4-quintela@redhat.com> In-Reply-To: <20230530115429.1998-1-quintela@redhat.com> References: <20230530115429.1998-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=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: 1685447775215100003 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 Mon May 20 13:24:58 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=1685447816; cv=none; d=zohomail.com; s=zohoarc; b=c3puC0pWpJOg4M/4ptn6nzJ6Fp+mR5a7nZlKVa7gpYwWVTfSS9siJ3m5AioO+/x8DXCsQ8USg85g7et/k/rKPiPO+waim55IGIkO1wspSu5wGiK2mTjFZkruO9kAo7tpd5CupumcsRiqtt1qtOGzsh8LzbWdxw7708ClVk+9qsw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685447816; 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=VbY3+O/Bxv6wkyJSCQHI9bW2nDIENTGNutJ+qhsAafazKHO9AmqbJAExj4LwfJ4XZvCPWwhjuxawBkjscmOjvvQ1oOc5JpIfC4GjlZbS37no428YHrYFvjLylectZ8H18zKCjL3ppOCyK3ErXQUdPZtq5wrWfaWc8SbcshR0+eo= 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 1685447816415762.6370237951687; Tue, 30 May 2023 04:56:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q3xw5-00052E-AC; Tue, 30 May 2023 07:54:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q3xw3-0004x3-KN for qemu-devel@nongnu.org; Tue, 30 May 2023 07:54:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q3xw1-00008C-Vw for qemu-devel@nongnu.org; Tue, 30 May 2023 07:54: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-614-F_tCMbPNMaCGU3KugtBgGQ-1; Tue, 30 May 2023 07:54:38 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 93F9685A5A8; Tue, 30 May 2023 11:54:38 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C3E240C6EC4; Tue, 30 May 2023 11:54:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685447680; 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=gkOTh2PfwMG4F5odpdb02mdPFAV0kS3QQvc6iS/7nkQiAqc7wmgkrhIZeLujLLilykNl02 Soxd+OMCJakMb3xgSFMxhcvDa+AS0hYXCssxZaW7FCq+C4PTSGxTQBRyImQT5U9l6z49oe AhhUJfyRppfK6RsjgcZoEfsP6h23vBo= X-MC-Unique: F_tCMbPNMaCGU3KugtBgGQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Juan Quintela , Paolo Bonzini , Peter Xu , Leonardo Bras , Vladimir Sementsov-Ogievskiy Subject: [PULL 04/21] migration: switch from .vm_was_running to .vm_old_state Date: Tue, 30 May 2023 13:54:12 +0200 Message-Id: <20230530115429.1998-5-quintela@redhat.com> In-Reply-To: <20230530115429.1998-1-quintela@redhat.com> References: <20230530115429.1998-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=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: 1685447817193100001 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 Mon May 20 13:24:59 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=1685447865; cv=none; d=zohomail.com; s=zohoarc; b=FPWvul548ygzbhXlNFqsDjQbJCa6FgUv4/DUamoMfivkY9ul3fpEZRFToPoPDhDBvCrIX1e7zl8/gP4v2AolForyTD4yWLa1rnVaTfQoOkay19eVjaemDcS46nLswS6mLhKjkJFscQ+Ox2vlk70nbH0QLlP88rxgkBN+p/meIio= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685447865; 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=YFB7v2whxHD4lieMeuWtJbwk/IHZqldHgH4alX4R/qHdP0cW6GotyYVy8ypy2XMDj2MViV07Yeycp54UHKw1cs4DMSpjyLsh47vH7zzQOEsPDKXopKdx/vWhzWTlaPL8AGTB0YBl7S5I4/a8czK08cM2qwYeJvhUkEhQovci4SQ= 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 1685447865951301.4563302873587; Tue, 30 May 2023 04:57:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q3xw6-00056N-UO; Tue, 30 May 2023 07:54:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q3xw5-000526-4Y for qemu-devel@nongnu.org; Tue, 30 May 2023 07:54:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q3xw2-00008W-KF for qemu-devel@nongnu.org; Tue, 30 May 2023 07:54:44 -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-664-pQBDCMfdP16W5cexz0mdtw-1; Tue, 30 May 2023 07:54:40 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1C234101A52C; Tue, 30 May 2023 11:54:40 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id DAE4E40C6EC4; Tue, 30 May 2023 11:54:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685447681; 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=SF6t91cUXn0BgYPwvL2TbdakrBnAEUw6xGZUTyYVgC7c9ndLJPhKxDFzTTgrtdtpiP5nEm A+/PM0dbY7TEsADmG7M7asOy8ogI/hsrAK4n/WBQvu4iQ9WOww436Ts90eoLzznZha81xr +NenspCn2Vc233DSeFqajoInKGudEWQ= X-MC-Unique: pQBDCMfdP16W5cexz0mdtw-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Juan Quintela , Paolo Bonzini , Peter Xu , Leonardo Bras , Vladimir Sementsov-Ogievskiy Subject: [PULL 05/21] migration: restore vmstate on migration failure Date: Tue, 30 May 2023 13:54:13 +0200 Message-Id: <20230530115429.1998-6-quintela@redhat.com> In-Reply-To: <20230530115429.1998-1-quintela@redhat.com> References: <20230530115429.1998-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=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: 1685447866237100001 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 Mon May 20 13:24:59 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=1685447701; cv=none; d=zohomail.com; s=zohoarc; b=OMdDz+N9+VU9gvm/fkxmheP+CkUfPKHDAW/4RWMbsWSFYmU6QjCnDTSprABhjMvOpe0f4W1jXpL0QeiCK2wcb+8s0LAvHWm9f3CJ/nLVTUFCbVSnoo5GkXimgAGx8mHwb1lQn1iuR9tV85UraJV5clljLDtofqQp2j+++TnhN70= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685447701; 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=f0NduDF9BVb4bVf0MLMb4Xs2tVd6hPNyNQdNEkT4hRMJNOzWxiNwLzTaPrw6u69f+TWbHkxT6xk+OF1Al/vCUf36BnyhGBeAw0pHup8nMcS3HKp32PlaYE1BRdznmSY9DZnAHhDOHH+NfSeyQ2O5x4sfX4nveAIHMPc3RrZvO5g= 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 1685447701462531.0958023177155; Tue, 30 May 2023 04:55:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q3xw7-00057y-Li; Tue, 30 May 2023 07:54:47 -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 1q3xw6-00055E-1P for qemu-devel@nongnu.org; Tue, 30 May 2023 07:54: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 1q3xw3-00008l-MC for qemu-devel@nongnu.org; Tue, 30 May 2023 07:54: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-591-JkAstht7PQe0Ivl_cGWQGA-1; Tue, 30 May 2023 07:54:41 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 763EB811E78 for ; Tue, 30 May 2023 11:54:41 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 635C440C6EC4; Tue, 30 May 2023 11:54:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685447683; 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=JfcD7UKoUEAWXL49xxHVwr2wnmCWK1lzQR+8Xea9jp7FtbZ99Y7zY/U4L6VdYbReVWHQW9 1MEINMWOWGSnQnUpfnPvaa53t7Aqu4DdYzojGgcZ5Byxb0SDhhOFvA2EqffQtQAmh5dYOC dVBIn0O9s6XD6jE7IqXNAjil2zf3DfI= X-MC-Unique: JkAstht7PQe0Ivl_cGWQGA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Juan Quintela , Paolo Bonzini , Peter Xu , Leonardo Bras Subject: [PULL 06/21] migration: Don't abuse qemu_file transferred for RDMA Date: Tue, 30 May 2023 13:54:14 +0200 Message-Id: <20230530115429.1998-7-quintela@redhat.com> In-Reply-To: <20230530115429.1998-1-quintela@redhat.com> References: <20230530115429.1998-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=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: 1685447702932100001 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 Mon May 20 13:24:59 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=1685447834; cv=none; d=zohomail.com; s=zohoarc; b=iCQ4F/Dz5H1jaNMm6OxqtUyFxlb6Ik+8HvYR7ZkpQwRuAkiX7zMINHmb8zb07dPnU3CztnbTb8LqB3n+AyURWZs3KcnWTNifjGeop1SUx+uNGhjIw15howFEB5iYs4DCtCATMXz7UZ6knJ0woOQ4+oQrAtQIHYWdtrwHI1IXioc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685447834; 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=kiHm7nzCatPH0gdU4wE64uI+XUO8XJXaylpnfagcr+MPj1On4yhpy6E3JtUXs2sGbelsDw6085Qq4QFzji3fMeE5pCH6V3afMLGfJUpMLCNBiG2/xChpunDAuifcbFGtMwwVoz0i2Rq2GIlVhg5ge9KuJTjFf0a0zqS15tBo23E= 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 1685447834683120.71886952189095; Tue, 30 May 2023 04:57:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q3xw8-00058o-UQ; Tue, 30 May 2023 07:54:49 -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 1q3xw7-00057X-BM for qemu-devel@nongnu.org; Tue, 30 May 2023 07:54:47 -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 1q3xw4-00009C-Vk for qemu-devel@nongnu.org; Tue, 30 May 2023 07:54:47 -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-626-L7XMConjMESZDLX9jYfCXw-1; Tue, 30 May 2023 07:54:42 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AD524101A53A for ; Tue, 30 May 2023 11:54:42 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id BDC4540C6EC4; Tue, 30 May 2023 11:54:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685447684; 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=XOgEnhg+oKBs9/V1JXGV8xAad06HChVTtTaHAuIUc6xgrhmkUxBbJ9RMI4Nh2qzyxq6ZBT p2Zq2Y0xs2m9amM4zXgqRGlangEdc2tquMxbZerVSLgo7aX3MoCn4m1gaI4v20gzy/uwVr CY+PMv866u2yJmgjvo7p22X7DRABwpk= X-MC-Unique: L7XMConjMESZDLX9jYfCXw-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Juan Quintela , Paolo Bonzini , Peter Xu , Leonardo Bras Subject: [PULL 07/21] migration/RDMA: It is accounting for zero/normal pages in two places Date: Tue, 30 May 2023 13:54:15 +0200 Message-Id: <20230530115429.1998-8-quintela@redhat.com> In-Reply-To: <20230530115429.1998-1-quintela@redhat.com> References: <20230530115429.1998-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=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: 1685447835927100003 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 Mon May 20 13:24:59 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=1685447839; cv=none; d=zohomail.com; s=zohoarc; b=hCkY7+wMCFCdrZEa8fbYszODbBPH8kQW2H7f16XRMjg0CxT67dAR7X+0993RsQ1G9ZFUMhaEo+g+9uB9bH4DHeHqWcz8JPn94UUPd7pOv5Vwv4HQMGxWj8jZGWmTGUPKzdy667y2t0KEjzNS5XrfVDPeLqpHjuisMGYk8WEOZ6Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685447839; 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=HwxXG+HyFRNtbYaEwqEAt7PbUkMZUp8dNAuGDIkPDjX+ee9YqFowqzFpNC+DXy2oLaw/3RE2xjYPDfYNU5u0vs/irzERRRYvFYVnR6PHDGz4ECsDnfHjAI0Cba0rr16mo96GQLyQ6l8rraywmXQksdevEj0HtnnVdTlyLBLBnRU= 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 1685447839415372.0708372429824; Tue, 30 May 2023 04:57:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q3xwE-0005DP-QJ; Tue, 30 May 2023 07:54: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 1q3xw8-000591-TL for qemu-devel@nongnu.org; Tue, 30 May 2023 07:54: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 1q3xw7-00009f-B9 for qemu-devel@nongnu.org; Tue, 30 May 2023 07:54: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-136-LuzGI3PUOmOPrB2-QyElGg-1; Tue, 30 May 2023 07:54:44 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E3AFD2A5957B for ; Tue, 30 May 2023 11:54:43 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id F377A40C6EC4; Tue, 30 May 2023 11:54:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685447685; 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=WU/yOseYw84hEQpUtxC2Jtta95ZMd647qQycTnpBDpqhr1p/OwEjK8MdYRm8jcskWb4Nyv kwMyXIzmWAANhgfM6/B2M/wpGB1GaQPltbeWJMSIU82+fuq0JdX2r79jBvYVhCiwVsB8ac CU+eT5TOxTfQ95TaJ7hofLuywCCx0S0= X-MC-Unique: LuzGI3PUOmOPrB2-QyElGg-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Juan Quintela , Paolo Bonzini , Peter Xu , Leonardo Bras Subject: [PULL 08/21] migration/rdma: Remove QEMUFile parameter when not used Date: Tue, 30 May 2023 13:54:16 +0200 Message-Id: <20230530115429.1998-9-quintela@redhat.com> In-Reply-To: <20230530115429.1998-1-quintela@redhat.com> References: <20230530115429.1998-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=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: 1685447841238100005 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 Mon May 20 13:24:59 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=1685447839; cv=none; d=zohomail.com; s=zohoarc; b=GDO4HSKlbsW4gMIpfQIyQwU1wCrVqwd4vRMbcfKbCRaxZeCZK8RzQAoyUkfVEL403RDQJwjF1tlDoQJGmW9LOmAebbHHkcC+hkqS9F9CvW1ZETxYE0jaH5uHO1UCQH66cStnIulxl9SLdKPTIngn6X9JSzEMAEVn0nXzAd0Y6w0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685447839; 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=gec4QWBD8Isompju7ZaT3VV4NCB+ABcoBqjP7KcvKsENCvyJP1dx1hNrxy7jfPpA9PA6j2q3itSlbmM5qDxoAgUMjk1DnHkkf/b7FaXSAds4yenywZT03GyjKjUJDP/ETFmlhv9UisMJ9K8s6JkrenGuG7UYEj+a2Fq74/+2m7g= 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 1685447839194633.840693652469; Tue, 30 May 2023 04:57:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q3xwE-0005DJ-Fc; Tue, 30 May 2023 07:54: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 1q3xw8-00058k-MT for qemu-devel@nongnu.org; Tue, 30 May 2023 07:54: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 1q3xw7-00009x-BO for qemu-devel@nongnu.org; Tue, 30 May 2023 07:54: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-593-w7h19nBxM96gSE17Xbx_EA-1; Tue, 30 May 2023 07:54:45 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 260BA8032E4 for ; Tue, 30 May 2023 11:54:45 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 36BBC40C6EC4; Tue, 30 May 2023 11:54:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685447686; 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=J9SOnxVshf52AwVrj3qOv2v/rFqr6ouiOchXBfeFo4001kGC4HR3goeP2u6dsqtTUjbXCz f61auxysol7TxoJJxeQ4p98HYPNkrO247x0BxdZBHRJdwORlVxdLkd9k2mvXc4Rnb++UL7 jZ1K+nfiq6avM4rVQGhyphbCc5mPxho= X-MC-Unique: w7h19nBxM96gSE17Xbx_EA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Juan Quintela , Paolo Bonzini , Peter Xu , Leonardo Bras Subject: [PULL 09/21] migration/rdma: Don't use imaginary transfers Date: Tue, 30 May 2023 13:54:17 +0200 Message-Id: <20230530115429.1998-10-quintela@redhat.com> In-Reply-To: <20230530115429.1998-1-quintela@redhat.com> References: <20230530115429.1998-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=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: 1685447841121100001 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 Mon May 20 13:24:59 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=1685447796; cv=none; d=zohomail.com; s=zohoarc; b=fBvzJK4ArPExYRS7488bc1q+/7ChObet4x4mx1drqFEUvIh8dFDaj4Bi2T/6YSro54oofVImDg4Srd7f45PKiRCbygAbfjboH76RiCn3A4yyr/5MgJZxysoGY+BbFgjZkyCIfCRYj0bH57RAvJPZdca030nWO1IsDG102/VfDIQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685447796; 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=MD2L3/XJ9uA8gCXsg9mGYXZtrKHavcWVo4lL6/u4OToOIIBsoT3NZMGapBdZYWkpgi5iMlD/Iwu/g2QUpi+/e5eqSKEsWtbUYndIMSGOGvFddXK4Nmv3TFHKWj6HWWXGJr2xJHot1L18NQeJjMnhbF7XsNElQCgRhS9rO208glw= 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 1685447796609101.66221535217016; Tue, 30 May 2023 04:56:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q3xwH-0005IW-TU; Tue, 30 May 2023 07:54:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q3xwB-00059K-Th for qemu-devel@nongnu.org; Tue, 30 May 2023 07:54:53 -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 1q3xwA-0000Al-Hj for qemu-devel@nongnu.org; Tue, 30 May 2023 07:54:51 -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-659-YsGwwyajN8qerjbUz63YZg-1; Tue, 30 May 2023 07:54:46 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5DA2C101A52C for ; Tue, 30 May 2023 11:54:46 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6C62540C6EC4; Tue, 30 May 2023 11:54:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685447690; 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=XSNkpNzy7/8jio3WMoF+UsdAz26SNPgtLtimqysc4WItuU1oi/febnZm1azFJ+Y/dD7Des x6Ntz8J1X+5vDJ/W9UIxGzvXXvGG+S9x0GOVBgFtCE7XxjVZ3NA9yTKjwt2ceWrFgSAhC7 L/LWYqLvqMOyHNmlx10J6aPYtH4QnoI= X-MC-Unique: YsGwwyajN8qerjbUz63YZg-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Juan Quintela , Paolo Bonzini , Peter Xu , Leonardo Bras Subject: [PULL 10/21] migration: Remove unused qemu_file_credit_transfer() Date: Tue, 30 May 2023 13:54:18 +0200 Message-Id: <20230530115429.1998-11-quintela@redhat.com> In-Reply-To: <20230530115429.1998-1-quintela@redhat.com> References: <20230530115429.1998-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=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: 1685447797477100003 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 Mon May 20 13:24:59 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=1685447734; cv=none; d=zohomail.com; s=zohoarc; b=jyDN1bvmKiMCy6a1HCqd7LW2IRYGsVNK629WYohH/4YVpPLMHBSX7ZagqQEBPreDObkZjmskpYLwr4RYHqMcdnWmH0zSMQw4qaEVD1IYYW0F5t62PiHOlyakr+ZF4ETKpGAf6POPJGL38AmvNTxMtd0XZurtUywKdObWtyUljyI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685447734; 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=ErMgXUNt85Km6gYf3cFRetaqYhEQnndighFrkqdrwdBgeLl9nfoungLUJTjgorhWEGhzGJUov0Mmx1ZuRiE2ETqXArdnRsVc+iQcymag7zbxoOF6mb/JixwrXCNKC6eS3f4UC42NDgq0PI/Ay0j//A/ZFF/V+LYz+hRVdN48AbM= 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 168544773474418.321709008721996; Tue, 30 May 2023 04:55:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q3xwF-0005FA-Dc; Tue, 30 May 2023 07:54: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 1q3xwD-00059T-Mt for qemu-devel@nongnu.org; Tue, 30 May 2023 07:54: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 1q3xwC-0000B5-2t for qemu-devel@nongnu.org; Tue, 30 May 2023 07:54:53 -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-358-VnvJUhoRNR-h7svxpJDn1Q-1; Tue, 30 May 2023 07:54:48 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B85762A5957B for ; Tue, 30 May 2023 11:54:47 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id A598840C6EC4; Tue, 30 May 2023 11:54:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685447691; 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=hPqWuAwOQ0cPKmPk3D7LkuN2H6wt5RMfDGjzfnNy5Jx5KuRRFAN3wwTJnhzokmrLPi4evY eV4Ig87UCvqAcPBmz+PycZfVmBhPeQz61/flhFzwB6eeVUfaHHg5ivHgYL+dUUj+PIjuKK O7Sot3h04UipXIYqqCk+uoMuEu7TqMo= X-MC-Unique: VnvJUhoRNR-h7svxpJDn1Q-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Juan Quintela , Paolo Bonzini , Peter Xu , Leonardo Bras Subject: [PULL 11/21] migration/rdma: Simplify the function that saves a page Date: Tue, 30 May 2023 13:54:19 +0200 Message-Id: <20230530115429.1998-12-quintela@redhat.com> In-Reply-To: <20230530115429.1998-1-quintela@redhat.com> References: <20230530115429.1998-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=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: 1685447736848100002 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 Mon May 20 13:24:59 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=1685447874; cv=none; d=zohomail.com; s=zohoarc; b=HCXuTL3L5lBVXQ18xFWHQh2deEEPnUqOxuzRXeOYRnFV/WG6vgD37dcwjMgHQgTxL9yGB7ftn9u6pSOXyAOdcG5X3fJ+kpNc1RHH28FYJnrOjwrfPxRfbAkKkzToPwnB+jl45tK6Qb79brehl0irfMy3Ueg0EMJ3XDA2j+CODSU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685447874; 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=WL4jP4npGrCc7F/Pty/hJ5cVPBAuKvEFm8ftmn4hjFwaLHcu+rmpKNM9pzZeaSEC+H5s+VW0jw9zZvbYUasirOTPwnbfQ4UWEf6SrunbMlsy7AjNKwxAe7pDiWxlOwP7+RIkvy1aatoeG22a7mN6dS8k4UJyzKpZL0BADTlZ7C4= 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 1685447873997841.2736502972309; Tue, 30 May 2023 04:57:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q3xwZ-0005ka-Rs; Tue, 30 May 2023 07:55:15 -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 1q3xwC-00059L-BC for qemu-devel@nongnu.org; Tue, 30 May 2023 07:54: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 1q3xwA-0000Ap-UI for qemu-devel@nongnu.org; Tue, 30 May 2023 07:54:52 -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-408-PkJNvZLRNuGR4lkEdrIQkA-1; Tue, 30 May 2023 07:54:49 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EEE553C0C88A for ; Tue, 30 May 2023 11:54:48 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0BD1740C6EC4; Tue, 30 May 2023 11:54:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685447690; 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=UrSmkopdfkw33b1ZFpo1zHtA63tpaneSlj0vCSt7CqAg+vq2r+GzQDtCgwd0CBAzKlDiAe FnVJx5SQqH2VlM4HQfA/eDrLF6p/XegBZOtGUuDxmHcc6Hmrveo3gTAn7hybiNpqqf9TIA DHBLoM2wwn1zliWW8INe7zlhJxQqlN8= X-MC-Unique: PkJNvZLRNuGR4lkEdrIQkA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Juan Quintela , Paolo Bonzini , Peter Xu , Leonardo Bras Subject: [PULL 12/21] migration: Create migrate_rdma() Date: Tue, 30 May 2023 13:54:20 +0200 Message-Id: <20230530115429.1998-13-quintela@redhat.com> In-Reply-To: <20230530115429.1998-1-quintela@redhat.com> References: <20230530115429.1998-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=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: 1685447875647100002 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 Mon May 20 13:24:59 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=1685447804; cv=none; d=zohomail.com; s=zohoarc; b=A4pkqfbuFalYA9g5SQr0qMbxHwwcuT6qngsxrszXAtUsuzzKNU1QV6oIqDs0t3DlcX6q5+HHe8UD3DHeBuc9eehEXpt/mhy4EazIm7qlqa2m92DenBop1LLdtUybbw8NyAxYcMVjEE7T0AacyDX+mq/FcbF3kheW+YzEZR8XGPg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685447804; 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=AGMbmY7nc2oOK81LDjzRDgGlj4kg/S+QnGaNisdhTh4=; b=EP5oWtIM3Pn6lD3gHhko+eP/A+AK5lAZgD+CmdLIohuGyDASNtQ+QY/ENiiIAdoWxqUs4JCFAG0j8GmAY3nkVIF9BAPbOaAukCSmU1UY17a8nO4BTrPFFpebs4pkqeL1ysT7u68k8b0r1p6+vX4H7+0nKlLrf3AJbAkP7X3zrQE= 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 1685447804725980.995639868013; Tue, 30 May 2023 04:56:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q3xx9-0006PP-Qh; Tue, 30 May 2023 07:55:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q3xwF-0005Ez-8R for qemu-devel@nongnu.org; Tue, 30 May 2023 07:54:55 -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 1q3xwD-0000Ba-Iv for qemu-devel@nongnu.org; Tue, 30 May 2023 07:54:54 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-9-lze8MPDLNcCGYJc2kI1o5w-1; Tue, 30 May 2023 07:54:50 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2FE02101A53A for ; Tue, 30 May 2023 11:54:50 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 403C440C6EC4; Tue, 30 May 2023 11:54:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685447693; 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=AGMbmY7nc2oOK81LDjzRDgGlj4kg/S+QnGaNisdhTh4=; b=KlR/Rha74n37ncXcPkSCijt1lAinBF9uFtvt8awx7JPNHU2Xl7nkfcJ9I69fLIr0LivCDE goDrRA31b8+wID+24um28bp+sW5Ka2f9GIJUdJYZR/n9zW7nPDOo+8OOfY2jy5Tai4PRvE XLaleZt28//DXoMBObQqsv4UriXWud0= X-MC-Unique: lze8MPDLNcCGYJc2kI1o5w-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Juan Quintela , Paolo Bonzini , Peter Xu , Leonardo Bras Subject: [PULL 13/21] migration/rdma: Unfold ram_control_before_iterate() Date: Tue, 30 May 2023 13:54:21 +0200 Message-Id: <20230530115429.1998-14-quintela@redhat.com> In-Reply-To: <20230530115429.1998-1-quintela@redhat.com> References: <20230530115429.1998-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=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: 1685447805105100001 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 | 6 ++++++ migration/qemu-file.c | 13 +------------ migration/ram.c | 16 +++++++++++++--- migration/rdma.c | 6 ++---- 5 files changed, 22 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..901c829c8b 100644 --- a/migration/rdma.h +++ b/migration/rdma.h @@ -22,4 +22,10 @@ void rdma_start_outgoing_migration(void *opaque, const c= har *host_port, =20 void rdma_start_incoming_migration(const char *host_port, Error **errp); =20 + +#ifdef CONFIG_RDMA +int qemu_rdma_registration_start(QEMUFile *f, uint64_t flags); +#else +int qemu_rdma_registration_start(QEMUFile *f, uint64_t flags) { return 0; } +#endif #endif 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 Mon May 20 13:24:59 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=1685447779; cv=none; d=zohomail.com; s=zohoarc; b=Gbbi8vPJ4nbkJVLSDDkI42XhYO8CHPq38SWc2hKIoRINeEs7giwY5/Z936G7lrShW96n5jqFQylODqxAzGTt4qnwOJuwPgqrOXtvf9JQbIzisWEzvYpJX/TAwKcXZHOVax4wHay7Xu5AqyJyHYGCQgQMyCBFzI59vHYSCTzAnQ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685447779; 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=r5uk81lSDjCEGUjgTHdC1Dbw+cttHFX1rc0Sx2hIOtk=; b=RAhA84CwpvdNFUVgD/X2WiTOGvcilm5oyjt2akhQ0eb/i5a8H3r04WjS4tVV9ExB6LkgXcSkkqvVQg7chPcC+b4T8xCYJYBm+bBl8YyEX5VbNTtzG/ldH+XYzih1FXzxkjVbgnR+rzA56Bm9gYeaD1kt+09FsJZg7AnvvqdsHfo= 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 168544777950045.71171259945572; Tue, 30 May 2023 04:56:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q3xwJ-0005JZ-GZ; Tue, 30 May 2023 07:54: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 1q3xwG-0005I6-Od for qemu-devel@nongnu.org; Tue, 30 May 2023 07:54:56 -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 1q3xwE-0000CB-LG for qemu-devel@nongnu.org; Tue, 30 May 2023 07:54:56 -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-257-98I9JHyIP3SoN5thZtAfgw-1; Tue, 30 May 2023 07:54:52 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 86C45381D1EC for ; Tue, 30 May 2023 11:54:51 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 75A3240C6EC4; Tue, 30 May 2023 11:54:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685447694; 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=r5uk81lSDjCEGUjgTHdC1Dbw+cttHFX1rc0Sx2hIOtk=; b=BzziB7omnDsSUGQnnEz84sQEXjgmz7hmLAtMRnwxPnRB+e44UAJ9gAKrXhwYRPtjgi7FWn hxGSxQ3bsPd1YSOrebrQuHP1skakTXDUF9YGzb+zaZIzaB3qxvHfacm8zvvuYrOV2CKjCx OGIpc385kBguqpG8d9uijACUi7sXbOQ= X-MC-Unique: 98I9JHyIP3SoN5thZtAfgw-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Juan Quintela , Paolo Bonzini , Peter Xu , Leonardo Bras Subject: [PULL 14/21] migration/rdma: Unfold ram_control_after_iterate() Date: Tue, 30 May 2023 13:54:22 +0200 Message-Id: <20230530115429.1998-15-quintela@redhat.com> In-Reply-To: <20230530115429.1998-1-quintela@redhat.com> References: <20230530115429.1998-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=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: 1685447781369100005 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 | 2 ++ migration/qemu-file.c | 12 ------------ migration/ram.c | 17 ++++++++++++++--- migration/rdma.c | 6 ++---- 5 files changed, 18 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 901c829c8b..a16a8d8bc6 100644 --- a/migration/rdma.h +++ b/migration/rdma.h @@ -25,7 +25,9 @@ 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 int qemu_rdma_registration_start(QEMUFile *f, uint64_t flags) { return 0; } +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 Mon May 20 13:24:59 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=1685447880; cv=none; d=zohomail.com; s=zohoarc; b=nrWPgavGilc11pA2ab525Hv4BeVIIwHn9HOPQ1hkwtZRK6ZTm99kWDenLCgiFewoYjcgWOVPXl/imsYxhAOGg/Mct5TcHXwe00LBzel5uqEIkql27PJsAuogFO8qEy1IiQYIySPrqWBZpyFDIMhcz/HLohLML/C6p9D6LKGF1u4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685447880; 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=Ng3vjBb5/CEJuy+uXUzWwwonNJCH2FVzMLFyhqLXMFI=; b=S8RfjjvyZ7EZDmLs5foEnnMJ3i3XZ7W//Oa4SxaR6x8C4Q84rxWJumwyR9vJf3H0IJDQXQE8ze0vnggD++qJmLY6hEeAp9poviOuARXqyQaZK0uTpof3DdP5RM8Gq9jxMsfFAvgeALH9YIQddJ+fS5B7fTfPVpsX2COZRAjioMk= 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 1685447880760931.887806564074; Tue, 30 May 2023 04:58:00 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q3xwI-0005Ie-BQ; Tue, 30 May 2023 07:54:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q3xwG-0005I3-Ki for qemu-devel@nongnu.org; Tue, 30 May 2023 07:54:56 -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 1q3xwF-0000CS-11 for qemu-devel@nongnu.org; Tue, 30 May 2023 07:54:56 -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-617-uIlTdqoCMFSuicHvk0pySw-1; Tue, 30 May 2023 07:54:53 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BE0053C0C884 for ; Tue, 30 May 2023 11:54:52 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE51240C6EC4; Tue, 30 May 2023 11:54:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685447694; 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=Ng3vjBb5/CEJuy+uXUzWwwonNJCH2FVzMLFyhqLXMFI=; b=fQaKzW3hjXK3kq+Pu83Vvew5Y/9+EEXTETHoGW26pb5tnd9GCon0jHTWoYFr/JjqRCXvqB g2aag1bLNaDbWD6oYKHjONK58C9+AbQoX30yTwkdIyJGh/iGy/3Npa+IWFmPuyaxcrFFKS fct+y74+AiYG5sacWdslMgyB1T4eMVY= X-MC-Unique: uIlTdqoCMFSuicHvk0pySw-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Juan Quintela , Paolo Bonzini , Peter Xu , Leonardo Bras Subject: [PULL 15/21] migration/rdma: Remove all uses of RAM_CONTROL_HOOK Date: Tue, 30 May 2023 13:54:23 +0200 Message-Id: <20230530115429.1998-16-quintela@redhat.com> In-Reply-To: <20230530115429.1998-1-quintela@redhat.com> References: <20230530115429.1998-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=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: 1685447882297100003 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 | 2 ++ migration/ram.c | 5 ++++- migration/rdma.c | 9 +++++---- 4 files changed, 11 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 a16a8d8bc6..8d0253047c 100644 --- a/migration/rdma.h +++ b/migration/rdma.h @@ -24,9 +24,11 @@ void rdma_start_incoming_migration(const char *host_port= , 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 +int qemu_rdma_registration_handle(QEMUFile *f) { return 0; } int qemu_rdma_registration_start(QEMUFile *f, uint64_t flags) { return 0; } int qemu_rdma_registration_stop(QEMUFile *f, uint64_t flags) { return 0; } #endif 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 Mon May 20 13:24:59 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=1685447780; cv=none; d=zohomail.com; s=zohoarc; b=mEEmYN3EpUwJxKOSwMwIuw/W1VAGqQ8mHJz1woj9MQDlAquxikbueXg0s3tWXqHXXjR4+Ktp3LWTwcwfXz5OGCMHqrPLrijswd7gmK+O/f9DlpvwjJN4NXIn3QI4CJa+aIU5wU2jaNlqJzA56U/k+B0p84cT29wPt+LctAw1maM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685447780; 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=KHU2pwRIK+H1KAi7c3egaHy74lp1q/zA2nVx8xZ4Zs0=; b=k824fUgSdAwX0NTj/t4q9ynQJdh1DaJGVt5GpMYbwGU0ARZfyVwJVIymdigTa5hPY0qp5qR/kDv1yhYd9iMnU48DuJVkbDGqWzfEKGoG+ZXmQUpRBTt5eQtIUDS8Tm4J7fNce8YWAyGfDrWgz0lViL5pgT9+dXqAz3D+J+03DxA= 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 1685447780779857.9602436991365; Tue, 30 May 2023 04:56:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q3xwb-0005nK-HT; Tue, 30 May 2023 07:55:19 -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 1q3xwI-0005J2-Vh for qemu-devel@nongnu.org; Tue, 30 May 2023 07:54: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 1q3xwG-0000D1-SK for qemu-devel@nongnu.org; Tue, 30 May 2023 07:54:58 -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-183-fHuZdCSFMxmAXx5fd2VJJQ-1; Tue, 30 May 2023 07:54:55 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B1A8A2A5957C for ; Tue, 30 May 2023 11:54:54 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 11DC440C6EC4; Tue, 30 May 2023 11:54:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685447696; 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=KHU2pwRIK+H1KAi7c3egaHy74lp1q/zA2nVx8xZ4Zs0=; b=GL1UkcurRqtzR4jucBdSHe5fVnY44311jLG22qIDY97SDtH/hx+ix08WqJx85DnnBm4JZZ M7YwxtWbBqnm9QyEQlFJ8DkvyAFTBcnuLw4bc0WnqmJWESnACTDmLAMq7nNqg73H0rQsH8 ai8NzOXCcBbhTcixj/JakyfM+OlpZ5I= X-MC-Unique: fHuZdCSFMxmAXx5fd2VJJQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Juan Quintela , Paolo Bonzini , Peter Xu , Leonardo Bras Subject: [PULL 16/21] migration/rdma: Unfold hook_ram_load() Date: Tue, 30 May 2023 13:54:24 +0200 Message-Id: <20230530115429.1998-17-quintela@redhat.com> In-Reply-To: <20230530115429.1998-1-quintela@redhat.com> References: <20230530115429.1998-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=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: 1685447782799100007 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 | 2 ++ migration/qemu-file.c | 10 ---------- migration/ram.c | 6 ++++-- migration/rdma.c | 29 +++++++++-------------------- 5 files changed, 15 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 8d0253047c..1266a90e07 100644 --- a/migration/rdma.h +++ b/migration/rdma.h @@ -27,9 +27,11 @@ 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 int qemu_rdma_registration_handle(QEMUFile *f) { return 0; } int qemu_rdma_registration_start(QEMUFile *f, uint64_t flags) { return 0; } int qemu_rdma_registration_stop(QEMUFile *f, uint64_t flags) { return 0; } +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 Mon May 20 13:24:59 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=1685447861; cv=none; d=zohomail.com; s=zohoarc; b=ULAql3zwIoZPmghaDpnPAvrM5Oj8rnBLEO/RHPnfsh9v9r9vHyqySp/2CMpBZ2rGlH3n6aE1BQbpEOp7VXNGtWzizxrrXxz8KNM7bzwlZsGtfB5Fs48ySrHPvP4ExaEyGgByJ4tQWR3xjBThHQx4WpPSykBKSQjItLN2q0i7He0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685447861; 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=3COZ0BARqMVhPm/JFHKioiR3HeLEi0KRIOAOdGoo4n8=; b=RwAsBuv/6daGvWSAUV6NtXdpVybneKXJw7BKV3MYYHGoKpg5wpr1AbIymuzrJNe1mcYCHbD7G7RVzCZWYZjlf/tyB6bzT0NsdMFh5vJmrBcfXYYaiRb18Lu6xXSMjycRIBFD8KCCA7SFxgu08bZoLCcUxiI8uX2AyHBNC+I5uRo= 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 1685447861940952.2716564538956; Tue, 30 May 2023 04:57:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q3xwx-00061g-5F; Tue, 30 May 2023 07:55:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q3xwK-0005Jf-3R for qemu-devel@nongnu.org; Tue, 30 May 2023 07:55:00 -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 1q3xwI-0000DQ-9x for qemu-devel@nongnu.org; Tue, 30 May 2023 07:54:59 -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-115-0dvjL2Z3PyG9c6ivFxfyAg-1; Tue, 30 May 2023 07:54:56 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 15A01381D1E8 for ; Tue, 30 May 2023 11:54:56 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 04E8040C6EC4; Tue, 30 May 2023 11:54:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685447697; 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=3COZ0BARqMVhPm/JFHKioiR3HeLEi0KRIOAOdGoo4n8=; b=LJc9AS8Hm/eGHCCJFxXYId44rPonOJdNOW4P2OzyIIQmvf94as0w1h0l8yFFJCdD7gNsEY g5l2g2TAzaafFS8k3uS5uSwQjZX1KZ93NT+8NP5jOrx0iX+2G+V0N2LwCWC0Tm/ajqdajk PHimAassKLAZDqltmKn5cQDJ3d1bSrk= X-MC-Unique: 0dvjL2Z3PyG9c6ivFxfyAg-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Juan Quintela , Paolo Bonzini , Peter Xu , Leonardo Bras Subject: [PULL 17/21] migration/rdma: Create rdma_control_save_page() Date: Tue, 30 May 2023 13:54:25 +0200 Message-Id: <20230530115429.1998-18-quintela@redhat.com> In-Reply-To: <20230530115429.1998-1-quintela@redhat.com> References: <20230530115429.1998-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=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: 1685447862226100001 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 | 6 ++++++ migration/qemu-file.c | 20 -------------------- migration/ram.c | 4 ++-- migration/rdma.c | 20 +++++++++++++++++++- 5 files changed, 27 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 1266a90e07..4674dceb4a 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,10 +30,14 @@ 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 int qemu_rdma_registration_handle(QEMUFile *f) { return 0; } int qemu_rdma_registration_start(QEMUFile *f, uint64_t flags) { return 0; } int qemu_rdma_registration_stop(QEMUFile *f, uint64_t flags) { return 0; } int rdma_block_notification_handle(QEMUFile *f, const char *name) { return= 0; } +int rdma_control_save_page(QEMUFile *f, ram_addr_t block_offset, + ram_addr_t offset, size_t size) { return false;= } #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 Mon May 20 13:24:59 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=1685447740; cv=none; d=zohomail.com; s=zohoarc; b=QVgWPWc5XV79x0dnbibwp3EZkBHGVKKo+giaNz3VjIajggv/CQsB7zazPnyyl/niCu8ivJmSM+NpehKs33X4oRK35fPubDI/cJ7PKGkAcDAu9iWcW8nms82sBr8mdTYqPBN+gAABwptsLECZTORELmejCp34p6DLBZlTmigLv1w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685447740; 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=fmGxdg6el16iI0AR3a09fH99FR+jnyyp7hn4o2hGMA+IScs6CQoG3xO5qHSWPDZi8ttT8Y2+Kz4mLeo980O3jaTDgLs/CfP53DUA7wlS5SaR/bfmcM7iADGIrRDU6TgCgYEHDc/c2T7lMsgrwy5AgOLSZ+UPPF5MW4D4i/EMtYY= 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 1685447740409875.8040151040891; Tue, 30 May 2023 04:55:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q3xwN-0005Nw-E8; Tue, 30 May 2023 07:55:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q3xwL-0005MV-8B for qemu-devel@nongnu.org; Tue, 30 May 2023 07:55: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 1q3xwJ-0000Dp-HB for qemu-devel@nongnu.org; Tue, 30 May 2023 07:55:00 -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-70-EVkwuCAuN2Wplt67wvJ1gA-1; Tue, 30 May 2023 07:54:57 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4D307101A52C for ; Tue, 30 May 2023 11:54:57 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5D14240C6EC4; Tue, 30 May 2023 11:54:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685447698; 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=XVcfmDZB83JNavjpmo95HB+gu8as2XA4OOlxxFLTX0p0d+6ygaZFOXZQvAvId0J+bhgYRc DQHuZZ7S4Nn0KPiuxAiNy1hjLdaiBJZebA0GMZekWRWHR7tJ28vBssFVJ1IriwJ6GEiHBt 0gyhmUoJwhyge3RpcE3MM/8nOLvfrbk= X-MC-Unique: EVkwuCAuN2Wplt67wvJ1gA-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Juan Quintela , Paolo Bonzini , Peter Xu , Leonardo Bras Subject: [PULL 18/21] qemu-file: Remove QEMUFileHooks Date: Tue, 30 May 2023 13:54:26 +0200 Message-Id: <20230530115429.1998-19-quintela@redhat.com> In-Reply-To: <20230530115429.1998-1-quintela@redhat.com> References: <20230530115429.1998-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=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: 1685447741196100003 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 Mon May 20 13:24:59 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=1685447792; cv=none; d=zohomail.com; s=zohoarc; b=e9WMxmKwrywfDQDto/9fLqVqwbDXBjDc8uxeldui7u98FzmMAZPi9siKATBXnVgEh7552EXkuZ0+5bfWasEcxSfFvlL3BZKLGFUmVHTPNtTr7YAMPIHdrasLf+Xqxuj3OIUu3hPM34+vtjzaoBBALyM5SExo+c4KaD3+T7edaAs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685447792; 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=f139DM+9pbfHifBb8kYIO9/p+hoVkHut/i5oEINmrcs=; b=D775F2JhqWmLHJI12tYeEiP3BsBfDF9k7P33kQzTcp1RlblGC32+IyMTCZfrukbhx9yq6whHnX0F2JjwhaD0LoD5lz+XlO6zy/Uw+Gr4cjhbuc2QmlxVxRnF6Nyt0Dam2uOUAcehB4p26FPgs+3OXSTKfxypHs7cngT98bu5678= 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 1685447792957449.52945782585357; Tue, 30 May 2023 04:56:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q3xxB-0006UF-FB; Tue, 30 May 2023 07:55: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 1q3xwP-0005Oo-Bo for qemu-devel@nongnu.org; Tue, 30 May 2023 07:55:05 -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 1q3xwN-0000El-Lj for qemu-devel@nongnu.org; Tue, 30 May 2023 07:55:05 -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-267-fzadRZxkOhyxS-ibijzGpg-1; Tue, 30 May 2023 07:54:58 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 85A9E800969 for ; Tue, 30 May 2023 11:54:58 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 94BA640C6EC4; Tue, 30 May 2023 11:54:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685447702; 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=f139DM+9pbfHifBb8kYIO9/p+hoVkHut/i5oEINmrcs=; b=gRThTfy5864vJVMoa+uZdyZBb+adjm/A2RbgK1OL0evj/3Omy3y+DQ0EjPCJdCwYwrd+Jh LotsPcPUir5TeOylFAP4OtJMPVozkRToJUMuW/ZzMIiKc6uUCkVBRGGXA9yX53TgUJ0SFU 8yvxYvj0Egzfqy1LKodR+J4KrGvbqBs= X-MC-Unique: fzadRZxkOhyxS-ibijzGpg-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Juan Quintela , Paolo Bonzini , Peter Xu , Leonardo Bras Subject: [PULL 19/21] migration/rdma: Move rdma constants from qemu-file.h to rdma.h Date: Tue, 30 May 2023 13:54:27 +0200 Message-Id: <20230530115429.1998-20-quintela@redhat.com> In-Reply-To: <20230530115429.1998-1-quintela@redhat.com> References: <20230530115429.1998-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=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: 1685447793300100001 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 4674dceb4a..9f3ace0900 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 Mon May 20 13:24:59 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=1685447774; cv=none; d=zohomail.com; s=zohoarc; b=dAnuihvluinsxEXHOTGMRGuu00cloKSIDlx5cGKvDLuoPULl7C2MJgGsg70yTrAPQO14ZQv6heqo/lokM1JAvedZQpFCT51jGa7tUsfTBPIluzsenYc4bMvH+2qQ4AT3n5SA5rlbAzGgWO80p20XkU6NexoaOmInvZj3DsmZiTA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685447774; 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=ori2HeU5LwHHa0GmaDNf7uNrmJVs2fJ9kjhRycn77n4=; b=NlOHX9HSPHNdBJoKkqJGVdPuYXDRvyASzREoKWfcOXnEF3YqS8WuV1djnxz+HohxfbdJMUOOp9ezYe9wVFDUdpHZlyMmrOEpCjcVZERtedKPYTPcwz/eJhbJwIHB10INTQ5XPt1qdTyt+kEKPELSyLqOFZzqdUnOu07wq0yb9/E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685447774261577.9546836321109; Tue, 30 May 2023 04:56:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q3xxG-0006tj-Mk; Tue, 30 May 2023 07:55:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q3xwV-0005Yz-28 for qemu-devel@nongnu.org; Tue, 30 May 2023 07:55:11 -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 1q3xwO-0000Er-11 for qemu-devel@nongnu.org; Tue, 30 May 2023 07:55:06 -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-8-sqf_dDnRPReti0_aIvOarQ-1; Tue, 30 May 2023 07:55:01 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E0499381D1EC for ; Tue, 30 May 2023 11:54:59 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE3F440C6EC4; Tue, 30 May 2023 11:54:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685447702; 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=ori2HeU5LwHHa0GmaDNf7uNrmJVs2fJ9kjhRycn77n4=; b=b0xnm31TCi/95nyhHejkQN1QXsCffbXLVCbvgo6xK4aA1Hj1ZKRgA27krniaIZf+L35mbB GWijsuKgpgqlU4VUJWTvBdBAYJl8hjvFvxajkoXhDESGn1DQ4TmIH1T+hT8whoEzmGCk3t 0JjNcdygejEtZaHZySRbXOJjQXQZj0M= X-MC-Unique: sqf_dDnRPReti0_aIvOarQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Juan Quintela , Paolo Bonzini , Peter Xu , Leonardo Bras Subject: [PULL 20/21] migration/rdma: Remove qemu_ prefix from exported functions Date: Tue, 30 May 2023 13:54:28 +0200 Message-Id: <20230530115429.1998-21-quintela@redhat.com> In-Reply-To: <20230530115429.1998-1-quintela@redhat.com> References: <20230530115429.1998-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=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: 1685447775370100005 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 9f3ace0900..9b28736902 100644 --- a/migration/rdma.h +++ b/migration/rdma.h @@ -42,16 +42,16 @@ 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 -int qemu_rdma_registration_handle(QEMUFile *f) { return 0; } -int qemu_rdma_registration_start(QEMUFile *f, uint64_t flags) { return 0; } -int qemu_rdma_registration_stop(QEMUFile *f, uint64_t flags) { return 0; } +int rdma_registration_handle(QEMUFile *f) { return 0; } +int rdma_registration_start(QEMUFile *f, uint64_t flags) { return 0; } +int rdma_registration_stop(QEMUFile *f, uint64_t flags) { return 0; } int rdma_block_notification_handle(QEMUFile *f, const char *name) { return= 0; } int rdma_control_save_page(QEMUFile *f, ram_addr_t block_offset, ram_addr_t offset, size_t size) { return false;= } 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 Mon May 20 13:24:59 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=1685447868; cv=none; d=zohomail.com; s=zohoarc; b=gs33elHoPAMD8lMqfgoHDUdkezFBDoExz136KipdPjRgFOeAq3/NvfUIhbPDECTntDzup3e1/0na6p30zLQ6qrhjS/6hplV3+FOC695aP0fzZxNGSKQ5kvUQbxN5vGcS0D3KaFkFILRfO8RpNYRRUTF8L5ZUOreyBC1D124dDJ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685447868; 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=fFzLGNM9NFTDiqfYbdVh1BfLlQy0BgEqM6XQYtYWR9ywMvxaLd3dwyonQgv+U+IVfRD+/9KNGz+j6VQs2DwUzMxRnpyXhPZe4c1IuWRO0t2tQjuY/L7xbDIA8t3E544n4YDIKvLVBKTBbcl5bJQ6A/uJw8B6PG2IliJXgOiR+NI= 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 1685447868812942.9218706522865; Tue, 30 May 2023 04:57:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q3xwW-0005Sm-0j; Tue, 30 May 2023 07:55:12 -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 1q3xwO-0005Oh-Qw for qemu-devel@nongnu.org; Tue, 30 May 2023 07:55: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 1q3xwN-0000Eu-CU for qemu-devel@nongnu.org; Tue, 30 May 2023 07:55:04 -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-563-VMZKlYQrNv2isGE5zru2oQ-1; Tue, 30 May 2023 07:55:01 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 21C3985A5BA for ; Tue, 30 May 2023 11:55:01 +0000 (UTC) Received: from secure.mitica (unknown [10.39.195.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3391540C6EC4; Tue, 30 May 2023 11:55:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685447702; 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=bHCFGS0MvAWm3SeR9fPI2+Ye0dGu4wX2waex3hW0kHbtSmINb9zx6pcuLgQ7RvrHxOISKi VEO45BhjRUl1fSYB/tRsYghW5Tvee35oHFNn0JzdJ/i0c4P7zYsb0wKkYSUM0FtILfmrj7 4SmGpT4W7iAA0hYnb/Axou0rA9+u8os= X-MC-Unique: VMZKlYQrNv2isGE5zru2oQ-1 From: Juan Quintela To: qemu-devel@nongnu.org Cc: Juan Quintela , Paolo Bonzini , Peter Xu , Leonardo Bras Subject: [PULL 21/21] migration/rdma: Check sooner if we are in postcopy for save_page() Date: Tue, 30 May 2023 13:54:29 +0200 Message-Id: <20230530115429.1998-22-quintela@redhat.com> In-Reply-To: <20230530115429.1998-1-quintela@redhat.com> References: <20230530115429.1998-1-quintela@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=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: 1685447869270100009 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