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/UFWGmIx1rRIweq0gxbsEPidcLrHGPCNSjgKWgKcypkAKHro7D4F8QTAJoS8RGYCkEZjEIhiqu2843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yRLAZjNjkiz6PGzMBz0HtpC6mnwVTd6pev+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,