From patchwork Wed Sep 6 15:08:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 13375723 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6AA7AEE14A5 for ; Wed, 6 Sep 2023 15:10:04 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qdu9h-0004Mg-Db; Wed, 06 Sep 2023 11:09:21 -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 1qdu9e-0004M9-T7 for qemu-devel@nongnu.org; Wed, 06 Sep 2023 11:09:19 -0400 Received: from mail-bn8nam04on20600.outbound.protection.outlook.com ([2a01:111:f400:7e8d::600] helo=NAM04-BN8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qdu9a-0003i4-N9 for qemu-devel@nongnu.org; Wed, 06 Sep 2023 11:09:17 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=goGciLAie1yMSEyZTR5kVFLH4tFZRFoeP7blO8I0pwkvMVaTaFsLZfBUMRLYH8PTvy0GWYizMdCteC99mivnpg5+cSW98S05ykenuCYIcmRtENtFrNvmGdHfVNO0zPpe9eDxpHvghKGYkWVTq9I9kljGdoj1kk8KwCBflRCMmJ4fYdvF3iL33LdM4GIB9j3p8uW/lnz57N0lCbZmotJcOyD58eNecHuLuSA59+zTV3FE4B+7pp8oD5VJ3vGrtlBbyQSKxeW2SkXMmDXIEu7T5VdVLpLs5YY4o1QO/Got30uigbY+LiiOx7doeUtZMqN4TzdDIIGLFFtMaiDbN9o29Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jvyyngd7FfVNeRyt7xrSL/FW17XxSoEYV8VAx5jok/Q=; b=jdqmkn9XZFHpVnUMdPHKelt2H33/S0DKOlZz9sNy4D+LMYRdT3NK/kgxi0s8kcvlJO2KDD2jSZ1al/iafzmyx0gPHmumosy0jCZ6yCwOPFHj39i59VZdv/29lcOIiO2PPWMDyMyMYmUy4WLZEoGE4C+Ag2jGaRKfR+bX2+X/YDU9olojc7cyDIO4iLXfa7nTe9YGHN75rdjg3VZxeWf47WaQKpAMpU4kaADGKMQJR/KFc+RDbJVGi6GB0FGKYMBruIKe1wx4WHmW/ULZVcZQ5WA6iRTrwvBzFd420usb/TzbLofOsYWAHLU8FhT/77gSak1PeE9SERyzCbkS+Pat/g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jvyyngd7FfVNeRyt7xrSL/FW17XxSoEYV8VAx5jok/Q=; b=Zdulr8szc+vYtYBhC+hb2GHmNetzyZlewT75GeDewerpnao/A0utIkIRYMz6Wi4h9ocBPMkYTp52fz9t5a8rTfDWJUpghWh8DJSOLEPZ09EIwJEwN3lm4jClgyUjTagRjjk2q+5WIBb9/Oq4DJF3mXYW1y48Izr8Q8WElFDKy5y2f8qjDT/RI0ZBTajZ+GnFHP9ZBP5vpgy/xDS/VUjQ4ERMbZFP/7ch8tsGOR770fzxbDTur++GWxWX01i19CRHp2r4EvS2Lozup7BacKHvZgWfuuTbRVb5ugl3xRgf7NzjOGKwSlTV8lThuBVqHZKtKxkMwxiY1NzxfmPDagtgsw== Received: from DS7PR05CA0078.namprd05.prod.outlook.com (2603:10b6:8:57::24) by CH3PR12MB9343.namprd12.prod.outlook.com (2603:10b6:610:1c0::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.34; Wed, 6 Sep 2023 15:09:10 +0000 Received: from DS2PEPF00003439.namprd02.prod.outlook.com (2603:10b6:8:57:cafe::ce) by DS7PR05CA0078.outlook.office365.com (2603:10b6:8:57::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.27 via Frontend Transport; Wed, 6 Sep 2023 15:09:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DS2PEPF00003439.mail.protection.outlook.com (10.167.18.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.25 via Frontend Transport; Wed, 6 Sep 2023 15:09:10 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Wed, 6 Sep 2023 08:08:59 -0700 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 6 Sep 2023 08:08:59 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Wed, 6 Sep 2023 08:08:56 -0700 From: Avihai Horon To: CC: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , Juan Quintela , Peter Xu , Leonardo Bras , Yanghang Liu , Avihai Horon Subject: [PATCH v3 1/6] migration: Add migration prefix to functions in target.c Date: Wed, 6 Sep 2023 18:08:48 +0300 Message-ID: <20230906150853.22176-2-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230906150853.22176-1-avihaih@nvidia.com> References: <20230906150853.22176-1-avihaih@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003439:EE_|CH3PR12MB9343:EE_ X-MS-Office365-Filtering-Correlation-Id: f7cf38b6-3a32-4e19-8b83-08dbaeeb3960 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FPGy6qX/QkprXn2QP/2gHPM96diX0IWG5GPpmEgWfVYZ1FIXNKQzhfxzcf8WdR2ljyce45jxLuoZUM7cKVblwzb+ZFLgb9DNyTPYK8BZosomCrU6oZJZuW1tZq6sZ6A4sph+f091k1s9mU699sZKbCQr7RYGsixJz0lQMoc2Yno9Hw5vq8aOmYQEbM0N+Rca8efxS9lBYlb60VneophcjLL/IXAG2x4ABYXkTArpAUNaLYQ9D3X9X/MG1xRp17gqdaL0ExEsDJZ/X786+2iEB6XGExdQkRSTYodJlVLVvRAYxDZci2oK3gSnkr96nhJiR5kyH81gRhdsdCWdrKVp9G0bV61Ncq5mVcIOlfLVZzWtwzw6JrCN+a5dMiMou3J+pFJZobwtWcc6+O3lDS3BOYaLBsVdQxTWN7WvERbKga0uBnlxnVsLVMySsJ3e1ygGFY0zKswVHosAbWRZJjgM3KtvnzKqpsrtnZD83WitUq4E1QN/XPKqh5RYSASpmfKmT8/4aIdtlnjNf+AP0EvY2IwciuRyN9R1qHmqbjHavLQQ+wY+59bzPvWBTCDLfr+sLBejWg3fZxYigLplBAoeXYHLyS8xY8ucC+h/xhKD6HQlmmq3sFGT10HTuYngxSdY+XxVohw0Fbvp7yNIlzJlOpU6TbdSs6zj4MbNvGYrJ98txk+nqEFYgyHWnHZJSnP5L7IVyBmVmrpwdK919Xi0cDcAWWc3ByKJ+yaYIDBiWRlv5YQcwMWJKwUCA3akds5y X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(376002)(39860400002)(396003)(136003)(346002)(451199024)(82310400011)(1800799009)(186009)(36840700001)(46966006)(40470700004)(70206006)(6916009)(316002)(107886003)(2616005)(1076003)(54906003)(8936002)(8676002)(4326008)(82740400003)(40480700001)(356005)(7636003)(7696005)(41300700001)(70586007)(336012)(426003)(26005)(83380400001)(5660300002)(6666004)(478600001)(66574015)(2906002)(47076005)(36860700001)(40460700003)(86362001)(36756003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2023 15:09:10.4514 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f7cf38b6-3a32-4e19-8b83-08dbaeeb3960 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF00003439.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9343 Received-SPF: softfail client-ip=2a01:111:f400:7e8d::600; envelope-from=avihaih@nvidia.com; helo=NAM04-BN8-obe.outbound.protection.outlook.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 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, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, URG_BIZ=0.573 autolearn=no 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org The functions in target.c are not static, yet they don't have a proper migration prefix. Add such prefix. Signed-off-by: Avihai Horon Reviewed-by: Cédric Le Goater --- migration/migration.h | 4 ++-- migration/migration.c | 6 +++--- migration/savevm.c | 2 +- migration/target.c | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/migration/migration.h b/migration/migration.h index 6eea18db36..c5695de214 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -512,8 +512,8 @@ void migration_consume_urgent_request(void); bool migration_rate_limit(void); void migration_cancel(const Error *error); -void populate_vfio_info(MigrationInfo *info); -void reset_vfio_bytes_transferred(void); +void migration_populate_vfio_info(MigrationInfo *info); +void migration_reset_vfio_bytes_transferred(void); void postcopy_temp_page_reset(PostcopyTmpPage *tmp_page); #endif diff --git a/migration/migration.c b/migration/migration.c index 5528acb65e..92866a8f49 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1039,7 +1039,7 @@ static void fill_source_migration_info(MigrationInfo *info) populate_time_info(info, s); populate_ram_info(info, s); populate_disk_info(info); - populate_vfio_info(info); + migration_populate_vfio_info(info); break; case MIGRATION_STATUS_COLO: info->has_status = true; @@ -1048,7 +1048,7 @@ static void fill_source_migration_info(MigrationInfo *info) case MIGRATION_STATUS_COMPLETED: populate_time_info(info, s); populate_ram_info(info, s); - populate_vfio_info(info); + migration_populate_vfio_info(info); break; case MIGRATION_STATUS_FAILED: info->has_status = true; @@ -1641,7 +1641,7 @@ static bool migrate_prepare(MigrationState *s, bool blk, bool blk_inc, */ memset(&mig_stats, 0, sizeof(mig_stats)); memset(&compression_counters, 0, sizeof(compression_counters)); - reset_vfio_bytes_transferred(); + migration_reset_vfio_bytes_transferred(); return true; } diff --git a/migration/savevm.c b/migration/savevm.c index a2cb8855e2..5bf8b59a7d 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1622,7 +1622,7 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp) migrate_init(ms); memset(&mig_stats, 0, sizeof(mig_stats)); memset(&compression_counters, 0, sizeof(compression_counters)); - reset_vfio_bytes_transferred(); + migration_reset_vfio_bytes_transferred(); ms->to_dst_file = f; qemu_mutex_unlock_iothread(); diff --git a/migration/target.c b/migration/target.c index f39c9a8d88..a6ffa9a5ce 100644 --- a/migration/target.c +++ b/migration/target.c @@ -15,7 +15,7 @@ #endif #ifdef CONFIG_VFIO -void populate_vfio_info(MigrationInfo *info) +void migration_populate_vfio_info(MigrationInfo *info) { if (vfio_mig_active()) { info->vfio = g_malloc0(sizeof(*info->vfio)); @@ -23,16 +23,16 @@ void populate_vfio_info(MigrationInfo *info) } } -void reset_vfio_bytes_transferred(void) +void migration_reset_vfio_bytes_transferred(void) { vfio_reset_bytes_transferred(); } #else -void populate_vfio_info(MigrationInfo *info) +void migration_populate_vfio_info(MigrationInfo *info) { } -void reset_vfio_bytes_transferred(void) +void migration_reset_vfio_bytes_transferred(void) { } #endif From patchwork Wed Sep 6 15:08:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 13375725 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8691BEE14A3 for ; Wed, 6 Sep 2023 15:10:46 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qdu9l-0004O0-2n; Wed, 06 Sep 2023 11:09:25 -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 1qdu9j-0004N3-Eu for qemu-devel@nongnu.org; Wed, 06 Sep 2023 11:09:23 -0400 Received: from mail-mw2nam12on20619.outbound.protection.outlook.com ([2a01:111:f400:fe5a::619] helo=NAM12-MW2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qdu9g-0003jf-U4 for qemu-devel@nongnu.org; Wed, 06 Sep 2023 11:09:23 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DTcXdFmfLDF3DapRS/Jbz+eURwsNxaSnt0CJfD4A+duBkgTvn/L7H3bsZrnKWELTgGavK4oUiBCq1rs+MTkbbeTcuQhIxEZ7FGUE02RWJhBIoZSrjo3YPOusXCLIB/l8jY9TYKKn6idWzEe8+EshkUkbtiy61cAixq6vsYrO5V87ygsNyk1tJFujySsph6LB+1jClwJOMKSEvZqdiSbXDiF47aICopH7lfNq7GYkhV1u6yTqEszcqWaPMnETX1eXQb1ryC/xIpIjRCMjExQtAf5aYPGV3AHxdLm5OwNGifVRA37BAtDyK1DqTqJkgDcXcYV4l4IEm/uQhn3KlrqFeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=FotuBtmavqR9dkaD1yotgN9OXacIbAe0HgjsL8Lx8Hk=; b=ivl8kn2pYII3hyWeh3bSKmKLM0xJe2dm6LQn7K9NAUQ7rr2m82ibaXfg1F4H4hAirjD7t+U4h6+LSAuPqLKt8qQk9ER4RZMPpyChiBUJ/dNic/yJtycSzWheJXQPd0TTZj4/9DgGlUdkq1j3LFk0oxDx4qa4Ot7LtWb/ollhcabKwQNyNW9R7ygV2+VdkT7pYKA1MJoMPj3h5rm04QhKMeyPOow3V5ZnPDl9JZlj2yDC1cYEKO0iPUjmJK3h4VPgBrENi0KnLOSQt9hYWSzL3mUV4sx7D81EU1/bzL+i/3WGPQNNHzdLIhZ9L2NsgQZ/CnA54rw/12EuxXQBeSqjsg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FotuBtmavqR9dkaD1yotgN9OXacIbAe0HgjsL8Lx8Hk=; b=Ft0isJy3bTR18G6arpe+p8jvZ4FvGhr/+pGnGv2h8WIYGkVsiUt1dFms5CMIik8p0Y1dbUcISGAM3u4Suo8+cdzzuXN9f8dWpOfthlqBi3DQzrXzYFvh+meKXRB4uF+iyZyIe69GknE/dK6uADTI9RL0RbVuZnlDgaWkUiRFWc+dv4RwJkN8xZUOKC+Frdk/44fFgM2JycnLXC/1x6LN0GlmMDhd4jq29p8HA0rNRebUnB12oiNhu3ef/4hkXnyX0zAhN6ixuB+h3Ki7pHTp2qtWhl8LWBxvV2YIkQLb/R81fJjmju7GZTFUT5kmZ52Ok6DB7Saxd+XZtE0aVjfPZA== Received: from BL0PR02CA0006.namprd02.prod.outlook.com (2603:10b6:207:3c::19) by DM6PR12MB4060.namprd12.prod.outlook.com (2603:10b6:5:216::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.33; Wed, 6 Sep 2023 15:09:17 +0000 Received: from BL6PEPF0001AB4F.namprd04.prod.outlook.com (2603:10b6:207:3c:cafe::bb) by BL0PR02CA0006.outlook.office365.com (2603:10b6:207:3c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.32 via Frontend Transport; Wed, 6 Sep 2023 15:09:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BL6PEPF0001AB4F.mail.protection.outlook.com (10.167.242.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.26 via Frontend Transport; Wed, 6 Sep 2023 15:09:16 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Wed, 6 Sep 2023 08:09:02 -0700 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 6 Sep 2023 08:09:01 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Wed, 6 Sep 2023 08:08:59 -0700 From: Avihai Horon To: CC: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , Juan Quintela , Peter Xu , Leonardo Bras , Yanghang Liu , Avihai Horon Subject: [PATCH v3 2/6] vfio/migration: Fail adding device with enable-migration=on and existing blocker Date: Wed, 6 Sep 2023 18:08:49 +0300 Message-ID: <20230906150853.22176-3-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230906150853.22176-1-avihaih@nvidia.com> References: <20230906150853.22176-1-avihaih@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB4F:EE_|DM6PR12MB4060:EE_ X-MS-Office365-Filtering-Correlation-Id: be8c7b9b-d251-4f02-c053-08dbaeeb3cd8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: S7dqMCsd9fw9JNAyfacqYuleCCMi7rV3shuvfn/PjSqQWZf1zVUX5PAYkLCXrDcI4Bta0+nv38DmTvyr7qgZXbY2kgY+7XsND3xQuzb9ofLgwtBGiw81SubdPfnkhlGcHnHMM08zMcaSpUQ+UjHTJ4yLPUVADiqQcjDSxLfmbJFhNdCMwvuGUlN9CsQQUqxvsr97q7q+Xyw2QWem+BwBgPI6n9xiik1ArINA1aP3Ho34RLlGUTQmV8zPoXZYnRWuw0e+nrsLD3Y6Z7n7qudyxZzCE2P3g3UkNew1K8Ls9koqqYNh8CMhqctZTTZp9dQsWypNfkXQMjHHNuy3V6C/FEpktszBqEgQ464/VR0PKBPb29mN/pqtdkJJZyQm959b1jxZsdOSm54hJvoQiOhifxXMFnCPjENvEHfL5XvwC40n+WUmmU9lL+5BNkDEHJwO590CO36s/I2l9u/3Ij79z/fN5xKc2jWl+UCbZ99rKbWO2aEA+QaCObi2WOxHvmAX2onUgxONeKp6vIRmgBKfsD5iME/bLtxduNVQ6J+U6ify1tx9XQKpn0OlGpsaun7FZKDC7o8HIb2rvapi12yPPb67QdDL0DxVWU2qmCOGb5Ckc3vlkusmdjp7ewf6keeYWmhk6LXLruMzSyq+jYT9NAcWsokdCRSD2GF3Lv1Vms3XlKQxT5dewBJ8xi9zwS5ND3xeVmrui7wtS4eT8soc57knOKJ7O3qFNAU+j0KXOrbJ3H1jYsyJIWfGiy1zCsld X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(346002)(136003)(396003)(39860400002)(376002)(1800799009)(82310400011)(186009)(451199024)(40470700004)(36840700001)(46966006)(26005)(5660300002)(4326008)(2616005)(107886003)(1076003)(40460700003)(8676002)(66574015)(2906002)(83380400001)(86362001)(47076005)(82740400003)(356005)(7636003)(36860700001)(36756003)(426003)(336012)(8936002)(40480700001)(7696005)(70586007)(6666004)(6916009)(70206006)(54906003)(478600001)(316002)(41300700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2023 15:09:16.2567 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: be8c7b9b-d251-4f02-c053-08dbaeeb3cd8 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB4F.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4060 Received-SPF: softfail client-ip=2a01:111:f400:fe5a::619; envelope-from=avihaih@nvidia.com; helo=NAM12-MW2-obe.outbound.protection.outlook.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, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org If a device with enable-migration=on is added and it causes a migration blocker, adding the device should fail with a proper error. This is not the case with multiple device migration blocker when the blocker already exists. If the blocker already exists and a device with enable-migration=on is added which causes a migration blocker, adding the device will succeed. Fix it by failing adding the device in such case. Fixes: 8bbcb64a71d8 ("vfio/migration: Make VFIO migration non-experimental") Signed-off-by: Avihai Horon Reviewed-by: Cédric Le Goater --- hw/vfio/common.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 8a8d074e18..237101d038 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -394,8 +394,7 @@ int vfio_block_multiple_devices_migration(VFIODevice *vbasedev, Error **errp) { int ret; - if (multiple_devices_migration_blocker || - vfio_multiple_devices_migration_is_supported()) { + if (vfio_multiple_devices_migration_is_supported()) { return 0; } @@ -405,6 +404,10 @@ int vfio_block_multiple_devices_migration(VFIODevice *vbasedev, Error **errp) return -EINVAL; } + if (multiple_devices_migration_blocker) { + return 0; + } + error_setg(&multiple_devices_migration_blocker, "Multiple VFIO devices migration is supported only if all of " "them support P2P migration"); From patchwork Wed Sep 6 15:08:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 13375724 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 57DA0EE14A5 for ; Wed, 6 Sep 2023 15:10:37 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qdu9l-0004OA-MO; Wed, 06 Sep 2023 11:09:25 -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 1qdu9j-0004Mw-67 for qemu-devel@nongnu.org; Wed, 06 Sep 2023 11:09:23 -0400 Received: from mail-dm3nam02on2062e.outbound.protection.outlook.com ([2a01:111:f400:7e83::62e] helo=NAM02-DM3-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qdu9g-0003jc-LE for qemu-devel@nongnu.org; Wed, 06 Sep 2023 11:09:22 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=haICKIQxuZYYG4TTDBGQ0H1OxvuXCRCqdJfp0Ykn4tV4GEOEONjZoc3Ly1kPZUjJFcOGJrmtgtIcwbFp1fUXMmsSSYnAoliopiT0vAyOJcPDvZQCQEMVYnKagicfBVFiE4BFBYNls5A9+pNhCZgJYgdicTK1ZvOudnY6JAmT7DUzTFZvcZ5q3SwGtW9RtNvMZ8Uy8M5z3oGJ3X+HuBUlS/b4082o52C0a4AXc2iW8SKt2Ca6WFKYsAYuoKaJiUuNnq7IfS1z0kASpfkxAwJBCwvr/McEglS7HNEQPhukyTI/l8ZDDDEYJebhTpH6vdtCD2BdiD9xUlu6BTWKlJTzJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7zujfAcUhmtizPK/ZnZu93fvANGT10YSJxmBJ9X7UFs=; b=jAaNt9651HWc9epDujNY81spGDY2iMYb4UeZOpdj4YBcRGAnjm56KPnTLvO4oHp4iZSzQgTG38bUXENaZuS3cJQtpSD9U4zV6oibQLws1RBHHQpuTdEpB/dbCW3yws46nrswfq+5D0SSAkAE8YiamcLRL2gKqz6HoRrVRwjZWIfymn3k6MqU/Ru1Lk6FbW4R+jGV7xKzaJ55aQbobC20zvznxONuD8LTT5Li90copFaXUoRLqV75XBN/tuZIUd67tRD4uU3TEkW7B9Q5kBUGq+TOhpI7nYMeLb1wqOEsxV6ndjo+bN2m1cBx9All7v6c2aRHqobpl2fOY01H/HvNFQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7zujfAcUhmtizPK/ZnZu93fvANGT10YSJxmBJ9X7UFs=; b=HEduFlpSQp29CcbSo3fKP4Er/EkLNcb7zBV+gpuyrSFw/PdInPgXI8Q+km6XS0Z3C0Uf72HLrteYb8xbAgyq/Vf1SLcR5A3Jn/dB81buhE7FAhvKtcU+RN5x51fip9CHFqRFfhgJMnRKiyG8R+8iP4j4SpBJ7Z8JUUazmR+88qVkBG9pF/GxsZfjLdZeRhvznbvTAI1npPOLwQP3VFOXpaREgPEg6ecRHtuvNCpABjZB2GRT+dJY2tzstTCZWzzlXMqnTYlf2LuOP7mP+mE98+iZy47wx7mzzDEjl023Rp4HG4BVPuO4+f3apvfYiL5NPBRF8nZbv+Gox0TCij8nzQ== Received: from CH2PR03CA0012.namprd03.prod.outlook.com (2603:10b6:610:59::22) by CH2PR12MB4972.namprd12.prod.outlook.com (2603:10b6:610:69::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.33; Wed, 6 Sep 2023 15:09:16 +0000 Received: from DS2PEPF0000343F.namprd02.prod.outlook.com (2603:10b6:610:59:cafe::21) by CH2PR03CA0012.outlook.office365.com (2603:10b6:610:59::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.34 via Frontend Transport; Wed, 6 Sep 2023 15:09:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DS2PEPF0000343F.mail.protection.outlook.com (10.167.18.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.25 via Frontend Transport; Wed, 6 Sep 2023 15:09:16 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Wed, 6 Sep 2023 08:09:05 -0700 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 6 Sep 2023 08:09:04 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Wed, 6 Sep 2023 08:09:02 -0700 From: Avihai Horon To: CC: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , Juan Quintela , Peter Xu , Leonardo Bras , Yanghang Liu , Avihai Horon Subject: [PATCH v3 3/6] migration: Move more initializations to migrate_init() Date: Wed, 6 Sep 2023 18:08:50 +0300 Message-ID: <20230906150853.22176-4-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230906150853.22176-1-avihaih@nvidia.com> References: <20230906150853.22176-1-avihaih@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343F:EE_|CH2PR12MB4972:EE_ X-MS-Office365-Filtering-Correlation-Id: b98e03f7-7cfa-4cd5-e3c7-08dbaeeb3ccb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bH39jUp9IxTOg9Mb0AyNy/Q77ygdxtjLQ8gyK9WXwqum8+bsVzk1w0BM2R02sj5IXvIjQ7ylp10zagHQOZRjtYsmZ/VzYqc9Xeo+T1x631ZllkVMXvSHK3OCRNWXATpKzqR12fz1MVqneqjHBv8YM9D+LjkI3S7kYBi6P+v860AwlzxATL5vBtQiJwsWdJ1zifHhgp0MGri1IivUO2UXLc1eH15aEIBPwVlhJ8xFbDdU4PNBFxoGUNLYYyVS6X4eApIo1vIjEmlZ9NmRvJxYUjJdEbwUvdPekNVtrDMUpnZJvfE0eejX8D2J/2FAC+9dMBadbJhywwn30lpwnMTV9UZ0b8TFMC9iQBp5QMHYJPJVw4SaE3HUlOnCOP66tjdF4qOQ8MGpqcCYFtWaV+yICQDyk5oBstA/Mtx1CEZXxcMbzNOKf5T76ejULhTIW34BkqNE+DHUUX8eYgruM7tkS2miQVuWplg0oKt/CEqwzCwJTwtSw6JJQZsl7iP5qXUl63092xuZbXUtaVfCukDrHkMqMmUy5IJnDkkQL2nfdGfVqB+VFwhfWuj02TxnRKmncmQDqy6n7Eul4Bd5tiTj6uI5mSPvkg/vIf8GGGoC3fOHXNxqsgBl1b3uoFLyyjDPvujAFTdmVggbdBVSdKsEpUI0cPh9SEx4p2iPhA9L2DGGNvMx573eSe4DY6THBHBFIJRwdwcI+4GRNyVzaaPX1XmgQY84ApBw9N8Z9Nqh1uOcNgovJ5y80LwAUf2x2Bvl X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(136003)(346002)(396003)(376002)(39860400002)(186009)(1800799009)(451199024)(82310400011)(40470700004)(46966006)(36840700001)(426003)(26005)(336012)(2906002)(36860700001)(83380400001)(8676002)(8936002)(2616005)(107886003)(7696005)(1076003)(47076005)(86362001)(36756003)(82740400003)(356005)(7636003)(478600001)(5660300002)(6666004)(40460700003)(4326008)(70206006)(70586007)(316002)(6916009)(54906003)(41300700001)(40480700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2023 15:09:16.1256 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b98e03f7-7cfa-4cd5-e3c7-08dbaeeb3ccb X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF0000343F.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4972 Received-SPF: softfail client-ip=2a01:111:f400:7e83::62e; envelope-from=avihaih@nvidia.com; helo=NAM02-DM3-obe.outbound.protection.outlook.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, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Initialization of mig_stats, compression_counters and VFIO bytes transferred is hard-coded in migration code path and snapshot code path. Make the code cleaner by initializing them in migrate_init(). Suggested-by: Cédric Le Goater Signed-off-by: Avihai Horon Reviewed-by: Cédric Le Goater --- migration/migration.c | 14 +++++++------- migration/savevm.c | 3 --- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 92866a8f49..ce01a3ba6a 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1425,6 +1425,13 @@ void migrate_init(MigrationState *s) s->iteration_initial_bytes = 0; s->threshold_size = 0; s->switchover_acked = false; + /* + * set mig_stats compression_counters memory to zero for a + * new migration + */ + memset(&mig_stats, 0, sizeof(mig_stats)); + memset(&compression_counters, 0, sizeof(compression_counters)); + migration_reset_vfio_bytes_transferred(); } int migrate_add_blocker_internal(Error *reason, Error **errp) @@ -1635,13 +1642,6 @@ static bool migrate_prepare(MigrationState *s, bool blk, bool blk_inc, } migrate_init(s); - /* - * set mig_stats compression_counters memory to zero for a - * new migration - */ - memset(&mig_stats, 0, sizeof(mig_stats)); - memset(&compression_counters, 0, sizeof(compression_counters)); - migration_reset_vfio_bytes_transferred(); return true; } diff --git a/migration/savevm.c b/migration/savevm.c index 5bf8b59a7d..e14efeced0 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1620,9 +1620,6 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp) } migrate_init(ms); - memset(&mig_stats, 0, sizeof(mig_stats)); - memset(&compression_counters, 0, sizeof(compression_counters)); - migration_reset_vfio_bytes_transferred(); ms->to_dst_file = f; qemu_mutex_unlock_iothread(); From patchwork Wed Sep 6 15:08:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 13375726 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 03CA0EE14A5 for ; Wed, 6 Sep 2023 15:10:56 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qdu9n-0004OX-Q0; Wed, 06 Sep 2023 11:09:27 -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 1qdu9k-0004ND-KY for qemu-devel@nongnu.org; Wed, 06 Sep 2023 11:09:24 -0400 Received: from mail-bn7nam10on20607.outbound.protection.outlook.com ([2a01:111:f400:7e8a::607] helo=NAM10-BN7-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qdu9h-0003je-Np for qemu-devel@nongnu.org; Wed, 06 Sep 2023 11:09:24 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VVGvZDEGQrvA+CSM2qZtqb/s4S0QGIL1FSqsdEnYcchKImMQM9jAW3Xk9hLRtUpk71Vvh3XYlmxnWceuTykp29w03Azb534/GKltdKlIxyYqy95zZl9vuK8toHxmdK9x+WLsDq2q0OywSpOq+4cYtFVDfOyijX84IF9GK9zso465EPjm0oA8iDULg6VCCUuCvNgsJF2EO5sThvg9QUPEcANBno1dChHLB6cVKDUkWwhQDhT9HIMKxyK/up5N7Bi2YEXEYE6njLAYaEZk5Sgt+i0hd5ST326a5J3YlxJgAdYrKksjM50gN3qz+v43kHoc0mD/9wwVI5u7Yozjx+q5iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=P/inR6YLO3dR4ImFqntuajtor9zf3v6RZGrWHBEb4cY=; b=kMFyIyC76Pkihs+IUYaI0ksJOrMcjh8wD9Ak/LNxucr54ySukC7JFSlxyjqC9iafqaF9lxMZWN9GHVYFXx9zwbdoMXTUehejyNcBXiF00t5TSM9fOdGzYn7g0+lpyiC68EMFnnIMb+HhohyjCjAVEcKVAcSTp2qUp2zYEEUbiidGMN/9kBnu4EFtHHhdzrbHJjxO+fIIKk4GjOcD5AdGa7+Qa9oo5r7cEJDCpZbS8i4L87bQX2HD7KesM9G0mMZfcAuLuRRnYb2Y05wXY+Xt/pjJKU9WqJ5ZEYBZ96Tb/8MNjR6d2DzoF07fLUWujfNsLTrJ0XtI4caJ4SvZgk/xcQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=P/inR6YLO3dR4ImFqntuajtor9zf3v6RZGrWHBEb4cY=; b=V6xeurfV3hYHZ2EbAqdrg9fw+INKtiMoRY+KbmqePxw0mIw7I60NA3rW5xFVkCXvV0wnPqRbJid5863cCrbbIxxWbOGVeNDyM23GsXEPpKxKIhfNBKaCm9+qLkSKeoyi1SJqKyD/qwDCHbxTrvEi+ZCZr0vCMlm5EUR7fls1XRo6zrWUMrzmhYBo4PCoksfQ3bT7mffZITzJn5ISAnUpDazdUz9mZ07tiJ81c7JXtRw4g8hh7GK7hWdVDvoy4lnLJij4hUX0pTYoZwPFgQKTT4CS2TZ7NyL2o1pIaSRfNjcUBMagX1rUD2I/zsIpsq0nkP0gIbQiI5g7tDrhDLYlpw== Received: from DS7P222CA0002.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::30) by SJ2PR12MB8954.namprd12.prod.outlook.com (2603:10b6:a03:541::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.33; Wed, 6 Sep 2023 15:09:17 +0000 Received: from DS2PEPF0000343B.namprd02.prod.outlook.com (2603:10b6:8:2e:cafe::5a) by DS7P222CA0002.outlook.office365.com (2603:10b6:8:2e::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.36 via Frontend Transport; Wed, 6 Sep 2023 15:09:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DS2PEPF0000343B.mail.protection.outlook.com (10.167.18.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.25 via Frontend Transport; Wed, 6 Sep 2023 15:09:17 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Wed, 6 Sep 2023 08:09:07 -0700 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 6 Sep 2023 08:09:07 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Wed, 6 Sep 2023 08:09:05 -0700 From: Avihai Horon To: CC: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , Juan Quintela , Peter Xu , Leonardo Bras , Yanghang Liu , Avihai Horon Subject: [PATCH v3 4/6] migration: Add .save_prepare() handler to struct SaveVMHandlers Date: Wed, 6 Sep 2023 18:08:51 +0300 Message-ID: <20230906150853.22176-5-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230906150853.22176-1-avihaih@nvidia.com> References: <20230906150853.22176-1-avihaih@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343B:EE_|SJ2PR12MB8954:EE_ X-MS-Office365-Filtering-Correlation-Id: 8387acc2-48f9-44a1-9ce2-08dbaeeb3d8b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JLsF1oWtHv9AacvGsn/okerewOed0qbLWdwu8fjYwvnKmsqwxV0GK45exunkXsDFlaUI7DQ8RYdITzLX0HYBONTj2lFI7GgJesr/3YaWg6nmLMTbklWic2XOA1NaCwO/AD5MHBeUwTXjeZ03wIRxw2zvbqcNeTN1865UaaaQfMXzoHfsLMlIEEnCDeKcQEGjSZHT51+X9H7NHL4hUfMcrxgBLeok6HCslqCw3tJJZEpIfvuEnfY47+CtQbkLaRuw9ycnStH/FwN3lL9GU9382Jg1Dr6lmy01yN6PdQbJPpBZ5ZEYoaXbqokVPlpTaSwxF7oOaA18bCddixVFdrxs9TdZEJJQyx8Sihxo8xpQCTuCfistY0OQKJqTcI/97M0IXAOZpdN6cFrTUWpXBM8kQ3TkV7mVAwYujl12aPw7cUl/UQ7SsRdoW3gOFCeGqEgauwEDFl3R/GEd3xfEt8UN35qiliqe09ifnk+jXDgECSQ3lU/6NXFmTZd0aFhuayUp7a+k726UdB3if/9cLAfwBApFEaBVkpIjA12BbMIrmIPnIHonrz35RDfagaExL8DFViSay5sng8yW/uic8pZjaim2HMz+aVR2pxTvPkgydeVvn+lT1Dl9IwtManf0OAhxSGDe7i6WM81nNRmia4oirmNEOgtw6hlzHdPeZ6Xyn753w1HBncaO79zZ87UW+Wxx8KeEd7X1QGvU3ujaz2NUxsgBs2G2wmbFaueDQLMmS1JkRLREGn+rAtyC/Q1rBWfu+GCMrXeZKbOrbay6F+mHbQ== X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(39860400002)(396003)(376002)(346002)(136003)(186009)(82310400011)(451199024)(1800799009)(40470700004)(46966006)(36840700001)(36860700001)(40460700003)(47076005)(2906002)(66574015)(36756003)(86362001)(7636003)(40480700001)(356005)(82740400003)(41300700001)(7696005)(54906003)(107886003)(4326008)(70206006)(8936002)(70586007)(8676002)(2616005)(1076003)(6916009)(6666004)(478600001)(336012)(426003)(316002)(83380400001)(26005)(5660300002)(142923001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2023 15:09:17.4758 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8387acc2-48f9-44a1-9ce2-08dbaeeb3d8b X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF0000343B.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8954 Received-SPF: softfail client-ip=2a01:111:f400:7e8a::607; envelope-from=avihaih@nvidia.com; helo=NAM10-BN7-obe.outbound.protection.outlook.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, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Add a new .save_prepare() handler to struct SaveVMHandlers. This handler is called early, even before migration starts, and can be used by devices to perform early checks. Refactor migrate_init() to be able to return errors and call .save_prepare() from there. Suggested-by: Peter Xu Signed-off-by: Avihai Horon Reviewed-by: Peter Xu Reviewed-by: Cédric Le Goater --- include/migration/register.h | 5 +++++ migration/migration.h | 2 +- migration/savevm.h | 1 + migration/migration.c | 15 +++++++++++++-- migration/savevm.c | 29 ++++++++++++++++++++++++++++- 5 files changed, 48 insertions(+), 4 deletions(-) diff --git a/include/migration/register.h b/include/migration/register.h index 90914f32f5..2b12c6adec 100644 --- a/include/migration/register.h +++ b/include/migration/register.h @@ -20,6 +20,11 @@ typedef struct SaveVMHandlers { /* This runs inside the iothread lock. */ SaveStateHandler *save_state; + /* + * save_prepare is called early, even before migration starts, and can be + * used to perform early checks. + */ + int (*save_prepare)(void *opaque, Error **errp); void (*save_cleanup)(void *opaque); int (*save_live_complete_postcopy)(QEMUFile *f, void *opaque); int (*save_live_complete_precopy)(QEMUFile *f, void *opaque); diff --git a/migration/migration.h b/migration/migration.h index c5695de214..c390500604 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -472,7 +472,7 @@ void migrate_fd_connect(MigrationState *s, Error *error_in); bool migration_is_setup_or_active(int state); bool migration_is_running(int state); -void migrate_init(MigrationState *s); +int migrate_init(MigrationState *s, Error **errp); bool migration_is_blocked(Error **errp); /* True if outgoing migration has entered postcopy phase */ bool migration_in_postcopy(void); diff --git a/migration/savevm.h b/migration/savevm.h index e894bbc143..74669733dd 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -31,6 +31,7 @@ bool qemu_savevm_state_blocked(Error **errp); void qemu_savevm_non_migratable_list(strList **reasons); +int qemu_savevm_state_prepare(Error **errp); void qemu_savevm_state_setup(QEMUFile *f); bool qemu_savevm_state_guest_unplug_pending(void); int qemu_savevm_state_resume_prepare(MigrationState *s); diff --git a/migration/migration.c b/migration/migration.c index ce01a3ba6a..d61e572742 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1392,8 +1392,15 @@ bool migration_is_active(MigrationState *s) s->state == MIGRATION_STATUS_POSTCOPY_ACTIVE); } -void migrate_init(MigrationState *s) +int migrate_init(MigrationState *s, Error **errp) { + int ret; + + ret = qemu_savevm_state_prepare(errp); + if (ret) { + return ret; + } + /* * Reinitialise all migration state, except * parameters/capabilities that the user set, and @@ -1432,6 +1439,8 @@ void migrate_init(MigrationState *s) memset(&mig_stats, 0, sizeof(mig_stats)); memset(&compression_counters, 0, sizeof(compression_counters)); migration_reset_vfio_bytes_transferred(); + + return 0; } int migrate_add_blocker_internal(Error *reason, Error **errp) @@ -1641,7 +1650,9 @@ static bool migrate_prepare(MigrationState *s, bool blk, bool blk_inc, migrate_set_block_incremental(true); } - migrate_init(s); + if (migrate_init(s, errp)) { + return false; + } return true; } diff --git a/migration/savevm.c b/migration/savevm.c index e14efeced0..bb3e99194c 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -1233,6 +1233,30 @@ bool qemu_savevm_state_guest_unplug_pending(void) return false; } +int qemu_savevm_state_prepare(Error **errp) +{ + SaveStateEntry *se; + int ret; + + QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { + if (!se->ops || !se->ops->save_prepare) { + continue; + } + if (se->ops->is_active) { + if (!se->ops->is_active(se->opaque)) { + continue; + } + } + + ret = se->ops->save_prepare(se->opaque, errp); + if (ret < 0) { + return ret; + } + } + + return 0; +} + void qemu_savevm_state_setup(QEMUFile *f) { MigrationState *ms = migrate_get_current(); @@ -1619,7 +1643,10 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp) return -EINVAL; } - migrate_init(ms); + ret = migrate_init(ms, errp); + if (ret) { + return ret; + } ms->to_dst_file = f; qemu_mutex_unlock_iothread(); From patchwork Wed Sep 6 15:08:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 13375722 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 47384EE14A6 for ; Wed, 6 Sep 2023 15:10:04 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qduA2-0004RA-Tk; Wed, 06 Sep 2023 11:09:43 -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 1qdu9y-0004Qt-N6 for qemu-devel@nongnu.org; Wed, 06 Sep 2023 11:09:39 -0400 Received: from mail-dm6nam11on2061d.outbound.protection.outlook.com ([2a01:111:f400:7eaa::61d] helo=NAM11-DM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qdu9p-0003lF-BD for qemu-devel@nongnu.org; Wed, 06 Sep 2023 11:09:38 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wdbt5zLT2WTpokhdKe3G/vD/n3zArbTSeYMk7K8FaEJrQzpMAlR1SF+vn1sqkPPThcSjuV0nG3Yt74oWWVJVYF58iCF0SvWgk3BwK70mDd1lGqG6Z7HK11f52cCrVoSykNZocJtNBDAWWZ8jf9aLu4Ijlrj8yuHceA8STRfHNHl17wA0cy+bTCWrOE9UOar0I3ZfXkHic1A7NQn5JyftN0xBI00WycVtI6qk963PO6hkFaWCdeQe0CpC3kw4Q9nfHcQ8cLzeL59xPlnP54WlQLDgMUK+744xQYAx+eQ3f2sOWoUXzKF2APLLZrmofTmyZGTEiF1rYDtFC6uUcEXWlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=G8r6cdkGjtfem0dSjq48tNITR5i3m7NvHpysIUHIz2o=; b=O+Wtx8hPqj+KF3l9lDOlEBslFBSYimRCDFkavtmDzlik7Biv9W8KjMu09fKx/Cd3GeqALuAhyraRpArNpOLWLSpToXn3aOaSuKxTc8N19INLMED0Q0hgpBWATMIYAB278RVTWxnn0PqIFbC6gHIAGBfsTd3s6BBfPfAc3O7U9xJWO1WcGD9uZ/bB4Bbpl1Mg7ug4DDYPH9JLw3bf2cWJcZVe5A5kQmsrrO4O3U0iraIWINOX7V1f36A8D8d+EM3l0I54XjvqW1tK2X8Rrz40gDWGRu+ldjL3BxFrbMbr5eR0yBH3croKmsBreznvXQdXAVirCdTIgvr13+9MTOCeXQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=G8r6cdkGjtfem0dSjq48tNITR5i3m7NvHpysIUHIz2o=; b=RWMzfgdvXunr/wEigAj2nv6RtJO72Kx12Z450hnYt2LvbMtS6TP79ZrIjC1rEIT7+uTOz+9gsPbznI6jf8BYua4vy6MhH9Ds5CEJy8VQ+jwawWp0iH6C9mGlJBFTbAqVkijHb9hvhd5dLTAOUB2pFjzOd8G6VoY190BeYCPHJ65yeSrWT/lOgbyJM83E4fbOBkPaRJJeybzWzDQi+U7JdtxVbeqkgP5uY3eWKnuC4Nf9GcYNhuDDts0sGlkWK5/KnEC3I6oLZ/6ho01dLW1Be9KFgzFXzTaALBjEJhQcHNdy/eujJCUdIBn7E2pgA0jmiLkMT3ikm3eZRgVo/3uenQ== Received: from BL1PR13CA0092.namprd13.prod.outlook.com (2603:10b6:208:2b9::7) by SJ2PR12MB8845.namprd12.prod.outlook.com (2603:10b6:a03:538::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.34; Wed, 6 Sep 2023 15:09:26 +0000 Received: from BL6PEPF0001AB4E.namprd04.prod.outlook.com (2603:10b6:208:2b9:cafe::48) by BL1PR13CA0092.outlook.office365.com (2603:10b6:208:2b9::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.26 via Frontend Transport; Wed, 6 Sep 2023 15:09:25 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BL6PEPF0001AB4E.mail.protection.outlook.com (10.167.242.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.26 via Frontend Transport; Wed, 6 Sep 2023 15:09:25 +0000 Received: from rnnvmail203.nvidia.com (10.129.68.9) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Wed, 6 Sep 2023 08:09:10 -0700 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail203.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 6 Sep 2023 08:09:10 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Wed, 6 Sep 2023 08:09:07 -0700 From: Avihai Horon To: CC: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , Juan Quintela , Peter Xu , Leonardo Bras , Yanghang Liu , Avihai Horon Subject: [PATCH v3 5/6] vfio/migration: Block VFIO migration with postcopy migration Date: Wed, 6 Sep 2023 18:08:52 +0300 Message-ID: <20230906150853.22176-6-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230906150853.22176-1-avihaih@nvidia.com> References: <20230906150853.22176-1-avihaih@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB4E:EE_|SJ2PR12MB8845:EE_ X-MS-Office365-Filtering-Correlation-Id: 83c1aca4-16ea-43a4-4dbe-08dbaeeb4262 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SooIVNIFVDM0mKqUuJlm1gmma7hgMfRYel3XMp2qxb35XemutGJz7ROX5UlUaQYPWerT4EInLH4mRBNivVM92UupYRzpGBWMv8aEz9xSp6tufJ9LFd/7ZlTcI/R5WUiYDac31hOdfhl3SLyN682xq8mmRWR4MMZ0MvOQWykZEWKHycHiIO7ftJb8ONyuSmyCMKNETZMVNTr4/73N5+Ccj+sk+LnRm+0WrJZzolAcMPb4t/cXhrutPX7a9paSzvCcmf0xsV/XKVkYUOLyphsRA1wZBesQFfh5XhIY/V3d+X07YzDfNlnyYV9TmWHxmWrhlVXacYqz100MAz4THT5Hgj/epIK4W6aZh+znQrXkWwr++dg4u/96jYWEFrDNhiOT1MgImbwCdUGMTz/bm4g6ZFRbDG8jeixvSHdFEbCMcwosTUdmm9BDrVvaYZuCdKqNqt6WuMz1FNw+A/zcsKzAH2gXzj+tKQlaV8jZhODr/z6V7Iiq9FrvAaduMZ0Ik3h/0fjx9CKXZWXbFC+jpCFIw9EDCYFPnMv1VegPm/sQJDno0CxUQn9TTRmeph1l71i+X2C9+D5+KyIA7LB10MPL64euKN5GaYnhHUFxfTJyRe9hUNWYBJVv7pc6uAW/q82+i4/7aMmsaVKL2rnqK6VXVtfwKZqZRN0dFLieM7pCymWP1jUAqd6yVNmefOQfSQaLxi4gQVFCOOwvxNd9IaXMWy0lH34ye6kl9Iss4DeDXHgpGQ92OHZvB7mt4PlKlUn+ X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(376002)(39860400002)(136003)(396003)(346002)(451199024)(82310400011)(1800799009)(186009)(40470700004)(36840700001)(46966006)(6666004)(7696005)(478600001)(83380400001)(1076003)(107886003)(2616005)(426003)(336012)(2906002)(26005)(316002)(6916009)(54906003)(70206006)(70586007)(41300700001)(5660300002)(4326008)(8936002)(8676002)(40460700003)(82740400003)(40480700001)(47076005)(36860700001)(36756003)(86362001)(356005)(7636003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2023 15:09:25.4843 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 83c1aca4-16ea-43a4-4dbe-08dbaeeb4262 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB4E.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8845 Received-SPF: softfail client-ip=2a01:111:f400:7eaa::61d; envelope-from=avihaih@nvidia.com; helo=NAM11-DM6-obe.outbound.protection.outlook.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, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org VFIO migration is not compatible with postcopy migration. A VFIO device in the destination can't handle page faults for pages that have not been sent yet. Doing such migration will cause the VM to crash in the destination: qemu-system-x86_64: VFIO_MAP_DMA failed: Bad address qemu-system-x86_64: vfio_dma_map(0x55a28c7659d0, 0xc0000, 0xb000, 0x7f1b11a00000) = -14 (Bad address) qemu: hardware error: vfio: DMA mapping failed, unable to continue To prevent this, block VFIO migration with postcopy migration. Reported-by: Yanghang Liu Signed-off-by: Avihai Horon Tested-by: Yanghang Liu Reviewed-by: Peter Xu --- hw/vfio/migration.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 71855468fe..20994dc1d6 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -335,6 +335,27 @@ static bool vfio_precopy_supported(VFIODevice *vbasedev) /* ---------------------------------------------------------------------- */ +static int vfio_save_prepare(void *opaque, Error **errp) +{ + VFIODevice *vbasedev = opaque; + + /* + * Snapshot doesn't use postcopy, so allow snapshot even if postcopy is on. + */ + if (runstate_check(RUN_STATE_SAVE_VM)) { + return 0; + } + + if (migrate_postcopy_ram()) { + error_setg( + errp, "%s: VFIO migration is not supported with postcopy migration", + vbasedev->name); + return -EOPNOTSUPP; + } + + return 0; +} + static int vfio_save_setup(QEMUFile *f, void *opaque) { VFIODevice *vbasedev = opaque; @@ -640,6 +661,7 @@ static bool vfio_switchover_ack_needed(void *opaque) } static const SaveVMHandlers savevm_vfio_handlers = { + .save_prepare = vfio_save_prepare, .save_setup = vfio_save_setup, .save_cleanup = vfio_save_cleanup, .state_pending_estimate = vfio_state_pending_estimate, From patchwork Wed Sep 6 15:08:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 13375727 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1FDAFEE14A5 for ; Wed, 6 Sep 2023 15:11:13 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qdu9u-0004QV-DB; Wed, 06 Sep 2023 11:09:34 -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 1qdu9r-0004PL-6j for qemu-devel@nongnu.org; Wed, 06 Sep 2023 11:09:31 -0400 Received: from mail-bn8nam12on20613.outbound.protection.outlook.com ([2a01:111:f400:fe5b::613] helo=NAM12-BN8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qdu9o-0003l8-L0 for qemu-devel@nongnu.org; Wed, 06 Sep 2023 11:09:30 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E+59MG6Na/zHjaVr8Bsc7KioWjFz+HXE3IOjz2NheQ13kosA3oYEiyb8U7r8seQ1fxZeNC46o8ZiprHiItAOGQG3aQphnzd8krwmk6ZCotYvollmAf4YdhrSnneFsIgxt78CRTN74rioXkzMEBoScR45LgsNf8tgTcHffyfjEdhFTRn2CX4ToXtiAo46Z0b6pm30R5VAx0c0OJRFhDVaoVMSbM8xPerWF+7pGUOkKFsHXGyHYkoaIbkCuxeofX8V4LXtS+cDgOiVy2KiB0nfwS46Zn23gyE4905lKi7+sgVeqrNyP0NnNxnXmwC54UM7dNcglIcuKZO9e6BejbvXMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bMqBWuBZ0C2IzYo80qdMyTdLCiOUB4xzzlj//eKXoXg=; b=RFWggbbDZMLRQCRxhoEkYYNkQqqFKG2YAHGOuz0hbWcvcNP+ICBVGCDpsuQioY+AifVIlrzUza8JuBSVsxw2XPuMn8sifCz1SWZ2mgJGjFlU0PfCq3qIhvqbTwKtDDY5uF2uC7MCYKP0hXXIOdt8KeE8dEeJqIqC4A/AA6mWrClcyfY7Lo0ae/ihNip1ZxS2odjADiI+AEuQqnCbyJWaNbHjA8WIQx4Ilhedt+KaL+vGaUcUv1gGvxRNJXzTszOUwMEUO/LpiEUojBMDP4QPyIrBZpRfRyUkdxuLyuRg4IvIQMNx57AX3GJUZZPSwvDvjLdBIFq7VF0FfMolhjzxPA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=nongnu.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bMqBWuBZ0C2IzYo80qdMyTdLCiOUB4xzzlj//eKXoXg=; b=hcngtd2eiul6iONQWsWqBRR9MdMOQbt3fXo2pG6ttYVKWI+h8bR32hoHHRNaGzwGUo1Aqk/YoxDuUQasLXF0cRi7fqYK8u6QeqmTBfABWuFlmllQuegePyh3SZGXpS2WL5l6JCuOi7/EUCUlu7DwuY3ZYgeTw/tnjlW90URURwUEFW7qdu5ZC011DrfaKkKcOTjmw/a6AWIgEwa1/ZekHvrm2B+ICRZqW+NnBbGkzYfph9F5+SLpHpd9ejYJEalxdQjpiCU2BBJzVmYI4mgGHSBZaCV2u61pYiqImRYLBQ/2s5M1+2FLC0fw+cZ+IMNyDVNX9RCF52jJFtdHmtVnvw== Received: from DS7PR05CA0079.namprd05.prod.outlook.com (2603:10b6:8:57::9) by DS0PR12MB7653.namprd12.prod.outlook.com (2603:10b6:8:13e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.30; Wed, 6 Sep 2023 15:09:24 +0000 Received: from DS2PEPF00003439.namprd02.prod.outlook.com (2603:10b6:8:57:cafe::51) by DS7PR05CA0079.outlook.office365.com (2603:10b6:8:57::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.26 via Frontend Transport; Wed, 6 Sep 2023 15:09:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DS2PEPF00003439.mail.protection.outlook.com (10.167.18.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.25 via Frontend Transport; Wed, 6 Sep 2023 15:09:24 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Wed, 6 Sep 2023 08:09:13 -0700 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Wed, 6 Sep 2023 08:09:12 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Wed, 6 Sep 2023 08:09:10 -0700 From: Avihai Horon To: CC: Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_G?= =?utf-8?q?oater?= , Juan Quintela , Peter Xu , Leonardo Bras , Yanghang Liu , Avihai Horon Subject: [PATCH v3 6/6] vfio/migration: Block VFIO migration with background snapshot Date: Wed, 6 Sep 2023 18:08:53 +0300 Message-ID: <20230906150853.22176-7-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230906150853.22176-1-avihaih@nvidia.com> References: <20230906150853.22176-1-avihaih@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF00003439:EE_|DS0PR12MB7653:EE_ X-MS-Office365-Filtering-Correlation-Id: 7c491fe5-6c19-41fe-8b02-08dbaeeb417f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 35Vi8CAwXfVj/BR7q2Rp0I/E7UrYv0iBCc5gutyrgX8QCPGKaUThL6+0grHuuLc1gkurEDmK3pfOvZPlPYDIyquYCIp/qOSr+gTG7H3Ucb3+WP0RjGTqb7I5yqLXR4TS0biuN5a5IR599mI7kmYpc5ihdoQo2JzhzfvblqctnUPryOiQcrfDT5QopSSwPnTyGoJk3jXL67Vh5I/iqCeE9WKkH8jFB/NdzO9Avej+yi1RrZe+S7XlGJyJiS7GFms//vFOY9YhKAKf6bf79Au0EZczO4OKveiBdlWf9rSd080m/VhxeEIk+xhy0nGIOeayrTxHz52MOcBeWRiwhS9QdMlU3an6+XC2GZbshjipV16s1NVj1TKV2RWcUfa9Wv9QAto2ug3N2uuyr7k3uu/QlyZh6IE7qURWa71E+3DS5Wo1Mbq3ebUgSeR2pIV0rYJR2syIyAI71XfEm35vrspf4G5FkiTH0P/kfp64uWX/anMdS8sBLKJCpZlQo3uxyyoTtL/oCsiUAQJzEc+cRBk2f82KO8Hhd2S2x5saGqh4LdUFxZP/UWX85YyA5uuxtokNnTZa/oiF4SB52NVjqp5Bj4hrPO0zRMA4yDsdvQ9QcSUpL2lqh5mkICpl1Um7GckYVfDV1KARzE6ERzitNQjfOMY4XBmDg/pCvK5DVzMOnmoatdJWaxEzg2hx9bdwJaNGFoQF1BZpzWWOyxwRwVqazgCk2u5iCGxEjXqZNKjT/QyejLtITzlSnMhOkT3pt4Y3 X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230031)(4636009)(376002)(396003)(346002)(39860400002)(136003)(82310400011)(1800799009)(186009)(451199024)(40470700004)(36840700001)(46966006)(40460700003)(41300700001)(1076003)(107886003)(6666004)(7696005)(356005)(7636003)(478600001)(82740400003)(426003)(26005)(47076005)(2616005)(36860700001)(336012)(83380400001)(70586007)(2906002)(40480700001)(54906003)(6916009)(316002)(86362001)(70206006)(36756003)(8936002)(5660300002)(4326008)(8676002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2023 15:09:24.1076 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7c491fe5-6c19-41fe-8b02-08dbaeeb417f X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF00003439.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7653 Received-SPF: softfail client-ip=2a01:111:f400:fe5b::613; envelope-from=avihaih@nvidia.com; helo=NAM12-BN8-obe.outbound.protection.outlook.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, 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Background snapshot allows creating a snapshot of the VM while it's running and keeping it small by not including dirty RAM pages. The way it works is by first stopping the VM, saving the non-iterable devices' state and then starting the VM and saving the RAM while write protecting it with UFFD. The resulting snapshot represents the VM state at snapshot start. VFIO migration is not compatible with background snapshot. First of all, VFIO device state is not even saved in background snapshot because only non-iterable device state is saved. But even if it was saved, after starting the VM, a VFIO device could dirty pages without it being detected by UFFD write protection. This would corrupt the snapshot, as the RAM in it would not represent the RAM at snapshot start. To prevent this, block VFIO migration with background snapshot. Signed-off-by: Avihai Horon Reviewed-by: Peter Xu --- hw/vfio/migration.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/hw/vfio/migration.c b/hw/vfio/migration.c index 20994dc1d6..da43dcd2fe 100644 --- a/hw/vfio/migration.c +++ b/hw/vfio/migration.c @@ -340,7 +340,8 @@ static int vfio_save_prepare(void *opaque, Error **errp) VFIODevice *vbasedev = opaque; /* - * Snapshot doesn't use postcopy, so allow snapshot even if postcopy is on. + * Snapshot doesn't use postcopy nor background snapshot, so allow snapshot + * even if they are on. */ if (runstate_check(RUN_STATE_SAVE_VM)) { return 0; @@ -353,6 +354,14 @@ static int vfio_save_prepare(void *opaque, Error **errp) return -EOPNOTSUPP; } + if (migrate_background_snapshot()) { + error_setg( + errp, + "%s: VFIO migration is not supported with background snapshot", + vbasedev->name); + return -EOPNOTSUPP; + } + return 0; }