From nobody Fri Nov 14 18:20:05 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1761555680; cv=none; d=zohomail.com; s=zohoarc; b=jL2JrhcMoFZ+q7uEBWPEwe8A5M+05vtfSw9N9YkeXRNiq4ZUSTJbX8WnJAfaraBCTzDUDKWo+2bfPxi8es1CIHNdh8ANqkHPm5ESSrsr8SZkiLJbxV5vW0GXfp2XTQewmziJINKpMqRBxyquoBO1GWm4kgWY/memXwG3RGXxeyU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761555680; h=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:Resent-Date:Resent-To:References:Resent-Message-ID:Resent-From:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=zRoqSH0EYkr4DlSWvpsYRCxmS2ZL6b1Fd6WHNXgK9Vo=; b=hVKEvM7clNqElzbCMMNz12HomLPJlbszLUM4OFDizWVkSEFX+6eXRreDBlJbhoebl8KcWiX2gLtXlI4Pz7jxHcDZs1QbqUr1Lz9NOov5iDQ8YGHqXtHY4/0wwNujix5hD7CPhSXOhPGUww5fWIr5Y8UcnUfnMZK0laKO+NhmyB0= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761555680835264.7063876914807; Mon, 27 Oct 2025 02:01:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vDJ5M-0004I0-Gw; Mon, 27 Oct 2025 05:00:16 -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 1vDJ5A-0004BC-TO for qemu-devel@nongnu.org; Mon, 27 Oct 2025 05:00:05 -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 1vDJ56-0002YN-TN for qemu-devel@nongnu.org; Mon, 27 Oct 2025 05:00:04 -0400 Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-578-sVf1JulfOHypPkRPwkNAeg-1; Mon, 27 Oct 2025 04:59:54 -0400 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BF7F719540E2; Mon, 27 Oct 2025 08:59:51 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.45.242.18]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5B37B1800451; Mon, 27 Oct 2025 08:59:51 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id CF9E521E6925; Mon, 27 Oct 2025 09:59:48 +0100 (CET) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 80D6021E6924; Mon, 27 Oct 2025 07:45:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1761555596; 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:resent-to: resent-from:resent-message-id:in-reply-to:in-reply-to: references:references; bh=zRoqSH0EYkr4DlSWvpsYRCxmS2ZL6b1Fd6WHNXgK9Vo=; b=CFLdbwi0LQIHyyw7xuqAgolobQE6Jl/c2Kf48u+5WBb4ueWYXlkaJScVBU8R6rwmP8evwG grVf3zd13A84+9GtAe0h7/cDMF1yfQh81A9iAt981vtNmgPA/VrZ4wiNgYO+xMrTeINKI7 R9wAwO9JiuEfknS7/MIlcZZQrC2n9vQ= X-MC-Unique: sVf1JulfOHypPkRPwkNAeg-1 X-Mimecast-MFC-AGG-ID: sVf1JulfOHypPkRPwkNAeg_1761555592 Resent-To: guobin@linux.alibaba.com, qemu-devel@nongnu.org, farosas@suse.de Resent-From: Markus Armbruster Resent-Date: Mon, 27 Oct 2025 09:59:48 +0100 Resent-Message-ID: <87ikg0pvnf.fsf@pond.sub.org> X-From-Line: armbru@redhat.com Mon Oct 27 07:45:03 2025 X-Original-To: armbru From: Markus Armbruster To: qemu-devel@nongnu.org Cc: peterx@redhat.com, farosas@suse.de, berrange@redhat.com, guobin@linux.alibaba.com Subject: [PATCH 1/3] migration: Use unsigned instead of int for bit set of MigMode Date: Mon, 27 Oct 2025 07:45:01 +0100 Message-ID: <20251027064503.1074255-2-armbru@redhat.com> In-Reply-To: <20251027064503.1074255-1-armbru@redhat.com> References: <20251027064503.1074255-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Lines: 85 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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: 1761555757036154100 Content-Type: text/plain; charset="utf-8" Signed operands in bitwise operations are unwise. I believe they're safe here, but avoiding them is easy, so let's do that. Signed-off-by: Markus Armbruster Reviewed-by: Fabiano Rosas --- migration/migration.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index a63b46bbef..9f0a91b1d9 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1672,9 +1672,9 @@ void migration_cancel(void) } } =20 -static int get_modes(MigMode mode, va_list ap); +static unsigned get_modes(MigMode mode, va_list ap); =20 -static void add_notifiers(NotifierWithReturn *notify, int modes) +static void add_notifiers(NotifierWithReturn *notify, unsigned modes) { for (MigMode mode =3D 0; mode < MIG_MODE__MAX; mode++) { if (modes & BIT(mode)) { @@ -1687,7 +1687,7 @@ static void add_notifiers(NotifierWithReturn *notify,= int modes) void migration_add_notifier_modes(NotifierWithReturn *notify, MigrationNotifyFunc func, MigMode mode, = ...) { - int modes; + unsigned modes; va_list ap; =20 va_start(ap, mode); @@ -1876,7 +1876,7 @@ static bool is_busy(Error **reasonp, Error **errp) return false; } =20 -static bool is_only_migratable(Error **reasonp, Error **errp, int modes) +static bool is_only_migratable(Error **reasonp, Error **errp, unsigned mod= es) { ERRP_GUARD(); =20 @@ -1890,9 +1890,9 @@ static bool is_only_migratable(Error **reasonp, Error= **errp, int modes) return false; } =20 -static int get_modes(MigMode mode, va_list ap) +static unsigned get_modes(MigMode mode, va_list ap) { - int modes =3D 0; + unsigned modes =3D 0; =20 while (mode !=3D -1 && mode !=3D MIG_MODE_ALL) { assert(mode >=3D MIG_MODE_NORMAL && mode < MIG_MODE__MAX); @@ -1905,7 +1905,7 @@ static int get_modes(MigMode mode, va_list ap) return modes; } =20 -static int add_blockers(Error **reasonp, Error **errp, int modes) +static int add_blockers(Error **reasonp, Error **errp, unsigned modes) { for (MigMode mode =3D 0; mode < MIG_MODE__MAX; mode++) { if (modes & BIT(mode)) { @@ -1928,7 +1928,7 @@ int migrate_add_blocker_normal(Error **reasonp, Error= **errp) =20 int migrate_add_blocker_modes(Error **reasonp, Error **errp, MigMode mode,= ...) { - int modes; + unsigned modes; va_list ap; =20 va_start(ap, mode); @@ -1945,7 +1945,7 @@ int migrate_add_blocker_modes(Error **reasonp, Error = **errp, MigMode mode, ...) =20 int migrate_add_blocker_internal(Error **reasonp, Error **errp) { - int modes =3D BIT(MIG_MODE__MAX) - 1; + unsigned modes =3D BIT(MIG_MODE__MAX) - 1; =20 if (is_busy(reasonp, errp)) { return -EBUSY; --=20 2.49.0 From nobody Fri Nov 14 18:20:05 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1761555663; cv=none; d=zohomail.com; s=zohoarc; b=gywqBZkVO8uyH9ICcRNgoEyEbhxz86SeclNBPYmPWCmGnTFSJIQt1N1EV6AWXp2aEJP5oJPnFCXuioW/QsY6ZO1lm1Oa0wO02Q+aMlsEBsMVIUyOiLdYSb+deEH56ThExnhXFVRPYsUsYWx9HJrQJL23HHECoJ5z4+o+VVD7L3o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761555663; h=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:Resent-Date:Resent-To:References:Resent-Message-ID:Resent-From:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4Drb6lCZuzrZTJv0a1dwSwvAAKw0dCj4rgic5dBYSMM=; b=e4S5uYujOZ3K4bDB0E1bCKBcHcE7A+LPYjRMSqGMoOfl5ECAnw2RlrHPxo6nbUksNmiUn/niUuCjMdcr/6CcD1p3BzljRTnRuv2O2n3OO0ceqMsmDc2nRKEIdWopyggnOHKaLfg1MIWlKN2ip7LDBhJhAkkQwJgoikazm+JdhvU= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761555663387993.9722218492086; Mon, 27 Oct 2025 02:01:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vDJ5J-0004Cv-Jz; Mon, 27 Oct 2025 05:00:14 -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 1vDJ5B-0004BK-AR for qemu-devel@nongnu.org; Mon, 27 Oct 2025 05:00:05 -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 1vDJ56-0002YZ-Pj for qemu-devel@nongnu.org; Mon, 27 Oct 2025 05:00:05 -0400 Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-626-MopAqorpPGu5MFFvqlJpDQ-1; Mon, 27 Oct 2025 04:59:53 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E974418002C1; Mon, 27 Oct 2025 08:59:51 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.45.242.18]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5EB8019540EB; Mon, 27 Oct 2025 08:59:51 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id DCF9221E6935; Mon, 27 Oct 2025 09:59:48 +0100 (CET) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8589421E6925; Mon, 27 Oct 2025 07:45:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1761555597; 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:resent-to: resent-from:resent-message-id:in-reply-to:in-reply-to: references:references; bh=4Drb6lCZuzrZTJv0a1dwSwvAAKw0dCj4rgic5dBYSMM=; b=K31+ykfD01t5KGwEwcePFgcSeTxvcqYfs0NNyfhWp6sGNjZ6jxBJ5YLSNL1oSLTsS7+zgk 2GwlpYQhIHdC8iYBMEo4s8pjsk+VOpMzKWYADysieEvRbCq87iKUBkqbF+rz6KiCxLzN7a 7915JwwgfRFsRG9nG3V/bwOAkiNW5qY= X-MC-Unique: MopAqorpPGu5MFFvqlJpDQ-1 X-Mimecast-MFC-AGG-ID: MopAqorpPGu5MFFvqlJpDQ_1761555592 Resent-To: guobin@linux.alibaba.com, qemu-devel@nongnu.org, farosas@suse.de Resent-From: Markus Armbruster Resent-Date: Mon, 27 Oct 2025 09:59:48 +0100 Resent-Message-ID: <87ecqopvnf.fsf@pond.sub.org> X-From-Line: armbru@redhat.com Mon Oct 27 07:45:03 2025 X-Original-To: armbru From: Markus Armbruster To: qemu-devel@nongnu.org Cc: peterx@redhat.com, farosas@suse.de, berrange@redhat.com, guobin@linux.alibaba.com Subject: [PATCH 2/3] migration: Use bitset of MigMode instead of variable arguments Date: Mon, 27 Oct 2025 07:45:02 +0100 Message-ID: <20251027064503.1074255-3-armbru@redhat.com> In-Reply-To: <20251027064503.1074255-1-armbru@redhat.com> References: <20251027064503.1074255-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Lines: 316 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 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=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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: 1761555679619158501 Content-Type: text/plain; charset="utf-8" migrate_add_blocker_modes() and migration_add_notifier_modes use variable arguments for a set of migration modes. The variable arguments get collected into a bitset for processsing. Take a bitset argument instead, it's simpler. Signed-off-by: Markus Armbruster Reviewed-by: Fabiano Rosas --- include/migration/blocker.h | 9 +++----- include/migration/misc.h | 10 ++++----- hw/vfio/container-legacy.c | 6 +++--- hw/vfio/cpr-iommufd.c | 6 +++--- hw/vfio/cpr-legacy.c | 8 +++---- hw/vfio/cpr.c | 5 ++--- hw/vfio/device.c | 4 ++-- migration/migration.c | 43 ++++++------------------------------- stubs/migr-blocker.c | 2 +- system/physmem.c | 8 +++---- 10 files changed, 33 insertions(+), 68 deletions(-) diff --git a/include/migration/blocker.h b/include/migration/blocker.h index a687ac0efe..80b75ad5cb 100644 --- a/include/migration/blocker.h +++ b/include/migration/blocker.h @@ -16,8 +16,6 @@ =20 #include "qapi/qapi-types-migration.h" =20 -#define MIG_MODE_ALL MIG_MODE__MAX - /** * @migrate_add_blocker - prevent all modes of migration from proceeding * @@ -82,16 +80,15 @@ int migrate_add_blocker_normal(Error **reasonp, Error *= *errp); * * @reasonp - address of an error to be returned whenever migration is att= empted * - * @errp - [out] The reason (if any) we cannot block migration right now. + * @modes - the migration modes to be blocked, a bit set of MigMode * - * @mode - one or more migration modes to be blocked. The list is termina= ted - * by -1 or MIG_MODE_ALL. For the latter, all modes are blocked. + * @errp - [out] The reason (if any) we cannot block migration right now. * * @returns - 0 on success, -EBUSY/-EACCES on failure, with errp set. * * *@reasonp is freed and set to NULL if failure is returned. * On success, the caller must not free *@reasonp before the blocker is re= moved. */ -int migrate_add_blocker_modes(Error **reasonp, Error **errp, MigMode mode,= ...); +int migrate_add_blocker_modes(Error **reasonp, unsigned modes, Error **err= p); =20 #endif diff --git a/include/migration/misc.h b/include/migration/misc.h index 592b93021e..e26d418a6e 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -90,18 +90,18 @@ void migration_add_notifier(NotifierWithReturn *notify, MigrationNotifyFunc func); =20 /* - * Same as migration_add_notifier, but applies to be specified @mode. + * Same as migration_add_notifier, but applies to the specified @mode + * instead of MIG_MODE_NORMAL. */ void migration_add_notifier_mode(NotifierWithReturn *notify, MigrationNotifyFunc func, MigMode mode); =20 /* - * Same as migration_add_notifier, but applies to all @mode in the argument - * list. The list is terminated by -1 or MIG_MODE_ALL. For the latter, - * the notifier is added for all modes. + * Same as migration_add_notifier, but applies to the specified @modes + * (a bitset of MigMode). */ void migration_add_notifier_modes(NotifierWithReturn *notify, - MigrationNotifyFunc func, MigMode mode, = ...); + MigrationNotifyFunc func, unsigned modes= ); =20 /* * Remove a notifier from all modes. diff --git a/hw/vfio/container-legacy.c b/hw/vfio/container-legacy.c index 8e9639603e..32c260b345 100644 --- a/hw/vfio/container-legacy.c +++ b/hw/vfio/container-legacy.c @@ -977,9 +977,9 @@ static bool vfio_legacy_attach_device(const char *name,= VFIODevice *vbasedev, if (vbasedev->mdev) { error_setg(&vbasedev->cpr.mdev_blocker, "CPR does not support vfio mdev %s", vbasedev->name); - if (migrate_add_blocker_modes(&vbasedev->cpr.mdev_blocker, errp, - MIG_MODE_CPR_TRANSFER, MIG_MODE_CPR_= EXEC, - -1) < 0) { + if (migrate_add_blocker_modes(&vbasedev->cpr.mdev_blocker, + BIT(MIG_MODE_CPR_TRANSFER) | BIT(MIG_MODE_CPR_EXEC), + errp) < 0) { goto hiod_unref_exit; } } diff --git a/hw/vfio/cpr-iommufd.c b/hw/vfio/cpr-iommufd.c index 8a4d65de5e..c244db88fb 100644 --- a/hw/vfio/cpr-iommufd.c +++ b/hw/vfio/cpr-iommufd.c @@ -158,9 +158,9 @@ bool vfio_iommufd_cpr_register_iommufd(IOMMUFDBackend *= be, Error **errp) Error **cpr_blocker =3D &be->cpr_blocker; =20 if (!vfio_cpr_supported(be, cpr_blocker)) { - return migrate_add_blocker_modes(cpr_blocker, errp, - MIG_MODE_CPR_TRANSFER, - MIG_MODE_CPR_EXEC, -1) =3D=3D 0; + return migrate_add_blocker_modes(cpr_blocker, + BIT(MIG_MODE_CPR_TRANSFER) | BIT(MIG_MODE_CPR_TRANSFER= ), + errp); } =20 vmstate_register(NULL, -1, &iommufd_cpr_vmstate, be); diff --git a/hw/vfio/cpr-legacy.c b/hw/vfio/cpr-legacy.c index 7184c93991..86c943158e 100644 --- a/hw/vfio/cpr-legacy.c +++ b/hw/vfio/cpr-legacy.c @@ -176,9 +176,9 @@ bool vfio_legacy_cpr_register_container(VFIOLegacyConta= iner *container, MIG_MODE_CPR_REBOOT); =20 if (!vfio_cpr_supported(container, cpr_blocker)) { - return migrate_add_blocker_modes(cpr_blocker, errp, - MIG_MODE_CPR_TRANSFER, - MIG_MODE_CPR_EXEC, -1) =3D=3D 0; + return migrate_add_blocker_modes(cpr_blocker, + BIT(MIG_MODE_CPR_TRANSFER) | BIT(MIG_MODE_CPR_EXEC= ), + errp) =3D=3D 0; } =20 vfio_cpr_add_kvm_notifier(); @@ -187,7 +187,7 @@ bool vfio_legacy_cpr_register_container(VFIOLegacyConta= iner *container, =20 migration_add_notifier_modes(&container->cpr.transfer_notifier, vfio_cpr_fail_notifier, - MIG_MODE_CPR_TRANSFER, MIG_MODE_CPR_EXEC,= -1); + BIT(MIG_MODE_CPR_TRANSFER) | BIT(MIG_MODE= _CPR_EXEC)); return true; } =20 diff --git a/hw/vfio/cpr.c b/hw/vfio/cpr.c index db462aabcb..998230d271 100644 --- a/hw/vfio/cpr.c +++ b/hw/vfio/cpr.c @@ -197,8 +197,7 @@ void vfio_cpr_add_kvm_notifier(void) if (!kvm_close_notifier.notify) { migration_add_notifier_modes(&kvm_close_notifier, vfio_cpr_kvm_close_notifier, - MIG_MODE_CPR_TRANSFER, MIG_MODE_CPR_E= XEC, - -1); + BIT(MIG_MODE_CPR_TRANSFER) | BIT(MIG_= MODE_CPR_EXEC)); } } =20 @@ -285,7 +284,7 @@ void vfio_cpr_pci_register_device(VFIOPCIDevice *vdev) { migration_add_notifier_modes(&vdev->cpr.transfer_notifier, vfio_cpr_pci_notifier, - MIG_MODE_CPR_TRANSFER, MIG_MODE_CPR_EXEC,= -1); + BIT(MIG_MODE_CPR_TRANSFER) | BIT(MIG_MODE= _CPR_EXEC)); } =20 void vfio_cpr_pci_unregister_device(VFIOPCIDevice *vdev) diff --git a/hw/vfio/device.c b/hw/vfio/device.c index 8b63e765ac..76869828fc 100644 --- a/hw/vfio/device.c +++ b/hw/vfio/device.c @@ -345,8 +345,8 @@ bool vfio_device_get_name(VFIODevice *vbasedev, Error *= *errp) "vfio device with fd=3D%d needs an id property", vbasedev->fd); return migrate_add_blocker_modes(&vbasedev->cpr.id_blocker, - errp, MIG_MODE_CPR_TRANSF= ER, - -1) =3D=3D 0; + BIT(MIG_MODE_CPR_TRANSFER= ), + errp) =3D=3D 0; } } } diff --git a/migration/migration.c b/migration/migration.c index 9f0a91b1d9..5f1c83aafd 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1672,8 +1672,6 @@ void migration_cancel(void) } } =20 -static unsigned get_modes(MigMode mode, va_list ap); - static void add_notifiers(NotifierWithReturn *notify, unsigned modes) { for (MigMode mode =3D 0; mode < MIG_MODE__MAX; mode++) { @@ -1685,15 +1683,8 @@ static void add_notifiers(NotifierWithReturn *notify= , unsigned modes) } =20 void migration_add_notifier_modes(NotifierWithReturn *notify, - MigrationNotifyFunc func, MigMode mode, = ...) + MigrationNotifyFunc func, unsigned modes) { - unsigned modes; - va_list ap; - - va_start(ap, mode); - modes =3D get_modes(mode, ap); - va_end(ap); - notify->notify =3D (NotifierWithReturnFunc)func; add_notifiers(notify, modes); } @@ -1701,13 +1692,13 @@ void migration_add_notifier_modes(NotifierWithRetur= n *notify, void migration_add_notifier_mode(NotifierWithReturn *notify, MigrationNotifyFunc func, MigMode mode) { - migration_add_notifier_modes(notify, func, mode, -1); + migration_add_notifier_modes(notify, func, BIT(mode)); } =20 void migration_add_notifier(NotifierWithReturn *notify, MigrationNotifyFunc func) { - migration_add_notifier_modes(notify, func, MIG_MODE_NORMAL, -1); + migration_add_notifier_mode(notify, func, MIG_MODE_NORMAL); } =20 void migration_remove_notifier(NotifierWithReturn *notify) @@ -1890,21 +1881,6 @@ static bool is_only_migratable(Error **reasonp, Erro= r **errp, unsigned modes) return false; } =20 -static unsigned get_modes(MigMode mode, va_list ap) -{ - unsigned modes =3D 0; - - while (mode !=3D -1 && mode !=3D MIG_MODE_ALL) { - assert(mode >=3D MIG_MODE_NORMAL && mode < MIG_MODE__MAX); - modes |=3D BIT(mode); - mode =3D va_arg(ap, MigMode); - } - if (mode =3D=3D MIG_MODE_ALL) { - modes =3D BIT(MIG_MODE__MAX) - 1; - } - return modes; -} - static int add_blockers(Error **reasonp, Error **errp, unsigned modes) { for (MigMode mode =3D 0; mode < MIG_MODE__MAX; mode++) { @@ -1918,23 +1894,16 @@ static int add_blockers(Error **reasonp, Error **er= rp, unsigned modes) =20 int migrate_add_blocker(Error **reasonp, Error **errp) { - return migrate_add_blocker_modes(reasonp, errp, MIG_MODE_ALL); + return migrate_add_blocker_modes(reasonp, -1u, errp); } =20 int migrate_add_blocker_normal(Error **reasonp, Error **errp) { - return migrate_add_blocker_modes(reasonp, errp, MIG_MODE_NORMAL, -1); + return migrate_add_blocker_modes(reasonp, BIT(MIG_MODE_NORMAL), errp); } =20 -int migrate_add_blocker_modes(Error **reasonp, Error **errp, MigMode mode,= ...) +int migrate_add_blocker_modes(Error **reasonp, unsigned modes, Error **err= p) { - unsigned modes; - va_list ap; - - va_start(ap, mode); - modes =3D get_modes(mode, ap); - va_end(ap); - if (is_only_migratable(reasonp, errp, modes)) { return -EACCES; } else if (is_busy(reasonp, errp)) { diff --git a/stubs/migr-blocker.c b/stubs/migr-blocker.c index 11cbff268f..e54c7160d3 100644 --- a/stubs/migr-blocker.c +++ b/stubs/migr-blocker.c @@ -11,7 +11,7 @@ int migrate_add_blocker_normal(Error **reasonp, Error **e= rrp) return 0; } =20 -int migrate_add_blocker_modes(Error **reasonp, Error **errp, MigMode mode,= ...) +int migrate_add_blocker_modes(Error **reasonp, unsigned modes, Error **err= p) { return 0; } diff --git a/system/physmem.c b/system/physmem.c index a340ca3e61..a7e2a5d07f 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -2255,8 +2255,8 @@ static void ram_block_add(RAMBlock *new_block, Error = **errp) "Memory region %s uses guest_memfd, " "which is not supported with CPR.", memory_region_name(new_block->mr)); - migrate_add_blocker_modes(&new_block->cpr_blocker, errp, - MIG_MODE_CPR_TRANSFER, -1); + migrate_add_blocker_modes(&new_block->cpr_blocker, + BIT(MIG_MODE_CPR_TRANSFER), errp); } } =20 @@ -4462,8 +4462,8 @@ void ram_block_add_cpr_blocker(RAMBlock *rb, Error **= errp) "Memory region %s is not compatible with CPR. share=3Don is= " "required for memory-backend objects, and aux-ram-share=3Do= n is " "required.", memory_region_name(rb->mr)); - migrate_add_blocker_modes(&rb->cpr_blocker, errp, MIG_MODE_CPR_TRANSFE= R, - -1); + migrate_add_blocker_modes(&rb->cpr_blocker, BIT(MIG_MODE_CPR_TRANSFER), + errp); } =20 void ram_block_del_cpr_blocker(RAMBlock *rb) --=20 2.49.0 From nobody Fri Nov 14 18:20:05 2025 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=quarantine dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1761555637; cv=none; d=zohomail.com; s=zohoarc; b=dRDw28UMBHdAFwqUjitEdm+RkBasxwLq6ztQfRn4tUq1hZIJ/4U8T2UHEwh0FMm58+b4923Aal1Hom0MovDVOBOM7/GGHTLMVkPA1wudRv2rhrsKe0uuYeEJRsZRheyGbSi3Vwu57eumDeyvMWir1orSc/LIR9dt4z85Iv2DiPM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761555637; h=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:Resent-Date:Resent-To:References:Resent-Message-ID:Resent-From:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=XZUl7HRBPcEusP4+ie7ACy7kl0AnVZqiBGsnVbFuRhE=; b=S7C2tHEKSN7JvqIZiXPDO/+kZfcS9Nb3BhTrCFMkxm2P6LfkTcAGbxwMqgNDpdnTG67+ZJMZTSFJhk8zz6NdJaLJWMVfEyHzTYNSd/Erk6AGTkQZ5tJNJuQRrsqZPygVRq3OPT0mFlfygZvJ6Dq+hmndrkT3vacx5xOQsrX0y3U= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761555637575420.428588025101; Mon, 27 Oct 2025 02:00:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vDJ5F-0004C2-Os; Mon, 27 Oct 2025 05:00:09 -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 1vDJ59-0004Au-UK for qemu-devel@nongnu.org; Mon, 27 Oct 2025 05:00:03 -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 1vDJ56-0002YM-OV for qemu-devel@nongnu.org; Mon, 27 Oct 2025 05:00:03 -0400 Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-13-NjKFreRqP36lrxkeJ9WkJQ-1; Mon, 27 Oct 2025 04:59:54 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A7813180A225; Mon, 27 Oct 2025 08:59:51 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.45.242.18]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 403A91800578; Mon, 27 Oct 2025 08:59:51 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id E7B4821E6773; Mon, 27 Oct 2025 09:59:48 +0100 (CET) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8983F21E6935; Mon, 27 Oct 2025 07:45:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1761555596; 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:resent-to: resent-from:resent-message-id:in-reply-to:in-reply-to: references:references; bh=XZUl7HRBPcEusP4+ie7ACy7kl0AnVZqiBGsnVbFuRhE=; b=CYOc5g+VX58y9D+WJfWoziggMt9zlPy7x+U4FaJzbtu1eyZSmCaDPuZusFYTux09ShWT3J 2TZGMqYDQmGLvJs8HDVd+/FgBD7LAY0Td0AKGeRnSetP4OVBH8PrqwDanRhk188lhh11Z7 PH2lG2dWr+bH6LGDAZE20fWwLfUEX88= X-MC-Unique: NjKFreRqP36lrxkeJ9WkJQ-1 X-Mimecast-MFC-AGG-ID: NjKFreRqP36lrxkeJ9WkJQ_1761555593 Resent-To: guobin@linux.alibaba.com, qemu-devel@nongnu.org, farosas@suse.de Resent-From: Markus Armbruster Resent-Date: Mon, 27 Oct 2025 09:59:48 +0100 Resent-Message-ID: <87a51cpvnf.fsf@pond.sub.org> X-From-Line: armbru@redhat.com Mon Oct 27 07:45:03 2025 X-Original-To: armbru From: Markus Armbruster To: qemu-devel@nongnu.org Cc: peterx@redhat.com, farosas@suse.de, berrange@redhat.com, guobin@linux.alibaba.com Subject: [PATCH 3/3] migration: Put Error **errp parameter last Date: Mon, 27 Oct 2025 07:45:03 +0100 Message-ID: <20251027064503.1074255-4-armbru@redhat.com> In-Reply-To: <20251027064503.1074255-1-armbru@redhat.com> References: <20251027064503.1074255-1-armbru@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Lines: 64 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 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=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_PASS=-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: 1761555700407154100 Content-Type: text/plain; charset="utf-8" qapi/error.h's big comment: * - Functions that use Error to report errors have an Error **errp * parameter. It should be the last parameter, except for functions * taking variable arguments. is_only_migratable() and add_blockers() have it in the middle. Clean them up. Signed-off-by: Markus Armbruster Reviewed-by: Fabiano Rosas --- migration/migration.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 5f1c83aafd..8a06b54167 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1867,7 +1867,7 @@ static bool is_busy(Error **reasonp, Error **errp) return false; } =20 -static bool is_only_migratable(Error **reasonp, Error **errp, unsigned mod= es) +static bool is_only_migratable(Error **reasonp, unsigned modes, Error **er= rp) { ERRP_GUARD(); =20 @@ -1881,7 +1881,7 @@ static bool is_only_migratable(Error **reasonp, Error= **errp, unsigned modes) return false; } =20 -static int add_blockers(Error **reasonp, Error **errp, unsigned modes) +static int add_blockers(Error **reasonp, unsigned modes, Error **errp) { for (MigMode mode =3D 0; mode < MIG_MODE__MAX; mode++) { if (modes & BIT(mode)) { @@ -1904,12 +1904,12 @@ int migrate_add_blocker_normal(Error **reasonp, Err= or **errp) =20 int migrate_add_blocker_modes(Error **reasonp, unsigned modes, Error **err= p) { - if (is_only_migratable(reasonp, errp, modes)) { + if (is_only_migratable(reasonp, modes, errp)) { return -EACCES; } else if (is_busy(reasonp, errp)) { return -EBUSY; } - return add_blockers(reasonp, errp, modes); + return add_blockers(reasonp, modes, errp); } =20 int migrate_add_blocker_internal(Error **reasonp, Error **errp) @@ -1919,7 +1919,7 @@ int migrate_add_blocker_internal(Error **reasonp, Err= or **errp) if (is_busy(reasonp, errp)) { return -EBUSY; } - return add_blockers(reasonp, errp, modes); + return add_blockers(reasonp, modes, errp); } =20 void migrate_del_blocker(Error **reasonp) --=20 2.49.0