From nobody Sat Nov 23 20:50:44 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=1730304114; cv=none; d=zohomail.com; s=zohoarc; b=br/oCTFnJJK0wrtH4msykGnExDsTTBwJHarSRliPtxQmqqA+yWkYhXlIpkLU/xhTCg4dMjH9AJbwttU2niuc1k7AtKC1tm0BgpwDSNyTm63UAAFEcKpbhzqr+T1Pf5WwZLVpbSadA+u72ZjtLCxkepNncOz1CDlr5tw4ptKj5V0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730304114; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=E4oURxNBXBkPRiq9WGmdIdu1uQxGl0jyPp2LNYV0ZBA=; b=k8RmIp3Xd+zcr9ut4dWJbVIYpf75VzpOFIPtdh746Ri1giQUmmPPeunf7or3Mh1/gWz6c0QP1o47cSGyCH6gjzk2LDhnUZC9S8ap33KRjki4TLEGQvuipOfCF5gmvORnjHRBgTu6Zr/+FwYdt1+YmHB26o1cXm/75wi800bDgfg= 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 173030411464497.3996678478868; Wed, 30 Oct 2024 09:01:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t6B5L-0003pO-7T; Wed, 30 Oct 2024 11:58: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 1t6B5H-0003o4-V5 for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:58:12 -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 1t6B5F-0007q3-5R for qemu-devel@nongnu.org; Wed, 30 Oct 2024 11:58:10 -0400 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-80-z0MOC_x0PCuQ8WrnbrbbtQ-1; Wed, 30 Oct 2024 11:58:06 -0400 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-6cbe4cb4252so63056d6.2 for ; Wed, 30 Oct 2024 08:58:06 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-114-190.cpe.net.cable.rogers.com. [99.254.114.190]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6d19c57c1ffsm22802276d6.89.2024.10.30.08.58.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 08:58:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730303888; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=E4oURxNBXBkPRiq9WGmdIdu1uQxGl0jyPp2LNYV0ZBA=; b=MGFpXA/ppNqFK/Ak0BJXOCEB9BdfN7I4UrAkmNV7LpPwjiqgyNLrs0bAHODMpb3SYf/ivq Yt7MfQ4dMtj9Al95CFBDlaieVmhFlQ9bS+OdWuzxSrROmtnjs99vOkrm2LXka2AOCywloJ pd/SIU2uB9IGNal1mMyzYpFH5apeXNw= X-MC-Unique: z0MOC_x0PCuQ8WrnbrbbtQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730303885; x=1730908685; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E4oURxNBXBkPRiq9WGmdIdu1uQxGl0jyPp2LNYV0ZBA=; b=Zpwd2+waQ4k4xwn2SgqC12jcOYrsEyfYgVsHUQkEls8htcJdZm4pLiPMqB4ngzu3NR L6VDjO7TWMCytXuzpayj7hJZWfUmZtw1edUh+JcStk1Qpsxr/1iqDvkBWU7EgdzhsBDK 8J5MXAGHXa+LqG9GcG6T889V8p2KHMxrByw2xw847/HTYoNOFnT5N5oekISQLLZqVHMQ 5van2Pjymoq9QJ2asIZsMWR13Wo3+Lremrsz+XmiGer2weEM3aM99mTMTuwizdEzP44D SPNTwl7m9FpjWt1x1SHKjbyNHtAtjQbu+TGlPGXo7mv5/fYzll729qZCIZeLqduB6r0c TSEQ== X-Gm-Message-State: AOJu0YxVihVX/Bn1qLibe1mekBI2jsdLbGGpLHXgUXMpBraEybmh8rbV 4GBBVtioXYtcINdH9YoEQ1RpxO3x5S+yg7nl4oMJMopu7ExmLYvKqz2xn0qKkOEjpYopcWTTEtC PyUqO3YzKHDESLsYyAg6AH+h6cBivoJlfxLtaqVQyhHFv0+Cc0NhduDhCVNHZjaRTxR2uDsyCk/ 2Bud92F5AyTfePVg1udciRsoL9ku42hnbzSw== X-Received: by 2002:a05:6214:4305:b0:6cb:ff04:655f with SMTP id 6a1803df08f44-6d1856eea23mr190399926d6.22.1730303884224; Wed, 30 Oct 2024 08:58:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEGDI1RbKNPifftg1STXFl8wa3OuriAQLyEGLq+Q7HiiTe19QARdxgOPAhrUgbnviWCNKwR2w== X-Received: by 2002:a05:6214:4305:b0:6cb:ff04:655f with SMTP id 6a1803df08f44-6d1856eea23mr190399036d6.22.1730303882365; Wed, 30 Oct 2024 08:58:02 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Peter Maydell , Peter Xu , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PULL 15/18] migration: Drop migration_is_setup_or_active() Date: Wed, 30 Oct 2024 11:57:31 -0400 Message-ID: <20241030155734.2141398-16-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241030155734.2141398-1-peterx@redhat.com> References: <20241030155734.2141398-1-peterx@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.366, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1730304115469116600 This helper is mostly the same as migration_is_running(), except that one has COLO reported as true, the other has CANCELLING reported as true. Per my past years experience on the state changes, none of them should matter. To make it slightly safer, report both COLO || CANCELLING to be true in migration_is_running(), then drop the other one. We kept the 1st only because the name is simpler, and clear enough. Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Fabiano Rosas Link: https://lore.kernel.org/r/20241024213056.1395400-5-peterx@redhat.com Signed-off-by: Peter Xu --- include/migration/misc.h | 4 ++-- hw/vfio/common.c | 2 +- migration/migration.c | 35 +++-------------------------------- migration/ram.c | 5 ++--- net/vhost-vdpa.c | 3 +-- 5 files changed, 9 insertions(+), 40 deletions(-) diff --git a/include/migration/misc.h b/include/migration/misc.h index e8490e3af5..86ef160f19 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -52,11 +52,12 @@ void dump_vmstate_json_to_file(FILE *out_fp); /* migration/migration.c */ void migration_object_init(void); void migration_shutdown(void); + bool migration_is_idle(void); bool migration_is_active(void); bool migration_is_device(void); +bool migration_is_running(void); bool migration_thread_is_self(void); -bool migration_is_setup_or_active(void); =20 typedef enum MigrationEventType { MIG_EVENT_PRECOPY_SETUP, @@ -95,7 +96,6 @@ void migration_add_notifier_mode(NotifierWithReturn *noti= fy, MigrationNotifyFunc func, MigMode mode); =20 void migration_remove_notifier(NotifierWithReturn *notify); -bool migration_is_running(void); void migration_file_set_error(int ret, Error *err); =20 /* True if incoming migration entered POSTCOPY_INCOMING_DISCARD */ diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 36d0cf6585..dcef44fe55 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -149,7 +149,7 @@ bool vfio_viommu_preset(VFIODevice *vbasedev) =20 static void vfio_set_migration_error(int ret) { - if (migration_is_setup_or_active()) { + if (migration_is_running()) { migration_file_set_error(ret, NULL); } } diff --git a/migration/migration.c b/migration/migration.c index de80d64dda..cab65ba8db 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1113,33 +1113,6 @@ void migrate_send_rp_resume_ack(MigrationIncomingSta= te *mis, uint32_t value) migrate_send_rp_message(mis, MIG_RP_MSG_RESUME_ACK, sizeof(buf), &buf); } =20 -/* - * Return true if we're already in the middle of a migration - * (i.e. any of the active or setup states) - */ -bool migration_is_setup_or_active(void) -{ - MigrationState *s =3D current_migration; - - switch (s->state) { - case MIGRATION_STATUS_ACTIVE: - case MIGRATION_STATUS_POSTCOPY_ACTIVE: - case MIGRATION_STATUS_POSTCOPY_PAUSED: - case MIGRATION_STATUS_POSTCOPY_RECOVER_SETUP: - case MIGRATION_STATUS_POSTCOPY_RECOVER: - case MIGRATION_STATUS_SETUP: - case MIGRATION_STATUS_PRE_SWITCHOVER: - case MIGRATION_STATUS_DEVICE: - case MIGRATION_STATUS_WAIT_UNPLUG: - case MIGRATION_STATUS_COLO: - return true; - - default: - return false; - - } -} - bool migration_is_running(void) { MigrationState *s =3D current_migration; @@ -1155,11 +1128,10 @@ bool migration_is_running(void) case MIGRATION_STATUS_DEVICE: case MIGRATION_STATUS_WAIT_UNPLUG: case MIGRATION_STATUS_CANCELLING: + case MIGRATION_STATUS_COLO: return true; - default: return false; - } } =20 @@ -1658,8 +1630,7 @@ bool migration_incoming_postcopy_advised(void) =20 bool migration_in_bg_snapshot(void) { - return migrate_background_snapshot() && - migration_is_setup_or_active(); + return migrate_background_snapshot() && migration_is_running(); } =20 bool migration_is_idle(void) @@ -2332,7 +2303,7 @@ static void *source_return_path_thread(void *opaque) trace_source_return_path_thread_entry(); rcu_register_thread(); =20 - while (migration_is_setup_or_active()) { + while (migration_is_running()) { trace_source_return_path_thread_loop_top(); =20 header_type =3D qemu_get_be16(rp); diff --git a/migration/ram.c b/migration/ram.c index d284f63854..5646a0b882 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -2860,7 +2860,7 @@ void qemu_guest_free_page_hint(void *addr, size_t len) size_t used_len, start, npages; =20 /* This function is currently expected to be used during live migratio= n */ - if (!migration_is_setup_or_active()) { + if (!migration_is_running()) { return; } =20 @@ -3208,8 +3208,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque) } =20 out: - if (ret >=3D 0 - && migration_is_setup_or_active()) { + if (ret >=3D 0 && migration_is_running()) { if (migrate_multifd() && migrate_multifd_flush_after_each_section(= ) && !migrate_mapped_ram()) { ret =3D multifd_ram_flush_and_sync(); diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 46b02c50be..231b45246c 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -375,8 +375,7 @@ static int vhost_vdpa_net_data_start(NetClientState *nc) =20 assert(nc->info->type =3D=3D NET_CLIENT_DRIVER_VHOST_VDPA); =20 - if (s->always_svq || - migration_is_setup_or_active()) { + if (s->always_svq || migration_is_running()) { v->shadow_vqs_enabled =3D true; } else { v->shadow_vqs_enabled =3D false; --=20 2.45.0