From patchwork Thu Aug 31 12:56:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 13371532 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 65CDEC83F12 for ; Thu, 31 Aug 2023 13:12:13 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qbhG2-0003l5-UD; Thu, 31 Aug 2023 08:58:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbhEp-0002he-BV for qemu-devel@nongnu.org; Thu, 31 Aug 2023 08:57:31 -0400 Received: from mail-dm6nam04on20608.outbound.protection.outlook.com ([2a01:111:f400:7e8b::608] helo=NAM04-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 1qbhEj-0005DJ-Kq for qemu-devel@nongnu.org; Thu, 31 Aug 2023 08:57:31 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JIZhyGAJtb4N6rUlOyBEHuXB4F1fpJ4euAqIKe+ut8GZ5+tlr+R2qyDikD2pvJmBlhjRnFz/ua+BF5tiFgpasAcab/paDdAygjCUzzdgkYt+GYmrSbnGnWFbGLcJeW4TZ4GNYDbSBSfjtq//XZ2NR3PT0N7zrgfx1saKHStUdjlhcATM5G2HhcJTeh2ZUIA9YfIR/7C5TCb8wQc44DKKw/Z9AzEa/oRV5W/Lvo9voT6GHZrM2uo5xD+xQeQNJxllru697IavOah0+ZrzHjb7b5JK+XGpPcNVP9GDBYWb7HCzf7GTsE4EPJCf5EZbkMe87w29GqXzk081FRESyuCivQ== 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=KtmFtbUZOFDNz49dlqUcCjn4p47WvFLN5EI4PfGa5a+b4SIWn8IFK6gJmXTK8qvzh2s29+G+1UGi1i+qoD/YZSUFvjCVTsBnUiz3AGwRPq+gaPT9kg3gJLIJY4oa9BWGTAhAMyb56MRqbEw3mWqrwy71Mib6QYjyij/yYZoO1/TvJRJV6OC22sw5Tw2K/ngCFujgnhXuFv50zjyZMQAqfaUkfZ013R0s51mSQbCl6HvJohWceOGLquic3w/rIsHkcEL2nMLQi9/87dUM1j9Ia6HbOriY4GTkRuTdZQmgp+iEEOeTGv1lk9LBMX5SLnm2bApSTyaKDSxKt6V93WNRjQ== 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=jvyyngd7FfVNeRyt7xrSL/FW17XxSoEYV8VAx5jok/Q=; b=nGXKOIBGnuoh67ASDZcN/UxqDymHtBN+PIObF2k/+gXhj1t7pdkSSiWVFbgUKmK3QJ6/PGZHDPcmN4EqytnQDsJse7J+DpLZpgPkqbl+GINam6dGMm6qTwtxQaGkBvrMkKzsB0GKlWPKJ0Pg8QUTz36hYZ6nhQEHKLwwIxfkdzXTpzkSTS1jm/wK7QtQ//ReKaCpbdUf0cw+EhYyuUPgAN71cSt2AVhOUKuEy+26onK6z2W14hF0qTIsXV3Thei7bz1gZI2Q5nfiblj+V/+Om00L8JPe2+WgqiQt/SsgcXiOvNp/oT+ilYcIfA2TcMowrDuqFvjFy9XyV+Kmpcmikw== Received: from DM6PR17CA0014.namprd17.prod.outlook.com (2603:10b6:5:1b3::27) by DS7PR12MB6168.namprd12.prod.outlook.com (2603:10b6:8:97::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.35; Thu, 31 Aug 2023 12:57:21 +0000 Received: from CY4PEPF0000EE3E.namprd03.prod.outlook.com (2603:10b6:5:1b3:cafe::f7) by DM6PR17CA0014.outlook.office365.com (2603:10b6:5:1b3::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.20 via Frontend Transport; Thu, 31 Aug 2023 12:57:21 +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 CY4PEPF0000EE3E.mail.protection.outlook.com (10.167.242.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.17 via Frontend Transport; Thu, 31 Aug 2023 12:57:21 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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; Thu, 31 Aug 2023 05:57:08 -0700 Received: from rnnvmail204.nvidia.com (10.129.68.6) 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; Thu, 31 Aug 2023 05:57:07 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Thu, 31 Aug 2023 05:57: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 v2 1/5] migration: Add migration prefix to functions in target.c Date: Thu, 31 Aug 2023 15:56:58 +0300 Message-ID: <20230831125702.11263-2-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230831125702.11263-1-avihaih@nvidia.com> References: <20230831125702.11263-1-avihaih@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE3E:EE_|DS7PR12MB6168:EE_ X-MS-Office365-Filtering-Correlation-Id: b7d33d7b-38a5-41f1-a14e-08dbaa21d0a4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5D+6m9KOWUepL8E3/3Z2BjR8/BsVoav/EF83pSE0RjGV5qpmwdy+WZoRBqXVHstRM2prbju9WpIhlGJCk2penxRSMXMNbsF3qBEbFO9ivfPEKSqCPMrxJ2qdx/lRJwFfuOSou2neiJvLiQN0EdofjRJpzwQNf18m6jrYwCqW6LymBoacOIX4Ihv8zcoMhnFIgFcRUP3RlzIg5W4CpjDNShr9aw+Uy8LZF0Y78MuhUNsyCRjw4cJg8uhAruszVfxUKxC5Hiz6rob0pUzUsIEis9zXD8cVwFYeQKI0Yn9dRQpwRwxk05l6ObeclCF7ppElngOElQEcKn750RU97+nwsVDctlZQVWFJJnrWkgVh+Mq31E3Nvezd8o7EyczyTlB+3PsZHpyG/KYW02souFUN30Ew8/cBImgBmzbwKsuOmvmQWSm6PZqPmoJNabi5VxR7lzmJVtR4xwpvNdi1fxTShTuqIniw+MTyC5J3JCfAhqmTvNp++B6plyauVS3s4oPANll5k0ifs2lQ8kf50Ryckoqh34QcFBP9FLqk0oAjXQYZm0B0Tg3ETUdVdSZ4b8NuZmovtsfhnx5GqEhXBdv7qJAkeOOD+kW2/4RoAhjYFZmwin0DcrHL62me6KVCGvP6sndjClQS1OBzznnxJ00sgNMDREJdPtRvNdZub96+uZV2AWPGAD3WZuMCpV10MjS/qHBeSQh/quP72AgW3hej6wIluhF1KEgC3HmDOFQRu3rPrA4hW/GgH0kIwBF1Qx6N 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)(39860400002)(346002)(396003)(376002)(136003)(451199024)(82310400011)(1800799009)(186009)(46966006)(36840700001)(40470700004)(40460700003)(41300700001)(316002)(8676002)(4326008)(426003)(66574015)(336012)(2616005)(2906002)(47076005)(86362001)(107886003)(5660300002)(83380400001)(36756003)(1076003)(26005)(36860700001)(6916009)(40480700001)(8936002)(6666004)(82740400003)(7636003)(356005)(7696005)(54906003)(478600001)(70586007)(70206006); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2023 12:57:21.2743 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b7d33d7b-38a5-41f1-a14e-08dbaa21d0a4 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: CY4PEPF0000EE3E.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6168 Received-SPF: softfail client-ip=2a01:111:f400:7e8b::608; envelope-from=avihaih@nvidia.com; helo=NAM04-DM6-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 Thu Aug 31 12:56:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 13371498 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 A78B6C83F01 for ; Thu, 31 Aug 2023 12:59:54 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qbhFV-0003C0-V6; Thu, 31 Aug 2023 08:58:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbhEs-0002lI-FV for qemu-devel@nongnu.org; Thu, 31 Aug 2023 08:57:35 -0400 Received: from mail-dm6nam11on20614.outbound.protection.outlook.com ([2a01:111:f400:7eaa::614] 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 1qbhEl-0005Do-9K for qemu-devel@nongnu.org; Thu, 31 Aug 2023 08:57:34 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZHdWEsE8m/ghnWK5t16xLJ+OVORU5aqx8Q7MFoHKbnQS7p2Pu7ZyhfGgmzdMATdtO2nmy3LnFAanycUImMelSPyS8N0k1U6BFZu8RpVM+1rnqtMYJPG9GMAIaRGV5SbWQA2ksA6FbcjeIB5SfRafb18B4J2QAKkVS99v2olSv9LmNfX3+zysyXKOO3rMDlPnSkFU/IR/VKuUYCGoxtmypAzrI9plqE6j5hoqC62DrVOy0ycpVG5Y7l8bqzbpFIZFvQKjbMlu2gOyt2FJZ2a/SVk+vTqGIJna1d9ZCjCz/og5wSt6LHpacz0ZVrB1gso13ftAdYqtOcEP3AtAMrJuZw== 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=jlc1uOstOKWUB38XnFivSF+QU8pTrEmA7BHCnFzNG7TflPS+MhO3w/jlQQIhwx7SAtg1v0jauBz4HihoVR4NqOnyrf7neEcMZPxyxWppj7gieY2OAUabzKdebVdXE2G8pApKrgjaOLsb/hx0g8laK4FLaKBsrCppU0u+XS64s4w4xUtDu1fpESoFizn2Xt/R8e+APjDJQkw+UsaF9wvPrzYABAg8s9ry+IOet7D3KfEw4ywVNqt61zgL5V/Y6qQqYKa+uqKBVHajjzISP6NzSm51Enoea5Ata7KlTIxEo+VWOjuRLfyvsYZfJ8e1MEyelIzNh6yZTcsBgcPCw5Hk1A== 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=FotuBtmavqR9dkaD1yotgN9OXacIbAe0HgjsL8Lx8Hk=; b=gtrki8whTLrbU6x9jkkZxrXupdux9opGishH4v8xGf0UPw+nipk0+jX7w+d1Q9eMbEMzXlomNH53Ln6mez/c9PJ/XA9qmmTSuHY7MgNxPZaGp08ZwoQ9TB566OkikGTm8N/3qT9KysJerkw4QUtyVGN2tYydvfoVFp7C7XW9yryIx5KCHG/+o+bGUYm9cmynu6GoZwxXXAWGRe+q7Qvzrzyyc3/ryykytUfydTGAJyn6ClVn4JQzmNz656icI1DSyC+W8lCsqGRkUnfUBH6139z9ozok/uZ9YsTadqAOdkWnLqDY86enH9g2WjRp3rZnVWG2AZARidV2LD1wVO+CUA== Received: from MW4PR03CA0059.namprd03.prod.outlook.com (2603:10b6:303:8e::34) by BL1PR12MB5222.namprd12.prod.outlook.com (2603:10b6:208:31e::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.22; Thu, 31 Aug 2023 12:57:22 +0000 Received: from CO1PEPF000044F9.namprd21.prod.outlook.com (2603:10b6:303:8e:cafe::21) by MW4PR03CA0059.outlook.office365.com (2603:10b6:303:8e::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.21 via Frontend Transport; Thu, 31 Aug 2023 12:57:21 +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 CO1PEPF000044F9.mail.protection.outlook.com (10.167.241.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.2 via Frontend Transport; Thu, 31 Aug 2023 12:57:21 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) 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; Thu, 31 Aug 2023 05:57:10 -0700 Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Thu, 31 Aug 2023 05:57:10 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Thu, 31 Aug 2023 05:57:08 -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 v2 2/5] vfio/migration: Fail adding device with enable-migration=on and existing blocker Date: Thu, 31 Aug 2023 15:56:59 +0300 Message-ID: <20230831125702.11263-3-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230831125702.11263-1-avihaih@nvidia.com> References: <20230831125702.11263-1-avihaih@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F9:EE_|BL1PR12MB5222:EE_ X-MS-Office365-Filtering-Correlation-Id: b4da71d9-231a-4162-a1d7-08dbaa21d0e8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xD5usAsbKv4EcWj4rzSezK4RXF+uo/HP9/7qewgXa+nKdOwNRnSzB34StbGKJyhYmVejvN28mZ/RHmI6sb5ngrqDERLoz7niqWDZJtJSOEwoWQpTTSX6HCxoE/4FXkxGAAMaLgL03iRA6zC1cqakzM1IbyQsH4nqrMawEw1pX3I1zrl93cDthstUUB3hCNxwQd6etaMv1pMR4TfzMpf+FqPRAZKDOJdRcx5iCLiYiKcWiYYCpJbgiDGLYalYveAugaySGxaeFcA88zR3MkxStSKrEjEpyjm7h4R4vYg94wjkb1IKNU/8d7/K626qKu5QGL9K+HvXUCAsDCof4rPf6XP5gzd36gMvEILFXDI+a/fLkBog7Lm0b3CpJ3sPbY9kLfPpvE6FNAt7QkOxeK7DWjlH5bVuaJuAvUvjaFGbPkHhWkpzsqAlmFDvguqHqwCKjS+Gx43WXQ/E0hKQW4B8+NexEc2/Cr2A5zvM5wNFoDP89PROvwXd9FZ9EPivJsUESTgxrsNyH6OWAr08F3G3UFJIHZxLw7lkTelKG4vlJZ36Fp75yg4gQYViZcE7oT14VfK1UYeCjb7EV4Bj2eySd2LpfmY6Y0B6L6A6eq26RbFD5wn0/CaXLCbVFw0qeGD745qMVVo/ImyXy1G9TsQyPFxfyzehE0B1GUN0BaFHxvB+yoqL5mDoRnKiW88PKVxz2QtECLLp1plg/hQVtINO/wtYqMoYesL5TlSY2KSRaxr4rnO9Eik2ZFcUmEjgsxP7 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)(346002)(39860400002)(136003)(396003)(376002)(1800799009)(186009)(82310400011)(451199024)(36840700001)(40470700004)(46966006)(41300700001)(70586007)(70206006)(40460700003)(86362001)(2906002)(6916009)(54906003)(316002)(66574015)(4326008)(8936002)(8676002)(107886003)(2616005)(26005)(1076003)(36756003)(426003)(5660300002)(336012)(40480700001)(83380400001)(82740400003)(7636003)(356005)(6666004)(36860700001)(478600001)(7696005)(47076005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2023 12:57:21.7512 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b4da71d9-231a-4162-a1d7-08dbaa21d0e8 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: CO1PEPF000044F9.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5222 Received-SPF: softfail client-ip=2a01:111:f400:7eaa::614; 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 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 Thu Aug 31 12:57:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 13371510 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 C1B0FC83F01 for ; Thu, 31 Aug 2023 13:07:40 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qbhHv-0007QC-KG; Thu, 31 Aug 2023 09:00: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 1qbhEt-0002lT-GR for qemu-devel@nongnu.org; Thu, 31 Aug 2023 08:57:37 -0400 Received: from mail-mw2nam12on20627.outbound.protection.outlook.com ([2a01:111:f400:fe5a::627] 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 1qbhEm-0005F8-ME for qemu-devel@nongnu.org; Thu, 31 Aug 2023 08:57:35 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FmQCTrgrB7LXaCsnSanaUq6swmP6AJFSgxU5NcgA2+RBrwh7G91kUd78ggji4bRBz9Nuj/73qGIkAXvGvuJJfG4ldEGX6xWsmSfh0SkuVh/xuruoqJ9Un3hlrbMeVo5o8J7zCw5gyDtE/dpaYR2aEnNYPZ8m6GCF6Hr7mm3a4qwGf0V2kuhY7UUGhOU1EZSIFEi8J8Qjk+0/toBy71aGoJXRf0Gar3/IT/duP8f5kUefhFH0wdIsBPXAvSyHQSvsWPOD7K43nYTz7jtFepFmhFIiYc4ENiFD0wvXwFhZZWYQzUSIZ4vGc9D1X9ZOYwltGfqIOZGFqDcjSHm5dAVgkQ== 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=6Ldz+kjyX5eCV58RPUVlmaZFVKCK91xCjZqK9I1y1jo=; b=OlEJ5DDTjxoE7IS6tQTu8rLxqEzt+XdeIP4qrD+A7LXYCZVv7UzO4shtv3g/cHY7LoGnT6efRt7o5AzyhZwsmjXeiKg0mtSd3stU7kHXAFmi6ODZlvU9/QiO8p/GLaXWKJZx/lFVb/aQsewgP4jnXTD5oSrHQLgEaKysj2cLjtilBS2QrG5VwNGkcxUT3AzIFfZ57Cka58lmy2jJzJ9Um+LBkpqIfx66X3BB9e/QSYMu4Cg7cMvlgmpVBmDH1rFdG1dG4aBO/dZ9kBVTZEpo6UwoHaa4qG0zLpxiIfWrgv2/BjzWGtcmz5H0al4GH+SG0dzCLG1lgUCub1zOqdEHQg== 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=6Ldz+kjyX5eCV58RPUVlmaZFVKCK91xCjZqK9I1y1jo=; b=KfNAOJLoT4z35yh8dXCF5gGeTtqlmfc8V7i9bA6i7VTukiVMpU0xTl2Q02pfInKuSfWEBcSXTYwS2GSv4Dc2mIAZxVXToweSmmhiNl1bCGqEO7CFC8Jj9AC6zQhLtgkAcUYLopn0fmTUMbs3UeuMs+sOVauH9zwWIqMT8arBkjyUagkyL7qAW2vIVaMmV0HN68+Ju6Oo8O1LRy7xxk4zTRbnc8nizASWrCahlrWpe1yVKFWXYFTmHL0u/+XOG94gH/fjFl65QgpYVNv8codavOxc7Ejo6kBZLIUlJNwAzBBSWeHJOVdAE5dI1l4jr3QiAHw8SmTFo4oIEqbqH73oWg== Received: from MW4PR04CA0112.namprd04.prod.outlook.com (2603:10b6:303:83::27) by DM4PR12MB8452.namprd12.prod.outlook.com (2603:10b6:8:184::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.18; Thu, 31 Aug 2023 12:57:24 +0000 Received: from CO1PEPF000044FA.namprd21.prod.outlook.com (2603:10b6:303:83:cafe::98) by MW4PR04CA0112.outlook.office365.com (2603:10b6:303:83::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.22 via Frontend Transport; Thu, 31 Aug 2023 12:57: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 CO1PEPF000044FA.mail.protection.outlook.com (10.167.241.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.2 via Frontend Transport; Thu, 31 Aug 2023 12:57: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; Thu, 31 Aug 2023 05:57:13 -0700 Received: from rnnvmail204.nvidia.com (10.129.68.6) 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; Thu, 31 Aug 2023 05:57:12 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Thu, 31 Aug 2023 05:57: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 v2 3/5] migration: Add .save_prepare() handler to struct SaveVMHandlers Date: Thu, 31 Aug 2023 15:57:00 +0300 Message-ID: <20230831125702.11263-4-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230831125702.11263-1-avihaih@nvidia.com> References: <20230831125702.11263-1-avihaih@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044FA:EE_|DM4PR12MB8452:EE_ X-MS-Office365-Filtering-Correlation-Id: b08c8a93-b841-4d8c-ede2-08dbaa21d29a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MSGJg8OAMxdqse7TcBnVCd4FxjmD6Jbvqdd8TAgy2EDOYkzSj/MqtFFV0w3Y4m4CpxDfo94C7Iq8eV/eP7YUaKka4DYfP9XbIClOdoDlIjCh+hXGLPu0f31aOvZ21XoE1Ay3drraFbRCu3ronw2wLA77ZZ2srNt2pgsUWCAcpwt748UeAmBzKUoaZ4Mhu0aAZuzTSwyiGLl3kTQ7VLhZAV+WTU6zz8rCp4/jUzkRo5FVBpCgu4Df6VshH471+tRskuveaDHynoYiwvHiDWDzOUJyISksHkiTbD2CG1KiR+Svwo3m8abvolrQh+fxFeVqBfCAze7UabyjysrEclT5DI5+q3SSRGEfoCs0YyCfqUNb3fFbi1zbCVyB4U59vTLsI+Ay6MsypYJngNAdD39fApf10mVrWqJO5xUp0kbV/tGJgD5aC25vuZzFS22Rc/8IiMVYnBi3uqQE3z+jcnn+mvDIm5OSV7Ow5IpeTsDoSD/2Q7PupulKYWL01Y2DfMQfcphSBRAsTs9hB2DdzzppbAsR3yjwMe62Z04OEWbPESqpDhZXBvp0Oo+bMv0jXWgEZBK4bGqQ6MvQUqsoq4FPSVOjBkrYet7boEjpnKZweYvpNFNLwthVp01hHNFrit4Rp4rtw80XLRCYKOePWFOfQNozO0mE5ZiRLlhPD1fezwaivoP7jlauC87yP+XR1MiSQOt41Pd2kWw8auKJ7SB6/lF+uK2l4BVBRlGExbeAHAvWiJPzPYlMWcOrtKx75/PGGCU8UDduiMQ3gzrB+0gtBg== 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)(346002)(396003)(376002)(136003)(451199024)(82310400011)(1800799009)(186009)(46966006)(36840700001)(40470700004)(40460700003)(41300700001)(316002)(8676002)(4326008)(426003)(336012)(2616005)(2906002)(47076005)(86362001)(107886003)(5660300002)(83380400001)(36756003)(1076003)(26005)(36860700001)(6916009)(40480700001)(8936002)(6666004)(82740400003)(7636003)(356005)(7696005)(54906003)(478600001)(70586007)(70206006)(142923001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2023 12:57:24.6131 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b08c8a93-b841-4d8c-ede2-08dbaa21d29a 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: CO1PEPF000044FA.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB8452 Received-SPF: softfail client-ip=2a01:111:f400:fe5a::627; 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 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. 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/savevm.h | 1 + migration/migration.c | 4 ++++ migration/savevm.c | 29 +++++++++++++++++++++++++++++ 4 files changed, 39 insertions(+) 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/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 92866a8f49..914783f07b 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1634,6 +1634,10 @@ static bool migrate_prepare(MigrationState *s, bool blk, bool blk_inc, migrate_set_block_incremental(true); } + if (qemu_savevm_state_prepare(errp)) { + return false; + } + migrate_init(s); /* * set mig_stats compression_counters memory to zero for a diff --git a/migration/savevm.c b/migration/savevm.c index 5bf8b59a7d..818510ec57 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,6 +1643,11 @@ static int qemu_savevm_state(QEMUFile *f, Error **errp) return -EINVAL; } + ret = qemu_savevm_state_prepare(errp); + if (ret) { + return ret; + } + migrate_init(ms); memset(&mig_stats, 0, sizeof(mig_stats)); memset(&compression_counters, 0, sizeof(compression_counters)); From patchwork Thu Aug 31 12:57:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 13371531 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 2DC23C83F12 for ; Thu, 31 Aug 2023 13:11:55 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qbhHN-0005Mw-NP; Thu, 31 Aug 2023 09: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 1qbhEt-0002lV-JP for qemu-devel@nongnu.org; Thu, 31 Aug 2023 08:57:37 -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 1qbhEo-0005GP-VL for qemu-devel@nongnu.org; Thu, 31 Aug 2023 08:57:35 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m2w+bBCv/GGjrPI7HrocA/hHfGcWNHEgFwVLlyXWG/5lxSKrM/X/74nj1uiBINUzj/oo0RUTVkpySvHgblCr6/j5KHHXyLFa3SR/k1Ne02IkhqGsFqrGEN/LmezAFfKRgeuSInf0H5sCncSG89SFk2JyI4ZDiS/Qm3OhOHjgpa5CDMOW86ny9cYjfaAcxPVimL2jvJpVpx8TZQifaBh8wvlo7geZLSMH0SNXGnTLYohEXLVxnnNDt9Yszc1d6997gDqmsJJVReH5TZBPkYFrNvZTlHUOYIwEtEUPfREfH5YHSbAQV2cIkb39ckjXsRCv7Ob6oeHYH2shQLiGiRiVpA== 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=/+w4eKVNZY3XK7OjkGs7r0f3qa3AFhJNPzBrdsO4ZVg=; b=SfAs53n72U/snHdrWnlVTN/xg9PWnvQPB5Dm7zj3/oPHYpKIWY5tESNA0iLMJ8V8iUB4gosCecrAUP3aRzQml2bTgdOXBTYmvnJDl1fcJJvmTSm2qV6GP3QY5aQEyRau0iUFzCkf0YcMHWLOzZK4HqW0WlgxWO8Bw6iOEBTXbbd0rHSERI87E8krsNjdqnBI7Vx54Ay1LdtN/zApsF5K0E9uewa3hSYf5xkz1aMYjfrWuk68S5Yxn7Vcn5RUdKB0dIJ8Dywl7tkWwnxQO6cTZmnmLkybNXeaC7K6MMocLRVruyqrUFbv8vAOcsEOFO1u9OXYDT4IohijwjtWHjnffA== 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=/+w4eKVNZY3XK7OjkGs7r0f3qa3AFhJNPzBrdsO4ZVg=; b=Eb9yA2KkhRTwmD0REEEJFVzGym76qWytVnA80Q0i1CW8n3ibYJ4dIpXW87osq0NmOn3LZG42MBAa4QIgCEZXL1VUbxtxfOcGZKI/yAaxcDqm4j1tqcwE8Ls7see2Wv3G0ck0e1lx0wGl5SD0FksL6PdqOLr6m0PKFKMKd/sIQ50pZSpZ1Z3DS1puC3uGqejmhZlJSMWyTG+4S6/NdXUf+gWqrlh3dZxICxGbuFawCwVEl8xwQGEuH+hK9w5ZW6THoV5af+9RACCWqoJQ6WmcJF81A+W9rbVPxuAViuM32uBKz6s6q28DxDT79yabpUK/XU+YgtvjYDIeXNhx//j7NA== Received: from MW4PR03CA0204.namprd03.prod.outlook.com (2603:10b6:303:b8::29) by DM6PR12MB5023.namprd12.prod.outlook.com (2603:10b6:5:1b6::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.20; Thu, 31 Aug 2023 12:57:27 +0000 Received: from CO1PEPF000044F7.namprd21.prod.outlook.com (2603:10b6:303:b8:cafe::22) by MW4PR03CA0204.outlook.office365.com (2603:10b6:303:b8::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.20 via Frontend Transport; Thu, 31 Aug 2023 12:57:27 +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 CO1PEPF000044F7.mail.protection.outlook.com (10.167.241.197) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6768.2 via Frontend Transport; Thu, 31 Aug 2023 12:57:27 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) 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; Thu, 31 Aug 2023 05:57:15 -0700 Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Thu, 31 Aug 2023 05:57:15 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Thu, 31 Aug 2023 05:57:13 -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 v2 4/5] vfio/migration: Block VFIO migration with postcopy migration Date: Thu, 31 Aug 2023 15:57:01 +0300 Message-ID: <20230831125702.11263-5-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230831125702.11263-1-avihaih@nvidia.com> References: <20230831125702.11263-1-avihaih@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F7:EE_|DM6PR12MB5023:EE_ X-MS-Office365-Filtering-Correlation-Id: 9d700624-7d72-4ee3-2c99-08dbaa21d41c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: q4FllNuK9taq+ViucraJ9XXmS1ICqjr34NzG6o/LG1NKz4ZkH9h0qB6CASb/k2FP2452s1SSRm9xPLnXj4bAeUxQJvjYgxYUdM3QVhRWuhcYVBhgLhwpJ3+yu//glmhWqhYxfML/nzs3lvIWb8gxyeuqOYil5egfFzTxGgxln05nvm1W9C4VCvIgjK0oA1A09hIgQ4/Lzt/X3D4jmFXneyAg00pQhO4Ehic6UgMs8FQkHV6o9eGrUqnzl+qP6CA8pVB4/wIOK6vKRQX0GLlFnUKtrE/gmWTOcXxNmF12ao6Ryfw6JebfDoclQmU+X1IZmPz+ViLhsLWOuJT0PBKzFReKkKoCW1Zqc/jZM2GES4gTR2/krWd4E9wbQyrQwfnLYaVMMeHDVkfjdNImAGdHBI8LbKVsiflbPaJ2yOZHZE41AJYMn7dgB/NF09v74cUrZXbm3bvkHm3xVsZ7wL+BnmPF2Qb19ioV/f+c5r85mjdBSKHQAKDYj8m6JglroZ82Bbb38noMRK7ICD4TwT4vd1G08BbnTgZg1Tse5i2M/YMPODl7a1qVMwutuIWmJHwd6FPxTq4bgIH77qTmDixDkhuYku9Vs6CaBHpaXvlXuS60U0XCOxib1d+yZFhKQ/2qL89oSLyl3M28rN+zFjKxCHl9lixrzbNf0HTFVnInBzat8DtsRXslIAKGawPhJqMpg1QSBIH2A6ORAyxacBFpWsq6D+9Jc9TEytSTe6YXWUmRsEwGcNl3X/8rFFTfnJl2 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)(376002)(396003)(39860400002)(1800799009)(451199024)(82310400011)(186009)(40470700004)(36840700001)(46966006)(36756003)(40460700003)(40480700001)(2616005)(83380400001)(8676002)(86362001)(41300700001)(4326008)(5660300002)(8936002)(6666004)(336012)(7696005)(1076003)(426003)(26005)(36860700001)(107886003)(47076005)(7636003)(478600001)(82740400003)(356005)(6916009)(70586007)(54906003)(70206006)(316002)(2906002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2023 12:57:27.1222 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9d700624-7d72-4ee3-2c99-08dbaa21d41c 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: CO1PEPF000044F7.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB5023 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 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 --- 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 Thu Aug 31 12:57:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Avihai Horon X-Patchwork-Id: 13371547 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 2D8BCC83F01 for ; Thu, 31 Aug 2023 13:13:49 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qbhHs-0006sb-ER; Thu, 31 Aug 2023 09:00:40 -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 1qbhF2-0002u2-Bt for qemu-devel@nongnu.org; Thu, 31 Aug 2023 08:57:46 -0400 Received: from mail-bn8nam12on2060a.outbound.protection.outlook.com ([2a01:111:f400:fe5b::60a] 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 1qbhEx-0005J0-9C for qemu-devel@nongnu.org; Thu, 31 Aug 2023 08:57:42 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H6tUxO62L4Guf3xLlgH4fPU5Xj+7hC9zZatKrmhprNdO3gJybuf122s/HXL/zSjHKT8oPbXy/oetfWFoA/CjOswyVyfR6GDNRFf3KJuRnUOgBIsSeZaVHcouz3zzM918Sk/BJC4Q14eZfwpIRQ1clUejM7GI31TYyrQ4ADOSyMiUi1kQLMEBDnRSKwyAhKaartJJ4m+3ZUOmUPl8QmJkU4IugUeigreptYnEIql6urYHmW5SvEGHNMqmoSzsgQ6lpJ1QtmD9bMK8AKOTf35PHPGNISIAjW8nunxGyvPKgOZO2rjXFYRzkr67jCZdix9Lnut84CdcZtwIVT/v1r6wfw== 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=EVsz7qyjfGTciYL0GienL0XaxUN0EYgW/kSLjyWZIg0=; b=nEvcWYvquGutJ+bqIn3fZn4EPWDWxGg1deEC7g39I3hS1iK78kJlNbhR4hUG3OeUBFlsMZlpQHEuQP/2AREZgpVqM7sgTXQuwLn1Kqdiby4hQxt1vIIsr/FdaDY+N1a4Nq0W8os7iOYk4Hk8rMEUGEznRCntk4m8xl8mXQ9l3BjLLvnyvBTH2iCQ7dyS5ZeQWpH83XlcEUSD25kM/EO8mQ6PhR4oS60RYyZioDojAaSUBxueOn1BOZcl7+AGy18p95mltokN6CHWKCK1tNEmD24gYqs9cKriGq1ozApKFmPC9+IDgGQ0w2QT6Hpu/Fas8a66qWullocVYO78H1QQ2A== 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=EVsz7qyjfGTciYL0GienL0XaxUN0EYgW/kSLjyWZIg0=; b=tfV8AP/7RDhCqscEH9lha3q4aT6KXFZFkmVZ/dEiVWURqoM5yRALFWnfBwLH8XfCwKFvKW7kNCWaP05q5OM/Uc1pUp76gvQbJXiVH5ZfCAmZ1tNqwfX7W3jgMwuX7a6wz639yMYIMAZlmQHy8fR0w51ai8Y+hNaCJB2FYgyZXEVSFAt5Kl3NCp8uK4zObFxni2WXx3Ywi+6fwpM18iEYrV8tvrbXLIIAZSYqMFlXXr82gbI46DiYBBvZFGidqszETuoftwfyjerz7rmZFLkvUbdZpHpXTBGjdpY4Y5wGdWB6YDBF920Sfp+LOPU4I/+Rc2Q8F64EP7sD2hk+te07lA== Received: from DM6PR04CA0009.namprd04.prod.outlook.com (2603:10b6:5:334::14) by PH7PR12MB6467.namprd12.prod.outlook.com (2603:10b6:510:1f5::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.34; Thu, 31 Aug 2023 12:57:33 +0000 Received: from CY4PEPF0000EE3F.namprd03.prod.outlook.com (2603:10b6:5:334:cafe::dc) by DM6PR04CA0009.outlook.office365.com (2603:10b6:5:334::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.20 via Frontend Transport; Thu, 31 Aug 2023 12:57:32 +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 CY4PEPF0000EE3F.mail.protection.outlook.com (10.167.242.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.17 via Frontend Transport; Thu, 31 Aug 2023 12:57:32 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) 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; Thu, 31 Aug 2023 05:57:18 -0700 Received: from rnnvmail204.nvidia.com (10.129.68.6) 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; Thu, 31 Aug 2023 05:57:17 -0700 Received: from vdi.nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Thu, 31 Aug 2023 05:57:15 -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 v2 5/5] vfio/migration: Block VFIO migration with background snapshot Date: Thu, 31 Aug 2023 15:57:02 +0300 Message-ID: <20230831125702.11263-6-avihaih@nvidia.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20230831125702.11263-1-avihaih@nvidia.com> References: <20230831125702.11263-1-avihaih@nvidia.com> MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE3F:EE_|PH7PR12MB6467:EE_ X-MS-Office365-Filtering-Correlation-Id: 9df120a8-994d-4381-f5cc-08dbaa21d764 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FLSBN8gtc4kIK24MBEvVE2UDWCTQUMdL92fMIc4127undcd/vBoIm6vvRt0qrBIRmjpRhAyFeQh7CN1iV7FOAc/YuMtD9RRo/2F5X12HAQUwF0UEkjLfSTp7+wS/+JEiGv/JiO/2crJfB2QsdvnumULY2TDQJk5KwOjQTzbgrNsnDQE8SkKxeK2E0guKJi60fBp/OuqztzAdhgdTnFQdfdixtAlcQ6GBpcvgC5PnJtv1F36EnCL4j7C2TKPyarsbiQunNwV+EDPdH01+BePPleF+h0b98kieiSV/JqpYVc0AA2WLkEd6tbHM7N7c8uU0AlUoM0G5tvveTAl/KS1BPYCpAG3dmiLPqCR7Zoz7DY8VGAU8jrV6kRNo0fsWW0WiUwIxQhDD1q7Aj2pu748cCJEbr8FoeQ/ifw0Q9MMAgmznaYw4NlfufgsKsZE75fLwZv56vf/MWt8rcjS+gSWvocOTiy2ynOfk786wrOSwvbBBBeXfTHwt1sDMju3/xt/QE836iQfNY4SP65wJK+v7NOAZoj7JJkarBBN642WeCw4HMMzwcU3IxGpfevw6jHlK9BZNG7JsjzaCpmiH6S4G2kwNSF+a//6AOt6IwDAJnPGs/gI2Cn1EEf1naelTfCc4V3aUwGEVNB9KGPGmBEoWoVXvU/KxHmAiMTEBf7t5vb9HRmPXwRm9KOK1w4ihrMPWWtPEfcLTsSyZy5vHHzr2xqQ5DnOEX3Xg8pN0jSushJPRhIEo5mmgVkL6axvu3dwG 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)(136003)(346002)(376002)(396003)(39860400002)(186009)(82310400011)(1800799009)(451199024)(40470700004)(36840700001)(46966006)(36860700001)(40460700003)(41300700001)(26005)(356005)(82740400003)(7636003)(6666004)(86362001)(83380400001)(478600001)(47076005)(336012)(426003)(1076003)(107886003)(7696005)(2616005)(40480700001)(70206006)(70586007)(6916009)(2906002)(54906003)(36756003)(316002)(5660300002)(8936002)(4326008)(8676002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2023 12:57:32.6011 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9df120a8-994d-4381-f5cc-08dbaa21d764 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: CY4PEPF0000EE3F.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6467 Received-SPF: softfail client-ip=2a01:111:f400:fe5b::60a; 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; }