From patchwork Fri Aug 6 21:43:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12423999 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2CE4C4338F for ; Fri, 6 Aug 2021 22:24:12 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2756961131 for ; Fri, 6 Aug 2021 22:24:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2756961131 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:57244 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mC8GB-0000TQ-2h for qemu-devel@archiver.kernel.org; Fri, 06 Aug 2021 18:24:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47530) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC86O-0000w5-HJ for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:14:04 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:18316) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC86M-0004bO-Fi for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:14:04 -0400 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 176MBqoY007330; Fri, 6 Aug 2021 22:12:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=7IG0uylibt3PCFRkEUpwV345IpenAzdM2NiCcshcivA=; b=GQao9IrD5F2zpxeF9IfuUlW2HjRjct1igapFlyPY93SV+hfq4mIYhoUuVtWtl1K0EQCt 8w+/WGw6nGuiQVlCRZrLX27ENpbBdbiS1UauWDCDawm2sBA74vx7WB98AqtpSWmr7B/3 2rchwODErGIR1skURCRAGm1h25mvqCcoEACWb5NDuPZrcQ+59Uo3x0aGCbhzqnHbtEBt xx3UF370knuPij/tG+ExBkIW4Eonu2ELL9wGc2B0R4mCu6TJsRQ1FtQhmudZIwb7rF4/ emz23UjXReU3Pzv+0egNm+Mn1HyXPJTLQ2PQZib46MiAcgWvJ5Ak6A7VBD6+zlUtVAsG pQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=7IG0uylibt3PCFRkEUpwV345IpenAzdM2NiCcshcivA=; b=amL6rJ7i4jLJBORoOCt+yu2+ooXCi1y01I6qf1kQNKpT4NANsWmE/x73BgkTrHT8BEZl Qed2RNlqUi871af7kF0wTPshmnB+xNUhL0O9U7CYmqZQ9NFu31191BkSgFUWwEaHUMCG UtWDMDvQpIISW7PdWFEhJeS8mKzEFZO9MoExalbAKpzmPHEVANYXNU3yzaboMWWvVag8 k4gsT7KJ3MPbBP0OVWFluthVt8a3i8LkmJfDH7FpIXxiEI/+SKUUI+Mqlqr114WJ0zPy 8b1A1AS488m5LSGYhRfYviA/BZY8GBusO5i9Mx2ZK2lSHEzj9Xyk/fyGQp4EHuzpBN4Y HQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3a8p6rjpkt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:12:56 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 176MBiLn013786; Fri, 6 Aug 2021 22:12:55 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2174.outbound.protection.outlook.com [104.47.58.174]) by userp3030.oracle.com with ESMTP id 3a962pfak1-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:12:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AXYoiuSgT9o/aOxpyfopYXkk7wQGnVp96xOIOPNdIF/2B8jjSGY+Tyrm7yvpQnJ5QtenMT0HXaRhoopoUE/xJ8JtEe9OeqZH4dar/5gR3dMHBueSJPHil7ugSTHpd3Q4EHmhgChurr5AFeB0nuh9nu4YaJgu8k5BfWRVagaT8r7u+84+wdISbJfhqq1JBdaCdTgwUf7ZIpTd3fWpZMyhQsshw6uw8V5bBbVLPsKoce6rKo2+pMNiIOBHru3PzGxRxCWg3dxq7xxWgvusYKagicZjUbihuSV/hlagtp+aRabKItryNR9h1UrdjnbDbcYspdzUD7HY9OiHuaaU1O+vcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7IG0uylibt3PCFRkEUpwV345IpenAzdM2NiCcshcivA=; b=DQIRUzwkQGFfkTcSx9+JfVx4R48XDgv9j2wtJwsG73EvvKxguonBb8qBAp80mPABim0TzauqDW4b7SCpVB17MHg93jRwY5CcUsyp/8rezRBOTLaMDAX3OA8dMpP86DN+iu6b/kynSJBNBsb89roUEAvYDy/Vb5aXX0kivQFSHmoLsuXHdcxGGAHgECl7bd22wpSKQmuFsYAJQ1G3sDhQB7l5jReDGSpB8vTDyZmEPFFMPT9zvgMwDuPl8fnfgycv/u1iA+B/AnR189ymT4QUkjgu3l5llJEK+A57Avb0dCEm98joayH3GaUMYXge72pJlx+2hlEVXuZmtMyl02eUkg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7IG0uylibt3PCFRkEUpwV345IpenAzdM2NiCcshcivA=; b=Fg2OlTRxhjsqXWGGiyTNPN+by1SgyKGN3KFIT2p8pJ1LIpklqVDRP6/Ccx2BPhyli9oTHbOBaw6/dVMkvDkGPf/RESEtAjyjrCHQ1kyxxPzw3wlQTEikBUX7KKGzi3XK1gsy62CR67XzmVbyMybLWqgVzuLVDkLLWYnDci5DQbQ= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) by BY5PR10MB4324.namprd10.prod.outlook.com (2603:10b6:a03:205::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.21; Fri, 6 Aug 2021 22:12:54 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3%5]) with mapi id 15.20.4373.028; Fri, 6 Aug 2021 22:12:54 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V6 01/27] memory: qemu_check_ram_volatile Date: Fri, 6 Aug 2021 14:43:35 -0700 Message-Id: <1628286241-217457-2-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> References: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) To BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ca-dev63.us.oracle.com (148.87.23.7) by SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Fri, 6 Aug 2021 22:12:52 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 707ed423-1eb1-49c0-2070-08d95927566a X-MS-TrafficTypeDiagnostic: BY5PR10MB4324: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:328; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QEpsZFNYBQMpzu6ibwu2TWFPJg2jxOv7ykF+bcTzb5MGJGTFzHLxjDgUjJkbJ6jbrZXjGUeZ/SKmlZTQMO+qu3l163rHVp+GNJUrrIQULSfip3uP4RWnsD5EChbgFwJ89wyiiqyBq0antdUy+j+bzfjxKT+aO7RyH1Qsjag5B/sYgbSIdPv8n8OGqkdfTdwWrK8/rFPyIKAeP49Yc5eyuygNRZAfBJ49BdkzUk3NggyYzy1XME4lxu5junM9ZoCLfK0/g1iR0/56NnPWAMEC21VwGLGiIkKmiRyuWhxHkcHjfun0FNVrYaLErmPQCQuJVvLLGLr4BoyOtlHcKcF4Racd0ZILCnWVDaMyKXAdY5QG3p37+A0FdCdY3M4u2NbI/6d63Uq5lAJ41UKuQuUpeF89axTb93UzjFcjl0TwAm66fPkWKrwFR7rVoyjHP0EvFo+XZJcs3pJyL7+1cRIYZZO2oH6NVGAMB5il1m+wAlUBzMCAGoOd4yDfet5ERMBSSP8hLwHMCQJIybpR3cflckhZMsxx1lYy6QlYZjMleXId7DJF3Prttg7fnYb8VFJKM3nL8tovZt6lt+vULJNdisTVjZ7VZa9KyGcOivvi8Du2Qdl11xcWluB0cR9Yu/NziJMNmcf/iB9TAcmmyy6zcJT/10iDtvLlEhPRD5/fzLEIwbV4WtPRns5nOqIQibj3qprCsh6dGpZYStZqXA3shw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(508600001)(6916009)(2906002)(36756003)(956004)(107886003)(7696005)(4326008)(83380400001)(7416002)(52116002)(2616005)(54906003)(186003)(86362001)(66476007)(66556008)(6486002)(66946007)(38100700002)(38350700002)(6666004)(5660300002)(8936002)(8676002)(316002)(26005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: b94HfYLtErZpQVvmTo4bppcE6aJnL3fvMEyZjg5H8XW2dWxioySeWh8ftFXOok0e5c3Q8w6LqbIYyTjRNn6z2s4OjBKG6yVp5qQY9VWDYejpSE4JM2eENifpPT380YWj4aTqVHG1z0191ZyqZqcKMwTLqDe6kXipSsAQcJKQfdrMfV0v27xTILCp6UhwD1aR9D3b5FWMAe+Y0Gdw0X3+YYHs9AmXonzF4tUuoUhkF18cVGb4SZQhm03cHUGPEA0QUGmcK2jkCURdqOEUHwhf96hWMIj/OsFSNKRvpM25wbyjSDiQ668eaegdxroFbbv/Dp6Kq9DLj8M1eWhsMKlXGE8QCwN1BHTsxdkc1oRgW+XRcl4i6oBJl/0vRPvYCImkva7pUCLXbz2tltSKYsa/bM2quyT4vhSZz7a7IKk4U0tAVXqraq+lxOtytk5xfESfDYRdIeYFfiQ2MBJ/s8yVIrrRmMFdhH18k7t461/bjxRWAspKKFr5hXBtoMPpluRNRTmD0b38lKCwoZDGcnmqE21hEn6uaA095QcJcM2n1/aXCxawZqUD831Cq7aAzSkCrLymyxCLJgXvpr90Wcm9Bsu3Xpo2+wDrsMBZhKu91R8dhvjws+9fVM0JExypxKUKJ7IKUll+m6uD70ASoMuw4c4IIIAn52TP8TqdrZIawDCYMHMYPFGvDRoIVOIkKqMUvFaUKC5EjJJqbRRxrCIGjceGE2aGk+mnWNrgm+bw3hmWFSAdQQiGs9U1HBEcorg0RgOqHifVvGyUW5NdcW+VVyiK7DYCL7+YzEBGEsHoKaoIKX5/TCSdesjDoOwn4vaRczxgugHI8Q2rNAZvm+vnhVvolBNDh/yxnwbmMUz2JeXMF6NVbFiori8kUzbJaLkl6KHtqCtWBQBwui5bMmIhL0uuLgel8Q+HZL3nLXWI8nDeZmecx7pvGTMyFvflumQkjVX83AbCTJq8qZNZV/V3yB3Bi5cA2y0G9S6Ns8mO5aFMRdTU0DudQLYuhzBP3JYL2D73wbWtVJ0qhdJdlSvRf/QxZ7w6qNQEbD5CtIfnVCQvy0KtVYhPiR1vjmTv2bey5ecBnYMCmAKunsNIIdJHg2E/glDxSsUNJ9UuHQMhQL1OhKrtDkksGTvRjjE8QByKp390wW6sgfj8VIZk4+lLFGzsIcF4rA4yrO700aHV6RYrrjO+CGwIki1/rORcH6IeTacfXjy4mktBfPiubEgJlJpPP/V09cut+46ZrQqgNqrinDypOYmzvMMnbs1x75P+GOwV23CmMEcrJsbgxrXSmjrnXX0W64HtBUM2UVF+ZCdxM1S+jJo9rMz2MtJO8TyH X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 707ed423-1eb1-49c0-2070-08d95927566a X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2021 22:12:53.9087 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: KS3RgUTwV5EIEVZ2iuK6Q4rXKfWozKRLqg1G+EohdHzeCP5k1oQRdjJVGz38h8gk1fBe5qbR+JUMpYt0SLgxTsIb/IrDOHjdBe+RUlSVcX8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4324 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10068 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 phishscore=0 bulkscore=0 adultscore=0 suspectscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108060145 X-Proofpoint-ORIG-GUID: d2Fec9x9ajYVVMLVBgWtXYfOOw3mZ5du X-Proofpoint-GUID: d2Fec9x9ajYVVMLVBgWtXYfOOw3mZ5du Received-SPF: pass client-ip=205.220.165.32; envelope-from=steven.sistare@oracle.com; helo=mx0a-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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , Jason Zeng , =?utf-8?q?Alex_Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Zheng Chuan , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add a function that returns an error if any ram_list block represents volatile memory. Signed-off-by: Steve Sistare --- include/exec/memory.h | 8 ++++++++ softmmu/memory.c | 26 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/include/exec/memory.h b/include/exec/memory.h index c3d417d..0e6d364 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -2925,6 +2925,14 @@ bool ram_block_discard_is_disabled(void); */ bool ram_block_discard_is_required(void); +/** + * qemu_ram_check_volatile: return 1 if any memory regions are writable and not + * backed by shared memory, else return 0. + * + * @errp: returned error message identifying the first volatile region found. + */ +int qemu_check_ram_volatile(Error **errp); + #endif #endif diff --git a/softmmu/memory.c b/softmmu/memory.c index bfedaf9..e143692 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -2809,6 +2809,32 @@ void memory_global_dirty_log_stop(void) memory_global_dirty_log_do_stop(); } +static int check_volatile(RAMBlock *rb, void *opaque) +{ + MemoryRegion *mr = rb->mr; + + if (mr && + memory_region_is_ram(mr) && + !memory_region_is_ram_device(mr) && + !memory_region_is_rom(mr) && + (rb->fd == -1 || !qemu_ram_is_shared(rb))) { + *(const char **)opaque = memory_region_name(mr); + return -1; + } + return 0; +} + +int qemu_check_ram_volatile(Error **errp) +{ + char *name; + + if (qemu_ram_foreach_block(check_volatile, &name)) { + error_setg(errp, "Memory region %s is volatile", name); + return -1; + } + return 0; +} + static void listener_add_address_space(MemoryListener *listener, AddressSpace *as) { From patchwork Fri Aug 6 21:43:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12423961 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48AACC4338F for ; Fri, 6 Aug 2021 22:14:26 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 74B0261179 for ; Fri, 6 Aug 2021 22:14:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 74B0261179 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:47892 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mC86h-0000Yz-5I for qemu-devel@archiver.kernel.org; Fri, 06 Aug 2021 18:14:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47032) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85T-0006Ii-Ey for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:07 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:63880) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85R-0003zA-Me for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:07 -0400 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 176MBlNL032562; Fri, 6 Aug 2021 22:12:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=F64+w3YSvZefRGfkU0pckjcMStMA3dKNyLg47J/KXEA=; b=plXHvsXa9lY+G9FJ8rMUa7d43yL4F/tJWPrK4FrPG0VC9/VSMixsu0kxXQm/r2HQALfV aVJjHamApC130rJ007A4oU6OAKs8LfJ2Kx8FfzkqIvrx2xZ+kPVPL3odWv2RSILLCkA0 1lzshtJDi7d4E1FdzH1DrAqtBsnXODIn3rpM5DgtBZckNTGKUs5g3FFIcToj2CZcZx0I 8BFU8Epi6aUmXO7nLp0rIA5UZ7j4sqoEQQGicMm4D9NaB1w/EBz7GcrazrPxp6rvT7JV Sz4N8Bw+f0f2LnQ4WI739GvbWK14S6jwsFU1u5mkqoaj2F9RNQ5b360lkGNNpQ2IP4MH mg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=F64+w3YSvZefRGfkU0pckjcMStMA3dKNyLg47J/KXEA=; b=ihwHr6N92LmVdwwFX/2LvfiP3PiOF/QCLTTCYPUSzGGqiDifPdZWm77zpNcr4oovpOHd vH1YSm6cpcUm+cFy8XGMV/Y1XkBF+e/3bychuo6qWjyr6r5q2yb9fhPDHTOfeeSOOO4Q d6WQ5budJiRNjziK956gHWXdrKFXbKZqhXlCD0XOO2Zk/1lf+qJV3PecJLvMaU/OeQmR m0zATqaDKUsWv4yFFfaUzW6OYBjOQVKm+cpxYhFGiaMNpUQ9B42DXntsUY7bWjtJCPRY mUOnLeQ1Jtg6dbW9unJd7vIVl0Mgc/itWjFvl7aoKBGnQBZ2pM6YIH4THOrHV4kf4mrv AQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3a9661s13k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:12:58 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 176MBl9R032685; Fri, 6 Aug 2021 22:12:57 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2169.outbound.protection.outlook.com [104.47.58.169]) by aserp3030.oracle.com with ESMTP id 3a78db75bj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:12:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lB1GsxsWFIzO104UN4q7Etlm7woacZBL9H5Ynu7M2UcYYvSR7z+DKmvhWPhcHteu3sCl4EOZHDbguBNej6uV5pFG1WCjqZ8MTzwIkcGujsjAW8YF9NNXYRkOULWYsZH+HE9+Azdgb/dFzEdoDQwMS0oaBtB5mGEM1/i70FCrtqzeGPGl4Yf7BPwFZPa636e4hzb0mdPwO0b+yGh4hcQRxsEyEXJXzWkjPjjS7JNDALs0DkAebVOrA2Sif6L6W/wAC3NfhixPPI1JfzoqwHBnxmGEnGfjaoTmVUYVQ18WaeAbI9IK5aj11nByhfyeU2W8f/f+Gymu0eSO2xE3ODtYqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=F64+w3YSvZefRGfkU0pckjcMStMA3dKNyLg47J/KXEA=; b=DpevK54luLSUiTRZo6aa2xgadA1JMMD9Uxlx5OZKKIJX5G0xcWoOHfZq84Ph2OXPXIfYjsx//V3xqXcJbsTkbmM1JQL5uRh8Okw7ynDH7mwqFXFFqcHtQxy1J7O9sQyTVuGM+pJZV4GOM4MtREJ3UDQl4xAnVpBdJYqxw8+vjp4Jg4Pi5E7iFdF7741zin1oU6dWhxRfbImSjUFKDbT7DrytNJKWBuWXa5Q7/X9p4sAV0vSmjGOcLayWSKbcigq+4G7isYTPy/d5a/eqZSy9CYb6hGKMLJgS6rJkJZonX3gV9xcUVQvk9BqJCHxR4fB+rBbWfe8q6x2iUwzojZX7ig== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=F64+w3YSvZefRGfkU0pckjcMStMA3dKNyLg47J/KXEA=; b=n7rEakoxyGxImR31JFe/ISL1AfaWxFrkT6Gi3M72fnYVkm3z15PZrFyahTtvBEMfApCrFNVbzOhhYCqbDLdWCnxpAQ6MzH8+3oaOvOfqlRLfXfcodO2GoVHadQONXAUss77uKYdXIPkFvFT1pncEVAS+td7Da0TcZUIC0B9iljY= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) by BY5PR10MB4324.namprd10.prod.outlook.com (2603:10b6:a03:205::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.21; Fri, 6 Aug 2021 22:12:55 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3%5]) with mapi id 15.20.4373.028; Fri, 6 Aug 2021 22:12:55 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V6 02/27] migration: fix populate_vfio_info Date: Fri, 6 Aug 2021 14:43:36 -0700 Message-Id: <1628286241-217457-3-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> References: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) To BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ca-dev63.us.oracle.com (148.87.23.7) by SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Fri, 6 Aug 2021 22:12:54 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4ed80a6f-da02-4b0d-4989-08d959275789 X-MS-TrafficTypeDiagnostic: BY5PR10MB4324: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1468; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ONXpM8NXVh2EgnLAB9uHfauwrv2J5PImI5449dNqCeUzgw9eF8+ZYwMR8igxKJutIvkkzlr3hEuMNUKqsGZgR6Nm+ClD0k7iEHeOA0kwwYheXyAoueg/S11XcdavqrFo/gCfvzVEbBuYNChtzI3Bt3Gn2pDpwXdLeoknLhq8X5giKAEsiO/+rkyJXr56EdicjWYUYEpWVv17k+uI4PeOjpv3iVphZvdQC7s8eOg4IZpejuOGDNv515TUMbAC4JlR/WiLh8T3hh3rFF1qQi+b3CGI+rGICJG1ZPGaCwwxZrQd3+UwO5MUigvQ/qnId6cz4qmb4JvAcTKkqk4QxG0gBES43VbY8Qy/+XMNOw35pZeA12LqSHzUCdu6vGCKwCSyTbMIoLiwKSeUHpkCwK+UOI5K44CKekhQ6tksjgryjEQW69psFf1rP7JAYKxTMAXQ6CL6o5YR7nYM6J+n9oqcAc4xYagaS20OOnSGSl0rKjddUHQRTRNcFcpkXijyj6nqBjS7ZvikSI0Ic3rSRjGHx7T8asT8nkQRscEHskhgKqyoykCBlG70+fQuDWO5J6upmbuX2ZKRYs48FTu8TPMyeFmywQ+d5hsM/cX7GEyf5y4vJHvYfv0pJ38Rirr53yBiXrG9TO93S08j0DI9yErOXW13pyiWK3HWwfU/vCEHw17bDjLoAzDtnlYFwbbezc+OCVYNXwoqyf+9TB0lqEVXhQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(508600001)(6916009)(2906002)(36756003)(4744005)(956004)(107886003)(7696005)(4326008)(83380400001)(7416002)(52116002)(2616005)(54906003)(186003)(86362001)(66476007)(66556008)(6486002)(66946007)(38100700002)(38350700002)(6666004)(5660300002)(8936002)(8676002)(316002)(26005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CEiwkfx7WFYSuDdKQSYWv5fZV9bGRy3H7FAxvJhkS7WvKWWMnJkf9lkQrX9FJWlrn0mCE9Ao1vRU85jHmYHtrZVDwBjd8JDg1uE0vg+RPQtDekPC+3uUMeQk1zqxMZsrmoTmk0z07r0hJ2wnvjqb7lKKcQs9nulnVDLRRtrdu82uBzuNnR4bQJMJcc84F77jb1fVPNU2giyQfftJ1tKwvzP+udi6gWW8cFcFotI6UcXeKlYwGXJfl0VYX8ntjax5Y1EcKFKTg4/IOzDBJKQbYESMuROk6PLCQ2Nw5MqhHXsH9tLhgoXEEXmTattwVwsI+Jp/YvaDMqt/DeNKQYAtGpVpnyLZdcOYRffkPKO6g+mQJYjpkb6lgabnNsikTjYDhmDJfzlJqRmRbivZDsMdTDRQtCzZCHV+6w6JiGnayCa7rwG9JbBQvFz0AQQhOhvFMJlyEHd9u0Q1LR42ajk4ZiniUaOez+vvdN4ML7XpuAN/quS3FA39+8jA5wndPe0523N9Ith+1hfeI4BXwON9EmpZNPTqDEY48/J0N0ACYG3L3iH8YLVTwOrMO3lFrqbazmwIdn0jmiuyn4u69YkDYzejCtYvgCP+E7rOTMT7kzUREb0qg8CYXc4JMax7UO9VfMWstSEBqkCEBg5nFLS7M2Audqr407ksj0ubrOa/QjM/ZVVJ5LsnWQV0jDf787iDUcO5YsU0pMZHc3qrjWAtCnSgG3F3gewBkjzbaIF8LZyYq+9Rzv5Kip+31MK64Ry93t5NsMLku/mSXDXctYp0Eyh658M8okuTFSF+YQnQPYwzOPHDfivj/xgVj+uQVWXcmxz3uY5SRYO4NLTuOM2sS8+lyzSGXo8TMBvU/VU/Hs+smPBavGFYptr7eg1P6puR+/6ARM86fZoMnq9TAwQnk2DiCEcys+Z7KEgMAfThurrS2Gx47vBuU7QLPsMMZ90ebJyRYqP499m0SkERCDim+YgpCwA4BLfU10tg9uIJrhISFc4SaZQY1HKH/zDL+jOOLRW/vvwMn1DSAhnlaq1pZyp9um9i91Yqq9muJctVGaBBpHEG1bjwE8+cjGA4Z1C9S7hNhrWySe4kwbj7Kfb/bCVIaEAsbOc0IaN5YDUqdh8iHwS/hvqY/embOJSlJCqUjADPSDQZm3F7siG+z0GQlWP8ttKglqFEnTOqNJvc1jKhviymEWMSgeu6u5fmKqSwpFkyP89wBD8uJlsg7Rn9I0puaFPRHjO/e1v+7tNkhd9oMEm/gtYU5a5mwoY409IM0lKjxts18qS7nxtTEUScg2pBisnj4xzbzPpZpOrOxf3AAFgg/kleSf+QQbkMDdK+ X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4ed80a6f-da02-4b0d-4989-08d959275789 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2021 22:12:55.8096 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ao7HtVvV1FIebDMxwrvl3ANdca7epbnEko1vQY07v82rjImpzBnQF85pnZwHpQjIxyeUFZ1Kn7oA3OExIOSaUI/iisje0Eha2STn7Cn92iw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4324 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10068 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 adultscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108060145 X-Proofpoint-GUID: 9_NELxw6ZkYYcBau9R_h1l3WsKLHD7vi X-Proofpoint-ORIG-GUID: 9_NELxw6ZkYYcBau9R_h1l3WsKLHD7vi 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , Jason Zeng , =?utf-8?q?Alex_Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Zheng Chuan , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Include CONFIG_DEVICES so that populate_vfio_info is instantiated for CONFIG_VFIO. Signed-off-by: Steve Sistare --- migration/target.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/migration/target.c b/migration/target.c index 907ebf0..4390bf0 100644 --- a/migration/target.c +++ b/migration/target.c @@ -8,18 +8,22 @@ #include "qemu/osdep.h" #include "qapi/qapi-types-migration.h" #include "migration.h" +#include CONFIG_DEVICES #ifdef CONFIG_VFIO + #include "hw/vfio/vfio-common.h" -#endif void populate_vfio_info(MigrationInfo *info) { -#ifdef CONFIG_VFIO if (vfio_mig_active()) { info->has_vfio = true; info->vfio = g_malloc0(sizeof(*info->vfio)); info->vfio->transferred = vfio_mig_bytes_transferred(); } -#endif } +#else + +void populate_vfio_info(MigrationInfo *info) {} + +#endif /* CONFIG_VFIO */ From patchwork Fri Aug 6 21:43:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12423965 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 784CDC4338F for ; Fri, 6 Aug 2021 22:14:28 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B70E461179 for ; Fri, 6 Aug 2021 22:14:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B70E461179 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:48184 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mC86k-0000ka-Ko for qemu-devel@archiver.kernel.org; Fri, 06 Aug 2021 18:14:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47050) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85U-0006J8-NZ for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:08 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:8272) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85S-00040U-V8 for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:08 -0400 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 176MC34m023309; Fri, 6 Aug 2021 22:13:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=emhj1NmXHkHVB4VTfPgnA0+3jmB42gCz4diX8NR9d8o=; b=0RJnoV8EjjS0+De1YoKSWnVJ0tdAPN13ABbzarnxClgRNDQMNeV9v8nhaYJAbvtALi5b Jsm9h56mKSpxgMA9kyvWnf6UoWJ3bFini9GxTIfCq8PmWIh5LAlFDFtUyo7WXTz7GHmn +PBQMfvRVM5gbFgVZOA310c/MknHKLEBPz++Y2TWPzSdoO1WqR5a4Gg0J1Dd2Ed9YKQN aV5CryQ6s86nCSIDXfRBABAkyKVhkFYHcwQzVAWUlzvSkSCm9bhi3obbiua1fJPcJtKi bJ8JwOyCD2MlTd5LqY+kHGjj4uocCXWyn893zk5ihSOGkCxJqVLGqSQAaGHbtJG/CB/g mg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=emhj1NmXHkHVB4VTfPgnA0+3jmB42gCz4diX8NR9d8o=; b=VyWu02qJAae/11lw0FAMkxR6B7hsi+VxdSPK3eNEtwSErR+rmH8KSjHsT4gi++8kL4Ek eqLzQF44y1dIwft1Z+vg3z8Rc49EDbcKJM1aaiu+XEY/ZYY9StpFYVsGzPRlaDx2Tn2M pw4YrZdRa6k1klB0ON5UqWVcB/iZcCS5WzYjlOYw5Ig0vrK9oBe/+YYd0xKdXoxwyfqa 35kGXRhk9nUrUNoTS3XMiVcXrchfDk8rGG6FoZo2zR7WoVLDaZMns2Qc/rRtCj8iUoiF yPkFryMYL8ZZ0OKUySLV14bpc8m1cbFfJp2ALN8Whuv/I/wDzrAAX98ZfNrbZRiE49W9 pg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3a8vy3t4xb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:01 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 176MBh6L032630; Fri, 6 Aug 2021 22:13:00 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2177.outbound.protection.outlook.com [104.47.58.177]) by aserp3030.oracle.com with ESMTP id 3a78db75cd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:12:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gOdaWKJtte5IALrjYwhxxcHvvWFJeOyKWa1kKjDWAw4hcIJ56t+bfRhpG+pnAFgYXU4xrtfEwZkax5Qat1DinUJDYioEU1kX4ELcMLPojTrc6VxM4MpRUSh8dOP6EYdbJ6iMs4aVJz06pNLbFbUmzGb5RPaBkpQjnbk1QGFoBKnP3DvP6/qt7UrT4Cl1NxaTWmFVIaLzyUEXpLfcUQZUOYi33gjpaZ2Z9gdHAbxqVodOscUV6nzqsmT++FKFJ3YWEGWf7aPE+KaORwvkqKUwjqO4NXQEk+6GGCkmxmJSXpmQSEJsuXGydROdmTgfWFdEknSxPOY0kdxLlZjYfl1s7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=emhj1NmXHkHVB4VTfPgnA0+3jmB42gCz4diX8NR9d8o=; b=EDPeY0wX34KQOi0xnswWKypWNDJrQshj556S1SKh9JY64y5oW06sqXo8ZhgoxEnAxBEh253ZtvzXZXCwBWW+LN1tjck8dtDD03lgl/Z2Uv34QDTNTsjptHq4oVDEwbxjtaRxgPIUN80anu0MxKLZTBNxihOooBZ0Il99Fn8IWRIbWN2tF6rmTqgnjNYe4xEjFAWzjb7uvI+MMAggoaVc54zlF1RcdUCcmS6vsranfmHz94TWCOmwLLEhzGZaB4oEgA9LLKaDkURk4pZHXYWI8y+lfvZGCPdQImGWX1fmSehrvwOfbnX7tGhTiPANTCsEvSTxWSrv3Xk8j0z/Xsc9oQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=emhj1NmXHkHVB4VTfPgnA0+3jmB42gCz4diX8NR9d8o=; b=piWJU4OZ+YoKBqbSr75R3FNI+p31KV2M4bqgzx4VHY9o32juvnqK3WjFluyCkdSv/12QByKcosYdcS6WSQ7kVTKBNDlxt1FjRR5AIdofRhVpHYIe/I7g2NW/GVViO8SCEQgpkHgyHkAqltrpvk7DbLDY+alnMNamsDvrqutt900= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) by BY5PR10MB4324.namprd10.prod.outlook.com (2603:10b6:a03:205::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.21; Fri, 6 Aug 2021 22:12:57 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3%5]) with mapi id 15.20.4373.028; Fri, 6 Aug 2021 22:12:57 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V6 03/27] migration: qemu file wrappers Date: Fri, 6 Aug 2021 14:43:37 -0700 Message-Id: <1628286241-217457-4-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> References: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) To BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ca-dev63.us.oracle.com (148.87.23.7) by SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Fri, 6 Aug 2021 22:12:56 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d64c4d44-661b-4f95-f016-08d9592758ad X-MS-TrafficTypeDiagnostic: BY5PR10MB4324: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3631; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QxsX/GCQEU2lgD7edNT3kqqT4w6KIQ9jvN1/5mBxoyHcDqdNKmb5EsS4aQnxaqYPlhYpPHPkq8+ugJWU4NyzN9BVvnM/xKP6DQv863wZwCZxiIXuRlQ73PN5a2kN/BHaFp+vpttoRJato/mn1rciliWuQLnu5epgz80XzclqvU7PwPWDZcN2njaUJq/9gHoomb2lFyF8ZtrBH0mzXqj4XL9hkYGTYjgJp3VR7sbZQM7AJlT6wL8oavbGGkQnMG4CxciJHVeHmk6sZEzIQ4ll9uR5WPkvOb9VriHGY0SmxQITqZw+K5h1Zku4DaaCnb5xlOCFBbMOr9cR/uFPakQeLMZxZH4si1J7w9nEJZGPr67T5wRB9jFG4TKiDTdrgqVhu8KUX6oMYtOrDj6zm9ji2/L4lnJQQ4fSB2iE4eoHo0LRiOgO9w2/lktq2XxtMkLbyFiW/cmbzphFT0daGaTd82rwIHsjdQPPBzLt50q0j+qVpNFGpBQO3EymMc7r5B4NK8I3QahwKZpKiFAqlK2FooYl9+12m2TDJjwg9AhcNTYDa5NJwRuqn2i0SAmtmYQA7dgtQ2diJ1cHifdN6As31dKo+0/YEr4cPpkiS4QsQOCx/4KCjTCIBPNgxtjxXu8b1olEnQ+eZ2ijpicrtBZQP+4EXfOfWJNfpBv8OLfs5JXtaGMskSORNYYx5SMuDuqN X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(508600001)(6916009)(2906002)(36756003)(956004)(107886003)(7696005)(4326008)(7416002)(52116002)(2616005)(54906003)(186003)(86362001)(66476007)(66556008)(6486002)(66946007)(38100700002)(38350700002)(6666004)(5660300002)(8936002)(8676002)(316002)(26005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nfUhCYXRzMrwQMotjfIB23hEIclNs9bFV5/BM75F4pO3r4CXbpHDHt+Twl/YSnPI81cFFBS1L15kayMLr5Y0cPot/a1LEeWTyCBJtk4g+AaLpUrTod+BHV+5gtVDGJWQ01IwbH5NPhhTllX76c1grqOvkvybrPL2OzzGCAxpdIUl146nlBiII3P+xv/RZ8BsuLl1dXZpBzLdj4hJuP9vVnqklm9dB7Wb++RLKAKaA7LEWLMzWWiDyzXLA4rjDb9l+3p1Ho50rRfohSJCVgY6qT5uCwWlndfa9r5nQ7g0TJ241Yl75Hvx6Tuf8RJjzoKvJc1sGNIzm8v4PpdvE4GuywKxSMCPVC/uZcBJcehpYz3pBk7+AA6bqIQbfJ2N3laMn5W1/MTG/GzuKNYTmsk4zaZKOoSBVUWDNCqzbg+2IrQpwW0tot0WkonW+zG8abygm71WCbY6pPbXvt2clIfof+OBQpG07tE9kMo0THKJv7H7Wtc3M1drrnzvAp/oEtnuykAwHKJQoGfOh6kb09h/1ZW7q9PJm9M5HJn1OQQaVKI7wbuBVsaWWasqmxzDv21iUnW5tKtIMHfKcgdvTR3YVgYUTmEP2lRCc6dRW+b0AyOuW/ZlMJvOu9mXApSH4eNVcMwBB+aS1vW1tEja1ON3WSjKnNZaWybWzxM4VM2+DTaJaWQPKUhXmI4gbTha2MQdmfUmmOgw6neiIn/nSRa2XEnQdH5pB9ksxIexeSpii4V58ShLfX3nCoK873uv2lTgmyskQaP2GLea5NqEE0Pe+K/eDRVfZKeN/1mcjPEAKaX/Bpf7Szq6TmWHH0hX/LNcUyfN4K8uhBhhoDHWceVUp19EF8eQjSa3XjdCJstUc/HC2WainpU88IMFmUca8wFgSXbdUQmpeHZdQoOJW6iqpLWockVprGfF9FsXVuyJYiohwPMs/5/NA7NvHByrQOFn5zpc7v0f61Cmg/uOAd4B+0bcqZl1diBWl7/dm3etV21KWydLxegi6gdw4BEfJMlz7l3ox5staErcIev7WHHbRxVujLZeot9sEadmad7Uv13r1KJtiOJkLvjU2MIYqkgwy3RGowQBAHeSYDWthvSYTG5wJ2pLZTzzr7Q470Ke2ttRy0brUiysiyBmfU6vK8opS0Qj3Xo89PhBtrO1btgn2MvZC8TGQfpO3qRXu1Ot5ZVy3kwUbserIykcONwcvR1gLbOOK6cZAYZhBJVlQC+Peb+LCTlIvRbN8FuGOyichlso4FIG32AzvqeTl2hIYfFOemx0pLoydH3n1t63WqXEb3lU7WnuDb0IymXZeKXlV5x5dmkiXQX3WMaEvYMkfC6s X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d64c4d44-661b-4f95-f016-08d9592758ad X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2021 22:12:57.7415 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: CQad3itAHr42VrCkfrSHgNqPl22sWHX4/zprAYADyqJ1LQw12av9VF0S7rbpLVYC6fO3HbYmPysYYDNvzs9PuKbKULatKNfy3DKrIsk/z0k= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4324 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10068 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 adultscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108060145 X-Proofpoint-GUID: oLIDN0yONmb0NGXbf1xiOQMRwbck1Sw9 X-Proofpoint-ORIG-GUID: oLIDN0yONmb0NGXbf1xiOQMRwbck1Sw9 Received-SPF: pass client-ip=205.220.165.32; envelope-from=steven.sistare@oracle.com; helo=mx0a-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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , Jason Zeng , =?utf-8?q?Alex_Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Zheng Chuan , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add qemu_file_open and qemu_fd_open to create QEMUFile objects for unix files and file descriptors. Signed-off-by: Steve Sistare --- migration/qemu-file-channel.c | 36 ++++++++++++++++++++++++++++++++++++ migration/qemu-file-channel.h | 6 ++++++ 2 files changed, 42 insertions(+) diff --git a/migration/qemu-file-channel.c b/migration/qemu-file-channel.c index bb5a575..afb16d7 100644 --- a/migration/qemu-file-channel.c +++ b/migration/qemu-file-channel.c @@ -27,8 +27,10 @@ #include "qemu-file.h" #include "io/channel-socket.h" #include "io/channel-tls.h" +#include "io/channel-file.h" #include "qemu/iov.h" #include "qemu/yank.h" +#include "qapi/error.h" #include "yank_functions.h" @@ -192,3 +194,37 @@ QEMUFile *qemu_fopen_channel_output(QIOChannel *ioc) object_ref(OBJECT(ioc)); return qemu_fopen_ops(ioc, &channel_output_ops, true); } + +QEMUFile *qemu_file_open(const char *path, int flags, int mode, + const char *name, Error **errp) +{ + g_autoptr(QIOChannelFile) fioc = NULL; + QIOChannel *ioc; + QEMUFile *f; + + if (flags & O_RDWR) { + error_setg(errp, "qemu_file_open %s: O_RDWR not supported", path); + return NULL; + } + + fioc = qio_channel_file_new_path(path, flags, mode, errp); + if (!fioc) { + return NULL; + } + + ioc = QIO_CHANNEL(fioc); + qio_channel_set_name(ioc, name); + f = (flags & O_WRONLY) ? qemu_fopen_channel_output(ioc) : + qemu_fopen_channel_input(ioc); + return f; +} + +QEMUFile *qemu_fd_open(int fd, bool writable, const char *name) +{ + g_autoptr(QIOChannelFile) fioc = qio_channel_file_new_fd(fd); + QIOChannel *ioc = QIO_CHANNEL(fioc); + QEMUFile *f = writable ? qemu_fopen_channel_output(ioc) : + qemu_fopen_channel_input(ioc); + qio_channel_set_name(ioc, name); + return f; +} diff --git a/migration/qemu-file-channel.h b/migration/qemu-file-channel.h index 0028a09..324ae2d 100644 --- a/migration/qemu-file-channel.h +++ b/migration/qemu-file-channel.h @@ -29,4 +29,10 @@ QEMUFile *qemu_fopen_channel_input(QIOChannel *ioc); QEMUFile *qemu_fopen_channel_output(QIOChannel *ioc); + +QEMUFile *qemu_file_open(const char *path, int flags, int mode, + const char *name, Error **errp); + +QEMUFile *qemu_fd_open(int fd, bool writable, const char *name); + #endif From patchwork Fri Aug 6 21:43:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12423969 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03D05C4338F for ; Fri, 6 Aug 2021 22:16:19 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 494B261104 for ; Fri, 6 Aug 2021 22:16:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 494B261104 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:56436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mC88X-0006Iy-9s for qemu-devel@archiver.kernel.org; Fri, 06 Aug 2021 18:16:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47060) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85W-0006Lo-4Q for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:10 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:5148) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85U-00041W-Ch for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:09 -0400 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 176MBWWm018324; Fri, 6 Aug 2021 22:13:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=OKKOuV3blUX4dsrfiH5BTzFtFcC9xu5Qop+ku8LKBiw=; b=ekJRT6JdsidLMDjR9yT8I4dvXaZ/8De4lKyjBJbi3QqbyhLOvBbH2K1Q9vE5EHfC6TjT lcYEfY87iuUyOWNdvbLsQiAu2VNZB9X4Yi4OU+pbmRDN702Y13Ge/eWLv5NuCnzmlRwQ /qX9hXn+kL/l9leKbKyXs1KVdr1kWqfTPvETcdMPVgy6tmxJYow2BXIv/LzY7oC9+euL Zcma1SDqagXIxxc36gk4oloYTw5zXcfLHkX5f1cUP4OaqM7yBQJK62QL2pS0NmldVVRl Vjy9yZAQo3HBOceKybE/VlAcPuKs8kVC3mKXdptw0ko3nC0lw4T/X63mFXPAQCglfYJP HQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=OKKOuV3blUX4dsrfiH5BTzFtFcC9xu5Qop+ku8LKBiw=; b=ShkgauHJBmpLPKrNAhyKhO32WmY4KkjRZZvJJoMUPP0Sr9ySkGiSisPmwSzf65XseTk9 4k9TlBQA7XFAFyrmR8+o3Xv3fZ/1j0zSNdswkmzBmj10H+c1YIZ/0lOi/hoXH2r74PPr sbxzipeJCEdAPr/n6Gzvy4EUxE6ZrqcR1ycjQNCtvpZEt/h7D01MhilTPF75KYIXolaE KPvOdaMbXMNX5g1V0MxQ1oNGPrJHjsXCxowWJRz/+le04uH5sJErU3Df3V9szrQEjLu8 wqEHwGTAn6QafHxGRXaWFQpiTudPYIHlFiJ0GbLZDdddqPdTer23gntdg6DrVERhDdjw wA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3a9645s12n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:02 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 176MBm93032743; Fri, 6 Aug 2021 22:13:02 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2170.outbound.protection.outlook.com [104.47.58.170]) by aserp3030.oracle.com with ESMTP id 3a78db75d4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vl665pDqxwM0C0jOkma4sgTZHrkzKLHqP4rdEKs1BdllWJaDINZK/7nQcOVLsObwYKy51LAWPoqIPwseV8PGBpUNcYxIw3Io2h+9Cku1Ua+mZMGR9xFBOzb6it4jvvHLnABvDrrbRGW5QRohMHgqNXbwB0QsHNHPFcGJPV8vo5H6VBxoON1JkuJLeA0CrsMoiGSOnRVzMWosXU4nKjtuX2YMM1hN/Ql35HjEL1YeRuzYetLfLj0YWm6qSrYtWrSyFgeybl+4QwRHsccTLmYeMgQ9D+SVRxfKrQSoJhhh0MCvF8TBGoVBekGq7dgUH9OWf0fOOkcbjRCiLuqV0EvHgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OKKOuV3blUX4dsrfiH5BTzFtFcC9xu5Qop+ku8LKBiw=; b=XRmrkCeHp6Od0B0IxypiGPefzuFqtQu90sftNWK/htthQ2Q042sRTaPHx0DphL6OPTQ6W+CWhpKeba8M+3rXBRQfnRjfQ1X8kQE99rSSc0MgZ+AorT9mEq9RwwfD3L/WBZ77nbZ5hawR3pj5f5odJVksHlS8alz7+KIWNQj9aYb2IKTarYDnwHE0QsZQtWri5ktg1ep4XQzrW9VhMZnyB1utJ4qxPvj8e+VJkxK+MZ1I1HdLLX8H9SVnMkkLk7TlEdNckUnqILUB36sZcyHvHV/Bbt85UXfHdbC9xWHOLJvVjbYguuHaajpzVkJiZZSWbJGg55x2SiEI9PZIt/+clA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OKKOuV3blUX4dsrfiH5BTzFtFcC9xu5Qop+ku8LKBiw=; b=0UTUR7ZFhOlMB6Aje5QPaOQETBpYtE98BacVFUzEe4ntCB6/Ltf+23VY8N40KG6tR+YZgnRXhE573ob6LBE491uosFbQJBPX2ISBrXhzCGnEfDz+AwYb9NrAmcZLvsAN50zfFjbIxnZSrY8Lnk8KOtFHumeiJ8FO2XSjO/reO6c= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) by BY5PR10MB4324.namprd10.prod.outlook.com (2603:10b6:a03:205::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.21; Fri, 6 Aug 2021 22:13:00 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3%5]) with mapi id 15.20.4373.028; Fri, 6 Aug 2021 22:13:00 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V6 04/27] migration: simplify savevm Date: Fri, 6 Aug 2021 14:43:38 -0700 Message-Id: <1628286241-217457-5-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> References: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) To BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ca-dev63.us.oracle.com (148.87.23.7) by SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Fri, 6 Aug 2021 22:12:57 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f5952da8-651e-431b-fa7e-08d9592759d1 X-MS-TrafficTypeDiagnostic: BY5PR10MB4324: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3968; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jsEIcs1jn8G8zgzfmUUz/7t8xxXA9gxY4GeSycMduw7rgb2iju2Q1FGS8jXN9sTDlvjfo3WJRMPbbQjSrarUY0z1UZyV3O0CXSvaEImg8JZQG+DJHBDRfygCAzpNEByYW3B+OQE3OZheyg9IcCuACAix27Sv8KwDWTStpLzclNsUc4zXgn4Shoq7xkWAlHxg+RfgTIGbCFi0lToFPiz4Axjx7Md7Y2pdknf3L9W3oxcfPghQmSn9QW6B7lcBoWCSCX62IH6EznB/jDNfQnruzMdWQlVPkGYbQ8PpVH9JDLJYJuSU8Oq9GiOe8OwTz4E3rbjS6veTARmN6xkuWRJojVVMR7IfpP1BZKJfVO1LyGxF0edLaY1e1/1zlDJkoWteBpq1JuNyLL9XIVR6P8xffMgM6C5HwKVXniykb7Vcw0ScRF++JmYEKANySO5X+KAG/uXnWi4plEDZnqVX7GHJFZPD3ACPHcYdAvqowYh8KhLl9tHfxmJnkfVQWNapadu1c0E1MUQOwsDvmBTEnjvMX8uFtOq7G3FJG0rIXMjFCkT7ZVC6sZufsV59o+Crvvfr8ECUmDc+B/mg03NPO4WO+Xfdyd02qz+9J3iS+jEY2QpGm/53zM8FGCx/tctVQqU9peRVM0JY20mm4DTF7arvvFCkRZaRyrCzp0k0HW+TEBnIQ4gZr65PyzxDqZ1VGEOq2YxKorxD4Al1COvTqL1Ibg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(508600001)(6916009)(2906002)(36756003)(956004)(107886003)(7696005)(4326008)(83380400001)(7416002)(52116002)(2616005)(54906003)(186003)(86362001)(66476007)(66556008)(6486002)(66946007)(38100700002)(38350700002)(6666004)(5660300002)(8936002)(8676002)(316002)(26005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XMMlaF41rq63jF7rt4UpURAmE/0+ZtolNcCHf7gx8kIkF/BoBt8a9kHXEo9rICikEw7a/JORYhuxdGhZ1na4Iy/KQaE1mmzlaJJhfsMTUzZpnjJjfKNIvK5R7Aw75DEeR3i6WXLnhLXbK5sF9cwqbLZbqd3Aqn+tPGvmwywcQMwFkdunq9Xqzb1X3Sij3afZmwpNg/PNPiD7lZXsmUngwCjMuTnGaoYyerOfo5ACAYIx4l2LacG4OPjZFcQoyAjewnwtdrxUpWqnKc/3sLPEj7+8nV4tZRTcCAB9jFu2/OZB2kxCCJAhMxA3B/+pxlCxiU6kv5k4W4oU7RFluzDoA0Ezs0M3HoQr0XUS+aQLfNINUYIDdNnVx2CAHlVuXrmdB5YJ+smGvsYV9drU4FxwnxLOrB+xiOZamoQQTivshdCy8H9qXcxP8rPlE2YyXK/OR182qT/iUCW9+sDbPqie8ZuVbA2AOZ05fqeM+r3+5u+krHLK207gR3b2mf/FuKqHbRxXc+lB943q7aoKMAdbTNQ7De1zbZJRy/FTu58wejRoDnurL/y20R5FKbdQgNgq6NUzLfkXpWD2Cvwha53jS10OT1ntUB2y5/BjjewsiV2gY79NkE1CiibW7Et9bMsIAxnbymjolX5ZQcHNPw9lL87DrjbyA2ak/HXkvJ8ImOyuC9vg9xpSfQCDjbSXh4YdkbDhf82Q1OsixwTLG83ocN9rArpw6AtROowTtGv84mikWK1Fjx73emPyw3CUWYme0mXQvZjk2MAQ4cDwQ5QZGnLvsIIMvdiB4f4NU1FpdxkZJiom2gTYE3GdwfcCQ1JydhJRdgVvUcv1sJvh46cNczIC17V2gljlJWwce6HZo9SqE4aFe6k1hfUXRHAt8mmqitveK1Q3Iy7A+9qIiZs1zSu/p/DGPXoH6GrJpFAHvGJjhMkUSe13SUudvWjpz6sJoHA434GqhUj30JvPy9NypiwVKGZC/LhvHMazQhViJGx+Mz1YXGwQWIMm2YjMcYgY8Y/07VzcFOKP8dSRQ8FKcqAjG3YZ9JVk8UhSJNDp2GlXfpHpvTPzEPInoPBmJ6xNXH//vWxj5q7DXKV33Y4sROQQ7UGvSp7avzLm1JbT9hDCHRIGYEn7LGHRHCLoAWJ5D09/rV+eh3Ql+lzwnNW7HSK42gtteVM5wJK+BbPKQOlNjEPz7bdLBCBMt+qonHxBHNC3qjFfWdpjJP0BKtx+5W6kI5kZaWFljQM6R2On3BXF0waxJ2KrAFyiQQXZ6e+xxDqjRz4WOP9gVaC9cRTrbmcNzNh/9l1WTj7OdRvOyQkqEcIXgbJmjuR8nI9TjggY X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f5952da8-651e-431b-fa7e-08d9592759d1 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2021 22:12:59.9273 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: oNgDAbqwAtYsZjKGLFfCo2vnYb5HQzkMVibyWUnaBzJLbNKMfUrkXkf9I00Q9g5VNXfwvQ2QM9j+c2mamRbsoK7bCzoKYc3cNzEBCPbjKV4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4324 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10068 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 adultscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108060145 X-Proofpoint-ORIG-GUID: 8PoFNYjbAx-WmGet1ywroJUloDRS79Jq X-Proofpoint-GUID: 8PoFNYjbAx-WmGet1ywroJUloDRS79Jq 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , Jason Zeng , =?utf-8?q?Alex_Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Zheng Chuan , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Use qemu_file_open to simplify a few functions in savevm.c. No functional change. Signed-off-by: Steve Sistare --- migration/savevm.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/migration/savevm.c b/migration/savevm.c index 7b7b64b..bdd6ef8 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2908,8 +2908,9 @@ bool save_snapshot(const char *name, bool overwrite, const char *vmstate, void qmp_xen_save_devices_state(const char *filename, bool has_live, bool live, Error **errp) { + const char *ioc_name = "migration-xen-save-state"; + int flags = O_WRONLY | O_CREAT | O_TRUNC; QEMUFile *f; - QIOChannelFile *ioc; int saved_vm_running; int ret; @@ -2923,14 +2924,10 @@ void qmp_xen_save_devices_state(const char *filename, bool has_live, bool live, vm_stop(RUN_STATE_SAVE_VM); global_state_store_running(); - ioc = qio_channel_file_new_path(filename, O_WRONLY | O_CREAT | O_TRUNC, - 0660, errp); - if (!ioc) { + f = qemu_file_open(filename, flags, 0660, ioc_name, errp); + if (!f) { goto the_end; } - qio_channel_set_name(QIO_CHANNEL(ioc), "migration-xen-save-state"); - f = qemu_fopen_channel_output(QIO_CHANNEL(ioc)); - object_unref(OBJECT(ioc)); ret = qemu_save_device_state(f); if (ret < 0 || qemu_fclose(f) < 0) { error_setg(errp, QERR_IO_ERROR); @@ -2958,8 +2955,8 @@ void qmp_xen_save_devices_state(const char *filename, bool has_live, bool live, void qmp_xen_load_devices_state(const char *filename, Error **errp) { + const char *ioc_name = "migration-xen-load-state"; QEMUFile *f; - QIOChannelFile *ioc; int ret; /* Guest must be paused before loading the device state; the RAM state @@ -2971,14 +2968,10 @@ void qmp_xen_load_devices_state(const char *filename, Error **errp) } vm_stop(RUN_STATE_RESTORE_VM); - ioc = qio_channel_file_new_path(filename, O_RDONLY | O_BINARY, 0, errp); - if (!ioc) { + f = qemu_file_open(filename, O_RDONLY | O_BINARY, 0, ioc_name, errp); + if (!f) { return; } - qio_channel_set_name(QIO_CHANNEL(ioc), "migration-xen-load-state"); - f = qemu_fopen_channel_input(QIO_CHANNEL(ioc)); - object_unref(OBJECT(ioc)); - ret = qemu_loadvm_state(f); qemu_fclose(f); if (ret < 0) { From patchwork Fri Aug 6 21:43:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12423971 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 96E88C4338F for ; Fri, 6 Aug 2021 22:16:29 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D516261165 for ; Fri, 6 Aug 2021 22:16:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D516261165 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:56736 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mC88h-0006Ud-R7 for qemu-devel@archiver.kernel.org; Fri, 06 Aug 2021 18:16:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47076) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85Y-0006Sd-9H for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:12 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:8182) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85W-00042z-Dw for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:11 -0400 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 176MAQjC021183; Fri, 6 Aug 2021 22:13:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=r2JbS8VYeBYPsfVg51cUNnmcVJkHDu497NEB/cljIYY=; b=q5ZFmmamYVbfUTygy7ARii2xcUJXc4sbVm3ZvR3+j0qoXqQnFn737Kbcw7+ZSQV1nIrZ Zvgdbk62x5Q84YvxD2Sk65L3HBZRPKkLZranNKk4/XjBELoOtZYch0L/v2uFe3d60nPq qGkZwRm04DltsbW7f7slOO30IE6zyR32w5u3aSgHyZwyTVv34LDs0vScrf3Rnb5zEfTV cs10oZu0bSqAPtKJJ55QgiL+etgyiZVpmhkhXqqR4kazyUS+1ttAQT6e+95VQ9v1QWf4 LmREhCLjCdn70/s0EV6XH9tNq5DUef0jc20jvvxgEEapu5E43XWaT31sHwAbrd+hYGGd Lg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=r2JbS8VYeBYPsfVg51cUNnmcVJkHDu497NEB/cljIYY=; b=Bg3JrJQJKpxVFSZKadGOjy2NmhEtJ1mizi1obH3PbCCnW2XR+jz+KDBhiMrs4NwiDYX5 GhvRrh/1j4MfPR8UV8yIc3F8Op1Lz7MyC3qSrbFVSVWWMl+pqnbhmeAtCNet/xrC9RjG uZ4D3u2NiUWxPzwYafRzygTzs4ElLUoNPBV3Xqc/1Mb0wy4x7fFA/NrqbnvvdCtW+lO5 y4Hk0Y2H653SkQwBPhlihVKESjDRBEiPRcDYtvHvaIHbYGOqws67wh9N3bgJk5g2epNp 9J0toOOTtiqjj+d5rEN9y7fbbSZKVTvvyhaiGqqbua3fio1GTV7lobVkdNKMMojwrkBF fw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3a97hqgrmu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:04 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 176MACpf083117; Fri, 6 Aug 2021 22:13:03 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2171.outbound.protection.outlook.com [104.47.58.171]) by aserp3020.oracle.com with ESMTP id 3a7r4caxv0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:03 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MUsSJwO/L/4MH5zHmyPnTSbEHxGpTphc6g6NjFpRE9I/TjaPgdWZ12HjQ3x6b7BuDqWvZWfLI+XRFpisGKzBpfv1e/kXvXg5PRYAAfFy+ImSbTTj1cSAlBgHJbCXJSBT9g/lDjg9L7KQqSVfYugKam8cfoQyT6OLwHqY0qG6Sj5pQ+KLDGhfXBnXDb0xXQ1MwFulkNCidNYBzrq9k+2utB66DIMdHT+ITnAsOntlvnRSXe1dDX/n8aYZsME7kVSaxHsUbwefp2Jcopn3Jlgpo2fS/HVYw2V8HdIyWaz6SZIlfm9iBhsyGrSbCF8IPRcMj5E/x0nlf7oI1WdsRjvhEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=r2JbS8VYeBYPsfVg51cUNnmcVJkHDu497NEB/cljIYY=; b=EADMWl7SkrCLDkEeTQzGIPjXEyMxGvQgA3KFQECso3Op8jauJmCKSQegY677bi2nmh6fv0+TU47fKSA1QjU+dBCHpXgFF3MlXAr1ZskBUaX+PQoCCMv4/e6x8lIsqIakftixlYPJbtM8WB/6378iKkfVb/jdBwWSnIFBQ1MF4pJD/tibYie7v44/XdHCqZQiUFpE09LEyA/OD0y/3/I3sEkD7/jFPdrNMGuN+DW6t4FtTTrokcovnPBsm+Vfdq13j4U1NtP34JgBNYI3i79Oldd9YepBrDUS/kiTFO9Kdj2C/PCgoVpS5RryG/vibcmJJeJEBlOJQrsWLRfA23mSDQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=r2JbS8VYeBYPsfVg51cUNnmcVJkHDu497NEB/cljIYY=; b=HGJFSfQxJ+7sG0FWa002g2hl2ILeXScCQzXgzlenYz6PVWgkv8qdceJZ/c2hCPri/DuQctSHtj8Dc4DAsMVeCo9alcYrDORFTedUhmhHN10y6PMN1pf+tF9Uc1B2B0kb49wxO0DZ1mKg7MtBsNECmf07+oNgEUbISvEdypsAXLQ= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) by BY5PR10MB4324.namprd10.prod.outlook.com (2603:10b6:a03:205::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.21; Fri, 6 Aug 2021 22:13:02 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3%5]) with mapi id 15.20.4373.028; Fri, 6 Aug 2021 22:13:02 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V6 05/27] vl: start on wakeup request Date: Fri, 6 Aug 2021 14:43:39 -0700 Message-Id: <1628286241-217457-6-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> References: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) To BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ca-dev63.us.oracle.com (148.87.23.7) by SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Fri, 6 Aug 2021 22:13:00 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a704647b-cf79-48e4-d6e7-08d959275b1b X-MS-TrafficTypeDiagnostic: BY5PR10MB4324: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Kpu9SM+zHHW6Xr6ckOJ/Rql/ZkEVg8XBf22V0fd+h4Y7sezrN63JczuYKDS7PEG1pV+qMGmibIS/rRk+f/absvrF/ox6YUrvEUurtwFDeR8tVPQ1lJaOtw63ibXXTVeAIWsx88FfEd2QZt7bpIPxUg9Fno05nf8knsabruumuBL9xmxkf6+zJprYLDrAmQq6ImivArXg7PDN+POUnGxcLukrgLc+k/ZP2QPzaRswWh/XHcXaKIkPC8+joe1Byn/DTDPYvhcZmXUAnaFA64fXm13Hs38m1t/Cgn9MGL2HsOFnU/wzgG0Zfy4+1VAApD2Ox7DPnjQq56/+3/wnd81JogrYm/bA9N8VChQ4QoY3/iD4o/roTrw9amGL9PC4Xs1hn4r33/KzPyx1PK6ABI7vK9UZAWS4lB5XzBH2fx58BSU108q002cb04IOjNKX2UIVF6M0AcpKjRlXXHm3pMUqNTotrLu7OPPItOt6K76yiXZbh6vNSQoY/pNpV0fcTpZ0v6s3NXSoqMfZzMZ8NlpzrIdUzNuiSqVdZapVVpSpcNv4u31et7r3+vhe0GoQ8dgYMrpjShdkK9um5JfkGY6SlkNz1SaGa/Og6ZKRbFKsVUtxA/mh5H3Z6NTvE/YUHncA4BC/JtuagY1M0ueyfQcTAkSAHw7EXk8lehBOihgfp1w/VzzWDM2mOBwsdvUj1o98uJNgXULNtNQQ+JyJUmzJxA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(508600001)(6916009)(2906002)(36756003)(956004)(107886003)(7696005)(4326008)(83380400001)(7416002)(52116002)(2616005)(54906003)(186003)(86362001)(66476007)(66556008)(6486002)(66946007)(38100700002)(38350700002)(6666004)(5660300002)(8936002)(8676002)(316002)(26005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FtjRJyLMFEaSfOWKEg+d9W1lqzyQp3v6Hq+w5X0rkzV4pkIuM9IScjYHqxLQarvhZ5reSSXaUEuhoqolUmhOgTRwdXVXn/crgUI8wvXxbancLxSTA9BGWvabEpZ4HnBAjbM2dlDoPAsFU30CUB8AFISR2ztQME4YsTrGNGf3VL4VeP9xS9pVcwYvXmIULfXQr50dkIsRu0xoPSG88Caw/5o3x/xPnK6F2QieoDKQZMtlkX6LYGOkcDMbTHZ6TxMr9+rGbD6fjXYMtiZbsaGYqLr/AzLxSP4whfQa7lRg/XUYvsU3HW5Jxdzcb0TpmnPvF/COKJtK1Qmupzb1fIydOnUQM4G3cso6vKZfspTapm4APzKe7g1vwPlrshYAwUXijpo/RjK462wU/yAy8Rtc9FHiQPtzjOcmbi2o2CNh+ulF2joe0MG9if41pGHE0oRAuNQDY7Q2NnVPMAQXWJe3dovGutuiiYYaj9BLn/byb4aPxQXcni8VtHcUsVRL564/x4QiJ9iXoYYDPyyzwqZN/KbLjyKK8xu7VzG9RWR/bb4U44oJV/nF10uMWn3sly6f7LlWLD0IWUEStswmZO7hcm2efTYmGbpho4dq5lzCM8v27Z5P+b6qISgN9k7EFf/GHK7u+kmEHkDbZbzy5QXfIOa3WK8vL7k7KEQpXRKTi4HQiOY9qoi5wNdAmK98fcDk8EcgGcfWLRu0omASQTHP0EiU8cR9x25hnTaLffuFvPSe5mw2hIHdy5sWTrA0LIbqFhMftLPkJS1rbXs+VFC4JbnQ5y9EZB2jOs76eeskbTEiuQhEAZVB1Z8Z4wLFzQlupvn1WNYzeh4JCTukqcMr83jI2KymYNu4EgTLsDutz1TbqJ/c+Bd34kYIs0a3zNqwi9/+jNzt2NLAIbjZTisljRGv8jmKMDbK67PpgncsWWQnlZGo1hzJL6RD3RHyKr3ptC0qES7rAqxY0/roZLSQ7OYGSGoUrNCfcSoMpZMcOMmJ3JXu2mT6J6GDyhCltAOS6YpJg+j9ioLpzzohSqFkO8XbM1mrbiWFQIzjvB9316Zn/coWU2xGJnk9diAgTL7dC/x2qfMhjCUJlNxsRK3ltBhV5K2f5pPHCSqngJnt+vzYlbJ7n7HCZLANVictkhNSPLHQRjs+R+7NzsCpkukVYoRWTCK1if+IL5gAn5ns3TCh5kn1AoubhwR6rqH1saMvcrmhX7CykBB9xnC5TUoIwtlgKTyW1jlo1NXa9G0OJomscok19IZv6xjP2atU11TZjUSBS1yVjRJtmbHbnbWfuvcs5+CYr8ie2rfBX4Vz209LRluY2RAdIjNonp6F+VYh X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a704647b-cf79-48e4-d6e7-08d959275b1b X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2021 22:13:01.8052 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: yuhWc5x0iaid8TECBiAX87ggh6MXKTT51No8WLKMn9bdJzq7z9B8/vRzOK4s0p0+oVdkKWHDj09BFxftvoaVhqZrlWqJuc7SfRRMqQV5DD4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4324 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10068 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 adultscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108060145 X-Proofpoint-ORIG-GUID: ogwf-WNlAcHfWbiJLP7KeEKOHSSyr3ia X-Proofpoint-GUID: ogwf-WNlAcHfWbiJLP7KeEKOHSSyr3ia 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , Jason Zeng , =?utf-8?q?Alex_Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Zheng Chuan , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" If qemu starts and loads a VM in the suspended state, then a later wakeup request will set the state to running, which is not sufficient to initialize the vm, as vm_start was never called during this invocation of qemu. See qemu_system_wakeup_request(). Define the start_on_wakeup_requested() hook to cause vm_start() to be called when processing the wakeup request. Signed-off-by: Steve Sistare --- include/sysemu/runstate.h | 1 + softmmu/runstate.c | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/sysemu/runstate.h b/include/sysemu/runstate.h index a535691..b655c7b 100644 --- a/include/sysemu/runstate.h +++ b/include/sysemu/runstate.h @@ -51,6 +51,7 @@ void qemu_system_reset_request(ShutdownCause reason); void qemu_system_suspend_request(void); void qemu_register_suspend_notifier(Notifier *notifier); bool qemu_wakeup_suspend_enabled(void); +void qemu_system_start_on_wakeup_request(void); void qemu_system_wakeup_request(WakeupReason reason, Error **errp); void qemu_system_wakeup_enable(WakeupReason reason, bool enabled); void qemu_register_wakeup_notifier(Notifier *notifier); diff --git a/softmmu/runstate.c b/softmmu/runstate.c index 10d9b73..3d344c9 100644 --- a/softmmu/runstate.c +++ b/softmmu/runstate.c @@ -115,6 +115,8 @@ static const RunStateTransition runstate_transitions_def[] = { { RUN_STATE_PRELAUNCH, RUN_STATE_RUNNING }, { RUN_STATE_PRELAUNCH, RUN_STATE_FINISH_MIGRATE }, { RUN_STATE_PRELAUNCH, RUN_STATE_INMIGRATE }, + { RUN_STATE_PRELAUNCH, RUN_STATE_SUSPENDED }, + { RUN_STATE_PRELAUNCH, RUN_STATE_PAUSED }, { RUN_STATE_FINISH_MIGRATE, RUN_STATE_RUNNING }, { RUN_STATE_FINISH_MIGRATE, RUN_STATE_PAUSED }, @@ -335,6 +337,7 @@ void vm_state_notify(bool running, RunState state) } } +static bool start_on_wakeup_requested; static ShutdownCause reset_requested; static ShutdownCause shutdown_requested; static int shutdown_signal; @@ -562,6 +565,11 @@ void qemu_register_suspend_notifier(Notifier *notifier) notifier_list_add(&suspend_notifiers, notifier); } +void qemu_system_start_on_wakeup_request(void) +{ + start_on_wakeup_requested = true; +} + void qemu_system_wakeup_request(WakeupReason reason, Error **errp) { trace_system_wakeup_request(reason); @@ -574,7 +582,14 @@ void qemu_system_wakeup_request(WakeupReason reason, Error **errp) if (!(wakeup_reason_mask & (1 << reason))) { return; } - runstate_set(RUN_STATE_RUNNING); + + if (start_on_wakeup_requested) { + start_on_wakeup_requested = false; + vm_start(); + } else { + runstate_set(RUN_STATE_RUNNING); + } + wakeup_reason = reason; qemu_notify_event(); } From patchwork Fri Aug 6 21:43:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12423973 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A6C45C4338F for ; Fri, 6 Aug 2021 22:16:31 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E068C61179 for ; Fri, 6 Aug 2021 22:16:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E068C61179 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:56812 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mC88j-0006XV-RT for qemu-devel@archiver.kernel.org; Fri, 06 Aug 2021 18:16:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47100) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85a-0006a1-KR for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:14 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:11068) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85Y-000444-AO for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:14 -0400 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 176MBdcB032510; Fri, 6 Aug 2021 22:13:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=a5dhAjsqTvzNVLMfT4s5tNUbs8dDdlkP/58BNy18jos=; b=wpy3XqXxb+IN2QpmWLt4qOzJvfYOPvq71CJ6hk1XRxfoTiKpbZ1d1liYDFRF4tfzmO+G Y2V2xt1T85b6ttcoGXHxaU5nqzSLbicmWjsXegHmnoN/HnrfaO4LdoFVtbYRCCIm0zav Uq5WSiLtF0dP7ZiGL0bQCh+JQuBQRSBwNzf6PddoA7814PW+pHzTDr3/HV77/idBHvDv gtCqhMTmQdwltfvh4x9RRzLBHK5c4o0Z6P4qjp5hl3l5st42ohJMaRURXDWr5GrzlHix BwQRC15irKvhm+ODZJqwjQZxM19mNDtxLnDhP9Gfi+vRmI5JeQkUAXQ28go7luRZfd3u ew== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=a5dhAjsqTvzNVLMfT4s5tNUbs8dDdlkP/58BNy18jos=; b=xTAGGzbqLO/fPpBiCSEWywP1htyDTDmBHZL+3zQ9vCLJYX9tM03AJVPoL3z9R1W37pYe di/NWGXf/FWDefRoJqlAO7viVNBeoM4hkr6Bhxyx8q1z0ph8t9XYlauHK/ES39jy69et vapYuPhAnGsmcARA/TRthPFO0R9pflSaFeIaxHUd2NM8S6l7bHvL1V5lhj6emGIAQhuo coBDi6h4WUwbHFcKdqOzLLOvpPUSXRpMKT3npyK8+b/8ASiln9Tmu0qSL6GcpbW8PPg9 PMXOTKLE1jtrJQpeqKSHDgypLIQirAEdTPanwLJacfJ7qAKqBdqQjwKCA/VZUZeI0Un9 0w== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3a9661s13p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:06 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 176MBk5A032675; Fri, 6 Aug 2021 22:13:06 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2176.outbound.protection.outlook.com [104.47.57.176]) by aserp3030.oracle.com with ESMTP id 3a78db75et-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FNWCqOVq6Uaurl2E/yOteURQdlW1PbCMgPRDBMoMNfSY4Dbp7bWhBCdNZW+6GiVknsjfpo/U5bckl2JacQaKQzyIowKKzqVN46Zh0/fnxLsDgN0oERJKfn0uu7eDcd4i/iIT+8oGbBv0N7Qw06DxFNv9mP0DzEGimJcoJ0YdR10AgW4m96m/tCIw1a/mSjgVe8pTXv9PveHllK2SiywRQFo3o6w4kYbT/3E2M2zuG1kPrjsC3/CFGvmc1r86WR8rAGCNU+hzHEY7pygaZVL9iDmrJACWTLH3nslwK/ET/xpZuLKaCq2zQoJYM3qKWtNvuX6rGhZZlf5T5fhLUlrWYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=a5dhAjsqTvzNVLMfT4s5tNUbs8dDdlkP/58BNy18jos=; b=fR7Iv2biOxhMMT0Zh0WZTTYPCzn48S2PPuMLpyFU1EOkW/icXYVOtPjOjqXLrfxWX/89R6mCM6jDgOia3sLPn6mkBkvSl97TP55kRN3PaXnFBmr8BGiMuWTWTCr3MSUi9t0StG/YmkjLLuVULGfi8uFiOmUoNrRxdOUSvd9xehfNSXhTeDi6B7o9zf3vjAQKpna4qP2RE5/yVEgUvIpuSTP8Ip8morVhBFdIr8b5gOVg46p6NVQ6m8BWv7CxuCnTtOSYqgf+UbTRvGQp+Drd2yRPboF6ol9ootjI4TUafcFUMU4/CAT6Z+aVeuTDSn1bXZkEyiTifx8kPO3w3Jht/g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=a5dhAjsqTvzNVLMfT4s5tNUbs8dDdlkP/58BNy18jos=; b=WIYmS37lBJ/WG04ERoPQREM6l3XXHNV3CgMkOE5OKfxG+00cIXKaHlWA+g0xKLsS8RmBwrKqfzJ3zzD+2Fm2Hl3PgziQM46kQGBWVE5ObGCRbLSlFvrUOjiN/tHRZ7OsKSyFP+isLKYVyd1TslvML9Of/9EpKKfa4F7TjQBn/8U= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) by BY5PR10MB4324.namprd10.prod.outlook.com (2603:10b6:a03:205::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.21; Fri, 6 Aug 2021 22:13:03 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3%5]) with mapi id 15.20.4373.028; Fri, 6 Aug 2021 22:13:03 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V6 06/27] cpr: reboot mode Date: Fri, 6 Aug 2021 14:43:40 -0700 Message-Id: <1628286241-217457-7-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> References: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) To BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ca-dev63.us.oracle.com (148.87.23.7) by SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Fri, 6 Aug 2021 22:13:02 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 64d02d30-9300-4f84-4529-08d959275c3f X-MS-TrafficTypeDiagnostic: BY5PR10MB4324: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HNPBUgrvm8lFWGQAVI6j2ClJwIQztkhOWbQJGuUUKZINGzIg8oUZ/1orQu8wwnTu42bB84KonP8fLZxKwKrog/WEFwZvyqy75Fi+Hvo0W4xXuw7I0+3CLziQUvxIxnbeyUcZNuNsMdzyLHCb5KO8sOQTAyynva3uVfHhAGCycCPSv4RbIhaKY5MTNiCx7xEJWrJHEaGz7UwxbWIs8BDDAO8U+jdaSVOHyPafJ0o88quLHMrva21swk3fQNd047MQ69XO2e+I8qH5A2/JBdlbdAZYPHQ7S7O+HcskNNwkU+iAEMmfSaj4/p0VHnnKje8bbxR+yUsREsvO6qhrU14W2hbltH5h9Xenx7V1K7PHa62FWIqilVRgMM8yLwbUaWuKHBUpOxVTrZvr5z3pA/fa7NErqcblMGMDVNTAqc+/WN56rImI0nDvylmXy3Xguu1OWZF6KvrCgESqlo54/ORz/n+TGZztWZ5anDTvhk958Ia3W0v76+cMcGVyXHCrEn5EOpu5AN2wRluO8WXjGifv1AF6xjgpjuMjtZKsvKV46bERw2miR5Ib78T6PIntaW2iGcTp/kzVQ2bqipIEUNrNnr6g8y79C3kug+S2UZt3HhP2pAJjuATk7kwRhRNb8kGHGtNw+8PEEpTrZenDNDz3H3mcjGS6KjmAm0caeyxwcQoUcuW7b8af+deKNGbI4Tto4A6MMv6MUJz0emlPgGaaJA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(508600001)(6916009)(2906002)(36756003)(956004)(107886003)(7696005)(4326008)(83380400001)(7416002)(52116002)(2616005)(54906003)(186003)(86362001)(66476007)(66556008)(6486002)(66946007)(38100700002)(38350700002)(6666004)(5660300002)(8936002)(8676002)(316002)(26005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AXFozWW2xoDrKUe8tWXgd1fj5QSEkmn8tMuXoHPlmbxG7XTPcWOpZH421hW2grjOE04REV8ZiPGJftc+lCCAEcvdm7opaK4vKCXNGXZdow31B9J4fTbMbOKlw70+kHrHC2t+apdoj1wajzXhnpG7ymveD1tYkkOL6n0UcByj4tVH3Tx3LjLyzRLGNgjWpLiVK5bbkRDh3rQ37ls1JoMQNWakd6ntB3UfW7gNu9BhrFL9tU8+gyODqAxg+R5JgbeOJsQQGVzua5SESWAigwlCulxfOz6lRokGljWB5Wd4b5S6k+luiLs3+BMuHckzIYbBTvKZ6QR7f20Ee2CkvASklUSA7inWc7Gofn6yuuTLY2zDkc5Ae3tkhoJ4rH5u/TseaFDzQXBZkHaedNFkTZK7xrSdzsu9uODbjQZ5DE8mzehc3KSByUdyKSEDc5Oao3jTedSEcmfQRtYiQhnHd3+B8mQRpbjhjW3zZdNlhPnbvg9o4sgSRYhHVsKgUqLjoqisHbmEbkVndtrq218iKjml8q8kpvty7kkd5sfLNEW24h2rgMDA43yb3pmQtwGKVb2OX2q9mMzDHQgKC+CZqd4WUAEWlDcpLT3rwyi3H9gzE0RVy+dGKTG+Uqyu0OXpWX8NiYkykN8RSJejxF87RzStnmDGmy/dqtSNR7mXygEDxw/NBOKM7sEGuHEcJR1bEv82wWx7EbIK2rxFsfNbZbwqVdcCOHmuH8atQt7CtfSceNoT/+1u0kINF2KhKpSfNnyzaF+QyOm4CyECaIY6IEpTHxzphYer42SCaUk+zlcyA3gUywySgwONGTVSFfEoRrakERkneWL83misF/Moq9jEdai6mmqEU/+anyMfXrBP3LagIykEAdFRPzlgiHqOPNtfXl6bgNDoInnzHTMI373fZHXoXC5x+57SPM6qnN+Wzo3tvGf9PcVNLntLE0ZUqK8ijnPKAxkR/75J8jg3ciyblhyiE0TPDNlZDc4VUB5fFIlx1Upbxuwv3I8fJZUfq5KcH2jSdOnR7buVCYwgi35iI2mrKdsc7hwIKW71ckrfOICCXDPKzgoOOozNr4+rFx9AVeqaytdZ7YJRlaTfbwsbB2YxP0zdFlGGqv5PCcvFPcFq6u/AxIASBdk6jLg87eP3R1JRf/ZSTLwTgu8aVlZcZHRIMnsaQBjTz8R3oNsX4L7cXOE93ByiaZjDEPgQENHeNyn+O1CEMIyEH8osGqgyJu2grBnxnMYiPhOa1hbToNEAgjRIn9BTgTHjkc08B8SS4hh2uLwiXZBoHkJ/ZeTi97MKw0ri30FOz/QTnxU4e84frSm/cLzLe+77uTkQwQJJ X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 64d02d30-9300-4f84-4529-08d959275c3f X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2021 22:13:03.7351 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: iQ3SbaGUv5nRnbjurV9D9KsKdg1HxVjFzKcmZRMx2LlrH7F8JcXYOmqGkRIb+1TH5Fv0KBXG0p6fwPqSb6l3d+H2ZLjZclp0rnjXwjR+bJQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4324 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10068 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 adultscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108060145 X-Proofpoint-GUID: 4j7LORCyoVoBZ5q9Zh4R_f6jO858j-em X-Proofpoint-ORIG-GUID: 4j7LORCyoVoBZ5q9Zh4R_f6jO858j-em 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , Jason Zeng , =?utf-8?q?Alex_Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Zheng Chuan , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Provide the cpr-save and cpr-load functions for live update. These save and restore VM state, with minimal guest pause time, so that qemu may be updated to a new version in between. cpr-save stops the VM and saves vmstate to an ordinary file. It supports any type of guest image and block device, but the caller must not modify guest block devices between cpr-save and cpr-load. cpr-save supports several modes, the first of which is reboot. In this mode, the caller invokes cpr-save and then terminates qemu. The caller may then update the host kernel and system software and reboot. The caller resumes the guest by running qemu with the same arguments as the original process and invoking cpr-load. To use this mode, guest ram must be mapped to a persistent shared memory file such as /dev/dax0.0 or /dev/shm PKRAM. The reboot mode supports vfio devices if the caller first suspends the guest, such as by issuing guest-suspend-ram to the qemu guest agent. The guest drivers' suspend methods flush outstanding requests and re-initialize the devices, and thus there is no device state to save and restore. cpr-load loads state from the file. If the VM was running at cpr-save time, then VM execution resumes. If the VM was suspended at cpr-save time, then the caller must issue a system_wakeup command to resume. cpr-save syntax: { 'enum': 'CprMode', 'data': [ 'reboot' ] } { 'command': 'cpr-save', 'data': { 'filename': 'str', 'mode': 'CprMode' }} cpr-load syntax: { 'command': 'cpr-load', 'data': { 'filename': 'str' } } Signed-off-by: Steve Sistare --- MAINTAINERS | 8 +++ include/migration/cpr.h | 17 ++++++ migration/cpr.c | 136 ++++++++++++++++++++++++++++++++++++++++++++++++ migration/meson.build | 1 + qapi/cpr.json | 56 ++++++++++++++++++++ qapi/meson.build | 1 + qapi/qapi-schema.json | 1 + 7 files changed, 220 insertions(+) create mode 100644 include/migration/cpr.h create mode 100644 migration/cpr.c create mode 100644 qapi/cpr.json diff --git a/MAINTAINERS b/MAINTAINERS index 37b1a8e..2611ca6 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2900,6 +2900,14 @@ F: net/colo* F: net/filter-rewriter.c F: net/filter-mirror.c +CPR +M: Steve Sistare +M: Mark Kanda +S: Maintained +F: include/migration/cpr.h +F: migration/cpr.c +F: qapi/cpr.json + Record/replay M: Pavel Dovgalyuk R: Paolo Bonzini diff --git a/include/migration/cpr.h b/include/migration/cpr.h new file mode 100644 index 0000000..a76429a --- /dev/null +++ b/include/migration/cpr.h @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2021 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2. + * See the COPYING file in the top-level directory. + */ + +#ifndef MIGRATION_CPR_H +#define MIGRATION_CPR_H + +#include "qapi/qapi-types-cpr.h" + +#define CPR_MODE_NONE ((CprMode)(-1)) + +CprMode cpr_mode(void); + +#endif diff --git a/migration/cpr.c b/migration/cpr.c new file mode 100644 index 0000000..1ec903f --- /dev/null +++ b/migration/cpr.c @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2021 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "exec/memory.h" +#include "io/channel-buffer.h" +#include "io/channel-file.h" +#include "migration.h" +#include "migration/cpr.h" +#include "migration/global_state.h" +#include "migration/misc.h" +#include "migration/snapshot.h" +#include "qapi/error.h" +#include "qapi/qapi-commands-cpr.h" +#include "qapi/qmp/qerror.h" +#include "qemu-file-channel.h" +#include "qemu-file.h" +#include "savevm.h" +#include "sysemu/cpu-timers.h" +#include "sysemu/replay.h" +#include "sysemu/runstate.h" +#include "sysemu/runstate-action.h" +#include "sysemu/sysemu.h" +#include "sysemu/xen.h" + +static CprMode cpr_active_mode = CPR_MODE_NONE; + +CprMode cpr_mode(void) +{ + return cpr_active_mode; +} + +void qmp_cpr_save(const char *filename, CprMode mode, Error **errp) +{ + int ret; + QEMUFile *f; + int flags = O_CREAT | O_WRONLY | O_TRUNC; + int saved_vm_running = runstate_is_running(); + + if (qemu_check_ram_volatile(errp)) { + return; + } + + if (migrate_colo_enabled()) { + error_setg(errp, "cpr-save does not support x-colo"); + return; + } + + if (replay_mode != REPLAY_MODE_NONE) { + error_setg(errp, "cpr-save does not support replay"); + return; + } + + if (global_state_store()) { + error_setg(errp, "Error saving global state"); + return; + } + + f = qemu_file_open(filename, flags, 0600, "cpr-save", errp); + if (!f) { + return; + } + + if (runstate_check(RUN_STATE_SUSPENDED)) { + /* Update timers_state before saving. Suspend did not so do. */ + cpu_disable_ticks(); + } + vm_stop(RUN_STATE_SAVE_VM); + + cpr_active_mode = mode; + ret = qemu_save_device_state(f); + qemu_fclose(f); + if (ret < 0) { + error_setg(errp, "Error %d while saving VM state", ret); + goto err; + } + + return; + +err: + if (saved_vm_running) { + vm_start(); + } + cpr_active_mode = CPR_MODE_NONE; +} + +void qmp_cpr_load(const char *filename, Error **errp) +{ + QEMUFile *f; + int ret; + RunState state; + + if (runstate_is_running()) { + error_setg(errp, "cpr-load called for a running VM"); + return; + } + + f = qemu_file_open(filename, O_RDONLY, 0, "cpr-load", errp); + if (!f) { + return; + } + + if (qemu_get_be32(f) != QEMU_VM_FILE_MAGIC || + qemu_get_be32(f) != QEMU_VM_FILE_VERSION) { + error_setg(errp, "%s is not a vmstate file", filename); + qemu_fclose(f); + return; + } + + cpr_active_mode = CPR_MODE_REBOOT; /* generalized in a later patch */ + + ret = qemu_load_device_state(f); + qemu_fclose(f); + if (ret < 0) { + error_setg(errp, "Error %d while loading VM state", ret); + goto out; + } + + state = global_state_get_runstate(); + if (state == RUN_STATE_RUNNING) { + vm_start(); + } else { + runstate_set(state); + if (runstate_check(RUN_STATE_SUSPENDED)) { + /* Force vm_start to be called later. */ + qemu_system_start_on_wakeup_request(); + } + } + +out: + cpr_active_mode = CPR_MODE_NONE; +} diff --git a/migration/meson.build b/migration/meson.build index f8714dc..fd59281 100644 --- a/migration/meson.build +++ b/migration/meson.build @@ -15,6 +15,7 @@ softmmu_ss.add(files( 'channel.c', 'colo-failover.c', 'colo.c', + 'cpr.c', 'exec.c', 'fd.c', 'global_state.c', diff --git a/qapi/cpr.json b/qapi/cpr.json new file mode 100644 index 0000000..2edd08e --- /dev/null +++ b/qapi/cpr.json @@ -0,0 +1,56 @@ +# -*- Mode: Python -*- +# +# Copyright (c) 2021 Oracle and/or its affiliates. +# +# This work is licensed under the terms of the GNU GPL, version 2. +# See the COPYING file in the top-level directory. + +## +# = CPR - CheckPoint and Restart +## + +{ 'include': 'common.json' } + +## +# @CprMode: +# +# @reboot: checkpoint can be cpr-load'ed after a host kexec reboot. +# +# Since: 6.2 +## +{ 'enum': 'CprMode', + 'data': [ 'reboot' ] } + +## +# @cpr-save: +# +# Create a checkpoint of the virtual machine device state in @filename. +# Unlike snapshot-save, this command completes synchronously, saves state +# to an ordinary file, and does not save guest RAM or guest block device +# blocks. The caller must not modify guest block devices between cpr-save +# and cpr-load. +# +# For reboot mode, all guest RAM objects must be non-volatile across reboot, +# and created with the share=on parameter. +# +# @filename: name of checkpoint file +# @mode: @CprMode mode +# +# Since: 6.2 +## +{ 'command': 'cpr-save', + 'data': { 'filename': 'str', + 'mode': 'CprMode' } } + +## +# @cpr-load: +# +# Start virtual machine from checkpoint file that was created earlier using +# the cpr-save command. +# +# @filename: name of checkpoint file +# +# Since: 6.2 +## +{ 'command': 'cpr-load', + 'data': { 'filename': 'str' } } diff --git a/qapi/meson.build b/qapi/meson.build index c356a38..73ece6a 100644 --- a/qapi/meson.build +++ b/qapi/meson.build @@ -27,6 +27,7 @@ qapi_all_modules = [ 'common', 'compat', 'control', + 'cpr', 'crypto', 'dump', 'error', diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json index 4912b97..001d790 100644 --- a/qapi/qapi-schema.json +++ b/qapi/qapi-schema.json @@ -77,6 +77,7 @@ { 'include': 'ui.json' } { 'include': 'authz.json' } { 'include': 'migration.json' } +{ 'include': 'cpr.json' } { 'include': 'transaction.json' } { 'include': 'trace.json' } { 'include': 'compat.json' } From patchwork Fri Aug 6 21:43:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12423981 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3DEB1C4338F for ; Fri, 6 Aug 2021 22:18:24 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7D23861165 for ; Fri, 6 Aug 2021 22:18:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7D23861165 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:37138 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mC8AW-0003kU-FN for qemu-devel@archiver.kernel.org; Fri, 06 Aug 2021 18:18:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47108) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85b-0006da-M6 for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:15 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:13882) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85Z-00046D-RX for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:15 -0400 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 176MAeTS021384; Fri, 6 Aug 2021 22:13:08 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=/HJjJf+osY2cyH2B6d46XwgkMBhpbaOfvBv/6BgNASE=; b=rEQkelBPxm9DIys3yeJv5j1bgkL4bcH9T+iXIuwMJzGixw2cxXarlYZjR05mU04Mgzkm eHPuqjTx5CqOcO8YeLWd/tA+TKhRUceGq9GxsdGZI+RJGkdowzzyWviTnRzwUbMl+IKx UWz4/gPE9TSmjLIF8N9Vrf+tZd7huXKMxL82G9VIFGf4LLXAa6Aam0nACoJaUOIoxM3H QVcL1RuDZAukptgGTlNXJP1qvLXrWUGYlwErEoOH7OTVRxIDljUyz7ol4iXZWP+RdFbe vLtiqgDoH9L4CCj5OvbsUBvMSGFtI5lx0u81W4zPnxT3yPKBc8f7JAPkRctP/4o4eIlR 9g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=/HJjJf+osY2cyH2B6d46XwgkMBhpbaOfvBv/6BgNASE=; b=g47UYOa07OGCI+u6o/MvVVXgj+S3uE5O49q+a//++OZSR2UsOYHnjqv6381SPlHvjnz0 zMUGYUclSDlyADMP9DX5dxIOGi8ojdnVTzNtUS95qxbsBaXpBt5bd5WB7FNWEK9btRDP iZKt7k1m3zzJdXbFpEI2SI8eGltbcUcrRr0PE6OwdtRz1wGJ7WK69kuFC5tIibDJsVDj fNaBnNdVjpqvJj74DOmp0ndcKHavUXp5UYM586mv6GFR1KrH8djYcGQLiogPBzO2poo0 JQiK+lmU1l8kNqYuX2UslLPwimwIEkNtnBYgTEdNY3Ays/c2GCnxiC9pzHfs18HN6Hk0 8w== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3a97hqgrmv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:08 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 176MBmge032742; Fri, 6 Aug 2021 22:13:07 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2176.outbound.protection.outlook.com [104.47.57.176]) by aserp3030.oracle.com with ESMTP id 3a78db75g9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kT5H2WtrwD2LScYEq53dNN0EdPMMmrDacp9wCwfni7B8ZKBWj55rTZq9bLKCrw3dgw9HCd0lUWVf6SSIqqh9Wa7BOBnzbJn2vI6hXpmhgctamSiH6stkni8odA6GtHxUghL1rMCw3qphH+44DAUqS2z++e4KHFqCC/7jxmIqGS7sT/eboQlrmwMRH9sxW3XhdjJWS/h2AMc3XujzxAs678x2fD8Cbn7Ls4k6Z8j/L4K5Dpgi9CzGjsrRnUIrAxVco/avfwdWCv6xlHEQxIlr/Kp9cVVpdz+yzGZ3ksPgCgp5SW09So0gzjlUH53+YyMSL1Q5Ct9n+ksFCZTkBjP+4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/HJjJf+osY2cyH2B6d46XwgkMBhpbaOfvBv/6BgNASE=; b=fICjIUkglO35ycpJwbfWjxkUVjQD7Ak6CfkPfLRS+EODMwrSTg304VULmWq/BGXeObuhH+b9EXPDNBcBVDNrrkorCMVHTaGOInc9/ivcMeLDLI6b+B2wtbB8EeksJ5J7TTzJ9rVdPSoMGa1SgOlON07B3l0lW9h01qqwWQlzzj/GeQBwVSDhXiWW6Avki89AZ+Lc6qVRkLBTquNXf6WQ92hvGKWM8D/gH9fPhuMRNedI2PHiJKoSWuocqHnSs0bFjz3ImI1/4gTYyx23oZD2PDlwU9PEwDBsynv5wUAKQxwD8QZKMzuckhzdrbmChp+hkIk3MrmF3dheCAE7OElnig== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/HJjJf+osY2cyH2B6d46XwgkMBhpbaOfvBv/6BgNASE=; b=s5UeedkpDibr5VjahNVNeLSlT52YaTCKaXH65KH+ROZEDmBxRwgVe2rXsr6lxNP4utTINr5dPnzkZXu2y/W7HmcAHHlTU2JWzilTAHLmNDn7mWxXbgxbNmAAebubaIVDV858/4EtGclx8SXi8xHhoi3TkwQSRZxxm7KbJoxPySY= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) by BY5PR10MB4324.namprd10.prod.outlook.com (2603:10b6:a03:205::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.21; Fri, 6 Aug 2021 22:13:05 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3%5]) with mapi id 15.20.4373.028; Fri, 6 Aug 2021 22:13:05 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V6 07/27] cpr: reboot HMP interfaces Date: Fri, 6 Aug 2021 14:43:41 -0700 Message-Id: <1628286241-217457-8-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> References: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) To BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ca-dev63.us.oracle.com (148.87.23.7) by SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Fri, 6 Aug 2021 22:13:03 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a88c685a-532f-4540-1bb7-08d959275d60 X-MS-TrafficTypeDiagnostic: BY5PR10MB4324: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:296; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yWd3oI2bHdL+4wTcgCXK0euKQkp3Na2+9YTxYwwHVhBH4CaQ8GK/OzkwC82v7GfOByO/vpXok/yjqgNj3U8Kgss9yMj95zMO4JnCZpUTVBBRu2LZO7J9UBEL5BK8phrj1/3nujJvhZY1bw2JVvwiNSK9a7ajmm5+RQJZlk+1r1xoBSQpKr15JTcwDGgH4Xc9cMxVNOzEasZyrWrEH65ri9/nq5YLbcCUU+jzZDtJEIR4ZXbnJ5v1Sm1Nj5Xff5rxP97GS/9yN3MFJ6r+iovbWa+YolJoI88RDh19w0FqXV2DJa/n67AbZTnARpjwo0lT+h4Gz6aRs/OKNR7MH70Hz6kguU6ANfTuWaHDZpqsZ5gHL6JP1FT9aI2TFQB51T/kIY0GeHNX/5Q2QjMWIHRr7ogT9FDiH0FUfldHyvrthJ6TA1Dh+IbMwBzoSsbWwP3SBDFph6hncY7VPh9htHD8umEjN/nCHnNs6Uxf81irDtNI92tq5tQS21Pd3p1Y3vKl1FBW1VHuAKYugY9DTismPfxbLI0ZxlGGWjevDVkQvgT5eRDCMBnRBgYs3x0W5RogzzDUagor1MpxSL0R0X82Eed57Y7WwwagIcCopvR7e51Db2MXIWyi8fl18dmkKR8Cv4hH2HilJ2bB0B6EpuwNwuj0/Vjp9IIr29e8HaOQ2cXgA1GlXNuP6WP4ngGVDx2ACTD5cFknFduVkY7wwNLRtQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(508600001)(6916009)(2906002)(36756003)(956004)(107886003)(7696005)(4326008)(83380400001)(7416002)(52116002)(2616005)(54906003)(186003)(86362001)(66476007)(66556008)(6486002)(66946007)(38100700002)(38350700002)(6666004)(5660300002)(8936002)(8676002)(316002)(26005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Aks/1uT99C4XImTxsgfT2P3VKd2CPRtO+Ql6qsNEPIf3raP4Ky8SMTZLrM7tDXQjEvgNWmx1s6HVQcCxFazCHk6pfX04z43F8Q37nuqRHeAFMhArX/aYUoKUn02Avnc2brs2vGcmReXWqOZoaBRqWl2fETvNfqqSFiiuaMU2XstHTcUlXjVG/AFHqyKkvqkTQP41hO/7erLZIm92wCXKsS/2rIKKtUBmq2xWmr8tXMZG9h9eGjM66b7yL2wtgoUt24MH3uza1DBlVe37/nYkPKogQB99kdOThl5b9j+3T0bfL1yuy30WvcvTmZYYEsYwr/ow7XKSyYByrl5itBeRHBdfHTTG+NwcEvaYL1ugmzZNZeaUP0ZFxYZY7LNT4/woYZshd1XQM1fwSzrBekdO1QiqoWjHVHRXgR0T5eO85h8LU0JQLPUXxvjHK1Ai7aYpcAWPvHn7geamb/gbchZVmP++JbcNVGtco1hLBoQzPmB+FJEqhomhxgAWIOD3TVoMrINf6+duGSoYXkaEtpmE4QF5GaD6iSS4QF+gg+du7D9QFNmittx6tfb1cUWFFhdlX4LCaYYt7TuY1SdTFNEZinDSkEsYK3mvaOqcum4dogCCuuu9JdpUNpjrKZ6PdZT9VmX+5XkZbN6thDTe7sU50ST7qA0dtuSy7AQOKFPT9dCZBVY0KfJufiQtw99NUB1G06sF3Bmgz9NPM4JtWlMjm43u7ni+ch89jSaLBz16V1UP3QaU/iNLIdNkMN2ahwS13yVv/wE9I19xv3+rOB4QYJxXeGpT5lGAvW25730cnITr/OaQFsPfHDmRujqPkFQUNnJWI99/DKhnTjrkXIm4lsol/Y7M3W09VwCxwsyfWLXAPbpfuY9v0GxPMbwAkQGw7wgCldRZxOx+yhoekxfqFkULc133SKyUk8ZiKr9Z40oWnaVR7XDBhPghPzKOaDUAdhXdmEYTSi8S1XLLd7k6YJrMavMlP9WV27+lINVqflBSdOgev0c7oS5l8S0JbU4YulVqd3+Ns9/IXwMBmr/pFhFAMc68VcV5OiMO+QbpdpwzdeGrQ6Mgg6zdOAN8sqDJdFo1Nub90xXju+KaCdLFuPRNH508a1rFfU181CrWLwf6nyZnZfx3I6Z0YI/FTpPvy2uvhwMRvTlN7bSlqXmJAbARNWqhR0RBtKw/19iSl90G46ayb5RaHqKZTLr1yQIojd/bfJ19tA+WkASuM2Q6+MxGi2RjH9sI8akAw+yCS0cpoz3VhJH7NFBSYiNVpRyAoorJoe8H0IBIqKhXpp4Fw+a3KJqnMwBnzNkSrllRIMZ7zolDXxN9rsuSHW0HcY7f X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a88c685a-532f-4540-1bb7-08d959275d60 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2021 22:13:05.6321 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: zRgjbLmF/8+UDNQwM093JchLB3BBdZ+/SrqolkmYVhWQxbInP2ehqe2ulkCIjWJat/9IAQGSA+h42ZfMfGwEofjx3xzfHsDcOIlzqDAErOk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4324 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10068 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 adultscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108060145 X-Proofpoint-ORIG-GUID: pY5zitiY8LptMVDqNw77ojjp2z-MpsdA X-Proofpoint-GUID: pY5zitiY8LptMVDqNw77ojjp2z-MpsdA 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , Jason Zeng , =?utf-8?q?Alex_Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Zheng Chuan , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" cpr-save Call qmp_cpr_save(). Arguments: filename : save vmstate to filename mode: must be "reboot" cpr-load Call qmp_cpr_load(). Arguments: filename : load vmstate from filename Signed-off-by: Mark Kanda Signed-off-by: Steve Sistare --- hmp-commands.hx | 31 +++++++++++++++++++++++++++++++ include/monitor/hmp.h | 2 ++ monitor/hmp-cmds.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index 8e45bce..0a45c59 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -351,6 +351,37 @@ SRST ERST { + .name = "cpr-save", + .args_type = "filename:s,mode:s", + .params = "filename 'reboot'", + .help = "create a checkpoint of the VM in file", + .cmd = hmp_cpr_save, + }, + +SRST +``cpr-save`` *filename* *mode* +Pause the VCPUs, +create a checkpoint of the whole virtual machine, and save it in *filename*. +If *mode* is 'reboot', the checkpoint remains valid after a host kexec +reboot, and guest ram must be backed by persistent shared memory. To +resume from the checkpoint, issue the quit command, reboot the system, +and issue the cpr-load command. +ERST + + { + .name = "cpr-load", + .args_type = "filename:s", + .params = "filename", + .help = "load VM checkpoint from file", + .cmd = hmp_cpr_load, + }, + +SRST +``cpr-load`` *filename* +Load a virtual machine from checkpoint file *filename* and continue VCPUs. +ERST + + { .name = "delvm", .args_type = "name:s", .params = "tag", diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h index 3baa105..01b5df8 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -58,6 +58,8 @@ void hmp_balloon(Monitor *mon, const QDict *qdict); void hmp_loadvm(Monitor *mon, const QDict *qdict); void hmp_savevm(Monitor *mon, const QDict *qdict); void hmp_delvm(Monitor *mon, const QDict *qdict); +void hmp_cpr_save(Monitor *mon, const QDict *qdict); +void hmp_cpr_load(Monitor *mon, const QDict *qdict); void hmp_migrate_cancel(Monitor *mon, const QDict *qdict); void hmp_migrate_continue(Monitor *mon, const QDict *qdict); void hmp_migrate_incoming(Monitor *mon, const QDict *qdict); diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index e00255f..6aed6ac 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -33,6 +33,7 @@ #include "qapi/qapi-commands-block.h" #include "qapi/qapi-commands-char.h" #include "qapi/qapi-commands-control.h" +#include "qapi/qapi-commands-cpr.h" #include "qapi/qapi-commands-machine.h" #include "qapi/qapi-commands-migration.h" #include "qapi/qapi-commands-misc.h" @@ -1177,6 +1178,33 @@ void hmp_announce_self(Monitor *mon, const QDict *qdict) qapi_free_AnnounceParameters(params); } +void hmp_cpr_save(Monitor *mon, const QDict *qdict) +{ + Error *err = NULL; + const char *mode; + int val; + + mode = qdict_get_try_str(qdict, "mode"); + val = qapi_enum_parse(&CprMode_lookup, mode, -1, &err); + + if (val == -1) { + goto out; + } + + qmp_cpr_save(qdict_get_try_str(qdict, "filename"), val, &err); + +out: + hmp_handle_error(mon, err); +} + +void hmp_cpr_load(Monitor *mon, const QDict *qdict) +{ + Error *err = NULL; + + qmp_cpr_load(qdict_get_try_str(qdict, "filename"), &err); + hmp_handle_error(mon, err); +} + void hmp_migrate_cancel(Monitor *mon, const QDict *qdict) { qmp_migrate_cancel(NULL); From patchwork Fri Aug 6 21:43:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12423977 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BBC28C4338F for ; Fri, 6 Aug 2021 22:18:17 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1753661165 for ; Fri, 6 Aug 2021 22:18:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1753661165 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:36736 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mC8AR-0003UV-QV for qemu-devel@archiver.kernel.org; Fri, 06 Aug 2021 18:18:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47124) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85d-0006kc-MU for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:17 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:19910) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85b-000475-TI for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:17 -0400 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 176MBjrI007313; Fri, 6 Aug 2021 22:13:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=DFKu5QoHSkTuVBKFWGCp01oukjx5plIhmfU+c9tbqxE=; b=H3EkGsuEs6hCPO5Xx6DDvtZqQ8U1sqVbmLMnGkXyiA1f2LNh/I+mzuVLe2uLatHs8SLA bC8wL7yUFPsdn2y6ZSywULfMSHNN4ymzCXV2NlY/ZJzPbllgbRXrTIi9NnbQMvrYxozh r14ouZtxuiisRdJyE4MbJMZm09DgKtstrfvqRLfn4keaBpjxcnjEfm2S/pu8cZGnD9XL 2P5kXWWNTyJvsNMr37IDWhB7JfpuY9JF9ebxb/uuBYYUsf/11PpoZWzrvp/dxlLaaj2e t4ZQHCEt+nmlkO6hMtIn0LMTTX2t6GSc0nGKndEUP1cO8OpHMJ1lE52QXfrMMnFObHho vg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=DFKu5QoHSkTuVBKFWGCp01oukjx5plIhmfU+c9tbqxE=; b=xBf+tuxs8uaGepww8MbQZi9tyQG5HMZR18LENqi+2Ttt86OEyNKw7ctwHtwcdFXOMryU Tf2V2eP1fDLaZtqh+LFXydQgjNSJoXYPxZU8nD7JYo7tjdGTmG4QLsWpruzZcsgfQAqV edo2LXtV/qCcRCb0ioU5OfLZOIHGbXzETQvo740VPzZnE1iLiCa71+eQd3yYjpktkkHb vJshrIUyQ0E4h8f5wb5WwKvqw90fCD4azP4UTC+Q6I+H/zKN9T7jdX9j/qaJBsAZJBYe AVGfJBR9RHA4U6MnDAUdP4U7uF2nmWQor9oepHwMNLRvqxxBpmXykHrt/udIkScyWSWh pA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3a8p6rjpm7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:10 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 176MBlK7032734; Fri, 6 Aug 2021 22:13:09 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2174.outbound.protection.outlook.com [104.47.55.174]) by aserp3030.oracle.com with ESMTP id 3a78db75hh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c9rcbM7I4JDYNCFz5hCgj3mNxFPVrP9PWuGiQfEj6RF7dWpmuf51UQEaVYU0091IUmoVS89q5F1TSFw3NVZZDmNkB8hZQEczqRt1ejdIJP84zYpnUFmdyNsBuqTxZwt6m5ouJ0VlnUu6VqLjEJ4CrROQDIbFq+zGZWbXb8zx7T5eu+9Hc682MMPPkTXxEwGGCpumJS5sKW6uK49sRpWwqPuyZguqezpwGVg9lizOdWmPmP6Te2qZ7RPyMe9Tt9nxpK9nBU80Txwjxrf+NbfC9bUN1fHAq0XA2WawoS2U8uG/LZdsKCNy0LeG58cwypGeHjxyEodnebmpDKVisr/zPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DFKu5QoHSkTuVBKFWGCp01oukjx5plIhmfU+c9tbqxE=; b=DRGKrQj6uoZKnti0hya9tKoVYqXLcq6LasfBJoXr1WCmWoeAdS/r4N18omui3+d6/6mvV0YrFgzlAmK98XQ9rydKKdTdtfWraFBzuX04Hzlvjn9s7QIwONYDO9lkwQBibDB3aF/f4OqRhQBExuMpBBKcIVQgLXs/YYr47BnREyIfTz7FzOKmHyEqpKUdP5PIY4IK7JGteyr77P9T7qtlfY3bm5c3QEA43PUVADYBZD+SE3zeifVNFDIOCCYt0MyAQd7sfTTOKLwvwM/L1c2JlZt6bG3jGpmayxubuD38IN+cUPbffg7BcOpxIbU7arcjqzLMIN7iVKqt7e4/v5XlUA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DFKu5QoHSkTuVBKFWGCp01oukjx5plIhmfU+c9tbqxE=; b=hXEP6dFcGrhOyAXyN67bM0XIlrzhomS1NgEFJRkVnfRIPaY2PE9CTzLmbVF0JEdIZlknFUgTSoTgDktWXp0qHf4C+KzTto9T8mjwd+ImAcRvnF92qLVtzO1azjvTz6pxEAcOboeEH44T8WIAuSfAc/ZQpofp2WF47xE0MquNeHA= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) by SJ0PR10MB4734.namprd10.prod.outlook.com (2603:10b6:a03:2d2::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.17; Fri, 6 Aug 2021 22:13:07 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3%5]) with mapi id 15.20.4373.028; Fri, 6 Aug 2021 22:13:07 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V6 08/27] memory: flat section iterator Date: Fri, 6 Aug 2021 14:43:42 -0700 Message-Id: <1628286241-217457-9-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> References: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) To BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ca-dev63.us.oracle.com (148.87.23.7) by SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Fri, 6 Aug 2021 22:13:05 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 43ea2f52-60a6-484c-bdd0-08d959275e86 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4734: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2958; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hu1hRyt5Y1qAxOyco8I3Vovkwd1lWVGsf0cYKbIBB7gjU+Y9Phpk8TcEHv5UvmzVU/LHLqWIdYXb2Tej9vQYc069lrzh9xN5Txv18QkzvHqKkss03TrM/r8LMAVqoMWyryrdKhYnGO7S54/m/ExrfOVCzascsBHEqHYjF9UyOuHptSzfLU2hSKwiBtxdPyPvp7wX9kxMmBUQcTM2svDpt45/yECxDT/pfyW1gAekUn9p8W76788t4Ky44R+w5ksvLqoqItuOAQ0syuPDgd4/UIUb4qNWE8VYvlnfDUfgU1Jp5kmDemkCrNU/5Ov7vDY+KhOs5aXL6GL3sfe0isg82REBwV0g0MeM/VMtaVDE3/Qsv/1rZM5H4c0l6wuIu8/R7rBxHPAC66vO4t15oLHiqoI1S8E96Rq6lxMAlnyMYwIC/RxRMH5w2pBvu2kpfl6OgjOd57NlZ1VovKOAxXlsPgEE+F7EE/uA4s8irNloTyGc0e0M2WmU7qSUSmnEsJYURYDVFDcxsxta1SPPG1+YwSVsdh7cCs3bRQvha5daeh+z8JQaApDo+4XfVlyBcPphXyrRFKKHfIqgt4pIm4ufKEcAEBzqdRWCcQe6DwwQSPdeaNJZaxlOIa4bVs0HGs3+yez+gtoZsvMkF5aXoxqW1j2h1wTLUuOjByBGeMor4qVQ96pGFO2tcxbT1aYAgS+HHX0oNM+fFv2nYGaWg7j5HA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(396003)(376002)(136003)(366004)(346002)(66946007)(107886003)(66476007)(8936002)(86362001)(316002)(83380400001)(54906003)(8676002)(66556008)(4326008)(36756003)(956004)(6666004)(26005)(186003)(2616005)(478600001)(7416002)(6916009)(5660300002)(2906002)(52116002)(7696005)(38100700002)(38350700002)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 08XVynwRs8adaK/HnrwcYgIVezIAXOp6o2zRrnpqOHeF+4dMrQeSkkpkmm8XAR6nA0BIi2yN/zQbvfiNmv4JLAT1NsbYWiG4+dM1tMEF3PtAp7fQpeX1idWPY1lOuwUZlf3pWm8kyR9HcmXLMTWqyUcnSkz52SGE37nZAmB3089w2hPe4XeEXgKIACYPz+UhkTMUyVfNkxt43oYexOi3+HBazjtBQO0mvKV9Ba3kPh3SHkqDU3bdkogljYQ0hjz6GP56c+jfZzkvmrvnzuKXWw5Sh12+qcmYSaV1dk1yeSXtI5OBzP9GvzbewvpBr8po810cMlaYkHiJFenpeJTOzdaEM81v5kM4wQqIYQnXBiG4l9L5cJtSErN6WTgW9PTQI/y8wLbU+ke1xEc02eV/dxFUtFHVRCbfi5LVVgX98vUBZVvbmt24QFgyTzA3LHxZMihoAntBUIJLJ3SuFqXlvXfgn9jKQoQYTve7NYc9efpCR83Tm0aXzo4Kelyn+0RFKHkBzyxTmea4ZKqhA7vwlb2xGO0cPqNMwgKyCyUmmxK5+EC37uIGuzvMJgCR1kw5SXokyVAUJOdVV1IMpJAsx9kQzI0v6UemAwYO2VdiPKLRi/LscL2XLcas9yHjgvuLaYNKaiWxnWYn0ADO68yInfm9myx0AH5Y/pD57Lso9+l6Z7chcl4LmjoV30bZ6luZaMvfoJteX64Cz8MPZNXMTFVGOQhMLwuGBKmQAEa3veoxfg5If2eQMppaC2fxBROZ23CRv6sCCnSl0Lfbnx8XiQIE5InyTO7fQWiXZaKQ5sVSZR89e3s+NWTd+6/jEOdPWX1DpF9bQQD2bAW00KlZWinL6/hUuum06uyTGoiFwX/AtHjgnyMESasyoq4KzzbAOM543XAZ3Xrr5eWXFykEoq9BFjUrXrfkkfrENNc/wiW6/0z4Zv6sftA/ZNenL4Jv1kJ6lNdLZUWOqtlVAOsg+RfkIPaekZWEqjKLPBLlo/Nc45ilUkobUvnoU3AGBqltvbaIhUF8H0piO0XnQOz63r5gcUjbYt6nU31RnMJJ2OUFkoaf5a8C0CqQcX78UnJy7gJ7HY3NsdCPQmAOwhHarFFTenvoQg1sfbkLzOWfowne1zUw8Vtefh0jBEqphp9T6exQhZm21fxyszC0Wx2pcAqsh9Uf9mlJhLOZgi/p/Dr2eLNBF8zPgjGstcTj1tfdhqumW0JKLiEbweBCstVW+lyTb/k5tDgHQL69XwG1zyuJ2g4YScoM7BuoD7oXJV5e+mpAUEarMt9oIElmVamCRhFiOUhb68c2u6uc2hp7MuLyycwJLE5iDsC9vYevcmrM X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 43ea2f52-60a6-484c-bdd0-08d959275e86 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2021 22:13:07.5350 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 0AKWHpokTKwDTkGONO0q6t9MCiuf+Uv5UEqfnigMbcLaqO/QTYxS1P8x6tUYxL6wkf71keoJbJLkRHgFvb55N1grLfdsbbfv/ua1/i6yoRg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4734 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10068 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 adultscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108060145 X-Proofpoint-ORIG-GUID: -YH3UAo7QBAQMKy8n6GLAZpWswM8g0Ij X-Proofpoint-GUID: -YH3UAo7QBAQMKy8n6GLAZpWswM8g0Ij Received-SPF: pass client-ip=205.220.165.32; envelope-from=steven.sistare@oracle.com; helo=mx0a-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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , Jason Zeng , =?utf-8?q?Alex_Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Zheng Chuan , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add an iterator over the sections of a flattened address space. Signed-off-by: Steve Sistare --- include/exec/memory.h | 31 +++++++++++++++++++++++++++++++ softmmu/memory.c | 20 ++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/include/exec/memory.h b/include/exec/memory.h index 0e6d364..2bb6772 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -2286,6 +2286,37 @@ void memory_region_set_ram_discard_manager(MemoryRegion *mr, RamDiscardManager *rdm); /** + * memory_region_section_cb: callback for address_space_flat_for_each_section() + * + * @s: MemoryRegionSection of the range + * @opaque: data pointer passed to address_space_flat_for_each_section() + * @errp: error message, returned to the address_space_flat_for_each_section + * caller. + * + * Returns: non-zero to stop the iteration, and 0 to continue. The same + * non-zero value is returned to the address_space_flat_for_each_section caller. + */ + +typedef int (*memory_region_section_cb)(MemoryRegionSection *s, + void *opaque, + Error **errp); + +/** + * address_space_flat_for_each_section: walk the ranges in the address space + * flat view and call @func for each. Return 0 on success, else return non-zero + * with a message in @errp. + * + * @as: target address space + * @func: callback function + * @opaque: passed to @func + * @errp: passed to @func + */ +int address_space_flat_for_each_section(AddressSpace *as, + memory_region_section_cb func, + void *opaque, + Error **errp); + +/** * memory_region_find: translate an address/size relative to a * MemoryRegion into a #MemoryRegionSection. * diff --git a/softmmu/memory.c b/softmmu/memory.c index e143692..45952fc 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -2645,6 +2645,26 @@ bool memory_region_is_mapped(MemoryRegion *mr) return mr->container ? true : false; } +int address_space_flat_for_each_section(AddressSpace *as, + memory_region_section_cb func, + void *opaque, + Error **errp) +{ + FlatView *view = address_space_get_flatview(as); + FlatRange *fr; + int ret; + + FOR_EACH_FLAT_RANGE(fr, view) { + MemoryRegionSection section = section_from_flat_range(fr, view); + ret = func(§ion, opaque, errp); + if (ret) { + return ret; + } + } + + return 0; +} + /* Same as memory_region_find, but it does not add a reference to the * returned region. It must be called from an RCU critical section. */ From patchwork Fri Aug 6 21:43:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12423979 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 431CCC4338F for ; Fri, 6 Aug 2021 22:18:20 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7B44C61179 for ; Fri, 6 Aug 2021 22:18:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7B44C61179 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:36974 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mC8AU-0003df-FW for qemu-devel@archiver.kernel.org; Fri, 06 Aug 2021 18:18:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47140) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85g-0006tE-42 for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:20 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:22864) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85e-00048w-8k for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:19 -0400 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 176MBfKo007299; Fri, 6 Aug 2021 22:13:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=+OtZ0oN1pLBeExwfEiVml6vg9iyAZzfaCCVKW3ly3sg=; b=O2bs6zPhIEueAJ7tXmUmg1TALMsfOqWqr1KeX5mlOcim111jQgMI9IQ0nvhxofcPeYmE ZKGkoUPgq2lWpH59WXs170Vh41CpsevLcCEYzIOv4G7BRoSVHKSrFHTvxT9jiwrBuzi1 Wjm2qJbleAyyoGVQorS5xgiONgup45zUOwhlhy6ICKYvioI0k31SD9Fq8E8ZoyoBz6Sh 812vvYot2iodSnt/GO3Wep3InBNSV0Tbx63Cw08gitHPDUQzMY+6gu++Vw1umS1iXisx inVnasxAOOPmIDFBfCiwOXAOON118p+Aro97zXj7vL38JHbHPv4o1z7lN0Er+CN1bkn3 AA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=+OtZ0oN1pLBeExwfEiVml6vg9iyAZzfaCCVKW3ly3sg=; b=mn3AG0RRgGU6e1rvzow3xHa8scBbpZmV8p9FJvP28xrZgeB0t97bulH5lY6UZQELKRqI UDkXQggj6axE9gRdtDpLjAzPlnoSmfjRUDIzpJC21geBZ0x+X0NoWDK/66eiqGoiROUM zrMF+tWrrtpcF1npQZPxcSXPCp7z0jGl9DcxIDxnY0mu5SuTw254ASAmVqFhnq0gwZKC ZLH01d6ZuaVLbhbSfUYnkUnJIPDrQvHfuR70zK4mUfg2SY5wL1j3kyNJFM1xm378gLMG l2roob/rsvzfKngQeyJ43K1xFYboBadsMwNcuhOAPkBR1HJoY4XDo8B53jyIHRr41jbS 7w== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3a8p6rjpm9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:13 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 176MBiK9013868; Fri, 6 Aug 2021 22:13:11 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2168.outbound.protection.outlook.com [104.47.55.168]) by userp3030.oracle.com with ESMTP id 3a962pfavd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hsMkqwLbvK7LKCN45FPa/PHDcOqJ7noIXte3EJILMWZRBEv6nUF9HAX/VJVouXSiIg2jonE/4C9SJp7BVpyyCti6uxGiisH734tgraoqblwnnS1Sg7Upaocwaj9ubbX4k2rZFfMYmDCk4wnjwb+Lm450JWWpCK2kS19fQkpD/MVnFvEsL941tS46Un8CZbsVzNAlYsL3zXNEVFTK/ErayaJwjWU/HqHnqrOCk6gxGjdv6t9n255K2yycwdZKHl++s/9B1CBoS99W1e1U1H4cdOKiI6wKE5rw/1RC9jNj62UcGwTB7poLyKZQg30n5enoqraOAeq84BGZW/5HAjUJYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+OtZ0oN1pLBeExwfEiVml6vg9iyAZzfaCCVKW3ly3sg=; b=MvmYo3nzWsNb05TZM16ki1WJE5dVVBuAHhBb8Cr1jorJiTOwNfTKHX2FRdk7LAPuPvg/Pc19HhR5LLcava2dW6X5vbf4BLjEOtNbSxstTKjN39u0ZQnQUF8V7k3b0wu83mI4jvwxWv2WTNa0kZbW+SXjeXQ/h93ShfMF7bu6H6vWsnty9sgQ8Yz7lt1JRk0g/4FPlFlvbGj9jTlG97zEQ/dz31AdVVjJxlSWChwcMZddIwqmffNcZjQsaTS0iH0VJxc3RM2x6osG4IqFnCT9ll4kf7g8M5+K4zXHEsRHDYASvzsWBt98gI6Vb7Lc3ae7JLyA056mFACSy3OrgatHUw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+OtZ0oN1pLBeExwfEiVml6vg9iyAZzfaCCVKW3ly3sg=; b=gZuQEt3XIjDRKKWLn95QVnduMGMweEjXkZ80WnXe7k2kGevLIwzCkug2+GUUnEmqiirgXraKITU+0oquL0pM0lKbJgNZWaOGGUDdJpmKU5jemyA9hYdb9g7gqFxMqXf5xFGMjhVFcff5HoFpaWYPlLP1D82vg/VAFLnkYfZKp/o= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) by SJ0PR10MB4734.namprd10.prod.outlook.com (2603:10b6:a03:2d2::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.17; Fri, 6 Aug 2021 22:13:09 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3%5]) with mapi id 15.20.4373.028; Fri, 6 Aug 2021 22:13:09 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V6 09/27] oslib: qemu_clear_cloexec Date: Fri, 6 Aug 2021 14:43:43 -0700 Message-Id: <1628286241-217457-10-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> References: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) To BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ca-dev63.us.oracle.com (148.87.23.7) by SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Fri, 6 Aug 2021 22:13:07 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 870ba059-4737-45ab-1273-08d959275fa4 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4734: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1388; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: V4IqJzDesksKCxc5FTjX5o4AC1t3TA6X/AaDn0h5aKcOuLuYbYoPUzg14Z0DxqDoiYG8BY/dOEtEOJXeBgA9nPM5gjeTVj9FhgBr5WfIGo+eUbfwGcEEfKKce4MwPu/U0cKFfSy6N54FHrgWLzgXW2t81LrI5M9iFzAMJk3PSaTPvgy+q2SkNcZhTLaG/az8X4tGHrtKsgdL+XSEbV3cJWN8Zd+ynamopcJp7j9D+iNOjDO8wDH9G1L77RGgEJTzWC81JHUZ+LV1qcO0xI1qmG/Ggf8szqgvZPWgScD602vyxfFekM97ZnAkq+NlfPpFqAXqnQF96Q04VCauPQOPS6nsKJzdNFVwDLYqqQRiZM4FFH79RdlfVXyqM4q9/xFZrfA84JzdUOjIBocTbKHlHedvjYFHr0U9OHuz07ZVIElFiL1N9sk6DppkeKs2RPvYQJw0iXPZ6mRhpv/y5WGHnVHy31qYzbXxdm2vlJe6HMw3Ukkuj8XwNImFAkKvYOlUaL7xHgC9DVmU7XqN/JPUhsPkl1ik2sggsPV6R81vBfDCqnJhHWHWb5lzRAlHAAmIQUDnZwwxkjF6yDKvnqcQKr61/+MPw64Sn51KrGCp8QuQULdJrh2u6RcdETC2Lu8cVY027Yls29oLiYT02PIQ3YN6t3ApVODHmxv4wgSt/ecmCuKxIJviE7hIqrdduWxuFnCm02Y8abd28uUhUP8/qQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(396003)(376002)(136003)(366004)(346002)(66946007)(107886003)(66476007)(8936002)(86362001)(316002)(54906003)(8676002)(66556008)(4326008)(36756003)(956004)(6666004)(26005)(186003)(2616005)(478600001)(7416002)(6916009)(5660300002)(2906002)(52116002)(7696005)(38100700002)(38350700002)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ruBItlrABqG0hfo59BN9X4O+kiOz30+oI8L8OUh8zPjbfDFPMnGQ+33NKPimzANjMW+7vM027bv/7nF99pvSE3LmMHvV8pKYC9ZQV8Ji+rXbJ0sXcnDLG464X5gZZH+4v7qBt65xSHbijl5pWLiLx93z7I8J8UzQs9EMPzSR917tUZGbbnwogkT/ZFveBg5s+UsyQguRxPVshCz8ZAXfms+YN+daoq0AyIrvUmLdvFicwnkkSPo94rRRa5hln4zoLClCbQepfeuyxM2Pm3C4OoWB6q9rUaeWw644ULpaFGeOPLmaIQjJbye7i3oOImZ1N3expfIDtDsDheE4HGNxYVeS3YK6nBDLcBsPitN6BPgXWJ9B+IcqAKNT/sOm/EtlbHnu3K275MKRmhTYPLQmNvPhL/p8NhCjhZXclPP5CvVE1+6f8DjNmQLRbb9dC0W9kRrJ1PBApD/jz1J6W+I8b16cHWQ2OCceWOrPkylo4yOmiBbC3B/Dz3V03ZOO4XAvhbCRXvCKDe5OpN4Jp/FUFbwn9ONGjGXg73Lw09rWg8HUQNiPV8zd0/czXyd7rzMZMjVIV9+zVVFb70CetAui8/o8d0Ks8wj4RbQTA6O9WlSx9A36rhD/cV8YgM5iRAOTDQ/YOSt+YuoqfT2GsMMy4PxMx/zEgTASN/RNZoiC6Fe0tRu92xne46/0l8XZPK9nAhphJLtc8I2fEQ9rCgZ5p2dCj7kPrJ5uFOFBNlVXC+66UwhwQu7YPTwXaiSxgx8usR5XjINycfuGFW9ozWFKE0MQPwwlOoWK9SL5IisWhb0GiBNNrtdvXRJyX6RkIu6Qpgv/jfKtf6QzexrHV8eQzD6ftfaeChctekLEULh/Asiy27ZwDlK1SXw4WY+TFB1VVCrybgAE+pFbdHiOl3nAxDif3nD4U50ATPXCYXCy5JmkS649r4oW3N5bhUViKNueISmjS1vaGynR52ng1NF7wbUon07rS17eQ2v4C6XFp/QbHbjGVamRhRUse86M8pbsMbBhppfli1M1/Gn8A2+d8uoskFK1fdvvRtkqFLX0k3qAlvhWMgLxKAfaR2uIqU/9Oit8XPg38wVvedrmR+wsJe0y2hD0u9HJaKXhdVbyvgiXmE3gyi1UjFuDxwoBAPsJFRLxzhORFdueibT1KBGrAt6LxCfadbz1TCZ/7FzyLB8ogJQuqyHbydhdf9LasBtB47YFjZAFntWIbnn4PMz1FecflYC0yVb2Ml4kDeKRxjk8EhlA55iPW6qcil+unkT+bk++Zq4C98z0OFI0IeovQLtNb8j+1gFDfGRjKD3OU8lnt7pqh34gqbdOSLf6c6w7 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 870ba059-4737-45ab-1273-08d959275fa4 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2021 22:13:09.4589 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 9K1UQ2jR3nuA0yxymweZvXMopMFjIEiJnGQe/+RyfFMcB8UXKoTcnABoUR1uHEYu8YlFcdUb/gAwASoHyM7dXcHsNK0V07dVB6buWrg9ZHQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4734 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10068 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 phishscore=0 bulkscore=0 adultscore=0 suspectscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108060145 X-Proofpoint-ORIG-GUID: uze49wiFBay36EcYSZgEE1PQoBZy-aaF X-Proofpoint-GUID: uze49wiFBay36EcYSZgEE1PQoBZy-aaF Received-SPF: pass client-ip=205.220.165.32; envelope-from=steven.sistare@oracle.com; helo=mx0a-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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , Jason Zeng , =?utf-8?q?Alex_Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Zheng Chuan , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Define qemu_clear_cloexec, analogous to qemu_set_cloexec. Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Steve Sistare --- include/qemu/osdep.h | 1 + util/oslib-posix.c | 9 +++++++++ util/oslib-win32.c | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h index 60718fc..1ad7714 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -637,6 +637,7 @@ static inline void qemu_timersub(const struct timeval *val1, #endif void qemu_set_cloexec(int fd); +void qemu_clear_cloexec(int fd); /* Starting on QEMU 2.5, qemu_hw_version() returns "2.5+" by default * instead of QEMU_VERSION, so setting hw_version on MachineClass diff --git a/util/oslib-posix.c b/util/oslib-posix.c index e8bdb02..7913334 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -309,6 +309,15 @@ void qemu_set_cloexec(int fd) assert(f != -1); } +void qemu_clear_cloexec(int fd) +{ + int f; + f = fcntl(fd, F_GETFD); + assert(f != -1); + f = fcntl(fd, F_SETFD, f & ~FD_CLOEXEC); + assert(f != -1); +} + /* * Creates a pipe with FD_CLOEXEC set on both file descriptors */ diff --git a/util/oslib-win32.c b/util/oslib-win32.c index af559ef..acc3e06 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -265,6 +265,10 @@ void qemu_set_cloexec(int fd) { } +void qemu_clear_cloexec(int fd) +{ +} + /* Offset between 1/1/1601 and 1/1/1970 in 100 nanosec units */ #define _W32_FT_OFFSET (116444736000000000ULL) From patchwork Fri Aug 6 21:43:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12423987 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47B3EC4338F for ; Fri, 6 Aug 2021 22:20:22 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 787E761165 for ; Fri, 6 Aug 2021 22:20:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 787E761165 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:45528 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mC8CS-0000qT-Fd for qemu-devel@archiver.kernel.org; Fri, 06 Aug 2021 18:20:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47162) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85i-00070t-F1 for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:22 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:25246) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85f-0004AI-T1 for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:22 -0400 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 176MBjrJ007313; Fri, 6 Aug 2021 22:13:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=TCDSxZKq8I0eOTivAM8EbtS/7kZgpQLRv2VhUQbkRzc=; b=PE2QQ6wVYshaoof29+xxUZgX7Kt17EF1umsUwwlWvdok8ghRsOrIkC75DAKsHrYxf3IP 2U+0PGyU7Lf/CyGC6H9VV/kUSilkAaCPsSCxc5yCuRUk7p0Mbn8ef9gGvJdNFmreMzEX mEfQT7pF0VNBfoyH2jiyD7TlgbeySaoqLVWW5nPzrgiWK9U7HNHeT0X0truY77Jt8Mfb ZXPmcs/Zw0Ju1pJCSVfThVPkgOI9cJn9g5J9Asky521tU8+qgsSmZJkPybq9slMLvvvG ylVTTLnsJo9aVdYMFbaQZmysH0/q3vyZgHh0v9M/FEmQPH6TCX/YF1wcgDCT6nP3KmxU wQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=TCDSxZKq8I0eOTivAM8EbtS/7kZgpQLRv2VhUQbkRzc=; b=IMjQenKNhRI4JIaRTPnqSx8jqTJzFok1+DmRAsYJcxn4/A9RejpEHqrEOKyp0GwBx2lR IA2Zd2eHig5wJQ1W6Lofrz8gm8SUfguf/RwG0hyvGS88m6Q3xdT3CjCjGFjBNPPyfQls MFTo/t+GH4OFqU2ayRvqZjF0xs/V9jKhVf3ZY6xCLkUVcNcWPYKpPVJyzwTQyxJHKxgL FO+qQxdbmSrFwmdwCVDxAmjovCgE8OnwqaXPGDmVurvrtwwOdMN2WbOYOt454ljYPZZn 2A6EWnUVmmKoy5rGWR3p30yS3tafeDZ5SKnDhK9i5cbd5N/MNSyQMGOuPemY5Lp2mLoW Gw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3a8p6rjpma-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:14 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 176MBl1p032690; Fri, 6 Aug 2021 22:13:13 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2168.outbound.protection.outlook.com [104.47.55.168]) by aserp3030.oracle.com with ESMTP id 3a78db75km-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lbjy0gPXeiNrELeQ3lzjfOzHzbLh7fm/V5sKkgnTRy0i2o3A20V4r9BtxrxTtvcJy1U+h89k6P9EhioUGcXUJV07MqbPoDU1yoNiWZyShzeR196NG+N2eLdarBCkzWzNKLgpZzzd9hL5AfazmZ3n+ZpVRJchSjgzQg0W+Rk0Ke2mLLNeWQyz8zvCIzq5rYl9fCvsXSjZlYgVzqjxA+XdHfao+fxVUa8kBRONdAH5sdbHpL2hcqjOLLhAbC3+ny7LQGO1DY4I+BJ4tUSlJqf/cWn9tU7Am1dDgaS9xJtc7meEWnioNak5g8AzRXByxfINM7GQAStmcEqd5wEcZyJUXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TCDSxZKq8I0eOTivAM8EbtS/7kZgpQLRv2VhUQbkRzc=; b=DlS0y9jsIpI33V4Kh1AyzlNp+HTpzpVlB/2Krxu2mvzN/k3/ta3F4kzvRJn+wyZzmSW6DA3+n3CewEAesnWAJ7s9m3BYvyr49zs8kWig7tvgObtqYwMz9+Fs1DmbT6/v/dxH6jpPvnBIeJQUMnc4O5msW6vWpy8sL4/CxsCGOC4Zs+829g8LlpbsAwb2bVkUIy+PnZmbIVbNRI1ChgMCJmUXR0Cj4WT6/AdZd8alkOTW4F7vkfRjwIsq51Dhj+rBWpPI6Xep/BLcyVwb8d+TSXdrHVm0TKIIyBR4ZooEYGQUz2N3Cb7Jpcs/ypYRYFppqK2+3s/GYGweSuvs9nJkww== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TCDSxZKq8I0eOTivAM8EbtS/7kZgpQLRv2VhUQbkRzc=; b=AmA8rNZwsw52Q+dVMfOfe2oejC6f3hpCzbRel7N7w4nl4ZEI529Flq86WAvXr3OTfA233mSpi2LxUpjDb6D3m4+g6nQt4tJ9EU06t0ZbL5XZUxVxjBE6LphPNIJG/L+F3+zCOYBfYPbEHuvRbWFWo6NkGHHB6NlRSy0z+LKAds0= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) by SJ0PR10MB4734.namprd10.prod.outlook.com (2603:10b6:a03:2d2::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.17; Fri, 6 Aug 2021 22:13:11 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3%5]) with mapi id 15.20.4373.028; Fri, 6 Aug 2021 22:13:11 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V6 10/27] machine: memfd-alloc option Date: Fri, 6 Aug 2021 14:43:44 -0700 Message-Id: <1628286241-217457-11-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> References: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) To BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ca-dev63.us.oracle.com (148.87.23.7) by SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Fri, 6 Aug 2021 22:13:09 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2c88aea7-8224-452a-bd87-08d9592760c6 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4734: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:93; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aCGRovEWxJj+eygNbGvkAFSOGH8YY7maHtrVw09V71/GTnHJIi9vpJRNNMfZaRBWCi3bVeuEswhUkt+T6Ld8X30Hox/Rycl+lO+3VNVcdP46wvwt3UW3+dLEDFFWcM+alIddymJOQ1p/saIp0u7PhG1VPNzOS5FxrAI8uctVf+4esU393gs9P3+M7m64EF1R+nk9T8QI5w/ZaihZvxZedOt5jTjcQIQPGmm9YTy6fpriwon6CAaTQjdfdsSgpmp1Ks56oGbVfMGuQdDfcQLjiFDQ4fUjt+GIGm/YJ1U+B0nAHc/Y6Mxc0tW++WyHCtL8d4CQE5mnU5FWP06Zg0yHcK2cZllaycjIWSUBtLo3e5iLU4+UF4APg2qdoviDP0XUUBiMlqr9SSgQErd/jt7lMVeN02l3NQ4WCNbzUo0tOUB+6bcpqInxveDIHhODdoVCtK2DJa5eHUqcaUBBNuYcPuDccr+9VcEHxoZLcFRaaYN3eCjxIWKm0rONnjPcv/jxpiO5c7qb8RmI+imwVHJ3OopfbOrgPhbqASRtsKI7csa+hj98o2vycCHwXnk4ROPC5a2icU67lxZ3CPVcoYAIeYwPrqH9i+ZXiuERRAQJg9yEYtTq7SlG5Bef6Ej8tvHDUB+Tbb3INm6525qUITZ5bT0oWSu0lWb/1NfbKac4CqLD17Vvcdz00lir/PkYf7oU X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(396003)(376002)(136003)(366004)(346002)(66946007)(107886003)(66476007)(8936002)(86362001)(316002)(83380400001)(54906003)(8676002)(66556008)(4326008)(36756003)(956004)(6666004)(26005)(186003)(2616005)(478600001)(7416002)(6916009)(5660300002)(2906002)(52116002)(7696005)(38100700002)(38350700002)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: S4kAlXc9mlz6xVDXU0pyiO/HtFcCtOhi9OXAZra8vvJ8dRSYQAlXHkBm9l+xVJQ8yupTSD3WXIEG/BjSZxUKKgP/LKq66xv8x8dIZ6qNSQR2xMfmXD6GKww6Ak6d+Zb7kZVbIeb8qwcmEc830sk62Ckc9bn/qj/WmHZcQ8cOq2ZtbvH0D5qREwf+VAsnyFRsx3dPFzyzusn1P4g3nix90lCMla4jI6Yt1cqGkiFHaCKyzo2eebmC4ITGnx2Y9SZcNdbjDSbLdnsnD6Eo9sqP2NkjRPiTBieO3cbpRHDBsVKd6EzbMNC0Oxy3f6bQswgQCslegf8oE3UdT52OB+vsgymc/WDnse6Az4S/pM2ER9qvgdpQRjaIWFi7rpEoFL+FAV9xYYJco6IgDxfLk7qUygk7rD3g2ca6vd8RIcBDwQpu0XeytLizQbjoennAFWyQq4SX4LF1myacIWiMQG/qzlQeaVuKNA8Sqwfg+//u8brPB7sginGr+bowFg+ax87iBiDJ95iqEhrSYcvN+ve0KOnEmwRpRO0OnV4ZaD4o/A7+RQfMoZwAsfOHl0RVkKf+aqrWYjztc83OR/85sUgbbMiuJsddBL+MGbuSEVsZOnRqlqs+kufJTP1NI2nzRph2dIIMWxmQlfUo4PVVhO8bWtwNwlQABPumzRSOSyoZJczFv9dGAECTuV4iY5v/q9I13nf/2/QlX7Fy3DP8W3xZ+027S0dxAkI2PvYmLk/EqL9lksVPC11UcuqlDdSeV0CfMrfEQ+2Epa1fVc47Mz1qZmAviVP3Ef0CeykQcIUVyi9ft3ZvX5Hj2guT+1w4JAg9ombJak9kldUJfb8TrrYYth1YHr9qrkaMhv89KKbZNvp42mTXszNE+v3hPfNhHQqfh0FLn2oV08l3dpmY4Eb3PwPOFghZ4mJfF25qGtYXmZE+wDCtZXL8vt3p+ilrSnA6rnQBx3ZlbXNHSN+8DrY4SFfnxnTpDm2dvGr5Ur6Y1i0BFgD4QOmiPU13ja/8MH8Q6dhTtEXtKcGHSFJXmbazkArhO5afGpb5Ga+BPmihHo4c1yu2INLcA46uIwFqLYLcLn97rnHf4bVOQz0lLY6ciSkyZl6Nw52Sq0tBPPPkdt2IlNg7L3rm2xcxEfhsFSfZ7cM6VPq+6UjL5+pK+GnFcNxNl/v27pxptYDbwCq0JtbfapMCffpEZaUW4CI2ogQB91KXb+0Eanl0SRTKvgBOLqOu6Y3reSb2R3xRu56E3kSqZno5qRhz5+675xItjn+dd7xf+sN8whXRJ0/wEG/c64ukcyVFi46icZC1pgzU+GSc+3PSYQbjEoVr2041tj6W X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2c88aea7-8224-452a-bd87-08d9592760c6 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2021 22:13:11.3189 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vwiZ6ohzSdwBf6fz4kR0vu0Q59wY31LwzYJdBFbnJlnz5j5YtGbMQwY7rse4MJJK8YkrKORjEb+k7U+w2zG48eCDuaTRKsCQyFyDUgJkNtM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4734 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10068 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 adultscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108060145 X-Proofpoint-ORIG-GUID: MeLrVjIgVPI0EvEvQ6jtFqnupIkpwv7e X-Proofpoint-GUID: MeLrVjIgVPI0EvEvQ6jtFqnupIkpwv7e Received-SPF: pass client-ip=205.220.165.32; envelope-from=steven.sistare@oracle.com; helo=mx0a-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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , Jason Zeng , =?utf-8?q?Alex_Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Zheng Chuan , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Allocate anonymous memory using memfd_create if the memfd-alloc machine option is set. Signed-off-by: Steve Sistare --- hw/core/machine.c | 19 +++++++++++++++++++ include/hw/boards.h | 1 + qemu-options.hx | 6 ++++++ softmmu/physmem.c | 47 ++++++++++++++++++++++++++++++++++++++--------- softmmu/vl.c | 1 + trace-events | 1 + util/qemu-config.c | 4 ++++ 7 files changed, 70 insertions(+), 9 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 943974d..5d76265 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -385,6 +385,20 @@ static void machine_set_mem_merge(Object *obj, bool value, Error **errp) ms->mem_merge = value; } +static bool machine_get_memfd_alloc(Object *obj, Error **errp) +{ + MachineState *ms = MACHINE(obj); + + return ms->memfd_alloc; +} + +static void machine_set_memfd_alloc(Object *obj, bool value, Error **errp) +{ + MachineState *ms = MACHINE(obj); + + ms->memfd_alloc = value; +} + static bool machine_get_usb(Object *obj, Error **errp) { MachineState *ms = MACHINE(obj); @@ -919,6 +933,11 @@ static void machine_class_init(ObjectClass *oc, void *data) object_class_property_set_description(oc, "mem-merge", "Enable/disable memory merge support"); + object_class_property_add_bool(oc, "memfd-alloc", + machine_get_memfd_alloc, machine_set_memfd_alloc); + object_class_property_set_description(oc, "memfd-alloc", + "Enable/disable allocating anonymous memory using memfd_create"); + object_class_property_add_bool(oc, "usb", machine_get_usb, machine_set_usb); object_class_property_set_description(oc, "usb", diff --git a/include/hw/boards.h b/include/hw/boards.h index accd6ef..299e1ca 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -305,6 +305,7 @@ struct MachineState { char *dt_compatible; bool dump_guest_core; bool mem_merge; + bool memfd_alloc; bool usb; bool usb_disabled; char *firmware; diff --git a/qemu-options.hx b/qemu-options.hx index 83aa59a..05e206c 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -30,6 +30,7 @@ DEF("machine", HAS_ARG, QEMU_OPTION_machine, \ " vmport=on|off|auto controls emulation of vmport (default: auto)\n" " dump-guest-core=on|off include guest memory in a core dump (default=on)\n" " mem-merge=on|off controls memory merge support (default: on)\n" + " memfd-alloc=on|off controls allocating anonymous guest RAM using memfd_create (default: off)\n" " aes-key-wrap=on|off controls support for AES key wrapping (default=on)\n" " dea-key-wrap=on|off controls support for DEA key wrapping (default=on)\n" " suppress-vmdesc=on|off disables self-describing migration (default=off)\n" @@ -76,6 +77,11 @@ SRST supported by the host, de-duplicates identical memory pages among VMs instances (enabled by default). + ``memfd-alloc=on|off`` + Enables or disables allocation of anonymous guest RAM using + memfd_create. Any associated memory-backend objects are created with + share=on. The memfd-alloc default is off. + ``aes-key-wrap=on|off`` Enables or disables AES key wrapping support on s390-ccw hosts. This feature controls whether AES wrapping keys will be created diff --git a/softmmu/physmem.c b/softmmu/physmem.c index 3c1912a..d11455f 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -41,6 +41,7 @@ #include "qemu/config-file.h" #include "qemu/error-report.h" #include "qemu/qemu-print.h" +#include "qemu/memfd.h" #include "exec/memory.h" #include "exec/ioport.h" #include "sysemu/dma.h" @@ -1960,35 +1961,63 @@ static void ram_block_add(RAMBlock *new_block, Error **errp) const bool shared = qemu_ram_is_shared(new_block); RAMBlock *block; RAMBlock *last_block = NULL; + struct MemoryRegion *mr = new_block->mr; ram_addr_t old_ram_size, new_ram_size; Error *err = NULL; + const char *name; + void *addr = 0; + size_t maxlen; + MachineState *ms = MACHINE(qdev_get_machine()); old_ram_size = last_ram_page(); qemu_mutex_lock_ramlist(); - new_block->offset = find_ram_offset(new_block->max_length); + maxlen = new_block->max_length; + new_block->offset = find_ram_offset(maxlen); if (!new_block->host) { if (xen_enabled()) { - xen_ram_alloc(new_block->offset, new_block->max_length, - new_block->mr, &err); + xen_ram_alloc(new_block->offset, maxlen, new_block->mr, &err); if (err) { error_propagate(errp, err); qemu_mutex_unlock_ramlist(); return; } } else { - new_block->host = qemu_anon_ram_alloc(new_block->max_length, - &new_block->mr->align, - shared, noreserve); - if (!new_block->host) { + name = memory_region_name(mr); + if (ms->memfd_alloc) { + Object *parent = &mr->parent_obj; + int mfd = -1; /* placeholder until next patch */ + mr->align = QEMU_VMALLOC_ALIGN; + if (mfd < 0) { + mfd = qemu_memfd_create(name, maxlen + mr->align, + 0, 0, 0, &err); + if (mfd < 0) { + return; + } + } + qemu_set_cloexec(mfd); + /* The memory backend already set its desired flags. */ + if (!object_dynamic_cast(parent, TYPE_MEMORY_BACKEND)) { + new_block->flags |= RAM_SHARED; + } + addr = file_ram_alloc(new_block, maxlen, mfd, + false, false, 0, errp); + trace_anon_memfd_alloc(name, maxlen, addr, mfd); + } else { + addr = qemu_anon_ram_alloc(maxlen, &mr->align, + shared, noreserve); + } + + if (!addr) { error_setg_errno(errp, errno, "cannot set up guest memory '%s'", - memory_region_name(new_block->mr)); + name); qemu_mutex_unlock_ramlist(); return; } - memory_try_enable_merging(new_block->host, new_block->max_length); + memory_try_enable_merging(addr, maxlen); + new_block->host = addr; } } diff --git a/softmmu/vl.c b/softmmu/vl.c index 5ca11e7..cb72ca2 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2406,6 +2406,7 @@ static void create_default_memdev(MachineState *ms, const char *path) object_property_set_str(obj, "mem-path", path, &error_fatal); } object_property_set_int(obj, "size", ms->ram_size, &error_fatal); + object_property_set_bool(obj, "share", ms->memfd_alloc, &error_fatal); object_property_add_child(object_get_objects_root(), mc->default_ram_id, obj); /* Ensure backend's memory region name is equal to mc->default_ram_id */ diff --git a/trace-events b/trace-events index c4cca29..a42c7c5 100644 --- a/trace-events +++ b/trace-events @@ -45,6 +45,7 @@ ram_block_discard_range(const char *rbname, void *hva, size_t length, bool need_ # accel/tcg/cputlb.c memory_notdirty_write_access(uint64_t vaddr, uint64_t ram_addr, unsigned size) "0x%" PRIx64 " ram_addr 0x%" PRIx64 " size %u" memory_notdirty_set_dirty(uint64_t vaddr) "0x%" PRIx64 +anon_memfd_alloc(const char *name, size_t size, void *ptr, int fd) "%s size %zu ptr %p fd %d" # gdbstub.c gdbstub_op_start(const char *device) "Starting gdbstub using device %s" diff --git a/util/qemu-config.c b/util/qemu-config.c index 436ab63..3606e5c 100644 --- a/util/qemu-config.c +++ b/util/qemu-config.c @@ -207,6 +207,10 @@ static QemuOptsList machine_opts = { .type = QEMU_OPT_BOOL, .help = "enable/disable memory merge support", },{ + .name = "memfd-alloc", + .type = QEMU_OPT_BOOL, + .help = "enable/disable memfd_create for anonymous memory", + },{ .name = "usb", .type = QEMU_OPT_BOOL, .help = "Set on/off to enable/disable usb", From patchwork Fri Aug 6 21:43:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12423967 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 556E7C4338F for ; Fri, 6 Aug 2021 22:15:00 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 93F2761179 for ; Fri, 6 Aug 2021 22:14:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 93F2761179 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:51052 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mC87G-0002ek-Ip for qemu-devel@archiver.kernel.org; Fri, 06 Aug 2021 18:14:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47206) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85l-0007BQ-Lw for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:25 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:28186) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85i-0004BR-Kf for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:25 -0400 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 176MBfKp007299; Fri, 6 Aug 2021 22:13:17 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=XZnWp40LvrZw0mIr2bJzELHBiVEeOB0Qd6ajB9Do80U=; b=ErgqXC+xVL2BPimVG/zEv/QnbBrEnoHRtI569E0fBU+uaNEE+L+CuOow5A4LMKPHeu+t 1ziEL9Q2ANv5Nx6CzQeJViRNPMkzKfYfjKkcZePZbyZoiWwzNazhFglSWGb8rJF5qdtw WPuBdOpIJ4TEdSmNyFWuJXwQHdlWZ6K1/ciP66vIKPyhyzjyIWiG+rlsZNFNjGSo0w5S JoCTmnrcxyCHa1eB0yAn+l5Tno1edmMMPPBGk9ejnEnzt67g5js95f2q0J6Dy+/IHeiC beiCySlVxP2I/3duzD8bpO8usOrjrpa0G1NKpgexb/LKXZiuCHNiIHwHt1PL9xmM7PT7 MA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=XZnWp40LvrZw0mIr2bJzELHBiVEeOB0Qd6ajB9Do80U=; b=T/n9qKkEXZsiE/AngPZerlCRBuzo4W9ZJV+uDZZrvIlQm1NZX+IIy1efK06k8Uu0ymmR vNvH4fcQIHRnvlR/pc4wf5CaCyKt6/J4zezw9A0Io66Xdzi4p7RBkce7xgqkbKr1R3oQ 3Gp3DSytidAXP1wcQYTV+U7Ff/wKpUPiSYQ9BjGnkE0Smz9EF/0Qv4U1i8Jq/EnyqQB+ NwVidSo07KExLMeN6qJYhCVumg7VSFJq/VYX/6nMnWtHP1mmeTseunJfh6+WYQfj2wpZ KPAK9gvGftJMyiBw0JpxcppprUTWHtO2uSiQ0IjGd1yyHLbzg/HS3gRuL+V5jeeFllXF Ww== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3a8p6rjpmb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:17 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 176MBeja032608; Fri, 6 Aug 2021 22:13:16 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2172.outbound.protection.outlook.com [104.47.55.172]) by aserp3030.oracle.com with ESMTP id 3a78db75me-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=h2F3Ju001noo7d8xwogpqKoRdIX+i9t3jZ+miTq7V/7t7Ac8sjo6xliy5HkpSepd2WF/UkM4bhNdjPrIPu+pUDnkBMrTpLKHsEFvw0Dz93YwYghKH8ddUyxpEY8DMkAy9pNHdNOW0I2qBnBg/2GDbU5Kg/8fPFD70wOpmiFfar89gulf7BleZB9mP7otLX3u8nO70Eccq22SEV29bx38duCjd8wzMYUf9zdMgOtcoyQWsRTWBUwj7lYjxecnYjMA0X+VEFQIeaxTpN2y3TWPIa2u7wYw4CfKlAMPkTqQdA3//LngGcAPpcGoxVZnGBesQ0mO+uAHsGPrcEhg5Uvbyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XZnWp40LvrZw0mIr2bJzELHBiVEeOB0Qd6ajB9Do80U=; b=ZYm8OybP0ZlKAKdaeyAHIHIeVcrewitqha5/JhCUONvqk+JZeLVZxumLeniEAdWjtJKn47PdC9g+BE5P+N8OysDjzHodJpkUcJDf/mkkxbpysp/FXwP60PA+YDJ6RzlRDV99xl5d2r/40Njx9web4YHb0jq6YiS1XOXk5+NPXi46eL2uUKoNeS4I0BhykP4TPdQwADpayFfdEVgRJRMOq9kaqgMw8/xjSUDb9/TWL4jArt9kkshF2ihQMi8e/FXS9vIaCS4id/j3GYufkgv1o9i+CXtw0QeYN5yUgJwETIJbt4kiFJYHyTGAV95Xnt0PRgjQye9htqbV8lK5KlP7Hw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XZnWp40LvrZw0mIr2bJzELHBiVEeOB0Qd6ajB9Do80U=; b=OHcbrmgFfeWcTDtkgmI9ASVffz4TOlZ43CJIB4jnIpiW+in7lDKwouIFmN3TII2ndvVvxSNYKdv0Ox3AxC9rMhDQFq4PPJffZUsB6ctuMxL/fiEAmcqr1NoK+NXeS2ZLW7fmBPtkpQj4EzyP5asqfyZvkYN1rNaVBH3xky8rpYM= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) by SJ0PR10MB4734.namprd10.prod.outlook.com (2603:10b6:a03:2d2::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.17; Fri, 6 Aug 2021 22:13:13 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3%5]) with mapi id 15.20.4373.028; Fri, 6 Aug 2021 22:13:13 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V6 11/27] qapi: list utility functions Date: Fri, 6 Aug 2021 14:43:45 -0700 Message-Id: <1628286241-217457-12-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> References: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) To BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ca-dev63.us.oracle.com (148.87.23.7) by SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Fri, 6 Aug 2021 22:13:11 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2a7016e8-581a-4dff-d554-08d9592761e4 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4734: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pRjpqspA6PBxO1KkdouzGKjG7DN+Hldv+epK6/DuUjHYQZm7nmuD4HQnyjRZwTC5SFDMFxUswAb4fi/TRa/9djUj4hzpLxSFYf6J37ECa8RWEeW2szYyO7rLgTaT13lGetRe4Ufb8nDSBQ1T9lalgRyUAlUpMuv4qhZ7TaJ60UJn0vyLZ3gsdPAQylLKqlA0TQDRrQJsjAQylM7Vr+A+e6KcrBKn+uruz2/zlbkZFIbhXJE6DkoXo3zFlBk30+Zi2ThqTVEu2maGRXSsgklHDgDL3sv8X3HBXysKQV6GBXGyMsH4IWXMFsTzYtDVYDMP4jurSAidxK9XDVWv7Xnhmv2c4zbbzBIXc2dtMjW6Nq6YkPs6gZivt8tLJ0tBdcQHNi0N2RGykOutLvcSHP4JOYCd9rq2HFVCrq2IEVZX09/Ivb5bmuDcFhJNoZv9iW1rbKd3of2K3dQZEe5M0oNdNv3d63AeOdzoPXEqvsiqVjFuKrd9upcHflN3Whbt8H6BSpQzL+dxWaLRyw0ZhI0U8gjiejtQ6AwIjIXjFe4VefThubdD5g6dHKm42lYT2Y06sMt5dvIY9dDEvEJfPV/Z4PvtFH1jO8ft6XKBbE1Bu6p0UjEKUSyXNMHpLPnC2/p+sFr5DEEkQFcuznpR7iQ9TQuAwhuWyI4O2WWrq79vnLSx2393REO40dkvsdctmdBGsyX2W1aZ9rG2dph3pwh/yTwZ4ZZQffLFy2xpcbJU9Mc= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(396003)(376002)(136003)(366004)(346002)(66946007)(107886003)(66476007)(8936002)(86362001)(316002)(83380400001)(54906003)(8676002)(66556008)(4326008)(36756003)(956004)(6666004)(26005)(186003)(2616005)(478600001)(7416002)(6916009)(5660300002)(2906002)(52116002)(7696005)(38100700002)(38350700002)(6486002)(309714004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GzBU2PztaztwRQ8a/UBdYaHxhQWzYAaYEbZu3VClNs/32f+jdilO/mg2kJZGsgF6BHpbFl/Xil6VkToc7/yuKI16cVjavubET+q2aRCe8pfmDVtDRK/2Uj91+n4TUAr8xhjsB2WCvVHDI+PZwmDHFEFVZnV2XuebjZQCuB29+x3+Iq9RGxMJeu5fub4DdZY6dbL3+w/2pKlmsws/3uHwBJO8ZOMG3qgHeXicqhOAOX4VKCIBP7V+bJ8lC7lvrXfxpwWWB4z0jM9nEE8I1msvd0caTBFlxa00CV4ljBSMakjZTx2PTXG3LbOAyN88tvHrN0bX/VpQ9/6Q+yt0u7jdkU/ihy0pciDfZ3BpeGOFav/ORPJwiV/RO+anpCmsaTuEEGJ8tfRUaZosFr6bMBNQYtFi6i8v1sbnrFGnAPITZ4vatmuVpKejD/oUC6YN87BW5b+2E6m8W7ZsKkfu5hcYmuV9kJRMj3ssQsjuMj5a0w/cXq2vy6CnYcShEegzR5z9uY9h17jV+szfxmGBFs6fx7TyvqpXCvhwe+RA9oFW0lFueAF48ZVgECZ5kZYdUesQfPTSGimUpWQ/DjyN1fCFoY/IU9nv6n/V9EhcxpnbSBbDrt6gwUNZy1QbaGsGh7L1HtdEyHI4wyfUZkwQD1VDlcmALkuaQOlzxD/RtROuLJ5RyYjoClw6S+8EJeLFo5l9onhEXOR84V/nld4F6fu4rGlWWoXkmqXY0yay12BkxNBt1EYuOyw5bwaKhZo4V2Zy5tRUsOLPjt7ot6mipIJHhJDXtlv3vqV0LpkZVjM94yHrO/fwQLBV9UPKxdmle2dvMY7TlCv86pSmk1UbJSs1nNykSwA8S0GHYO45XTacfzHCcs+/HTfcmDTIFCTU+AIzy0ffGzMwlbENYQbhPOevDO/doPN/tstb/+dHd3lT6w8pdb+7+dNkduf8ONJBErDB/zEwAaBJYVg0vK61gwEKKZ9GXsokBMurqiEfmInRaGhbLgqKRJgtqpL9v6YEZcxcGJo7Z5HGSFF8hLdQcS8uWGZbBjJAOdMSDQbsHVcUADIDdAO1ByDATg41ZKhVkixwJ9ojxPprhRIvq+BwWp5Bg0Z2y12F9qrVkCJ4utMl5e3OT9haPbbZHg0+XEyUlzigQLSbf7pFXSEjCnMkgeoI01lNs1wBtfG47nS3tZ1xiiMOYWbcZd6DnyT0V3ly04YzmoXmaOqIpn3XZGOzd1MFA7fM05s+bK8O+5nGrMqJeBKfxez9h0ClFdZpGIjQ0DCeN5hjyg/RWCcwMPECdkcW1pt1LdKAshNpbGSgCYsSaVgsQH2uW2ocq/XiJRyIcJu2 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2a7016e8-581a-4dff-d554-08d9592761e4 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2021 22:13:13.2368 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: dT8BNT+NMgyK0yRzc+bf2v5rLJRXKFMkxSEWAEilyk7bBqmf50gKUP+nua4PY02wAQYOGZcBFTUHaHs1LmgxpVQsVpHxI+iHXaRntBAoWY4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4734 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10068 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 adultscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108060145 X-Proofpoint-ORIG-GUID: vr5khCymhy0zm8FgL_2EG668inNSu0bD X-Proofpoint-GUID: vr5khCymhy0zm8FgL_2EG668inNSu0bD Received-SPF: pass client-ip=205.220.165.32; envelope-from=steven.sistare@oracle.com; helo=mx0a-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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , Jason Zeng , =?utf-8?q?Alex_Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Zheng Chuan , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Generalize strList_from_comma_list() to take any delimiter character, rename as strList_from_string(), and move it to qapi/util.c. Also add strList_from_string() and QAPI_LIST_LENGTH(). No functional change. Signed-off-by: Steve Sistare --- include/qapi/util.h | 28 ++++++++++++++++++++++++++++ monitor/hmp-cmds.c | 29 ++--------------------------- qapi/qapi-util.c | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 27 deletions(-) diff --git a/include/qapi/util.h b/include/qapi/util.h index d7bfb30..83cc4d7 100644 --- a/include/qapi/util.h +++ b/include/qapi/util.h @@ -16,6 +16,8 @@ typedef struct QEnumLookup { int size; } QEnumLookup; +struct strList; + const char *qapi_enum_lookup(const QEnumLookup *lookup, int val); int qapi_enum_parse(const QEnumLookup *lookup, const char *buf, int def, Error **errp); @@ -25,6 +27,19 @@ bool qapi_bool_parse(const char *name, const char *value, bool *obj, int parse_qapi_name(const char *name, bool complete); /* + * Produce and return a NULL-terminated array of strings from @args. + * All strings are g_strdup'd. + */ +char **strv_from_strList(const struct strList *args); + +/* + * Produce a strList from the character delimited string @in. + * All strings are g_strdup'd. + * A NULL or empty input string returns NULL. + */ +struct strList *strList_from_string(const char *in, char delim); + +/* * For any GenericList @list, insert @element at the front. * * Note that this macro evaluates @element exactly once, so it is safe @@ -50,4 +65,17 @@ int parse_qapi_name(const char *name, bool complete); (tail) = &(*(tail))->next; \ } while (0) +/* + * For any GenericList @list, return its length. + */ +#define QAPI_LIST_LENGTH(list) \ + ({ \ + int len = 0; \ + typeof(list) elem; \ + for (elem = list; elem != NULL; elem = elem->next) { \ + len++; \ + } \ + len; \ + }) + #endif diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 6aed6ac..da91a0a 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -43,6 +43,7 @@ #include "qapi/qapi-commands-run-state.h" #include "qapi/qapi-commands-tpm.h" #include "qapi/qapi-commands-ui.h" +#include "qapi/util.h" #include "qapi/qapi-visit-net.h" #include "qapi/qapi-visit-migration.h" #include "qapi/qmp/qdict.h" @@ -70,32 +71,6 @@ void hmp_handle_error(Monitor *mon, Error *err) } } -/* - * Produce a strList from a comma separated list. - * A NULL or empty input string return NULL. - */ -static strList *strList_from_comma_list(const char *in) -{ - strList *res = NULL; - strList **tail = &res; - - while (in && in[0]) { - char *comma = strchr(in, ','); - char *value; - - if (comma) { - value = g_strndup(in, comma - in); - in = comma + 1; /* skip the , */ - } else { - value = g_strdup(in); - in = NULL; - } - QAPI_LIST_APPEND(tail, value); - } - - return res; -} - void hmp_info_name(Monitor *mon, const QDict *qdict) { NameInfo *info; @@ -1170,7 +1145,7 @@ void hmp_announce_self(Monitor *mon, const QDict *qdict) migrate_announce_params()); qapi_free_strList(params->interfaces); - params->interfaces = strList_from_comma_list(interfaces_str); + params->interfaces = strList_from_string(interfaces_str, ','); params->has_interfaces = params->interfaces != NULL; params->id = g_strdup(id); params->has_id = !!params->id; diff --git a/qapi/qapi-util.c b/qapi/qapi-util.c index 3c24bb3..1edbd04 100644 --- a/qapi/qapi-util.c +++ b/qapi/qapi-util.c @@ -14,6 +14,7 @@ #include "qapi/error.h" #include "qemu/ctype.h" #include "qapi/qmp/qerror.h" +#include "qapi/qapi-builtin-types.h" const char *qapi_enum_lookup(const QEnumLookup *lookup, int val) { @@ -109,3 +110,39 @@ int parse_qapi_name(const char *str, bool complete) } return p - str; } + +char **strv_from_strList(const strList *args) +{ + const strList *arg; + int i = 0; + char **argv = g_malloc((QAPI_LIST_LENGTH(args) + 1) * sizeof(char *)); + + for (arg = args; arg != NULL; arg = arg->next) { + argv[i++] = g_strdup(arg->value); + } + argv[i] = NULL; + + return argv; +} + +strList *strList_from_string(const char *in, char delim) +{ + strList *res = NULL; + strList **tail = &res; + + while (in && in[0]) { + char *next = strchr(in, delim); + char *value; + + if (next) { + value = g_strndup(in, next - in); + in = next + 1; /* skip the delim */ + } else { + value = g_strdup(in); + in = NULL; + } + QAPI_LIST_APPEND(tail, value); + } + + return res; +} From patchwork Fri Aug 6 21:43:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12423985 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A17A9C4338F for ; Fri, 6 Aug 2021 22:20:18 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E862161179 for ; Fri, 6 Aug 2021 22:20:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E862161179 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:45234 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mC8CO-0000eM-SJ for qemu-devel@archiver.kernel.org; Fri, 06 Aug 2021 18:20:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47222) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85m-0007DR-87 for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:26 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:29052) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85k-0004CU-7Z for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:25 -0400 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 176MC34n023309; Fri, 6 Aug 2021 22:13:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=75zZ/yjfc+FBxgEI3tCsey3+RfhAFPqgNxlIO52HzAY=; b=CYvgj4KQN92gjsMPzHklftDBQwrcXQiNiGzPxvdiy6hLFfSL2tSu7pU09DfXnUyBGqy8 4zlXXVEUnRxlpqSY1Yk0HX1rFhx0PzKcohqXuVwJ9OIYmyawHxH80+k3jR1ghAI2mTuU rsd5wdRf3Ql6PUL9iC0t/TyFTHjZfmC6qGUxDMyTRu1JrqzqinZE+Xlm5ta4NZSCzv4j Mk7GikC6eJ94PTvG7COVTmoayhWUPGmxgJIoRMy/RvowQ58fx3A2R2bh/E8+lUCU4i0R PRhRZ2xR2yTiZl/la2LshacLvaNAKFOR6hsLP1a9I8fxc37YOxdrciI6U66YxnTC6YHA 6w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=75zZ/yjfc+FBxgEI3tCsey3+RfhAFPqgNxlIO52HzAY=; b=ea+HGRKZ8jHMZGcU6T4qf+HIEwoG/wNjoXKcZ/fuUIH7ocVG4LNtUSH9Hp07Fpcr68Vc GNvkjmUqvUGKONs1Ei9bHpdlVGHKrspc2xlT7DkVee81GWPggx3qMNq3TWtzsn0vKU3j wHS6GuKETRqq/Mp07WFny105AU04h3hECcYAtB2lIsQE+UeEh8qeTuYpcm/atRCr3l2O sdFEtPBraKG96TZPebLvSM8m2LWRa9Zr2rFkTg9dNWl6YJEu1OdBMRX2+orM55VlvChW E9wJW3ot1JXAldwcByI2vFgldEjtnvKGJD2wN+c7FutO1zTU9vcTZWn1EIOhHqUd8nyh ww== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3a8vy3t4xq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:18 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 176MBejb032608; Fri, 6 Aug 2021 22:13:16 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2172.outbound.protection.outlook.com [104.47.55.172]) by aserp3030.oracle.com with ESMTP id 3a78db75me-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TibgtvvXMYYw7iTjRlrmF8FJiVxoo2k+OhYE84t/61fYMwBS0K8iJQpaZK9AMAZKWbaFdeeRS1O43HLU+a+BGpHkl6++6CJMsZq6RuTwH3DOnS3uFkMXT7y9EU6XPSB5QpYZjGUC4DExzshuQNC7wUaYm1NjzSimuUdcRDdRgxZTgwsoU0ShtwA6HXB/FQUR2zBBMybCfO56rrI54oMyvFdFZucAeigY6tfVONPEtTBtApBnNdNuNZy95Ep2vI/FJ2UL1OeqNR6JyhPDcU1MLkYxAcXnydilYcSoZE85TLMenWZFq1H1G70VkIyaUbGhveUlIv2Vl3awS8fzneZlog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=75zZ/yjfc+FBxgEI3tCsey3+RfhAFPqgNxlIO52HzAY=; b=lZNE6Iw1cfQtBwcc0tYm+oAQhlQ0uAjVzigN0iaPlo+4/nLR3wSrSm6s0Se+SxHkG4ZvcrwNS5Z5ErVUzMtKppKRauE5jm0WIvcQfZH+LIWSDNUZfTIMsDnhTpZPEp1x2RtC+uRYfJgv0WYNEUJYeI7qFhJfJRkfL8Q8n85rHp38yOBtD/znldxAhUEk7qFc32DQzgPB5G+zRHA9Ys2ys2x/YsAMssIQt5aoO8hxFYFCw+Ppx1bRwzcibDDHr5e3BvYnyIUizuIvaWzqAjbgpNfDTPbzJ5isAKBoceJ1RD/DTogtkRxPCdaiz7GKY8QwcSrsibklgxzP2WVkf6tzpA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=75zZ/yjfc+FBxgEI3tCsey3+RfhAFPqgNxlIO52HzAY=; b=nxAjB78n+DRFidVRNzOjAs9TjEl/sPkKaMH5RvUFhSGCAyRrbltSgIyv5aNg6oMraS3+CPPsPsjd181mYe79Kxwg+nuxwljCgJbk6n10ParWMsRywUp7Q4ZIjRw6Q/K46+hyrWY+uDJH2oJVsghbBw3R1PuAkq9gLpJoZQ1hInc= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) by SJ0PR10MB4734.namprd10.prod.outlook.com (2603:10b6:a03:2d2::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.17; Fri, 6 Aug 2021 22:13:15 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3%5]) with mapi id 15.20.4373.028; Fri, 6 Aug 2021 22:13:15 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V6 12/27] vl: helper to request re-exec Date: Fri, 6 Aug 2021 14:43:46 -0700 Message-Id: <1628286241-217457-13-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> References: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) To BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ca-dev63.us.oracle.com (148.87.23.7) by SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Fri, 6 Aug 2021 22:13:13 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 81a811e6-386d-49cf-06c8-08d959276309 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4734: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:108; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: q+MpO8HO4VZL8Qi6kge9flT7z/yNg44oIFMmRX853/lRLx6sPzQAAFoQz6K8Q6SvXFCDfZ+SfZTNYIPGnYY4TTgPjv6+SNZJJpXXO1FT0ZbxWMylHFtilk1ZLd/hhaC7ql3W31weeKCZjWDWjvmW/p0vGXlfZ8qziC87OcitorB78BEOuhBPWbvyVRwoFQ33namUkURKWZlx8sYJ2iirT+lTjQnne2ZEtB80PcHHGY8r6D+qUrh9ur7s/rd7kQKXSlxUhE/UIrwZKhJrZK1wgofJFaH8vrl7NjhmjzX/4eXhV8nf7OvDE+vhZGqnC8NvBGu648sHdC2cblWbyE0JGxu5JSLoWv0clcyWaSRYVl0/j8x4+p9FlVoPN1S5sv/Ar3U7N2c+JTl5Nw99g4Jue5jXP7IgggGJTLBHXatbPx1fUOF7wWLELlFYD2S1YDFL5GKbR57v/2aqtU5GP4K8IdPCFxbV+wMEYS4UPWVtQE+I1b0DturUdqyBr1jFyZ6NHFksm7M0g3EeRYKaPO5eRhm62ynIDCD32UqgVqG/4PYGcBl4o6Ls0DjWVFcwYN/xeb22/IrkdyaArL9d9oYfkiN+9OTGjZU/ajN9h6j16otzF+F4khLiO535RgIJv33I4bUWn8yA298KKmVIUnrI/cwl7kVPQmKurBRjiiRjtrg80aLgclSnJYtCjV/Mc7g6putePWQUo1gX01U3nYEu6Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(396003)(376002)(136003)(366004)(346002)(66946007)(107886003)(66476007)(8936002)(86362001)(316002)(83380400001)(54906003)(8676002)(66556008)(4326008)(36756003)(956004)(6666004)(26005)(186003)(2616005)(478600001)(7416002)(6916009)(5660300002)(2906002)(52116002)(7696005)(38100700002)(38350700002)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Z4Pzlpuurjei3XzFkF3gUvHd/1lZf8slLdGMvxznSRrfwEobNvL0LcExarA8uoSnrEtE3d3BHbrPhxChOyBJUC4Q9wblga4ZRUO7l0LB1TFKMkUvwRIVzBgktu+fBVvLRzu+ykAY8Nnvxv7LPf6PjlcOdHoHYEpJGqcxGco3nrlFtjuIKHWsqfky2jv9ul49/f1+/WgZtiUrbo3eXPGkmwcbl2TArQ38a5eAMivRQdL/IpNc1BfrJVbh8+R0rXr2EojlnriXKCemdfcvtCcMfcl5gFiZa6qQsPeeUpQ9FzooUVcVmr5ViN4V9bFBCMmEJIwb29RV+6zVqAFq8HUBSfraj1roIom2/98xhcz9/+dGhfaltOx722WpgZw1O59fxs6b/qAGDKiW3PnETBZ0DtQKjHCvIP7JmZrYInfHr3wuIaUXdrUhcXDEbgqN9/S9UYerWyq15TALRRq4gQSJkH5lQAiQaVXDiRH9BmfAwervl2kJ+TohtjvApv/qMROMtR7ho+MPOidtl1AHgy6nWIxfE2xCRucHsrdexCSC0VoBYtRmCoHCPQi8Yc3q7egABOHD7lu4ChoNz2CGvBMVPPmUSHptm0uB2mreByhwz18HiOa4kRb3ajd9rEurHLHc5ksEfSK+DiOu5Jfm/qOXj02kAtkQbL3XSifjWwoxZ5XyMIMCeC9+xJHBl6PO9BdqnukWfB3luBo0SCKaskuD7LxVMS3ZZa3EvTonQFyE4rpEh7ikY5gRtFzMigA+rpXdRyvaWeDaBLkwAvNidkF9fPf/qEJcqEosw6r2JAas71WVAgKMdx1g123QhcAFNzfCLyS4cGFlh170K9Xv/AVZ6xhkEkcewyCoErJRnUC0z5wkxHyIGnT3NzzgZh2CNYLjkeJuhARlhrBDkWP32zreBsI6JlbRJgqnO8DksEtKLjzZXSrlQN0Z4vkGGvggxB54oOy74pPsbFVzTRbK8BvkDlgzVIOynrSq1tZEQA9s1x0cnELixBH0duttcmuHwohUuiZ1XDUak3xWVj9kt5bBNEHktqodjBJ6f9bdfXWfrJYjInqqozSbNhjr/cOJ8UAyq7S4gPRwuBbADvUZxd9ruHJqrgUaEEo8LdQcENc805/YxbSS7LCDLFYUeUgIom993tNWxFkReP50uNVU8i6Hylj+yQVABw/VTO7hls4eAPxiWXDe0wFSobdi1B61S8D3rMoOol7fnbPeQnOXRTIAYeb0RzqvPnQG64eFohZQU/Tqge6w9sCIoIbVoSzxQazUH1dXTUCiy4vWshI1sKPltGwE1ViaLOjOx1IvfUXSvtIMdHHt7sZ4vqmI5Xtd2zMk X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 81a811e6-386d-49cf-06c8-08d959276309 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2021 22:13:15.1277 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: cugwOKP+AXz2ifDB8lAdMkcFGey92jUFtKm55rDG6my3jq3YEKv7qEpOGWpwCUvRAytOnmg2wzB1qVwYYdU1jZpzTueW5snsVHEpt9QxowU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4734 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10068 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 adultscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108060145 X-Proofpoint-GUID: abwyZAdrL4PcAlP-ZdC448AhvHr8x5rf X-Proofpoint-ORIG-GUID: abwyZAdrL4PcAlP-ZdC448AhvHr8x5rf Received-SPF: pass client-ip=205.220.165.32; envelope-from=steven.sistare@oracle.com; helo=mx0a-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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , Jason Zeng , =?utf-8?q?Alex_Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Zheng Chuan , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add a qemu_system_exec_request() hook that causes the main loop to exit and re-exec qemu using the specified arguments. Signed-off-by: Steve Sistare --- include/sysemu/runstate.h | 1 + softmmu/runstate.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/include/sysemu/runstate.h b/include/sysemu/runstate.h index b655c7b..198211b 100644 --- a/include/sysemu/runstate.h +++ b/include/sysemu/runstate.h @@ -57,6 +57,7 @@ void qemu_system_wakeup_enable(WakeupReason reason, bool enabled); void qemu_register_wakeup_notifier(Notifier *notifier); void qemu_register_wakeup_support(void); void qemu_system_shutdown_request(ShutdownCause reason); +void qemu_system_exec_request(const strList *args); void qemu_system_powerdown_request(void); void qemu_register_powerdown_notifier(Notifier *notifier); void qemu_register_shutdown_notifier(Notifier *notifier); diff --git a/softmmu/runstate.c b/softmmu/runstate.c index 3d344c9..309a4bf 100644 --- a/softmmu/runstate.c +++ b/softmmu/runstate.c @@ -38,6 +38,7 @@ #include "monitor/monitor.h" #include "net/net.h" #include "net/vhost_net.h" +#include "qapi/util.h" #include "qapi/error.h" #include "qapi/qapi-commands-run-state.h" #include "qapi/qapi-events-run-state.h" @@ -355,6 +356,7 @@ static NotifierList wakeup_notifiers = static NotifierList shutdown_notifiers = NOTIFIER_LIST_INITIALIZER(shutdown_notifiers); static uint32_t wakeup_reason_mask = ~(1 << QEMU_WAKEUP_REASON_NONE); +static char **exec_argv; ShutdownCause qemu_shutdown_requested_get(void) { @@ -371,6 +373,11 @@ static int qemu_shutdown_requested(void) return qatomic_xchg(&shutdown_requested, SHUTDOWN_CAUSE_NONE); } +static int qemu_exec_requested(void) +{ + return exec_argv != NULL; +} + static void qemu_kill_report(void) { if (!qtest_driver() && shutdown_signal) { @@ -641,6 +648,13 @@ void qemu_system_shutdown_request(ShutdownCause reason) qemu_notify_event(); } +void qemu_system_exec_request(const strList *args) +{ + exec_argv = strv_from_strList(args); + shutdown_requested = 1; + qemu_notify_event(); +} + static void qemu_system_powerdown(void) { qapi_event_send_powerdown(); @@ -689,6 +703,13 @@ static bool main_loop_should_exit(void) } request = qemu_shutdown_requested(); if (request) { + + if (qemu_exec_requested()) { + execvp(exec_argv[0], exec_argv); + error_report("execvp %s failed: %s", exec_argv[0], strerror(errno)); + g_strfreev(exec_argv); + exec_argv = NULL; + } qemu_kill_report(); qemu_system_shutdown(request); if (shutdown_action == SHUTDOWN_ACTION_PAUSE) { From patchwork Fri Aug 6 21:43:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12423975 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1CB49C4338F for ; Fri, 6 Aug 2021 22:17:18 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 503FC61179 for ; Fri, 6 Aug 2021 22:17:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 503FC61179 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:59712 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mC89U-0008SJ-9m for qemu-devel@archiver.kernel.org; Fri, 06 Aug 2021 18:17:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47240) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85o-0007Kq-Aw for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:28 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:33188) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85l-0004E7-RB for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:28 -0400 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 176MB4xq029754; Fri, 6 Aug 2021 22:13:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=DkdxhPhVcs9eVeaL+YNGmWufhSD0Gu3Clef6v2P5ufY=; b=DAckRIhnlTouYsbN3LXt/PJF9xGnUyXXBtvQw5BSwLTz1mPHOK7TwBXmUR5iVeyzPKU0 pTYFYoAYkh+vqcwHXPPWOPKwBJdzWFKJR7YlP76IGAIeQWT5NXEV8i984xCvZZjKFmJP b941R6Rv7lg/RffcYVcasz7QQQGjRes2cz2op4iQbK1Qa9tFgY0k2mC8Bw1x39nrhvAZ qwtACu73SJCO4RVpux5O8HuQB0ZzaxIPgnNkR222YSWBXmX6kxMS/kG1GhTzIj2dfSh6 P9Oq50e3oZlfl5KzMLroN250cyFCCqigeJSrEsBcaLuVcBKGG+w6xJT6kYYweTqezNC8 xQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=DkdxhPhVcs9eVeaL+YNGmWufhSD0Gu3Clef6v2P5ufY=; b=QLV3r6TBUxUq1N3lQ2LFCSSIHtgrlQia2KjWvQ1LhbjCMK49L/Tv8FyjL9wywoSnUf6g Wqd0C6VfBD5ybeSHUSDnRhVBeV/Oe1w8fEsCY/IUmg/nntM7QOD39DjaBdiDU+Zg89lu TQzN3lw9fNNprb2QDC75k5PJcLH4yulDjodI05Mm4egzzNOsoo6M7uHyBvv+9RY5ePE7 +f3SdYlw4SGStez8aFswuFgOY4zuiAiTEIkEvR+7V2Zi4MAFLW/fA+cbUrIDuAQWR5DC vuHOP5wD3Upu70xwBDu8/rWB7XQBuR5Fu5r1uhyaU82eWW5GXP0999JdjZX8ray9Z38x uQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3a90justq8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:20 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 176MACDP083083; Fri, 6 Aug 2021 22:13:19 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2170.outbound.protection.outlook.com [104.47.55.170]) by aserp3020.oracle.com with ESMTP id 3a7r4cay1x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fATBhy4tZ9Hfg8X5wEDzrz5QcLFnnFOVAWY+e/HaLVnI7lHouh02lkJ7R8Qy/qFG7lF+cEDkSZeHx5MJHZcH81F3vuynOsCjzMSb+UBd9+AplaJQrucJa9qaRuIH+a8pBLl7V50+W3W8kHmgkiroJSkEl4xXCYJs6nAStBGFvlIOQJda79T4GZSt70zBX/fXOWNbD9+O5ZnqFftsyX5eyzYoPmHbjdFtlg9BcdXYIbmCKOlxomntrPMnDDxez6QgUhqVvKd04uFiam90QLTrV1EQfl3qjTOdTMs1C4y4t+VfOy426jZ5Nu/0gosUqcF2Ucbt+O+5fcn2lM0BAudDFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DkdxhPhVcs9eVeaL+YNGmWufhSD0Gu3Clef6v2P5ufY=; b=WUttEuW7wnmwHwfGYSpknr7WxJwEzLyc6eS1aCwECPLhJN41o/4W0ZCdLZEleF7Sb4bWJe8N3RrI1BxgDIuTbQt9PgB646MiXz1l/FMoAnkAXN5qZ4TjGKXftK4F6GeqIuBOkO5TpocxQk1PA8+Joo5kAPtipGoYjSH7PSRuYf4VjFE//sHsdnmN6cLgRAkHz3Y7avTKeqXxc7yBwb+F620TapZZcVbPWDNVSI7xLpm++HgLi1TTf+4UAa62Sy+Dcd+Mob/KPxRSiVk4jodD9NYzKwaPpPujaHRK0lmB9UGYhP4hloBUBUX/+ICHhb8baJaySOCJS0O75+zQ0rMJeQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DkdxhPhVcs9eVeaL+YNGmWufhSD0Gu3Clef6v2P5ufY=; b=dTYsnVY1ANpjfyQPEph/Rt+5I55ftUoRIV6VkCAqqBpKGWRUWtj1WTm6IDvdGYzu6B9Ss4kR9HCrrGyH5m7Y+o0rzUB5wSTI2cHb0Y3rJA8H4exFjenfypuFCu3YobDNNXCTUOmKpu9pjbgtsm7pAI+9OnipLTfPb3Kc+DzSBKQ= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) by SJ0PR10MB4734.namprd10.prod.outlook.com (2603:10b6:a03:2d2::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.17; Fri, 6 Aug 2021 22:13:17 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3%5]) with mapi id 15.20.4373.028; Fri, 6 Aug 2021 22:13:17 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V6 13/27] cpr: preserve extra state Date: Fri, 6 Aug 2021 14:43:47 -0700 Message-Id: <1628286241-217457-14-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> References: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) To BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ca-dev63.us.oracle.com (148.87.23.7) by SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Fri, 6 Aug 2021 22:13:15 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dfa75a1e-20e0-42b5-864e-08d95927642d X-MS-TrafficTypeDiagnostic: SJ0PR10MB4734: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:341; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: N+t6UxUL08ExNPvh+tt/hDl/NES45pOCH7WoYV9dYBeDrg4IfwVQg9vjQd1Tpb6iy1jk40yQl9+pR2759Op/DXb7SgfOHtHCyADB1Dh3mSX2lH+HeB6hd0pJ4xRqtujlIGLQThNKTo2Wk61hrfRMeXYnBybBwykxiqhdxEr6peOjWJ7I38NVinqyI5KnvOsVixJnBygai3JbGTIxHeL/sOOnwg5nfyqRzful0G9hCwhlMn21tryW5aLcc4MzJA8WfYTn/NINYbmAgVV9C3lx67NPIap0BDU3MU83yqW4d2/j7Lazw2cqNIN0Ry41erJxHyyZ6sKbgV22JGNvy+zKV+NN99unIbnWX0hURRsuAz6LocSNAmv2pRnwZcvmrsv9A4GZfDQp1bs9Bl8BPJJuxyCZwxi+f9Ct7d0ialM2pt6U7NH4R3ZlQnQAbY8g9oOr2L4XNlIQ+rjRy1UKKFkchfJvEP9LeQkdYEhh4a+c8achc14jciVmACDORTmQuvrdZDabegipSgYerCluvuH7VQh5uYhCzsUSEwo0RqgkWfT3CbS+e4kdBvcOtOYK8itZAGZ14Ew+KP4A0an7IJ4kFEQEoRYpxLv/pUNJ5cuVCwyiPise3JYXde8nTv3Dc9fo0nlP7fKyiKsw/fyIEWUmN78y87V5avSxzbRWu5VrZr2PyBW0DrTSRKyxethkiSCV6Q8A2LUWUW8Q209WgidGpw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(396003)(376002)(136003)(366004)(346002)(66946007)(107886003)(66476007)(8936002)(86362001)(316002)(83380400001)(54906003)(8676002)(66556008)(4326008)(36756003)(956004)(6666004)(26005)(186003)(2616005)(478600001)(7416002)(6916009)(5660300002)(2906002)(52116002)(7696005)(38100700002)(38350700002)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7DD6YB9OU4TkV6Uc8g81vihyrhSh09wrT+H6BMJwYuwHwZjEOY907XJdvu1OBH7HotIy8XgoJsu6w7geoERwazz7fbK4K0vW68Nk8oA0/pmASJT0sWOFn7HYqJ4HXAUfU7dJL8GZn8dsFw7957PBvr0n/7aw7K0fG2OZZ+KHI6sNikt99M4eId+EIARlUgXG7CdY/2jVjklsf0eEP+A2kBZQa87UEF5ZXr5DfMcn+6YJHiwgDfzLBk0yPoIVgwibryCY+btxSRuRqLOkZEzpnELC3nGMVf092JLgG+V7IDndUeJGh3Z66uiVKSpH1X41FUoYIouMdOAHfI6u8WeVOWVUVuEEz6ZwSwYPq24Lyuc5dskT8iPwjeEHFjihir3od0bHD6zZPgTnxWVC7cXKgwVomU7ZUpFcta6CnAVyT3RLnG5yKi2LhijQ1td3aTs8d2fGo/os3/+BOhYc1pEjGqKH31Vk279Vh71+632ezvOiaG8YEaalbfOII1ep3MefZCsKa8HTv+kUUtEDuD/KWpB64SKrKbwaBrHKCgKTMTmU+39wJkqusqIZN3V1GHIVmPlkHHyee8u26FunODf0yW/GO45aH9G1GXIfhtsktEUZs7ys92Zs5Y+32q79wljWjg3qilPmTkRQE/wmhpiWI/fz1b6XR8Y1XU8XLgM9TdwqWBD3Y9akBgTPziC5xztnoLuIt2BO2gm8nA+P6HoS4PBIXV7SwsqXOmyvBEmxOV7p3x2yu1yMObHgNFGDat0GXkx5311yBDVoecN+ydR27oIunWztF39LHpJtq2uzGZ5gY72DEvEBeEBzvJvmomA6dN7YfHt8SHFXodm06S/p/QML1l97exC7RIKs8l9BarpJRIkq415XFDFwtE64T3pqIey5/izZ68M5yjq6xO2gxNjFVSvSYk6BKORx6Q+DI2umZfYzOFD5xs6O/rquxfKt2+Mw3TfAvW3NKqULNzieGw3bVOWhQHeA+jeEXIwPlDbuz/tiMQPagwsD71tBUNndBk9Ae76BJv1Y6IxTP3rSbOFonsF3Eyo22aciI+wwDo5eYesFrCZkkOdkPo6XhLJBQsWX6xHiTE/y9JBon2NoL3SFwOMSG8KRqEEd5GOD2dp93tybInvX0a3mrK1avcUNIygXwnhV9hFiVMySW48TohU72875Ixuf0NsBipW5BPffQmXxW8GpoURQQC3yd1M7IxLqxSCo05cyhP72lnU8ZqJiL6vVukb3wcSO5of0kR/5uxiQSVSJBn2TFkBh3oA+gNKVz6iMJBpdLuX5KzqtJeuonVN8e13eAS8vTzTvg1fG9oSn7bYRMsvlqj8fAkc6 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: dfa75a1e-20e0-42b5-864e-08d95927642d X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2021 22:13:17.0226 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: spLePreo6wZHv52mVjiqjFqdDaD9mgL8L3jFtzF0JC9YAHUvnh1CXDVImp2Agwu1Zs79AFdu7QlVDfJ7dbikAJJgGf2LUuCaAWwRxkmC5uY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4734 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10068 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 adultscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108060145 X-Proofpoint-ORIG-GUID: aXpZJ59XJD3kjCUcocE51M4E7FB6C1Xj X-Proofpoint-GUID: aXpZJ59XJD3kjCUcocE51M4E7FB6C1Xj Received-SPF: pass client-ip=205.220.165.32; envelope-from=steven.sistare@oracle.com; helo=mx0a-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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , Jason Zeng , =?utf-8?q?Alex_Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Zheng Chuan , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" cpr must save state that is needed after qemu is restarted, when devices are realized. Thus the extra state cannot be saved in the cpr-load vmstate file, as objects must already exist before that file can be loaded. Instead, define auxilliary state structures and vmstate descriptions, not associated with any registered object, and serialize the aux state to a memfd file. Deserialize after qemu restarts, before devices are realized. Currently file descriptors comprise the only such state, but more could be added in the future. Signed-off-by: Steve Sistare --- MAINTAINERS | 2 + include/migration/cpr.h | 11 +++ migration/cpr-state.c | 215 ++++++++++++++++++++++++++++++++++++++++++++++++ migration/meson.build | 1 + migration/trace-events | 5 ++ stubs/cpr-state.c | 15 ++++ stubs/meson.build | 1 + 7 files changed, 250 insertions(+) create mode 100644 migration/cpr-state.c create mode 100644 stubs/cpr-state.c diff --git a/MAINTAINERS b/MAINTAINERS index 2611ca6..a9d2ed8 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2907,6 +2907,8 @@ S: Maintained F: include/migration/cpr.h F: migration/cpr.c F: qapi/cpr.json +F: migration/cpr-state.c +F: stubs/cpr-state.c Record/replay M: Pavel Dovgalyuk diff --git a/include/migration/cpr.h b/include/migration/cpr.h index a76429a..83f69c9 100644 --- a/include/migration/cpr.h +++ b/include/migration/cpr.h @@ -14,4 +14,15 @@ CprMode cpr_mode(void); +typedef int (*cpr_walk_fd_cb)(const char *name, int id, int fd, void *opaque); + +void cpr_save_fd(const char *name, int id, int fd); +void cpr_delete_fd(const char *name, int id); +int cpr_find_fd(const char *name, int id); +int cpr_walk_fd(cpr_walk_fd_cb cb, void *handle); +int cpr_state_save(Error **errp); +int cpr_state_load(Error **errp); +CprMode cpr_state_mode(void); +void cpr_state_print(void); + #endif diff --git a/migration/cpr-state.c b/migration/cpr-state.c new file mode 100644 index 0000000..003b449 --- /dev/null +++ b/migration/cpr-state.c @@ -0,0 +1,215 @@ +#include "qemu/osdep.h" +#include "qemu/cutils.h" +#include "qemu/queue.h" +#include "qemu/memfd.h" +#include "qapi/error.h" +#include "migration/vmstate.h" +#include "migration/cpr.h" +#include "migration/qemu-file.h" +#include "migration/qemu-file-channel.h" +#include "trace.h" + +/*************************************************************************/ +/* cpr state container for all information to be saved. */ + +typedef QLIST_HEAD(CprNameList, CprName) CprNameList; + +typedef struct CprState { + CprMode mode; + CprNameList fds; /* list of CprFd */ +} CprState; + +static CprState cpr_state; + +/*************************************************************************/ +/* Generic list of names. */ + +typedef struct CprName { + char *name; + unsigned int namelen; + int id; + QLIST_ENTRY(CprName) next; +} CprName; + +static const VMStateDescription vmstate_cpr_name = { + .name = "cpr name", + .version_id = 1, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_UINT32(namelen, CprName), + VMSTATE_VBUFFER_ALLOC_UINT32(name, CprName, 0, NULL, namelen), + VMSTATE_INT32(id, CprName), + VMSTATE_END_OF_LIST() + } +}; + +static void +add_name(CprNameList *head, const char *name, int id, CprName *elem) +{ + elem->name = g_strdup(name); + elem->namelen = strlen(name) + 1; + elem->id = id; + QLIST_INSERT_HEAD(head, elem, next); +} + +static CprName *find_name(CprNameList *head, const char *name, int id) +{ + CprName *elem; + + QLIST_FOREACH(elem, head, next) { + if (!strcmp(elem->name, name) && elem->id == id) { + return elem; + } + } + return NULL; +} + +static void delete_name(CprNameList *head, const char *name, int id) +{ + CprName *elem = find_name(head, name, id); + + if (elem) { + QLIST_REMOVE(elem, next); + g_free(elem->name); + g_free(elem); + } +} + +/****************************************************************************/ +/* Lists of named things. The first field of each entry must be a CprName. */ + +typedef struct CprFd { + CprName name; /* must be first */ + int fd; +} CprFd; + +static const VMStateDescription vmstate_cpr_fd = { + .name = "cpr fd", + .version_id = 1, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_STRUCT(name, CprFd, 1, vmstate_cpr_name, CprName), + VMSTATE_INT32(fd, CprFd), + VMSTATE_END_OF_LIST() + } +}; + +#define CPR_FD(elem) ((CprFd *)(elem)) +#define CPR_FD_FD(elem) (CPR_FD(elem)->fd) + +void cpr_save_fd(const char *name, int id, int fd) +{ + CprFd *elem = g_new0(CprFd, 1); + + trace_cpr_save_fd(name, id, fd); + elem->fd = fd; + add_name(&cpr_state.fds, name, id, &elem->name); +} + +void cpr_delete_fd(const char *name, int id) +{ + trace_cpr_delete_fd(name, id); + delete_name(&cpr_state.fds, name, id); +} + +int cpr_find_fd(const char *name, int id) +{ + CprName *elem = find_name(&cpr_state.fds, name, id); + int fd = elem ? CPR_FD_FD(elem) : -1; + + trace_cpr_find_fd(name, id, fd); + return fd; +} + +int cpr_walk_fd(cpr_walk_fd_cb cb, void *opaque) +{ + CprName *elem; + + QLIST_FOREACH(elem, &cpr_state.fds, next) { + if (cb(elem->name, elem->id, CPR_FD_FD(elem), opaque)) { + return 1; + } + } + return 0; +} + +/*************************************************************************/ +/* cpr state container interface and implementation. */ + +#define CPR_STATE_NAME "QEMU_CPR_STATE" + +static const VMStateDescription vmstate_cpr_state = { + .name = CPR_STATE_NAME, + .version_id = 1, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_UINT32(mode, CprState), + VMSTATE_QLIST_V(fds, CprState, 1, vmstate_cpr_fd, CprFd, name.next), + VMSTATE_END_OF_LIST() + } +}; + +int cpr_state_save(Error **errp) +{ + int ret, mfd; + QEMUFile *f; + char val[16]; + + mfd = memfd_create(CPR_STATE_NAME, 0); + if (mfd < 0) { + error_setg_errno(errp, errno, "memfd_create failed"); + return -1; + } + qemu_clear_cloexec(mfd); + f = qemu_fd_open(mfd, true, CPR_STATE_NAME); + + ret = vmstate_save_state(f, &vmstate_cpr_state, &cpr_state, 0); + if (ret) { + error_setg(errp, "vmstate_save_state error %d", ret); + return ret; + } + + /* Do not close f, as mfd must remain open. */ + qemu_fflush(f); + lseek(mfd, 0, SEEK_SET); + + /* Remember mfd for post-exec cpr_state_load */ + snprintf(val, sizeof(val), "%d", mfd); + g_setenv(CPR_STATE_NAME, val, 1); + + return 0; +} + +int cpr_state_load(Error **errp) +{ + int ret, mfd; + QEMUFile *f; + const char *val = g_getenv(CPR_STATE_NAME); + + if (!val) { + return 0; + } + g_unsetenv(CPR_STATE_NAME); + if (qemu_strtoi(val, NULL, 10, &mfd)) { + error_setg(errp, "Bad %s env value %s", CPR_STATE_NAME, val); + return 1; + } + f = qemu_fd_open(mfd, false, CPR_STATE_NAME); + ret = vmstate_load_state(f, &vmstate_cpr_state, &cpr_state, 1); + qemu_fclose(f); + return ret; +} + +CprMode cpr_state_mode(void) +{ + return cpr_state.mode; +} + +void cpr_state_print(void) +{ + CprName *elem; + + QLIST_FOREACH(elem, &cpr_state.fds, next) { + printf("%s %d : %d\n", elem->name, elem->id, CPR_FD_FD(elem)); + } +} diff --git a/migration/meson.build b/migration/meson.build index fd59281..b79d02c 100644 --- a/migration/meson.build +++ b/migration/meson.build @@ -16,6 +16,7 @@ softmmu_ss.add(files( 'colo-failover.c', 'colo.c', 'cpr.c', + 'cpr-state.c', 'exec.c', 'fd.c', 'global_state.c', diff --git a/migration/trace-events b/migration/trace-events index a1c0f03..e3149b6 100644 --- a/migration/trace-events +++ b/migration/trace-events @@ -310,6 +310,11 @@ colo_receive_message(const char *msg) "Receive '%s' message" # colo-failover.c colo_failover_set_state(const char *new_state) "new state %s" +# cpr-state.c +cpr_save_fd(const char *name, int id, int fd) "%s, id %d, fd %d" +cpr_delete_fd(const char *name, int id) "%s, id %d" +cpr_find_fd(const char *name, int id, int fd) "%s, id %d returns %d" + # block-dirty-bitmap.c send_bitmap_header_enter(void) "" send_bitmap_bits(uint32_t flags, uint64_t start_sector, uint32_t nr_sectors, uint64_t data_size) "flags: 0x%x, start_sector: %" PRIu64 ", nr_sectors: %" PRIu32 ", data_size: %" PRIu64 diff --git a/stubs/cpr-state.c b/stubs/cpr-state.c new file mode 100644 index 0000000..24a9057 --- /dev/null +++ b/stubs/cpr-state.c @@ -0,0 +1,15 @@ +#include "qemu/osdep.h" +#include "migration/cpr.h" + +void cpr_save_fd(const char *name, int id, int fd) +{ +} + +void cpr_delete_fd(const char *name, int id) +{ +} + +int cpr_find_fd(const char *name, int id) +{ + return -1; +} diff --git a/stubs/meson.build b/stubs/meson.build index d3fa864..2748508 100644 --- a/stubs/meson.build +++ b/stubs/meson.build @@ -5,6 +5,7 @@ stub_ss.add(files('blk-exp-close-all.c')) stub_ss.add(files('blockdev-close-all-bdrv-states.c')) stub_ss.add(files('change-state-handler.c')) stub_ss.add(files('cmos.c')) +stub_ss.add(files('cpr-state.c')) stub_ss.add(files('cpu-get-clock.c')) stub_ss.add(files('cpus-get-virtual-clock.c')) stub_ss.add(files('qemu-timer-notify-cb.c')) From patchwork Fri Aug 6 21:43:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12423997 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06A30C4338F for ; Fri, 6 Aug 2021 22:24:05 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 43A8561050 for ; Fri, 6 Aug 2021 22:24:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 43A8561050 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:56858 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mC8G3-0000Ck-95 for qemu-devel@archiver.kernel.org; Fri, 06 Aug 2021 18:24:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47250) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85p-0007OJ-Fu for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:29 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:35294) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85n-0004Ew-7o for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:29 -0400 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 176MC34p023309; Fri, 6 Aug 2021 22:13:22 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=HtPJgQ3FM5PygFIityiYckiHpJusSRipyU6Efojp/Po=; b=YcdvHRcHYXRrrDx9J0r8toTheOgGZKwoTpwjTWsxky3h8Wq6CL71MTi6nG8FVgAXndoV NEUTItz5nIqBS3N1MdC9zNy7WYN6BbDZk6pJ1g5cGaaB+LUuP2dNdPP2xDY3AXlhP9sa Gnn6U9LXRD9XCypMMEVD5uzux4awLYC/KcHAv1P5Q6hFtRRApLzaNgPt7vcwC8yQPsen WTJBYhXfTyrA8l/ILa1Av3X3e3DbhmVyRurYz4QM7k1GxKxiqjLO6y6XWTVhX/Xp+2nW uZxNNCyfJkegMf2T7aYm/1r67CkMDNsQDOobrzb9H1LWvmCrWc0M1xcCJOaWW8d2Dwg6 ig== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=HtPJgQ3FM5PygFIityiYckiHpJusSRipyU6Efojp/Po=; b=O/qluE/gchZqt3s1Vj5hQUWSDJk0SO98X4DgebuJhoLgZL+ybUijgMoUaAEtLBg7BRH0 hpA+HseANgryy/XNWMy1BDwzsdJvM2+c73Swn2ii9ieVx0ns+ZYUa8yznSgCxlZfWqUL P+1vIsxAlSMDf67bG/TItgvOx4v4Baffbuo3MdjlMw/JIzDxRUWgus8CNtw6gK0fxHDf LGvWEFtoQxNcH/u8HCJVAfcTrPDHbcVIc6gOufRK+fXL0VY1qt2wb1aK+EKNNjM32vMi gpZQZzo5JYoflcTQHGYVRq56fy5EPSAU+hr4AzSIGnbf83shNYIJU8SQk6kU9n7IlulH 0Q== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3a8vy3t4xv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:21 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 176MAC88083053; Fri, 6 Aug 2021 22:13:20 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2177.outbound.protection.outlook.com [104.47.57.177]) by aserp3020.oracle.com with ESMTP id 3a7r4cay2k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KBezYn0FPOeIDEvyoJaXF+G1CeuuFbOAfaNDjktuLa3BBKc4d2QZ30y94mIL8otpi42jH6uN1boR3jQDavWf7iQsgAEDlO4VCIvdsyp1VB5TlOEhByAHc8TIObxeESJhUbnmt4l7n5jzx3tqKWTgMlA56ZYWluXya5bACxvYDjr8etyxPQ4DQkB1bsj0N9olR0dvJ0r/87vE/TpKSOdo+j/a9+CP1xGSDPFsh75fXa1qQ4tisucO7MRU7mdRQnDMx0jP1pTvsM7/qp0K8RkRncpgUDTX/BMX+ioO2HR47hTMHoax4bHSo7Qlandm33726TwrY6Ro9LZE+yLNjvR6Ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HtPJgQ3FM5PygFIityiYckiHpJusSRipyU6Efojp/Po=; b=RIYjW0r6PkAo6twjLfGRp26wtAfa3OCqQiUTJV27ATXUCw8KOn8L3e7RhT6Y5V/vWF584g28+rL+dx2aFFVP9Z7UV0udghL0Z3IFPI8y4zKSGOPMgUjLAZXwnDbpLY+QDUoJ4/J2CUl7D8XIoh9TEasRlCyVSozTS5C8ICWa2nCyCcTTN/nwq7+uu4/1eJKJXrNgNCl+PI5u6LDkdCuEM8NJLYNOC2t/oUbOXuYy8GrDoUBIPlMp8dhXv0HGRK0NffbujhdTVRCNeuGJQf4135Z5uZ1f6X2IDDXFzW0cOhypflpyeCdOZ+dM3/pp/f0DlpDsSGL0Mb5RMYcMNdrc4g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HtPJgQ3FM5PygFIityiYckiHpJusSRipyU6Efojp/Po=; b=zo/KRn839Ie/MzzrFjvWLImcZlqwJeEA6Bv33EBzDtOZvqYZjuNtlUgYmNh01PRUvS5tCakjtiBZthU4XLOb+OYMa340WRxab6CUzeKb8dbt/W3OwEvS4M6EdXbUg0YuHplstgwJ7uijwXqyhRfa8IVtDxr0baYT0KNWPlVNVNY= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) by BY5PR10MB4129.namprd10.prod.outlook.com (2603:10b6:a03:210::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.17; Fri, 6 Aug 2021 22:13:19 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3%5]) with mapi id 15.20.4373.028; Fri, 6 Aug 2021 22:13:19 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V6 14/27] cpr: restart mode Date: Fri, 6 Aug 2021 14:43:48 -0700 Message-Id: <1628286241-217457-15-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> References: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) To BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ca-dev63.us.oracle.com (148.87.23.7) by SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Fri, 6 Aug 2021 22:13:17 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 63e54238-d7e4-4262-500f-08d95927654b X-MS-TrafficTypeDiagnostic: BY5PR10MB4129: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: n6bsG4o3PHe+57ufsiHi0Z2SXL2ARtDDC0KDG+ORlV4qBaB5DyHmbmCYpfSXdGV35IrwUVqwVFPsw8EqRTCfjAS7n7lbKrbdDQBnDG8t8D6QdYwoaIUr47kxNOvLAT4/nKoh6TjldCFx4sr22gODbqF08IV+vh14KYjElQVFN334tBu9pPj7Ocq84XjTSR9G6vJJYXVVKtyGdWUYPpAycmlwx4b4RcO5ZhICUmAouMwgRHjKxY2QtAvnvTiZPrtp8aRS4Kmb0QWLqTXYgac0TQJn8U1EfQ/NYrOzu+jVx2qyOriSpjrG+4h33LAfis3CiptFuM9L0XaemcpCG3IJYAlO6dJeDuwo/4LsaBmA1WtNRE491MG6gu77wZ7dOAGNZGT26SBXW/jxjwVJhwbwp0TgK51GlCOAXbv5IfDLbp8gM9mHKYgceRH8CnfGdLQieFrYb+oahzO+oXetb6eNVFac8U9ANZjIMcUdqNIxP5drjRduEdbrOX6r3VafRx7AHmytlmNl7oi0q7Tug7DKNIL2sWFuR2xCl+Tl9W0abQb0/lYve324A7eEVXZj/BSBCkx3bf+JcO37QCzJpjrXDxj8bJHLu+pE/kj5UBdMja8OooJW0GXBQRE/ZcWsXSK7RSLtFhrhPJ6Gz6Xb9z1UAXBdO1bzLrd7HDqU78OhqHb/3QPylFC+VmcM70qu3QRZ27QGhNDMxfo7veMngxkzKQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(396003)(39860400002)(366004)(346002)(376002)(66946007)(66556008)(956004)(2616005)(316002)(7416002)(38350700002)(8936002)(478600001)(66476007)(36756003)(86362001)(38100700002)(5660300002)(54906003)(8676002)(4326008)(6486002)(7696005)(52116002)(186003)(2906002)(6666004)(107886003)(6916009)(26005)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tThxw+tTpwfyMdNwK1Xvme7a82ete1ZAihJVexUjAoqXdNX/oMcaHNIYDE3NOuhshJulCYLuiLzu5o9LRv17kK1JMl4AgVSW6c7khrVZqdJ1uLuPzRZfIgUKg2Jrxr4NTxyXeKmeeEw+2UqC4CZSmBZ7bQGq2aqgZgosrMG96t8PZmxG03bhHw7Ent9LByTmOo+UKv7kp/hYgGuAMxu3nnopd+XnGpNkUQpyJ4aoacl7ao91dMcr+caAwCTbEg/zrarTzfOloGBwojTVMO4vrFWL4ZupbnVCXEt1jlV6jtY3nkRseiO8DBdWAJEZWVPRrXvzmf0ylYaou9yVKtHH4ZwVoNIh86fwv+8LTq88/8pQ4GvEuvRu9e3QN4rhUU11EBMT43zJpZstOInbOzGVvoK6CGtI/M35W7EJJaBd7BNMjfDVkTK6xWQrdMRW7b6gyw++/kahcblpZLstttawmrMyA54WICrQA4fEZKqnwc7OPzgkEktAY043fugH0hLFPWPegAvLbG9kRPW83ywukr9WTz04Hi1QkbhgU7xW4pjBvI2x/x7JO1kN0bxVtkXIbpzgR/CKVchd0bicb1T4Dn1WVz2dbNRIgHlYXYznPSzH6XBARNisRVKVHJ3EE7PW9qWd84xxdEN2rGozxAH1WGIfShQ5J4eo+0GdQSlvgOe8ks41iEgI9O9hCmKP2S0DdRGIpeJ4abivnX3epUyu7/isleP6Tz+eF3v18nb2jouMbBZ/HLzTqzCHYZdvTzlFrVybZuqjZud+pQ36U490v5mCWlYsGv+cpsr+6/b+cETDycH9KKK8FdCscIDHrJWLQzN3O50EWlTXUtv5wOdCAQYVDCQ/J8goyvtDimkELW4wQ7h6D+jQnP4MvCY0G1V/E6ubmLmRWX7FY6Qdv2VU0WKC+nDgz2EKGETpChISSx/hbcV20g/xGizHF7zADfv7R5N0E9u4kh1IlIeTtn2VcUAirnVi82up7V2PuCqFNiwtrBvflH8GhxGjd4yewxEcL1lmHtfhCpbELkR7rrAU8cdRUG7EI4PjB1ymQ6oCe/6bAM1TsY0YQfwZWLXfmuvadyL0N5TzMJqwTF2fOpgXkVcPKUr72XgdmjVqcBqhRtCpr7LBxfnrga9ckEjCgV+FRkDpreHH5GAaVj2hrz4mSKNA8igU3/1YteSEZBdBu7L/SDFL6/J5bqlM9AA/fhBc/O33LrulZfhmOm9mhNOwbSKREthDZGNBZt6+lB+PWjbPjAT0/+oScInZO1CmYQ9aBjINbvd1tdIi3bMDnPe52N3+B9mmKEOogOKUIQIx96pIrHx6LidAeD9jaepS5rGa X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 63e54238-d7e4-4262-500f-08d95927654b X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2021 22:13:18.9296 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Oolj5C1h2NrY7K4SZi0bh449hFg5UTmRbVYoA6tpvvyeYT8a/4k2zeIBFV6MlWevh8HlFgv4h1Gt4MgrIgLGJ/c71YuD4oddEHtO4B2sjPs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4129 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10068 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 adultscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108060145 X-Proofpoint-GUID: kGLwqOz0exBIOMa4Dg5INsLxUQopPTzw X-Proofpoint-ORIG-GUID: kGLwqOz0exBIOMa4Dg5INsLxUQopPTzw Received-SPF: pass client-ip=205.220.165.32; envelope-from=steven.sistare@oracle.com; helo=mx0a-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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , Jason Zeng , =?utf-8?q?Alex_Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Zheng Chuan , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Provide the cpr-save restart mode, which preserves the guest VM across a restart of the qemu process. After cpr-save, the caller passes qemu command-line arguments to cpr-exec, which directly exec's the new qemu binary. The arguments must include -S so new qemu starts in a paused state. The caller resumes the guest by calling cpr-load. To use the restart mode, all guest RAM objects must be shared. The share=on property is required for memory created with an explicit -object option. The memfd-alloc machine property is required for memory that is implicitly created. The memfd values are saved in special cpr state which is retrieved after exec, and are kept open across exec, after which they are retrieved and re-mmap'd. Hence guest RAM is preserved in place, albeit with new virtual addresses in the qemu process. The restart mode supports vfio devices and explicit memory-backend-memfd objects in subsequent patches. cpr-exec syntax: { 'command': 'cpr-exec', 'data': { 'argv': [ 'str' ] } } Add the restart mode: { 'enum': 'CprMode', 'data': [ 'reboot', 'restart' ] } Signed-off-by: Steve Sistare --- migration/cpr.c | 30 +++++++++++++++++++++++++++++- qapi/cpr.json | 22 +++++++++++++++++++++- softmmu/physmem.c | 5 ++++- softmmu/vl.c | 3 +++ 4 files changed, 57 insertions(+), 3 deletions(-) diff --git a/migration/cpr.c b/migration/cpr.c index 1ec903f..72a5f4b 100644 --- a/migration/cpr.c +++ b/migration/cpr.c @@ -88,6 +88,34 @@ err: cpr_active_mode = CPR_MODE_NONE; } +static int preserve_fd(const char *name, int id, int fd, void *opaque) +{ + qemu_clear_cloexec(fd); + return 0; +} + +void qmp_cpr_exec(strList *args, Error **errp) +{ + if (xen_enabled()) { + error_setg(errp, "xen does not support cpr-exec"); + return; + } + if (!runstate_check(RUN_STATE_SAVE_VM)) { + error_setg(errp, "runstate is not save-vm"); + return; + } + if (cpr_active_mode != CPR_MODE_RESTART) { + error_setg(errp, "cpr-exec requires cpr-save with restart mode"); + return; + } + + cpr_walk_fd(preserve_fd, 0); + if (cpr_state_save(errp)) { + return; + } + qemu_system_exec_request(args); +} + void qmp_cpr_load(const char *filename, Error **errp) { QEMUFile *f; @@ -111,7 +139,7 @@ void qmp_cpr_load(const char *filename, Error **errp) return; } - cpr_active_mode = CPR_MODE_REBOOT; /* generalized in a later patch */ + cpr_active_mode = cpr_state_mode(); ret = qemu_load_device_state(f); qemu_fclose(f); diff --git a/qapi/cpr.json b/qapi/cpr.json index 2edd08e..56be0e5 100644 --- a/qapi/cpr.json +++ b/qapi/cpr.json @@ -15,11 +15,12 @@ # @CprMode: # # @reboot: checkpoint can be cpr-load'ed after a host kexec reboot. +# @restart: checkpoint can be cpr-load'ed after restarting qemu. # # Since: 6.2 ## { 'enum': 'CprMode', - 'data': [ 'reboot' ] } + 'data': [ 'reboot', 'restart' ] } ## # @cpr-save: @@ -33,6 +34,11 @@ # For reboot mode, all guest RAM objects must be non-volatile across reboot, # and created with the share=on parameter. # +# For restart mode, all guest RAM objects must be shared. The share=on +# property is required for memory created with an explicit -object option, +# and the memfd-alloc machine property is required for memory that is +# implicitly created. +# # @filename: name of checkpoint file # @mode: @CprMode mode # @@ -43,6 +49,20 @@ 'mode': 'CprMode' } } ## +# @cpr-exec: +# +# exec() a command and replace the qemu process. The PID remains the same. +# @argv[0] should be the path of a new qemu binary, or a prefix command that +# in turn exec's the new qemu binary. Must be called after cpr-save restart. +# +# @argv: arguments to be passed to exec(). +# +# Since: 6.2 +## +{ 'command': 'cpr-exec', + 'data': { 'argv': [ 'str' ] } } + +## # @cpr-load: # # Start virtual machine from checkpoint file that was created earlier using diff --git a/softmmu/physmem.c b/softmmu/physmem.c index d11455f..2e14314 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -65,6 +65,7 @@ #include "qemu/pmem.h" +#include "migration/cpr.h" #include "migration/vmstate.h" #include "qemu/range.h" @@ -1987,7 +1988,7 @@ static void ram_block_add(RAMBlock *new_block, Error **errp) name = memory_region_name(mr); if (ms->memfd_alloc) { Object *parent = &mr->parent_obj; - int mfd = -1; /* placeholder until next patch */ + int mfd = cpr_find_fd(name, 0); mr->align = QEMU_VMALLOC_ALIGN; if (mfd < 0) { mfd = qemu_memfd_create(name, maxlen + mr->align, @@ -1995,6 +1996,7 @@ static void ram_block_add(RAMBlock *new_block, Error **errp) if (mfd < 0) { return; } + cpr_save_fd(name, 0, mfd); } qemu_set_cloexec(mfd); /* The memory backend already set its desired flags. */ @@ -2251,6 +2253,7 @@ void qemu_ram_free(RAMBlock *block) } qemu_mutex_lock_ramlist(); + cpr_delete_fd(memory_region_name(block->mr), 0); QLIST_REMOVE_RCU(block, next); ram_list.mru_block = NULL; /* Write list before version */ diff --git a/softmmu/vl.c b/softmmu/vl.c index cb72ca2..924e8f9 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -76,6 +76,7 @@ #include "hw/i386/pc.h" #include "migration/misc.h" #include "migration/snapshot.h" +#include "migration/cpr.h" #include "sysemu/tpm.h" #include "sysemu/dma.h" #include "hw/audio/soundhw.h" @@ -3614,6 +3615,8 @@ void qemu_init(int argc, char **argv, char **envp) qemu_validate_options(machine_opts_dict); qemu_process_sugar_options(); + cpr_state_load(&error_fatal); + /* * These options affect everything else and should be processed * before daemonizing. From patchwork Fri Aug 6 21:43:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12424009 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9996BC4338F for ; Fri, 6 Aug 2021 22:26:24 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D718C60720 for ; Fri, 6 Aug 2021 22:26:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D718C60720 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:36446 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mC8II-0005XT-OQ for qemu-devel@archiver.kernel.org; Fri, 06 Aug 2021 18:26:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47268) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85r-0007UO-EV for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:31 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:34466) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85p-0004Gx-CK for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:31 -0400 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 176MAeTU021384; Fri, 6 Aug 2021 22:13:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=ZZndjaYMVMsu5cSny0e//bgpuCg91ravSz/nJI9JG5g=; b=elICUs+nD2WVd6OSKONsnVcU39Lt5Acg9GSTwMeTZSZnMEOaxXBh2OUMhQYagexGTRIT p1BBR7ADgrsYL7RloWFORhDV2oBg0iwAKdMJ64FVgwLiH73XmoC+JaTxfJlPUwm1iIO/ /u2CgHzqTiuSKGFgr3wQ49UyesJuXp8E+gF/oO0i+eKNFyDyb5rmIhNy2HrUqgQGUbiK HUiZfgf0rpkOZQOpVnO+2lp99ETJWz0ieeQWo7Muy1uXKIRWk4o28+LFz81AG0oRPESh ZxIcZr4dJffLYIKwDJP1GGrMyP0x8221yYnhG38t+eaxRSfQ9FEUOuIYlwJh815G4DBz NQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=ZZndjaYMVMsu5cSny0e//bgpuCg91ravSz/nJI9JG5g=; b=knZU6m0IJobt4Ioz4LWl4luE+V41084UIgKII8DUwwfl8sxga85DgQGUeRIqBlI4Tu1o GsGMz5j3T9no8CKTjj7JQBkUqRBqeglpad4bdkbTRP8aUr+4yDEktEwBvLtceb3hLEM8 iAPTuj3UGuGgaekDfdzQLlARGH6BlFFL0/hMqD1RmyrkTMaLdFrMGbpLjSU/0DMUl+Px Du18fUiLYTCHQAvZqKHdIlTi+IueBk1Jaqwg7eZoH94XJavJlxrx0Mg01HbddVywyGo4 cvuda66gauY2ZnV3O57am/PzSpLVtUqwxG8tzTbIL8Ob7WiOWiUGmguwcxmyJmZttWhK ig== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3a97hqgrn0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:23 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 176MBkbb013964; Fri, 6 Aug 2021 22:13:22 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2175.outbound.protection.outlook.com [104.47.57.175]) by userp3030.oracle.com with ESMTP id 3a962pfb15-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N05oVYABYSbjtd519fujyikHfLq07rrUyWfkAbC07/ohm2Zk2KEbp8SdmUJR058k8yiRvByqT4ogd/JOYqX0pfnwm8CYyYiqnRHvhWxC7G0HxNLTKP8D0q5pZ607fRQ7o6r0hGddNC+rml+QQt/3JSH+RXQM05bNHPYr8LnLhEtqTpYiVdw1Vjn2ONdAfIl4f5edsMkfLpPVeql8NY57PMBFUXO28KR7zXnpry7xG1kvAJDD7eu/AjssflDv4j1gDZvHBvVIb1C7y6LFt2i5PZ0fwrLFsVabp/WZPPjdKA3Ay0FfD5GmbRUOoXRspiZeO/wVHjY4UMCcxjrP4lGBKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZZndjaYMVMsu5cSny0e//bgpuCg91ravSz/nJI9JG5g=; b=HFyy/6ZHlH+2Diged361G9bnc6u+ws6S50W2SeLDXnaxjUU6hU02Gq1K8NSye/KbPjOi9hgi7kJMmHM8wTSPbzFm6eSyrUE4k2LNTwcWBJIAM45Ipq8rrMZJxAGeO7VWFzAfFbEWXJf3EU6DMEDfDjtlcno9OrkWOWN5yBnYfjoHLJndgKdv8655y7YbX7wV4uX8KtOWs2rwXXxuGqkl2lrybYinDBa6OFXQBb2COf51xfY12wYu0LwusieNHEjGU0nqWftUBfP7+8wtVe/RfV5a/dZOA7GvwXEpJekV3Tp5fw5X2X4XRTc8FUXTkh5rHtUzR/UONiEixsB7QDv1nw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZZndjaYMVMsu5cSny0e//bgpuCg91ravSz/nJI9JG5g=; b=WwcR4eRzVO30rZY3KNm9RMTXbfdp9RfNNPmRcKqxprV+4OKeXEf/5YZLjaA8PBSg/xknJNDsWS5o2Te9cmmP9haddikruRmruNbUYsZcx7ZIidQwFQo0qrWWO+GvPaYWyLMYyH3yNE7uz2jrfa67Cn2Bsd5ysJRMuDO05hcT0RE= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) by BY5PR10MB4129.namprd10.prod.outlook.com (2603:10b6:a03:210::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.17; Fri, 6 Aug 2021 22:13:20 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3%5]) with mapi id 15.20.4373.028; Fri, 6 Aug 2021 22:13:20 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V6 15/27] cpr: restart HMP interfaces Date: Fri, 6 Aug 2021 14:43:49 -0700 Message-Id: <1628286241-217457-16-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> References: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) To BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ca-dev63.us.oracle.com (148.87.23.7) by SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Fri, 6 Aug 2021 22:13:19 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b534eb10-3f14-47a9-2b14-08d95927666a X-MS-TrafficTypeDiagnostic: BY5PR10MB4129: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:346; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7SLG17ujWKK7LdAbl0rFFMP6EvR54Q9Nz93Swmzd35pato9ML7Fxx6HLjfVVcwYKo2VvkXvr3D+kpeGUQxGGlRe9nH73TwCVT1AhpPtl8eCYXuKvvzsX1s6JZqPWsky26KC/1IGse6pPlY51mTOhEjwcsbdnfiwV/3nxRXArgbEhenVUaDqFTdnnsFCncpfpegliFMmeGXv9UD8DLx8qIR+fjMc8bH92IqiFWrtmNPG1+wdBVeCEIJP4z1ASivPN6I5gP2jrq7Iem1ZxYnydhwzttgHaiTOAz0Yi9evqOEJtxKE1o2Jv7/yJG8zm0CPBt/scJsFNCDMSfo3xyXHUWBEbjRAYbiKCqpWeR8hZ5Ylnb/QeU6PxXIBsLA1VLgvvCin1099VYyT7Y/gP5x829ifRlGlTrV/7GDdlgTTlqFLyLpug276uYzy7iS9sM23l/mWw11TnR1ayrP/G3jXwGRxoBLdGL2lb1FlRhNpthP++PKxvoP/OiK3f4yg0U0LRQMUxQ2YKjmHAfrYvFTSah/d7QP4CIKlkYC1c8muvBJ1ADwUTOMItux0KVcw3PcMHORZ9uQuE+M9q9nNKVxf6BR/l90HMqeXOW43uFPIHTcJWi3PpG9oqDmD2ectKWmZpOXkpemR3zi4U6CaDd5zm7WI9msD4/K4d+IlBnSOslffIirJ//tQKsb7p/eldPvwfeS51Q/w6W3LmqfHKAficHg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(396003)(39860400002)(366004)(346002)(376002)(66946007)(66556008)(956004)(2616005)(316002)(7416002)(38350700002)(8936002)(478600001)(66476007)(36756003)(86362001)(38100700002)(5660300002)(54906003)(8676002)(4326008)(6486002)(7696005)(52116002)(186003)(2906002)(6666004)(107886003)(6916009)(26005)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ahKN960MdJK38/AgeM/LUg8QL5ydHY6xYspkjh65n0Ajn1vdwEwhxkCduyJ5wbERl6UNIWppQzWUGDUmpATv9xVeAY7uX6Lfp4yYYKbANTI5xinQ417rTD3dLOfLdrprtWq7k9i/H8QRr9RQDV1JWRyV4aYMvbrl23+zIuH7OCuD4xVGUuuu+gdMVxp+QKjxLCeftwc+Pyzi+oOAGRi2z40v3ngeYjyv57boH8sG8D6dXdimTWS4+1GNZL/gudlRDRSfFd2RqDs1opVE82ozhXInOjC1PdHFyoXhBbgOBKeCiWUPM40L3Pc0h9XRccIeqpE3v/nvu7LP0vK4061H9kpnzmBRbBxkAndW8nUR//Kf1xU9ANeGs9GzPXqR3gqFQ2bCgQba3nMnRmnI1TmLM1qRg2MSEdTI9eFldIF/Rtk0/5sOx5/PXjwncc2GZFqdvsdPAo9fbq+X9c5FVh/o2rsWU/1+5rLYhOMyAvPACajER30rgLa3uhEEXccuQ9IbcNVl8ivJH5yCUMUggganHQbg2QapSzD5k5133aE6Q84bqrZ6zoeSGAiHAwGgniRu6SxTeKmoqDw1R335fkzdFvORrilxZtR7cybMnrnvtFIMtK0k2FRkJkwIXTSRD8EexusJVbfKQ8EGccd6rVGobvQEwbmJvYMTmpmDxGROcndU08lNOFb99oXqIRipacdte6XMqZafP76VGLHMbtBZbfDfFurZh5FeQSVPKGl2IvKwlhqBm71McVEZR+k1n2XI9AL2o7QJjrcEA0Q8CIsaAlxp5iCcyOBHxxxLEvCT38WhoaD0PhdX0Xc4/U9IH0R0nA3BauCDQzrB4gcYxt78mjkVbOzosQ/3rjdshl5/PUdGemxiynkWjr4nrpf4gya714xXF1D9aR27JfKCqTbpHiOjPqaoV+TE4txj8xy7DMXtx1SoRFzdBGoQH4n7xuqsgGn1rOrthFFnLVfnTeYH7Trf3mzGq09MJ/ElSf1Te7X6v5grGTGDdjux3aZlUYAiu98xle806ivrTVi80DW301VBP0RS6OlQWQYo0AxExxSm9NZMxzAPxOYd58d5BiZVkSVqBPbZ8NSB5gu/t5tx2iYSGbSMH3dGac7G7Cb0x/K38Hft47pVPPa/10o6BNoZqaZz9h92YgpCJxwtd6s1+qEgwjcSs78aZxn8kYaXz4QRlBOaMwqZEX78PT0hWDx8u7krmMC9JE2ryZQ8++Y2/WzFuDfydKy8MmlxAcstIDFBRCCc8eZB7/Xo3RQ4xPPIVvcSalF/PnnVEqqbgkrey6aUicaTiD+I2Wk5wMc34iBjzTT0BcnHjq7vXzq6qNN2 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b534eb10-3f14-47a9-2b14-08d95927666a X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2021 22:13:20.7735 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2QfqOZ4dnBNGsaemsMDCgKikuV3pGju/faj/CyGS4WYZJOkogKpej3B2iKRADpYdnuhPxZY7LVm+3FC6Aekb+qFnM+2BUcsXYZ+BIE1QEmE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4129 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10068 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 phishscore=0 bulkscore=0 adultscore=0 suspectscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108060145 X-Proofpoint-ORIG-GUID: keKUdeGmSBnMHQhiwn1LA6zy8D2xzK0P X-Proofpoint-GUID: keKUdeGmSBnMHQhiwn1LA6zy8D2xzK0P 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , Jason Zeng , =?utf-8?q?Alex_Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Zheng Chuan , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" cpr-save mode may be "restart" cpr-exec Call qmp_cpr_exec(). Arguments: command : command line to execute, with space-separated arguments Signed-off-by: Steve Sistare --- hmp-commands.hx | 21 ++++++++++++++++++++- include/monitor/hmp.h | 1 + monitor/hmp-cmds.c | 11 +++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index 0a45c59..9541871 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -353,7 +353,7 @@ ERST { .name = "cpr-save", .args_type = "filename:s,mode:s", - .params = "filename 'reboot'", + .params = "filename 'reboot'|'restart'", .help = "create a checkpoint of the VM in file", .cmd = hmp_cpr_save, }, @@ -366,6 +366,25 @@ If *mode* is 'reboot', the checkpoint remains valid after a host kexec reboot, and guest ram must be backed by persistent shared memory. To resume from the checkpoint, issue the quit command, reboot the system, and issue the cpr-load command. + +If *mode* is 'restart', the checkpoint remains valid after restarting qemu +using a subsequent cpr-exec. All guest RAM objects must be shared. The +share=on property is required for memory created with an explicit -object +option, and the memfd-alloc machine property is required for memory that is +implicitly created. To resume from the checkpoint, issue the cpr-load command. +ERST + + { + .name = "cpr-exec", + .args_type = "command:S", + .params = "command", + .help = "Restart qemu by directly exec'ing command", + .cmd = hmp_cpr_exec, + }, + +SRST +``cpr-exec`` *command* +Restart qemu by directly exec'ing *command*, replacing the qemu process. ERST { diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h index 01b5df8..90f18fd 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -59,6 +59,7 @@ void hmp_loadvm(Monitor *mon, const QDict *qdict); void hmp_savevm(Monitor *mon, const QDict *qdict); void hmp_delvm(Monitor *mon, const QDict *qdict); void hmp_cpr_save(Monitor *mon, const QDict *qdict); +void hmp_cpr_exec(Monitor *mon, const QDict *qdict); void hmp_cpr_load(Monitor *mon, const QDict *qdict); void hmp_migrate_cancel(Monitor *mon, const QDict *qdict); void hmp_migrate_continue(Monitor *mon, const QDict *qdict); diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index da91a0a..99f75a1 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -1172,6 +1172,17 @@ out: hmp_handle_error(mon, err); } +void hmp_cpr_exec(Monitor *mon, const QDict *qdict) +{ + Error *err = NULL; + const char *command = qdict_get_try_str(qdict, "command"); + strList *args = strList_from_string(command, ' '); + + qmp_cpr_exec(args, &err); + qapi_free_strList(args); + hmp_handle_error(mon, err); +} + void hmp_cpr_load(Monitor *mon, const QDict *qdict) { Error *err = NULL; From patchwork Fri Aug 6 21:43:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12423993 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB632C4338F for ; Fri, 6 Aug 2021 22:23:06 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1BC4C61165 for ; Fri, 6 Aug 2021 22:23:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1BC4C61165 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:53984 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mC8F7-0006f0-1Z for qemu-devel@archiver.kernel.org; Fri, 06 Aug 2021 18:23:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47290) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85t-0007aP-5L for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:33 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:37510) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85r-0004HP-9T for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:32 -0400 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 176MAVUP021342; Fri, 6 Aug 2021 22:13:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=NJNM7NfZ3AdqmVfamSVJJZ1OhHqgSI7k4O0s/qa3Ohk=; b=MaOjDPhN6/vl7ecoN8Cq1NgZjPo8iEOxidsaGbZP5lJgU/PYc9A8qQiQmYFbQadfGvHL gPFzBR7UlywRIJE457u69vZQcThiRd+CY9emu9TYX7WB6+tjPWRTllJobqpaCkmfLzhY 7DpEg8dsG5kyPZiRvwBmMcwUI78vxcehAuKLK3bcJ+TlS6oByusx2qr9eviIZjrvZ7Ea fHvCVyqhDem+YwiNOR0fNIo8h2G2In/jExo00qMzq5yhqRVSFaIInoNd0BLr+QRF+Q3R f3UQsl77luf96c8exAyz23RO6UAxX9uDjST1DioGhnzGsmuLFCWrF+58otrREVb/hDu+ 1Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=NJNM7NfZ3AdqmVfamSVJJZ1OhHqgSI7k4O0s/qa3Ohk=; b=Z+WVobRzGUbkoPOidiLr3Z8wgL6ScHYCIhia9nNAtNc6bv0FdTacnZtjDHeL9kzzixi8 TorwDkBh9x+4Dn7adtrsqW1jrRtUEqldm7ATPoQvCR2nh7l+nPhr5KH01WglxRlWjt49 xOjS1MdkM1b+0UAPXtibTuo3lJgV3UrQENBQSXVD4irfn/OpKUj2d9+u7o087fNa7TAl ddnU9Y/Lp81Q0nQHh9CyU3pNs2Yom3gfcjC6qIKJVfCiyCvfZetnNZafT0J52nep9aZB W3UYvIXAdCDbc5m/SVX2jCPrrtmmF/KGi1DhFOQgVd8zxipwA/P4xVC9dMcG1vpkKPih ZA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3a97hqgrn1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:25 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 176MACtS083059; Fri, 6 Aug 2021 22:13:24 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2172.outbound.protection.outlook.com [104.47.57.172]) by aserp3020.oracle.com with ESMTP id 3a7r4cay3v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FBFpi/MS22Ub1gGjLtOc/6eq59SN7xA2kSv8bqaDyTO0vvUMl+zgXVdvp38/CMMmd0074yHKsYy+t1QNhUyw2wnm9+0RSqNcC+uSQQYBg3uQpf+Obrvj12Lw1OECJzlu/dSo1JIzK6/B9dEAXkjDRAdQW1AXApnRqfRv9emfpIehlu4orVD5jqOCGeOf7VY2irb22GlYB+MuqWZI7jLwOfX8tOUtYM9wC7BiSv8epKMkzuArs9xTYuye8KIDMDZ9WYnRjPQngMCfh1Zcd4YUU4dqfSWsGtUJWjU5fL9gv3uZWzNjF7Wf/ab1q9FhH+bKfa0Bs+Gp+WV+2tqGIINCbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NJNM7NfZ3AdqmVfamSVJJZ1OhHqgSI7k4O0s/qa3Ohk=; b=clzdYjqky9p1Ies2foTCF6B51W3xNfpSHdY7XNADeE9NHGjTlP7pDcMCwmUqjkpAolVENB1LYFcLPGU6LH+APbsqSN7IbmAfg26K3bY9SZU1zLMR5U0HwRdho0u6wdqByEw4vg8Yt5B92SbLz0usXFWP/4nIOR2RNV7cnrPFf8jya6wdt2XE3UF1FUV3u9VvyXNQoi0lOH1W2sbfRvIaCMSBk+7s22i+Z1aR4IqWuNEjBPG0b7GG1iZVl7/EfBsjE7mNHzbQfVCi4JqNWku03TcddgSiJry4++om5NNdM6K4wGuhCpFNShegoRPE3U0MIvg8jN0E9Ih7L7O7Tn2ydA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NJNM7NfZ3AdqmVfamSVJJZ1OhHqgSI7k4O0s/qa3Ohk=; b=O8ZX4fNjon4m4Keqd+21nDk1CMiAvoeMPNf25dm79dgfZJAUBSgFMWfPRZCui36+xJyXrID22mlglVDp13+/vhBcnv9ZCVXpbiWobczaOQmuNGPcEsUs3zuUfzp5HUI2VP0O1qJMTC38NMAC1MFIl9I+lwT4o15wMyFMT6bOI2c= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) by BY5PR10MB4129.namprd10.prod.outlook.com (2603:10b6:a03:210::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.17; Fri, 6 Aug 2021 22:13:22 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3%5]) with mapi id 15.20.4373.028; Fri, 6 Aug 2021 22:13:22 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V6 16/27] hostmem-memfd: cpr for memory-backend-memfd Date: Fri, 6 Aug 2021 14:43:50 -0700 Message-Id: <1628286241-217457-17-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> References: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) To BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ca-dev63.us.oracle.com (148.87.23.7) by SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Fri, 6 Aug 2021 22:13:21 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fb973303-3c9e-4f7c-a6cc-08d959276787 X-MS-TrafficTypeDiagnostic: BY5PR10MB4129: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:404; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 74IviNfWfrS/VKznCD3iGT39ut4IedTkfuGHaIl25MZlQQ5h94NR1/lZR4b2nTvJxEKlChRDr67MtLJMbqKuBngcb+bm57Q3+OudICuD3HYDbqJrgxbP2GwRU+4cK4u2z2ndUUorNLanqUbfEBnlvpOoQ46eVNC2ACmCQSzRv2nfppliYB8Qwp5CDAPuRyup51cNNSFprrTGgMYqwj1AhhptyhyAecyA+DO/IAQ+QPgy9DumCn25PcDC6sDv43LwNaeGaVbyfXyv73qchI1dDCEPUU6CBn3Q4vGAr+G+dUGW20O4JXqHp0z1eekMxHeCkaYgIPc32TaGuBkkIA9JOoIyExljGNg2U8CmZZy9Mte+rBEZ+53oOYRvj674em9xgylz+jxeoVQHvbzyP3TGseGUdcEIiykK4SVKxllVpZub+z3w8FZLDVm5h0wbVdJJUSiLiYtb7QXqWTvJl8jT/Gndfgna2QiUDdcOhwhXMajwMGfgO2WfYax0p1VPa3Q5jw+I8y118RjAWL4Dy6ny5Jmgv1pWvD1EqVZm34I/lPGuDTvqUBaxC+8e9eKSSUZsTZZbl8bapT8JAJrhOQdkxpdsuPfo1NKSFe1CRXc+HfokAhtymPem0LoJzEgE5CKtderbK3ZpFfbAF79YrOQS0w3sjYTdjJZDwDvnBwlqTSVp0+eDkRCO5YRyuVkNalTW X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(396003)(39860400002)(366004)(346002)(376002)(66946007)(66556008)(956004)(2616005)(316002)(7416002)(38350700002)(8936002)(478600001)(66476007)(36756003)(86362001)(38100700002)(5660300002)(54906003)(8676002)(4326008)(6486002)(7696005)(52116002)(186003)(2906002)(6666004)(107886003)(6916009)(26005)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dtof9zuMzHGqiUQIPfu0+4fvC5jtzlAh7gqsJq/UFWGmIx1rRIweq0gxbsEPidcLrHGPCNSjgKWgKcypkAKHro7D4F8QTAJoS8RGYCkEZjEIhiqu2843Z7Ram8gaPMWzY/W2nVZQwolBNit+KSWu8R3l1mF3c8fI9XxkBVs2epdyKMHBpMnB096ffwdrYnNhT/SBlFyqkABR02U5LfbYOXWGrFTmBBOqbSS70AQK4MTJJxY1x0+KefamcQbGUKlEzb6+D0fwxdt08U3px/hYQxHRWw/0xOSgnbFiZPrRG6ZZCkN2d6vL7CElSfNj557EM/GgF0TxbnnaWe34yuSmKHa/olCdy3vY5W+no6uL+0qpVHNuTHAmS7MnVrPKJmiwDDzLOUBs3mJVcSbZ6qhly5tdh9nc0REQgpCXo6F8Z3nY50C9VGUNgDKSmeBURPLMMGugFfh+xAQAVa2hihvbhBWF2YtD4cl/EoS6ziMTGixUys0e5TfsK5EzVNC464zXHNhAjutKpiLVriqSMJHA8l5TGGqxNKSNzSv2nXWqn4t61qM127J2u8R2kLYY1GAqWTppvsvCEIf+ySfwnWq3K0DVDFO0tJkiDoGqa/fTFVHsisNJeXOo2+FsNyt2lc/qli1kwbMLvY0qaprb/gsdexQ2spcoXZk9AS7Y4Z3tiZfKpMj1lqhB+ImoPGxPpIT5ufDFzW4n6BC8Es/XaYjB3zYuT6xGiRFr8fw4qwvg7Wsl5bzz5uq92lxNpo4KnT+u9SPBkXRbt4C78kBvxHMkV6KS3Fqyy5uho4Q1o1Feti0fzX3bmXsIWZjD5WRFoTq7DEeCnb9ZdDmeqSXHk2IxF30lJEOWDbp2bHc7WckGh747BbjXpfej7rtXKhAqhZl+CFzugTSr4gK7vOY79/4Kth6g1V27oko1A5umxHv/y5KQGTCpmPPpdcdEM8RMFh67PYktSK81rOB05kpZ1iF0ybSGT5llx4DRBPsIiHXTWkh6j9xbEgiLRG8eiMCP8k89oo9vbmBmS1ZS5ufMZTkSfj2hHOB/taN1hiLkRdF4uwLBZk4H4/Of29P/YFlaGfLX1lxBgB9IJnFnswhiRJNnNPSNY7uidDutHPl/gT5kGmJ0SpvlpG+9L6xOji048KDpbdSjXsWdv+gKwra/MbyEtaaomjY5/t7qDIjWxeBV2KzyRLAZjNjkiz6PGzMBz0HtpC6mnwVTd6pev+MvgscYdioN/rOU/UWBjlibqOCXLm4FItsMT3KdoBuIeaaPBwMAL9ce20sCIgVBIPzTNPkuwkSRSqZAFjcqaME2G9gQgzVQDERvQFQ/LbW2kQ794JJA X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: fb973303-3c9e-4f7c-a6cc-08d959276787 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2021 22:13:22.6315 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: xDuhQ109Cq0ZXFRfqsckq9xjlVjO9KcAuPoIShx98DwL/jPPG5eUN3p2RQhbaIsbRf8CkppitgEKyrnSf4N/7DI9pUTfnyypVUN3MqJMVvI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4129 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10068 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 adultscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108060145 X-Proofpoint-ORIG-GUID: qmn9HwY59IIGBg4WxA3WFd94uljBpMyj X-Proofpoint-GUID: qmn9HwY59IIGBg4WxA3WFd94uljBpMyj 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , Jason Zeng , =?utf-8?q?Alex_Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Zheng Chuan , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Preserve memory-backend-memfd memory objects during cpr. Signed-off-by: Steve Sistare --- backends/hostmem-memfd.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/backends/hostmem-memfd.c b/backends/hostmem-memfd.c index 3fc85c3..5097a05 100644 --- a/backends/hostmem-memfd.c +++ b/backends/hostmem-memfd.c @@ -14,6 +14,7 @@ #include "sysemu/hostmem.h" #include "qom/object_interfaces.h" #include "qemu/memfd.h" +#include "migration/cpr.h" #include "qemu/module.h" #include "qapi/error.h" #include "qom/object.h" @@ -36,23 +37,25 @@ memfd_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) { HostMemoryBackendMemfd *m = MEMORY_BACKEND_MEMFD(backend); uint32_t ram_flags; - char *name; - int fd; + char *name = host_memory_backend_get_name(backend); + int fd = cpr_find_fd(name, 0); if (!backend->size) { error_setg(errp, "can't create backend with size 0"); return; } - fd = qemu_memfd_create(TYPE_MEMORY_BACKEND_MEMFD, backend->size, - m->hugetlb, m->hugetlbsize, m->seal ? - F_SEAL_GROW | F_SEAL_SHRINK | F_SEAL_SEAL : 0, - errp); - if (fd == -1) { - return; + if (fd < 0) { + fd = qemu_memfd_create(TYPE_MEMORY_BACKEND_MEMFD, backend->size, + m->hugetlb, m->hugetlbsize, m->seal ? + F_SEAL_GROW | F_SEAL_SHRINK | F_SEAL_SEAL : 0, + errp); + if (fd == -1) { + return; + } + cpr_save_fd(name, 0, fd); } - name = host_memory_backend_get_name(backend); ram_flags = backend->share ? RAM_SHARED : 0; ram_flags |= backend->reserve ? 0 : RAM_NORESERVE; memory_region_init_ram_from_fd(&backend->mr, OBJECT(backend), name, From patchwork Fri Aug 6 21:43:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12424005 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA65BC4338F for ; Fri, 6 Aug 2021 22:25:41 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1968261131 for ; Fri, 6 Aug 2021 22:25:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1968261131 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:33840 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mC8Hb-0003m3-TW for qemu-devel@archiver.kernel.org; Fri, 06 Aug 2021 18:25:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47300) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85u-0007eq-UE for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:34 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:39806) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85s-0004J1-QF for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:34 -0400 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 176MBhkI032541; Fri, 6 Aug 2021 22:13:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=w/vrcOivBpdqxFi9TZFcRb2nnlFEOUIrem0F/zKASyk=; b=DgD3bcvPeonstqklUIjh1eNRR6tCkW3IU0oX2DPLkXJRXBYl+zJgEs2Y8TYfgbh3w/Wg 31PkHIbpRyx7ffm6wWvMeT2gxPHW1xR+xOGJaQpGJGrEjND0c5SPifcVbbsk16itPysk VN3om/1/tZ2pOxGYaxkh36RDfskIeJZiaigfxPW85TGlZsfBjd80oVF5w/hSw1e6qkPn 8KxypvVz+HbFehrta2cEi7yUVU2js8R3RkiduRCM19rMARR1KWHcMo8jAhVFrFCNmV05 TYEQz4RBxjSQFs2Ly/PV/9bheRBoEiNiL1KVb0p6AHvnWyKYyQ4OOG+XfmVO3aykvB3E wA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=w/vrcOivBpdqxFi9TZFcRb2nnlFEOUIrem0F/zKASyk=; b=u0nwijw2jfQc2GSSwjSacLgEYPuRDvnkncTikgNR6/jYnKjAGi146kO4lnbN/kQIVR7J Ma7jVqkogJl6dDztcWAqAt9kE0luUqaMeytZ4o+Mv0NlJ1YeOtM8S4kxUxnX/mSEWIaS DBzjrz0WWV6RQoq+6anw/SsaHldjXvesfIx3KVnruBR7NArD0mtD5QIRQ93Cjq67Av1q jawIQ+Ce5bdrcqyn86OsGRyyrNZvzyoLfJ6Wm96oihkd4Hz75A5rK9UAyWJ3vMolmUp9 dxLSqfd0sUobINFHdR3CGbQLkTQdDZtqhsydLCCVziZ0IQ2qLJMMEQeqwi5Z3filzJHY 2g== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3a9661s13v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:27 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 176MACtV083059; Fri, 6 Aug 2021 22:13:26 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2172.outbound.protection.outlook.com [104.47.57.172]) by aserp3020.oracle.com with ESMTP id 3a7r4cay3v-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Aq8XZGiudY3WSbM4ClbyTOewrjCI17bp5IlTWXvKjysdBvcROY05/Nx225k6eU/5rTEuSdp18f6T96SEFVd+e1Uz81ZFv6OYwQWWhd3LcDoQfanPTMvq+321kLtLWI1tm5TLmSiR6dL2GYETqM/fcq+U/KtZi1Epnc5/fIbgaEYzFKqj54k70W8t9+V+VrAXRAsKlIGtL9O5NXHGoOf/dC3GLV7cqsPaYD0JPsgtgfsSzJDQpp1bdKkqK80I6mtEmfFuc7rA4qw+kz8yY7QJW4s32d+YzFTHmTmB4tiYA+wvcP+WCxkJYzhtaaXHc8MTERQbJNJ6jOD/2JIlfS6g3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=w/vrcOivBpdqxFi9TZFcRb2nnlFEOUIrem0F/zKASyk=; b=fR2T6jJ3Pfi11vEYbJ7Fr9G2PtTgAYghtNEkL170gibXEXJYExeD5k1U3YT4LNsPEr+nrEHOIJfxEdiffrpE2KDGsa27phF1aqu0keu9RFSLhhM/bPNrvtcr8/sI9IWAFsf/lm6EeIJhTbsR0rCipcM7ZeBe7Bk0F1WRSNLK5OZBOQPIujAwXX3OhmpzSkpHGkpUWAeuepV+PtuSMYruww6LE1RVmaMbcOBYGBKL+nYf4N/OVkbJYD2MpfyATRQjGj99EWQRz43AL8e0rrR5ifWL00NvW6Ir8KawQQZ+N06bylM2tfgqMSkkBHTllJQt3s/V6Dz7DD85EbteV0728g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=w/vrcOivBpdqxFi9TZFcRb2nnlFEOUIrem0F/zKASyk=; b=jinm4zFafwKe9BbqN8QliqRbH6DY3jPVzl0bSJg/cMXV0vD/lAtWDYnX9uBVNUgx3zEbpd7H+3DrA9ASXCKeDSqProSd20bu7spWA940zNb3AEnQwS0wjmOmr1ruAsDB5SNr0mL6qL2UX3R+7Ozy/613pOxop7iPA6BdlKmnDDA= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) by BY5PR10MB4129.namprd10.prod.outlook.com (2603:10b6:a03:210::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.17; Fri, 6 Aug 2021 22:13:24 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3%5]) with mapi id 15.20.4373.028; Fri, 6 Aug 2021 22:13:24 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V6 17/27] pci: export functions for cpr Date: Fri, 6 Aug 2021 14:43:51 -0700 Message-Id: <1628286241-217457-18-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> References: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) To BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ca-dev63.us.oracle.com (148.87.23.7) by SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Fri, 6 Aug 2021 22:13:22 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dc0694db-df7e-4f15-3831-08d9592768a4 X-MS-TrafficTypeDiagnostic: BY5PR10MB4129: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1013; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CDBcpp9ZhvFToL0Aq86f1EGjv+RzkxfWE+GhbpkUE3uCObNHRCusQMVgqjaBvcVgNc1bd/K7pc1ay/JWaj8NwtWNNBoiuZpTvdtMfn7ImEgDLiwlAnKSQbgCZmnD2SeikHniKXktLrKGsVXTH9+iTk1y9lXeot2P24uz/p+neDIo5TLAx11MOmojysYbUhGAVpIqC/oX6wlYNbx1z+Y+P0xuox4pWhZTCqJz2M8tGv4ZGdIv52nLN2TFUGfOqbJZRti8vYZFUkh4G3YzP0ye3/Jpu39jwJ0LxISQ44X4rWwgbL+UWUay+iJoyRmk3gno5yDgWhQQyuJbrFTlgE2sJSgAS5eb0yw2j5dIeaELx1qbX2UWK1LkNyFnibBW8U0QOUSosc+M0sKwD0eN6e0cj5R/f4SJs/vgyCLgme3PMjMJnY9Sn3FwCOsXknnKd4zepe01VI4zdwXW7Pcs1OGxM+pdDfrh6hvmdypSs3Pjmy+qqzoPzJlvK3C2N5S937thbYIuadLXFiWhKhCVNC4qngqql8KKEhveJryDhQnEPbVt/s2V2UfCrc45BnDQj8oGOZmbLbwbbJkN+7es4tTivpKhZYOgt6lplF5mQejg4TjuBxeShvxf7FtBi1CRSZyVARLANLRUARRoHQzerVQYp4XZbrqvhYRB3pVpsG+oEW2fNjum/C3tL3iUKYZbBuVOiyX5sMeVP3VFEuUag22nYA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(396003)(39860400002)(366004)(346002)(376002)(66946007)(66556008)(956004)(2616005)(316002)(7416002)(38350700002)(8936002)(478600001)(66476007)(36756003)(86362001)(38100700002)(5660300002)(54906003)(8676002)(4326008)(6486002)(7696005)(52116002)(186003)(2906002)(6666004)(107886003)(6916009)(26005)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 73WdXUqIAEITFg02cq7BGjX0zaliCKzHcrWFIeVU1Gql61PeADFSCADzulg4rKNElsnQ/KtdVQ54sGeBKWF2YWjuxOd9q5ldWb74zZcLyXiS3yleTmFaMU2RWiPjhM1w4iBREpgtxw9ZytjOfTRAskZumQOIbwCJAN9Uz1LOyFxPxwZ8BmKfP0/T64TReahEBaVBihhGdnRjaSIAVmD3rC+73jWyEuSwphOjz+Ak1b0y6cXXVhnDEhE5j6pHUdb/vqz6PXwDs8We2W4got8NYaPSk+ldu8NkAvtL2yMTa28DbuSH9AKjF5kdLbvEm3Q3iyyCtEJ+8Y0KRlhv3L2shuZm8c0jAzVATjiujzHmevgICHs8+xj7xQPwhVVYzGedYo5VzAFeazWuNvESu96oFfBiXwRk0QnlfGmriSfuq0GZEwC4YO75ApDUJuhrQrbf5a+MA++S0x2tZZ0uGLM1QtTne4AB6BHbHxLbuVXJ7oMehdAtP0n3D4vE4TgM9FZecIHHyl3aMrBYLwhiadMLM7g6Yd9Mh7DQhmtM1hYLzgoiKl+A4J7nqOGeF/2fxQyPGZpdw3qN6tvQlUBhRkcKCaHyZGJxgi1HQQ1pNjXAT8tsqnnxnih4hThN7Et9V9LpXHrZbY8QLGOZRDogb27M2L22VtIDEZc090TBFz7HKbRYR32isSx8JrPTCkQ3upZLrwVo2ANwF4S0+lZEvFjeCVk+RpPfpccIuskSUV/nul5RbyS+MllVfCc0K55Zn6w26Wnums3bsCmewzzvZMxa9BSDLZgx/tmaVMUcAn1fSt7uYLV1OLrTKS5S/HGi6Z7xM8XOKSEGm1DbLq9iqqn7Pq7ahCBRDpUvGORK3IkC4lxXByvW3rdzz4acEr5BWJJYStUQNohoY1r4RxQa5PEGv4vDTipagXaIewPoNtxUsNEFlhHJI4kKhTJan5wFl+9kOU3iU6YgSsFzNctCyKjoy4qu4rdZrVRrf2NLw9V3wQVtK/1olhyWksFYhexqp0oYLgQz6Qyr0mScMt5XmdDAyrJ0qrQrcM4q52pk06/wsNnsfVgD9MU6/q+MpdVs0V/4wJPuJAutU8ivv0jooJiNFLffcMBsbNrFnFuHwexWKLC9tT4rpc9bhDH0TNWtZpROa3qI/jr5T/kUfhR9wRViAVkyoyInWxjP30045PMi4UReIMNDWp2Mm+qE7GK5TSuPy8sxluES005h4PwxzsEyfNc+MdZClyWK7YEUNz06cMOIk59a+PHCo+AWYS7OHUGJQdAzDmBy9Onqc6rKlf0V5yl9p3+edMFhd+fzmFHQVWFDGQcbF+1M46I1MH7XZCaF X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: dc0694db-df7e-4f15-3831-08d9592768a4 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2021 22:13:24.5104 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 8kSBOEUL5bywbEPBP0YHAknCJRqQ+rjhqdLdva0DmtntRZCx43C2+cvnBYW76DbjJoFmpfx0FEHe1Bia40ckV19AV5wXfIUVb1rBXnGWevA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4129 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10068 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 adultscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108060145 X-Proofpoint-GUID: pwo5v9C8bJTHJXW6UCBbYQcpXZZvyHwd X-Proofpoint-ORIG-GUID: pwo5v9C8bJTHJXW6UCBbYQcpXZZvyHwd 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , Jason Zeng , =?utf-8?q?Alex_Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Zheng Chuan , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Export msix_is_pending, msix_init_vector_notifiers, and pci_update_mappings for use by cpr. No functional change. Signed-off-by: Steve Sistare --- hw/pci/msix.c | 20 ++++++++++++++------ hw/pci/pci.c | 3 +-- include/hw/pci/msix.h | 5 +++++ include/hw/pci/pci.h | 1 + 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/hw/pci/msix.c b/hw/pci/msix.c index ae9331c..73f4259 100644 --- a/hw/pci/msix.c +++ b/hw/pci/msix.c @@ -64,7 +64,7 @@ static uint8_t *msix_pending_byte(PCIDevice *dev, int vector) return dev->msix_pba + vector / 8; } -static int msix_is_pending(PCIDevice *dev, int vector) +int msix_is_pending(PCIDevice *dev, unsigned int vector) { return *msix_pending_byte(dev, vector) & msix_pending_mask(vector); } @@ -579,6 +579,17 @@ static void msix_unset_notifier_for_vector(PCIDevice *dev, unsigned int vector) dev->msix_vector_release_notifier(dev, vector); } +void msix_init_vector_notifiers(PCIDevice *dev, + MSIVectorUseNotifier use_notifier, + MSIVectorReleaseNotifier release_notifier, + MSIVectorPollNotifier poll_notifier) +{ + assert(use_notifier && release_notifier); + dev->msix_vector_use_notifier = use_notifier; + dev->msix_vector_release_notifier = release_notifier; + dev->msix_vector_poll_notifier = poll_notifier; +} + int msix_set_vector_notifiers(PCIDevice *dev, MSIVectorUseNotifier use_notifier, MSIVectorReleaseNotifier release_notifier, @@ -586,11 +597,8 @@ int msix_set_vector_notifiers(PCIDevice *dev, { int vector, ret; - assert(use_notifier && release_notifier); - - dev->msix_vector_use_notifier = use_notifier; - dev->msix_vector_release_notifier = release_notifier; - dev->msix_vector_poll_notifier = poll_notifier; + msix_init_vector_notifiers(dev, use_notifier, release_notifier, + poll_notifier); if ((dev->config[dev->msix_cap + MSIX_CONTROL_OFFSET] & (MSIX_ENABLE_MASK | MSIX_MASKALL_MASK)) == MSIX_ENABLE_MASK) { diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 23d2ae2..59408a3 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -225,7 +225,6 @@ static const TypeInfo pcie_bus_info = { }; static PCIBus *pci_find_bus_nr(PCIBus *bus, int bus_num); -static void pci_update_mappings(PCIDevice *d); static void pci_irq_handler(void *opaque, int irq_num, int level); static void pci_add_option_rom(PCIDevice *pdev, bool is_default_rom, Error **); static void pci_del_option_rom(PCIDevice *pdev); @@ -1366,7 +1365,7 @@ static pcibus_t pci_bar_address(PCIDevice *d, return new_addr; } -static void pci_update_mappings(PCIDevice *d) +void pci_update_mappings(PCIDevice *d) { PCIIORegion *r; int i; diff --git a/include/hw/pci/msix.h b/include/hw/pci/msix.h index 4c4a60c..46606cf 100644 --- a/include/hw/pci/msix.h +++ b/include/hw/pci/msix.h @@ -32,6 +32,7 @@ int msix_present(PCIDevice *dev); bool msix_is_masked(PCIDevice *dev, unsigned vector); void msix_set_pending(PCIDevice *dev, unsigned vector); void msix_clr_pending(PCIDevice *dev, int vector); +int msix_is_pending(PCIDevice *dev, unsigned vector); int msix_vector_use(PCIDevice *dev, unsigned vector); void msix_vector_unuse(PCIDevice *dev, unsigned vector); @@ -41,6 +42,10 @@ void msix_notify(PCIDevice *dev, unsigned vector); void msix_reset(PCIDevice *dev); +void msix_init_vector_notifiers(PCIDevice *dev, + MSIVectorUseNotifier use_notifier, + MSIVectorReleaseNotifier release_notifier, + MSIVectorPollNotifier poll_notifier); int msix_set_vector_notifiers(PCIDevice *dev, MSIVectorUseNotifier use_notifier, MSIVectorReleaseNotifier release_notifier, diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index d0f4266..bf5be06 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -904,5 +904,6 @@ extern const VMStateDescription vmstate_pci_device; } MSIMessage pci_get_msi_message(PCIDevice *dev, int vector); +void pci_update_mappings(PCIDevice *d); #endif From patchwork Fri Aug 6 21:43:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12423983 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE444C4338F for ; Fri, 6 Aug 2021 22:19:13 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F0AAA61179 for ; Fri, 6 Aug 2021 22:19:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org F0AAA61179 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:40040 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mC8BL-0005gB-RG for qemu-devel@archiver.kernel.org; Fri, 06 Aug 2021 18:19:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47324) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85w-0007ki-UG for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:37 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:45586) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85u-0004JF-OF for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:36 -0400 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 176MB38v029751; Fri, 6 Aug 2021 22:13:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=77DrTQtv9HGtkH8RSMHnlyukv11D14Z+6dwlBj27OSs=; b=YNWXrijBYGfid47yY/1O7lKH1bGHHyM47XkATkBZW4Cp8xR8qMGro9+l61PaJkUYL12+ TRr/ntCCsLCT0stkonyLd2IcXbOsAJkVeyFjhp/H4nwDQ/vs4RcI+xA/UehlWVTzcZjT B+TRkeriu/FF+AnscHWY6QCIqqzoUb7mGUXZJkGiiithgO8PHno0EzeYJ47bhvChM3WW nRRp0eQ6zIGkkMlgKIpNIqMK9KNtSKF6CThwowf4ZnZyE1X85Avzajxs83tIAnRmi1Sh ryk5H7bWjx6Se+MDv6TYmajK0NGffb/uzwJLqlDmF470SLvurK919OzJW8GDa5BaEend zg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=77DrTQtv9HGtkH8RSMHnlyukv11D14Z+6dwlBj27OSs=; b=xfXLLoFfGBvAWXbr6lks2Y4zYeLwpddccUtDWnM9m7wuzjODkcEzunM2gw5pjDYPoBnu GqNIDTo8iHOsvRK7MJyBKJqOOSFCR5LvnztgCpZXjmRbZP6m7wusfswWtjK8RndHjt6C +cWxI7D32A1A2CWd3iy3aqFmj5r7FETUNmYnX6WbdUyuvYXgGXoQFsAe4xd1XTvhzRxJ 68hkTKxw6tDrWNyHPRZuHODhfOrl1OezO0eOoJn8nYDRHEWXVtRWlAABjEzFuz4qX8ip 0m4d2bh3wczDrZxuM1EqkCsXHXNTuYoZq4ijMzL1VsXJq/Rd0GBwiEwMocM8/osbPFol OA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3a90justqf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:29 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 176MAC4w083160; Fri, 6 Aug 2021 22:13:28 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2176.outbound.protection.outlook.com [104.47.57.176]) by aserp3020.oracle.com with ESMTP id 3a7r4cay5k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=awaTK4Xzge5vB0I8pBQy5Mbou5UfuIWkpZTtWorIKK5v8jwgDooMluxRpKkMnoRa+VcHObScNgWGoyrmbS+Mo+Fz18L8LWrmrf3MnfTF2oInWLOYRWewXA4ZzlbCPOn4d+14AU8iQ5ZMkuUKzpTjc65djqHwKOLmxDY+IT5XWwAScy/eUDcHB5KZ6SA/e18DDw0ptlbJbMl3fVprpfAstOtJqsbbYmwrt841186jUn4ElUWptGGOluabs5EY5L2DxeSTooaOzgaZny/boo93TzlR3cIIzdFlToatmlCKYet1oVAkNxp05J4sCOfWfy11/iCxvhzMQRW6foY38RHHmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=77DrTQtv9HGtkH8RSMHnlyukv11D14Z+6dwlBj27OSs=; b=cpPaBtYfWUrjR3bUEVl/v7XZNMYwrpXDXUKpt2yMBxb5qQT86jQE67kRLJ43Q6iOo4TFRrZVynFuRWi2TZuyJGHN5m0jouw+uAVNp1Z2UWeAAWD0BIjVLc3LquwfgOBChbJcq/O6tBihrvbhdVdGz5naLOakLz/aCfaqvreheSrL1dXq5SIEMLFc3G8rIRsZPzT0g/Db5hVo6vgapQz7k1m8dtV8ZfrmyUUxdsIJOyWlaV6gZ1SXkEa0g4S280sXNW6CnAKryAezRSbuFfTEjvStW3suKbHo0AFxakv7YhAdULRRz+soLyOCRzIz3K8Es4SqImXZb2Oqg19hHtw9NQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=77DrTQtv9HGtkH8RSMHnlyukv11D14Z+6dwlBj27OSs=; b=vDw1qHSS8TWmkEXQos8QKxJQNQGTjK20qFfoW3dIW4vwogFFCK2i0zL6A1RQ7i/jIHdOIS3bz+La7q9K8fSjFfAJDK64BqgGMQmv2r1JVgsIOXUMKDCu0W/wn6hX9vXNe2UhVW5QZo4Wfa+Kcy0h+P/qgYVYb0DgMfbYASvRZrI= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) by BY5PR10MB4129.namprd10.prod.outlook.com (2603:10b6:a03:210::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.17; Fri, 6 Aug 2021 22:13:26 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3%5]) with mapi id 15.20.4373.028; Fri, 6 Aug 2021 22:13:26 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V6 18/27] vfio-pci: refactor for cpr Date: Fri, 6 Aug 2021 14:43:52 -0700 Message-Id: <1628286241-217457-19-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> References: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) To BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ca-dev63.us.oracle.com (148.87.23.7) by SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Fri, 6 Aug 2021 22:13:24 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2a283f48-c1d7-4ca9-7b8e-08d9592769c0 X-MS-TrafficTypeDiagnostic: BY5PR10MB4129: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:580; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OlelaFjwZy8kMyg86gyni/X2x+10Fh7xDfSWFyi1g99JaO0iyskDRlNsRCLznicyxygabzbwJhrEsB9yre0F3axbpC8/m4DGKHPREuN5KxbQJJSJ4XeD7BL+aQyvQ8p5IEgcjTGxsiNVZGwBPJj5cJ5X9jPGXKjl+Y1PbBkNXh5lKFJG8o8qklpRswxQRueanq43HAeE2EiFyy+EnTlVe2BHRKyq3F/SLixTj9Hjuuz5KPNjuK7qcnTQc1tp1m85VO0uK92UQVtviy1qCDqsbFZFpxYRwB/bI9ytdu6/jvRPdBlPk94n2UeJ1kwmxUzq1RJo149kQNV20nAmnaYKxs/IMZ9OcmQOn11nO4uJjAkUvMtg+yEjkB7Q9tWFi/mDJSIFqWh8sxnzwUg5SdnhxwKyQ/cjhWxWe+5gYpQZzgs+UiGhvFpScEz4+eZ4qsTBMWNIaemkJ7r/lDs8LJzv6+jU0jpFMA9zIcGjXZzagx/gdI4BSbB0WtKpTuWih9EHHRXzBqW8QTr8tyv+PzK7x01pGJUN6qfMwa9EzMWB3DbUDgLQ3N94jlAa8d1vO4+AiL16+C4qKZJQlrY1ErXJhF543/cC/RQPOAxiedmZYXD4Kerqh1conTxZI60SSHq33nzoagVO+bdG7mJDPAzH8GJJ0uNX+DhpC1tAcqI/gcdintZXiQgpGpOKLjrDzELlU/OxaXny521/4EGNlW8lqg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(396003)(39860400002)(366004)(346002)(376002)(66946007)(66556008)(956004)(2616005)(316002)(7416002)(38350700002)(8936002)(478600001)(66476007)(36756003)(86362001)(38100700002)(5660300002)(54906003)(8676002)(4326008)(6486002)(7696005)(52116002)(186003)(2906002)(6666004)(107886003)(6916009)(26005)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Wgd/34AyDnHo0ehrKI02ABwTXUT65B0oCL1Xx9coWqOEbj0LNgzCns1ADvVqy20KjWdQun6VO3fJcSdyxNM7X+C2+nPWMSn04peq7JxP4PeAURz/SXd3a4RVJRvpClzhHL0UBOz4ISJnxqtTMJ+pHpgqODtiJZhczo1qmn5NR6oHvct+Vx80qcEhhjRhgMIxynI5OMNvSbuQyHDfnfdDCKvcx7DjdEMUprj03lsljtUH6TEqNClRAjbk75v/ddyApRh4Vf9ftnKaHpaubDaMVtWdCIZ0jjbb9Qqa47OPlqkWSwd/TzfvOFFwHVxBEf1Zyoqfr+risT90n+xy2Hb/zzk3Q8MQ8uywOrpB4hm+Cs44NCeCXn4u8Q60B8pOmMQIYVZ5Vq4TZlCA2BDz6prGNFsqV0nmiIVeR25+kDhfaIns2JXuGT5cyntCSs8x3R2WJhAqcKeiSNVhSdCgfj0Vds1F1+KIAMZOf0G7cfCWbFSCFvhag33ic6RJDco4hSUmTe3FS90P6DMCpzrYORT1cFx2m9PbTXVMHAnmU5l9QRUa0uplUJ7UdPpKRlwnaWjpVPX2PkICiAyDbylLO+fBNOOoQTakrh6IFFCR+RBavDbT3Yew1cFpnZT85Gu/GH0sJllT2QK2Cx95qseLQUq7d/MEbf8xGMEVqgDivxkmjBr9ovx63TGlbPMwYcUYKyaNVcQHToiAJClr5H+4o396sGQ1RZvgE199frAnf8ObtJMQIVrB9UY4iqgFhrRG9bG7BqxZv24dEBVzxQSlDFgui+0idkX5irVWM7wF4K5QCi0iu6TtU9CZPa4gywsJaVK9JstzcAo+Y2lj5eyI/Vx/mByU+MbiTggdEeW3ysPc/RoApPfZKNpoMIzgVc0W+VZFV58HNTBDSDbEcQkz85LsfH9TFDlEoAaOEMrzs7y0zkltl688OHTNkODHUeiZmzAZCsvz2fS2bmcOh7OGZ1ICo8fXFhftvVbogo5kgWlAJGuHSOW70auY7meFy/WxGKMu2yvhxfkOoPcyA7hSKe3LeUfr/hnEOOMLtZbLzjscrnctLSjIjwYBIWGiXfn+77DvwjBcf/Cf9LxLcy1I41yphWwTh3HDK46J7AMLm+bPfg7ttUj2geb+YoALQEMtO2GfDbZ6KiciYZ9n0lYC1V0NMrUQnw8UByDvaiGcnQ5v10ETw4D+bgql3Jo3Mrh1fjpo0Tlzl3h8ax1v+hP910RTxdBbxNR86HEn6YY+2D9/5cKHiIaBkv7qRIJIILtBS2YoB8ozmnRXdfo+V6btnVxN2YngcN00q9Dv6saz8RCGszFo6fy6vGHJl0KeLcVOtc1/ X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2a283f48-c1d7-4ca9-7b8e-08d9592769c0 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2021 22:13:26.4033 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: t5hmDo5ihBRxHaFthLOsPZo2eHdeI7PSXhLSY5TB+QoeHfvy6h3fW0Cv8BgPRkmHZIFNYkD71h4LsQXwenF4Sk9XmBDuCegq4ij35TdtXWY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4129 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10068 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 adultscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108060145 X-Proofpoint-ORIG-GUID: hth-sB7E69dOdwLqQ6k3d4PjgQ9JeWBz X-Proofpoint-GUID: hth-sB7E69dOdwLqQ6k3d4PjgQ9JeWBz Received-SPF: pass client-ip=205.220.165.32; envelope-from=steven.sistare@oracle.com; helo=mx0a-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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , Jason Zeng , =?utf-8?q?Alex_Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Zheng Chuan , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Export vfio_address_spaces and vfio_listener_skipped_section. Add optional name arg to vfio_add_kvm_msi_virq. Refactor vector use into a helper vfio_vector_init. All for use by cpr in a subsequent patch. No functional change. Signed-off-by: Steve Sistare --- hw/vfio/common.c | 4 ++-- hw/vfio/pci.c | 50 +++++++++++++++++++++++++++++++------------ include/hw/vfio/vfio-common.h | 3 +++ 3 files changed, 41 insertions(+), 16 deletions(-) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 8728d4d..7918c0d 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -43,7 +43,7 @@ VFIOGroupList vfio_group_list = QLIST_HEAD_INITIALIZER(vfio_group_list); -static QLIST_HEAD(, VFIOAddressSpace) vfio_address_spaces = +VFIOAddressSpaceList vfio_address_spaces = QLIST_HEAD_INITIALIZER(vfio_address_spaces); #ifdef CONFIG_KVM @@ -558,7 +558,7 @@ static int vfio_host_win_del(VFIOContainer *container, hwaddr min_iova, return -1; } -static bool vfio_listener_skipped_section(MemoryRegionSection *section) +bool vfio_listener_skipped_section(MemoryRegionSection *section) { return (!memory_region_is_ram(section->mr) && !memory_region_is_iommu(section->mr)) || diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index e1ea1d8..e8e371e 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -48,6 +48,20 @@ static void vfio_disable_interrupts(VFIOPCIDevice *vdev); static void vfio_mmap_set_enabled(VFIOPCIDevice *vdev, bool enabled); +/* Create new or reuse existing eventfd */ +static int vfio_named_notifier_init(VFIOPCIDevice *vdev, EventNotifier *e, + const char *name, int nr) +{ + int fd = -1; /* placeholder until a subsequent patch */ + + if (fd >= 0) { + event_notifier_init_fd(e, fd); + return 0; + } else { + return event_notifier_init(e, 0); + } +} + /* * Disabling BAR mmaping can be slow, but toggling it around INTx can * also be a huge overhead. We try to get the best of both worlds by @@ -410,7 +424,7 @@ static int vfio_enable_vectors(VFIOPCIDevice *vdev, bool msix) } static void vfio_add_kvm_msi_virq(VFIOPCIDevice *vdev, VFIOMSIVector *vector, - int vector_n, bool msix) + const char *name, int nr, bool msix) { int virq; @@ -418,11 +432,11 @@ static void vfio_add_kvm_msi_virq(VFIOPCIDevice *vdev, VFIOMSIVector *vector, return; } - if (event_notifier_init(&vector->kvm_interrupt, 0)) { + if (vfio_named_notifier_init(vdev, &vector->kvm_interrupt, name, nr)) { return; } - virq = kvm_irqchip_add_msi_route(kvm_state, vector_n, &vdev->pdev); + virq = kvm_irqchip_add_msi_route(kvm_state, nr, &vdev->pdev); if (virq < 0) { event_notifier_cleanup(&vector->kvm_interrupt); return; @@ -454,6 +468,20 @@ static void vfio_update_kvm_msi_virq(VFIOMSIVector *vector, MSIMessage msg, kvm_irqchip_commit_routes(kvm_state); } +static void vfio_vector_init(VFIOPCIDevice *vdev, const char *name, int nr) +{ + VFIOMSIVector *vector = &vdev->msi_vectors[nr]; + PCIDevice *pdev = &vdev->pdev; + + vector->vdev = vdev; + vector->virq = -1; + if (vfio_named_notifier_init(vdev, &vector->interrupt, name, nr)) { + error_report("vfio: Error: event_notifier_init failed"); + } + vector->use = true; + msix_vector_use(pdev, nr); +} + static int vfio_msix_vector_do_use(PCIDevice *pdev, unsigned int nr, MSIMessage *msg, IOHandler *handler) { @@ -466,13 +494,7 @@ static int vfio_msix_vector_do_use(PCIDevice *pdev, unsigned int nr, vector = &vdev->msi_vectors[nr]; if (!vector->use) { - vector->vdev = vdev; - vector->virq = -1; - if (event_notifier_init(&vector->interrupt, 0)) { - error_report("vfio: Error: event_notifier_init failed"); - } - vector->use = true; - msix_vector_use(pdev, nr); + vfio_vector_init(vdev, NULL, nr); } qemu_set_fd_handler(event_notifier_get_fd(&vector->interrupt), @@ -490,7 +512,7 @@ static int vfio_msix_vector_do_use(PCIDevice *pdev, unsigned int nr, } } else { if (msg) { - vfio_add_kvm_msi_virq(vdev, vector, nr, true); + vfio_add_kvm_msi_virq(vdev, vector, NULL, nr, true); } } @@ -640,7 +662,7 @@ retry: * Attempt to enable route through KVM irqchip, * default to userspace handling if unavailable. */ - vfio_add_kvm_msi_virq(vdev, vector, i, false); + vfio_add_kvm_msi_virq(vdev, vector, NULL, i, false); } /* Set interrupt type prior to possible interrupts */ @@ -2677,7 +2699,7 @@ static void vfio_register_err_notifier(VFIOPCIDevice *vdev) return; } - if (event_notifier_init(&vdev->err_notifier, 0)) { + if (vfio_named_notifier_init(vdev, &vdev->err_notifier, "err", 0)) { error_report("vfio: Unable to init event notifier for error detection"); vdev->pci_aer = false; return; @@ -2743,7 +2765,7 @@ static void vfio_register_req_notifier(VFIOPCIDevice *vdev) return; } - if (event_notifier_init(&vdev->req_notifier, 0)) { + if (vfio_named_notifier_init(vdev, &vdev->req_notifier, "req", 0)) { error_report("vfio: Unable to init event notifier for device request"); return; } diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 8af11b0..cb04cc6 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -216,6 +216,8 @@ int vfio_get_device(VFIOGroup *group, const char *name, extern const MemoryRegionOps vfio_region_ops; typedef QLIST_HEAD(VFIOGroupList, VFIOGroup) VFIOGroupList; extern VFIOGroupList vfio_group_list; +typedef QLIST_HEAD(, VFIOAddressSpace) VFIOAddressSpaceList; +extern VFIOAddressSpaceList vfio_address_spaces; bool vfio_mig_active(void); int64_t vfio_mig_bytes_transferred(void); @@ -234,6 +236,7 @@ struct vfio_info_cap_header * vfio_get_device_info_cap(struct vfio_device_info *info, uint16_t id); #endif extern const MemoryListener vfio_prereg_listener; +bool vfio_listener_skipped_section(MemoryRegionSection *section); int vfio_spapr_create_window(VFIOContainer *container, MemoryRegionSection *section, From patchwork Fri Aug 6 21:43:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12424015 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 369DBC4338F for ; Fri, 6 Aug 2021 22:28:11 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5BBBD61165 for ; Fri, 6 Aug 2021 22:28:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5BBBD61165 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:44612 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mC8K1-0002lW-AD for qemu-devel@archiver.kernel.org; Fri, 06 Aug 2021 18:28:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47358) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC861-0007y4-A9 for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:41 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:45942) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85x-0004LD-4P for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:41 -0400 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 176MBdcD032510; Fri, 6 Aug 2021 22:13:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=SQqYrioUhIu+iP1XhaZzIqU/EWmZ+h17CMRsdvXlLs0=; b=yfuGLqkmLZlEnGfJjFCA62u+4qpBTzdUg0OpacAdW+hus7pSgGQpiDun+jJEsuRovU3y L3ZNbIbi1m5HxTukgrWihkhhMmnO3eqbq7Qz4pUdSoKqEwzBO1XFJd1kamDybTTpVAjG 1vf/qqnkLrNn5R9oV87tePT8xpQxS83Ixy3IU+4a4BVb/dn8X+Vkmj8W9bVqcn7feQBs e1ATxc691+RaoL27gYMW5nI/oGb6w9V+aSFniWnQnoUlsKwvjvcMDrnTcolpQ+CaJ4B5 8tHONf49EHcZxd4gnAISTv1glc8up/oTfbzWk75h3Oj+DfpHqhy1ijhuq8Z5FqR5MRZ2 Kg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=SQqYrioUhIu+iP1XhaZzIqU/EWmZ+h17CMRsdvXlLs0=; b=uc7Vca3pYG1hY6mLRsEHRwzoJ2tc3KBRMZlVa0DICxtP5g7P7c33mZEWieiJGX58S5tg uR9T5XA9mZz71SqCwUWXq3YtRug8uV5PchKK9ABy+DfDeBVR1wRd4Zc6McwJXhOz0oTH HhNG97nPED6wWuyvniDw2/gE4mL+lpHDWxXOiY77nKl9RElMLJMBV9D99u3mYxEz/bHN nL6EhSqoS1m4HJ2r84T2CGYYMyzvU7tuYZM87eDsE79qX31UXL4EqmkToUKZP9IBH3Ey hHiHZrwjHj2cw+ILp8wJwKi5awftjbgOzxHe9sH7z4D6xMi85fYUnzko0M9lmMyt6BPO mQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3a9661s13x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:31 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 176MABQQ083043; Fri, 6 Aug 2021 22:13:30 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by aserp3020.oracle.com with ESMTP id 3a7r4cay6f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f+T7F3/ce7rOecL3dKldCUoT9t0ebHsQZbbwkYB5JpRlavhxjmVsKKVy2U1sBEpafGPuzK+MD3bJqvOGtwq2ua7rrB/HLPA8y2LrUoYqWH/pybqqT1lofuFPSTf4Cz7ksfwxOwir7BdwrXQ6djLWovKjNwhQyUtwXQkoqgyecl+6UOgMdIVQXesYcF5YIETCPkq79c+7e1iX2Pt/AYNmf4HCRLSHqCY9OGipUz5tlhRtjXQ1+x/XpemqD7KEH8MeOPgopVcj82Fp9Utez9RCHXr1sRF2cMm9ikxkBcTvKZxdUfKQgmggkvmmIHCtSmfp348qA571Kv1WG1BbDBLaeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SQqYrioUhIu+iP1XhaZzIqU/EWmZ+h17CMRsdvXlLs0=; b=bfGzO4qdllC7ao/ZjP9CHQ2SM6P5rc6b0JU0Cb4tplDEkebvox80a10n3umPRtETkYOefTxhWpAuD3eTOkfrWhlAHUdLxTFckaKlRc1Xjpne1X/1x7bQHpREtctdl7uBeSZKXWiWRNzOsRZcd/O2Pcip7NAxygkIB1+hC//qmMKhv18FqbC5nETPvqdqPFsED/0pGGBlZ4PXbkRkgW/NBm/gQFHiVYAkcheQMgoWL/JhGuBuy035fmDROxyVIeoXd1NO1I+BVrXju1j+eZV51zWLOhcS8ca7YXulLlUYrm+dRjODtUe7WLD6SNKfysTSZaau/OCHTrMczsx3wWiYyw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SQqYrioUhIu+iP1XhaZzIqU/EWmZ+h17CMRsdvXlLs0=; b=PqIZBj8QanvzooPN0MMK6NKRR3X1YF++5rAnuK+WGZthQFGFNWs9h/aQUbPgnJuyx9zhYMVE32rbDkq3KDgI/EdJYuzPe0+dEp4ZZVldgTCiCyzmTBViQVXH+puMLCpL0yEr3etz6s15inY9ioBT3QngARMluMOsJPDix5FuZqs= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) by BY5PR10MB4129.namprd10.prod.outlook.com (2603:10b6:a03:210::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.17; Fri, 6 Aug 2021 22:13:28 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3%5]) with mapi id 15.20.4373.028; Fri, 6 Aug 2021 22:13:28 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V6 19/27] vfio-pci: cpr part 1 (fd and dma) Date: Fri, 6 Aug 2021 14:43:53 -0700 Message-Id: <1628286241-217457-20-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> References: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) To BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ca-dev63.us.oracle.com (148.87.23.7) by SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Fri, 6 Aug 2021 22:13:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0bc10d25-c429-4eaf-3365-08d959276ae6 X-MS-TrafficTypeDiagnostic: BY5PR10MB4129: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:392; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SiclzzOUDYTxkgLZLbBINI1rWyxEblCVZRc7azTtoa0gfIJfQOXtmkWTj/i4UscZtKEGN9URfqOwpHCExC6P117Vslw4BDtLuvp/hw852LT4JT9UZqdMHEJVQMitgO8NKH2tTf5hSoIx1G+mJV7Set0dJHZMk4adqsJg/hEnkpwITN5ZGD+AWuIpsV1tW5e0HHFyecEN5DghRpj/2r3bbvIDsmJ+L7Yc7J/Ngzkn/ow8QsxSqNAq040acykUMl2qptjTTKuusqwMI8Okjz3Skh4R98V5JyOG5tNyy63Hc42H4wdIVOejuUy3KdRrLxVspXj4il2bml+i8IRRNafgitBXQiQ21v5TXtMXtR9ttB3JanKZSX2FJkRmaoI3KlxNGliumf+NucNBEnKlFUeG3vnzwef8O0OdthqKf78ECgva1w/FZ9e5C1onwdQ7ANFB6L9VX55HGjy45cG3myw+v/TmzeD1FKEXW4utO4LDLfAANaY29+GN9xuT+AFXhbcTo+lJtV3+qpHQTnr1K07m3QdXDxEebJ7Pnn+7eJAYEkY5fOjbGg0hVYzsE+LS7MlIY34rS3n2m5lzugTc6LEimBKm7mUfGXZpgYGfIxBpnLwVNhM41iVH+R6SoHpYyuIrODlXXxlO8HNGkkDOZ4J4NDzXBgq+k7SKPVjRU2Fs4sIpoFXqOhMwtBbzPdp37Jhvhi5rUQoRfWy8WJ5PDsrQSA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(396003)(39860400002)(366004)(346002)(376002)(66946007)(66556008)(956004)(2616005)(316002)(7416002)(38350700002)(8936002)(478600001)(66476007)(36756003)(86362001)(38100700002)(5660300002)(54906003)(8676002)(4326008)(6486002)(7696005)(52116002)(186003)(2906002)(6666004)(107886003)(30864003)(6916009)(26005)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4TSM+O+s+J9Fh2uor66oqJBAPFdyw9L/aK+jecrM/l2nrbb2YeumwJey/2uS4TqB+E03U7tcs9gda7xRBv2wrJshHSQ6+2BZv/OM1rn3A+b8BZoAgyVYqrwRGn/SYt/O4RyLn4KTuUl71Wkrim+j+H4PuL0vZm0oSjkj7GoIqXCgPbpFZJT/lwDW1eqBKJ5b1vBAG1ROezmqAqtjCptxxLP2rntrF1miBPV4jqGSfPihePECR7peVdjkFChrLHiYNiGPixvSVMJ2RMM0kJTUhPX8k74aoedJnBGxQ0q49KjNK5UyeRB8vp9NwOg/zVdNbWfdl6sAEQvxPPtU5M3ce8UzIbYr2welsaBK6TZDMQqWutoifP+a4bWJ5tW6LDG27Wwn2yhtu0KmISLNzkBS6h7H7mrAaRAzz9BZk4YFLjEnIfi2YqX/HSG3foPQjgyaVnRj+CQATbu7X5xvcTofRDuXvwVMhkiCA8ONmAKuUmX7toBjvg5qwbkt59Vv5RQaATQe6mysVkoCTtNrdpbeeWCCXGKanqA4z1/BwkpjBrF5wh+0PXBSk8kBODBQEaBGrg/TA727XeJFFS4mLz4i0pXaKCPLJ8crNCIhZEgragVawL+nuNOH0f5tfvM9X61s9DlpI689CrZ186a3lQqiwu0PfusPfoXQB81uvCwBiCP8fOzqcM3JkIV074dyOgI9HisX7LjPmZXf+f53qnSdqSYj59xWwkxvhaStoCNPG0LwmHS+4IGHbHI0naje1SJDsEUBFfpFHrHPgH7i2Cl46SuGeCgqi01xu9KMeJD8SGYA1YIH4vz8fU7tJcIpifeeAF4h2kum2EMUooag4J+w764VnBURIcV0q723nz6iJkUZaDPL5oLbSePJWdppVzUUs4xecbnM9u7I+6B8FYUupv7PU3bXysS+lTEJn4vK0jDeC/dX/nj9eLMWdHFZr8y+rootl4sU0XAlhyQ/FH8reWCP2+0+5f2Es6do0TA9hhdoK0qgKsfnPDifYRwJBBo/4/Kvw0Vzf4RHICUi8xoFJanVVLnSupsOsG14Wxi78wEGcdsmfcxtE8NS/lLr9nhG17G43zOlKJP0j0CJ73yrDjQGEJ9uBwjXfcgQooym49tLc+KWl2P2hbKd69uJLwgL3ufhj9wJ1vAkLQVdE4NOdoYbGQKtCqWoDb99PQfcz6JaZS3GpXAxj8xnw3b94TJOoIj7fVRDv6QQpOW82qZdQPkHC0q3T4/hdrk4bQmzqlAIN6TVyBKBCC4zRPRoQrc6j98YSH1W/9gVykqs7tSHCEvkBBDFP+dap3QFy0ciGa9i7fHCI2Ykao2WojUNxNWZ X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0bc10d25-c429-4eaf-3365-08d959276ae6 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2021 22:13:28.3462 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: g1y70b2fqbzrvqqKkAYFHkM9zxT6GO0m5nmUWZ1pppPGnVGRhl4sv5su5T0L/RSlQlwyStUlJp1s9+7WRvBkEeuEsudGTWZsqPZrV9zPE4c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4129 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10068 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 adultscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108060145 X-Proofpoint-GUID: E2OUhkuVCl3sd0X9Pbf7XA3EcYr1X9oZ X-Proofpoint-ORIG-GUID: E2OUhkuVCl3sd0X9Pbf7XA3EcYr1X9oZ 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , Jason Zeng , =?utf-8?q?Alex_Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Zheng Chuan , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Enable vfio-pci devices to be saved and restored across an exec restart of qemu. At vfio creation time, save the value of vfio container, group, and device descriptors in cpr state. In cpr-save and cpr-exec, suspend the use of virtual addresses in DMA mappings with VFIO_DMA_UNMAP_FLAG_VADDR, because guest ram will be remapped at a different VA after exec. DMA to already-mapped pages continues. Save the msi message area as part of vfio-pci vmstate, save the interrupt and notifier eventfd's in cpr state, and clear the close-on-exec flag for the vfio descriptors. The flag is not cleared earlier because the descriptors should not persist across miscellaneous fork and exec calls that may be performed during normal operation. On qemu restart, vfio_realize() finds the descriptor env vars, uses the descriptors, and notes that the device is being reused. Device and iommu state is already configured, so operations in vfio_realize that would modify the configuration are skipped for a reused device, including vfio ioctl's and writes to PCI configuration space. The result is that vfio_realize constructs qemu data structures that reflect the current state of the device. However, the reconstruction is not complete until cpr-load is called. cpr-load loads the msi data and finds eventfds in cpr state. It rebuilds vector data structures and attaches the interrupts to the new KVM instance. cpr-load then walks the flattened ranges of the vfio_address_spaces and calls VFIO_DMA_MAP_FLAG_VADDR to inform the kernel of the new VA's. Lastly, it starts the VM and suppresses vfio device reset. This functionality is delivered by 3 patches for clarity. Part 1 handles device file descriptors and DMA. Part 2 adds eventfd and MSI/MSI-X vector support. Part 3 adds INTX support. Signed-off-by: Steve Sistare --- MAINTAINERS | 1 + hw/pci/pci.c | 4 ++ hw/vfio/common.c | 69 ++++++++++++++++-- hw/vfio/cpr.c | 160 ++++++++++++++++++++++++++++++++++++++++++ hw/vfio/meson.build | 1 + hw/vfio/pci.c | 57 +++++++++++++++ hw/vfio/trace-events | 1 + include/hw/pci/pci.h | 1 + include/hw/vfio/vfio-common.h | 5 ++ include/migration/cpr.h | 3 + linux-headers/linux/vfio.h | 6 ++ migration/cpr.c | 10 ++- migration/target.c | 14 ++++ 13 files changed, 325 insertions(+), 7 deletions(-) create mode 100644 hw/vfio/cpr.c diff --git a/MAINTAINERS b/MAINTAINERS index a9d2ed8..3132965 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2904,6 +2904,7 @@ CPR M: Steve Sistare M: Mark Kanda S: Maintained +F: hw/vfio/cpr.c F: include/migration/cpr.h F: migration/cpr.c F: qapi/cpr.json diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 59408a3..b9c6ca1 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -307,6 +307,10 @@ static void pci_do_device_reset(PCIDevice *dev) { int r; + if (dev->reused) { + return; + } + pci_device_deassert_intx(dev); assert(dev->irq_state == 0); diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 7918c0d..872a1ac 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -31,6 +31,7 @@ #include "exec/memory.h" #include "exec/ram_addr.h" #include "hw/hw.h" +#include "migration/cpr.h" #include "qemu/error-report.h" #include "qemu/main-loop.h" #include "qemu/range.h" @@ -464,6 +465,10 @@ static int vfio_dma_unmap(VFIOContainer *container, return vfio_dma_unmap_bitmap(container, iova, size, iotlb); } + if (container->reused) { + return 0; + } + while (ioctl(container->fd, VFIO_IOMMU_UNMAP_DMA, &unmap)) { /* * The type1 backend has an off-by-one bug in the kernel (71a7d3d78e3c @@ -501,6 +506,10 @@ static int vfio_dma_map(VFIOContainer *container, hwaddr iova, .size = size, }; + if (container->reused) { + return 0; + } + if (!readonly) { map.flags |= VFIO_DMA_MAP_FLAG_WRITE; } @@ -1872,6 +1881,10 @@ static int vfio_init_container(VFIOContainer *container, int group_fd, if (iommu_type < 0) { return iommu_type; } + if (container->reused) { + container->iommu_type = iommu_type; + return 0; + } ret = ioctl(group_fd, VFIO_GROUP_SET_CONTAINER, &container->fd); if (ret) { @@ -1972,6 +1985,7 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as, { VFIOContainer *container; int ret, fd; + bool reused; VFIOAddressSpace *space; space = vfio_get_address_space(as); @@ -2007,7 +2021,13 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as, * details once we know which type of IOMMU we are using. */ + fd = cpr_find_fd("vfio_container_for_group", group->groupid); + reused = (fd >= 0); + QLIST_FOREACH(container, &space->containers, next) { + if (container->fd == fd) { + break; + } if (!ioctl(group->fd, VFIO_GROUP_SET_CONTAINER, &container->fd)) { ret = vfio_ram_block_discard_disable(container, true); if (ret) { @@ -2020,14 +2040,25 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as, } return ret; } - group->container = container; - QLIST_INSERT_HEAD(&container->group_list, group, container_next); + break; + } + } + + if (container) { + group->container = container; + QLIST_INSERT_HEAD(&container->group_list, group, container_next); + if (!reused) { vfio_kvm_device_add_group(group); - return 0; + cpr_save_fd("vfio_container_for_group", group->groupid, + container->fd); } + return 0; + } + + if (!reused) { + fd = qemu_open_old("/dev/vfio/vfio", O_RDWR); } - fd = qemu_open_old("/dev/vfio/vfio", O_RDWR); if (fd < 0) { error_setg_errno(errp, errno, "failed to open /dev/vfio/vfio"); ret = -errno; @@ -2045,6 +2076,7 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as, container = g_malloc0(sizeof(*container)); container->space = space; container->fd = fd; + container->reused = reused; container->error = NULL; container->dirty_pages_supported = false; container->dma_max_mappings = 0; @@ -2183,6 +2215,7 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as, } container->initialized = true; + cpr_save_fd("vfio_container_for_group", group->groupid, fd); return 0; listener_release_exit: @@ -2212,6 +2245,7 @@ static void vfio_disconnect_container(VFIOGroup *group) QLIST_REMOVE(group, container_next); group->container = NULL; + cpr_delete_fd("vfio_container_for_group", group->groupid); /* * Explicitly release the listener first before unset container, @@ -2253,6 +2287,7 @@ VFIOGroup *vfio_get_group(int groupid, AddressSpace *as, Error **errp) VFIOGroup *group; char path[32]; struct vfio_group_status status = { .argsz = sizeof(status) }; + bool reused; QLIST_FOREACH(group, &vfio_group_list, next) { if (group->groupid == groupid) { @@ -2270,7 +2305,13 @@ VFIOGroup *vfio_get_group(int groupid, AddressSpace *as, Error **errp) group = g_malloc0(sizeof(*group)); snprintf(path, sizeof(path), "/dev/vfio/%d", groupid); - group->fd = qemu_open_old(path, O_RDWR); + + group->fd = cpr_find_fd("vfio_group", groupid); + reused = (group->fd >= 0); + if (!reused) { + group->fd = qemu_open_old(path, O_RDWR); + } + if (group->fd < 0) { error_setg_errno(errp, errno, "failed to open %s", path); goto free_group_exit; @@ -2304,6 +2345,10 @@ VFIOGroup *vfio_get_group(int groupid, AddressSpace *as, Error **errp) QLIST_INSERT_HEAD(&vfio_group_list, group, next); + if (!reused) { + cpr_save_fd("vfio_group", groupid, group->fd); + } + return group; close_fd_exit: @@ -2328,6 +2373,7 @@ void vfio_put_group(VFIOGroup *group) vfio_disconnect_container(group); QLIST_REMOVE(group, next); trace_vfio_put_group(group->fd); + cpr_delete_fd("vfio_group", group->groupid); close(group->fd); g_free(group); @@ -2341,8 +2387,14 @@ int vfio_get_device(VFIOGroup *group, const char *name, { struct vfio_device_info dev_info = { .argsz = sizeof(dev_info) }; int ret, fd; + bool reused; + + fd = cpr_find_fd(name, 0); + reused = (fd >= 0); + if (!reused) { + fd = ioctl(group->fd, VFIO_GROUP_GET_DEVICE_FD, name); + } - fd = ioctl(group->fd, VFIO_GROUP_GET_DEVICE_FD, name); if (fd < 0) { error_setg_errno(errp, errno, "error getting device from group %d", group->groupid); @@ -2387,6 +2439,10 @@ int vfio_get_device(VFIOGroup *group, const char *name, vbasedev->num_irqs = dev_info.num_irqs; vbasedev->num_regions = dev_info.num_regions; vbasedev->flags = dev_info.flags; + vbasedev->reused = reused; + if (!reused) { + cpr_save_fd(name, 0, fd); + } trace_vfio_get_device(name, dev_info.flags, dev_info.num_regions, dev_info.num_irqs); @@ -2403,6 +2459,7 @@ void vfio_put_base_device(VFIODevice *vbasedev) QLIST_REMOVE(vbasedev, next); vbasedev->group = NULL; trace_vfio_put_base_device(vbasedev->fd); + cpr_delete_fd(vbasedev->name, 0); close(vbasedev->fd); } diff --git a/hw/vfio/cpr.c b/hw/vfio/cpr.c new file mode 100644 index 0000000..0981d31 --- /dev/null +++ b/hw/vfio/cpr.c @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2021 Oracle and/or its affiliates. + * + * This work is licensed under the terms of the GNU GPL, version 2. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include +#include +#include "hw/vfio/vfio-common.h" +#include "sysemu/kvm.h" +#include "qapi/error.h" +#include "trace.h" + +static int +vfio_dma_unmap_vaddr_all(VFIOContainer *container, Error **errp) +{ + struct vfio_iommu_type1_dma_unmap unmap = { + .argsz = sizeof(unmap), + .flags = VFIO_DMA_UNMAP_FLAG_VADDR | VFIO_DMA_UNMAP_FLAG_ALL, + .iova = 0, + .size = 0, + }; + if (ioctl(container->fd, VFIO_IOMMU_UNMAP_DMA, &unmap)) { + error_setg_errno(errp, errno, "vfio_dma_unmap_vaddr_all"); + return -errno; + } + return 0; +} + +static int vfio_dma_map_vaddr(VFIOContainer *container, hwaddr iova, + ram_addr_t size, void *vaddr, + Error **errp) +{ + struct vfio_iommu_type1_dma_map map = { + .argsz = sizeof(map), + .flags = VFIO_DMA_MAP_FLAG_VADDR, + .vaddr = (__u64)(uintptr_t)vaddr, + .iova = iova, + .size = size, + }; + if (ioctl(container->fd, VFIO_IOMMU_MAP_DMA, &map)) { + error_setg_errno(errp, errno, + "vfio_dma_map_vaddr(iova %lu, size %ld, va %p)", + iova, size, vaddr); + return -errno; + } + return 0; +} + +static int +vfio_region_remap(MemoryRegionSection *section, void *handle, Error **errp) +{ + MemoryRegion *mr = section->mr; + VFIOContainer *container = handle; + const char *name = memory_region_name(mr); + ram_addr_t size = int128_get64(section->size); + hwaddr offset, iova, roundup; + void *vaddr; + + if (vfio_listener_skipped_section(section) || memory_region_is_iommu(mr)) { + return 0; + } + + offset = section->offset_within_address_space; + iova = REAL_HOST_PAGE_ALIGN(offset); + roundup = iova - offset; + size -= roundup; + size = REAL_HOST_PAGE_ALIGN(size); + vaddr = memory_region_get_ram_ptr(mr) + + section->offset_within_region + roundup; + + trace_vfio_region_remap(name, container->fd, iova, iova + size - 1, vaddr); + return vfio_dma_map_vaddr(container, iova, size, vaddr, errp); +} + +bool vfio_is_cpr_capable(VFIOContainer *container, Error **errp) +{ + if (!ioctl(container->fd, VFIO_CHECK_EXTENSION, VFIO_UPDATE_VADDR) || + !ioctl(container->fd, VFIO_CHECK_EXTENSION, VFIO_UNMAP_ALL)) { + error_setg(errp, "VFIO container does not support VFIO_UPDATE_VADDR " + "or VFIO_UNMAP_ALL"); + return false; + } else { + return true; + } +} + +int vfio_cpr_save(Error **errp) +{ + ERRP_GUARD(); + VFIOAddressSpace *space, *last_space; + VFIOContainer *container, *last_container; + + QLIST_FOREACH(space, &vfio_address_spaces, list) { + QLIST_FOREACH(container, &space->containers, next) { + if (!vfio_is_cpr_capable(container, errp)) { + return -1; + } + } + } + + QLIST_FOREACH(space, &vfio_address_spaces, list) { + QLIST_FOREACH(container, &space->containers, next) { + if (vfio_dma_unmap_vaddr_all(container, errp)) { + goto unwind; + } + } + } + return 0; + +unwind: + last_space = space; + last_container = container; + QLIST_FOREACH(space, &vfio_address_spaces, list) { + QLIST_FOREACH(container, &space->containers, next) { + Error *err; + + if (space == last_space && container == last_container) { + break; + } + if (address_space_flat_for_each_section(space->as, + vfio_region_remap, + container, &err)) { + error_prepend(errp, "%s", error_get_pretty(err)); + error_free(err); + } + } + } + return -1; +} + +int vfio_cpr_load(Error **errp) +{ + VFIOAddressSpace *space; + VFIOContainer *container; + VFIOGroup *group; + VFIODevice *vbasedev; + + QLIST_FOREACH(space, &vfio_address_spaces, list) { + QLIST_FOREACH(container, &space->containers, next) { + if (!vfio_is_cpr_capable(container, errp)) { + return -1; + } + container->reused = false; + if (address_space_flat_for_each_section(space->as, + vfio_region_remap, + container, errp)) { + return -1; + } + } + } + QLIST_FOREACH(group, &vfio_group_list, next) { + QLIST_FOREACH(vbasedev, &group->device_list, next) { + vbasedev->reused = false; + } + } + return 0; +} diff --git a/hw/vfio/meson.build b/hw/vfio/meson.build index da9af29..e247b2b 100644 --- a/hw/vfio/meson.build +++ b/hw/vfio/meson.build @@ -5,6 +5,7 @@ vfio_ss.add(files( 'migration.c', )) vfio_ss.add(when: 'CONFIG_VFIO_PCI', if_true: files( + 'cpr.c', 'display.c', 'pci-quirks.c', 'pci.c', diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index e8e371e..64e2557 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -29,6 +29,7 @@ #include "hw/qdev-properties.h" #include "hw/qdev-properties-system.h" #include "migration/vmstate.h" +#include "migration/cpr.h" #include "qemu/error-report.h" #include "qemu/main-loop.h" #include "qemu/module.h" @@ -2899,6 +2900,7 @@ static void vfio_realize(PCIDevice *pdev, Error **errp) vfio_put_group(group); goto error; } + pdev->reused = vdev->vbasedev.reused; vfio_populate_device(vdev, &err); if (err) { @@ -3168,6 +3170,10 @@ static void vfio_pci_reset(DeviceState *dev) { VFIOPCIDevice *vdev = VFIO_PCI(dev); + if (vdev->pdev.reused) { + return; + } + trace_vfio_pci_reset(vdev->vbasedev.name); vfio_pci_pre_reset(vdev); @@ -3275,6 +3281,56 @@ static Property vfio_pci_dev_properties[] = { DEFINE_PROP_END_OF_LIST(), }; +static void vfio_merge_config(VFIOPCIDevice *vdev) +{ + PCIDevice *pdev = &vdev->pdev; + int size = MIN(pci_config_size(pdev), vdev->config_size); + g_autofree uint8_t *phys_config = g_malloc(size); + uint32_t mask; + int ret, i; + + ret = pread(vdev->vbasedev.fd, phys_config, size, vdev->config_offset); + if (ret < size) { + ret = ret < 0 ? errno : EFAULT; + error_report("failed to read device config space: %s", strerror(ret)); + return; + } + + for (i = 0; i < size; i++) { + mask = vdev->emulated_config_bits[i]; + pdev->config[i] = (pdev->config[i] & mask) | (phys_config[i] & ~mask); + } +} + +static int vfio_pci_post_load(void *opaque, int version_id) +{ + VFIOPCIDevice *vdev = opaque; + PCIDevice *pdev = &vdev->pdev; + + vfio_merge_config(vdev); + + pdev->reused = false; + + return 0; +} + +static bool vfio_pci_needed(void *opaque) +{ + return cpr_mode() == CPR_MODE_RESTART; +} + +static const VMStateDescription vfio_pci_vmstate = { + .name = "vfio-pci", + .unmigratable = 1, + .version_id = 0, + .minimum_version_id = 0, + .post_load = vfio_pci_post_load, + .needed = vfio_pci_needed, + .fields = (VMStateField[]) { + VMSTATE_END_OF_LIST() + } +}; + static void vfio_pci_dev_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); @@ -3282,6 +3338,7 @@ static void vfio_pci_dev_class_init(ObjectClass *klass, void *data) dc->reset = vfio_pci_reset; device_class_set_props(dc, vfio_pci_dev_properties); + dc->vmsd = &vfio_pci_vmstate; dc->desc = "VFIO-based PCI device assignment"; set_bit(DEVICE_CATEGORY_MISC, dc->categories); pdc->realize = vfio_realize; diff --git a/hw/vfio/trace-events b/hw/vfio/trace-events index 0ef1b5f..63dd0fe 100644 --- a/hw/vfio/trace-events +++ b/hw/vfio/trace-events @@ -118,6 +118,7 @@ vfio_region_sparse_mmap_header(const char *name, int index, int nr_areas) "Devic vfio_region_sparse_mmap_entry(int i, unsigned long start, unsigned long end) "sparse entry %d [0x%lx - 0x%lx]" vfio_get_dev_region(const char *name, int index, uint32_t type, uint32_t subtype) "%s index %d, %08x/%0x8" vfio_dma_unmap_overflow_workaround(void) "" +vfio_region_remap(const char *name, int fd, uint64_t iova_start, uint64_t iova_end, void *vaddr) "%s fd %d 0x%"PRIx64" - 0x%"PRIx64" [%p]" # platform.c vfio_platform_base_device_init(char *name, int groupid) "%s belongs to group #%d" diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index bf5be06..f079423 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -360,6 +360,7 @@ struct PCIDevice { /* ID of standby device in net_failover pair */ char *failover_pair_id; uint32_t acpi_index; + bool reused; }; void pci_register_bar(PCIDevice *pci_dev, int region_num, diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index cb04cc6..0766cc4 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -85,6 +85,7 @@ typedef struct VFIOContainer { Error *error; bool initialized; bool dirty_pages_supported; + bool reused; uint64_t dirty_pgsizes; uint64_t max_dirty_bitmap_size; unsigned long pgsizes; @@ -136,6 +137,7 @@ typedef struct VFIODevice { bool no_mmap; bool ram_block_discard_allowed; bool enable_migration; + bool reused; VFIODeviceOps *ops; unsigned int num_irqs; unsigned int num_regions; @@ -212,6 +214,9 @@ VFIOGroup *vfio_get_group(int groupid, AddressSpace *as, Error **errp); void vfio_put_group(VFIOGroup *group); int vfio_get_device(VFIOGroup *group, const char *name, VFIODevice *vbasedev, Error **errp); +int vfio_cpr_save(Error **errp); +int vfio_cpr_load(Error **errp); +bool vfio_is_cpr_capable(VFIOContainer *container, Error **errp); extern const MemoryRegionOps vfio_region_ops; typedef QLIST_HEAD(VFIOGroupList, VFIOGroup) VFIOGroupList; diff --git a/include/migration/cpr.h b/include/migration/cpr.h index 83f69c9..e9b987f 100644 --- a/include/migration/cpr.h +++ b/include/migration/cpr.h @@ -25,4 +25,7 @@ int cpr_state_load(Error **errp); CprMode cpr_state_mode(void); void cpr_state_print(void); +int cpr_vfio_save(Error **errp); +int cpr_vfio_load(Error **errp); + #endif diff --git a/linux-headers/linux/vfio.h b/linux-headers/linux/vfio.h index e680594..48a02c0 100644 --- a/linux-headers/linux/vfio.h +++ b/linux-headers/linux/vfio.h @@ -52,6 +52,12 @@ /* Supports the vaddr flag for DMA map and unmap */ #define VFIO_UPDATE_VADDR 10 +/* Supports VFIO_DMA_UNMAP_FLAG_ALL */ +#define VFIO_UNMAP_ALL 9 + +/* Supports VFIO DMA map and unmap with the VADDR flag */ +#define VFIO_UPDATE_VADDR 10 + /* * The IOCTL interface is designed for extensibility by embedding the * structure length (argsz) and flags into structures passed between diff --git a/migration/cpr.c b/migration/cpr.c index 72a5f4b..16f11bd 100644 --- a/migration/cpr.c +++ b/migration/cpr.c @@ -7,6 +7,7 @@ #include "qemu/osdep.h" #include "exec/memory.h" +#include "hw/vfio/vfio-common.h" #include "io/channel-buffer.h" #include "io/channel-file.h" #include "migration.h" @@ -108,7 +109,9 @@ void qmp_cpr_exec(strList *args, Error **errp) error_setg(errp, "cpr-exec requires cpr-save with restart mode"); return; } - + if (cpr_vfio_save(errp)) { + return; + } cpr_walk_fd(preserve_fd, 0); if (cpr_state_save(errp)) { return; @@ -148,6 +151,11 @@ void qmp_cpr_load(const char *filename, Error **errp) goto out; } + if (cpr_active_mode == CPR_MODE_RESTART && + cpr_vfio_load(errp)) { + goto out; + } + state = global_state_get_runstate(); if (state == RUN_STATE_RUNNING) { vm_start(); diff --git a/migration/target.c b/migration/target.c index 4390bf0..984bc9e 100644 --- a/migration/target.c +++ b/migration/target.c @@ -8,6 +8,7 @@ #include "qemu/osdep.h" #include "qapi/qapi-types-migration.h" #include "migration.h" +#include "migration/cpr.h" #include CONFIG_DEVICES #ifdef CONFIG_VFIO @@ -22,8 +23,21 @@ void populate_vfio_info(MigrationInfo *info) info->vfio->transferred = vfio_mig_bytes_transferred(); } } + +int cpr_vfio_save(Error **errp) +{ + return vfio_cpr_save(errp); +} + +int cpr_vfio_load(Error **errp) +{ + return vfio_cpr_load(errp); +} + #else void populate_vfio_info(MigrationInfo *info) {} +int cpr_vfio_save(Error **errp) { return 0; } +int cpr_vfio_load(Error **errp) { return 0; } #endif /* CONFIG_VFIO */ From patchwork Fri Aug 6 21:43:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12423989 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B86E9C4320A for ; Fri, 6 Aug 2021 22:20:23 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E673F61179 for ; Fri, 6 Aug 2021 22:20:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E673F61179 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:45760 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mC8CT-0000ze-JN for qemu-devel@archiver.kernel.org; Fri, 06 Aug 2021 18:20:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47378) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC862-00083Q-SB for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:42 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:51820) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC85z-0004MU-4V for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:42 -0400 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 176MBjek007308; Fri, 6 Aug 2021 22:13:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=nazt+pVIrvR7J5R+6KhuojhkbDmPVepyu7YKCsjds9U=; b=SNy128W3zpFhOy2FniIlatPKh7hF0dYmy8r7SZu3kxnPaxfbdayU7eC7JAJzvUkEu7ah DdbOc80SoulqlkPk6EoCIp+7aCzN61GBUgyguoCvRpKfDsjVT2A3BGhbynXnkp72rJ/q i+QNPa7efGdFMCuMPeGcjxPS44IOj34Lz7+l28Yw0o/Z+BW+AvIv7H7ZEa5BBuKI8jAq 9UXwGDWI98bi0t0DCLpi6fhFog22D8+ib/fX5iDvoGZHAlcdhhzJp2OofUgurP6ITBoz DQox2SyIVKUWWdcXTXLaIQNWEd64ZiZa5MdE1++p7+0fDCqT0tGoR03HUEOVqskFDsD7 4g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=nazt+pVIrvR7J5R+6KhuojhkbDmPVepyu7YKCsjds9U=; b=qB9SSLuMpu+rbSY1O8Caur+0SMMf1hFR6PVKGLLIgf6ols+KpwyboM3Pe0EjWZasB5T8 ex9ZbDmYjCB/2pjSGIFNNcbal84NytPrzn0TiZKvYfOYiGT9WiBlc5VZsHK9vpXXfTwJ gDiGbvjWy0KZqFWVJL57TeE7K67sGiA8CmWOtptAxbZRZJXSVGcP3lI6B0h8ZIRpwkxo Mls51GqZe0dGMFscOU0DM0SvEMdLEDzD4T8+7HAlAWIIi01XRFivm7lMcMesz6Z6lyr7 szDce0um3DaXhiS834hAFPTCve4pXqRJ/vyTV+v0VovluyTSF1p4BZcEO6UW1BnXCucS TA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3a8p6rjpmp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:33 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 176MBgJL181317; Fri, 6 Aug 2021 22:13:32 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2171.outbound.protection.outlook.com [104.47.57.171]) by userp3020.oracle.com with ESMTP id 3a5ga30fgn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:32 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CTE7Kuapz3YbVTdXirgxWX5COSgLzCALs6PLUHIbuU1kA3sNDMH+CnR+3h7a26WhNcB88bRUoYOcxQ2v7Qsmipy46OJVIsZ/ZuRlZfUZKa+ITkb6j8f2WA7nWEtWdv6poq3g+avie6qbfVEUNK5MohsvLPmADnhIvGkI1Fk74FWWLn+gpxCSGOW8i17mR18S6btd6dV8RzqflcDEOL/vD2iVgdh5Nv/G38qspGJJkBNtSv+0lOwkokKDyVAq8RCrOL+BhedOLFDUPOnxq7UlWwt7pSFLTI9x5PjosAevIXSGyKn3R5uhaBhU0+NdNfmJ3BNxRlkn8/+cI0qMmsA05Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nazt+pVIrvR7J5R+6KhuojhkbDmPVepyu7YKCsjds9U=; b=HwsTSRhxbONzDpTinYX+XvTPIeP4pIHHAXaV6nV/rqJlx1e04Ynm8076x29mMYtQG5+gFpLSsPTVn8Fw5ZJ7PELDwrsrTpOJEB+7rrE0ixQuL69mnvrKQnl1YQGKTPIkh2V/5ndp6D3bSefgefhh9Du/K/Fwp/wKfPKh4IQ+HzG0RqpTcxbvAIcrWtUDwJSpGs1XJrBZRhe74GbCwciKiwrcJkl4w04dRV0XIBbMHB8TzzjAHWeW9JnUaGqRmwdIZw6dhC4d4pkUpTTf9gyOge+zyipkFdeyB5/1wyNPnRdgoNXA6U1lM6P6Dvx4IbgrbqPbieoLCB40xopPpv3Whg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nazt+pVIrvR7J5R+6KhuojhkbDmPVepyu7YKCsjds9U=; b=IEyC51gNnWqlxn3Xw8Q0tfxe8NapNM8GBzYQouwwKymFAitq8g1a/O4RRGI25Gr7NbIrfjEFvb2IOWhffBHRJaMgaD/oC+h5DE6HGb9QaGuXiGl19R8b3n4kU15r3ZDybc7nTnvraLibPOUbbuLoB6IQuI3e7fbf+MH2Z6S11Bs= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) by BY5PR10MB4129.namprd10.prod.outlook.com (2603:10b6:a03:210::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.17; Fri, 6 Aug 2021 22:13:30 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3%5]) with mapi id 15.20.4373.028; Fri, 6 Aug 2021 22:13:30 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V6 20/27] vfio-pci: cpr part 2 (msi) Date: Fri, 6 Aug 2021 14:43:54 -0700 Message-Id: <1628286241-217457-21-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> References: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) To BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ca-dev63.us.oracle.com (148.87.23.7) by SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Fri, 6 Aug 2021 22:13:28 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 994eccc1-cb83-4c86-280f-08d959276c0b X-MS-TrafficTypeDiagnostic: BY5PR10MB4129: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:108; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AgDRsA+4L6qekOAhF6317Ov+cfSCHslHps97lFYu0CH4mZoVutdy9Q6+xnHqF7iCHd6NrtuN0j+X2fKG1oU0vmGUNrMscgN13oxlRZ1ZXD+qdgRXQLsuX9stGadr2W+UpUK4QhvKP5ROsguVX+cCPn1kL7IIHmme/luEqYROL70YVvN/DT19fj6UcBwmdMvfF9rxKCrT15SSf+8Bqcw+n3ved8qNQTkxiBLGwldx+wYYbMt58fBZaJfbvXNZpABDAD7Gequhy4POgE2Ege8XDYeQ7W+1H7xOUuxk+h+rx5xp6AZM5j/V2fQESxvNSBwVON+8fb3r6txXsdsjpdAVB2kZtLaZ/W85ROgA40kjHvAE5R2Q556DbEIp0GSZlYYoHRoXaCcSfJDeDhvEA/Bc9z7vCg/V8K4yc9rqsZCzrIqGX8PEWaECVv5F0MGdaytUgDOazl/Wl52ZV5pvO1imtUYrT343Zg+7hjeJnrDhwDE0pb64iZ9SoYupTyzphTF9K80+B2CKMAn8ZK1iC2X/JHpW9KeijBWkPsqNi+QUrWp4y1/gVF54NL0G5GhCZZsaWIbzxs25DbBg6fKqRcizmj+zvdb8JZgEZvlR2ToLJ3MKIBYdX/OgZcERXuoQ4FL+5zcNFIFWYMRmv1zfN45EubQnJXigh1kbnakA7MFXw10YQtJvPqH57HYZRYzbpMsgp4C2l8DGnsBl8V8gvghZFw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(396003)(39860400002)(366004)(346002)(376002)(66946007)(66556008)(956004)(2616005)(316002)(7416002)(38350700002)(8936002)(478600001)(66476007)(36756003)(86362001)(38100700002)(5660300002)(54906003)(8676002)(4326008)(6486002)(7696005)(52116002)(186003)(2906002)(6666004)(107886003)(6916009)(26005)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: k+WqG4fck+IThUw3RUlPcJG7YsWlAZK64Hw7KsW3soqIXyMjukVBIqQ3sk5vBFlI0vjO88dQ3z4/tv4VCG2NqBTKestY2vyaZvEABNyAQqUuZdRj6l53VYyAjaWKUAnHKkB4+Z5xGwhohp1enYF+SQMJKIVnJpFWJarYrhP2HsvfXhvtv+GJvnMUhWESSl37ZBs61bvM+CKdXKnEhgp6aF/FHoHSQYz8Qyih97dBVNl9Kn1uoEBwV1rXXR5xyWmEuLH3oMJKXnBHrHlmFLBA5CGj3fvOoi+g/IE1e7bND2WrJhr4ogUUv9a4eM2NclkeavaPyKskuMSskV5DZvvh7XlU6A7GzDApUAgJ/1NJdX61OElfzcldUEr35oj+kUhgtHvXJIbZ6cFnq5OECcE3IHYHRcMkmUkg+gANvxpMU22Mpe5zAXh3DHmi1fJo7Z0kV8LxHDtEAZFHHxVy4FxrlU7Ps5zJJ5hs9W5sKzyOK572lJZzKceHRPfIXy3+fQHJqeNv7nVmSz3dRfDJSOhKpOFPhXaYSx/Vb4ZTe3af4z/M9+TkOdYH0ZdNuaVAQIQMvMkQSZyq/zu9mUDoOQ9ln5lpUn0kvMMas+QTF/uBU7r/aec1tlJUjM3SM1UktRcOtdwXYkYjeg0/5xv1YCPBveuAkuwEIZ3QXdwLd97YMNSvutXEp6KE9rRqO/Zv0CRH/Mz9uphOuLXOHekkk36B20e2TiSGyBcLkLpWASsLtv2Os51u+O4aEI1L4mWLc5fZMx7HqL0QkeJma+B0DqoYpcI9EmAj6ptYeN+CMY/dJWqgAKfUNdi5cSEq8tiU8hZR1YhsvZ24Mx1WseG9Dk5PyCqM+yS2fYBCUdgQqt56vN8RYofR5tt+zi02Tp63B4R0TezogifbsxC97m452SMu8qXauvzP/BcbApesZG6WFVP+lX/1AE1j9rYQGmKHPgguXgpt5L1N+ZSMQTEiGmOLk+BYUQVgrudaXFIKevlXM3s02uP4bHCQK3Js60TfgnDTOr3Unsnl5UP6DuqO1vUbiotpjkMmghK072l+gy8yskRIUAlR683Du+OSzcLzpQe2G+l1Im0HCpAtnakaxsV9bfj3UhJxQlazgf0y66H9ya1NLp0/lnmYH/vFDrnvke43Qp7n49lRjqxWhyY2P1vu8Fw5fE68gJN2n/7CkW6Ui+t/8i5Q15WfuTxh/vEX5JHYaW2nPueSNi/PyDJt5OSXsm/OY0dY5RhTPqyzmHFDFtTFWF/eeFqJyTGOzZB+I7pNiSrNTdC3eIruGEy78BV41h95XUQ+j1ho9EV80g+KlEKIGN5LDtpQ5Zi0/n+N6qcR X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 994eccc1-cb83-4c86-280f-08d959276c0b X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2021 22:13:30.2452 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: q19uzGwBVVLOPl1xVEYI6Mca7danTdu+c1bEyBOiAi8AHBQFCmljjxpYtbIvCwWbqlSzXg89JqB1jj+c0MIhMmWxfMzJkwomO/Iyz2C2rBA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4129 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10068 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 phishscore=0 spamscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108060145 X-Proofpoint-ORIG-GUID: yC7uqWXHvP3AVk-pqqNzu2i8k8-aY_Mk X-Proofpoint-GUID: yC7uqWXHvP3AVk-pqqNzu2i8k8-aY_Mk Received-SPF: pass client-ip=205.220.165.32; envelope-from=steven.sistare@oracle.com; helo=mx0a-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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , Jason Zeng , =?utf-8?q?Alex_Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Zheng Chuan , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Finish cpr for vfio-pci MSI/MSI-X devices by preserving eventfd's and vector state. Signed-off-by: Steve Sistare --- hw/vfio/pci.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 107 insertions(+), 1 deletion(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 64e2557..1cee52a 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -49,11 +49,31 @@ static void vfio_disable_interrupts(VFIOPCIDevice *vdev); static void vfio_mmap_set_enabled(VFIOPCIDevice *vdev, bool enabled); +static void save_event_fd(VFIOPCIDevice *vdev, const char *name, int nr, + EventNotifier *ev) +{ + int fd = event_notifier_get_fd(ev); + + if (fd >= 0) { + g_autofree char *fdname = + g_strdup_printf("%s_%s", vdev->vbasedev.name, name); + cpr_save_fd(fdname, nr, fd); + } +} + +static int load_event_fd(VFIOPCIDevice *vdev, const char *name, int nr) +{ + g_autofree char *fdname = + g_strdup_printf("%s_%s", vdev->vbasedev.name, name); + int fd = cpr_find_fd(fdname, nr); + return fd; +} + /* Create new or reuse existing eventfd */ static int vfio_named_notifier_init(VFIOPCIDevice *vdev, EventNotifier *e, const char *name, int nr) { - int fd = -1; /* placeholder until a subsequent patch */ + int fd = name ? load_event_fd(vdev, name, nr) : -1; if (fd >= 0) { event_notifier_init_fd(e, fd); @@ -2709,6 +2729,10 @@ static void vfio_register_err_notifier(VFIOPCIDevice *vdev) fd = event_notifier_get_fd(&vdev->err_notifier); qemu_set_fd_handler(fd, vfio_err_notifier_handler, NULL, vdev); + if (vdev->pdev.reused) { + return; + } + if (vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_ERR_IRQ_INDEX, 0, VFIO_IRQ_SET_ACTION_TRIGGER, fd, &err)) { error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); @@ -2774,6 +2798,11 @@ static void vfio_register_req_notifier(VFIOPCIDevice *vdev) fd = event_notifier_get_fd(&vdev->req_notifier); qemu_set_fd_handler(fd, vfio_req_notifier_handler, NULL, vdev); + if (vdev->pdev.reused) { + vdev->req_enabled = true; + return; + } + if (vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_REQ_IRQ_INDEX, 0, VFIO_IRQ_SET_ACTION_TRIGGER, fd, &err)) { error_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); @@ -3302,13 +3331,87 @@ static void vfio_merge_config(VFIOPCIDevice *vdev) } } +static int vfio_pci_pre_save(void *opaque) +{ + VFIOPCIDevice *vdev = opaque; + PCIDevice *pdev = &vdev->pdev; + int i; + + if (vfio_pci_read_config(pdev, PCI_INTERRUPT_PIN, 1)) { + assert(0); /* completed in a subsequent patch */ + } + + for (i = 0; i < vdev->nr_vectors; i++) { + VFIOMSIVector *vector = &vdev->msi_vectors[i]; + if (vector->use) { + save_event_fd(vdev, "interrupt", i, &vector->interrupt); + if (vector->virq >= 0) { + save_event_fd(vdev, "kvm_interrupt", i, + &vector->kvm_interrupt); + } + } + } + save_event_fd(vdev, "err", 0, &vdev->err_notifier); + save_event_fd(vdev, "req", 0, &vdev->req_notifier); + return 0; +} + +static void vfio_claim_vectors(VFIOPCIDevice *vdev, int nr_vectors, bool msix) +{ + int i, fd; + bool pending = false; + PCIDevice *pdev = &vdev->pdev; + + vdev->nr_vectors = nr_vectors; + vdev->msi_vectors = g_new0(VFIOMSIVector, nr_vectors); + vdev->interrupt = msix ? VFIO_INT_MSIX : VFIO_INT_MSI; + + for (i = 0; i < nr_vectors; i++) { + VFIOMSIVector *vector = &vdev->msi_vectors[i]; + + fd = load_event_fd(vdev, "interrupt", i); + if (fd >= 0) { + vfio_vector_init(vdev, "interrupt", i); + qemu_set_fd_handler(fd, vfio_msi_interrupt, NULL, vector); + } + + if (load_event_fd(vdev, "kvm_interrupt", i) >= 0) { + vfio_add_kvm_msi_virq(vdev, vector, "kvm_interrupt", i, msix); + } + + if (msix && msix_is_pending(pdev, i) && msix_is_masked(pdev, i)) { + set_bit(i, vdev->msix->pending); + pending = true; + } + } + + if (msix) { + memory_region_set_enabled(&pdev->msix_pba_mmio, pending); + } +} + static int vfio_pci_post_load(void *opaque, int version_id) { VFIOPCIDevice *vdev = opaque; PCIDevice *pdev = &vdev->pdev; + int nr_vectors; vfio_merge_config(vdev); + if (msix_enabled(pdev)) { + nr_vectors = vdev->msix->entries; + vfio_claim_vectors(vdev, nr_vectors, true); + msix_init_vector_notifiers(pdev, vfio_msix_vector_use, + vfio_msix_vector_release, NULL); + + } else if (msi_enabled(pdev)) { + nr_vectors = msi_nr_vectors_allocated(pdev); + vfio_claim_vectors(vdev, nr_vectors, false); + + } else if (vfio_pci_read_config(pdev, PCI_INTERRUPT_PIN, 1)) { + assert(0); /* completed in a subsequent patch */ + } + pdev->reused = false; return 0; @@ -3325,8 +3428,11 @@ static const VMStateDescription vfio_pci_vmstate = { .version_id = 0, .minimum_version_id = 0, .post_load = vfio_pci_post_load, + .pre_save = vfio_pci_pre_save, .needed = vfio_pci_needed, .fields = (VMStateField[]) { + VMSTATE_PCI_DEVICE(pdev, VFIOPCIDevice), + VMSTATE_MSIX_TEST(pdev, VFIOPCIDevice, vfio_msix_present), VMSTATE_END_OF_LIST() } }; From patchwork Fri Aug 6 21:43:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12424007 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3EDD4C4338F for ; Fri, 6 Aug 2021 22:25:54 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6B7D961050 for ; Fri, 6 Aug 2021 22:25:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6B7D961050 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:34138 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mC8Ho-0003yW-DV for qemu-devel@archiver.kernel.org; Fri, 06 Aug 2021 18:25:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47558) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC870-0002hU-Sq for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:14:42 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:2470) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC86y-0004z5-PA for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:14:42 -0400 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 176MBhkK032541; Fri, 6 Aug 2021 22:13:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=dwbtd9Y8G35jDOZzwkslOyk3801OUh4E/B3FjwuKJs4=; b=08ubusd7AxW5yKmRtFBlJ/VJUcdtUADAMSe38AmjjvtzCawQ/U7P0Q5AIWypQiAC/cQ3 X2MqPwsODN89SlcUs1D9LLnQvZ/nkzEfUc5sDaRlaZGwV1Wdmgp1U5m6sKwx1PMr3Skp Bs1iuIxxh9mv5fSEe6z6GhrP/T7Fvyfr9QetcwPLSopKp+8QhizV/Qp8KKYfqU97ZjfW 9H8ksQN4Hr7iwBooNU5DvC5TuFNM64FY5fjEq2QszSnJvBOtz0o/oLcu4tLCcoC96gmk NzSQer6sgWIxnS4ldpM95oEDHtmLrWZmUN6uLKPtdcHmgSgozFZjeMSWYcJpqzVFRc0b Lg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=dwbtd9Y8G35jDOZzwkslOyk3801OUh4E/B3FjwuKJs4=; b=VLynKkMlR4HiwIj/ngpDmfAadFN/VFqYe7RYhy83Dx/C5yRSY6IiR745D97MkKT/aGXE eXtoQyXXhsetGic9l3B0OZA38rQ30J0r+WGIe9r5VxHZA2qy41kMam0UBKf5aqY2Xjip 3wuI4v9EKddJfx40MTY9qXiMMkvBxWQTgBCqjvYX7EE5rHUcnXtodqksJCnhc4T2XmUk eiAiFkqpithYNg/vqM4TU8wsibu60rrI7qBBsn+/iHE17USN44aU7ZWcgDzgkkuwbsya Kf7DKFqMvYxHgjjElYfvEkwMNQ+KYhWgLydGYLW7p6kXErGqQqvqkRvK+vnfECkITHKE aA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3a9661s140-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:35 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 176MBiKO013845; Fri, 6 Aug 2021 22:13:34 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2175.outbound.protection.outlook.com [104.47.57.175]) by userp3030.oracle.com with ESMTP id 3a962pfb69-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f/ANx/mQZcDs8QgZwjC4puPnPSh1LCxBwvzDGXVBqnjt5Lb6bYW6UXN1haMuEwYMfKjhDihtZbFGcIoCCV3KtoGCP6sIoX24xMu5MtHh7FuLF7R3oxCdMfgtIZrtEpXjwNpRnG2d1h7sR1YdeToGHpNQQ9meXEq42suln/osizmVFmJ5/gjhFH2Q86tY8OaqzEBeblZIrU8hm0UjkBZeVBH8fPKsmCu/0/zC5+r06ndyB0NUr4tKsUY9wr5Ho0M+dTil5YWDfnflNjXGClH3r40DDODYrWsl77ewEVu+KIiWKAXviiRClfCdA6TJX8h3coo92dWPqLa+4MQAkfabNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dwbtd9Y8G35jDOZzwkslOyk3801OUh4E/B3FjwuKJs4=; b=DrDjURx7IIT7n5PRqmNjCWtaksWloagjwzAlzFjr0At34xTBtuUz+W6v0WnGbEsKCyoZR8pB79cgb6wYsLPKAquWpEt+2BtnA2c+O9zAtbfRoqxa22yD3xtKm42SgwRraYwUpKcjbD6PcN6HtIGRgTKKSA4mmL3gFMBo4Rsdola9aFHUJ7rxjRmYRZY4efuYSmEShyF1TGkea3EhyR3PUkgHFXCCkUyziXWJAQusB+Fg1AMAw9Rx04UedsELeWbUmjyTZ4xOd83sdt5okon7KtLObyg4Ggq0MrbdWUcHFOXhYWlGU69ese2uitTuqju2uwhS28YtRDzHgRJO3kqxhA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dwbtd9Y8G35jDOZzwkslOyk3801OUh4E/B3FjwuKJs4=; b=mBQnkOFnivxoBx3+QQQFW7aLz7DtGmzlPbzUMDS5MJnXpdsVye9njHPd8CNP9HNvozZJld1VAZESwkRKyqlFeCevmQYv4nArzZkzSo8v8Wh+VGObkZDrVMHOwuYR5Q5SlHcq6/H5aHNmJKkq+QghXN139fXmOl80LExqjximH7E= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) by BY5PR10MB4129.namprd10.prod.outlook.com (2603:10b6:a03:210::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.17; Fri, 6 Aug 2021 22:13:32 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3%5]) with mapi id 15.20.4373.028; Fri, 6 Aug 2021 22:13:32 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V6 21/27] vfio-pci: cpr part 3 (intx) Date: Fri, 6 Aug 2021 14:43:55 -0700 Message-Id: <1628286241-217457-22-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> References: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) To BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ca-dev63.us.oracle.com (148.87.23.7) by SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Fri, 6 Aug 2021 22:13:30 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a4018c54-b06c-4ab1-36ed-08d959276d2d X-MS-TrafficTypeDiagnostic: BY5PR10MB4129: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BI2Pt2zJlHZGQnpyYPonNe6Z6VlNLE4SAU/ncdauYtkHzsUZWZcf63mNxq/hce+xpXWHkw38LcHHcMiNXeMIXK5Bvh68eNdfOvSf3c7Ncgac7/baqh1xRFPso+7OFW1rBpciFiYqxtgm5/3tKjHGZmnJDPQpswessy6eOQNaTxsVe7g4fAd3bYc/bcveHUXl/62dQS08kKMKTxo5fI90cq+UwlYZS14xNPEW+Y/Feb4GcKbO7T8REUCi7SfMreSw0lEajKjK5sSpCsiGeNNu4+drsRuRTsPESGybcCSSzi2kYA4J/anhOS3TObdMQUHM8j0VvwjU8HUqGubj2OtE5RPuBX4SowMWm5+NPWoukuZdlHvOeI9P3PDwJ3pl6lvWq3tNo3a6KMUhIHNeJUPi6N34ZOltH0NzhfU2mraYe2bh5XND0/ZQgUnPXOLWIiaN+B1rS9geSQwy3b8/25aGSpOr9VY7S73FOyQDub38RkmaHRj5NSR7C1k0NYBpilDTZ9tmhM9mfWDZ55clSdJBjXOKcPceTbb6IWdnEGtrDnxUk9HNpOXbp59FdwCuBXq7ABZGB5d6KnaljoCTLjlxU3Y6S1zSNtFC6++Fqjs3whdg2vC6rU8eLWUpxkenCrqjOGnzmg/jcxgPwn+3LBUjWg5URLbvMPHn8X3BAAseJaJuVZkPpC7H99l0d5O9zB9Yt0XFmYggrDN2YYfhhROgIA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(396003)(39860400002)(366004)(346002)(376002)(66946007)(66556008)(956004)(2616005)(316002)(7416002)(38350700002)(8936002)(478600001)(66476007)(36756003)(86362001)(38100700002)(5660300002)(54906003)(8676002)(4326008)(6486002)(7696005)(52116002)(186003)(2906002)(6666004)(107886003)(6916009)(26005)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: vqd5VShlrmosXQej+9uxJ/U5CeerAUYg5kSFzrcjcGhm1S3SEmFSzhdEMN4OuwnMBph/n3Zq1xHdRMV8zOE+laYURhVPuHI+cTWBzs+SdiVY/Uo1BsryTYbA+VqjnQvraquXVIkQz80fuZCdhh5RY7VN2GmQrCS2cmKiITRJGXsPlN0Gz4yFhD5vdLMsguFnFD3cM2dbupuUFuMJoxPkjLVMAF6XYoZTNR5dRoL5+PDN7v6NLJO1cj62VtKDczdV3zb+KTL3iabBngORxopmA18ctBpOVQlke0GmhTkQBwGUL8yCZFDyVb+7WDlfdVcZQDJgiT6hiYa4iIx6htMJKm7V3RkL9xQzwR06qgl96MRJMynCdL7rFU8y8hhazOfSubX6nAW3hJ8Ge9XhqWWOQoyb67zDekM7nkgt1duufn7jyeHicdybrbuc0+JXOQiQok0tweRqP8q2rqxz71fx4YNhUZSUQF2OeSXTwKxAsuJZYwF3kNOQ4H/Yv1o300Dsf/YkgBBRbO1c+P/XKa1HM0VzZ3uWN8hzrY6piev/xJ7bVz2Q2Bn3ZD6hQ2nWUb3a87uewOhlLb5kgvvpNSNcLaHPSNdVlTe8dS0W22gGQCeELWmxbd53q0DxrK/WM10x6aZkYgwGvmb8XPVWHqnPdKeBeGcIPK2147Tm1ICtPaO8jBrSuhXAXtmOMCh0WXPwexrapXwiouL+72m1NeaTPzsz7pu9GQc2HzXhK+Brx3liE1JLcPLjA7v0IPtSeyCx+SW8ls+XfCqdOuGc7BpWSX9oLlzOmhiTyhU7qE3wUJeqy7YtBMdf/NHgUUfxwVujvqgDifTu3Gcqnn30OB0WEC6SwsZRzQoC9lyvEYgi1+FbROxKPezvRh0ns0M0VcKQAoLj/1a1smvSjL53njwDr0o4FomOrMAoAIcPhy92uhTaZnXg/VZmkzcUPPpAH1+y4DWEP1f1qWuWK5cTA4zXPDG7mLBBbAJdGQiR5FEDp4mCckcabKaD8kV4qX4S8Buz8TU5/1E+l0cCqkCL2vsNW9PR7J8dxawNo5BJ+sl3PN5QspDAHOH/WAMb86l6NwVJayleINBRTjCJj1BA/rsZHeKGXa7tte9L3Q4wcjd5Qk/NUesdCRpGlYx67McS3mLAWtPOFdm+o2OhJuWgeIEeOLIAU2gAaz2r2anXAqaBLPmoICpBbOkbHT4bgY7QFIYJRpMH7D7EBVgvCNDiDo3vu34cJlMlgQO0JJpzVX3tHTtVssirTJpur0iSmVwDH9v+R7b3DX7w6DRdw65g70pIngQKrfMkXJV0lzhXXKbUyxt4QSDcbJ3WPuOh/orM5okC X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a4018c54-b06c-4ab1-36ed-08d959276d2d X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2021 22:13:32.1281 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: g9KeHXALa54SlbXypah39k8tFMLQRAh1UVqj5TLD3KA+xrnTWACIKOOGERGIdrhs3Rnia0U7+m001UXLQrsETwX8pbxazIgoPZerNtroKjs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4129 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10068 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 phishscore=0 bulkscore=0 adultscore=0 suspectscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108060145 X-Proofpoint-GUID: s_ykErTRxxu5E_XZtRakmK8dEHf1CiCS X-Proofpoint-ORIG-GUID: s_ykErTRxxu5E_XZtRakmK8dEHf1CiCS 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , Jason Zeng , =?utf-8?q?Alex_Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Zheng Chuan , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Preserve vfio INTX state across cpr restart. Preserve VFIOINTx fields as follows: pin : Recover this from the vfio config in kernel space interrupt : Preserve its eventfd descriptor across exec. unmask : Ditto route.irq : This could perhaps be recovered in vfio_pci_post_load by calling pci_device_route_intx_to_irq(pin), whose implementation reads config space for a bridge device such as ich9. However, there is no guarantee that the bridge vmstate is read before vfio vmstate. Rather than fiddling with MigrationPriority for vmstate handlers, explicitly save route.irq in vfio vmstate. pending : save in vfio vmstate. mmap_timeout, mmap_timer : Re-initialize bool kvm_accel : Re-initialize In vfio_realize, defer calling vfio_intx_enable until the vmstate is available, in vfio_pci_post_load. Modify vfio_intx_enable and vfio_intx_kvm_enable to skip vfio initialization, but still perform kvm initialization. Signed-off-by: Steve Sistare --- hw/vfio/pci.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 83 insertions(+), 11 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 1cee52a..7e59f4f 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -145,14 +145,45 @@ static void vfio_intx_eoi(VFIODevice *vbasedev) vfio_unmask_single_irqindex(vbasedev, VFIO_PCI_INTX_IRQ_INDEX); } +#ifdef CONFIG_KVM +static bool vfio_no_kvm_intx(VFIOPCIDevice *vdev) +{ + return vdev->no_kvm_intx || !kvm_irqfds_enabled() || + vdev->intx.route.mode != PCI_INTX_ENABLED || + !kvm_resamplefds_enabled(); +} +#endif + +static void vfio_intx_reenable_kvm(VFIOPCIDevice *vdev, Error **errp) +{ +#ifdef CONFIG_KVM + if (vfio_no_kvm_intx(vdev)) { + return; + } + + if (vfio_named_notifier_init(vdev, &vdev->intx.unmask, "intx-unmask", 0)) { + error_setg(errp, "vfio_named_notifier_init failed"); + return; + } + + if (kvm_irqchip_add_irqfd_notifier_gsi(kvm_state, + &vdev->intx.interrupt, + &vdev->intx.unmask, + vdev->intx.route.irq)) { + error_setg_errno(errp, errno, "failed to setup resample irqfd"); + return; + } + + vdev->intx.kvm_accel = true; +#endif +} + static void vfio_intx_enable_kvm(VFIOPCIDevice *vdev, Error **errp) { #ifdef CONFIG_KVM int irq_fd = event_notifier_get_fd(&vdev->intx.interrupt); - if (vdev->no_kvm_intx || !kvm_irqfds_enabled() || - vdev->intx.route.mode != PCI_INTX_ENABLED || - !kvm_resamplefds_enabled()) { + if (vfio_no_kvm_intx(vdev)) { return; } @@ -300,7 +331,9 @@ static int vfio_intx_enable(VFIOPCIDevice *vdev, Error **errp) return 0; } - vfio_disable_interrupts(vdev); + if (!vdev->pdev.reused) { + vfio_disable_interrupts(vdev); + } vdev->intx.pin = pin - 1; /* Pin A (1) -> irq[0] */ pci_config_set_interrupt_pin(vdev->pdev.config, pin); @@ -316,7 +349,8 @@ static int vfio_intx_enable(VFIOPCIDevice *vdev, Error **errp) } #endif - ret = event_notifier_init(&vdev->intx.interrupt, 0); + ret = vfio_named_notifier_init(vdev, &vdev->intx.interrupt, + "intx-interrupt", 0); if (ret) { error_setg_errno(errp, -ret, "event_notifier_init failed"); return ret; @@ -324,6 +358,11 @@ static int vfio_intx_enable(VFIOPCIDevice *vdev, Error **errp) fd = event_notifier_get_fd(&vdev->intx.interrupt); qemu_set_fd_handler(fd, vfio_intx_interrupt, NULL, vdev); + if (vdev->pdev.reused) { + vfio_intx_reenable_kvm(vdev, &err); + goto finish; + } + if (vfio_set_irq_signaling(&vdev->vbasedev, VFIO_PCI_INTX_IRQ_INDEX, 0, VFIO_IRQ_SET_ACTION_TRIGGER, fd, errp)) { qemu_set_fd_handler(fd, NULL, NULL, vdev); @@ -336,6 +375,7 @@ static int vfio_intx_enable(VFIOPCIDevice *vdev, Error **errp) warn_reportf_err(err, VFIO_MSG_PREFIX, vdev->vbasedev.name); } +finish: vdev->interrupt = VFIO_INT_INTx; trace_vfio_intx_enable(vdev->vbasedev.name); @@ -3092,9 +3132,13 @@ static void vfio_realize(PCIDevice *pdev, Error **errp) vfio_intx_routing_notifier); vdev->irqchip_change_notifier.notify = vfio_irqchip_change; kvm_irqchip_add_change_notifier(&vdev->irqchip_change_notifier); - ret = vfio_intx_enable(vdev, errp); - if (ret) { - goto out_deregister; + + /* Wait until cpr-load reads intx routing data to enable */ + if (!pdev->reused) { + ret = vfio_intx_enable(vdev, errp); + if (ret) { + goto out_deregister; + } } } @@ -3338,7 +3382,8 @@ static int vfio_pci_pre_save(void *opaque) int i; if (vfio_pci_read_config(pdev, PCI_INTERRUPT_PIN, 1)) { - assert(0); /* completed in a subsequent patch */ + save_event_fd(vdev, "intx-interrupt", 0, &vdev->intx.interrupt); + save_event_fd(vdev, "intx-unmask", 0, &vdev->intx.unmask); } for (i = 0; i < vdev->nr_vectors; i++) { @@ -3395,6 +3440,7 @@ static int vfio_pci_post_load(void *opaque, int version_id) VFIOPCIDevice *vdev = opaque; PCIDevice *pdev = &vdev->pdev; int nr_vectors; + int ret = 0; vfio_merge_config(vdev); @@ -3409,12 +3455,37 @@ static int vfio_pci_post_load(void *opaque, int version_id) vfio_claim_vectors(vdev, nr_vectors, false); } else if (vfio_pci_read_config(pdev, PCI_INTERRUPT_PIN, 1)) { - assert(0); /* completed in a subsequent patch */ + Error *err = 0; + ret = vfio_intx_enable(vdev, &err); + if (ret) { + error_report_err(err); + } } pdev->reused = false; - return 0; + return ret; +} + +static const VMStateDescription vfio_intx_vmstate = { + .name = "vfio-intx", + .unmigratable = 1, + .version_id = 0, + .minimum_version_id = 0, + .fields = (VMStateField[]) { + VMSTATE_BOOL(pending, VFIOINTx), + VMSTATE_UINT32(route.mode, VFIOINTx), + VMSTATE_INT32(route.irq, VFIOINTx), + VMSTATE_END_OF_LIST() + } +}; + +#define VMSTATE_VFIO_INTX(_field, _state) { \ + .name = (stringify(_field)), \ + .size = sizeof(VFIOINTx), \ + .vmsd = &vfio_intx_vmstate, \ + .flags = VMS_STRUCT, \ + .offset = vmstate_offset_value(_state, _field, VFIOINTx), \ } static bool vfio_pci_needed(void *opaque) @@ -3433,6 +3504,7 @@ static const VMStateDescription vfio_pci_vmstate = { .fields = (VMStateField[]) { VMSTATE_PCI_DEVICE(pdev, VFIOPCIDevice), VMSTATE_MSIX_TEST(pdev, VFIOPCIDevice, vfio_msix_present), + VMSTATE_VFIO_INTX(intx, VFIOPCIDevice), VMSTATE_END_OF_LIST() } }; From patchwork Fri Aug 6 21:43:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12424011 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6901C432BE for ; Fri, 6 Aug 2021 22:27:27 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2DA1D6113C for ; Fri, 6 Aug 2021 22:27:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 2DA1D6113C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:42018 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mC8JK-0000yp-6i for qemu-devel@archiver.kernel.org; Fri, 06 Aug 2021 18:27:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47398) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC864-00089P-CX for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:44 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:56974) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC862-0004OY-LN for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:44 -0400 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 176MBPFi029961; Fri, 6 Aug 2021 22:13:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=biDqY0Q/Fv1zFLC8JgiEyiyUXIcCxUjJwR37bRrNLDM=; b=W1yWvVaG5Xglt2nZtOG/f3Gc5Kg2BvnYwWH7KtYFSOh6j3q+aGGtd7i7RIwx9TlT5CFP O9p1crsyyEt1xx6PKi5r+Aja1PxRQKFNHUHmJZkrqJVVs3AoQQCotiglZwWFeSU48366 UcEHZH8W8c1j84KYbh4pIZcQpmXHK0c2eW5QvnCL6qvIhbo8i7BAqtjcyR6iHyyLUw7V AW4QutYdkT0PELWToDrG+a0StKg/Vwe3SDes1lEOaxg/lyL7G/ypIjeLZdOhSfLxiClv cAL47oHNaRcAetWv5GfF2bvuzkSCSSidpU9TT0nhkeCfhieEQjDbRp6VXyiaPmvuSf92 lA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=biDqY0Q/Fv1zFLC8JgiEyiyUXIcCxUjJwR37bRrNLDM=; b=fMU4G8vpaR+Fj8piYIwu2ffSJTiTH6Atu4OOLUPGlVaOoL1aaz+1DiMxYCntAZJcscAx MVl5PYWq/Gex1JMlbEGFjiiIaD9hxdWkMl0Lt9MFbdp5hUp3QsGCWBcz/qWFf5MKMt96 r+PGCJHMZfSeyPxJIbXSvvzqSdyJw1ykoqMhTS2OmGv58ADEmk5pyyBI4/FBqL8awdz8 PL/OpvI+Ed3gFi2taFUfTPuSJvW9pzNsr2v0xPclS6zFDQCiYcP3KpKQTDf7NVwhdtGI as/HotQBvLLX2NYVVoKJ2+lHsN1xFMgdOBx7QfCnOrueV7wKhnFy61q98fm2c8AepO0m jw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3a90justqk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:37 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 176MBi32181498; Fri, 6 Aug 2021 22:13:36 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2177.outbound.protection.outlook.com [104.47.57.177]) by userp3020.oracle.com with ESMTP id 3a5ga30fj3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IZmW22FhtnlpDqhwl8EJnx+4/fHit12frDtUgVxwVMGznljGVX7gmm2h9zoagDhHUsuq2OGD46stOI/v72XMLd6RdgFQMDyrxMZsoVm7cK7VKproCps2lxL4bAL2BmbCvEaLiM39NW8edDnGYpKWJAVB6Zflm9qKGDW3am0pKvFlXC88x/8SSIeBcEXLX+Hcd9iFpbLEf7FgMIqpB3/npcz+VxgRGGEN/cv5HxBSvVP7E3PC90KzwKtWxldH0Bv5pAZye0T6oaLHCpHgDp6mPZlGQZ8nNwBD+Spkw/S8OdXPKBJMg7efoCkx3EiUHrR2V3x5XIZq+RPiHl4MKo2RsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=biDqY0Q/Fv1zFLC8JgiEyiyUXIcCxUjJwR37bRrNLDM=; b=i1DDgTUwHlv0a9LL0jkRRTlW8V4KBjm8dm8bOOQaYf2mNP3Ou+ahfTC0B9gkLznWh0Xqtp3wo/NaEMugzNqFhKA0Ht/J2YO5BB9CWwkeTxrXYIXp+DtdMtBUQxCKUsyKETcNI9eCvH5Kul04I+udoR9UDfONPhDUc/1W8Z1dv01YRU9Vua9xPyZgFhymJZ+c40i9198siQyleUyJJ0lyNj0B8Kt2V2W690saPujfDZIWVKh1K69iRq0jNXSMeiff0xpcq2b+FQe5QNJlXdzc5HZhfbtWqEvfbQKjMIjD9R1+L3pY1LHHhpGhu3TIhlWIxeSAqkGUxZiMlOCdAZHIlw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=biDqY0Q/Fv1zFLC8JgiEyiyUXIcCxUjJwR37bRrNLDM=; b=k8zOFW1Hr75oLaS6+kOvSr338DLrWSvXecOQ43IityE3o6IOUENVEM30AYbZWp+3/agXHEKPAV8hTvRr9nBmVZeYntU69HFX2nmfpAlmkrhWMIOnNPd5QqyELzEk+vTirGCZ9g9W5seI3GJ8GAAjIySDiiVTB1J/MCty9j7DjV4= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) by BY5PR10MB4129.namprd10.prod.outlook.com (2603:10b6:a03:210::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.17; Fri, 6 Aug 2021 22:13:34 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3%5]) with mapi id 15.20.4373.028; Fri, 6 Aug 2021 22:13:34 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V6 22/27] vhost: reset vhost devices for cpr Date: Fri, 6 Aug 2021 14:43:56 -0700 Message-Id: <1628286241-217457-23-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> References: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) To BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ca-dev63.us.oracle.com (148.87.23.7) by SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Fri, 6 Aug 2021 22:13:32 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1cf64abf-6434-4b54-a534-08d959276e50 X-MS-TrafficTypeDiagnostic: BY5PR10MB4129: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vljJ7U9ROqfRDPVsGcKK+h+OVt4GIw946gvpbhY2DAnEy72yYn7QDDpHfI21Drg5E+LAOqDfYUWhzULKKynPkfmvEP2jYPDabAC/l4+gkr3kL9N1mXfPa9J7afonWWLx7g6BhUb6c92oBz5JoWQrWoIvzINM/axyiMZzu6zyekdyJoHLfCf0fyuiUdFIlccF7N/SwYIq+7qhqb37K0fEQMwBcSsOgzmzqUtq8wXogcpI8FK9h9c4B/kMt7phosbWH25ao8RU9y/ilHJphrEj+zWcnJDs2OiCePmnu/9MASKXYu2olguFWoRJj2v3VW1Wn7HbX3K2vfS7PUyYB3xxqRhl1OXVIwDplkAlP2l5zaNtP1hqjnjuXRwEpfCn+Mv4u4vBXBzos2jxA+j9Pzvue5TpBTQp+gen6CK+JnhKQr5eu/PFZEL3AsiZrVZMF62H25gDc6x9XdzWZln54JOIgnEtAWNdlRolWJldnWQcW9M/zgNP6SsTH3pK8iKI3tId4dt7yctG+sWolSytIdGKxq0LUXwpce4Wn8QdI8Vcz4h1X7kRD5/x8K3AhNTHfFxTp9hfKFwiDSM0N7lhEuma1eH2bX7LPPiCICINv0RTwTT2Mzj2QH7WYKjqVA6BebzhMoFe1aqeJxMQSRokyApPLT53oyhpV6/dtAVA6jJVn6JMIgctCa0OlJUazXfIp+tQwvSQuXDLfvxwjfrhUp0Qxg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(396003)(39860400002)(366004)(346002)(376002)(66946007)(66556008)(956004)(2616005)(316002)(7416002)(38350700002)(8936002)(478600001)(66476007)(36756003)(86362001)(38100700002)(5660300002)(54906003)(8676002)(4326008)(6486002)(7696005)(52116002)(186003)(2906002)(6666004)(107886003)(6916009)(26005)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +oYMGmBr4hrJGfsKezc53vHVUF2h+y2yXQUkVwOu3aaurf7qp636qrMccxOXK4xSUdfwzp1EKB7pwzKJzSWWTD4eLm3Y1RyH64eOxz/YgFPNyVyIUMNqddI7fit9kingJZrhOdb2HDsBORYvUPp3M8w88ze2BjcDizE5LgYXkUBiXy9dtXw1HtAqqFA6wNUL2WXjF2jFDHxT9NfGGH9VTNhB2q7DzEFWPOrfBzFsL+zogU1rKQdfgnn+O0WMh1PdROXIhRBGTlSlPkaQgRsFiaeEEIlRnnWwtT2PzaHGnn6Pkcwlnk5Q0zymnvi7WW4MCaM8PjKehpIi8c5wlW17iFU998AG5jxFqlCrq3Avhf1LnO9mXeFPh7/q8h00R2ihOmR1j6PGkhrC2LxRrYrd+DenQiXZWnGo0sU7/NxanUl+IJ/4sg//n6IXXGObqyufs1d0H9obJWosynCi8Yy5f0OlstOGbjxV6TpSTvaDk31uKa6I/g+jO56FOYWpisq9QqH0P5TEGiT/KGEFEKtfxudH7HJJo07PqBUkzZTaLnFJownaApYI7ik3uoTqJvg5ggMTq/thg57/AvCrFMYdVUki4l0Rk9CEYdrYR+FazM7553/brsg3ElnrQdylas0d6gYqznc63L3tVtZzV72i7GgOAjAAKARxKzBowQwb6k0fqmrgrWNQOacTKcyp/VAZUaD0Yn5KRE0NCr+Q7tK+hCkJAPIyT0SLlXlw1xAdjse+CKUiIONuDq5f9dbB9S94LdyII/AWUHclVXnDbg5KJKBuw1ZDkBg60Z9Rykxa9eDRqGlBIAuLwu9Vsw/OMSNgub7v0Bve9u0BGX80vaUXjOWWCcQfK0oJ1Kfz7GzpGBdGufxtunLPOi3+RErzN3/YkJbwq+cZgGeIZSNjNsBzk6gwKoJx81GcaX+ARMfMRktNnkLgrqqOhN+1zlpTQMF0CBzvbReEDzMBoeXu73K3f2tE3tBhFfYUtGgFeiS4iSAC2WI9hMfbuVk0+QuAgwQnMG07i9Oaar3tcBPVG5r2ZB4UIzSyiw36ox4xGkJsFBVsS0zmjzAEb62gIeE+RGOhLFiCISp+wAT4gMGE92RBt8Y19miWIJaQ8NbE6OavYN4OfUgt8QvancnsdHoewiZVanCQ7u34h19FwCd/DWjrwtiJyoXffYNe4uaihiUdYdChy5PLIDr6kU2vz47SylS+maG8H1S3kMi7zCvuDx3Tb+i8eJv02pvO4WFa6/GXbZswCunikuwdGGzAYxQMHriUm4hxL42fbfnnmQzg4hgIboPIdJrgkjOQAA00DWbj8/R357vcuExXMyk3j+ZEpE/p X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1cf64abf-6434-4b54-a534-08d959276e50 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2021 22:13:34.0280 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: XbI/1Fswmo6rIWcRE3tQByejTwQA7fCOLY+9tO/3dwzivGf5DbxyJ0SoWpVA3nB6n8nNpyc70lUAkCMdZjNFeMmdGyM3TfV52jgQOdfieE8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4129 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10068 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 phishscore=0 spamscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108060145 X-Proofpoint-ORIG-GUID: qFLI0iX3M1ARDLpkuC2kBuKSwH259dLi X-Proofpoint-GUID: qFLI0iX3M1ARDLpkuC2kBuKSwH259dLi Received-SPF: pass client-ip=205.220.165.32; envelope-from=steven.sistare@oracle.com; helo=mx0a-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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , Jason Zeng , =?utf-8?q?Alex_Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Zheng Chuan , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" A vhost device is implicitly preserved across re-exec because its fd is not closed, and the value of the fd is specified on the command line for the new qemu to find. However, new qemu issues an VHOST_RESET_OWNER ioctl, which fails because the device already has an owner. To fix, reset the owner prior to exec. Signed-off-by: Mark Kanda Signed-off-by: Steve Sistare --- hw/virtio/vhost.c | 11 +++++++++++ include/hw/virtio/vhost.h | 1 + migration/cpr.c | 2 ++ 3 files changed, 14 insertions(+) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index e8f85a5..3934178 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1832,6 +1832,17 @@ void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev) hdev->vdev = NULL; } +void vhost_dev_reset_all(void) +{ + struct vhost_dev *dev; + + QLIST_FOREACH(dev, &vhost_devices, entry) { + if (dev->vhost_ops->vhost_reset_device(dev) < 0) { + VHOST_OPS_DEBUG("vhost_reset_device failed"); + } + } +} + int vhost_net_set_backend(struct vhost_dev *hdev, struct vhost_vring_file *file) { diff --git a/include/hw/virtio/vhost.h b/include/hw/virtio/vhost.h index 045d0fd..facdfc2 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -108,6 +108,7 @@ int vhost_dev_init(struct vhost_dev *hdev, void *opaque, void vhost_dev_cleanup(struct vhost_dev *hdev); int vhost_dev_start(struct vhost_dev *hdev, VirtIODevice *vdev); void vhost_dev_stop(struct vhost_dev *hdev, VirtIODevice *vdev); +void vhost_dev_reset_all(void); int vhost_dev_enable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev); void vhost_dev_disable_notifiers(struct vhost_dev *hdev, VirtIODevice *vdev); diff --git a/migration/cpr.c b/migration/cpr.c index 16f11bd..fd37d98 100644 --- a/migration/cpr.c +++ b/migration/cpr.c @@ -8,6 +8,7 @@ #include "qemu/osdep.h" #include "exec/memory.h" #include "hw/vfio/vfio-common.h" +#include "hw/virtio/vhost.h" #include "io/channel-buffer.h" #include "io/channel-file.h" #include "migration.h" @@ -116,6 +117,7 @@ void qmp_cpr_exec(strList *args, Error **errp) if (cpr_state_save(errp)) { return; } + vhost_dev_reset_all(); qemu_system_exec_request(args); } From patchwork Fri Aug 6 21:43:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12424017 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 319CEC4338F for ; Fri, 6 Aug 2021 22:29:53 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 14A6D61165 for ; Fri, 6 Aug 2021 22:29:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 14A6D61165 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:48146 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mC8Le-0005DI-Oc for qemu-devel@archiver.kernel.org; Fri, 06 Aug 2021 18:29:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47426) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC867-0008Lq-LF for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:47 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:60408) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC865-0004Qk-7W for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:47 -0400 Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 176MB390029751; Fri, 6 Aug 2021 22:13:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=oDxqybc1HnbMODF9rjdxb5ZqdzNNWjUwKT2x/MCZh0A=; b=BteLes3hx0yiyLJXIqqSjuqgUms5RJgKYYKRzIKv9wJdG9PFp7YksOKvno6ngefp+j21 K+eqCCNFOtf4+PHSNPRM8SHtzeLucD0R5KsNPNzb6RWzLFv8qNbduXk2MMbhYFrQuIfL 58sDYXj/vdSFL6BXZtJJeVXlqtTXkN1OUpF6fRseOPg+C02pEPD05kUau+VinEPdWHmp HpxgIx32Sy7aQ4WPIZtbO2NHYSJeg8i2iMx7IWhklzvaD5sKKj0V4Fc1feQsP64X05jH 49ZLzmPKTpwpayVQp0ApiqwA3ZjXX7VnIVQ7TVpu0KovOLLI7unBhu7Yn3O6CJUTITMj gw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=oDxqybc1HnbMODF9rjdxb5ZqdzNNWjUwKT2x/MCZh0A=; b=onCDqwQdsHNzV6WBdBJ5rhtD8a+dWk+fGKOt7YLW8LAq/iCjLUvCl24N0/8AH5zm/byS mPFQuRpqR0AyHwfADaTd2bybf5yjIAaLrvJhwCcDD4tYH46jPQPpZCCefs24hIEyXrEV WylJCPHBPJe91KSseGLe6FZ7tQFzYmHVtOEwbUQyXnaMxDcGzfF8Il3cw0tQMdzJJx4R Y1jyptHOyzjt0EREM5QfnRgHuHTejTELZ0BlA97VPjMkPHFlAm1oPVHn3QnHLOAmSR7Z HHB3k1hthuCXLe06++4t0Z8G2oKBKGuJSpPYO6BrS/Q78Vy84LljAh9dTm+fBi8udnii IA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3a90justqm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:39 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 176MBgJM181317; Fri, 6 Aug 2021 22:13:38 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2177.outbound.protection.outlook.com [104.47.55.177]) by userp3020.oracle.com with ESMTP id 3a5ga30fk0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ki8JDj/j8OpkxqY5x0M7NdxZvKN9afUZAnsMYsmSBQEimbyKr+EYUJrBiQMY6Be1Hckk33kVUR57y34q60EB4VzjHR/SB3JaVWCpAyAf7rsSS9RzQd2CfJev1co0uLlfMtN1PJJq4K0AtoIXJfXrDyUlFdc0zRmWvxCTkz1l++oZTfmOVpS3NwKhsKccLmr5hQnPkeARQMhPK0yL42Io0SORF3y8n2/YzYIoccPZw8g3363zrzITS9KdrvgV+OlWT5aBgUCiqOxA15gjFdQjyfSEuLdsE6m3+BxONdMLf6fXEU1nDe45R+LCjm3Ne1dft8PUIlZgLYMmnIQBMtZmXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oDxqybc1HnbMODF9rjdxb5ZqdzNNWjUwKT2x/MCZh0A=; b=eAfZjFlW23nXeReTibtd7/+fSeTiyz/i+PswWb+apZ9aGUE9SqbQPnoFUYpPi2FH55bxZZWtkCdxVOR/zbeJ9cDHgU1JPGzU7f+uin4WyWbmCBzA4PZFp4H63Wk7IxwSiMlLUbW/uoY0tJSri8R/rv3JczyNrlnJ39PH2qedQi0UXO7eH1lPHtZpUYfYkegMjg1FSqasQKQXpTe2E5x5McArOZH5BwbsrRwdEXkvi0b5VQ/m2dL9xZUNayQ8Abja1HAhK/3kui1/YkkyOL5m3Tz65z0rXF3wTR2jv7iUjltZceNsk6cRDuLMb2bIigQY9/ISHboowgz6m+NCS6YLWw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oDxqybc1HnbMODF9rjdxb5ZqdzNNWjUwKT2x/MCZh0A=; b=DBCL9s/w1dIJjdBPvfwnwH/0URe4lFKDonNONUMMCYKezNpTvmoT+LX5m6zaE5RErphbTlzLTsrqER9M1f6QguAO13rXTb8FJkSQl+JgZb/ilJ/kTFIhdzW4V16X9tnledbwTFcLs6jRf+Y416xzKQn4J3AZW3Supy5OSjh5Z0w= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) by SJ0PR10MB4734.namprd10.prod.outlook.com (2603:10b6:a03:2d2::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.17; Fri, 6 Aug 2021 22:13:36 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3%5]) with mapi id 15.20.4373.028; Fri, 6 Aug 2021 22:13:36 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V6 23/27] chardev: cpr framework Date: Fri, 6 Aug 2021 14:43:57 -0700 Message-Id: <1628286241-217457-24-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> References: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) To BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ca-dev63.us.oracle.com (148.87.23.7) by SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Fri, 6 Aug 2021 22:13:34 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 92b19678-a206-444a-ed0c-08d959276f6a X-MS-TrafficTypeDiagnostic: SJ0PR10MB4734: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:147; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ODH9yfW82LObc8pt0vWZvDvANtEt+EXrXoVXZN48XEp2c07onD1iwMMa8aO1WVpM1lhllzwPtNFqEQSADgcwinikpd7jkEWj+dXvj+gsNDUV/eq5RD7cSnlVbNl/D1OZdDZZwpDOzZBm+puX5o9QF4JFhs8nhWmzJsJmF4XcDGsJJG3sKKkiGSHVm3LnuMc/a+p9Dz/WMv8IRB1JnD04YiI+OXkI2wxD0DjYJKCdtj2opxwamHC+0q7VD/DR+Fi0y5aceGmIQJbLgNl96HfwTs7+bonQhKd90WBvg7/ux6udJD74iG3iaIvuLUJkkSUe4/+qzZsbr72QYdPCSMMOKbuzZezRB4QoJz4ud1Be0/M0yiIy/neZSGkVkkwB+5ESHjkNNLOzf3Q5e4jiNs0Ui+WtEjGfCUImqM0eVukLVz3SBk7Q68WNRlYSWWK3qDqlnDoDHRFjihkPhgQIXDNO6HfT3qZG1GO3MNVLFZ3twuXf1tbEmyhSi5jH6FUReULV2OlBC0isEj48sNGy5eIHHJkzGtn6yIdyfrWqjCOvbeRT3DC4trJ23iXF2G7pPqcVkCFvRZTHb2an1eYZhNH/iuoHNTSaRnxBat5N23FFTc9J7gzQkBnslXtSA8eT0mHwR1XJzHjQD8b7KY52YWt0dITCzwewDQymgNEmiIJLG8KYA4xz1lIJE6XVGgA0q0eoAG6KpBAwbSE9DSgAK6Psdw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(396003)(376002)(136003)(366004)(346002)(66946007)(107886003)(66476007)(8936002)(86362001)(316002)(83380400001)(54906003)(8676002)(66556008)(4326008)(36756003)(956004)(6666004)(26005)(186003)(2616005)(478600001)(7416002)(6916009)(5660300002)(2906002)(52116002)(7696005)(38100700002)(38350700002)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jpQ30QDUNJX0sJxsHlKwOM9s27G6oGdV9guV8ZySk1ZNfkONCfdZbP4t9quUfU6ojpvtuEWN/ICxqnmWysXGCv4Agm/+/eEXtPzJNTyzLmSfU7d1C4TZwgs2SzgxANCulo0OJvG9CQ9ezQwDIKB22v33s+DX3qAUsiyhXaKFivR+LsBGJ4VfS1g48P91vlaLdeCjf1f1GgvbhJKRcV7X+0aksDZYMpcPvikcdIvP7bglWIr0TxX3OSJUow9FO6gOKiKdr2Yn35woeGtLgUfWH17Wu3Cgikt7K/IpJBSVZYPKo80PgBypXL20cK3AhFnyybhVu6gBrO972eDV3tkR/CkzQcze7hkbkME4FnIAPE0VR5IFj9emwQ++nlfWkMn6N7WtAy+JnzkVik8fIre8wJHFbnrV4UIMlTxxzwDcXA7NoLcu4RUw+Ub4k0amNLJ2bGng/e+axGmSYf3Ip1W7z4cjyiRqsXlfEaXBl4ksB8lSWhQ6EkFm6OlCbB5cnqoJbuwJVGu28Rl2pWeEvFC6/gKd0TFcybKnaYqAx3g6WokuoPUEM1gbIYzKqe6PB5A9tDeAXnkyJsU/VID1EbA6ZuVQb8W2pL4b62uTbm0/cT4OF3Q2y9T7fUCY1gmOaecdBOB5650fUq63imbJYrmMhI1YYmeQv8FX7vJCpsMHdC9y4poL1tnrjT3eCQnzfLWxODYpAKrCqBb4nmXZDZOZe/Ca8qXWb2fM3PZ1hu77HxoK4VjQAiysrqcLBPeszVHudIxgZ18eI1Ss4b9vq/0wDV8H5M7VgTQIjTCGoVug4U2rzo2sg+Z4Obk7Vbn3fuZff0igFPZB5o6SNCFt0hh+xiqY5CL/w5gMAqCqnIJHCre/pgXAdj3245gjD3lMWtBKKfgUncS/nZiiQIJ8jH0ttQg4rOK8BCOKaeUiI5tqAtwV7LZc4lvicoqML2dASZniLmi8AyujyRFc+J4V0+u/DG1COfFBRKGYfDcyrfYXG+DaZrUVKzsh3AJr3JFo2Wl8C4Vs7mSNrBQqWYrRwsZuZECeTyRFzYExVmgLwpbNdzBX6I937wuOoxPhqVBUKJILN4NHz/6hSMjzY1Ju5FROSD1ghs+l3qhVUBhrpcZWVO4kPRcrL6y4gTKCeHMWM+mPoDNOxAa0uSuRaV17pT4Wfqs+YlvhrD5rNPfyHRJlkeu3giHNDm0Dnlx3GF5OCHXOu6J7MOFK6VKzxs1UXYBqa5yvUyD42doy7hWXh4n14FledpvT97x2+mHD/zZKjacoIVNJ54Zz7RNrVe86dtGN/EoC+RtK9vVajPOk0GBJAOOdAOdbcd5dIDm0XqoOaYkD X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 92b19678-a206-444a-ed0c-08d959276f6a X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2021 22:13:35.8970 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: c/VGAQSahLulAVOeBQ4jL9uJQ733MjcgLRpJMWfF4xkUsorrBEI72dcojI8YBpW1reLH3eQiuOL71kaXmffp9jSMuFXcAkRHlTs7w/et8fg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4734 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10068 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 phishscore=0 spamscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108060145 X-Proofpoint-ORIG-GUID: _oE1jeTBcXMY--oawMbq74FoTJf_cv9K X-Proofpoint-GUID: _oE1jeTBcXMY--oawMbq74FoTJf_cv9K Received-SPF: pass client-ip=205.220.165.32; envelope-from=steven.sistare@oracle.com; helo=mx0a-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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , Jason Zeng , =?utf-8?q?Alex_Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Zheng Chuan , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add QEMU_CHAR_FEATURE_CPR for devices that support cpr. Add the chardev reopen-on-cpr option for devices that can be closed on cpr and reopened after exec. cpr is allowed only if either QEMU_CHAR_FEATURE_CPR or reopen-on-cpr is set for all chardevs in the configuration. Signed-off-by: Steve Sistare --- chardev/char.c | 43 ++++++++++++++++++++++++++++++++++++++++--- include/chardev/char.h | 5 +++++ migration/cpr.c | 1 + qapi/char.json | 7 ++++++- qemu-options.hx | 26 ++++++++++++++++++++++---- 5 files changed, 74 insertions(+), 8 deletions(-) diff --git a/chardev/char.c b/chardev/char.c index 4595a8d..013afdd 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -36,6 +36,7 @@ #include "qemu/help_option.h" #include "qemu/module.h" #include "qemu/option.h" +#include "migration/cpr.h" #include "qemu/id.h" #include "qemu/coroutine.h" #include "qemu/yank.h" @@ -240,7 +241,10 @@ static void qemu_char_open(Chardev *chr, ChardevBackend *backend, /* Any ChardevCommon member would work */ ChardevCommon *common = backend ? backend->u.null.data : NULL; + chr->reopen_on_cpr = (common && common->reopen_on_cpr); + if (common && common->has_logfile) { + g_autofree char *fdname = g_strdup_printf("%s_log", chr->label); int flags = O_WRONLY | O_CREAT; if (common->has_logappend && common->logappend) { @@ -248,7 +252,13 @@ static void qemu_char_open(Chardev *chr, ChardevBackend *backend, } else { flags |= O_TRUNC; } - chr->logfd = qemu_open_old(common->logfile, flags, 0666); + chr->logfd = cpr_find_fd(fdname, 0); + if (chr->logfd < 0) { + chr->logfd = qemu_open_old(common->logfile, flags, 0666); + if (!chr->reopen_on_cpr) { + cpr_save_fd(fdname, 0, chr->logfd); + } + } if (chr->logfd < 0) { error_setg_errno(errp, errno, "Unable to open logfile %s", @@ -300,11 +310,13 @@ static void char_finalize(Object *obj) if (chr->be) { chr->be->chr = NULL; } - g_free(chr->filename); - g_free(chr->label); if (chr->logfd != -1) { + g_autofree char *fdname = g_strdup_printf("%s_log", chr->label); + cpr_delete_fd(fdname, 0); close(chr->logfd); } + g_free(chr->filename); + g_free(chr->label); qemu_mutex_destroy(&chr->chr_write_lock); } @@ -504,6 +516,8 @@ void qemu_chr_parse_common(QemuOpts *opts, ChardevCommon *backend) backend->has_logappend = true; backend->logappend = qemu_opt_get_bool(opts, "logappend", false); + + backend->reopen_on_cpr = qemu_opt_get_bool(opts, "reopen-on-cpr", false); } static const ChardevClass *char_get_class(const char *driver, Error **errp) @@ -945,6 +959,9 @@ QemuOptsList qemu_chardev_opts = { },{ .name = "abstract", .type = QEMU_OPT_BOOL, + },{ + .name = "reopen-on-cpr", + .type = QEMU_OPT_BOOL, #endif }, { /* end of list */ } @@ -1220,6 +1237,26 @@ GSource *qemu_chr_timeout_add_ms(Chardev *chr, guint ms, return source; } +static int chr_cpr_capable(Object *obj, void *opaque) +{ + Chardev *chr = (Chardev *)obj; + Error **errp = opaque; + + if (qemu_chr_has_feature(chr, QEMU_CHAR_FEATURE_CPR) || + chr->reopen_on_cpr) { + return 0; + } + error_setg(errp, + "chardev %s -> %s is not capable of cpr. See reopen-on-cpr", + chr->label, chr->filename); + return -1; +} + +bool qemu_chr_is_cpr_capable(Error **errp) +{ + return !object_child_foreach(get_chardevs_root(), chr_cpr_capable, errp); +} + void qemu_chr_cleanup(void) { object_unparent(get_chardevs_root()); diff --git a/include/chardev/char.h b/include/chardev/char.h index 7c0444f..3fa3528 100644 --- a/include/chardev/char.h +++ b/include/chardev/char.h @@ -50,6 +50,8 @@ typedef enum { /* Whether the gcontext can be changed after calling * qemu_chr_be_update_read_handlers() */ QEMU_CHAR_FEATURE_GCONTEXT, + /* Whether the device supports cpr */ + QEMU_CHAR_FEATURE_CPR, QEMU_CHAR_FEATURE_LAST, } ChardevFeature; @@ -67,6 +69,7 @@ struct Chardev { int be_open; /* used to coordinate the chardev-change special-case: */ bool handover_yank_instance; + bool reopen_on_cpr; GSource *gsource; GMainContext *gcontext; DECLARE_BITMAP(features, QEMU_CHAR_FEATURE_LAST); @@ -291,4 +294,6 @@ void resume_mux_open(void); /* console.c */ void qemu_chr_parse_vc(QemuOpts *opts, ChardevBackend *backend, Error **errp); +bool qemu_chr_is_cpr_capable(Error **errp); + #endif diff --git a/migration/cpr.c b/migration/cpr.c index fd37d98..62b2d51 100644 --- a/migration/cpr.c +++ b/migration/cpr.c @@ -6,6 +6,7 @@ */ #include "qemu/osdep.h" +#include "chardev/char.h" #include "exec/memory.h" #include "hw/vfio/vfio-common.h" #include "hw/virtio/vhost.h" diff --git a/qapi/char.json b/qapi/char.json index adf2685..41475dc 100644 --- a/qapi/char.json +++ b/qapi/char.json @@ -204,12 +204,17 @@ # @logfile: The name of a logfile to save output # @logappend: true to append instead of truncate # (default to false to truncate) +# @reopen-on-cpr: if true, close device's fd on cpr-save and reopen it after +# cpr-exec. Set this to allow CPR on a device that does not +# support QEMU_CHAR_FEATURE_CPR. defaults to false. +# since 6.2. # # Since: 2.6 ## { 'struct': 'ChardevCommon', 'data': { '*logfile': 'str', - '*logappend': 'bool' } } + '*logappend': 'bool', + '*reopen-on-cpr': 'bool' } } ## # @ChardevFile: diff --git a/qemu-options.hx b/qemu-options.hx index 05e206c..3f0c974 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3185,43 +3185,57 @@ DEFHEADING(Character device options:) DEF("chardev", HAS_ARG, QEMU_OPTION_chardev, "-chardev help\n" - "-chardev null,id=id[,mux=on|off][,logfile=PATH][,logappend=on|off]\n" + "-chardev null,id=id[,mux=on|off][,logfile=PATH][,logappend=on|off][,reopen-on-cpr=on|off]\n" "-chardev socket,id=id[,host=host],port=port[,to=to][,ipv4=on|off][,ipv6=on|off][,nodelay=on|off][,reconnect=seconds]\n" " [,server=on|off][,wait=on|off][,telnet=on|off][,websocket=on|off][,reconnect=seconds][,mux=on|off]\n" - " [,logfile=PATH][,logappend=on|off][,tls-creds=ID][,tls-authz=ID] (tcp)\n" + " [,logfile=PATH][,logappend=on|off][,tls-creds=ID][,tls-authz=ID][,reopen-on-cpr=on|off] (tcp)\n" "-chardev socket,id=id,path=path[,server=on|off][,wait=on|off][,telnet=on|off][,websocket=on|off][,reconnect=seconds]\n" - " [,mux=on|off][,logfile=PATH][,logappend=on|off][,abstract=on|off][,tight=on|off] (unix)\n" + " [,mux=on|off][,logfile=PATH][,logappend=on|off][,abstract=on|off][,tight=on|off][,reopen-on-cpr=on|off] (unix)\n" "-chardev udp,id=id[,host=host],port=port[,localaddr=localaddr]\n" " [,localport=localport][,ipv4=on|off][,ipv6=on|off][,mux=on|off]\n" - " [,logfile=PATH][,logappend=on|off]\n" + " [,logfile=PATH][,logappend=on|off][,reopen-on-cpr=on|off]\n" "-chardev msmouse,id=id[,mux=on|off][,logfile=PATH][,logappend=on|off]\n" + " [,reopen-on-cpr=on|off]\n" "-chardev vc,id=id[[,width=width][,height=height]][[,cols=cols][,rows=rows]]\n" " [,mux=on|off][,logfile=PATH][,logappend=on|off]\n" + " [,reopen-on-cpr=on|off]\n" "-chardev ringbuf,id=id[,size=size][,logfile=PATH][,logappend=on|off]\n" + " [,reopen-on-cpr=on|off]\n" "-chardev file,id=id,path=path[,mux=on|off][,logfile=PATH][,logappend=on|off]\n" + " [,reopen-on-cpr=on|off]\n" "-chardev pipe,id=id,path=path[,mux=on|off][,logfile=PATH][,logappend=on|off]\n" + " [,reopen-on-cpr=on|off]\n" #ifdef _WIN32 "-chardev console,id=id[,mux=on|off][,logfile=PATH][,logappend=on|off]\n" "-chardev serial,id=id,path=path[,mux=on|off][,logfile=PATH][,logappend=on|off]\n" #else "-chardev pty,id=id[,mux=on|off][,logfile=PATH][,logappend=on|off]\n" + " [,reopen-on-cpr=on|off]\n" "-chardev stdio,id=id[,mux=on|off][,signal=on|off][,logfile=PATH][,logappend=on|off]\n" + " [,reopen-on-cpr=on|off]\n" #endif #ifdef CONFIG_BRLAPI "-chardev braille,id=id[,mux=on|off][,logfile=PATH][,logappend=on|off]\n" + " [,reopen-on-cpr=on|off]\n" #endif #if defined(__linux__) || defined(__sun__) || defined(__FreeBSD__) \ || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) "-chardev serial,id=id,path=path[,mux=on|off][,logfile=PATH][,logappend=on|off]\n" + " [,reopen-on-cpr=on|off]\n" "-chardev tty,id=id,path=path[,mux=on|off][,logfile=PATH][,logappend=on|off]\n" + " [,reopen-on-cpr=on|off]\n" #endif #if defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__) "-chardev parallel,id=id,path=path[,mux=on|off][,logfile=PATH][,logappend=on|off]\n" + " [,reopen-on-cpr=on|off]\n" "-chardev parport,id=id,path=path[,mux=on|off][,logfile=PATH][,logappend=on|off]\n" + " [,reopen-on-cpr=on|off]\n" #endif #if defined(CONFIG_SPICE) "-chardev spicevmc,id=id,name=name[,debug=debug][,logfile=PATH][,logappend=on|off]\n" + " [,reopen-on-cpr=on|off]\n" "-chardev spiceport,id=id,name=name[,debug=debug][,logfile=PATH][,logappend=on|off]\n" + " [,reopen-on-cpr=on|off]\n" #endif , QEMU_ARCH_ALL ) @@ -3296,6 +3310,10 @@ The general form of a character device option is: ``logappend`` option controls whether the log file will be truncated or appended to when opened. + Every backend supports the ``reopen-on-cpr`` option. If on, the + devices's descriptor is closed during cpr-save, and reopened after exec. + This is useful for devices that do not support cpr. + The available backends are: ``-chardev null,id=id`` From patchwork Fri Aug 6 21:43:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12424021 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A803AC4338F for ; Fri, 6 Aug 2021 22:32:44 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E3EE661158 for ; Fri, 6 Aug 2021 22:32:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E3EE661158 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:53112 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mC8OQ-0000Ji-QJ for qemu-devel@archiver.kernel.org; Fri, 06 Aug 2021 18:32:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47594) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC875-0002xv-IM for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:14:47 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:13076) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC873-00052E-LV for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:14:47 -0400 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 176MC2S3023291; Fri, 6 Aug 2021 22:13:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=7wMaSno/Fh25MXUAXxVPxpEVPhxavP8Wm9st/teRymU=; b=1NwAUM5YNm7gKtOKKtCAVfL7Xnxw6YDAKxkcKGsBBfzOQfsSdDgTcSd0SLMoy14wG6BD WFcq2rocmjnOdyHPHlj0/rpLtSRmGsxsECXJ6P7b/ysLB+u1K9vU5Yid8Au0x7z/UFQq WlfJBoOalcJhproEBUgWsOzFlgue1PKG2l1YHcgzL22Mm6x1z4R6NbEenBehWdivucMs xMuWt2ZSqP91UGpSYZyGrm48AfQUmh2lzZM0+3p8N9ZPs36eW4ANde+VJIB8K5sIqnDO cwcuGXk/eZcyHcYaTMF8PbAWzAPOtTh8kBZLh+rXleZ2wvU1Y0G0Eg2RG+ZvgQsI5ROo UQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=7wMaSno/Fh25MXUAXxVPxpEVPhxavP8Wm9st/teRymU=; b=xTUhoBZSJk2RazFuJWnfhDJibqoEg1uiwFBuvZrAkt+3m3VbVWQP6l13b4oDKqvNLDZ8 b86Z0B58mZLe/TgZVn5w9C2yk1SXR3Eij+Tt5E9FHjg5hG02DDy1n3BnsuIRkOvvBYp4 bJyM1WNVLq63+Ua8GPvM+h7DmLJxBGPHOnokTHxrymXzqzTMvNRl/+bhwdxDMK4rgGm6 ENR09TtHocDzZ5kYmQratzkkxLGS7azaK+hRVR5FcZLpM9Jq55la7Dw7PgTxwiOAA7t6 8ZkUcL+KXXzfduLpRoycDt3XKfKOOBDcXMUdUAmf/qZCfU766lxfc+r03rY59/GCTw/I xQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3a8vy3t4y4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:40 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 176MBgJN181317; Fri, 6 Aug 2021 22:13:39 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2177.outbound.protection.outlook.com [104.47.55.177]) by userp3020.oracle.com with ESMTP id 3a5ga30fk0-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cwwLsH7rDNSsnH8KI9kN7PM6co/w7+gny2RGNhzBOeyj+R5io8i47hB7HJ+90o9VQ0bmd8zqwJTvHbyrNxB3qeND3rIljoO/DHEbx8jyqawkdGkSKdfE3wM+3jb4IjO+EO4KZWghxqMlPg1FENFwRW4mxLrZuA8LKxdM92yrbJov0h2x0OQOZpylfPzcXFXzZD8m5/05HB1SgYD953p3trsZgqwglYjYQi2+2xpuTkJBb6IcMHGcRRnRWD0uREl4wVYpNzHITUMfCOwG5QOtVgGw8l9eVkqZTd7tBvpDlVABUrRW3W0uC3OkVur/JafeI0XPNx9DZMZNX38/q865Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7wMaSno/Fh25MXUAXxVPxpEVPhxavP8Wm9st/teRymU=; b=eEHnGpHxputHlz2sbrvmFtxKLeJaBaYEejQHLw0i8fKj5IHqgZ3xAE4j9SPsleHTewrInG2G+pGLd5mJJGtH7gkmMhHN5M1qZ3QJ4a3wSK9t/FgusyJ49t2oZfLCiNOsW0Du9jdQyWdLkBfmBM69vcE42Tvvny/WGcBOZF25KZp+PgpvoZocgDpb4H5Wl//UadzHXkwqjXKBXzkLpspSg2T6uaDipHoa2xv4Xw1OAvOUedw856t1wDbwFPHkYZbdzXs7v9uKvy7r8rfqrgL0N5v10q2n67UFfXS0nH4aRBmjrU+CBi24G+gOpbRYkBJQEf1YL0FtULdXiZmYaNsDLw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7wMaSno/Fh25MXUAXxVPxpEVPhxavP8Wm9st/teRymU=; b=UNxnQdpWyZbPkVMMNuHhthpizWrt3aHaPfo9QM2MInjCkDghxf7A5ScZIsGMzO1vz0J/BhwsTyGeWX3+AnK613iHYo9A65VaiwnSPLGHeQHDhK38bE3At2QPZCmE5SK2OvOSR7qZN9hFi+Sk21YGgsJ2DrT1k7FeOQwOcZYGKIU= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) by SJ0PR10MB4734.namprd10.prod.outlook.com (2603:10b6:a03:2d2::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.17; Fri, 6 Aug 2021 22:13:38 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3%5]) with mapi id 15.20.4373.028; Fri, 6 Aug 2021 22:13:38 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V6 24/27] chardev: cpr for simple devices Date: Fri, 6 Aug 2021 14:43:58 -0700 Message-Id: <1628286241-217457-25-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> References: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) To BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ca-dev63.us.oracle.com (148.87.23.7) by SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Fri, 6 Aug 2021 22:13:36 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 58d98d1a-2bc3-4869-8630-08d959277095 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4734: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:281; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cgRTPrDXiHM75XuRYQpWJLlAUgj3GVFnUeXijYJ3/AJZ1WIlUct0hDKmwEcXFgu+ADlLp++bmuFdp22fhBHnYa4Bb8Iwsiu4tprZSU7OS8l2k4mMyFzD9EgGUmGcCnIdJnVDnLk0Pmjz/I1JhcrSmpO4abz6o8oT8E+S4MhKbC3QVOC+wscmWJ7kAjTHUUWB5OA9lZPowG7l75Vc/YRJJmhsYCwy9CQYifRp+XEPnz/ZbLqmznZ0qz93fxsWkNxCsAJua8/KGr8A+hiu1w2ngQE62Q2nYNr7lZSaqwtLjemQX6JpatZlstJJHFhqc4Uy9W9e6sAZkdJWDtZHYgRa8OUjQYVKuPCmf5yFJAO8H2YuQhqGh2W7dRBsgBqL26WrXE5BoaV1H6hi7dpqzA+/6+SsfJgO2vJiMEh7vXhy2hCUXwdGEiva8f04hq9NxThP2MPAtq+tbMMhF4XmJZ0OLgFaKXYNN8mNBgjWx5zvgRF+N1hc31Gas6CJSWlAeEJZVdIfs64cjSNhAolAZJTSft7eZz6bQ1MoK4Rblo3hPYxP7fypIkAVakDxCReqbU4Q4rv46FQaTfHeelLaKmuN5hKUsn5wZhHJEZ3OBLdnrigvFAArNhkpumBJutvt/QwMpSAZX16I9OzbBES0XwN86fRGxO0ERLNZTkKJlPjMnHZlxdfZGKbLfXW3QEZtmeHgqN79OeBjUo+ygcmtz78yqQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(396003)(376002)(136003)(366004)(346002)(66946007)(107886003)(66476007)(8936002)(86362001)(316002)(83380400001)(54906003)(8676002)(66556008)(4326008)(36756003)(956004)(6666004)(26005)(186003)(2616005)(478600001)(7416002)(6916009)(5660300002)(2906002)(52116002)(7696005)(38100700002)(38350700002)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fa8XbD1jG9uCxn7MScFKy6szLf99WeIPJjkB29xe7rlpDrEeHpxP4e7XrsFVFPdZTclcKyPZpFOe44JqZuxJXXTlcWvaM6NEy+4+xBpRHOP8aJUCxiipQma8dkGKB+V8MD4Y82425C0c27/fl52hwdFn7xkwe/CzY7dZZXqp/lbZZooxFsT3RN5bR3D6VfWsZwQ0r5m8e2d4+NkMlGJSNTPTgLQrshaSafSB/cucHLTf9tXV4wwLZqqBSi10VHbbvnwPKaurrbHAJ/UWWFvN0gaeRTMFGMrGjaR5meQ3MakzZmLV2V0uNVpJuI2M8NiH+aDmvGPQaPhhzu4F5mwEy7kPbxxXWncsvkjp0SvOjxUImhnHuSBOd9aSlUzBdRZWWsA12Cb2xBAoH23Nly5zEbnmTwVtziMHSfORVS6/DpS9uvITs74blce44JznFdi8jS2IvXn53xVGYbfs0rTGpiXV+Su1I5I/tM8bctNFkdnZPBzuua/8S7yXRFoR2pKJjdD1YDQClY/6mJETR7/NHbnDQzfPqELEDfqY1QytAkzVlPwlWMsbK8Q+oztykDCIdU8U6MseQE3+nSK7f6uUVai/hGUL5kWAuyiDiCLClgHc+GP7q2aSRoSNpilvj0yF/UCu/l80AetwE1oRSOHwIWaHJkCMtoK7WDOwvJ22DhTH4CJ2rkiB3tPe+x/vMfxKz5zi/1pD6EdKoC1uYC5Tyl/UI/84w6PfLjDq/kso2oHCUkgjHvGU5oINLmFJHpjA43Y+eUUeKGkF2VLphyWA0sQIlFEL0J7CtolW2l+KROfciPc1IFStZR8/ONvCT3FuiFHXzQBBYxNHNMV9hNEIU1yiy4Xy41Krg3hbeap77ZQHraqGDqNvLPStYIqcjkosCzGjo9rmQOZmxIQQWm+DslUn2BLOrx2u2cVl+BX6FU1taJ/Mq/EwMY7z3rO6fr9E//ad9ftgiCacLRQEe8bFeAclqbh4fVqHtR2cbjGrh4SYeexpNxJ8yD6PrOvfjhxbrcec0hnXRaM73tK6lUAGAOPW/+CAlEjsSdrA8SYISIcEQAuhNXwMg011C40dOdz1Y2DiPIPr9ZDtS5wlYHqoUYsaayvRyKv93NMptp28P4i3CAlQsKnSsARVpkOoahV6bNVMRjs9yVrBFB4pExiIQoz/lCOMbooPfrtBVwN+mzC9RtQNZgtiQg48g7Sum2sC8vufHtMmdjs0fQoOFxFvn8pNe6Kto8RePrDvlG8Rt8uCFWOENrHBcwXBGllAVyzahtbrX7Csygudo+a1XMl/0CzIOH8C4l7cSY1t3gBZBPIk8E89rmac7P6vFR8FV0ja X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 58d98d1a-2bc3-4869-8630-08d959277095 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2021 22:13:37.8678 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Hm8f+PbpDELxLVziNSzRbF86TP+BOHGW6HC4KyAwTkMU/yrjkciWqR4OiwNkN7PMGjxhCqsnUg/OdWbNdbeFcIbAfXSI0bwowsMzNNJsjM8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4734 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10068 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 malwarescore=0 phishscore=0 spamscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108060145 X-Proofpoint-GUID: em-lCe8bGZevPqfyzTBQDJ-IaGg0dagv X-Proofpoint-ORIG-GUID: em-lCe8bGZevPqfyzTBQDJ-IaGg0dagv Received-SPF: pass client-ip=205.220.165.32; envelope-from=steven.sistare@oracle.com; helo=mx0a-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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , Jason Zeng , =?utf-8?q?Alex_Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Zheng Chuan , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Set QEMU_CHAR_FEATURE_CPR for devices that trivially support cpr. char-stdio is slightly less trivial. Allow the gdb server by closing it on exec. Signed-off-by: Steve Sistare --- chardev/char-mux.c | 1 + chardev/char-null.c | 1 + chardev/char-serial.c | 1 + chardev/char-stdio.c | 8 ++++++++ gdbstub.c | 1 + include/chardev/char.h | 1 + migration/cpr.c | 1 + 7 files changed, 14 insertions(+) diff --git a/chardev/char-mux.c b/chardev/char-mux.c index 5baf419..bf7bad9 100644 --- a/chardev/char-mux.c +++ b/chardev/char-mux.c @@ -336,6 +336,7 @@ static void qemu_chr_open_mux(Chardev *chr, */ *be_opened = muxes_opened; qemu_chr_fe_init(&d->chr, drv, errp); + qemu_chr_set_feature(chr, QEMU_CHAR_FEATURE_CPR); } static void qemu_chr_parse_mux(QemuOpts *opts, ChardevBackend *backend, diff --git a/chardev/char-null.c b/chardev/char-null.c index 1c6a290..02acaff 100644 --- a/chardev/char-null.c +++ b/chardev/char-null.c @@ -32,6 +32,7 @@ static void null_chr_open(Chardev *chr, Error **errp) { *be_opened = false; + qemu_chr_set_feature(chr, QEMU_CHAR_FEATURE_CPR); } static void char_null_class_init(ObjectClass *oc, void *data) diff --git a/chardev/char-serial.c b/chardev/char-serial.c index 7c3d84a..b585085 100644 --- a/chardev/char-serial.c +++ b/chardev/char-serial.c @@ -274,6 +274,7 @@ static void qmp_chardev_open_serial(Chardev *chr, qemu_set_nonblock(fd); tty_serial_init(fd, 115200, 'N', 8, 1); + qemu_chr_set_feature(chr, QEMU_CHAR_FEATURE_CPR); qemu_chr_open_fd(chr, fd, fd); } #endif /* __linux__ || __sun__ */ diff --git a/chardev/char-stdio.c b/chardev/char-stdio.c index 403da30..9410c16 100644 --- a/chardev/char-stdio.c +++ b/chardev/char-stdio.c @@ -114,9 +114,17 @@ static void qemu_chr_open_stdio(Chardev *chr, stdio_allow_signal = !opts->has_signal || opts->signal; qemu_chr_set_echo_stdio(chr, false); + qemu_chr_set_feature(chr, QEMU_CHAR_FEATURE_CPR); } #endif +void qemu_term_exit(void) +{ +#ifndef _WIN32 + term_exit(); +#endif +} + static void qemu_chr_parse_stdio(QemuOpts *opts, ChardevBackend *backend, Error **errp) { diff --git a/gdbstub.c b/gdbstub.c index 52bde5b..5210a3f 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -3534,6 +3534,7 @@ int gdbserver_start(const char *device) mon_chr = gdbserver_state.mon_chr; reset_gdbserver_state(); } + mon_chr->reopen_on_cpr = true; create_processes(&gdbserver_state); diff --git a/include/chardev/char.h b/include/chardev/char.h index 3fa3528..187c665 100644 --- a/include/chardev/char.h +++ b/include/chardev/char.h @@ -295,5 +295,6 @@ void resume_mux_open(void); void qemu_chr_parse_vc(QemuOpts *opts, ChardevBackend *backend, Error **errp); bool qemu_chr_is_cpr_capable(Error **errp); +void qemu_term_exit(void); #endif diff --git a/migration/cpr.c b/migration/cpr.c index 62b2d51..d14bc5a 100644 --- a/migration/cpr.c +++ b/migration/cpr.c @@ -119,6 +119,7 @@ void qmp_cpr_exec(strList *args, Error **errp) return; } vhost_dev_reset_all(); + qemu_term_exit(); qemu_system_exec_request(args); } From patchwork Fri Aug 6 21:43:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12423995 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ADBD7C4338F for ; Fri, 6 Aug 2021 22:23:14 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F409961050 for ; Fri, 6 Aug 2021 22:23:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org F409961050 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:54348 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mC8FF-0006uH-0S for qemu-devel@archiver.kernel.org; Fri, 06 Aug 2021 18:23:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47448) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC869-0008Tf-Rb for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:49 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:61144) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC868-0004Sf-3k for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:49 -0400 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 176MBlNN032562; Fri, 6 Aug 2021 22:13:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=PuPwd/kuKKKo9Ljmph+vtxsgiEEgmmfCQmLTxKjsVgs=; b=mTpeSzAOYvQzG5tkXp64Nv/datZzsSKmAkBd9afK8pVTOIGsvb1hc7lWKgTh9eL9rV4B zp1oQTaz/zFHWtqLwKds7+HT3+ORkvm5m09i5ctwYRK5JSMEDucvpHaR1NsYP45kF6UY DXhSjhHWXz3+1gpXVGDTQiXydXtaLIWOwWddnCTCO+HNNGAUub0olNE5gKPZUZFL9ZvV gL5RWrmIrq5ovA0Ae+vdJw1npaPwRCwAxeQQuXTDp3o7QN7CDIVID8mSAwAhkt41Nq9Z kTA6Wl+NyrfLXCoi3ZvbQicRzWVxOTeaADaWRFZ0EtCMya/s+omDvrGNPsPvkpA4t39H lQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=PuPwd/kuKKKo9Ljmph+vtxsgiEEgmmfCQmLTxKjsVgs=; b=jbhtzSQzoLW0XY5uvTo976i9OJSV8JxfvXR/Dat8HD/2pRiOHF0gV2oOz1g2Z+6AjjT+ 17xqT2sLIc3oE05xt1VvBq7PSeQSvGrRo6tvQ1VJVIAPJG1hS0xaZfX1lZhgfN2dtPkp 0qUosEkQPEfDcoRqCS9LVYw9/o5a7I0ChZRJ11bK6C0TyoSQLGnoMOyr1SJbR1uLvXCE d8EKvSNoYuoxNYz8ZV0CZSmj5tNhykf9YKpoLCM9wINvXjx9uoX8otWbLV7EmhpyIxwD pLu5sv9v46r5s426er4/p38E42hSPPmOe18/I/L9rY0aH8uNdSX3BIwnldZ+GRN5phPv 6A== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3a9661s143-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:42 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 176MBie0013869; Fri, 6 Aug 2021 22:13:41 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2109.outbound.protection.outlook.com [104.47.58.109]) by userp3030.oracle.com with ESMTP id 3a962pfb9c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W+CBZAGq2Csho70ms7mrs7lRcxgg52tR4hc6ZQNe8M4y4jHNFsltpU+rfOoQehC2q8a1En0RLfn9iQm1KC+Yqir9nrBHcv242jlmN61GkjfqNIVo3dPssNL76Veh64rnUYU2IfaY4hEd5no83ET/W+TP/9mmnmLailmXD7iRqNkZpU6MMyw6eNfAbKOsHm9jT1gu1RYC0xeoB9oUJsyjJdi6nahFA19GIhqDEIAem0vjHCfPD8Ksj3rh6Bua8JOYps6mpUb2FF3B1aS6tRR19A6Sg2a6e5oaFJCXrmYGKq/HeIfk0LjwWZ0Ex7rW3vkrTulR1D9uiBuzJfHIafv2Kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PuPwd/kuKKKo9Ljmph+vtxsgiEEgmmfCQmLTxKjsVgs=; b=EV1fIM4go7QHiXEt4lHvl3uO8NN/JsRznuzs2zcZ1E7KEMtaMPIzd4oSLJAhL26FQ14jdPeFOOHD9nNFjCbeXkDQtIAX/mfVPYVBtVqw0gcpa0/2kh/XwfF2xr9OmLoSG73bfxXvDN9U2BUKQ3+nMYf/b5BD6oVQjPF2DPWeJpsCnoyzQ+EyH0hK3Fg3B6nX4yAOPVK9vPbcOAkI68nBTAT7ii+VRsvyB4BXQldxg+HQc+7povdaO6wFBrKR2wwDBKsF/5Cwsc8yMwcqiaIFuSDw/e7qSwFzB6ChlRpW+Ar0+yZVldbDNSZ0TCXu/1sZCDZdL9PVGgG8hiwja4kJFg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PuPwd/kuKKKo9Ljmph+vtxsgiEEgmmfCQmLTxKjsVgs=; b=ohN0sIdVDS9E2yCud99PsPwyCRy4SI/PZ9dWIPhwYHhJ4XEbhZiO5ZB2PdQjucjIdVJPg2IU95uHCvSaa83Xu6f2AiYgxffc89M+Swa98DsgQsWoT9w61xpn8wWV4zzjE5jntV7UFtQtMm3nAr9GQ8K0TzIcFcgdihAxUYK0F3s= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) by SJ0PR10MB4734.namprd10.prod.outlook.com (2603:10b6:a03:2d2::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.17; Fri, 6 Aug 2021 22:13:39 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3%5]) with mapi id 15.20.4373.028; Fri, 6 Aug 2021 22:13:39 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V6 25/27] chardev: cpr for pty Date: Fri, 6 Aug 2021 14:43:59 -0700 Message-Id: <1628286241-217457-26-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> References: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) To BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ca-dev63.us.oracle.com (148.87.23.7) by SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Fri, 6 Aug 2021 22:13:38 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c150da72-dc7a-4e49-7adc-08d9592771ba X-MS-TrafficTypeDiagnostic: SJ0PR10MB4734: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:113; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: P5enNzmOS3GgY4DklVbLy19yRVSLNiup+RDWKmvv+8Dp3bEiVnZ5vt43X/JEaBT9r1A2i5l/HcDGN13uhZAMcDNgbjBXo476iUiit4Fq50gsCeftK3D5zTyRja+/enulhVsW7Q42P1T4i50LiwYPg1XYii9iJ/ndLeHGgIdurGDGqiLgL6ErWVm1AlogXisMJm9tSiLqa6PqAlN8G0nCO6UewfqMy/RwubzndEmqEdCiJfk9vXab3R22acF7MYZGm98Rkk4OjF+s4sa8ZsrOeCTfAcHO2QpgtYVnLZdVXxeJaIGa2UzDTtjD1IdzdGA4Y7VoYZsHWTXwTblzS6hFNzxMEXmEYDC9QWGHMELm3M9kiM2jYl2nQq50ryQXAovPQCDURBpP9X9KZyNm24xKnlTIhqjhrgxtDvcXuqut8l8evSVlgt2XtjmmfPz9iEHQROMIQX9eo/uXVX3y1Y4z2FxMi3qpI9hF+7jp2bzJ3U6R0JeaKJGtuKnHg9IA7THS3UrCePru4/uxpRBpY83noyCOjyXtAq8jtCwlijb4sTyqiP5r66KhsYkiQYlWOfzAmCoS+Qoz6wLM06WdSazxLPQ29apIYhwNc85F9ZBUxMa5As7i712uyeo8KCSnMLZh+YGrfXkXrZ+krRof520cIkL6pdHuY21SixOouZLjicyFVM5rerdIdb8FftrhbN/S X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(396003)(376002)(136003)(366004)(346002)(66946007)(107886003)(66476007)(8936002)(86362001)(316002)(83380400001)(54906003)(8676002)(66556008)(4326008)(36756003)(956004)(6666004)(26005)(186003)(2616005)(478600001)(7416002)(6916009)(5660300002)(2906002)(52116002)(7696005)(38100700002)(38350700002)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 53G/U4cXq1yc9Nojba1BEbC3iqHo+spcpJwvq4ckqAsKLI3weO5B5bAdUDwuYRqooHyp44Tyl5f4hexQFHxXrL3EuRLWX8nuUPMrpEYLg3XkoOTrhLXvbhcFlSzsduVw55RH/2CdwYEnjPegijFx8WkOBFWiHCOACMhV9ceiXyN0mRBc1MMoK2cQIiVJr1o0W+SboxZNo0EjkvxEnTz2YKpJBuglq9cLa03q1+1wqw6vWzj/s3kiMwbMDoA9MQcutTInjepqdguq9yQ8Q50DqfkF93rGP6sOhWrNJN9762/Syg9A6Wyl8FMYWeFqe207MVomPHQ/9VmZcydZAP48Zhh0ukCENWCBgLP3irYA2xqafKeNAIZNzF2F1yWPJ/nc5OG7RRdX4Q1DxNzOVCCDIKUgNRiKwsHow4jfYJj76g4EIpXWKS/HOnc+xXqiX+koAI8a76tl95F/nvtIMfJAgEInm8Lsn6uZakQxmbuizS1JTgRGG3ZN1w4LrpTwdHWC5SY0oZ0EWxWPYet6qJdaws7OWWNhcR55GF89veonDuezyf/1kU5/zaONYffcM9+ybfTAzaUNB9yBVExaNbaBh1GMXVO8Gx3pM713FgcSIpmBj/627wQIexEdesTz6cD39vxgzjv4mE3zobkoBYGoKv7OAeiCn7wxLABCbkcvIVz6jSB5F7yFMN6a7ZpYKLpdoUw76JJ+xpUSDqHWhmKyatQNfcW0XGsfEYC3mZMPY00MI9ONnuZrkvzl0N15ayPci3sof6qJTjAWYz/Vx78qS6Ul5zjpCbCkiPIPPQYp/xKeokcx+Q3XhyAS4R5j/CXnUIhgrylDfFJXm1ru+Y24sK/UpMecC5zSN0V5wyMHUEjwA2S8lP2cv3qwr7BvMplxZLOuwi/klT4LsZWQcD+o+0W5w883OBd2W1bhRfWqKVBAYBY41iqTnKXhhkyxOlJ89lJFF2MvIXRNfgS0M/uJCw0b+aqOdzeDz9/IGMIwtqOv1FOxryhnkgbMbUrfTsZ17Kg1gcq8oMZwnEmPNcthY2fASSw9Bhody+zYQMzTAb4eoNqpJjL2r1DMB2n71gCh5cV3/MZ5/e9bSNZxGNAZ8oY2mKMUoHfPFg0/GWao+WdUXASqWFThsU8FLJrZVYtonM0FaAm/LUAfMbRtrWXhZbGngD164LwUh+Z0xtJDB/RupN2qoeySWvQ4J6te3t1AVCIG7ZUoCsX5ojjuKzZmyh2bAlUOqlDpW407HMqAsN989OMdhG/GPW8JT10Tdmcns5lYhsjNohLEs0K/s5lB96nei4x2Ut83e/kuhWU9g3u1IJ/1oQ8q5P+9e6fA1ZpD X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c150da72-dc7a-4e49-7adc-08d9592771ba X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2021 22:13:39.7648 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vrRIsK6xFQ/YRfb20UPe3XGWWETYwcTgyy9wnXNCFhbcvdl5CNCek7M/oSBuBpHF6qUE8bFvULR+5Be7xmSD+zZNtoAHhPFD2DNXdpkueKU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4734 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10068 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 phishscore=0 bulkscore=0 adultscore=0 suspectscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108060145 X-Proofpoint-GUID: Ov-Q2PsCgpSOBoDDGbnXSLXxg84c1wKT X-Proofpoint-ORIG-GUID: Ov-Q2PsCgpSOBoDDGbnXSLXxg84c1wKT 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , Jason Zeng , =?utf-8?q?Alex_Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Zheng Chuan , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Save and restore pty descriptors across cpr-save and cpr-load. Signed-off-by: Steve Sistare --- chardev/char-pty.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/chardev/char-pty.c b/chardev/char-pty.c index a2d1e7c..721cee9 100644 --- a/chardev/char-pty.c +++ b/chardev/char-pty.c @@ -30,6 +30,7 @@ #include "qemu/sockets.h" #include "qemu/error-report.h" #include "qemu/module.h" +#include "migration/cpr.h" #include "qemu/qemu-print.h" #include "chardev/char-io.h" @@ -191,6 +192,7 @@ static void char_pty_finalize(Object *obj) Chardev *chr = CHARDEV(obj); PtyChardev *s = PTY_CHARDEV(obj); + cpr_delete_fd(chr->label, 0); pty_chr_state(chr, 0); object_unref(OBJECT(s->ioc)); pty_chr_timer_cancel(s); @@ -207,12 +209,20 @@ static void char_pty_open(Chardev *chr, char pty_name[PATH_MAX]; char *name; + master_fd = cpr_find_fd(chr->label, 0); + if (master_fd >= 0) { + chr->filename = g_strdup_printf("pty:unknown"); + goto have_fd; + } + master_fd = qemu_openpty_raw(&slave_fd, pty_name); if (master_fd < 0) { error_setg_errno(errp, errno, "Failed to create PTY"); return; } - + if (!chr->reopen_on_cpr) { + cpr_save_fd(chr->label, 0, master_fd); + } close(slave_fd); qemu_set_nonblock(master_fd); @@ -220,6 +230,8 @@ static void char_pty_open(Chardev *chr, qemu_printf("char device redirected to %s (label %s)\n", pty_name, chr->label); +have_fd: + qemu_chr_set_feature(chr, QEMU_CHAR_FEATURE_CPR); s = PTY_CHARDEV(chr); s->ioc = QIO_CHANNEL(qio_channel_file_new_fd(master_fd)); name = g_strdup_printf("chardev-pty-%s", chr->label); From patchwork Fri Aug 6 21:44:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12423991 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E60CC4338F for ; Fri, 6 Aug 2021 22:21:30 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5F88461050 for ; Fri, 6 Aug 2021 22:21:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 5F88461050 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:48672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mC8DY-00034Z-D2 for qemu-devel@archiver.kernel.org; Fri, 06 Aug 2021 18:21:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47464) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC86C-0000Bb-4T for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:52 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:63928) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC86A-0004UI-3i for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:51 -0400 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 176MBdcE032510; Fri, 6 Aug 2021 22:13:45 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=Ynl3rqDV80YypsCnO3SFfnqToaD3KbhyxyKpAHPDIy0=; b=yOyDYuhrswfWiOO1yo+YkU3B2qjWSoz7mSLJp/HDYcDh9rIscr+epNIoBQaETtWS4uVv E1quMj5xwzl2A2FRToi2p2IqUDdJVQH734rLJ1ZrWQLL7TsOp+U18GOwaBKpmH7ol0Fs Wa+bQ5dachUH03lNv37V0jv5p1ShsJ5gNOajKuFVuwB61n6yvQsZMx393eA/Vlq0H8mk qXFliPnBQt+nknm/zGA6KYD2k4kj4hYNTQBHCbLGGv2QC5koQ31i7xL/GGkXgK6pcCpq biQFLXYKo3qrxjyH2T8XFqqfwl9sLMtVwR2iYJSFZ6y7BoZNL3lsc8To915dRvhw8qRH wQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=Ynl3rqDV80YypsCnO3SFfnqToaD3KbhyxyKpAHPDIy0=; b=dTkQwh3HSj4f93FEGu9vpv3hTznroOzVUlo5sGTo6u5zuTbQ9TuFWesbLnPjyI3JQP7V Be6Op/sSyuSBMjXQDhV6BAaebkBuvNfQ6GJWC2UZegeAsBfwVie7zPPY47YQn/XLTooa 0+78aQbTbzlpCN5xzjE4s9PqUwP5fHnRjRoj+SkNNA1kiqNhd/4Srvi8kFKdQdR9Tx+F RZ3b9hxNpLcEEX7dQqdrsMDSTc8cbLmbhDZ5AtfCgPDC7+Tye9F7s1c+ZLuNJ0dXiuiP ZJwd9X77Ihka13cWSUqhBuh2lgpRmo4ycdKKsqxd1aQxWy2vTmFFTp6M4TEvY9vTg28F oQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 3a9661s144-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:44 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 176MBmb4013986; Fri, 6 Aug 2021 22:13:43 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2105.outbound.protection.outlook.com [104.47.58.105]) by userp3030.oracle.com with ESMTP id 3a962pfbad-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KqdTkR8vLECqXnxUptrCf0WsD8I25+V/Z90vN9Um52yB/7tlXme8PnyC8G27dn6EFoukrUMwdCVCh0V9rijLWGMWfh+VC5dSMgEzfbLfT5YOEcqBWlASsbMvU1huHbc5MiedvWLKC1AptMrmhT8bkAIADPqgDE24QLjldmFg6AnEY8JbY9oUnZ24+SvDMCYk4dhN5Dwl4RpQp1lP4BaFJ25gCx42c2VVy3pj+yhVGBplAzsqiQJRkWYqKElxTTnGPA81lln8N/UsA+PFRClmcxclr13KnXfXSxFlApafkBUj4UBezLabCrIyinj3B1Jch6ti0u6ami82ytcRowtCDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ynl3rqDV80YypsCnO3SFfnqToaD3KbhyxyKpAHPDIy0=; b=TKgCRGpzP5Zx71UXMza2HeLE12mYy4KsHZddPTK5/GgEXY0pZbIi+daRbZhwAiE6pGcUntz4bCniL0I21fqtx1LhD6oUK45kG5poMnlwVf6LHnOp1MKR43dQ2BYwVVS8InH8TD53QUvKBlIXYySX9qtxX3Qg1kEpaAnMpacvNOsWbTGL27Ubo6/3jCvYXgh7fswCktEiYV9DTf2+mRmOuLX9K5MAFYgclv8K8EwNYWlvQ8gkN56qt9iWa7ZF7Y7+hYxGd2uFYSyum6Xjp3YeFes9PPjYDbbswwCTRTyXzwgFNdyLZdc0/hBQNnqB/7h5ZQoP3ytZsprQWvN3vZtdBQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ynl3rqDV80YypsCnO3SFfnqToaD3KbhyxyKpAHPDIy0=; b=h3D1y4xOPIlfYE3Qmzo552+px/sK4ycZRRZqk6zLT8p/Wkpb92eyNvm8LqzeqgwMnVG3rvVjP1kkdIdXdJPHUtRqONzPycs+7NZF8vjo5B+Gh5AZAubs/DbkSAjWo/YF99VLSVLmhlSZEqYiBVFyCOHOH/jvE/EBYZh1yKi9Co8= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) by SJ0PR10MB4734.namprd10.prod.outlook.com (2603:10b6:a03:2d2::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.17; Fri, 6 Aug 2021 22:13:41 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3%5]) with mapi id 15.20.4373.028; Fri, 6 Aug 2021 22:13:41 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V6 26/27] chardev: cpr for sockets Date: Fri, 6 Aug 2021 14:44:00 -0700 Message-Id: <1628286241-217457-27-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> References: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) To BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ca-dev63.us.oracle.com (148.87.23.7) by SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Fri, 6 Aug 2021 22:13:39 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5bb8d30b-6b28-4f6c-fee3-08d9592772dc X-MS-TrafficTypeDiagnostic: SJ0PR10MB4734: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:843; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: I6Yph2+Fl06Opy4ZlV15B9S3PcNsnhTbO51cf/KQ7K25xl4QQi4EMRbi/Nexs46r75iqv3Ib/QY0r6S6FKpa/mfftEecXe/zU8REKZTLBLcp+yNYfeoH1lu8hCluRmWu6bCwjrsGxdDJOy5/EL+QsmzMJyXt1uyQ99oNeBC/KnHRswoa8NzdJj4mm+sX8EGMHyyckzdCruflGS/xBVpf1sB47OapYPR8X7qGGxDPSwjarhpUkGf3tYVi3s3ww+hjY2l+lAgGcjWBNj9wbAc3YFpB1RSvXJq9vEqheyTnWAj7eX556UChzz6jODMHcMOxbqNC03L2NbfvY5B4KX+sukYOKhEXv5rgmMeWeQQHlwTTtEmU65LQRjh0wnZirw989Awik4Czk/nhqmdMy4guFvqj709KAyUCm3SMqY5i8GacqA+Bxnl+QB0FCOH2bkFHbb1QFmXkjxD9dVWDHoHAlw/HPZSOUv9Jf+JVije9/OaTjrtKW1r9HayV9J/gBHPAB74aTTlgT54BuWrrgzcdt/K2Ob4JSXySAELEQU4bOT61RHr6KFecAk67isF6GOe/QNuk2qnT0zof+Ufl0XCePmx8M9OBUjZpEb5G6VpyT0SZS4JX1flk8UPUKNnkQ5JwcF1FffSRXOh43bPhkPMDPUDj3U9M/x/BCsWHdgd7ETEVAPJr+bzlv22oYEQPtB+03QpAYS0AFfyaRKOeQ9hvrw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(396003)(376002)(136003)(366004)(346002)(66946007)(107886003)(66476007)(8936002)(86362001)(316002)(83380400001)(54906003)(8676002)(66556008)(4326008)(36756003)(956004)(6666004)(26005)(186003)(2616005)(478600001)(7416002)(6916009)(5660300002)(2906002)(52116002)(7696005)(38100700002)(38350700002)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0f5cD9uz1wtmT1j2Bbce2hT6ONWsoDtChqDZEY9uc6FjcLvSijIBENMn5y+GIIMWzUuJ0rxK7M905YdXf0QeUB6i0631hBjBdsRajYI/YxExUv2fX5/as838ukS5vFTGFvkN2dES6l+B7ttVMQKwCTjrH3agwr+ncPR1Wt//7gJqtguvY8LMixNR0wbTn9ZhDrq/2Yo2t2j0Re2YNnwFtUWDShKG1DLUGTLmxBahjyO+Sf4zg4NeG37D9nXRxf6an7c9ZSlKdPy9GY/C6zFrirMkLXz6olO1TqnSPYaeIxiqkn2MyM3FnZsLLhWQKl6oceMbAlk/o+nUU/tbl1EudMTFCxQsovqM1o9nu9uWHYCX0XtQtX2S1nFWtEOYKEZSR/fPNh2foXng4Vbx7KjutWpbTXVfpNRXxc1JS8yAYSEFFkfUtVNtOvqBChZj/BMEe20TqqM3J0mFKmUe3AF5WoPq/5nqPn9CNQaTPOpCI8yl5O+c7Y6/IIEcOqDUjJEeEsQ7A1RIevatYRH8cAYvm95W2y52l9xtWDC6N3MbkXrBuIjtOA7NK9+CYW9JUtURkdLrU+YzqRVbK22rK/zlorG2VjPHlTfdRWyWUZwlgGVYbqpd9CSllMYe5KpDh5dQsqzrNYFv0EstU0xyWB8QlV5ANZuPFyuZH4byxetD0ABjdqEg/R1TKBNsw2Zl0oNhuHvcT/vc3X4MObpJEYuUUD9GPDRrHWRRa/AsOopSJ+vPld6O30cfwKkoTMcnbfyRuscVprN1+T5uzZ06YRhovnhUlcmz7GmX3jSI0VcU+0mIXHA/+aN2XzKTr5txXto9XN9N1yZ2S2ZRx7HRor89kPIoKfo9IJuEM/ReOk+zRmKTSvnkIvY63KfeUPd+kEhlgB9vGHOair1r7a6PYgVRPTchJIprB0hyqWzCVR2PHC91MwqHlh2WYEmUuy7njRbodvdXNTpW49YJuhn73yTqOhxy185cGtSKzBvVLQmJ5Pp545DFSHAqD5VTOWwc9+dTBc8g5snMTygQX2qw8HUQEMxyGlGpeorMRm5oX4E/yCYm6CXNh3dPrmW6bSooxXKY5inc9qGnfX8uRnXm8GnNhKqp69jLg2kpAn2FAXspWuGlx+CrQ4mxsPf0mia7mQrJBYwf6VZ0YJFs14yHd1OF+1Ge/ElPKAZBiS+wH3skSkMW8IzsTGP4JETu1RpRoWrftLT8w5xkwD58QCR6C46ftPY4Z0GnYETfqsiLtkzojJvPwA3uAGFes5xiZ6FVreOfFMu8F6in6NWFdFtNdzsRnug1bI6F80z3P977t404adNlzJy88Gh5oEDA/zL1iQ70 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5bb8d30b-6b28-4f6c-fee3-08d9592772dc X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2021 22:13:41.6587 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: izTfNbDocC8nFcYgcI/LlvyFS4/5W/1j9nXpsThrIZp+uovpDRt41PRrhcM7QlsxmCGNMp/V0Tc3+A7+dpX0BeUxang3srhKezjVoq5JrXA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4734 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10068 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 phishscore=0 bulkscore=0 adultscore=0 suspectscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108060145 X-Proofpoint-GUID: 2cg72fE365qIFtAyNlyReb1GW0lVr-A0 X-Proofpoint-ORIG-GUID: 2cg72fE365qIFtAyNlyReb1GW0lVr-A0 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , Jason Zeng , =?utf-8?q?Alex_Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Zheng Chuan , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Save accepted socket fds before cpr-save, and look for them after cpr-load. in the environment after cpr-load. Reject cpr-exec if a socket enables the TLS or websocket option. Allow a monitor socket by closing it on exec. Signed-off-by: Mark Kanda Signed-off-by: Steve Sistare --- chardev/char-socket.c | 32 ++++++++++++++++++++++++++++++++ monitor/hmp.c | 3 +++ monitor/qmp.c | 3 +++ 3 files changed, 38 insertions(+) diff --git a/chardev/char-socket.c b/chardev/char-socket.c index c43668c..f6d00d8 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -27,6 +27,7 @@ #include "io/channel-socket.h" #include "io/channel-tls.h" #include "io/channel-websock.h" +#include "migration/cpr.h" #include "io/net-listener.h" #include "qemu/error-report.h" #include "qemu/module.h" @@ -414,6 +415,7 @@ static void tcp_chr_free_connection(Chardev *chr) SocketChardev *s = SOCKET_CHARDEV(chr); int i; + cpr_delete_fd(chr->label, 0); if (s->read_msgfds_num) { for (i = 0; i < s->read_msgfds_num; i++) { close(s->read_msgfds[i]); @@ -976,6 +978,10 @@ static void tcp_chr_accept(QIONetListener *listener, QIO_CHANNEL(cioc)); } tcp_chr_new_client(chr, cioc); + + if (s->sioc && !chr->reopen_on_cpr) { + cpr_save_fd(chr->label, 0, s->sioc->fd); + } } @@ -1231,6 +1237,26 @@ static gboolean socket_reconnect_timeout(gpointer opaque) return false; } +static int load_char_socket_fd(Chardev *chr, Error **errp) +{ + SocketChardev *sockchar = SOCKET_CHARDEV(chr); + QIOChannelSocket *sioc; + const char *label = chr->label; + int fd = cpr_find_fd(label, 0); + + if (fd != -1) { + sockchar = SOCKET_CHARDEV(chr); + sioc = qio_channel_socket_new_fd(fd, errp); + if (sioc) { + tcp_chr_accept(sockchar->listener, sioc, chr); + object_unref(OBJECT(sioc)); + } else { + error_setg(errp, "could not restore socket for %s", label); + return -1; + } + } + return 0; +} static int qmp_chardev_open_socket_server(Chardev *chr, bool is_telnet, @@ -1435,6 +1461,10 @@ static void qmp_chardev_open_socket(Chardev *chr, } s->registered_yank = true; + if (!s->tls_creds && !s->is_websock) { + qemu_chr_set_feature(chr, QEMU_CHAR_FEATURE_CPR); + } + /* be isn't opened until we get a connection */ *be_opened = false; @@ -1450,6 +1480,8 @@ static void qmp_chardev_open_socket(Chardev *chr, return; } } + + load_char_socket_fd(chr, errp); } static void qemu_chr_parse_socket(QemuOpts *opts, ChardevBackend *backend, diff --git a/monitor/hmp.c b/monitor/hmp.c index d50c312..993df18 100644 --- a/monitor/hmp.c +++ b/monitor/hmp.c @@ -1458,4 +1458,7 @@ void monitor_init_hmp(Chardev *chr, bool use_readline, Error **errp) qemu_chr_fe_set_handlers(&mon->common.chr, monitor_can_read, monitor_read, monitor_event, NULL, &mon->common, NULL, true); monitor_list_append(&mon->common); + + /* monitor cannot yet be preserved across cpr */ + chr->reopen_on_cpr = true; } diff --git a/monitor/qmp.c b/monitor/qmp.c index 092c527..0043459 100644 --- a/monitor/qmp.c +++ b/monitor/qmp.c @@ -535,4 +535,7 @@ void monitor_init_qmp(Chardev *chr, bool pretty, Error **errp) NULL, &mon->common, NULL, true); monitor_list_append(&mon->common); } + + /* Monitor cannot yet be preserved across cpr */ + chr->reopen_on_cpr = true; } From patchwork Fri Aug 6 21:44:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12424019 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3AFC2C4338F for ; Fri, 6 Aug 2021 22:31:11 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7153E60EAF for ; Fri, 6 Aug 2021 22:31:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 7153E60EAF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:50278 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mC8Mv-0006lR-CR for qemu-devel@archiver.kernel.org; Fri, 06 Aug 2021 18:31:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47492) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC86G-0000QP-Cf for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:56 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:3170) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mC86D-0004Vo-W0 for qemu-devel@nongnu.org; Fri, 06 Aug 2021 18:13:56 -0400 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 176MBWWq018324; Fri, 6 Aug 2021 22:13:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=L+oepirhFKnW2hA5F+wQIflOnajOhhxOYl14RZdUlJY=; b=HofGySrqSuu9qS+p3UFH3z3fV/J/RYDg4LV2ZTgVIiMdtZ8nryIdeYpsx7RTbc1EU1ld z6j6siE8TY5FD1zfMP8TBYp31fzyjLfaF7Yn1jHPMIgHfECM6MHFs8+7yJnztqdriavE woWUx4Dcq0KGb93DxUSQAeKnHr0nWWXegVcPL/x+1i/KoL9QWXeNDHxkwS2aGzSdClwI ZMcYxgakqVPJDVZyD3p+uSOIHLQS6Iq+pWjFSlK8AvHXIBsZ44vw04qG+DwWOIIjW/eL rcYmKMs1awbFiymguaOKQRo6Hnt3ICkeApk+HKvRnnRTRf748iRD3FtXyyBekQbYbUrG Mg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=L+oepirhFKnW2hA5F+wQIflOnajOhhxOYl14RZdUlJY=; b=EIfhiJT3EzJMaeDpwO0hhDk1rmKw2JLaToozgVKDjSfbnOfLU2cgfErs2NsBA9pwIbj5 5lLEHMUGtMKrdAYcfU8z+Bq0foSqkq75IRu7P2cEBxhXhUbithVHH0w14EvPdocJmivx 3rIT7eggc4m8fzBmP/1pFJT3bja5JLlsOLsDOdBYogc4F+jbq0UdRooakPLmV/4/l4B2 TWlkvh5rvSBAvI1xWzBP13hJ5vuSf6M3A8dPBlAfGMLV/Q7pQVriWsHd4j3uQZdnB1wJ PA1iwbcsCYiUr8LvjTGlmYOyD5sZyDyoaLMLm3epY6uMEWCDsGnYfCs54DCJuKvM8z3h HA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3a9645s135-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:46 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 176MACfm083094; Fri, 6 Aug 2021 22:13:45 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2102.outbound.protection.outlook.com [104.47.58.102]) by aserp3020.oracle.com with ESMTP id 3a7r4cayc8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 06 Aug 2021 22:13:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RBxTrXLJHHUiPLfoqVMnLpq6WNFTkp8hk3kwt+Zx10blMK5WucZHh4YW6tNoZdvuGxojw/OH40eForfBROher1zz9cu9clgQ+yRGodT8j4LVRYT51yIqN3x53lWX18HmaW8t3zOHYU3lOB1eM/Fvqdc0m968JfwfG7n3cnCS4VkHmtFIUDFR4JllIH6kJKXZm+gWAxiaf/LNYDHbsfdgHDU/g5ncmiHjnmj3k2cfoqxV8gK0SVfziugq7+E6WPG4wwfuAri58Y92s4Hrve4lAZMcFu+9rHMwGBLv6x3eVfQYW5H6U6Tf49hY0vAax4s1bFNWaxgTWSIi182DZaqAsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=L+oepirhFKnW2hA5F+wQIflOnajOhhxOYl14RZdUlJY=; b=UPk91/eX1iGxIKqfSF7pr3Ad4xKDINpQUVOEbyPUxm7WE0WEW5vFsZPY1PCeFMFGv0VjqLzpCwJaLvRN+3I0a5XJa7WEvT0Kiji00FlN1GnpJziHIR9iXJSt7ySVa6Be9XQ4uIXGWrd1clrRORwHxD8iS6MPiLBV/ZI3JaWOq2y/EKSqemFZ6s0oNzInN3CwKcP7jVXqIfpG4hTawkdoGIiNlPToaFake7JdODJDr96YtFENAw/pQ0gLYcju34Y7JCgiltEOMbwDjuxMGXaBz2jEY214CHVJV+K1T/MecJtMcGvkC3w/o1/QYU2noSH4gamJcG5HguU7HYMwFQKGUQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=L+oepirhFKnW2hA5F+wQIflOnajOhhxOYl14RZdUlJY=; b=tGobPU01m508cU0qRQ2Sw0O7/ynm7DWZUKrZJq1I2tS6meytL/zLxsNVksmhaS8QP3O03yjjWRJXWsoocKVeZdrBhPx65j2ylOBWwa1XW9dK+IboJOoGCuldUYGTQ0c0tFbd+ha4kTwevSyyS03iws+F7/Y9ItQz/EX0Vn/QJ+s= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) by SJ0PR10MB4734.namprd10.prod.outlook.com (2603:10b6:a03:2d2::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.17; Fri, 6 Aug 2021 22:13:43 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::99fe:4091:351d:11e3%5]) with mapi id 15.20.4373.028; Fri, 6 Aug 2021 22:13:43 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V6 27/27] cpr: only-cpr-capable option Date: Fri, 6 Aug 2021 14:44:01 -0700 Message-Id: <1628286241-217457-28-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> References: <1628286241-217457-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) To BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from ca-dev63.us.oracle.com (148.87.23.7) by SA9PR03CA0002.namprd03.prod.outlook.com (2603:10b6:806:20::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.16 via Frontend Transport; Fri, 6 Aug 2021 22:13:41 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 71f93dc7-a7d9-40f6-d058-08d959277408 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4734: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1417; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SZO1V5QMiQP/bSO425lxZVU74jxy60Zld/JgfJ9VX6T2g5U9zZ48SdKM0s2geMusVWgjvOUAvSlQX+J/Uk0YL/ZceZDKGUq5Ro8syA9tB7TYl0kayREZFukOM7gURgUr47G+esxZa6b8rAgCiHYOpeIf0xzmPf3IdHMTJm/KU912sN4FiPCzo8O8bjX1ovqJchCyE1GlQ0eKyG85KBOWueYiEJZIpTXmuedde1Ll9NDqwLrHf22+Ib/rTD4zMVw3p8KXgMfgqVe7gwmC3GEjZc7XHY4X35EStDe3VoWJQkF5ApzV555bmzTa5+sgNZFXCBrl5uXV2C4zRsY50a6iCSCiw9QwpxN2anIdDe8BMq+YVy2kyVj89/cI+00zCvuNQq+1G8fDzvgPVRdR8T9sC5zRqFh4TPOFz86q77Xx/EriHjWlPKp6lmnTo4pgbnOo6utw1mI2ihRxsq+5q5uWMR0K57jElAHGfeIbLnjbuh3oaneGzYd6CECtFnSdAh5nu7Q5CG8ZPx2bb3UGsNXoGT1FpAxXics83RKeWmvBNnIhADRPdy0QwDN65BOcubJYxRi9bWbX6vkBFwcdbvzCEQPKqLWB/94Klgi8/uQU/59SHR3Pfy89kSnSDiqNW0Q7dheKgmVMXLnze1rdNZia4MG/rCCRThBiuhl4Vkdm72fi81tczz+3T7TDS6C0dIEGXElVOcE7pR9e7p/RUS+Hug== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(396003)(376002)(136003)(366004)(346002)(66946007)(107886003)(66476007)(8936002)(86362001)(316002)(83380400001)(54906003)(8676002)(66556008)(4326008)(36756003)(956004)(6666004)(26005)(186003)(2616005)(478600001)(7416002)(6916009)(5660300002)(2906002)(52116002)(7696005)(38100700002)(38350700002)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: JNdIIzSW64kLJqZ6AGTj9L2dQs+EUJjYZXnQoP6stnG+Uh/JrZ1k/Z8IfROxa0E0bhRS/AsUO6dMdSa5VRCn16zjOMPJko3EofEmBd/oYgFYkDCyC7SGxjIHLgbj0eiwVaezScBmvEH9jZbc4sPHtXM8+hE9mGZKgYgITYoNXiFJwV1dUNHmNSJJSZTxv/txbTKcg/E7DJe4ETOD6aBjEeGSdvSwOerRS6fUAViMi4UfPZGR9H9jRW3LaIJs7t5ThJj7ju8+BJ184L5EQCOeJa83sk9r6RnswaySFp5BuVUo3j+jkRmE8BONX4vXFeYzhAZkPi60TvkbyK98w/rkn9p4s+cQzwvVRTIMsedSxfBrDlgj+87CETeo7Fmat8KBcirM9MheHY1FIf3lMOPgEHRJ5lxZxzyi1G5Bc4IUGSH6a61+Tcfjrv54/eIA82gZ2R3hcveSFWX4JvdlME4PyqnEdr1SBsw+AQcT820b4GyO+MEnQeoeqgEgJgE4XuXrxsEa0ID+A5ICkSFSYcK81OfMMMn0ibc2XfZi2Nqhs4f0Fzdi0hoPgYB55fgQh0Lxpc3SdQm4SgYqQUsqBr8zsN+K2eJV6KME44a1QFUQJWBrpxvci94aX9v9TYHjnSA6bv+xrMPBYf8LyMNf3mJr7mO0ys/lZtkxxIaO5m9yql5hoxKVfa8CyZR1j6D90XTXpcEJdD35hxIbBsEswsuxdPik7pTLKovqbOzrTXX5BNM2QG46WzPBQlslzhNEMAMSCTaYo7nY2gRD0LxZfEjo9mK51FUiUAat/HNpOsrEAmPQWONnNaCDPnyxWyeKguS7/h2AclfbZMx5xYoGjHbyayV+b15eV0ExXd4QaidjIfcGdVRCXuhHPrUk+byH4UC+Ng2p5qpxPp4Qezfj9mtX3N9HRlV5Bo1C9Wd1yCkAJ4P45yvy7bRjKN36oP2OYQGXbzc0+b78Hm9crFiH797Pu58krLhDjtM57pL9s2T64N/o9WcSEIB90nc6qtoEI7UYa6S5iD1y3dFrRCAXDupNbzjmmFaDQLZh4N/y+H6sqjPgZ4TFqQPQLWwhYbi7s6tRRVNYCyWFe1bPN5nnyWU3ioe8mQBfiYDnK3OW6Sr/SqluImySH0EoOxu42nbI45CNIPYda2xj7XO5gcAbGqUanZgRUGvYc5KKOIvs6J4jNQOAWQPxgezlQc3vpJQ37XhI1qOf9ChBIS1oNMmmqLxvD16qVgq5qOcrzkjQU7x9k5vetWNs8kB0BQ9iEDTUydFj4p/mmTziPjUr0nl5Dj1nfIkilnYoDaYVtkUZpSjDZu+dmH1IRD6jHWPbvHvwoScN X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 71f93dc7-a7d9-40f6-d058-08d959277408 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Aug 2021 22:13:43.6506 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ErPOUPJokgoE8cyCaUXMoO0HQdzOmfluHhMmfyEdCQUCXR83BdLT2ZKx3GIveNoXg6a8sjh5SPQkKkM3HRS8NAhwgPY6Z1wBKEPbqZyTJJI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4734 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10068 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 adultscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 spamscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2107140000 definitions=main-2108060145 X-Proofpoint-ORIG-GUID: GQTL-wbgAfAqh99xJ86Mr1s6a49bxVO7 X-Proofpoint-GUID: GQTL-wbgAfAqh99xJ86Mr1s6a49bxVO7 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_LOW=-0.7, 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Daniel P. Berrange" , "Michael S. Tsirkin" , Jason Zeng , =?utf-8?q?Alex_Benn=C3=A9e?= , Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Zheng Chuan , Alex Williamson , Steve Sistare , Stefan Hajnoczi , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Add the only-cpr-capable option, which causes qemu to exit with an error if any devices that are not capable of cpr are added. This guarantees that a cpr-exec operation will not fail with an unsupported device error. Signed-off-by: Steve Sistare --- MAINTAINERS | 1 + chardev/char-socket.c | 4 ++++ hw/vfio/common.c | 6 ++++++ include/sysemu/sysemu.h | 1 + migration/migration.c | 5 +++++ qemu-options.hx | 8 ++++++++ softmmu/globals.c | 1 + softmmu/physmem.c | 5 +++++ softmmu/vl.c | 14 +++++++++++++- stubs/cpr.c | 3 +++ stubs/meson.build | 1 + 11 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 stubs/cpr.c diff --git a/MAINTAINERS b/MAINTAINERS index 3132965..1cc0f73 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2910,6 +2910,7 @@ F: migration/cpr.c F: qapi/cpr.json F: migration/cpr-state.c F: stubs/cpr-state.c +F: stubs/cpr.c Record/replay M: Pavel Dovgalyuk diff --git a/chardev/char-socket.c b/chardev/char-socket.c index f6d00d8..a6ffb93 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -39,6 +39,7 @@ #include "chardev/char-io.h" #include "qom/object.h" +#include "sysemu/sysemu.h" /***********************************************************/ /* TCP Net console */ @@ -1463,6 +1464,9 @@ static void qmp_chardev_open_socket(Chardev *chr, if (!s->tls_creds && !s->is_websock) { qemu_chr_set_feature(chr, QEMU_CHAR_FEATURE_CPR); + } else if (only_cpr_capable) { + error_setg(errp, "error: socket %s is not cpr capable due to %s option", + chr->label, (s->tls_creds ? "TLS" : "websocket")); } /* be isn't opened until we get a connection */ diff --git a/hw/vfio/common.c b/hw/vfio/common.c index 872a1ac..2f8f982 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -38,6 +38,7 @@ #include "sysemu/kvm.h" #include "sysemu/reset.h" #include "sysemu/runstate.h" +#include "sysemu/sysemu.h" #include "trace.h" #include "qapi/error.h" #include "migration/migration.h" @@ -1859,12 +1860,17 @@ static void vfio_put_address_space(VFIOAddressSpace *space) static int vfio_get_iommu_type(VFIOContainer *container, Error **errp) { + ERRP_GUARD(); int iommu_types[] = { VFIO_TYPE1v2_IOMMU, VFIO_TYPE1_IOMMU, VFIO_SPAPR_TCE_v2_IOMMU, VFIO_SPAPR_TCE_IOMMU }; int i; for (i = 0; i < ARRAY_SIZE(iommu_types); i++) { if (ioctl(container->fd, VFIO_CHECK_EXTENSION, iommu_types[i])) { + if (only_cpr_capable && !vfio_is_cpr_capable(container, errp)) { + error_prepend(errp, "only-cpr-capable is specified: "); + return -EINVAL; + } return iommu_types[i]; } } diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 8fae667..6241c20 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -9,6 +9,7 @@ /* vl.c */ extern int only_migratable; +extern bool only_cpr_capable; extern const char *qemu_name; extern QemuUUID qemu_uuid; extern bool qemu_uuid_set; diff --git a/migration/migration.c b/migration/migration.c index 041b845..3556f01 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1249,6 +1249,11 @@ static bool migrate_caps_check(bool *cap_list, } } + if (cap_list[MIGRATION_CAPABILITY_X_COLO] && only_cpr_capable) { + error_setg(errp, "x-colo is not compatible with -only-cpr-capable"); + return false; + } + return true; } diff --git a/qemu-options.hx b/qemu-options.hx index 3f0c974..c47af4c 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -4374,6 +4374,14 @@ SRST an unmigratable state. ERST +DEF("only-cpr-capable", 0, QEMU_OPTION_only_cpr_capable, \ + "-only-cpr-capable allow only cpr capable devices\n", QEMU_ARCH_ALL) +SRST +``-only-cpr-capable`` + Only allow cpr capable devices, which guarantees that cpr-save and + cpr-exec will not fail with an unsupported device error. +ERST + DEF("nodefaults", 0, QEMU_OPTION_nodefaults, \ "-nodefaults don't create default devices\n", QEMU_ARCH_ALL) SRST diff --git a/softmmu/globals.c b/softmmu/globals.c index 7d0fc81..a18fd8d 100644 --- a/softmmu/globals.c +++ b/softmmu/globals.c @@ -59,6 +59,7 @@ int boot_menu; bool boot_strict; uint8_t *boot_splash_filedata; int only_migratable; /* turn it off unless user states otherwise */ +bool only_cpr_capable; int icount_align_option; /* The bytes in qemu_uuid are in the order specified by RFC4122, _not_ in the diff --git a/softmmu/physmem.c b/softmmu/physmem.c index 2e14314..8db8a6d 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -47,6 +47,7 @@ #include "sysemu/dma.h" #include "sysemu/hostmem.h" #include "sysemu/hw_accel.h" +#include "sysemu/sysemu.h" #include "sysemu/xen-mapcache.h" #include "trace/trace-root.h" @@ -2006,6 +2007,10 @@ static void ram_block_add(RAMBlock *new_block, Error **errp) addr = file_ram_alloc(new_block, maxlen, mfd, false, false, 0, errp); trace_anon_memfd_alloc(name, maxlen, addr, mfd); + } else if (only_cpr_capable) { + error_setg(errp, + "only-cpr-capable requires -machine memfd-alloc=on"); + return; } else { addr = qemu_anon_ram_alloc(maxlen, &mr->align, shared, noreserve); diff --git a/softmmu/vl.c b/softmmu/vl.c index 924e8f9..7c638d8 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2695,6 +2695,10 @@ void qmp_x_exit_preconfig(Error **errp) qemu_create_cli_devices(); qemu_machine_creation_done(); + if (only_cpr_capable && !qemu_chr_is_cpr_capable(errp)) { + ; /* not reached due to error_fatal */ + } + if (loadvm) { Error *local_err = NULL; if (!load_snapshot(loadvm, NULL, false, NULL, &local_err)) { @@ -2704,7 +2708,12 @@ void qmp_x_exit_preconfig(Error **errp) } } if (replay_mode != REPLAY_MODE_NONE) { - replay_vmstate_init(); + if (only_cpr_capable) { + error_setg(errp, "replay is not compatible with -only-cpr-capable"); + /* not reached due to error_fatal */ + } else { + replay_vmstate_init(); + } } if (incoming) { @@ -3446,6 +3455,9 @@ void qemu_init(int argc, char **argv, char **envp) case QEMU_OPTION_only_migratable: only_migratable = 1; break; + case QEMU_OPTION_only_cpr_capable: + only_cpr_capable = true; + break; case QEMU_OPTION_nodefaults: has_defaults = 0; break; diff --git a/stubs/cpr.c b/stubs/cpr.c new file mode 100644 index 0000000..aaa189e --- /dev/null +++ b/stubs/cpr.c @@ -0,0 +1,3 @@ +#include "qemu/osdep.h" + +bool only_cpr_capable; diff --git a/stubs/meson.build b/stubs/meson.build index 2748508..dd9e51f 100644 --- a/stubs/meson.build +++ b/stubs/meson.build @@ -5,6 +5,7 @@ stub_ss.add(files('blk-exp-close-all.c')) stub_ss.add(files('blockdev-close-all-bdrv-states.c')) stub_ss.add(files('change-state-handler.c')) stub_ss.add(files('cmos.c')) +stub_ss.add(files('cpr.c')) stub_ss.add(files('cpr-state.c')) stub_ss.add(files('cpu-get-clock.c')) stub_ss.add(files('cpus-get-virtual-clock.c'))