From nobody Sun Sep 28 15:29:08 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1758549041; cv=none; d=zohomail.com; s=zohoarc; b=YoOqzQZvCoOJfjNuFMM6+CmOEfrkGf5iTAe+4+k122Cup8w+FXGw0CY/PfH5y5aJX3DOKSZ8Vu15RNyluODBoUnfAuVYnxbsGjhCyfqVUd+Vh22/KM5erG6s+3hlnIwGv2bLG54yXsmJJG9WeSHUXdpHbzKlH1d2ys4ofg0yiWM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758549041; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=a1OWDnMLDg8boXx6EnW3WJpFBvSqT8/lF0638NDHTDw=; b=Qgul7bK4Z+w0GRlxjCzCEMApVz7TdT0I9yLSCNLKoaO2KTOR9x2TW5SxQST0N/Dd+6+N8nZNrlms/xP5rgzzppSys4P3KPPrrquVrC0Si32p1qDAMHv5H1SPF7EfiX7wDOAMo+Lm3ur5udmrIi0uD1ykxTa0I/AcCghkAmq9jyc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 175854904128833.874121316093465; Mon, 22 Sep 2025 06:50:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0gvh-0000Tq-7N; Mon, 22 Sep 2025 09:50: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 1v0gva-0000QV-Bp for qemu-devel@nongnu.org; Mon, 22 Sep 2025 09:50:02 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0gvT-0001ti-1u for qemu-devel@nongnu.org; Mon, 22 Sep 2025 09:50:02 -0400 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 58M7NKHu006483; Mon, 22 Sep 2025 13:49:50 GMT Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 499kvttfmn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 Sep 2025 13:49:50 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 58MCMrcL034116; Mon, 22 Sep 2025 13:49:49 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 49a6nhan86-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 Sep 2025 13:49:49 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 58MDnlWD004351; Mon, 22 Sep 2025 13:49:49 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 49a6nhan6x-2; Mon, 22 Sep 2025 13:49:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :date:from:in-reply-to:message-id:references:subject:to; s= corp-2025-04-25; bh=a1OWDnMLDg8boXx6EnW3WJpFBvSqT8/lF0638NDHTDw=; b= m7peNvEpdWJWWx16SmsiO5beBcqIwtsXHrG4iKEBU5/+/7vfF85jnuAfhUFYqmjk DfcgLw4LxG5/GcYn995GRwho7OHpFM5rm0BGhoyOqOYuOMHDIgC5LjF0DS5Yz0fX tKDoJiHQa9e5t26KGTfOhptCZLoDxnwCsf6GWwz3zxGUif7slOag9ddsg98h8thU qEwKij1k7GHaI7MYOP/FGI1S2vQ2O4GzjnjEzWZl/Qj/zvv7Okn4s6ncSDZke+ni h0C4Vbhp/kyL0XWvmznXKCeu0KJhuO2KSO3K2EVUkRDyMh9ikPmy8H6cLKATIa/b nww5fxwRfINQmh2+ZwOeow== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Peter Xu , Markus Armbruster , Paolo Bonzini , Eric Blake , "Dr. David Alan Gilbert" , Cedric Le Goater , Alex Williamson , Steve Sistare Subject: [PATCH V4 1/8] migration: multi-mode notifier Date: Mon, 22 Sep 2025 06:49:38 -0700 Message-Id: <1758548985-354793-2-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1758548985-354793-1-git-send-email-steven.sistare@oracle.com> References: <1758548985-354793-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1117,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-09-22_01,2025-09-22_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 mlxscore=0 spamscore=0 malwarescore=0 phishscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2508110000 definitions=main-2509220135 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwOTIwMDAyNSBTYWx0ZWRfX/Qe2ZnnjzvI5 M95mU5YM4OhUfWRi2qOQKbY6wEs28p9LUG4X9YzECVxyjHcdYxbYZoYHkOpy+znyOjiTLSxmpbl LwXtHySknXKxckP3eXoHKxv0rSNWPE3N4qwlATjgU9F2Fj3NBfDCYsdwCsdmm928uO2p2F9PDvW WmUXr7EfD8ISG035cl7ppEDxUARiaTF7akwIWdKnlfVp4i9fsiHl9qFRJREtGGFevv6REAU6yNO ELOVvrylyZWpkQl50iJLjFqvq+j2hTWM+u7dqskBnYbfTPMH0XIHpVXL7k9OM++uUIQvYu+9NpQ tK3S3epdOlV6T7g64Es5dPwZ+fx9qjmhBOf+xZ2+BU1WvtCsWZZaEBOXgFTZs4u7EBywv/wnEtJ jWVmNmyOdEB1jmf2o2FBeYKzCFufYQ== X-Authority-Analysis: v=2.4 cv=UPPdHDfy c=1 sm=1 tr=0 ts=68d153fe b=1 cx=c_pps a=e1sVV491RgrpLwSTMOnk8w==:117 a=e1sVV491RgrpLwSTMOnk8w==:17 a=yJojWOMRYYMA:10 a=yPCof4ZbAAAA:8 a=qm0lDVemfS40E2rT5CEA:9 cc=ntf awl=host:13614 X-Proofpoint-GUID: Ga9aDgP-61HG5lJfm8DQqM3p0By6obAZ X-Proofpoint-ORIG-GUID: Ga9aDgP-61HG5lJfm8DQqM3p0By6obAZ Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=steven.sistare@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1758549043678116600 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Allow a notifier to be added for multiple migration modes. To allow a notifier to appear on multiple per-node lists, use a generic list type. We can no longer use NotifierWithReturnList, because it shoe horns the notifier onto a single list. Signed-off-by: Steve Sistare Reviewed-by: Fabiano Rosas --- include/migration/misc.h | 12 ++++++++++ migration/migration.c | 60 +++++++++++++++++++++++++++++++++++++-------= ---- 2 files changed, 59 insertions(+), 13 deletions(-) diff --git a/include/migration/misc.h b/include/migration/misc.h index a261f99..592b930 100644 --- a/include/migration/misc.h +++ b/include/migration/misc.h @@ -95,7 +95,19 @@ void migration_add_notifier(NotifierWithReturn *notify, void migration_add_notifier_mode(NotifierWithReturn *notify, MigrationNotifyFunc func, MigMode mode); =20 +/* + * Same as migration_add_notifier, but applies to all @mode in the argument + * list. The list is terminated by -1 or MIG_MODE_ALL. For the latter, + * the notifier is added for all modes. + */ +void migration_add_notifier_modes(NotifierWithReturn *notify, + MigrationNotifyFunc func, MigMode mode, = ...); + +/* + * Remove a notifier from all modes. + */ void migration_remove_notifier(NotifierWithReturn *notify); + void migration_file_set_error(int ret, Error *err); =20 /* True if incoming migration entered POSTCOPY_INCOMING_DISCARD */ diff --git a/migration/migration.c b/migration/migration.c index 10c216d..08a98f7 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -74,11 +74,7 @@ =20 #define INMIGRATE_DEFAULT_EXIT_ON_ERROR true =20 -static NotifierWithReturnList migration_state_notifiers[] =3D { - NOTIFIER_ELEM_INIT(migration_state_notifiers, MIG_MODE_NORMAL), - NOTIFIER_ELEM_INIT(migration_state_notifiers, MIG_MODE_CPR_REBOOT), - NOTIFIER_ELEM_INIT(migration_state_notifiers, MIG_MODE_CPR_TRANSFER), -}; +static GSList *migration_state_notifiers[MIG_MODE__MAX]; =20 /* Messages sent on the return path from destination to source */ enum mig_rp_message_type { @@ -1665,23 +1661,51 @@ void migration_cancel(void) } } =20 +static int get_modes(MigMode mode, va_list ap); + +static void add_notifiers(NotifierWithReturn *notify, int modes) +{ + for (MigMode mode =3D 0; mode < MIG_MODE__MAX; mode++) { + if (modes & BIT(mode)) { + migration_state_notifiers[mode] =3D + g_slist_prepend(migration_state_notifiers[mode], notify); + } + } +} + +void migration_add_notifier_modes(NotifierWithReturn *notify, + MigrationNotifyFunc func, MigMode mode, = ...) +{ + int modes; + va_list ap; + + va_start(ap, mode); + modes =3D get_modes(mode, ap); + va_end(ap); + + notify->notify =3D (NotifierWithReturnFunc)func; + add_notifiers(notify, modes); +} + void migration_add_notifier_mode(NotifierWithReturn *notify, MigrationNotifyFunc func, MigMode mode) { - notify->notify =3D (NotifierWithReturnFunc)func; - notifier_with_return_list_add(&migration_state_notifiers[mode], notify= ); + migration_add_notifier_modes(notify, func, mode, -1); } =20 void migration_add_notifier(NotifierWithReturn *notify, MigrationNotifyFunc func) { - migration_add_notifier_mode(notify, func, MIG_MODE_NORMAL); + migration_add_notifier_modes(notify, func, MIG_MODE_NORMAL, -1); } =20 void migration_remove_notifier(NotifierWithReturn *notify) { if (notify->notify) { - notifier_with_return_remove(notify); + for (MigMode mode =3D 0; mode < MIG_MODE__MAX; mode++) { + migration_blockers[mode] =3D + g_slist_remove(migration_state_notifiers[mode], notify); + } notify->notify =3D NULL; } } @@ -1691,13 +1715,23 @@ int migration_call_notifiers(MigrationState *s, Mig= rationEventType type, { MigMode mode =3D s->parameters.mode; MigrationEvent e; + NotifierWithReturn *notifier; + GSList *elem, *next; int ret; =20 e.type =3D type; - ret =3D notifier_with_return_list_notify(&migration_state_notifiers[mo= de], - &e, errp); - assert(!ret || type =3D=3D MIG_EVENT_PRECOPY_SETUP); - return ret; + + for (elem =3D migration_state_notifiers[mode]; elem; elem =3D next) { + next =3D elem->next; + notifier =3D (NotifierWithReturn *)elem->data; + ret =3D notifier->notify(notifier, &e, errp); + if (ret) { + assert(type =3D=3D MIG_EVENT_PRECOPY_SETUP); + return ret; + } + } + + return 0; } =20 bool migration_has_failed(MigrationState *s) --=20 1.8.3.1 From nobody Sun Sep 28 15:29:08 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1758549148; cv=none; d=zohomail.com; s=zohoarc; b=KUpZM7gUs5b4a5bal7JYK9TmqVQYyyxJLyfEeASpE/frpxjuSzmxSY22dONE5b3vy5q7pBXcMe6YcaOFiBIkDcQWcwSuxecjJmoyq9LRjr3gcFsuKLhHD+Zuvg7mu735nMr97PZRHsL/F2K4HCree+FRnKeAKJ075vsUfml3FDo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758549148; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=2bWnxhTfby+JfYwTzPOe6ikvJvlzOf50/3Bo9FgmuXY=; b=BF2smP3itSztHQPyBHVocJvmIjYvGMj2+iJkG+CfbtP9c0seB7UqkLOu/U7oHCt3d03PvwMWquuaZkDsbThsejz3eNvP2WF+eEe6N9kXXroMpY4/Qvu2xuEJLBagoPqWQ+IrAZ28HLzppYgckWTkbMqWh9rwVl5e9OEc5jzH8U8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758549148637993.8893503009298; Mon, 22 Sep 2025 06:52:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0gvh-0000Tp-56; Mon, 22 Sep 2025 09:50: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 1v0gvZ-0000QE-1H for qemu-devel@nongnu.org; Mon, 22 Sep 2025 09:50:02 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0gvS-0001u0-HU for qemu-devel@nongnu.org; Mon, 22 Sep 2025 09:50:00 -0400 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 58M7NNsc024185; Mon, 22 Sep 2025 13:49:51 GMT Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 499jpdjg8p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 Sep 2025 13:49:51 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 58MCGFgP034388; Mon, 22 Sep 2025 13:49:51 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 49a6nhan8m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 Sep 2025 13:49:51 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 58MDnlWF004351; Mon, 22 Sep 2025 13:49:50 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 49a6nhan6x-3; Mon, 22 Sep 2025 13:49:50 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :date:from:in-reply-to:message-id:references:subject:to; s= corp-2025-04-25; bh=2bWnxhTfby+JfYwTzPOe6ikvJvlzOf50/3Bo9FgmuXY=; b= NQvdccYfVL5jq/ZkR111bxNufECVf3MD6fmxY0ZJjJZINL6TQ+4U6wgdykgk0Ujw BfB6xas9VM3rDb4Bsf2RMCvKIPDPFk7zzEyZu1eMi9JEAp5r3bjtz1o1wVM5Nlaf SF4sRzCc6EnasZOlC9sRILJrZmtkl4oE+KbE3CkPmFIgAYhVZTgI3gJxKfjYd/uc 0EuZFJBL3ueLNNqNvKA6GKNO5c7c65mSfy4C52hFT+zfTyKl96bhJFnh0s+kfHZg izkdDg0VZUtpPkW29pgapZu1kMPa5RvZlBUcEg9jUNcXKe7Fzd2NUoP0OcWw7cFJ ZgYmeXRMfwvnSkv54mkoyw== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Peter Xu , Markus Armbruster , Paolo Bonzini , Eric Blake , "Dr. David Alan Gilbert" , Cedric Le Goater , Alex Williamson , Steve Sistare Subject: [PATCH V4 2/8] migration: add cpr_walk_fd Date: Mon, 22 Sep 2025 06:49:39 -0700 Message-Id: <1758548985-354793-3-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1758548985-354793-1-git-send-email-steven.sistare@oracle.com> References: <1758548985-354793-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1117,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-09-22_01,2025-09-22_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 mlxscore=0 spamscore=0 malwarescore=0 phishscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2508110000 definitions=main-2509220135 X-Proofpoint-GUID: x1yL8aEv2pIU9zhWR_lXw7jXqChR34yy X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwOTIwMDAxMiBTYWx0ZWRfX+XJwVbkWD8fk K0/tiBKNEXrF0IHc9mjVauGZsmaMwncb6yHjrdY2ZFmunZ6MAAGuuusKszS8L/YUmOhy4VxyxJ4 54ZzG0CMMoGG6A0gD2zkZxrR/1YJnnZvIAeLL2l0KtPkrOxO2NuK/bbmJ0axMZm2KuDSmVk32PD YVkhdUVKTdJoW6BiipEWGUtINcFgfP1R/Xywk+x7MhiZM8t2JcU8+XTIzSfwVWm98yWvpV+fmSX hHWUbEmdjHJZERSEjOBG/j0Ip1jK4v5pIMETulBlaztfg6bQLJdgaoX6OX91ReKWEsRx/eGCDqg 0ruxrdcu6cvIznPyBFusWsO6QZSfERfqy0yPs3qAirOX6COWhufSMhupHjoRDSm/P6qD991dgO7 w78hPTfdtIEBUTMLEN9VgtNrvIT/1A== X-Authority-Analysis: v=2.4 cv=aJPwqa9m c=1 sm=1 tr=0 ts=68d153ff b=1 cx=c_pps a=e1sVV491RgrpLwSTMOnk8w==:117 a=e1sVV491RgrpLwSTMOnk8w==:17 a=yJojWOMRYYMA:10 a=yPCof4ZbAAAA:8 a=20KFwNOVAAAA:8 a=XbKixnoXw7dXUEClIQQA:9 cc=ntf awl=host:13614 X-Proofpoint-ORIG-GUID: x1yL8aEv2pIU9zhWR_lXw7jXqChR34yy Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=steven.sistare@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1758549150606116600 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add a helper to walk all CPR fd's and run a callback for each. Signed-off-by: Steve Sistare Reviewed-by: Peter Xu --- include/migration/cpr.h | 3 +++ migration/cpr.c | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/migration/cpr.h b/include/migration/cpr.h index 3fc19a7..2b074d7 100644 --- a/include/migration/cpr.h +++ b/include/migration/cpr.h @@ -34,6 +34,9 @@ void cpr_resave_fd(const char *name, int id, int fd); int cpr_open_fd(const char *path, int flags, const char *name, int id, Error **errp); =20 +typedef bool (*cpr_walk_fd_cb)(int fd); +bool cpr_walk_fd(cpr_walk_fd_cb cb); + MigMode cpr_get_incoming_mode(void); void cpr_set_incoming_mode(MigMode mode); bool cpr_is_incoming(void); diff --git a/migration/cpr.c b/migration/cpr.c index 42ad0b0..d3e370e 100644 --- a/migration/cpr.c +++ b/migration/cpr.c @@ -121,6 +121,19 @@ int cpr_open_fd(const char *path, int flags, const cha= r *name, int id, return fd; } =20 +bool cpr_walk_fd(cpr_walk_fd_cb cb) +{ + CprFd *elem; + + QLIST_FOREACH(elem, &cpr_state.fds, next) { + g_assert(elem->fd >=3D 0); + if (!cb(elem->fd)) { + return false; + } + } + return true; +} + /*************************************************************************/ static const VMStateDescription vmstate_cpr_state =3D { .name =3D CPR_STATE, --=20 1.8.3.1 From nobody Sun Sep 28 15:29:08 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1758549035; cv=none; d=zohomail.com; s=zohoarc; b=lwrUeCYAJwVd/urishnfhKqzXg6FXY8Esxals277pp6vAEsOYbXZggTsMQTHGt3vlQZ3MWiVMV1V9D2KAninp7sHHE+gKoLLmEtwCE3jTisCXmcGI632E3fFkl5eYInycedGDU6uuykwtgDdyRVNO1AUztZblQOdDaWfHlrvQjk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758549035; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=qLNHKUlUg3IKOiVVxtcSzwTwsfWTIOGy9gGV6FylCYI=; b=Lsh53k6va0b4C0BPaci5AufPUJaYvtH/TYywuQtwPDjmpHpcfgdAERJOgMy5rRHFlXNbI5obXGIKULd4PpzL9B4iSV3GXuhAL96ARmQ/ECukhl9BWAdiQ71DPFSFEiBwEikpSvXcbRlKIj6JS8oWRWYq1pkOdB6Je28n9WmB2E0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758549035258758.0144032084357; Mon, 22 Sep 2025 06:50:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0gvX-0000Ps-T5; Mon, 22 Sep 2025 09:49:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0gvW-0000Ph-P4 for qemu-devel@nongnu.org; Mon, 22 Sep 2025 09:49:58 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0gvT-0001uF-T3 for qemu-devel@nongnu.org; Mon, 22 Sep 2025 09:49:58 -0400 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 58M7NMAE006534; Mon, 22 Sep 2025 13:49:53 GMT Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 499kvttfmx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 Sep 2025 13:49:53 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 58MC2Hng034336; Mon, 22 Sep 2025 13:49:52 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 49a6nhan9a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 Sep 2025 13:49:52 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 58MDnlWH004351; Mon, 22 Sep 2025 13:49:51 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 49a6nhan6x-4; Mon, 22 Sep 2025 13:49:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2025-04-25; bh=qLNHKUlUg3IKOiVVxtcSzwTwsfWTIOGy9gGV6FylCYI=; b= Ce+Xb1ytsKiNrnfhIi0Rg+1ray+YUXIlT8Cg35xaZQhqEA4S8RDIEj8tLQwUIvMv YWgXhX1/SLhrg+y3YQm4Fd/nkaYDQXM0RMt14y+C/XUNI/Z5n3eTVjxv/xh3e0pj hW39eyMZKOeP22DMyIXHMEfslHA2ZxGIAMq4u7NbDT6bU9LYErW22vghA+oJExLD z32naFnk8aMIXUymeBO+98XQDtkU+YA5e8SrxvfNab5T7JLkdDDjfxX9tnnfu1W2 stUgH9darr5DpT7Y7iccTNbAPsTmNt5J7xP6omVgbi/km03aWSW7akgiqJDqc6Gu IHElx2RGQh3PQq6XEeeEOQ== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Peter Xu , Markus Armbruster , Paolo Bonzini , Eric Blake , "Dr. David Alan Gilbert" , Cedric Le Goater , Alex Williamson , Steve Sistare Subject: [PATCH V4 3/8] oslib: qemu_clear_cloexec Date: Mon, 22 Sep 2025 06:49:40 -0700 Message-Id: <1758548985-354793-4-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1758548985-354793-1-git-send-email-steven.sistare@oracle.com> References: <1758548985-354793-1-git-send-email-steven.sistare@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1117,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-09-22_01,2025-09-22_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 mlxscore=0 spamscore=0 malwarescore=0 phishscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2508110000 definitions=main-2509220135 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwOTIwMDAyNSBTYWx0ZWRfX8hN8TxdVL8e1 nT6awQCEDNAmy/Y7MxhCAI2MZDVMs2iZ+jaAXL77F3QOYLocD0f4X2f9jM67qgxcHURoFdOvsKu NSCskU8JJV88IiD6MdAEdWgWiyaFk3cV/OLJLhIk4T8/KtLKqqqmuT7yjmShfJ0JFq6cPeCL5mr 0X4dMltJU5aFbI8ko9D9p3hVEQdiyaodah0gvyqkhPS0GWNe74/R0O6bbUjHCmw4OzbGUmF+zjR E1Ego7FtgeysxdnrJIJGhSq12LI5gM+BNG8M28TWQ6Z7EqSFLp4OUyId27g/IHSL8lpNehxSqKm 2NfPbO3YZjTw6KPfe0EKCTHnGkqRkFJhNat6U4yCIDxkF5kmXRBIpsbUclQwiRNn7uFGpxO25Dq 6WdyXnGH4E+MyGF4rjcAqMyFSLlrYw== X-Authority-Analysis: v=2.4 cv=UPPdHDfy c=1 sm=1 tr=0 ts=68d15401 b=1 cx=c_pps a=e1sVV491RgrpLwSTMOnk8w==:117 a=e1sVV491RgrpLwSTMOnk8w==:17 a=IkcTkHD0fZMA:10 a=yJojWOMRYYMA:10 a=yPCof4ZbAAAA:8 a=20KFwNOVAAAA:8 a=eRAJs6dweEk5O_tl00MA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 cc=ntf awl=host:13614 X-Proofpoint-GUID: OTB-cUUrGNnIQakcpuSLp0Y6WbVzMZeI X-Proofpoint-ORIG-GUID: OTB-cUUrGNnIQakcpuSLp0Y6WbVzMZeI Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=steven.sistare@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1758549037397116600 Define qemu_clear_cloexec, analogous to qemu_set_cloexec. Signed-off-by: Steve Sistare Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Fabiano Rosas --- include/qemu/osdep.h | 9 +++++++++ util/oslib-posix.c | 9 +++++++++ util/oslib-win32.c | 4 ++++ 3 files changed, 22 insertions(+) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index be3460b..8dac4ed 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -688,6 +688,15 @@ ssize_t qemu_write_full(int fd, const void *buf, size_= t count) =20 void qemu_set_cloexec(int fd); =20 +/* + * Clear FD_CLOEXEC for a descriptor. + * + * The caller must guarantee that no other fork+exec's occur before the + * exec that is intended to inherit this descriptor, eg by suspending CPUs + * and blocking monitor commands. + */ +void qemu_clear_cloexec(int fd); + /* Return a dynamically allocated directory path that is appropriate for s= toring * local state. * diff --git a/util/oslib-posix.c b/util/oslib-posix.c index 4ff577e..4c04658 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -307,6 +307,15 @@ int qemu_socketpair(int domain, int type, int protocol= , int sv[2]) return ret; } =20 +void qemu_clear_cloexec(int fd) +{ + int f; + f =3D fcntl(fd, F_GETFD); + assert(f !=3D -1); + f =3D fcntl(fd, F_SETFD, f & ~FD_CLOEXEC); + assert(f !=3D -1); +} + char * qemu_get_local_state_dir(void) { diff --git a/util/oslib-win32.c b/util/oslib-win32.c index b735163..843a901 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -222,6 +222,10 @@ void qemu_set_cloexec(int fd) { } =20 +void qemu_clear_cloexec(int fd) +{ +} + int qemu_get_thread_id(void) { return GetCurrentThreadId(); --=20 1.8.3.1 From nobody Sun Sep 28 15:29:08 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1758549117; cv=none; d=zohomail.com; s=zohoarc; b=ICDKplx45ts2Gp/ZBpI48n3fJRmjpba/4L+xfsf791n6oMvq8rqwglH/FlaNpXXsz+IpP6he5VIRX9Se41V8mH1pAa+dgTyLDXW+314YFgwpduvGkKtRE2nP24tqHRwWf6/61hHdDcQqoV9tCL+Yv6JHvb89M3xGvglRes7V9Dk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758549117; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=VggucWXHRsV9x5Cmy/z6Zo3PNEb1fQUeyB+8KnvYUxE=; b=Fekm0XL7LtQsauR9L3s0234m6ExtEd8pF9zp0bqABlfz9KF9tcSD2q4GeIMIJmUN6hghyGYYT79dUA4k/d6eyKhKfSuDOUwemjTLKt177zzR5f2qir1B/AolizEpjO8vaDd6CNpC/H1CKPdAgY+/Ohj9pN2uHVK3uxYSfhJQ674= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 175854911731322.936028425353015; Mon, 22 Sep 2025 06:51:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0gvc-0000Qz-8p; Mon, 22 Sep 2025 09:50:04 -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 1v0gvX-0000Pr-Ou for qemu-devel@nongnu.org; Mon, 22 Sep 2025 09:49:59 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0gvU-0001uR-Uj for qemu-devel@nongnu.org; Mon, 22 Sep 2025 09:49:59 -0400 Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 58M7NQno030914; Mon, 22 Sep 2025 13:49:54 GMT Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 499mad2gmu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 Sep 2025 13:49:54 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 58MC1BOG034255; Mon, 22 Sep 2025 13:49:53 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 49a6nhanaa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 Sep 2025 13:49:53 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 58MDnlWJ004351; Mon, 22 Sep 2025 13:49:53 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 49a6nhan6x-5; Mon, 22 Sep 2025 13:49:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :date:from:in-reply-to:message-id:references:subject:to; s= corp-2025-04-25; bh=VggucWXHRsV9x5Cmy/z6Zo3PNEb1fQUeyB+8KnvYUxE=; b= Oi4/mxzdMibzaOIowfZs0ci4XzmNgqKtFcm6ZawuW+hkt2Gp7oSvmX6YoTfEpxm/ 7/wpm08dUHTUeJOMVY9C9Bs0QEDbpUTcz95D3yUPFItPJU310DZyMoL99nF2fQT2 K41J/K2xUgYq9iWBgsLifNG5ux7E16GnmamamwjMSuSbwclESngvYDDjrK5itrZ1 82qxCkhQ2X/UCfm1TjYjCh8uk1AKAEzj1RQXJoTF6guC5y6Nmt5OGDVACFBi5jhx Nfp3Wrmf1GtLxp4tMiIhiE0Y0KsokfX591MhoR3jTYGZMoee/UsGXoHWzd8Vyr7f VyPpMkIUtystlHmjtI/XEw== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Peter Xu , Markus Armbruster , Paolo Bonzini , Eric Blake , "Dr. David Alan Gilbert" , Cedric Le Goater , Alex Williamson , Steve Sistare Subject: [PATCH V4 4/8] migration: cpr-exec-command parameter Date: Mon, 22 Sep 2025 06:49:41 -0700 Message-Id: <1758548985-354793-5-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1758548985-354793-1-git-send-email-steven.sistare@oracle.com> References: <1758548985-354793-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1117,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-09-22_01,2025-09-22_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 mlxscore=0 spamscore=0 malwarescore=0 phishscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2508110000 definitions=main-2509220135 X-Proofpoint-ORIG-GUID: zL0R1A33i_tGuJdUCy1Bss5LsGgPE9UD X-Proofpoint-GUID: zL0R1A33i_tGuJdUCy1Bss5LsGgPE9UD X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwOTIwMDAyOSBTYWx0ZWRfX+2+yURKcC+F6 PvlMxts1r2/o+Q4PbFGZZE3O9BRg5Vd9PQMrFio7bp0j/YH8XKLtwqMCWAjF+hbFk/fOBcfPYHu 9X3bijt4h06zdvuAB3+COmhI/E0NN4ngRE6qh6BxOnE/YJvVMOUJyJoxzpJZ2PYmd9yiSxM1Kt1 cdOYlSKXu4PgUfEPvV0ZgIQwi3WFpDWKBWdU5Ko302+1LwdPLmfqesmtxVuZdzJ3YhzSxDTIG2w dnMPUmbeJVL218z1moso0PI6Eto9AzcWdfhTEQcn3i2yHUz/hEy2NmaVnExJte7TcdCD5xkm96f j/k29SMbkMR3QEPfOts7Gyvhsl2uYbcjY1yheGz8K+EYMkV69epJPm3eugqEqFXJoODaESy4lx6 hTBv6+KOtdcRMsiGAj3Riz7w5PzJaA== X-Authority-Analysis: v=2.4 cv=Vfv3PEp9 c=1 sm=1 tr=0 ts=68d15402 b=1 cx=c_pps a=e1sVV491RgrpLwSTMOnk8w==:117 a=e1sVV491RgrpLwSTMOnk8w==:17 a=yJojWOMRYYMA:10 a=yPCof4ZbAAAA:8 a=20KFwNOVAAAA:8 a=MKfdV2AELyQW9RJxCdwA:9 cc=ntf awl=host:13614 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=steven.sistare@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1758549118521116600 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Create the cpr-exec-command migration parameter, defined as a list of strings. It will be used for cpr-exec migration mode in a subsequent patch, and contains forward references to cpr-exec mode in the qapi doc. No functional change, except that cpr-exec-command is shown by the 'info migrate' command. Signed-off-by: Steve Sistare Acked-by: Markus Armbruster --- qapi/migration.json | 21 ++++++++++++++++++--- migration/migration-hmp-cmds.c | 30 ++++++++++++++++++++++++++++++ migration/options.c | 14 ++++++++++++++ hmp-commands.hx | 2 +- 4 files changed, 63 insertions(+), 4 deletions(-) diff --git a/qapi/migration.json b/qapi/migration.json index 2387c21..2be8fa1 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -924,6 +924,10 @@ # only has effect if the @mapped-ram capability is enabled. # (Since 9.1) # +# @cpr-exec-command: Command to start the new QEMU process when @mode +# is @cpr-exec. The first list element is the program's filename, +# the remainder its arguments. (Since 10.2) +# # Features: # # @unstable: Members @x-checkpoint-delay and @@ -950,7 +954,8 @@ 'vcpu-dirty-limit', 'mode', 'zero-page-detection', - 'direct-io'] } + 'direct-io', + 'cpr-exec-command'] } =20 ## # @MigrateSetParameters: @@ -1105,6 +1110,10 @@ # only has effect if the @mapped-ram capability is enabled. # (Since 9.1) # +# @cpr-exec-command: Command to start the new QEMU process when @mode +# is @cpr-exec. The first list element is the program's filename, +# the remainder its arguments. (Since 10.2) +# # Features: # # @unstable: Members @x-checkpoint-delay and @@ -1146,7 +1155,8 @@ '*vcpu-dirty-limit': 'uint64', '*mode': 'MigMode', '*zero-page-detection': 'ZeroPageDetection', - '*direct-io': 'bool' } } + '*direct-io': 'bool', + '*cpr-exec-command': [ 'str' ]} } =20 ## # @migrate-set-parameters: @@ -1315,6 +1325,10 @@ # only has effect if the @mapped-ram capability is enabled. # (Since 9.1) # +# @cpr-exec-command: Command to start the new QEMU process when @mode +# is @cpr-exec. The first list element is the program's filename, +# the remainder its arguments. (Since 10.2) +# # Features: # # @unstable: Members @x-checkpoint-delay and @@ -1353,7 +1367,8 @@ '*vcpu-dirty-limit': 'uint64', '*mode': 'MigMode', '*zero-page-detection': 'ZeroPageDetection', - '*direct-io': 'bool' } } + '*direct-io': 'bool', + '*cpr-exec-command': [ 'str' ]} } =20 ## # @query-migrate-parameters: diff --git a/migration/migration-hmp-cmds.c b/migration/migration-hmp-cmds.c index 0fc21f0..54df615 100644 --- a/migration/migration-hmp-cmds.c +++ b/migration/migration-hmp-cmds.c @@ -306,6 +306,18 @@ void hmp_info_migrate_capabilities(Monitor *mon, const= QDict *qdict) qapi_free_MigrationCapabilityStatusList(caps); } =20 +static void monitor_print_cpr_exec_command(Monitor *mon, strList *args) +{ + monitor_printf(mon, "%s:", + MigrationParameter_str(MIGRATION_PARAMETER_CPR_EXEC_COMMAND)); + + while (args) { + monitor_printf(mon, " %s", args->value); + args =3D args->next; + } + monitor_printf(mon, "\n"); +} + void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict) { MigrationParameters *params; @@ -435,6 +447,9 @@ void hmp_info_migrate_parameters(Monitor *mon, const QD= ict *qdict) MIGRATION_PARAMETER_DIRECT_IO), params->direct_io ? "on" : "off"); } + + assert(params->has_cpr_exec_command); + monitor_print_cpr_exec_command(mon, params->cpr_exec_command); } =20 qapi_free_MigrationParameters(params); @@ -716,6 +731,21 @@ void hmp_migrate_set_parameter(Monitor *mon, const QDi= ct *qdict) p->has_direct_io =3D true; visit_type_bool(v, param, &p->direct_io, &err); break; + case MIGRATION_PARAMETER_CPR_EXEC_COMMAND: { + g_autofree char **strv =3D NULL; + g_autoptr(GError) gerr =3D NULL; + strList **tail =3D &p->cpr_exec_command; + + if (!g_shell_parse_argv(valuestr, NULL, &strv, &gerr)) { + error_setg(&err, "%s", gerr->message); + break; + } + for (int i =3D 0; strv[i]; i++) { + QAPI_LIST_APPEND(tail, strv[i]); + } + p->has_cpr_exec_command =3D true; + break; + } default: g_assert_not_reached(); } diff --git a/migration/options.c b/migration/options.c index 4e923a2..5183112 100644 --- a/migration/options.c +++ b/migration/options.c @@ -959,6 +959,9 @@ MigrationParameters *qmp_query_migrate_parameters(Error= **errp) params->zero_page_detection =3D s->parameters.zero_page_detection; params->has_direct_io =3D true; params->direct_io =3D s->parameters.direct_io; + params->has_cpr_exec_command =3D true; + params->cpr_exec_command =3D QAPI_CLONE(strList, + s->parameters.cpr_exec_command); =20 return params; } @@ -993,6 +996,7 @@ void migrate_params_init(MigrationParameters *params) params->has_mode =3D true; params->has_zero_page_detection =3D true; params->has_direct_io =3D true; + params->has_cpr_exec_command =3D true; } =20 /* @@ -1297,6 +1301,10 @@ static void migrate_params_test_apply(MigrateSetPara= meters *params, if (params->has_direct_io) { dest->direct_io =3D params->direct_io; } + + if (params->has_cpr_exec_command) { + dest->cpr_exec_command =3D params->cpr_exec_command; + } } =20 static void migrate_params_apply(MigrateSetParameters *params, Error **err= p) @@ -1429,6 +1437,12 @@ static void migrate_params_apply(MigrateSetParameter= s *params, Error **errp) if (params->has_direct_io) { s->parameters.direct_io =3D params->direct_io; } + + if (params->has_cpr_exec_command) { + qapi_free_strList(s->parameters.cpr_exec_command); + s->parameters.cpr_exec_command =3D + QAPI_CLONE(strList, params->cpr_exec_command); + } } =20 void qmp_migrate_set_parameters(MigrateSetParameters *params, Error **errp) diff --git a/hmp-commands.hx b/hmp-commands.hx index d0e4f35..3cace8f 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1009,7 +1009,7 @@ ERST =20 { .name =3D "migrate_set_parameter", - .args_type =3D "parameter:s,value:s", + .args_type =3D "parameter:s,value:S", .params =3D "parameter value", .help =3D "Set the parameter for migration", .cmd =3D hmp_migrate_set_parameter, --=20 1.8.3.1 From nobody Sun Sep 28 15:29:08 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1758549114; cv=none; d=zohomail.com; s=zohoarc; b=aofyOgErppPvAWb2Gy7d+s78LReTmjbHFhSq2uo9ByE6dyaTa3jhSEBYp57BPhGMVOpdpia54eM+Vmm55i3rSwv/OJarkvJ7Wk8mJuwkT+gzOkEHVW7Ceby8an4jomgovC6KMWKSHObs0dg/zjA3RJ5qqJ0ZxPuKibsuo/M8qak= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758549114; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=pqnZsGOveum6MdUWHm6O4m8PyUF0whO7RsRA30FGE0w=; b=im9TulY4sBK0TzL2+IB2OJ6ovFqb6yxTjVN2Br4LlVPQWTbAWADgxUXNZcwgzHUUWJ4RexsuyLA/aOmTg/QijHOPG2B1cM2Zzl209yiJcoz8dWwbtZSBn6B4cDquGvHMwmwsuJXK7z2TxPPgPsn3mnqmnc6d+KL5jbFg6UdvULg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758549114716809.306151175718; Mon, 22 Sep 2025 06:51:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0gvc-0000Rf-R1; Mon, 22 Sep 2025 09:50:04 -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 1v0gva-0000QO-74 for qemu-devel@nongnu.org; Mon, 22 Sep 2025 09:50:02 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0gvV-0001v2-Nc for qemu-devel@nongnu.org; Mon, 22 Sep 2025 09:50:01 -0400 Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 58M7NM5B030887; Mon, 22 Sep 2025 13:49:56 GMT Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 499mad2gmy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 Sep 2025 13:49:56 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 58MCARua034252; Mon, 22 Sep 2025 13:49:55 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 49a6nhanb1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 Sep 2025 13:49:55 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 58MDnlWL004351; Mon, 22 Sep 2025 13:49:54 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 49a6nhan6x-6; Mon, 22 Sep 2025 13:49:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :date:from:in-reply-to:message-id:references:subject:to; s= corp-2025-04-25; bh=pqnZsGOveum6MdUWHm6O4m8PyUF0whO7RsRA30FGE0w=; b= E4izIl3OJEoVuICWOvc8lkp3aDnFsNAjLkGo0iXttH9o3f6VamNK0ZSwc8mPLmAM +fqvtNsw4zH9fjCSqYQP3/z9MJxD9vqnqpJJ9+0YCiY0yD4vASjOO34YgK8bxCBZ /MvubyXxqpD7//AKpcSeIQWTGXrUbj+8z9QhtVwRWY+ESbnnykhwQ5iQn5GzPt+F SZDV8949oyeRBudJRjnSuVN4bTVM0lszAErNZkhMOXkWaSoFk5BYGFvVmL17oDB9 Ejo4gpNJquawIiL7swOCrQ1P3qg6XhQacb72tSeR3J/sPb25uIV4YdbG/fLtzF8E W6LXzU9YTKjJ/2FdLddBhg== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Peter Xu , Markus Armbruster , Paolo Bonzini , Eric Blake , "Dr. David Alan Gilbert" , Cedric Le Goater , Alex Williamson , Steve Sistare Subject: [PATCH V4 5/8] migration: cpr-exec save and load Date: Mon, 22 Sep 2025 06:49:42 -0700 Message-Id: <1758548985-354793-6-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1758548985-354793-1-git-send-email-steven.sistare@oracle.com> References: <1758548985-354793-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1117,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-09-22_01,2025-09-22_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 mlxscore=0 spamscore=0 malwarescore=0 phishscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2508110000 definitions=main-2509220135 X-Proofpoint-ORIG-GUID: stoIjZNoyFdXhEM8gq1-gsfJLcY_xVFg X-Proofpoint-GUID: stoIjZNoyFdXhEM8gq1-gsfJLcY_xVFg X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwOTIwMDAyOSBTYWx0ZWRfX9F7ifZdON4TB A82ONeVEhYxR+SnOXyzLVNlnRhYOst8vCjm06IkPFBaOyTJlbWNnXbxP2ZvcTEGNm81OocQPYs3 1B1NWJ73vVwWtgUSupwP/k08wb/go7oI5NZ5YNrJFmgb5rtQ7em9eDIMHMuSQYjGPSUD9HfX8MI E993c1VsMBqVxc+88Xu43/YWwx3lGBvKOU09BF1g/8kO4QTj4xCpMrkd3n9CBUXom/K/5uI57gQ YnNLjl39earFUpSSB4eiBHBpmuW3j9kYHtCK5wffxi1L5ADYrUXkBi5oyp2397aZGX28NSrlShC ygWdfTiGaOOjYR19f3a6GxNiYnT5SareeQeipKHwRidzjK7jy49WBXUFtLadJPGGluG+W6de3Cl cAFURplz9eieiD/IRqO4h7xbkL/KRg== X-Authority-Analysis: v=2.4 cv=Vfv3PEp9 c=1 sm=1 tr=0 ts=68d15404 b=1 cx=c_pps a=e1sVV491RgrpLwSTMOnk8w==:117 a=e1sVV491RgrpLwSTMOnk8w==:17 a=yJojWOMRYYMA:10 a=yPCof4ZbAAAA:8 a=mt9KrOKPv6uyc6Gi5S4A:9 cc=ntf awl=host:13614 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=steven.sistare@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1758549116494116600 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" To preserve CPR state across exec, create a QEMUFile based on a memfd, and keep the memfd open across exec. Save the value of the memfd in an environment variable so post-exec QEMU can find it. These new functions are called in a subsequent patch. Signed-off-by: Steve Sistare --- include/migration/cpr.h | 5 +++ migration/cpr-exec.c | 94 +++++++++++++++++++++++++++++++++++++++++++++= ++++ migration/meson.build | 1 + 3 files changed, 100 insertions(+) create mode 100644 migration/cpr-exec.c diff --git a/include/migration/cpr.h b/include/migration/cpr.h index 2b074d7..b84389f 100644 --- a/include/migration/cpr.h +++ b/include/migration/cpr.h @@ -53,4 +53,9 @@ int cpr_get_fd_param(const char *name, const char *fdname= , int index, QEMUFile *cpr_transfer_output(MigrationChannel *channel, Error **errp); QEMUFile *cpr_transfer_input(MigrationChannel *channel, Error **errp); =20 +QEMUFile *cpr_exec_output(Error **errp); +QEMUFile *cpr_exec_input(Error **errp); +void cpr_exec_persist_state(QEMUFile *f); +bool cpr_exec_has_state(void); +void cpr_exec_unpersist_state(void); #endif diff --git a/migration/cpr-exec.c b/migration/cpr-exec.c new file mode 100644 index 0000000..2c32e9c --- /dev/null +++ b/migration/cpr-exec.c @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2021-2025 Oracle and/or its affiliates. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "qemu/cutils.h" +#include "qemu/memfd.h" +#include "qapi/error.h" +#include "io/channel-file.h" +#include "io/channel-socket.h" +#include "migration/cpr.h" +#include "migration/qemu-file.h" +#include "migration/misc.h" +#include "migration/vmstate.h" +#include "system/runstate.h" + +#define CPR_EXEC_STATE_NAME "QEMU_CPR_EXEC_STATE" + +static QEMUFile *qemu_file_new_fd_input(int fd, const char *name) +{ + g_autoptr(QIOChannelFile) fioc =3D qio_channel_file_new_fd(fd); + QIOChannel *ioc =3D QIO_CHANNEL(fioc); + qio_channel_set_name(ioc, name); + return qemu_file_new_input(ioc); +} + +static QEMUFile *qemu_file_new_fd_output(int fd, const char *name) +{ + g_autoptr(QIOChannelFile) fioc =3D qio_channel_file_new_fd(fd); + QIOChannel *ioc =3D QIO_CHANNEL(fioc); + qio_channel_set_name(ioc, name); + return qemu_file_new_output(ioc); +} + +void cpr_exec_persist_state(QEMUFile *f) +{ + QIOChannelFile *fioc =3D QIO_CHANNEL_FILE(qemu_file_get_ioc(f)); + int mfd =3D dup(fioc->fd); + char val[16]; + + /* Remember mfd in environment for post-exec load */ + qemu_clear_cloexec(mfd); + snprintf(val, sizeof(val), "%d", mfd); + g_setenv(CPR_EXEC_STATE_NAME, val, 1); +} + +static int cpr_exec_find_state(void) +{ + const char *val =3D g_getenv(CPR_EXEC_STATE_NAME); + int mfd; + + assert(val); + g_unsetenv(CPR_EXEC_STATE_NAME); + assert(!qemu_strtoi(val, NULL, 10, &mfd)); + return mfd; +} + +bool cpr_exec_has_state(void) +{ + return g_getenv(CPR_EXEC_STATE_NAME) !=3D NULL; +} + +void cpr_exec_unpersist_state(void) +{ + int mfd; + const char *val =3D g_getenv(CPR_EXEC_STATE_NAME); + + g_unsetenv(CPR_EXEC_STATE_NAME); + assert(val); + assert(!qemu_strtoi(val, NULL, 10, &mfd)); + close(mfd); +} + +QEMUFile *cpr_exec_output(Error **errp) +{ + int mfd =3D memfd_create(CPR_EXEC_STATE_NAME, 0); + + if (mfd < 0) { + error_setg_errno(errp, errno, "memfd_create failed"); + return NULL; + } + + return qemu_file_new_fd_output(mfd, CPR_EXEC_STATE_NAME); +} + +QEMUFile *cpr_exec_input(Error **errp) +{ + int mfd =3D cpr_exec_find_state(); + + lseek(mfd, 0, SEEK_SET); + return qemu_file_new_fd_input(mfd, CPR_EXEC_STATE_NAME); +} diff --git a/migration/meson.build b/migration/meson.build index 0f71544..16909d5 100644 --- a/migration/meson.build +++ b/migration/meson.build @@ -16,6 +16,7 @@ system_ss.add(files( 'channel-block.c', 'cpr.c', 'cpr-transfer.c', + 'cpr-exec.c', 'cpu-throttle.c', 'dirtyrate.c', 'exec.c', --=20 1.8.3.1 From nobody Sun Sep 28 15:29:08 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1758549073; cv=none; d=zohomail.com; s=zohoarc; b=njA20OO6X3MVHunlQczesnNZ51a9WGSYOl3pIsAzPy5K5xZ1y53tg9ILhyd8EeLFC2EJN1xCB6ekso9xmNlRh0WanSSE6Rx3Agwn4GeTF8nN4FD5xdUXZZj4zDU9H+1a1KbR/c2rEfdDQV3kp1ZWyqXvlQGGP1GQJs03mX7EPqw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758549073; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=i7UfslXeC7dbh77BjEQkceC6BmJ39kT/oadJ+bYbN48=; b=HkkuBDfTO0DBLDfoeGUNZi/+0Uhsh3pWxBtX/YY1g4LuknSQAMfRuBJlbYzhGNsxsgf4/+ANqbdGvS6uT4Z8KpF/lZ0UecMP2c3aqvPO0LQhj3mZH8v6nMiNH6KuYrZFF9Z0UCEUmE3lcuZczD4sT8UTGa7ca8QSFy5WDJbzhZU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758549073090775.4916025254441; Mon, 22 Sep 2025 06:51:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0gvh-0000Tr-6y; Mon, 22 Sep 2025 09:50: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 1v0gve-0000SL-KE for qemu-devel@nongnu.org; Mon, 22 Sep 2025 09:50:06 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0gvb-0001vv-Pn for qemu-devel@nongnu.org; Mon, 22 Sep 2025 09:50:06 -0400 Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 58M7NM0Q030881; Mon, 22 Sep 2025 13:50:01 GMT Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 499mad2gn0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 Sep 2025 13:49:56 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 58MCARub034252; Mon, 22 Sep 2025 13:49:56 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 49a6nhanbx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 Sep 2025 13:49:56 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 58MDnlWN004351; Mon, 22 Sep 2025 13:49:55 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 49a6nhan6x-7; Mon, 22 Sep 2025 13:49:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :date:from:in-reply-to:message-id:references:subject:to; s= corp-2025-04-25; bh=i7UfslXeC7dbh77BjEQkceC6BmJ39kT/oadJ+bYbN48=; b= k2tahy88Wrmf1d/Iyo1zn2jOP2GY53IZgaD2HVmjf4Radf87kbu6y18R/sdR3PQx dxPxNNcDDfXqKzOIuaMiSQd/I50zJJCbQ7bmQjsJdrhfVNFE/hpLuRLylGP+kmZ+ puE2Q21TM33x7+rmCZ2X4lkL8pUu+Qm9COOK3n6EKmYXjbD8wdwMcrqCSkkRLJLC 2y6AX+UAOTUJd43y2n/2mBjv50b7O8RgUy2W1jz8fnBllLZcxJ9dqiq57Ypmfpy7 3t8QlmTa/KZxncSzVTDmITjhNIMxas1bcl2bUKzH1W7RpMyfW76Rl+Z3TD1Sz4Mc cRHhfmaSDPSniQgylW8XUg== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Peter Xu , Markus Armbruster , Paolo Bonzini , Eric Blake , "Dr. David Alan Gilbert" , Cedric Le Goater , Alex Williamson , Steve Sistare Subject: [PATCH V4 6/8] migration: cpr-exec mode Date: Mon, 22 Sep 2025 06:49:43 -0700 Message-Id: <1758548985-354793-7-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1758548985-354793-1-git-send-email-steven.sistare@oracle.com> References: <1758548985-354793-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1117,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-09-22_01,2025-09-22_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 mlxscore=0 spamscore=0 malwarescore=0 phishscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2508110000 definitions=main-2509220135 X-Proofpoint-ORIG-GUID: VyafF5Sq2-BE5dvqtPM2JIoqARukWvFN X-Proofpoint-GUID: VyafF5Sq2-BE5dvqtPM2JIoqARukWvFN X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwOTIwMDAyOSBTYWx0ZWRfX0t3+e+Msgwe2 RoLaTXhFpasEZM+EbKB9pVpYycnUcvDXjYozLxrRbtoF2nOAUbVj67GeycePElK5gOBSdQy8T0L C2/5GqbrHP7EdCf9w4ZhH8ZZs1TUAa2Qc/jWfkn5fdGTec4rh9n9PpJVmOjy3TgW9pFd6PcchGa okJScTKYMHAJyQBKwzubFj0l7WtTsXxFs0CjBtyhhkzUr/dPgSqQkap+utrvo4GNXw6e2Ms/p0A HV/f0ZS+p/3uaEwV2pVhJyQNzNwoNB76Ysm23j12IKHHeNWW1RvMtlQXrPe6tNMmP66Vs2tub6q BZyxmho9y3gg2BPa7CJ5xxNRgDp3xdI3bBC6UurFePc8HNh3aT9V/Zb+i4P8Tr3nzo28J+EEVU2 oiJ6hBuv6WALNGwWnFLlB415/KULWQ== X-Authority-Analysis: v=2.4 cv=Vfv3PEp9 c=1 sm=1 tr=0 ts=68d15405 b=1 cx=c_pps a=e1sVV491RgrpLwSTMOnk8w==:117 a=e1sVV491RgrpLwSTMOnk8w==:17 a=yJojWOMRYYMA:10 a=yPCof4ZbAAAA:8 a=20KFwNOVAAAA:8 a=V5tUqp5okAFojsnLb_sA:9 cc=ntf awl=host:13614 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=steven.sistare@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1758549074146116600 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add the cpr-exec migration mode. Usage: qemu-system-$arch -machine aux-ram-share=3Don ... migrate_set_parameter mode cpr-exec migrate_set_parameter cpr-exec-command \ ... -incoming \ migrate -d The migrate command stops the VM, saves state to uri-1, directly exec's a new version of QEMU on the same host, replacing the original process while retaining its PID, and loads state from uri-1. Guest RAM is preserved in place, albeit with new virtual addresses. The new QEMU process is started by exec'ing the command specified by the @cpr-exec-command parameter. The first word of the command is the binary, and the remaining words are its arguments. The command may be a direct invocation of new QEMU, or may be a non-QEMU command that exec's the new QEMU binary. This mode creates a second migration channel that is not visible to the user. At the start of migration, old QEMU saves CPR state to the second channel, and at the end of migration, it tells the main loop to call cpr_exec. New QEMU loads CPR state early, before objects are created. Because old QEMU terminates when new QEMU starts, one cannot stream data between the two, so uri-1 must be a type, such as a file, that accepts all data before old QEMU exits. Otherwise, old QEMU may quietly block writing to the channel. Memory-backend objects must have the share=3Don attribute, but memory-backend-epc is not supported. The VM must be started with the '-machine aux-ram-share=3Don' option, which allows anonymous memory to be transferred in place to the new process. The memfds are kept open across exec by clearing the close-on-exec flag, their values are saved in CPR state, and they are mmap'd in new QEMU. Signed-off-by: Steve Sistare Acked-by: Markus Armbruster --- qapi/migration.json | 25 +++++++++++++- include/migration/cpr.h | 1 + migration/cpr-exec.c | 84 +++++++++++++++++++++++++++++++++++++++++++= ++++ migration/cpr.c | 28 ++++++++++++++-- migration/migration.c | 10 +++++- migration/ram.c | 1 + migration/vmstate-types.c | 8 +++++ system/vl.c | 4 ++- migration/trace-events | 1 + 9 files changed, 157 insertions(+), 5 deletions(-) diff --git a/qapi/migration.json b/qapi/migration.json index 2be8fa1..be0f3fc 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -694,9 +694,32 @@ # until you issue the `migrate-incoming` command. # # (since 10.0) +# +# @cpr-exec: The migrate command stops the VM, saves state to the +# migration channel, directly exec's a new version of QEMU on the +# same host, replacing the original process while retaining its +# PID, and loads state from the channel. Guest RAM is preserved +# in place. Devices and their pinned pages are also preserved for +# VFIO and IOMMUFD. +# +# Old QEMU starts new QEMU by exec'ing the command specified by +# the @cpr-exec-command parameter. The command may be a direct +# invocation of new QEMU, or may be a wrapper that exec's the new +# QEMU binary. +# +# Because old QEMU terminates when new QEMU starts, one cannot +# stream data between the two, so the channel must be a type, +# such as a file, that accepts all data before old QEMU exits. +# Otherwise, old QEMU may quietly block writing to the channel. +# +# Memory-backend objects must have the share=3Don attribute, but +# memory-backend-epc is not supported. The VM must be started +# with the '-machine aux-ram-share=3Don' option. +# +# (since 10.2) ## { 'enum': 'MigMode', - 'data': [ 'normal', 'cpr-reboot', 'cpr-transfer' ] } + 'data': [ 'normal', 'cpr-reboot', 'cpr-transfer', 'cpr-exec' ] } =20 ## # @ZeroPageDetection: diff --git a/include/migration/cpr.h b/include/migration/cpr.h index b84389f..beed392 100644 --- a/include/migration/cpr.h +++ b/include/migration/cpr.h @@ -53,6 +53,7 @@ int cpr_get_fd_param(const char *name, const char *fdname= , int index, QEMUFile *cpr_transfer_output(MigrationChannel *channel, Error **errp); QEMUFile *cpr_transfer_input(MigrationChannel *channel, Error **errp); =20 +void cpr_exec_init(void); QEMUFile *cpr_exec_output(Error **errp); QEMUFile *cpr_exec_input(Error **errp); void cpr_exec_persist_state(QEMUFile *f); diff --git a/migration/cpr-exec.c b/migration/cpr-exec.c index 2c32e9c..8cf55a3 100644 --- a/migration/cpr-exec.c +++ b/migration/cpr-exec.c @@ -6,15 +6,21 @@ =20 #include "qemu/osdep.h" #include "qemu/cutils.h" +#include "qemu/error-report.h" #include "qemu/memfd.h" #include "qapi/error.h" +#include "qapi/type-helpers.h" #include "io/channel-file.h" #include "io/channel-socket.h" +#include "block/block-global-state.h" +#include "qemu/main-loop.h" #include "migration/cpr.h" #include "migration/qemu-file.h" +#include "migration/migration.h" #include "migration/misc.h" #include "migration/vmstate.h" #include "system/runstate.h" +#include "trace.h" =20 #define CPR_EXEC_STATE_NAME "QEMU_CPR_EXEC_STATE" =20 @@ -92,3 +98,81 @@ QEMUFile *cpr_exec_input(Error **errp) lseek(mfd, 0, SEEK_SET); return qemu_file_new_fd_input(mfd, CPR_EXEC_STATE_NAME); } + +static bool preserve_fd(int fd) +{ + qemu_clear_cloexec(fd); + return true; +} + +static bool unpreserve_fd(int fd) +{ + qemu_set_cloexec(fd); + return true; +} + +static void cpr_exec_cb(void *opaque) +{ + MigrationState *s =3D migrate_get_current(); + char **argv =3D strv_from_str_list(s->parameters.cpr_exec_command); + Error *err =3D NULL; + + /* + * Clear the close-on-exec flag for all preserved fd's. We cannot do = so + * earlier because they should not persist across miscellaneous fork a= nd + * exec calls that are performed during normal operation. + */ + cpr_walk_fd(preserve_fd); + + trace_cpr_exec(); + execvp(argv[0], argv); + + /* + * exec should only fail if argv[0] is bogus, or has a permissions pro= blem, + * or the system is very short on resources. + */ + g_strfreev(argv); + cpr_walk_fd(unpreserve_fd); + + error_setg_errno(&err, errno, "execvp %s failed", argv[0]); + error_report_err(error_copy(err)); + migrate_set_state(&s->state, s->state, MIGRATION_STATUS_FAILED); + migrate_set_error(s, err); + + migration_call_notifiers(s, MIG_EVENT_PRECOPY_FAILED, NULL); + + err =3D NULL; + if (!migration_block_activate(&err)) { + /* error was already reported */ + return; + } + + if (runstate_is_live(s->vm_old_state)) { + vm_start(); + } +} + +static int cpr_exec_notifier(NotifierWithReturn *notifier, MigrationEvent = *e, + Error **errp) +{ + MigrationState *s =3D migrate_get_current(); + + if (e->type =3D=3D MIG_EVENT_PRECOPY_DONE) { + QEMUBH *cpr_exec_bh =3D qemu_bh_new(cpr_exec_cb, NULL); + assert(s->state =3D=3D MIGRATION_STATUS_COMPLETED); + qemu_bh_schedule(cpr_exec_bh); + qemu_notify_event(); + + } else if (e->type =3D=3D MIG_EVENT_PRECOPY_FAILED) { + cpr_exec_unpersist_state(); + } + return 0; +} + +void cpr_exec_init(void) +{ + static NotifierWithReturn exec_notifier; + + migration_add_notifier_mode(&exec_notifier, cpr_exec_notifier, + MIG_MODE_CPR_EXEC); +} diff --git a/migration/cpr.c b/migration/cpr.c index d3e370e..eea3773 100644 --- a/migration/cpr.c +++ b/migration/cpr.c @@ -185,6 +185,8 @@ int cpr_state_save(MigrationChannel *channel, Error **e= rrp) if (mode =3D=3D MIG_MODE_CPR_TRANSFER) { g_assert(channel); f =3D cpr_transfer_output(channel, errp); + } else if (mode =3D=3D MIG_MODE_CPR_EXEC) { + f =3D cpr_exec_output(errp); } else { return 0; } @@ -202,6 +204,10 @@ int cpr_state_save(MigrationChannel *channel, Error **= errp) return ret; } =20 + if (migrate_mode() =3D=3D MIG_MODE_CPR_EXEC) { + cpr_exec_persist_state(f); + } + /* * Close the socket only partially so we can later detect when the oth= er * end closes by getting a HUP event. @@ -213,6 +219,12 @@ int cpr_state_save(MigrationChannel *channel, Error **= errp) return 0; } =20 +static bool unpreserve_fd(int fd) +{ + qemu_set_cloexec(fd); + return true; +} + int cpr_state_load(MigrationChannel *channel, Error **errp) { int ret; @@ -220,7 +232,13 @@ int cpr_state_load(MigrationChannel *channel, Error **= errp) QEMUFile *f; MigMode mode =3D 0; =20 - if (channel) { + if (cpr_exec_has_state()) { + mode =3D MIG_MODE_CPR_EXEC; + f =3D cpr_exec_input(errp); + if (channel) { + warn_report("ignoring cpr channel for migration mode cpr-exec"= ); + } + } else if (channel) { mode =3D MIG_MODE_CPR_TRANSFER; cpr_set_incoming_mode(mode); f =3D cpr_transfer_input(channel, errp); @@ -232,6 +250,7 @@ int cpr_state_load(MigrationChannel *channel, Error **e= rrp) } =20 trace_cpr_state_load(MigMode_str(mode)); + cpr_set_incoming_mode(mode); =20 v =3D qemu_get_be32(f); if (v !=3D QEMU_CPR_FILE_MAGIC) { @@ -253,6 +272,11 @@ int cpr_state_load(MigrationChannel *channel, Error **= errp) return ret; } =20 + if (migrate_mode() =3D=3D MIG_MODE_CPR_EXEC) { + /* Set cloexec to prevent fd leaks from fork until the next cpr-ex= ec */ + cpr_walk_fd(unpreserve_fd); + } + /* * Let the caller decide when to close the socket (and generate a HUP = event * for the sending side). @@ -273,7 +297,7 @@ void cpr_state_close(void) bool cpr_incoming_needed(void *opaque) { MigMode mode =3D migrate_mode(); - return mode =3D=3D MIG_MODE_CPR_TRANSFER; + return mode =3D=3D MIG_MODE_CPR_TRANSFER || mode =3D=3D MIG_MODE_CPR_E= XEC; } =20 /* diff --git a/migration/migration.c b/migration/migration.c index 08a98f7..2515bec 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -333,6 +333,7 @@ void migration_object_init(void) =20 ram_mig_init(); dirty_bitmap_mig_init(); + cpr_exec_init(); =20 /* Initialize cpu throttle timers */ cpu_throttle_init(); @@ -1796,7 +1797,8 @@ bool migrate_mode_is_cpr(MigrationState *s) { MigMode mode =3D s->parameters.mode; return mode =3D=3D MIG_MODE_CPR_REBOOT || - mode =3D=3D MIG_MODE_CPR_TRANSFER; + mode =3D=3D MIG_MODE_CPR_TRANSFER || + mode =3D=3D MIG_MODE_CPR_EXEC; } =20 int migrate_init(MigrationState *s, Error **errp) @@ -2145,6 +2147,12 @@ static bool migrate_prepare(MigrationState *s, bool = resume, Error **errp) return false; } =20 + if (migrate_mode() =3D=3D MIG_MODE_CPR_EXEC && + !s->parameters.has_cpr_exec_command) { + error_setg(errp, "cpr-exec mode requires setting cpr-exec-command"= ); + return false; + } + if (migration_is_blocked(errp)) { return false; } diff --git a/migration/ram.c b/migration/ram.c index 7208bc1..6730a41 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -228,6 +228,7 @@ bool migrate_ram_is_ignored(RAMBlock *block) MigMode mode =3D migrate_mode(); return !qemu_ram_is_migratable(block) || mode =3D=3D MIG_MODE_CPR_TRANSFER || + mode =3D=3D MIG_MODE_CPR_EXEC || (migrate_ignore_shared() && qemu_ram_is_shared(block) && qemu_ram_is_named_file(block)); } diff --git a/migration/vmstate-types.c b/migration/vmstate-types.c index 741a588..1aa0573 100644 --- a/migration/vmstate-types.c +++ b/migration/vmstate-types.c @@ -321,6 +321,10 @@ static int get_fd(QEMUFile *f, void *pv, size_t size, const VMStateField *field) { int32_t *v =3D pv; + if (migrate_mode() =3D=3D MIG_MODE_CPR_EXEC) { + qemu_get_sbe32s(f, v); + return 0; + } *v =3D qemu_file_get_fd(f); return 0; } @@ -329,6 +333,10 @@ static int put_fd(QEMUFile *f, void *pv, size_t size, const VMStateField *field, JSONWriter *vmdesc) { int32_t *v =3D pv; + if (migrate_mode() =3D=3D MIG_MODE_CPR_EXEC) { + qemu_put_sbe32s(f, v); + return 0; + } return qemu_file_put_fd(f, *v); } =20 diff --git a/system/vl.c b/system/vl.c index 4c24073..f395d04 100644 --- a/system/vl.c +++ b/system/vl.c @@ -3867,6 +3867,8 @@ void qemu_init(int argc, char **argv) } qemu_init_displays(); accel_setup_post(current_machine); - os_setup_post(); + if (migrate_mode() !=3D MIG_MODE_CPR_EXEC) { + os_setup_post(); + } resume_mux_open(); } diff --git a/migration/trace-events b/migration/trace-events index 706db97..e8edd1f 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -354,6 +354,7 @@ cpr_state_save(const char *mode) "%s mode" cpr_state_load(const char *mode) "%s mode" cpr_transfer_input(const char *path) "%s" cpr_transfer_output(const char *path) "%s" +cpr_exec(void) "" =20 # block-dirty-bitmap.c send_bitmap_header_enter(void) "" --=20 1.8.3.1 From nobody Sun Sep 28 15:29:08 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1758549076; cv=none; d=zohomail.com; s=zohoarc; b=F7k0h2W+eetDfe23LIQTNCsqv+j4cyK/whbSAlJ+BmMk/T+PK1A3+kKIdIOjOCXi+WHgV/i35xHiIMA7TinmCwvXrMGR9S3hBhwEPdAip7unoHuF85S/Kq1nXxyVo2pmO8SGgFPzr9WkX1b3Iw25re3B1NIeYBvUHUO1I6au42g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758549076; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ktPqRcThKWBXTYTM1qYbZx9/j5hYFaBSqo8yG1rfiYw=; b=kmqXWY9A5yX5+Hn49eyFMdOZnw0X72EGMoc8Q8jG4CCf0YjLPqudZVmsHlWAvvEH0GDSxIwoKcGl4Ti1s4awP5ceVlR9b85BStzzkUSIqHTd8niTP1dTmFp1mYB87VumqedpxQ1tF9+hRdAiZlCmwxmlviOy8mqd+C5ERNTCD6M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758549076144953.4579488235407; Mon, 22 Sep 2025 06:51:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0gvk-0000Vu-L5; Mon, 22 Sep 2025 09:50:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0gvi-0000U5-1u for qemu-devel@nongnu.org; Mon, 22 Sep 2025 09:50:10 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0gvX-0001vS-Ry for qemu-devel@nongnu.org; Mon, 22 Sep 2025 09:50:09 -0400 Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 58M7NUbs030944; Mon, 22 Sep 2025 13:49:58 GMT Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 499mad2gn3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 Sep 2025 13:49:58 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 58MCK1VJ034265; Mon, 22 Sep 2025 13:49:57 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 49a6nhand4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 Sep 2025 13:49:57 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 58MDnlWP004351; Mon, 22 Sep 2025 13:49:57 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 49a6nhan6x-8; Mon, 22 Sep 2025 13:49:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :date:from:in-reply-to:message-id:references:subject:to; s= corp-2025-04-25; bh=ktPqRcThKWBXTYTM1qYbZx9/j5hYFaBSqo8yG1rfiYw=; b= S1yDOLbXT9gU9lGTDBCvF3+ykUwBHAm+4R+akqgJEtnIQo9Aqs7AssyMdAV+YKIB DUtAKBpsqZVQqYfJY099nNPAOddrDbLJYt/zUSV5jsaF5ENCuGxu2K7EzoBRdxfg 4CjYluqpaKYwB5SH8Vg4hggmFfGU/4G2PCM7RHZQ2LzCz73pwBrctD+lHnO61AGM VijaD1kRKmQw8qbpfaWnaRAvAE5BaJKJVmTPf+e8lax7lU75dd+L0IJQvgc9LkgZ 2RnYNSgPUy3O68tPI6L95JbeAahp7Tcow9rkWQiMEYP7NmS9qfz8zmeOICwSXXPw 9vtj7z9yzfQXekAQHsFTDg== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Peter Xu , Markus Armbruster , Paolo Bonzini , Eric Blake , "Dr. David Alan Gilbert" , Cedric Le Goater , Alex Williamson , Steve Sistare Subject: [PATCH V4 7/8] migration: cpr-exec docs Date: Mon, 22 Sep 2025 06:49:44 -0700 Message-Id: <1758548985-354793-8-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1758548985-354793-1-git-send-email-steven.sistare@oracle.com> References: <1758548985-354793-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1117,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-09-22_01,2025-09-22_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 mlxscore=0 spamscore=0 malwarescore=0 phishscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2508110000 definitions=main-2509220135 X-Proofpoint-ORIG-GUID: h9j0JwcsiRchurismf0oy5UAStcbPwLV X-Proofpoint-GUID: h9j0JwcsiRchurismf0oy5UAStcbPwLV X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwOTIwMDAyOSBTYWx0ZWRfX623HsbeDWy3I Mkzcoi6bws83enM86qRphLLXh7tc2tQ+NBwSg65RzVlVgS7X+U+WXEzp7cl6okeX4gVYIabNmEW Xbw+4X5GVQhw5npip42gIyUojikkaBgNrlcMQlcGM7diwlUBxSP5mg1N32Mf+EcKNrv1LwVCphx iEvEDWp6rYAZK413MXBx+4RTCeKR7mE7bz4K/OmPzqo2fs1ra5CbV4FSgSGwizvkPdVKlL/U4DH W7TGa16W91ShSFl3VsWiWBuGL2RmPrdFdz8pqKnHOrWfydcZqEA+Ab1xY3S4Q/8m33orT0cwVjm Cdq8VYJBcScsDiyi6cf5WvmTbIl1PoRSm6vnl6X8LkqAbLVQMdiZEvF/J5r1276LR5RU6/omcUq ZI3uSIOXZhegH5qnGn2mV/u4Q6RCPg== X-Authority-Analysis: v=2.4 cv=Vfv3PEp9 c=1 sm=1 tr=0 ts=68d15406 b=1 cx=c_pps a=e1sVV491RgrpLwSTMOnk8w==:117 a=e1sVV491RgrpLwSTMOnk8w==:17 a=yJojWOMRYYMA:10 a=yPCof4ZbAAAA:8 a=Ierz01wVG17__kDJZf8A:9 cc=ntf awl=host:13614 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=steven.sistare@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1758549077890116600 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Update developer documentation for cpr-exec mode. Signed-off-by: Steve Sistare Reviewed-by: Fabiano Rosas --- docs/devel/migration/CPR.rst | 106 +++++++++++++++++++++++++++++++++++++++= +++- 1 file changed, 105 insertions(+), 1 deletion(-) diff --git a/docs/devel/migration/CPR.rst b/docs/devel/migration/CPR.rst index 0a0fd4f..77fdbdd 100644 --- a/docs/devel/migration/CPR.rst +++ b/docs/devel/migration/CPR.rst @@ -5,7 +5,7 @@ CPR is the umbrella name for a set of migration modes in wh= ich the VM is migrated to a new QEMU instance on the same host. It is intended for use when the goal is to update host software components that run the VM, such as QEMU or even the host kernel. At this time, -the cpr-reboot and cpr-transfer modes are available. +the cpr-reboot, cpr-transfer, and cpr-exec modes are available. =20 Because QEMU is restarted on the same host, with access to the same local devices, CPR is allowed in certain cases where normal migration @@ -324,3 +324,107 @@ descriptors from old to new QEMU. In the future, des= criptors for vhost, and char devices could be transferred, preserving those devices and their kernel state without interruption, even if they do not explicitly support live migration. + +cpr-exec mode +------------- + +In this mode, QEMU stops the VM, writes VM state to the migration +URI, and directly exec's a new version of QEMU on the same host, +replacing the original process while retaining its PID. Guest RAM is +preserved in place, albeit with new virtual addresses. The user +completes the migration by specifying the ``-incoming`` option, and +by issuing the ``migrate-incoming`` command if necessary; see details +below. + +This mode supports VFIO/IOMMUFD devices by preserving device +descriptors and hence kernel state across the exec, even for devices +that do not support live migration. + +Because the old and new QEMU instances are not active concurrently, +the URI cannot be a type that streams data from one instance to the +other. + +Usage +^^^^^ + +Arguments for the new QEMU process are taken from the +@cpr-exec-command parameter. The first argument should be the +path of a new QEMU binary, or a prefix command that exec's the +new QEMU binary, and the arguments should include the ''-incoming'' +option. + +Memory backend objects must have the ``share=3Don`` attribute. +The VM must be started with the ``-machine aux-ram-share=3Don`` option. + +Outgoing: + * Set the migration mode parameter to ``cpr-exec``. + * Set the ``cpr-exec-command`` parameter. + * Issue the ``migrate`` command. It is recommended that the URI be + a ``file`` type, but one can use other types such as ``exec``, + provided the command captures all the data from the outgoing side, + and provides all the data to the incoming side. + +Incoming: + * You do not need to explicitly start new QEMU. It is started as + a side effect of the migrate command above. + * If the VM was running when the outgoing ``migrate`` command was + issued, then QEMU automatically resumes VM execution. + +Example 1: incoming URI +^^^^^^^^^^^^^^^^^^^^^^^ + +In these examples, we simply restart the same version of QEMU, but in +a real scenario one would set a new QEMU binary path in +cpr-exec-command. + +:: + + # qemu-kvm -monitor stdio + -object memory-backend-memfd,id=3Dram0,size=3D4G + -machine memory-backend=3Dram0 + -machine aux-ram-share=3Don + ... + + QEMU 10.2.50 monitor - type 'help' for more information + (qemu) info status + VM status: running + (qemu) migrate_set_parameter mode cpr-exec + (qemu) migrate_set_parameter cpr-exec-command qemu-kvm ... -incoming fil= e:vm.state + (qemu) migrate -d file:vm.state + (qemu) QEMU 10.2.50 monitor - type 'help' for more information + (qemu) info status + VM status: running + +Example 2: incoming defer +^^^^^^^^^^^^^^^^^^^^^^^^^ +:: + + # qemu-kvm -monitor stdio + -object memory-backend-memfd,id=3Dram0,size=3D4G + -machine memory-backend=3Dram0 + -machine aux-ram-share=3Don + ... + + QEMU 10.2.50 monitor - type 'help' for more information + (qemu) info status + VM status: running + (qemu) migrate_set_parameter mode cpr-exec + (qemu) migrate_set_parameter cpr-exec-command qemu-kvm ... -incoming def= er + (qemu) migrate -d file:vm.state + (qemu) QEMU 10.2.50 monitor - type 'help' for more information + (qemu) info status + status: paused (inmigrate) + (qemu) migrate_incoming file:vm.state + (qemu) info status + VM status: running + +Caveats +^^^^^^^ + +cpr-exec mode may not be used with postcopy, background-snapshot, +or COLO. + +cpr-exec mode requires permission to use the exec system call, which +is denied by certain sandbox options, such as spawn. + +The guest pause time increases for large guest RAM backed by small pages. --=20 1.8.3.1 From nobody Sun Sep 28 15:29:08 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=oracle.com ARC-Seal: i=1; a=rsa-sha256; t=1758549036; cv=none; d=zohomail.com; s=zohoarc; b=ETWPd5qvNKbSyYx6BNaMpLwclL3JnHg39rWINSXgKuRoLWLBmD50w1wb6ZKhMV4XzAjlEykB3WOlwCE4sg3dU8oXQeeAECBF+38iD9AgXNHIECgeqyGXZnSRh7kZcnLboXjUHqrL6E/VgiKjA2RnQxiLOPhhHNW9HX1E73YMOAg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758549036; h=Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=BPXzv5B6T9PMErDiIgdcjXInWBOu92+1LXdsiyJ/RNU=; b=EiT7Wjs/JL7oIDm3EtOt65N5M+IoLpBiJEA7NGH2kL0bmAydvrczRjCUY3HOZVW2QKslUhVCU8ilg7HDHSaUTBp0n57Hjp62/hlSj4G8rhsCQw4EpUKmXeBMXNl1/tVllvi2aXkpOw9L28BbllTFllHiapPqn6LFmzyu89DQRm0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1758549036501958.806818373403; Mon, 22 Sep 2025 06:50:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v0gve-0000SP-Pk; Mon, 22 Sep 2025 09:50:06 -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 1v0gvc-0000Re-GE for qemu-devel@nongnu.org; Mon, 22 Sep 2025 09:50:04 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1v0gva-0001vj-7T for qemu-devel@nongnu.org; Mon, 22 Sep 2025 09:50:04 -0400 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 58M7NQTE029561; Mon, 22 Sep 2025 13:50:00 GMT Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 499k23agdw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 Sep 2025 13:49:59 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 58MCGk9Q034253; Mon, 22 Sep 2025 13:49:59 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 49a6nhane6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 Sep 2025 13:49:59 +0000 Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 58MDnlWR004351; Mon, 22 Sep 2025 13:49:58 GMT Received: from ca-dev63.us.oracle.com (ca-dev63.us.oracle.com [10.211.8.221]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTP id 49a6nhan6x-9; Mon, 22 Sep 2025 13:49:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :date:from:in-reply-to:message-id:references:subject:to; s= corp-2025-04-25; bh=BPXzv5B6T9PMErDiIgdcjXInWBOu92+1LXdsiyJ/RNU=; b= TxBw/k39lwCLXUTihBTwDGxvqn0snIIyy8T+KE5oYCGK396fj+U9OPO/vEFHwdIz gpcMXGR0bnS+RBVVHkwJWMeNca54uIjCXDouOlAumSl7nRdnb3ZUcvBnhBCkkMbj b3QsxTd7l9CC66y7G5igIukEWzMTIDaoRgUIMRRfkS34cIrCNNov6Gx1/f6UI3La DDoEJGVnHg2zwWE2D4Kif30otlH5dQXo1HQUY0PAoU/Jf+ZfsHTygnUKZjEUQhCp NvMZPmJ8a95v8r/mrxk7jjYMjfUiJM1VlIZwXfkn5ZcBv9uOlgkG7w5EA73t1zcc JLuK5XlCZYwjtqJ2Bji6/A== From: Steve Sistare To: qemu-devel@nongnu.org Cc: Fabiano Rosas , Peter Xu , Markus Armbruster , Paolo Bonzini , Eric Blake , "Dr. David Alan Gilbert" , Cedric Le Goater , Alex Williamson , Steve Sistare Subject: [PATCH V4 8/8] vfio: cpr-exec mode Date: Mon, 22 Sep 2025 06:49:45 -0700 Message-Id: <1758548985-354793-9-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1758548985-354793-1-git-send-email-steven.sistare@oracle.com> References: <1758548985-354793-1-git-send-email-steven.sistare@oracle.com> X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1117,Hydra:6.1.9,FMLib:17.12.80.40 definitions=2025-09-22_01,2025-09-22_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 adultscore=0 mlxscore=0 spamscore=0 malwarescore=0 phishscore=0 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2508110000 definitions=main-2509220135 X-Authority-Analysis: v=2.4 cv=C5XpyRP+ c=1 sm=1 tr=0 ts=68d15407 b=1 cx=c_pps a=e1sVV491RgrpLwSTMOnk8w==:117 a=e1sVV491RgrpLwSTMOnk8w==:17 a=yJojWOMRYYMA:10 a=yPCof4ZbAAAA:8 a=V7xkzyaGXGj9tJ5OYwUA:9 cc=ntf awl=host:13614 X-Proofpoint-GUID: CdSSvPKFurojM_uFpi2P62fndT3sqUnz X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUwOTIwMDAxNiBTYWx0ZWRfX3EXTur+NXMQJ hIXe+CLuPvGvuArIxbuGIlJrn2ZuoSOhYb40l5McV39VuTKSJMr67/RsSX94oknqO0Ebq3DkszX YhDQf6/SnOVhlRfSCUGpSG9vlIIkYgXLR7qkl3u0flaFlkl5hAWgWfOxi1hwVbpPFZFRnzOurbt NOEuUKLnfF+XFLKSN31Z/5oLdcPZg0Memu1mTzoJJdo50vsAy6M7WBgbznOBv83b8Lhzw/Q5wuH 6ra6D9TG3CmvLBK+hzpTsMCNGSOF+B8bc6PYMCV/5v6Ct6czifWzsKynojsdKyAiAOvqqko4IIK veQ/OclP/3ukAniPRNFcxIscipDdP9Ix9jTlCOKjcCdcLPsHaeR0AJLvKcCwV4qm39SR1YHe9i2 uXuS1QMJWZaVkKr1zkULArQ4OiNiCg== X-Proofpoint-ORIG-GUID: CdSSvPKFurojM_uFpi2P62fndT3sqUnz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.220.177.32; envelope-from=steven.sistare@oracle.com; helo=mx0b-00069f02.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @oracle.com) X-ZM-MESSAGEID: 1758549037450116600 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" All blockers and notifiers for cpr-transfer mode also apply to cpr-exec. Signed-off-by: Steve Sistare Acked-by: C=C3=A9dric Le Goater --- hw/vfio/container.c | 3 ++- hw/vfio/cpr-iommufd.c | 3 ++- hw/vfio/cpr-legacy.c | 9 +++++---- hw/vfio/cpr.c | 13 +++++++------ 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/hw/vfio/container.c b/hw/vfio/container.c index 030c6d3..935f14d 100644 --- a/hw/vfio/container.c +++ b/hw/vfio/container.c @@ -988,7 +988,8 @@ static bool vfio_legacy_attach_device(const char *name,= VFIODevice *vbasedev, error_setg(&vbasedev->cpr.mdev_blocker, "CPR does not support vfio mdev %s", vbasedev->name); if (migrate_add_blocker_modes(&vbasedev->cpr.mdev_blocker, errp, - MIG_MODE_CPR_TRANSFER, -1) < 0) { + MIG_MODE_CPR_TRANSFER, MIG_MODE_CPR_= EXEC, + -1) < 0) { goto hiod_unref_exit; } } diff --git a/hw/vfio/cpr-iommufd.c b/hw/vfio/cpr-iommufd.c index 148a06d..e1f1854 100644 --- a/hw/vfio/cpr-iommufd.c +++ b/hw/vfio/cpr-iommufd.c @@ -159,7 +159,8 @@ bool vfio_iommufd_cpr_register_iommufd(IOMMUFDBackend *= be, Error **errp) =20 if (!vfio_cpr_supported(be, cpr_blocker)) { return migrate_add_blocker_modes(cpr_blocker, errp, - MIG_MODE_CPR_TRANSFER, -1) =3D=3D= 0; + MIG_MODE_CPR_TRANSFER, + MIG_MODE_CPR_EXEC, -1) =3D=3D 0; } =20 vmstate_register(NULL, -1, &iommufd_cpr_vmstate, be); diff --git a/hw/vfio/cpr-legacy.c b/hw/vfio/cpr-legacy.c index 8f43719..eebb3bf 100644 --- a/hw/vfio/cpr-legacy.c +++ b/hw/vfio/cpr-legacy.c @@ -176,16 +176,17 @@ bool vfio_legacy_cpr_register_container(VFIOContainer= *container, Error **errp) =20 if (!vfio_cpr_supported(container, cpr_blocker)) { return migrate_add_blocker_modes(cpr_blocker, errp, - MIG_MODE_CPR_TRANSFER, -1) =3D=3D= 0; + MIG_MODE_CPR_TRANSFER, + MIG_MODE_CPR_EXEC, -1) =3D=3D 0; } =20 vfio_cpr_add_kvm_notifier(); =20 vmstate_register(NULL, -1, &vfio_container_vmstate, container); =20 - migration_add_notifier_mode(&container->cpr.transfer_notifier, - vfio_cpr_fail_notifier, - MIG_MODE_CPR_TRANSFER); + migration_add_notifier_modes(&container->cpr.transfer_notifier, + vfio_cpr_fail_notifier, + MIG_MODE_CPR_TRANSFER, MIG_MODE_CPR_EXEC,= -1); return true; } =20 diff --git a/hw/vfio/cpr.c b/hw/vfio/cpr.c index 2c71fc1..db462aa 100644 --- a/hw/vfio/cpr.c +++ b/hw/vfio/cpr.c @@ -195,9 +195,10 @@ static int vfio_cpr_kvm_close_notifier(NotifierWithRet= urn *notifier, void vfio_cpr_add_kvm_notifier(void) { if (!kvm_close_notifier.notify) { - migration_add_notifier_mode(&kvm_close_notifier, - vfio_cpr_kvm_close_notifier, - MIG_MODE_CPR_TRANSFER); + migration_add_notifier_modes(&kvm_close_notifier, + vfio_cpr_kvm_close_notifier, + MIG_MODE_CPR_TRANSFER, MIG_MODE_CPR_E= XEC, + -1); } } =20 @@ -282,9 +283,9 @@ static int vfio_cpr_pci_notifier(NotifierWithReturn *no= tifier, =20 void vfio_cpr_pci_register_device(VFIOPCIDevice *vdev) { - migration_add_notifier_mode(&vdev->cpr.transfer_notifier, - vfio_cpr_pci_notifier, - MIG_MODE_CPR_TRANSFER); + migration_add_notifier_modes(&vdev->cpr.transfer_notifier, + vfio_cpr_pci_notifier, + MIG_MODE_CPR_TRANSFER, MIG_MODE_CPR_EXEC,= -1); } =20 void vfio_cpr_pci_unregister_device(VFIOPCIDevice *vdev) --=20 1.8.3.1