From patchwork Wed Jul 7 17:20:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12363123 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, 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 5A646C07E95 for ; Wed, 7 Jul 2021 17:36:33 +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 EBFB261CC8 for ; Wed, 7 Jul 2021 17:36:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EBFB261CC8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:38480 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1BTM-0004yp-64 for qemu-devel@archiver.kernel.org; Wed, 07 Jul 2021 13:36:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47978) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKT-0000D3-KG for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:21 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:21326) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKP-0006jH-Dz for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:21 -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 167HCEqN003527; Wed, 7 Jul 2021 17:27:12 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-2020-01-29; bh=1QZTvYAJi0a+xjzUiWVOa0M109U7m9mKLQJiOLgpkIg=; b=uWqkmOUbG/jBugoZLuhqhQsdjdWFbYuBBypZwhU9nDE8H29W66YHgFnS/1M+hE+Z3TP3 Hd10MYVn13yk0q4tv/T84ly9EBmj04vZ0uZCMMYJcQR+uvmI+y1OMdgiZRZ9AI9wU9v9 degVHVQ9QhS5BrFTcf4QJ1DpFksmZLmSKaWgf+5aHZ0DH29c6alhnJo9m3xaAf6vyYOs GSa3BSiuEtS9eULsgrM4lzqYCz31rhUzksQnJBFQg0+EVbbo+8iI+nlViQB0EFYWxfd5 WwblwpZSsP50EYqL5Kc3ESiIZCth4eNY0xpzxsl9fE5Tb9RmlGEiEYcaQ/HHQ+Sd90iH 2w== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 39n4yd1er7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:11 +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 167HA9YU026110; Wed, 7 Jul 2021 17:27:10 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2043.outbound.protection.outlook.com [104.47.66.43]) by userp3030.oracle.com with ESMTP id 39jd13ub9h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:10 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Shl08xvwjazsvDPUXU7+Y1PaU7sC/pkdK9WiWkuUj7y4o4/WUiaGT17zgdxOR+bhBCiMIoc8Ekodel0Y57EqTUpHGZVtUEQoqhczxTfqIk4I8mUkR66HH1FIuvmftpOUZIyCuQbqV7W82eYGpgL4iy6hVw2NdW4y7jHbVj/swI6wLaAdVx9fq5BlQZDRV4j5i67FZoRWa+OaeXBH6dm1aEbaZ4HWDWAWWwBjcDy7/Uc2rJjGAazP2ClI8YOhCdNIS0UCA3dhgx1zOoAomkp9EjZAu9xpTrL7YGLOoUOgbm1CBSYopfuseTK+pD/CCW7GNXcYQsF71JqQSRwIolHVlQ== 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=1QZTvYAJi0a+xjzUiWVOa0M109U7m9mKLQJiOLgpkIg=; b=dw6ifdUhCnuolpKqF86UHkMhz5UtvwjUZyo4KddJHHZRSYOSiaS2upJgI4LC7UiDF9o5PIPtxeahG38qw8ywCUNR8ptyhFvEP01JUAIv5FGQgdObyI6v7Om2VTEYNzsYNzthJJXJiGp1WMYzlW4HpdkXb2zYMjnFMxd2WajvkHKoCqbMTsLnMUvjr4nlgYohDEuaf6GmjFQhYKZRSn3dsfXLsJM+T9aC9Lca8lerSGsN/yhasmo488Q+XtA4kk+zduTcLtAZZgo3EC8rTJHQ3HRx0a3BN6tGvOB0Jxv61DGOd/LcjE8I9OtBgAW9OyBG5Hdn03EBqxgQgJzMy0io2w== 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=1QZTvYAJi0a+xjzUiWVOa0M109U7m9mKLQJiOLgpkIg=; b=a/WQ7p0/E9QKFJ+SYtLRrt7+Ly/MCNXRb3uZVvxCxbd+bU67+FQSmC2NJWcCn0I2zkEPrxztQh2D66mobldACX5Q8C/N/xNd80eI+PNQxDMxCQ+yCMQfCj54vKnIRzDwQj6anM4Ksqi16bAqcsu1M/QETdqnjYIfO32lIB0M/bo= 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 BYAPR10MB4104.namprd10.prod.outlook.com (2603:10b6:a03:11b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.23; Wed, 7 Jul 2021 17:27:08 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba%7]) with mapi id 15.20.4287.033; Wed, 7 Jul 2021 17:27:08 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V5 01/25] qemu_ram_volatile Date: Wed, 7 Jul 2021 10:20:10 -0700 Message-Id: <1625678434-240960-2-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> References: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) 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.13) by SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21 via Frontend Transport; Wed, 7 Jul 2021 17:27:07 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2cbf9a56-9ea9-4ee8-9006-08d9416c7220 X-MS-TrafficTypeDiagnostic: BYAPR10MB4104: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:328; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wCXQGACru4O5OATG7wGlJwiyU+pz+4bZZKDGIoEtgzP48Q0YgVbRMRVyWNf0JJsZ2RTBLXbQbknEvHNDjKd+76sT77nwU14RCvrOgyqU9HyTJF95Bh7VOQFQtC72LGm3J3cOVSs8JZxDp8Yhm6Q6HAYNYcNQDNqo9vzVYdPlJ5/CWaN/7KykiLRag910BtyUNjFQgvMmvtSPhfLhxhpJvMmwLTA1vi4dzXnQMkamdIvFLxmU1NP0LrB5vkWlMVKMXjUakr9139w0deEaHN+K3Joq3xjh6be3dyyXV5miiMVk/02fLdtx3gSXCNFX1w887YQoO0UuKcUlMlfXnZtufYqImutyHlFq7LKEvKVc07R2jlbSMNwfKAOKrDqM2qxK+dTMnAJVgMl+wefzJQB7IAv8AGf/mIn2AF6eFhPzYaToKbpfObxen5nSwdsuAPBK3zofy5MB/cs3J8ozfQFTMdN3A3wp+jJthDCZ0nDFwRSmeD9Ckh4md0Itp0wbUznWo5N2c8xFvJA3QYH7ftyhILtCiAazWvCMPG2ytawOZi4wdSpMpliEl0EuTgdqqoSqdjNSYh1Pu1WALqtZnwznHbmRAYPMgostog1bIAzMf71kIGrHOp6gOeldSRZ35QbgYCECwY5VPp0V+WjrUU5COFDM0nukAIbjRAupgE6APZGAhF1L+HJyENqGkKRkHWDixgiiDyvd5nXQF7MfuxcBag== 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)(39860400002)(376002)(136003)(396003)(346002)(478600001)(36756003)(2906002)(2616005)(38100700002)(186003)(6486002)(66946007)(8676002)(7696005)(6916009)(956004)(8936002)(26005)(66556008)(7416002)(38350700002)(66476007)(5660300002)(52116002)(54906003)(4326008)(107886003)(86362001)(316002)(83380400001)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zBEJBpvk2Jk8I3SS0xqg1BdstXpkPWKQAi40eYnvzBphgJpsVZeTyX5gSLm+dGr0gGht3C/Za8/rJoKsGWDhTmrBJkOG3MchqrVWnxCI0gNvHR88GNIYu4wjl/2eCbTejScuINH8eI6HjGlG3QTqQmEl6knvD0LfGgYDcrALCOz942Zo3LuxPi6WQESPxFu0P+x+8v7fMMacsTfJjTwjVCD/8i7oXdc6vvNyCeTWOMNZbXZkidPaBeFCyX/VFpOV7bwihqoQKuPCIgfU8+agBGdnNclCxDi0Ur5HmX2eHE8wOkSXd3+aNLuI1XxF6xwtzE13Lkd2gFm5IjOB/t/v+mBjgKIrvgKeQ8vz66m1EB7krRsLuSfWvykgTLpuzrSzGP1DABLlWq1kojLSQDQJjHPwTNT6Vhfbta3I/HK70ZZyMjmfaJLLg9xiLTVgWi59NF/2b9f4GWiSAeOItINJz/raPVsxCckjJVXtJGzQKwkVqhMbB1hUjM+zyZyfv2Jq7palXoEFk7qQcRTupSVR1fmmuy66t3aqMLi3cJoyBij0HGrspN0tH9S7Ge95X58F9klMTLeP95Zfj1pe+DtF9qa0sO2lMPFh6jms2wK4wBYJKQsuwvZKaoTCnpWPThwAPy2CPcxsXa8x+QlGrvXgav2z7w5n6V1xBcsNu5fzCmKAEDB31ckLXgPXMKXYLSuDOF21AuUIRxckra8h0tEufFwhTlXMhh5W97F8FLF0JqgHsJqGZHpF4/npxzuesGGKQ7mqQC97i7F4TVKqrcNAOS/zZTElaHMPAPzcW6lAbOC+l9V0drigc8dq5GnfVhbja3qnpz4V6WmaD7jt6ppi9oKkj6Cpv4nf1dVXyG3DNNog6gwm982E/oNfpbdA9zWN6SpJuFwg1l6brSm9TVYxjb9xYjm5p8eJcKf+qQXC+DYg3h3Vgq6HzYWbxaFVXUtXkOKwmYnRCu4EHRk4sgDXWMq7fwY5axJOrUA26SAucNufNSKsBq1n35Kuqyyk39WCyHrTWG64quNy8GGUQy2iEgzZ/ARZEBX7cQXYM+zL3ValkxGFXxKfeAiOQyXmvzSaT5elPqcEYWL8L37C8UYU3RvCEMryv1D5v08tLaB/iMdygBKEiKgqremuVatvnANi1WhfS4aV81xoqFZA1ln28fw6rq5dksHkXzv4I8yfXRKaP4dsCJCxulKg+ZBPmXVg2vXsUgOejvtLV0pvXSRU0XwSs0U9z75O4DTRsZ65B9aYGldftl9n9ESfaqbJFiVSrP5+22o1xUPo8NvhHtXcUjsdyCZxGWd9fH1OckDkTNo8x+mcH4RnpH1k0M0Gy8vT X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2cbf9a56-9ea9-4ee8-9006-08d9416c7220 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2021 17:27:07.7795 (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: zw73V1q2FcmdphE/nwowfPTkUGQtmjtrq0nqG2GEbEuk1zd3zNp7Pk9fslIJht7mXvG7qqFSsbA4RXbAWl6/7AEgOfegiEVNyVySylDhSfc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB4104 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10037 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 suspectscore=0 phishscore=0 mlxscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107070100 X-Proofpoint-GUID: f1ZaQlggTU05qErZ4pE1InlIWTsemwLc X-Proofpoint-ORIG-GUID: f1ZaQlggTU05qErZ4pE1InlIWTsemwLc 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 , 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 true if any ram_list block represents volatile memory. Signed-off-by: Steve Sistare --- include/exec/memory.h | 8 ++++++++ softmmu/memory.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/include/exec/memory.h b/include/exec/memory.h index b116f7c..7ad63f8 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -2649,6 +2649,14 @@ bool ram_block_discard_is_disabled(void); */ bool ram_block_discard_is_required(void); +/** + * qemu_ram_volatile: return true if any memory regions are writable and not + * backed by shared memory. + * + * @errp: returned error message identifying the bad region. + */ +bool qemu_ram_volatile(Error **errp); + #endif #endif diff --git a/softmmu/memory.c b/softmmu/memory.c index f016151..e9536bc 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -2714,6 +2714,36 @@ void memory_global_dirty_log_stop(void) memory_global_dirty_log_do_stop(); } +/* + * Return true if any memory regions are writable and not backed by shared + * memory. + */ +bool qemu_ram_volatile(Error **errp) +{ + RAMBlock *block; + MemoryRegion *mr; + bool ret = false; + + rcu_read_lock(); + QLIST_FOREACH_RCU(block, &ram_list.blocks, next) { + mr = block->mr; + if (mr && + memory_region_is_ram(mr) && + !memory_region_is_ram_device(mr) && + !memory_region_is_rom(mr) && + (block->fd == -1 || !qemu_ram_is_shared(block))) { + + error_setg(errp, "Memory region %s is volatile", + memory_region_name(mr)); + ret = true; + break; + } + } + + rcu_read_unlock(); + return ret; +} + static void listener_add_address_space(MemoryListener *listener, AddressSpace *as) { From patchwork Wed Jul 7 17:20:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12363143 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, 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 1BA66C07E9E for ; Wed, 7 Jul 2021 17:46:02 +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 83E9B61CC9 for ; Wed, 7 Jul 2021 17:46:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 83E9B61CC9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:60856 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1BcW-00038a-FF for qemu-devel@archiver.kernel.org; Wed, 07 Jul 2021 13:46:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48370) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BLO-0002RE-QK for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:28:19 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:43418) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BLM-00070O-6w for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:28:18 -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 167HCO7D011975; Wed, 7 Jul 2021 17:27: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-2020-01-29; bh=3JbDIQloszK837SdSLbPFEpydMxjEf5gwezDmSwYyKs=; b=JUe/uZyc95MdmENgeX2cFd7Mi7Ju62dRgyA2286trQmc2mStXhL7RZUG8cx3njjKBbVW Cq/xw66FeJ/BlQHflTFJE8Way+4eGOU+5spKKtNsxI42d4CfUJUz/0t5I4BMpdsfQ2tN YsKoDNWSfKgY7wxjxRRxg8co/Q/QygJYDoydRBgXZs5RyEYtCTjvK2Nj7Yk9TzXnpv8G Zzwhy+SvmQjQ/JpR4qsAaJ+4rRm80ygWbx7UAbTLevQy+8UqMyDEAI6q0c4coKYbYsrG o2Nw/1/EXxH+CoVDpiR1kvQb9fLOrrJb43c5gw8hDxMS2NmTfXviiJ8rUKM6F8OnGCfJ Wg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 39nbsxrqms-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:12 +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 167HA9YV026110; Wed, 7 Jul 2021 17:27:11 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2043.outbound.protection.outlook.com [104.47.66.43]) by userp3030.oracle.com with ESMTP id 39jd13ub9h-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kJ17BK8qVTbPbi3xB85YP2Njp6NOvFBXm1wjVQYashrdqtA65s6o8PEz5E4tx+DurwBNDqUkAP2eBa17VSBsNlIfd46wY4FxAmLVtwpHXiuKweU8vmZnQnNNBRGUB/B8OtxD9UsB3kODG6QEH6PQde6LuktnBRmy3hKuu7nJ6jGg7kHWkgPawD9pdK0YqBDnCY3piVeS3gqIKJoZdpgRUafVj2QNixvDxtP0e2lmXcmPBIYcD7G5W9C3D9cXutz7JXqN6kxeZJ2iJwQl+evQvSUlhjF4A+yU3tZ/UDDuEpuGYwQCBmM38CUYonH5cd8hFXl24D8w9zIFHC/0o0AkKA== 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=3JbDIQloszK837SdSLbPFEpydMxjEf5gwezDmSwYyKs=; b=W3M0Se+PZ75hQNGkXQf/6eRRfO4cBBj25kGIOOUOdhTnp0C180kwVQ1rKbM7UUGrADiC3bwuqDOsS7R3EfCVQCvQr9IGvhKgqzb5GjfG9ZGzPnk6BLcwn1SuOOnfPaXDWrm8wmD4oTa4pjjPdlsdVvsfN8IewPfMh4W2KRzHXDPz6o5VN3YyBClMu+zzBJ3PSVmd/JpuL6mUtPucN1xPKgisFXT48+NHsQci9JEl00yFMNEJTiiyczhC7cauyrYqgVBpLtjOJY0bejw+al0SX/Q+GYl7pUuYIFIhLJsOonxr1/PzScG9auwcl4zkvtz6jU+OPg7P7kNlVmDyAaUcdA== 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=3JbDIQloszK837SdSLbPFEpydMxjEf5gwezDmSwYyKs=; b=KhPZY+ETURrlXhcMEzdGwFseE7BW6c27LgefEi0WLcYhLn7/GQhPMxvlGQXlegWtkGMUnb5061fVgv3aVk6mtmbIKHZfkQ7NB/ua/QZd6OymBEw0ps3Qs/gZOLqScbzhxUOtN3a3rfUFgAgfqPas1nfr/UipxXsGZYyet9hr3b8= 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 BYAPR10MB4104.namprd10.prod.outlook.com (2603:10b6:a03:11b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.23; Wed, 7 Jul 2021 17:27:08 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba%7]) with mapi id 15.20.4287.033; Wed, 7 Jul 2021 17:27:08 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V5 02/25] cpr: reboot mode Date: Wed, 7 Jul 2021 10:20:11 -0700 Message-Id: <1625678434-240960-3-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> References: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) 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.13) by SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21 via Frontend Transport; Wed, 7 Jul 2021 17:27:07 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a42ab4a0-1782-45b1-ef8c-08d9416c725e X-MS-TrafficTypeDiagnostic: BYAPR10MB4104: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SVtE898PObJTscGa5mOw/U8eT6/eOjuOzPcX+QVeBsQuFt3fugOrm7a9XEOioGIWaI/AD9RuPag6tIqdbebGvh2j1/HNVn7Nu9PLOKCufxQgWxmSUsANzTzrGEDixSDjy2+hZ+K2ghw+ICq0PR7GnqCirViR0LedpHO6mF7ppKHuzcoZahztevDISxJs5WVxS+KKU6s1ZMg4MlmMUWm1Ylnrl2N1AEcGRm6od8YW5Z9RTg3wImxJ4o5pRZ8mdqfKS4vbzkn8ETYXQb0JutCkVi+UwugWcDuPgjoVuPH01zPrGUhCKLOlH5P9+ZU6Vfz0MdLC2v/giv1SbbqV84pXk2NTRLsphe4XLMKu6bxUTr0K0UG807OLH4jd6q1HmC6EJ/0TUJWnIcfvFcBII/9i8OKROYwheLFWTxplBUsPodin4xuIUTghWVxa75s4XwRL/6pHvAoUOuLcUG7lOYrUDdyLcSh/lw0wa3ecZvWeeaCVmbM+3z9iRVJkzVfL6QBoMhrhYxNOC09oiVWA89GRlx6lRpuh0E0qsvxxhs4MOJl51jDUhIKroJxpMw7mTsa11KTWJ7UgSAHidkNDajbtgeqLuPjb30K+29wc8NK7vX/O0yo80PdxkfIBQ09/0aA2RyQt6zjDGdcBIpWKyK342kX++wJIyC6V21+h5jekMbLtddb+jNBlMHs+jGD0xL6MXvMgg9QRwmCM0AtRmi71iw== 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)(39860400002)(376002)(136003)(396003)(346002)(478600001)(36756003)(2906002)(2616005)(38100700002)(186003)(6486002)(66946007)(8676002)(7696005)(6916009)(956004)(8936002)(26005)(66556008)(7416002)(38350700002)(66476007)(5660300002)(52116002)(54906003)(4326008)(107886003)(86362001)(316002)(83380400001)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RbNmfMJP7jVZPjdUUAvVRS5dqeGDw6RD+sLH2pw6ancppbtjVqc5B6uX3ku9LPrUOKskOyzz0MqHWdkTVHa1EFSQ//8zXnr5X3+F99v4iI1Gkt+hiUPJdETzL1Ri1+tTQy96KFzgzHO5B2BcmXSHRe28jldSOszly7G/KJAB66S9W/Xcq3nGSrZmr30jUTCc/j/y7dDU6u03FFmCquhXZqm5ybB+14/v4/0m0kiWYG3N7tWcIpZtRXdXDHFFQLLtM+/m0Tp/59Yy80TIjgFKK4EbY0cN4fa+E3FDOresgceaZZI29hWc2ojmZ7eSV4s/X5mmph2jVZqiLzRqtZ2nlDkchTw9jYDaqfvME5hau1EZhjUOb4RAEDE7AFiEPiqk8Qk1qdUhKZp6hA1rBncCGFTcSDeX+F2EjMibyB0AeLuB5HDgQP/+PWs7gUP3f1qLXWLTAF8FM5H75+MzI7UnNX8Xs8ek4BEmudYw65dlpPXGawlh2Nqz9EDKIU9R+EOztzNry4pOghsTKlkHaSCtDXFJst+cpv4HBjReS6RO7m63eUR/xknCPvszoFoIHTm4StjmDa6n8nHQRnbM0soD0CJKfrbGAq5EWI7L9GQnWFI9PKfey4BpG024PgXV1sDr8Kdlvxhl7/mpY/f0jY+4uROjlYZ33c64Gm6RjJCnFjFSewzXq2RwM8hszi4dctrG/iDfxOu+4lRtmPNiAmyda6x3egiTbCFS9vMjrLUWgosGU9Tp0IR1ChDA4q+YLW6p7cFVnOQI+vmNCSrJCYBYeZwh/vE0vF7mhzvdpDfmdWgpRufJ26rFLPPzqRn3gcKUoKTGyUt40ovFexolJ6DrE6ygtTpiqY99tcCyiWfTBpPA7VLWhpIqRQO7pEQdWyZiZQJBwvmhyI8p9V3IKaKfkGCv0NCn8P9HMShjfcDByrl8gZL8DocnG1N1bKgf++h3Stfe9YEOxHLA0YhuVRvphWRkvjvcKWhrT90vYiPqo4osvkTCu+v9+wNnyb9Hg5P4YSPzdl9Sz0xD4E9dlqsf5N8HIFTojL4/QDNFCfdAhQkyj4d07P6+kgxVTxP25NpPt2za5/MLLp4QjsQZh8fqBS8znsEiB2Zp77HOskc0kg7pAyDnFDn3BxxLpNN3oTt4O6MY1Pjy618Eb/fySJaSyM1HnPbThnHgYgCRRuCRMBNiVjiJ9uwv5LBxvJlRxQfZoSa5Syzzl1vTS9fYV8huDb3VvtLhUcanM0+1B2hSlwI10EqfNwL2RwitIHUcrCbjmi9u9I0DKmQo17EmWQ2maSFbUs97xPP9w4v1Jpd7EoX4fIiKMQO33R8ZpKVnLBc9 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a42ab4a0-1782-45b1-ef8c-08d9416c725e X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2021 17:27:08.1862 (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: OSC4l8s2SVK1tH4dWlcpYzIjjU/bBPa5JbnXDMadNGqalzQ/MEAICMeUtL2xJJGyFWfPmzZz89xG5TEjp6QSAI5iVE65u6sUZsHM0kCECd8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB4104 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10037 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 suspectscore=0 phishscore=0 mlxscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107070100 X-Proofpoint-ORIG-GUID: sxzMU8EvaLQtDPUozjq4wLcOi8Mz0Nea X-Proofpoint-GUID: sxzMU8EvaLQtDPUozjq4wLcOi8Mz0Nea 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 , 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 cprsave and cprload 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. cprsave 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 cprsave and cprload. cprsave supports several modes, the first of which is reboot. In this mode, the caller invokes cprsave 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 cprload. 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. cprload loads state from the file. If the VM was running at cprsave time, then VM execution resumes. If the VM was suspended at cprsave time, then the caller must issue a system_wakeup command to resume. Signed-off-by: Steve Sistare --- MAINTAINERS | 7 +++ include/migration/cpr.h | 17 ++++++ include/sysemu/runstate.h | 1 + migration/cpr.c | 149 ++++++++++++++++++++++++++++++++++++++++++++++ migration/meson.build | 1 + migration/savevm.h | 2 + softmmu/runstate.c | 21 ++++++- 7 files changed, 197 insertions(+), 1 deletion(-) create mode 100644 include/migration/cpr.h create mode 100644 migration/cpr.c diff --git a/MAINTAINERS b/MAINTAINERS index 684142e..c3573aa 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2858,6 +2858,13 @@ 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 + 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..bffee19 --- /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" + +void cprsave(const char *file, CprMode mode, Error **errp); +void cprexec(strList *args, Error **errp); +void cprload(const char *file, Error **errp); + +#endif diff --git a/include/sysemu/runstate.h b/include/sysemu/runstate.h index a535691..ed4b735 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_wake_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/migration/cpr.c b/migration/cpr.c new file mode 100644 index 0000000..c5bad8a --- /dev/null +++ b/migration/cpr.c @@ -0,0 +1,149 @@ +/* + * 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 "monitor/monitor.h" +#include "migration.h" +#include "migration/snapshot.h" +#include "chardev/char.h" +#include "migration/misc.h" +#include "migration/cpr.h" +#include "migration/global_state.h" +#include "qemu-file-channel.h" +#include "qemu-file.h" +#include "savevm.h" +#include "qapi/error.h" +#include "qapi/qmp/qerror.h" +#include "qemu/error-report.h" +#include "io/channel-buffer.h" +#include "io/channel-file.h" +#include "sysemu/cpu-timers.h" +#include "sysemu/runstate.h" +#include "sysemu/runstate-action.h" +#include "sysemu/sysemu.h" +#include "sysemu/replay.h" +#include "sysemu/xen.h" +#include "hw/vfio/vfio-common.h" +#include "hw/virtio/vhost.h" + +QEMUFile *qf_file_open(const char *path, int flags, int mode, + const char *name, Error **errp) +{ + QIOChannelFile *fioc; + QIOChannel *ioc; + QEMUFile *f; + + if (flags & O_RDWR) { + error_setg(errp, "qf_file_open %s: O_RDWR not supported", path); + return 0; + } + + fioc = qio_channel_file_new_path(path, flags, mode, errp); + if (!fioc) { + return 0; + } + + ioc = QIO_CHANNEL(fioc); + qio_channel_set_name(ioc, name); + f = (flags & O_WRONLY) ? qemu_fopen_channel_output(ioc) : + qemu_fopen_channel_input(ioc); + object_unref(OBJECT(fioc)); + return f; +} + +void cprsave(const char *file, CprMode mode, Error **errp) +{ + int ret; + QEMUFile *f; + int saved_vm_running = runstate_is_running(); + + if (mode == CPR_MODE_REBOOT && qemu_ram_volatile(errp)) { + return; + } + + if (migrate_colo_enabled()) { + error_setg(errp, "error: cprsave does not support x-colo"); + return; + } + + if (replay_mode != REPLAY_MODE_NONE) { + error_setg(errp, "error: cprsave does not support replay"); + return; + } + + f = qf_file_open(file, O_CREAT | O_WRONLY | O_TRUNC, 0600, "cprsave", errp); + if (!f) { + return; + } + + if (global_state_store()) { + error_setg(errp, "Error saving global state"); + qemu_fclose(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); + + ret = qemu_save_device_state(f); + qemu_fclose(f); + if (ret < 0) { + error_setg(errp, "Error %d while saving VM state", ret); + goto err; + } + + goto done; + +err: + if (saved_vm_running) { + vm_start(); + } +done: + return; +} + +void cprload(const char *file, Error **errp) +{ + QEMUFile *f; + int ret; + RunState state; + + if (runstate_is_running()) { + error_setg(errp, "cprload called for a running VM"); + return; + } + + f = qf_file_open(file, O_RDONLY, 0, "cprload", errp); + if (!f) { + return; + } + + if (qemu_get_be32(f) != QEMU_VM_FILE_MAGIC || + qemu_get_be32(f) != QEMU_VM_FILE_VERSION) { + error_setg(errp, "error: %s is not a vmstate file", file); + return; + } + + ret = qemu_load_device_state(f); + qemu_fclose(f); + if (ret < 0) { + error_setg(errp, "Error %d while loading VM state", ret); + return; + } + + state = global_state_get_runstate(); + if (state == RUN_STATE_RUNNING) { + vm_start(); + } else { + runstate_set(state); + if (runstate_check(RUN_STATE_SUSPENDED)) { + qemu_system_start_on_wake_request(); + } + } +} 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/migration/savevm.h b/migration/savevm.h index 6461342..ce5d710 100644 --- a/migration/savevm.h +++ b/migration/savevm.h @@ -67,5 +67,7 @@ int qemu_loadvm_state_main(QEMUFile *f, MigrationIncomingState *mis); int qemu_load_device_state(QEMUFile *f); int qemu_savevm_state_complete_precopy_non_iterable(QEMUFile *f, bool in_postcopy, bool inactivate_disks); +QEMUFile *qf_file_open(const char *path, int flags, int mode, + const char *name, Error **errp); #endif diff --git a/softmmu/runstate.c b/softmmu/runstate.c index 10d9b73..7fe4967 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_wake_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_wake_request(void) +{ + start_on_wake_requested = true; +} + void qemu_system_wakeup_request(WakeupReason reason, Error **errp) { trace_system_wakeup_request(reason); @@ -574,7 +582,18 @@ void qemu_system_wakeup_request(WakeupReason reason, Error **errp) if (!(wakeup_reason_mask & (1 << reason))) { return; } - runstate_set(RUN_STATE_RUNNING); + + /* + * Must call vm_start if it has never been called, to invoke the state + * change callbacks for the first time. + */ + if (start_on_wake_requested) { + start_on_wake_requested = false; + vm_start(); + } else { + runstate_set(RUN_STATE_RUNNING); + } + wakeup_reason = reason; qemu_notify_event(); } From patchwork Wed Jul 7 17:20:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12363087 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=-13.9 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, UNWANTED_LANGUAGE_BODY,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 9D48EC07E95 for ; Wed, 7 Jul 2021 17:28:48 +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 329A561C98 for ; Wed, 7 Jul 2021 17:28:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 329A561C98 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:38792 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1BLq-00032e-B3 for qemu-devel@archiver.kernel.org; Wed, 07 Jul 2021 13:28:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47958) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKT-0000C1-7X for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:21 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:44502) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKP-0006jC-Lk for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:20 -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 167HCO4E029361; Wed, 7 Jul 2021 17:27: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-2020-01-29; bh=uUPd8ywn/2q536iq/Nsy8RD5CPFrhQt4bo3xVk+Kgw0=; b=Ao/+z4Efd+DV8oJAWOYOlLEoZGRrI3VrTCK4m3qLhRBDp/F63dhEPzvB0VLNG8TJhe3P dVuy30kUU64h6cHLxCmtPUdvYucGpduQD8J85eX6I9EwQBNpXTFWcAT2tdKdUW0ETQGO wQOE31NhlCwZGkv/ijqD5rVhhdPfbyhAcYDR91MZGtKWOWX7131hY4CoHQiNjc6mqN43 T8hTDPupy1q8kZBauP+qh/hIz1RsfD25ze+JSntKpQxu7OicPr6IPJ5EnDECwSzuJV1s hADFNs03VReleBrj+WavbSJODmukZTZkurP96fNQGZqN8fEwcpL+oHVePKVuBrO48KuZ yg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 39m2aacpar-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27: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 167HA9YW026110; Wed, 7 Jul 2021 17:27:12 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2043.outbound.protection.outlook.com [104.47.66.43]) by userp3030.oracle.com with ESMTP id 39jd13ub9h-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FxqAepu1bv5/yG03FSrXHF/sj0AG8N6hzZZVs+O4EKrF3Ao75xKKCoOLNnrjWRslpIJgQuj/BYK6FGQv3PvHjVMCNrkcVa3Fd9iej6iz57c+uOpmvVfqbw8sUsIq1aXfFhOfnzkxNRM8zQlOqY+QlVRfq0Yx5NSHp+fbQfTmvvvwrfqzHDr5MABnDX8soZL/y/PH98WsbjuDMcuMAPePNGIuZk0DpYNXxUmpR4PSPkGlSwiDzFeXM3+3j5dB6Ybl99SppHS7mVK62Z22UYRi7z28W2QNu0wSrCRyfJWUkixOG0BQaplsgHX3+aublfjRhU+gtcuqPsCJnhvJuxhQeQ== 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=uUPd8ywn/2q536iq/Nsy8RD5CPFrhQt4bo3xVk+Kgw0=; b=SppLQGQXgPC5B5FrbP9Ds/MZHV6sSrMOzBbIYZHC0AbB/U1BtOm9TgCuePhOR+LrcRK3lTW/4uDG4W3oMK5hEKw6vsno5U2jY8aXNYwAPhhHiqyhCV8PCnN0H69h271xGagDiOQ10enyGJHmwKIThhzcOqkVvp2wddFthgJgcql4o+NudsM0/9o/OW0A5I0XENGRov7r4XjC6VBySxbZQDE4jddTcTzJN66owtf7MKKQeQulWHE+asIi5HNVw/d+/UgLKcTxrl+oekz4x4LxyRk6vqmF+3LlhFpV7WXyLElcYPY1Z12EWznTBK34FlD4AWOhz3lekPTAYZUzxuX+ig== 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=uUPd8ywn/2q536iq/Nsy8RD5CPFrhQt4bo3xVk+Kgw0=; b=RoRQn3p94Q6Pm0CjxAvO6UzY/bp05+ailF9rzM9GUW34yPB1QdQXQMJhL6vUY0We3/Dy9l8vew0OVzTPj8xosM785qrkyffTZW2NXpH/fnhGx96ALNUrvDmNJ7O97Et8+h5dDTw4jbiz4VCky7Pf3wLhHZ/TVkOFikS1D51kAxE= 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 BYAPR10MB4104.namprd10.prod.outlook.com (2603:10b6:a03:11b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.23; Wed, 7 Jul 2021 17:27:09 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba%7]) with mapi id 15.20.4287.033; Wed, 7 Jul 2021 17:27:09 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V5 03/25] cpr: QMP interfaces for reboot Date: Wed, 7 Jul 2021 10:20:12 -0700 Message-Id: <1625678434-240960-4-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> References: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) 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.13) by SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21 via Frontend Transport; Wed, 7 Jul 2021 17:27:08 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e1aa468f-1686-44ef-a10e-08d9416c72a4 X-MS-TrafficTypeDiagnostic: BYAPR10MB4104: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RJcqCWXNoPXdPeaf862inWJwhdVAaHR8qES6GGWeikvTfaZbaU1DH2Mv5WJK7yX4JHG16I7gjm3ufVCD8fsTnJiQX8Iz+eMMyTVqLjsXOvo1ZBlCytFXfLBPtYRtr+q/amiR6/1k3/HdIzCRQXeMUn05gj7tCfjeJdDa4SZSPSQr82kdxetmp8NNCUgh056TBmgrw99YWu+2dHUyNCoszbF7pwbMeag85gfMduLLdqmbx+xzQ1VKcLoxvL4Quo1/3xk+IEYHnX9G0FC8dyNm+KmIQDhOenIBfuCiOpGTyu/Glu32QHDFPaqFTq2ofmdpYYkut6xzFCFvLHbYgGeBauDxC9DCSXR22QsuAwUvEEX0cwuq8S6idl9jzf5ZmXNOUX8RoZQgX/qtQ1ODTxk/0KtyH2nZnVNf39qRY4vWiXSZIdW8qbWBMX5AWlLdkBpLvt9Pg5CJ2Ur40URpt576Jy3ejN/K1HLcIVGQVRhMUgnfRvAiFtpUKmG/z2ij0b7IVqmmWRByZSJbHu2iYPJFJwJhxrZpsVqXWUHl+oAhs/m/76E1qpYoLrXzDFZgQGPOAIZO7wb5FpEdOtWRNltFSfjnE/LnnT7W+oYXn0BE7/bbSoaazWPh+bjgIE0FebCYXZ9M1Fhh+fuCSw27jO4wFM8ELfocvOp09m/7r7E1ZXFqvi5Kj+Bt6JyhiCL8S3yQp4jkAp6O0y+44PbEe5ep8Q== 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)(39860400002)(376002)(136003)(396003)(346002)(478600001)(36756003)(2906002)(2616005)(38100700002)(186003)(6486002)(66946007)(8676002)(7696005)(6916009)(956004)(8936002)(26005)(66556008)(7416002)(38350700002)(66476007)(5660300002)(52116002)(54906003)(4326008)(107886003)(86362001)(316002)(83380400001)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xb2qzAWShVk/tzl86VP76TmNlUSCYik66sth5PKJCo9cNl5kDBUz4M1kx0rjXNukHmuZ/rCnojArvByyJ+HhnEDAk+2Kvpwvj8H7mTfxnj0VfBnGEPlX5/Ji8l/wqgc1EEVAHs0oksdL3mDNdduDOhMpyMnSrfKsdybrYAN04rAEJpzrZK0PGAqG2tnUZgPHbFUMK0M37Ck/RpAYl8e4FWYNNSNgh4G3xi5b0aBxvRk65OxfN2kPzrtkcpbnWlOr4CBWA4rQU7bm5CAVQlKviQpTaHG4xkBHwGkVS5epuVmTKgs0L9Ch6yjSObUsfnQjVJklVSGiJYJDpXbeYPNQhfeacakON4reZmvROK5pis0ixFpRLb76LhHftihEOsZ1s26sttuBECy2XNJhi45Q7QFHGPRbieiwsfxxXN/FxlFGuIVGJFXuf/cDokgibjvJ8vaU67nYVJpUxPU7NMYwAb+m4EKxv54x+bvVh48gl+euo9GtwNIs+SVxQS2S/Z9vEo3C2cyQHiLYpniDcgwzK7g/xFFBQmsc3wzQoXxGHtvCon/xCHtRdHU/ssoBXiUWVEI27ZzdHjRYDMRG8B1vaegPvOcssaLe28UaJEc/ACpDqyot/2mUAY1jZX1iL8f/mezF5FGgd8ab2ZX/T9QcAVfyV/J8ztazu6IFTVCIEuozMnPoKqWF1qUmoTgjqcNT2/EodALKOtQLrkIVh4cV4q3un6p1Sfe3/gwCi36higa/4n1fdWRh+wy/7Oie0KZ0QIWGIjXx59McbTpM1VgtdwCIN1DTT1lBNWvYFT7Qjp5W+0ZWmB15L3QWxkIiSCwELflb3fi6HW8Pkeqsl+fSv8gXjrb/0l0DBxWZ258Os4PO412mgYq19JUHe7zhfbjEil62Q4Mg1psEVfsDFw+E/+1LNPVVbuGNn4IT1XXFt6eJ0oR3QBeLUbQWV1BA8FWoI1HWLiYhxMUnL3FUE9OmEboIAZagvHzMqvgf3Zajhn08xFy09Nyup7jKdkpCBWR1TBX3nChXGzEJZyGGFtf34kRjGbbZx7r+XK0cW/O/7wfhwCSiIgjl7x/WCCMqg8n1Kaq/bgV0fu75Kq6dlPoS5sAHirWHNtyYJCpcgcgYuqZd9feGuF2PvCn0rleCu1Qj9Anb1vjF5tCpxfZRWdoCKgDHwts5+egVMQkktQcYrU9nRnZkQrqR5OofzTjrOKlAWUtc7I6xRulAewHwUkNp+49IwieTgQdv2kJI/kycFhR5GASKNI/1WWhGyNnHBV26Oo2ojw4Lp0gdiuT7Dperg808i+Xc7t4oSCYPXDlJ20QasWRc3WXQxYoS4a8md3ub X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e1aa468f-1686-44ef-a10e-08d9416c72a4 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2021 17:27:08.6920 (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: 96SQWjdSFsaweRtmXna4d6YsKkyPPn0yM8PeKbrdtZ7EtNpylrfnRdrE0rpjEXUOWtQRDqMSFrqTYc5TCPHnkfqVm9sYhKEn6rwYdlIKyhE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB4104 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10037 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 suspectscore=0 phishscore=0 mlxscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107070100 X-Proofpoint-ORIG-GUID: cGmuxFPOhMTuJMarNQmcVWh8FSY45oLj X-Proofpoint-GUID: cGmuxFPOhMTuJMarNQmcVWh8FSY45oLj 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 , 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" cprsave calls cprsave(). Syntax: { 'enum': 'CprMode', 'data': [ 'reboot' ] } { 'command': 'cprsave', 'data': { 'file': 'str', 'mode': 'CprMode' } } cprload calls cprload(). Syntax: { 'command': 'cprload', 'data': { 'file': 'str' } } cprinfo returns a list of supported modes. Syntax: { 'struct': 'CprInfo', 'data': { 'modes': [ 'CprMode' ] } } { 'command': 'cprinfo', 'returns': 'CprInfo' } Signed-off-by: Mark Kanda Signed-off-by: Steve Sistare --- MAINTAINERS | 1 + monitor/qmp-cmds.c | 31 +++++++++++++++++++++ qapi/cpr.json | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++ qapi/meson.build | 1 + qapi/qapi-schema.json | 1 + 5 files changed, 108 insertions(+) create mode 100644 qapi/cpr.json diff --git a/MAINTAINERS b/MAINTAINERS index c3573aa..c48dd37 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2864,6 +2864,7 @@ M: Mark Kanda S: Maintained F: include/migration/cpr.h F: migration/cpr.c +F: qapi/cpr.json Record/replay M: Pavel Dovgalyuk diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index f7d64a6..1128604 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -37,9 +37,11 @@ #include "qapi/qapi-commands-machine.h" #include "qapi/qapi-commands-misc.h" #include "qapi/qapi-commands-ui.h" +#include "qapi/qapi-commands-cpr.h" #include "qapi/qmp/qerror.h" #include "hw/mem/memory-device.h" #include "hw/acpi/acpi_dev_interface.h" +#include "migration/cpr.h" NameInfo *qmp_query_name(Error **errp) { @@ -153,6 +155,35 @@ void qmp_cont(Error **errp) } } +CprInfo *qmp_cprinfo(Error **errp) +{ + CprInfo *cprinfo; + CprModeList *mode, *mode_list = NULL; + CprMode i; + + cprinfo = g_malloc0(sizeof(*cprinfo)); + + for (i = 0; i < CPR_MODE__MAX; i++) { + mode = g_malloc0(sizeof(*mode)); + mode->value = i; + mode->next = mode_list; + mode_list = mode; + } + + cprinfo->modes = mode_list; + return cprinfo; +} + +void qmp_cprsave(const char *file, CprMode mode, Error **errp) +{ + cprsave(file, mode, errp); +} + +void qmp_cprload(const char *file, Error **errp) +{ + cprload(file, errp); +} + void qmp_system_wakeup(Error **errp) { if (!qemu_wakeup_suspend_enabled()) { diff --git a/qapi/cpr.json b/qapi/cpr.json new file mode 100644 index 0000000..b6fdc89 --- /dev/null +++ b/qapi/cpr.json @@ -0,0 +1,74 @@ +# -*- 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 +## + +{ 'include': 'common.json' } + +## +# @CprMode: +# +# @reboot: checkpoint can be cprload'ed after a host kexec reboot. +# +# Since: 6.1 +## +{ 'enum': 'CprMode', + 'data': [ 'reboot' ] } + + +## +# @CprInfo: +# +# @modes: @CprMode list +# +# Since: 6.1 +## +{ 'struct': 'CprInfo', + 'data': { 'modes': [ 'CprMode' ] } } + +## +# @cprinfo: +# +# Returns the modes supported by @cprsave. +# +# Returns: @CprInfo +# +# Since: 6.1 +# +## +{ 'command': 'cprinfo', + 'returns': 'CprInfo' } + +## +# @cprsave: +# +# Create a checkpoint of the virtual machine device state in @file. +# Guest RAM and guest block device blocks are not saved. +# +# @file: name of checkpoint file +# @mode: @CprMode mode +# +# Since: 6.1 +## +{ 'command': 'cprsave', + 'data': { 'file': 'str', + 'mode': 'CprMode' } } + +## +# @cprload: +# +# Start virtual machine from checkpoint file that was created earlier using +# the cprsave command. +# +# @file: name of checkpoint file +# +# Since: 6.1 +## +{ 'command': 'cprload', + 'data': { 'file': 'str' } } diff --git a/qapi/meson.build b/qapi/meson.build index 376f4ce..7e7c48a 100644 --- a/qapi/meson.build +++ b/qapi/meson.build @@ -26,6 +26,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 Wed Jul 7 17:20:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12363089 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, 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 69FEAC07E95 for ; Wed, 7 Jul 2021 17:28:52 +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 DCBCA61C98 for ; Wed, 7 Jul 2021 17:28:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DCBCA61C98 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:39024 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1BLv-0003BT-4J for qemu-devel@archiver.kernel.org; Wed, 07 Jul 2021 13:28:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47996) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKU-0000FA-Fv for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:22 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:45590) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKP-0006jW-9n for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:22 -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 167HCNPJ027412; Wed, 7 Jul 2021 17:27: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-2020-01-29; bh=GiRtNFHV2ddlH5s8xRtUUSzZTJrtCh/5NUeLljNBiNw=; b=MNaSA2JHUNvU09eQ9cImh0I6OxvtXtpH3NiGj26+tmGnJTtYJTdWBCsj9zkgQk2A3M54 t2+9/R+Gie5zSuoCxFM/h57IIAOFnRA/UEd3TCuHdIte6aGB63GmLdULmdqe9TSV0Ww3 7jDbKYA0iFEtWMqH5JQPEiLaoDuWeQr8ojB8eCii1UWiuznBT+dXBIQGLgR+Z2GTnnyd xo0XZQxDZAloA6dZCXp/YCCv5oAZq8+92/rbr+2UdcG4PUAthNKMwB8CwVC5WlxLecQ1 fTvDmAs0gGoCx82QnHq+egzwvPu0SWiQl54HOdlnZvaqy7OO2ci36JGMhmfZwWCw2cq3 0Q== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 39m2smmq6u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27: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 167HA9YX026110; Wed, 7 Jul 2021 17:27:12 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2043.outbound.protection.outlook.com [104.47.66.43]) by userp3030.oracle.com with ESMTP id 39jd13ub9h-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d183zsXD2KC+DwAucEIcLwwnyy6THYRPO6j+SHVsu6veL6Jv3jIuwCqnR/RTSptsMlNznR4CJZzv2Cbz/a3KPwoungmpXLau5t31QUdd+UPu1wb5YnWTGq38lDAx0+5ePYg2piXOBTSLbq56UXXGKvVkDDexE/+DOr3JtIIckWa7xNI4ynThKOG7O5RWsq3fL03/SMV0hrsIQb/3oK6PmFzschyqKQN4YV6xr92PaYr6aHUzQf4j1UYMICNOAr1tqvE/r9ZQRIlgaj+/7mp/XvhQoO3o4B/W8Q/ynEOEfrfijcdZ16PvmgoDn54tXn8yII5P5PBuLNY7GsrSWM2Ycg== 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=GiRtNFHV2ddlH5s8xRtUUSzZTJrtCh/5NUeLljNBiNw=; b=Uc6ksRCWyzqRF6hOL+QyNZL463sBmALWJt1LmTQNPcHVUGGV6O8gL7Rb9jHmvI1dXmLmCmroSR42QpJuS5+93VEhCb6Yy01V4CafjfLmm470pu2WlVwk8Lo7QcwwctQhcCAdFWiGre3SJ4iOtI+v22/ESNCyebneFa6+HbWiQ+SlJPXgNhaSXJJpL9SFyjl5dwDIamo6JC/jtNastoNPlXOC9qaJxYxhdZXhi2b76gwlvfmNXKE3yG1gZ+VdmHvLLLM27LEM9OegI6gvGlSyRGlFbn2SLm0c9+bPdtBNtKbziscxM3JJuOCQ+qreQuyddVs5LRa5OkjuB0i9HQkx+A== 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=GiRtNFHV2ddlH5s8xRtUUSzZTJrtCh/5NUeLljNBiNw=; b=tdO1LIwZH70gDEEHsHk6NnBcnV1jlrI39vflnjfP6h94OfNm+tPujeApoDpfr7NvtUKUXpD0OFZiSGttVXUwvhxNqoBr4jAp7ERQZ1viwcoB84akI4rbkuNEOGESbF0utWUCFabG/L2IlLN4pA7L+zljAPdB44bqdzFImQtz4k0= 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 BYAPR10MB4104.namprd10.prod.outlook.com (2603:10b6:a03:11b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.23; Wed, 7 Jul 2021 17:27:09 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba%7]) with mapi id 15.20.4287.033; Wed, 7 Jul 2021 17:27:09 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V5 04/25] cpr: HMP interfaces for reboot Date: Wed, 7 Jul 2021 10:20:13 -0700 Message-Id: <1625678434-240960-5-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> References: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) 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.13) by SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21 via Frontend Transport; Wed, 7 Jul 2021 17:27:08 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6ce4e29d-a5c8-402c-be18-08d9416c72f7 X-MS-TrafficTypeDiagnostic: BYAPR10MB4104: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:386; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iJiLPsuZUurjM9w840FCwkJeAia6zAqNi3iKH7nGkfLmN1qNTZ5zUcceZKlQmd9PXjWx7G/1oE3DrAFtvLn9iP1CM13QzqrAuxNwGYDnmjMTvyKPAaD8dajwYI2/vX+vVvlxvSaPSlO3/FKKC0aOpieGOdbKjo5MpIZE7sspciXQE4GLypDu1wU2LENxu9DgcOyILOLOQoBmQAyTcfdPJSn/BSiHNLTimJ9lilLBVfkod3ClpSVhz3i4U7qahhCJwdDGA6HyOpngDRdDor2dFb6RI3hF48bU6Pc04ytwxGdt/tJTO94myS49fgqtb96VZ4416rqVXbQT9PwnjCjOy3iuFs7T182rr7wps5BpPLqw53/D2QN//2vqePTo63sl+M/4Dyhmca9mtKLcym76VqZV+4vrs0JgLXoeiOrxJAxeqt7iztBE91w0AZiAxetNCxiWqPMZhu9iDrvH0nNWmNrYYlRTCjmv/JY40CNkw8GAOgl87EfqqAMpLx8USZXAq/YlCn1vCElc6yi9UMle+krdt/0/nYt/7e/nhK01ygPs0JIfM4LnGZ7VdzK7CNkRWXBq29AloTR1ikdEaUu0X0g/JqhXKzc8IgxAg6yDxsMnMm9r0sSnq5L1VXg4QEDY3wJwUJ6a4EW494nDhp0GQdo7rUFh0rJ9Z9ug58lgVH+RmdCbARV6AeVu9h/RSONxh1O8UkoATFkHmUFMMB8Oag== 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)(39860400002)(376002)(136003)(396003)(346002)(478600001)(36756003)(2906002)(2616005)(38100700002)(186003)(6486002)(66946007)(8676002)(7696005)(6916009)(956004)(8936002)(26005)(66556008)(7416002)(38350700002)(66476007)(5660300002)(52116002)(54906003)(4326008)(107886003)(86362001)(316002)(83380400001)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sLwzU1n+F3+RakCmQmB2fxg1n1VXWVur9tI/jAPb79WReL0qQd0H21x0p2QhMuElQgwiVo7KR/8bBsHX/05uprSNAJKN3g3tnO7TcF9fGLiRUxFOeomIfd3LSanysc/wbGqE7xVu6wjSbc3X7tj0k7krMwfoKfMeb3dgHF5h0OspgugA3bdVKpL8jyC2MuXjzeDSQ/rDNLsqmBcHpT2NoptTVW29sjh8spHFuX4iN3gB5UImbxcfU3jZ80NKOywQ94gQX/plH2U9QWH7Eo/PJMHoqHAL1/NyOrTfe9VgO1jfKUcq/rW8jfzKVsdGhwYIr88xM1z+p8bByCrjI6dpjad2ARpO089UvyAm0YhG4UmsyJ4tLuwfpRr4QeT1oSyCq41dkg/rK5S5/R2ziaEucwX7imq1inEaCKd4pZIQJJZlruvL5NkW01FCqGsSf4siQ5DEprbZ9cd1arNlZyOjL1ja/5XfQqVcedhEUDDFGHkGTV7i1KC7dzYyM6zEnpLFdjNLGjEIYYHNhwnAKi4+WPH47qfP4on5T2jupc8B/kVNtxndN5DSDd3KD1GJjKs4yf73KjycSuV7w/g+Fnzg0sk5XDeuN3u2JjqxKJ2v385n57OfR0KVmWaCKURZD1RPkz8VuohGI8CLBD9Nne02pCHVj37LGrq4B0vG1j+i94MUJfuKKCoe/01/L+3Emdt73IZhgB/QbS4Nw44K4ZA9gBT/0ZWsnS2EZ2FjC2Dg8WryCuusMjX0jISQWQnnETMvaSjew5rRzB1XC17Ke10CDuKUr4xxpO3YBFwf/OlmSRCrPADi8sz37wJMvkLzl9ZLU/nIpapWbZrRJAbMpklD89bryM8V3NKd64kexAJK8meXM9MvZAI99gEJDoxRpsMM+m/t0JfSGkd/7ROWGWAwpB5ED7w+chnddBLD7ptML9eTJLIAIg63uocAw0TCW1o9Sj/ZKISjQ0A0IWpXffiSJcHYoFHlUIrfk1wDJ1xAN3MdhOfeWePH+rUTfEHzGNZaDpBaidoJfAPscFszwM9i3ZVNGZ+lFdfqHpmMvuj/zIR5mX09k4BSEGDfeJLbX1ggSGAMYCPFxKvtOHtogFCyjX0EyZODMJYy7o6fnWcnn6DekCtMhETmOITsEKMIJjtSm/8qCNfHD50AQidGZ0Gm8IrsOr6Vzd4Byzi4RixkPczlEeU6oZ8EMjp9wwstbigV977pW8pdA5HdVfYsgWmcHQh5bkVYNBC+g3sFVl6aVz4r97AwKT2AxU0DjhqinXk67MDHu6IoUzsQd0rIJebWnHLNePkrDaPbIxnUaOd93zPhQhrfLTAQIZHs/FdF1EOk X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6ce4e29d-a5c8-402c-be18-08d9416c72f7 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2021 17:27:09.2337 (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: R6omumkV/K0UDXsOVUtJyss2vwAIT1vrtpic669Ei9EMCmCJZS0+sd5Nx+UG/Fs1lXMzF4m/wISX20MafsgT/fhBEnjiwEMOA+1Oc5LzReg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB4104 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10037 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 suspectscore=0 phishscore=0 mlxscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107070100 X-Proofpoint-GUID: fuyQheFQfY9qqh13gpaME4GmbWhxWNrE X-Proofpoint-ORIG-GUID: fuyQheFQfY9qqh13gpaME4GmbWhxWNrE 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 , 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" cprsave Call cprsave(). Arguments: file : save vmstate to this file name mode: must be "reboot" cprload Call cprload(). Arguments: file : load vmstate from this file name cprinfo Print to stdout a space-delimited list of modes supported by cprsave. Arguments: none Signed-off-by: Mark Kanda Signed-off-by: Steve Sistare --- hmp-commands.hx | 44 ++++++++++++++++++++++++++++++++++++++++++++ include/monitor/hmp.h | 3 +++ monitor/hmp-cmds.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index 8e45bce..11827ae 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -351,6 +351,50 @@ SRST ERST { + .name = "cprinfo", + .args_type = "", + .params = "", + .help = "return list of modes supported by cprsave", + .cmd = hmp_cprinfo, + }, + +SRST +``cprinfo`` +Return a space-delimited list of modes supported by cprsave. +ERST + + { + .name = "cprsave", + .args_type = "file:s,mode:s", + .params = "file 'reboot'", + .help = "create a checkpoint of the VM in file", + .cmd = hmp_cprsave, + }, + +SRST +``cprsave`` *file* *mode* +Pause the VCPUs, +create a checkpoint of the whole virtual machine, and save it in *file*. +If *mode* is 'reboot', the checkpoint remains valid after a host kexec +reboot, and guest ram must be backed by persistant shared memory. To +resume from the checkpoint, issue the quit command, reboot the system, +and issue the cprload command. +ERST + + { + .name = "cprload", + .args_type = "file:s", + .params = "file", + .help = "load VM checkpoint from file", + .cmd = hmp_cprload, + }, + +SRST +``cprload`` *file* +Load a virtual machine from checkpoint file *file* 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..98bb775 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -58,6 +58,9 @@ 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_cprinfo(Monitor *mon, const QDict *qdict); +void hmp_cprsave(Monitor *mon, const QDict *qdict); +void hmp_cprload(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 0942027..8e80581 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,53 @@ void hmp_announce_self(Monitor *mon, const QDict *qdict) qapi_free_AnnounceParameters(params); } +void hmp_cprinfo(Monitor *mon, const QDict *qdict) +{ + Error *err = NULL; + CprInfo *cprinfo; + CprModeList *mode; + + cprinfo = qmp_cprinfo(&err); + if (err) { + goto out; + } + + for (mode = cprinfo->modes; mode; mode = mode->next) { + monitor_printf(mon, "%s ", CprMode_str(mode->value)); + } + +out: + hmp_handle_error(mon, err); + qapi_free_CprInfo(cprinfo); +} + +void hmp_cprsave(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_cprsave(qdict_get_try_str(qdict, "file"), val, &err); + +out: + hmp_handle_error(mon, err); +} + +void hmp_cprload(Monitor *mon, const QDict *qdict) +{ + Error *err = NULL; + + qmp_cprload(qdict_get_try_str(qdict, "file"), &err); + hmp_handle_error(mon, err); +} + void hmp_migrate_cancel(Monitor *mon, const QDict *qdict) { qmp_migrate_cancel(NULL); From patchwork Wed Jul 7 17:20:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12363085 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, 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 70762C07E95 for ; Wed, 7 Jul 2021 17:28:45 +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 DE4E361C98 for ; Wed, 7 Jul 2021 17:28:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DE4E361C98 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:38628 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1BLn-0002wO-Uc for qemu-devel@archiver.kernel.org; Wed, 07 Jul 2021 13:28:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47898) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKR-0000Av-Bp for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:19 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:44554) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKP-0006jE-5U for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:19 -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 167HCNF4029345; Wed, 7 Jul 2021 17:27: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-2020-01-29; bh=UyyWNVzOLHKMrmkqN8hYwR1tb8++eQDHnddSOLGxYdc=; b=e8gVWfnlEu1zmdb4l49L7zUX/j6Ko3Eg5rUV8Wwh+PR0MmqJFzCGT3fLF2QP/9mv7VHZ jUiHkjgWcwpI3Eqxz03EJJO+4GLEtbK3QnW4+tXECNNRFu0M3Mey9FwCF+O//C9ABSxR u4tc8sSX57L4RjzUEnwwBd87oF3i4oIt2g5LVdWfJWeL4ppn+V8RmusYr1PqMN/dmenf FVcifKYAxAtdMNUJQIjlGnszfAio6rkVmjr5RsRAhdtU/k9SRylYuoIKj5ieFGgCTbOs 6nVJBO1GXC/3ZB0kNkuFKt+XRSmYbt8i/rV5QTFW6VAvg7xHsERJ3WrE5dEq7UotX1HN GA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 39m2aacpas-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:13 +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 167HAMKn068988; Wed, 7 Jul 2021 17:27:12 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2169.outbound.protection.outlook.com [104.47.55.169]) by aserp3020.oracle.com with ESMTP id 39jfqayxx9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hsbxTs26UemKtw4fzqV+PAR200sSXP+a7EmS+zKK8PruX3jUXMEdHwVzC4SnRwSTj6N7E6mbfSdomo22HoEDKurFfcJ6Kbq2wdFb4ajCFob66qqOpb+um7c0AiQZ6XK7AKosJLQkS2JlRraDAyjj1Yl4FVuwq+TqK/aLQAygHPQtcK8J8FAXLMTr7HUEIZdPO2Hfrc+rJ6zXwD0Lx7i0O93ac+SO/XhcP5cjaDwp/RmxuJ/gF4vGaKoV7DmNGVsuD5uI+vyYQOuMWZ/CdLt9BSraK0iNr17KcKiP/Yb3pQjcBukivyHzN6EBgD9lmtj+CDqIC6txaFGGFT5QPTzFpg== 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=UyyWNVzOLHKMrmkqN8hYwR1tb8++eQDHnddSOLGxYdc=; b=Bki4eZZrq9zgqFwj/ekE6ZOUjcxYmqnvhr4RuY79gvq7C4gdBiwMBXb0IRzUvEhz4TntKC3X2p0AbpZsEL1wxsW9KqAupZYGmtQ6lQzYiLcakFakblHMk0Z5UFMfP5H6zW8SLXsg1KQC9CISuXjT6Tv7/G/rGCEtP3uQNFkBEwdsHqY+T9iotBTFybJwGJJ8jSGkPszV3/LeyTZnK7eM2hD1DPZvE6GiR2UF88iEMQrXcUM+rMFgkpyzVCzDYjlIP6SFVFduJGMZGXH4TcHPmjWXzb0bYd270RounBdCKJ+w3CCxRri7LU0qS41dXFHPV4QdHQNPVvJEnpTlrHgd8w== 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=UyyWNVzOLHKMrmkqN8hYwR1tb8++eQDHnddSOLGxYdc=; b=SCgzFJH6s/iAZzpBG7+aNTiYVY4ebK1I6iFNvPoIeZkf7UW4/bqyEaNUYj0N4av66MNgR7BZc8MCQYw/euFj40w6H4tHrjLSghTtYo+rAN16D+MsJjmqo6Z1uCBHjN6HrNMmfdbGLkYUOkPNyK42PaORp/l+SKSpLVPZvJYQ57I= 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 BYAPR10MB3285.namprd10.prod.outlook.com (2603:10b6:a03:159::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.20; Wed, 7 Jul 2021 17:27:10 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba%7]) with mapi id 15.20.4287.033; Wed, 7 Jul 2021 17:27:10 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V5 05/25] as_flat_walk Date: Wed, 7 Jul 2021 10:20:14 -0700 Message-Id: <1625678434-240960-6-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> References: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) 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.13) by SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21 via Frontend Transport; Wed, 7 Jul 2021 17:27:09 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8a1d1284-8e7e-4de1-e7f5-08d9416c734d X-MS-TrafficTypeDiagnostic: BYAPR10MB3285: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WbLtFn75UhQwGT3uK245tYl7OAXwfldA00AjrjppFrYb3N7eE1zViCmug7FhELmmn2i+625jl4cvo4JawA3UxzltELQGyHQn3+Q0eA27DDRTp696TM33OGxsREZ1s1l1WOKihrG5AM85G1ArUKnBdnfMz/1wrWc8PKDsOam4uDgJnZ9DfK0Yandy+CliU0QY8ULJYVfHbXcumt8oDAa/gc37XlmzCfMvAvBIhAzkJHsiEb91FEwzMkgE/Ykulebof8ZMe3v24wcW8TbLN4995x8qiiFpSBfUw5PGbadxkuAMoeCHaNKLRpAp8vLPb1Gq9x2Kj1DEdgI8p6nXZ033Fjz34ejxQByDs0FnI7LuHbBc6lFWiFY2w9RedQcwN81y+hDxxPTYqTLzpQpViDGJlm6kpK2ifpdk235FkEl6eaYlntPP1bx4FeQ6x/HzyAUCEuc61bH2e65F8AZ5SYZP7omtScVFe1vx0Y199Ea3hFpcPKxFxADM9vp8fADMr2v5W4WU0kPMl+WtMH3kI0yvZrD6Co/WsujFDfAcNOgaFl3sWnKcQQZgs3PWxRLjHa126EbIQVujrWznsFqT/ybSfoJnIv2wf4KoW/YEdgSpbHKjl9tfDWmSkyrTBg3lQ79W4XrKw78QghTv+DaLGjk+uyg4pHoPUHVRppzD4u8hsPSMYT6pk+IiniaC9nD+SnKawzWaM0u5MasuwA3LZn0aLA== 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:(376002)(136003)(366004)(396003)(39860400002)(346002)(4326008)(8936002)(54906003)(7416002)(66946007)(38100700002)(38350700002)(107886003)(86362001)(7696005)(52116002)(66556008)(66476007)(2906002)(83380400001)(36756003)(6486002)(5660300002)(2616005)(316002)(26005)(8676002)(6916009)(186003)(956004)(6666004)(478600001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rUlol77H64ozPeV6U6eMaHIpm9x0ieS88GYbIKR1JV8EsEe88FecginWCg2q0DHv7uarTdU/5BTpYfcFrDKg35PTEf6dy06sS9NiWnJLQRXKh0bwIF+Q0/KLhOzTLPaB1yryR436J2nkzqd8tvlrXHFziq0vbcZXfi/T5BhvlvSDYJrxzQCGFFRIpwXQx3o7+hw6+Dqth2u7KrDS5EOuNMAW30MOh0cZUnSKOLG6JT7EtD83oxfynPNdVnPHlNZr2lECmNIuicntyxYDtBxYTwyE5V7U8w+S4HS9XtOXt09y//6NcdjjETltJEp1eGoXUcr82ofHQyAPThK7gHowa1C28SqcHE2cwx7AiHksjfKZMAPkA5GVkkKE5EeeZHYxgTpUW2Ja+olSy0k5Cy9FOse5KCrVOYYHwA2WBEwA1SzeUPvUfARymUmoWQK0wVo3gwxjTJuj7NgcfmYuRQ0BVgy5VCdpnGsdthf5uF9Qi5MgSJ/jMAdqiiaooG+MT+o9oV0DnpWOz0b27iq0vgM4dGpsM5jxUs86kV4EtdOa5v4z553SJiMhZ+Si1W/OfAA5Fqe9vhZ+g8Ry4kWfTid6vGEKGXUmC+sklm8Ib3XOGxUpivTU9PT8rF/UytuWMZwiJiQXnVFR2HU3bpncNUHM5HApsTHXv+ZexerVC7M0j/gITh4Ehrd+KljAhGmAbkwqbJUpU0MK4+ZLyJFoBBtGtP+wBHDUFvKy8a1ZYSp89pPlmFojkGajVxz9zEpdRrU7R+eNLOASucWB6LYpfsNTbL5H531jLuB7dI7Y5Sniloco69zg7UsK4ypfBpszeGsN9r4H4RdAc3NJShc2MQONMSGwh3cBFDjsAn4D0Ri7vVD83/ooypaB4beX0VhBvCV1rKIPfKgc5msWVLiKdariP+w5yWSQyJ5uvpJJSkHNghQepNIcUiFk/D4HQsGZ3wOqTiISSUXY0QW8I99itcljvZvx3HtFvEKGXbxNijMV0dTD+syzeRTbrDPTDEq8FVYgdLdlm0fSTtHC1TuFFD+dxo8yANNjab0WAGCI2UxOe9LXL6lYacs4hzl9gSav2vIpm3nukyAwB6u4nMRy8ibgVcpswjgGQtKd+3Fm+L/uAgbcTqGdG7dDBVdCdvqBJoaF3iTKQ6Am4bx0/z7BbMSniz6dytFthz1z5P3n3SKV8eV60JiXVCJG453doosixkJbwT9mHlYyxmAAPs/csR3O3GV14os9ouQmW4XbXgNMuk3J0f0U63dKjkJp9XcjFE3OU8Za8eo6wBWJCkKk++ynFfusaLgLJW1zFR34UWEdhznh6enTK2L2IyviSLUwyCGf X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8a1d1284-8e7e-4de1-e7f5-08d9416c734d X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2021 17:27:10.2211 (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: CT0eh3Z8Xoinrn1oVT4iErxaxe6vaPFL/Cen1KVh5QPUQ0C3l2wrcjzpXu62yetjmbeDqzIu+oZSH368lv5ZTKoOXRcXohODD/1yAeeKDxs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3285 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10037 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 phishscore=0 mlxscore=0 bulkscore=0 malwarescore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107070100 X-Proofpoint-ORIG-GUID: h_t1jMrW-RpAnTdwwu3wh1pRQSNXVtdx X-Proofpoint-GUID: h_t1jMrW-RpAnTdwwu3wh1pRQSNXVtdx 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 , 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 | 17 +++++++++++++++++ softmmu/memory.c | 18 ++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/include/exec/memory.h b/include/exec/memory.h index 7ad63f8..a030aef 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -2023,6 +2023,23 @@ bool memory_region_present(MemoryRegion *container, hwaddr addr); */ bool memory_region_is_mapped(MemoryRegion *mr); +typedef int (*qemu_flat_walk_cb)(MemoryRegionSection *s, + void *handle, + Error **errp); + +/** + * as_flat_walk: 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 + * @handle: passed to @func + * @errp: passed to @func + */ +int as_flat_walk(AddressSpace *as, qemu_flat_walk_cb func, + void *handle, 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 e9536bc..1ec1e25 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -2577,6 +2577,24 @@ bool memory_region_is_mapped(MemoryRegion *mr) return mr->container ? true : false; } +int as_flat_walk(AddressSpace *as, qemu_flat_walk_cb func, + void *handle, 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, handle, 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 Wed Jul 7 17:20:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12363119 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, 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 B34EEC07E9C for ; Wed, 7 Jul 2021 17:34: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 15B4861CC0 for ; Wed, 7 Jul 2021 17:34:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 15B4861CC0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:58972 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1BQy-0008JN-AZ for qemu-devel@archiver.kernel.org; Wed, 07 Jul 2021 13:34:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47948) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKT-0000BW-0g for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:21 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:46168) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKP-0006jc-OG for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:20 -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 167HCl4M005038; Wed, 7 Jul 2021 17:27: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-2020-01-29; bh=QxEkZv7BDVxU5n7Cb0DWUXFhD5bjhZHhOlCFAb616BY=; b=CSOvrsxz9uwWhBZtlghKWH2ATVwoHG1U5Kauc/rIXRbg1rcJXMD5l6WffDpvNvmRWtHb OSJgDbAPInQd6Qr41OOvHf1iBVTqvhKmB87cD5h7NWQn2wN4NztlKap4dxRNScg5Lcj9 /xHnt9ZPnDTX4loUAbDbssZuI4ROR0+JetlkovX4aU7QJlMTK6CLlzFEb/itZhlkj4qv DgLIeYjfffMQpnigJcworqujNK59d8LirWzdn9TU4XcYPWvqWT5JX/6HShsfq+usnXHJ YRG4/oh+DEUzERabSaB0xD8BSM+25FJ0ZOhfRluZkZH15IfdWjuL1ZVlVc/Ftojm0XP+ rQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 39n7wrs7pu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:14 +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 167HAMKo068988; Wed, 7 Jul 2021 17:27:13 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2169.outbound.protection.outlook.com [104.47.55.169]) by aserp3020.oracle.com with ESMTP id 39jfqayxx9-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eF/5wxcuuRR0gJLZylUT1SD93OOJ5mTtpCguGLMiKN0tsp5gQBeHPc+Awy2M59BumeMtPE2FwQ2uTD3oiZkqJsMCw1J14vb5z05sJYPepSWK9O19Vitnc3aU0hqRw5YLxLR5I+IM0YdCpEj+1HrT2KrVrbyhtRQGQime74c1sAI//LUzB9nWMotdmth3pIOKYk1J1+tYdWWn+ZN3bLqkTpzDj+4GJ65Edn+oZSU76rFiF/LCKcGekGP9Z6yoJOs/eVKzQv4Nc4kJjJDMfejqB3gXWHWJS4ZaslU7mbioL3WudPiJCVCCo1sHvc6lfI/1iYYhb0TusI0HmeZzbyd+dg== 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=QxEkZv7BDVxU5n7Cb0DWUXFhD5bjhZHhOlCFAb616BY=; b=k5H/wfJuiT8RX2HmmPhfPcUk4hYxMJWSAX2iqMNJbxn0OfICpjUbb0N7opnvkottL652hryF9cWCbEKfmQ7ulqIuBNM5dfMYoULfu/htwApXP4aREa9K13mTkut5KDCTEfD+q6Q/d1aJYFTAJGG20ZqOEfl0aygVLfyKh63f2Zr9+HTr9OcX2tN0fbQ/ZJxASdXrx8MxwttAQZDmJYXFTdG/SZMX4Wf0rZrS1Y5CepJMZncaTG+ncAiJ7SMYm3D9g398VHrnqkUQ3/GdBArn5wyFWTLToAkah4ZUNnWUbjDWn2RdokGkAB2vHqw67lqbq4bnP3FS3qSA0PkoSE+jaQ== 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=QxEkZv7BDVxU5n7Cb0DWUXFhD5bjhZHhOlCFAb616BY=; b=IfRhU1UPqFJPBxiH4uLpbBYTYeISurY6UjBqBNYctqxTQp3fLznKmuWKp+VSlIthHPsvl0pwuxwnnMDoBHU7K25F52j7atuQGxSomE/Yy2p+0S2Asl5zy0rNXXXK2W5qWeGQa10y2IP1P0RdTq0ihpTbjiccWP8BY9V4icjN7B4= 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 BYAPR10MB3285.namprd10.prod.outlook.com (2603:10b6:a03:159::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.20; Wed, 7 Jul 2021 17:27:11 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba%7]) with mapi id 15.20.4287.033; Wed, 7 Jul 2021 17:27:11 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V5 06/25] oslib: qemu_clr_cloexec Date: Wed, 7 Jul 2021 10:20:15 -0700 Message-Id: <1625678434-240960-7-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> References: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) 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.13) by SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21 via Frontend Transport; Wed, 7 Jul 2021 17:27:11 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a0fe94f3-3801-4973-f8bf-08d9416c7454 X-MS-TrafficTypeDiagnostic: BYAPR10MB3285: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1388; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: u67upKuRJo4cijwsuyrGOOjSjh6jWctTkd78oMWhOCnU40giSBl/wA91mB1/9qLYTWfvV29p0xFWP0tr44GeKX59aQzr1UHC98+b6Qo9Y/G7uG0IbIASCMvzlIdAh6++yUUmLva9NFj7jOG8l0fQwRq3y+2DETjjAdcwe2F3pCkVaqD/VYHK4UX1m/YwuGnQXg8nT17KctPWRUsmQtkmLtsNGoG/W6ZBDtFrfBA6q8mU681iHkfklbYb96PehHfad5cWXz2wd2fNJYe3egt0mdvV2EQmLJ8RWTqn2+IAPCtn7smBQ8Ki5BsSZaXFKXURiGCzmTScldleZCqFWY34FXlvpeEi3boFPkXZECgWKHCRbcEbYyMZJ36WvxyLFJDTIOre08504SFCZNVW0EnllZWsHYB+VuLcWLg6fhRHUQHtakBQScoDS49Pv5g0fbZ6H1ZL+OoUMZXKiBdNy2+puPgz3H5L+b5V3N7L7oq9TPOjrTOaeHXdv7nh4dAlM7NH7yTLn8q5uxlCR3yOTgGw+gHJlDGWLFd1CehAWGlaHtkYg5tb5NpBbvgNtdI2pkPG7WxKn/bHrzkaTRiO087yoFzwpwFFSO+GpBIANkwuzDg6UgJuZ/wLWFuS39CJw6M+fnWhEzIn4XpUcBVHXf4di/SDhvKY3EqWRKF1MurNw4gqNwTJuT/D8g/SYRUTnYiYgFKyZHG9oAzzydrlhwZ81g== 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:(376002)(136003)(366004)(396003)(39860400002)(346002)(4326008)(8936002)(54906003)(7416002)(66946007)(38100700002)(38350700002)(107886003)(86362001)(7696005)(52116002)(66556008)(66476007)(2906002)(36756003)(6486002)(5660300002)(2616005)(316002)(26005)(8676002)(6916009)(186003)(956004)(478600001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IVcvsO8D2JYBtfLL7bzcSiJSMdoakZY2j5DosL3/IlDQTQR4l1iMrzO027l2C7/hGylbiVUeBZBhz+OEtWd56pk250ek8jJO8tIlxZDQLEo4hsY1yXHWtsyiNQcFXQE+r35H1sZh43CqrfVaE/3Wzlja8uL7DXO5QAbkZUYPD2ysaNmTfoJhvVaPNnZREL14sNadApB49hDtkg9xdhbD2Z0RZXjskSjs2LQpCbiUxbtNfoJ6P0o9w0Pb9z9S6GFjVQfXImkWWMvijQg0++OVsmjNVuiBoVHI0bmBZ+FAb3Q4mC1JWDPr+IfhGcUeV7s1MX8+bXie+0DPO8bfYYy02JVpENU6VdcFpMuUWt9Uc0VBsYv9dTdDMj3EkihJNEvHgHc/LfIBBPBGgsUa86WJIa93AryX4UoqYoEL8du+GHnjbihOzkDCH4zvwvrWIr09p0GYzzWuqzpeg6V6AnaxwJxiVmay+ymnNb7hsn7fleyxBeGnXeFDU52gKCw0PBsl9EegD1VEeuzASWUgw9FJ2zcnomm5X85x1T0Q/cFAAt7KfVbUSvRY2xXQmcPeP7qnOqXhjM4Lpan4dxGOCHyeaophogENByh3tNQn5KT0CrO5Q+8OwIm5LdzszBmVH7fzqg+K6FedcofdMZoYBXUptWTFsZWjAG9k/dmXXl4tS1bVjM4oaNCuoWAcHQsmFQf8RtxRFs/Is/32d2FDCzg0Z4mHg1O8GHCcxRO21znJZ3NwJ1I/nj6K0Ppa4qcarIDYjLCWwEPAk3RVOTURNqpap8YZZCI/ivzo2ZgCdOlIhK8mLuE0QPjcmyTplbn1V0h7J8zDnCqMToS+UJqezishI+HEdv5clZ6CTphePAGtH4QJjtGrbkeTyUIrKzXRIwVEo+VkAnCqOzOUd243esZsbP1wEY8C6Bw8BuHkM/Mqn0pJ9GcIR7+yNhz+Zfs6rWp4fu0UHc9HBiu57M27e12zF8haEDwr444ygS44VaFNTyHRkfp5unx/NZMaf9tJ2iMz8Nr56eLqRUOt7s2gryRLXlWRjZePW5yB4AtD9SIl/TNVFOdQT3hlRlBT9tlnah+Iwx9+8dOf34N4H9zmgZKtWjaCKqISkAlQY8TY/CmLvmybbAhbZtGUCUK9YphOyNmcb4vu9VtLlfK4IAkh5IFU7JCqSiKXTuV7YtWqtLM/BCXTwanZbZM0ZTq4szuB2YDufvCs/rapD/rO0z+9/uaHLWLA/MpRiL5U8TllxDlQg3JLo9ojF4uyntgb/vaWpD/En5MWcPu+TznMCfbcBup7IrPeRKMvisSBTFuseI5CUsA4pQV8Vg1GVlvhBQtSeEMf X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a0fe94f3-3801-4973-f8bf-08d9416c7454 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2021 17:27:11.6633 (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: BRoyYY2YxGeFDVxVWkSuhsLtcRTEW37YnkjSiUGB4oxb+pt0jGoz7JUyQpe+tppnzqujECl69q1nL1s+YNm3Yv7C5OJ7Ct5MHZPY/iWhTxw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3285 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10037 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 phishscore=0 mlxscore=0 bulkscore=0 malwarescore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107070100 X-Proofpoint-ORIG-GUID: ot9MTXs8f2ZbJkkv2MGi3mNBu90E6l64 X-Proofpoint-GUID: ot9MTXs8f2ZbJkkv2MGi3mNBu90E6l64 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 , 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_clr_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 c91a78b..3d6a6ca 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_clr_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..97577f1 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_clr_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..46e94d9 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -265,6 +265,10 @@ void qemu_set_cloexec(int fd) { } +void qemu_clr_cloexec(int fd) +{ +} + /* Offset between 1/1/1601 and 1/1/1970 in 100 nanosec units */ #define _W32_FT_OFFSET (116444736000000000ULL) From patchwork Wed Jul 7 17:20:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12363127 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, 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 E1FCDC07E95 for ; Wed, 7 Jul 2021 17:39:50 +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 4BC4F61CC2 for ; Wed, 7 Jul 2021 17:39:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4BC4F61CC2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:46068 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1BWW-0001gW-0S for qemu-devel@archiver.kernel.org; Wed, 07 Jul 2021 13:39:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48014) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKV-0000GN-1T for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:23 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:48350) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKQ-0006jj-3D for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:22 -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 167HCNF6029345; Wed, 7 Jul 2021 17:27:15 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-2020-01-29; bh=OuaoV5BkBBCvBHVDROVktq6g8EY45ffOKBgvHBRjVyk=; b=eHqwlR683AhE2tIyV10hEtqDF1j5Us35YykgEMfA6JXcqqCzzyxv2AGZGZMgHXBr9nWZ 9HXz2DzQvrsgK6JsHmLiYhG27uXFTWSlNoVTx+4vZEYXs1duSN8+Wg0F2tr2sfpzggTw AMVPFMiELZkTq+YFSF1YZyGbJh9Ru3OjSPzEwrtM8zRrLG3GDG36nbjJea46wdyRvWlA xH26On4G7Mc5kiydSi0+ny3pC8gAjJREcybeJ2oSMfUJ+GHwLUdETHoyNqaKc9QpSlhS X87m/6IohHclO3IZZToq274tStKGhB+j3SHZykqB9gEq342Jcqp7RmtGeFoFwZEiAf7m ow== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 39m2aacpau-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:15 +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 167HAMKp068988; Wed, 7 Jul 2021 17:27:14 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2169.outbound.protection.outlook.com [104.47.55.169]) by aserp3020.oracle.com with ESMTP id 39jfqayxx9-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PPp5Y8sY881VJjIvhamvCIat9g/ByPpuJ0fcvRaqlLkmkPgXtNFPs9W0Qnb5AgWtJwYMFzeJYEjVSfjoOfp3Zg/amIRRHoAdEYSGWCDLUp133jxF012QgBSE5JpD3Xa1t92HjoHwbNG/xtctqMh4BbNcSaHcXUx0g9xELRmZmiSuxV0kiSLy1ZZ9uvIJYgq8Y9cuqQeXORuZWQzFz127mhkKabPa0cr6Q9VFE306tB18CvWUxbKa4iURNYfhnUfYZeF1J4R/c0kQMvvT1XHbSXfPC5+/ta1wwQo+4UOw5H5OfmD7LcZMtaEz4IBhdRr++8wtbdFbDT7Fla8EgIvrRQ== 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=OuaoV5BkBBCvBHVDROVktq6g8EY45ffOKBgvHBRjVyk=; b=dGEtLRJhV+r/WEtSV1xiSE/xUd/TaYnML2am1ruHC7Ke/y1cx36nImIJ3jkr1oD2Y3kKZU3B0Aq/fFs7OMnzmfmTBAmvd7QmZIgvwYaxhnsHbaBGsQBSz69TGNSAxQbA90GRReK+05jWXA0/NHlNBBcOmjk4ZIb2a31RFO6rQZ0puMcLyiBjtGrmS8dZ3sUzN2OiGX+f7d9YoTEe5d4ERsbLBCad+Cpd3pCm3VQUPhowO8eRxw6DCGb8xJHSmq9XrYRnFOD88JOkYrCXxbKkWVfCT0m5sk1k05XsVdhpV9xD4khIBAvlsteyRjk6Aom7/jETKj6Tx1EmlPzBdrpM2g== 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=OuaoV5BkBBCvBHVDROVktq6g8EY45ffOKBgvHBRjVyk=; b=ItAkHuedgAHHxlmWJnpJ9+OY1T3HV6FTzF3qhUj34T7dd4tQOqgXgsuUaJNhIyd2+y9g70AQkNUc09PTtASP4tLEX6m41GOba1Z6JsF37QXEbaogU/JULFL3kNZsnsn1JthAVF72su5OzUyrS9eBlNsA20rZGdWASBQ0bsfhWS4= 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 BYAPR10MB3285.namprd10.prod.outlook.com (2603:10b6:a03:159::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.20; Wed, 7 Jul 2021 17:27:12 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba%7]) with mapi id 15.20.4287.033; Wed, 7 Jul 2021 17:27:12 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V5 07/25] machine: memfd-alloc option Date: Wed, 7 Jul 2021 10:20:16 -0700 Message-Id: <1625678434-240960-8-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> References: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) 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.13) by SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21 via Frontend Transport; Wed, 7 Jul 2021 17:27:11 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 057d43d1-5211-4211-29b6-08d9416c74c2 X-MS-TrafficTypeDiagnostic: BYAPR10MB3285: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:131; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pFP6XHYf3ZqMVQq1yKlU02m1RO4P7gtoOpkE0Srwd5VZjjPeWrv1mU/zDL4A4nVibHmxXuxKhVwx3S3Uu308nEm+l2GqAvS/XA8MRM/EOFQlm9nq+bG6yvQ6VNngqVtiwGvwascCMRLLrALr0aCGxejZl8zeFq3XQXPH/RxDizlm28CKC9TTiR21nuF2YNRK9VtFedyolVAou44CFF8rIohdOBTDbHMV5CXTYSuGobLiXmfRxOhgUk+OFem5iZeCDWFy0eiTiGMYyhq+NPU6qNp/cJ1eoAufCSVhhmHcLsIEfJd5VZBhvlbwglpgFmCTvLkjaMpm2OFWiNZGJzpGEu7qu/qQFJdGi8mclbLCYg4z5Lo7aNfxx0kLF8vIgH1dUB5mI3X2sG6j1h8yFJLlGwR+4RCOJVplVc3K9dCG59SbL7T7mtv0Uh5xJg5OYNrnwRexwEY+W4mpgZ4KHX77G++EqvUHNTHsDqLgphlltre66/CFxx8H2XnGASd1kjpWn21dHvHbOlSQ1FchafYEM4LtPUm9jPO5R5mbdh6gmEsJ4vkVk9Zet8+8xEA0MlgudOWHJ7Jq1SkNzpSj2H/CuLir8ki4AA6Kg4UU8MrWkxF4puE230BYTaMIC3GYr7tdsP6d+H9UGdztlHY1rzMdlNMjkcMVUbTxRPALfXGzFjNHCOUtpM6s9cj8vxnT9erN 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:(376002)(136003)(366004)(396003)(39860400002)(346002)(4326008)(8936002)(54906003)(7416002)(66946007)(38100700002)(38350700002)(107886003)(86362001)(7696005)(52116002)(66556008)(66476007)(2906002)(83380400001)(36756003)(6486002)(5660300002)(2616005)(316002)(26005)(8676002)(6916009)(186003)(956004)(478600001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: khDs/0YfUpPSb5PBNlV9gFoQZs0+TEknbp3kxiknMvsE24XDB95/2ni/ZGYiCVCxb1wzsO7jxltW2SKwYPasSqxxqse9UY8Zho4NPyuopqQ61TCEYYBmOerAVKQlkhUZoCaXHQZf4gEfMmsP0e1yr7ARY0krmfAVsAsSED0V3Jw2WhYT8AtEkoGG8BmxXvtcv6k5FqQhThwRfvEPl64GRi6PgEdSHSuSGSweySv/B86o4vN3YYnUpYpseo66jQDUnWYLEIS4UbfdAQqdoD1+8BYvrLONaeDgOvEKLhAqgdC9Djl+shiy0MBsSxUaC4BhIROhQFQyWYpSJbrpMmrsW1lLjJfn79lsaREUWCr4C+0inE+rfw9eincro4p2UtCrD5Yt2xjDKOHrkPIjEo9+Zj4oWpWfYlDnmpKLNNlx0GPmQgI2Mt52sZ7FyKtW0bur1syBVJ+3bA10LirKVBe+eRQmFxxbp8cOLyMBSf/01lbU/MjJaIT9TvNXhTMNkG4j3ok28PaeE4GBByBAmG+oUAqo0D6I5sS1oSKZlWw/mPpdD6rbfw1JWUS547UE+cgq04R+jSSLIpKNUPsUMHjJw0QhAzSRIHbZj2GGWk/vplHleGuaR97LS2q5bw38Nm8hutdpK4CsG1r4XqosoiQwMXqhHA8Q+FegFJ0nDnwFUJLcC/y6SzSmD2GsEc4+EXpx9+M1hNx1rdn3B/+jbW33qD2l2jlzXKwb0BSaHONeB3R+wZroM+wWTkkrCQMY2P+sFOdoL1ntfpYFQuX+0KClTH9dxLwTLlAQe9oKcQB3fq9fwdQx1g4c9MGFeTSp1gek/OFOYp1gLV6xXPfbbUpF6CVbDw/DGWVJFfUXiITOTL1S63LN4Pleog6x+CS3lbOmtKAZZnjYalGIt7AjDsRA2nQ1kuy9nrDF8nGWWcQVginyUF0WeblSf1+0lO7vb3nPeyzh3WyPF6Z6tWDTFi6zaas4BSRo8b2tC4WFgco8Js7buCSPxmaCdjJWzHeSkelRfR/EftgJJHSRjIG5Wf36huoUrMRZYG7wyOX87hEaCzXXjCUAXK0cV+I1s+HtbHheTtPg7VJXgjWGiAEpuREFRGx5NTl/Y5zYEsZicSBsj8MXjdEHOUop87qWet8exP6wiHD/wRkgKCFxN8RQzmdMEsW8pbBIMv5rYY+u0tYzvHLsmX0Ipf50jra85GExm6wrwDr5hVjC5+V4HBCWrCqVwNevhHtnRkcmfzc3356kxnRsPNmHySuyD1KOvJAgHYH22Ew6E802378IAsUyHYkBIKyuZOLbcO/CBqPIJUeCRFysENV65c+J4ki5DVMQN9z+ X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 057d43d1-5211-4211-29b6-08d9416c74c2 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2021 17:27:12.2280 (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: puwNZYGhVVxmnJ5c8sQ1csJ9mDanpzcTpdxIdsVev3lnFLp1MKMEuBFkznH2W3tsLzCvkdkhM7VvRujYWof1KAB7STUkfEFBajMd0JkZCw8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3285 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10037 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 phishscore=0 mlxscore=0 bulkscore=0 malwarescore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107070100 X-Proofpoint-ORIG-GUID: O5O7QzWdY3MD6PBTtugBOKHTwd_-b0D- X-Proofpoint-GUID: O5O7QzWdY3MD6PBTtugBOKHTwd_-b0D- 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 , 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 | 5 +++++ softmmu/physmem.c | 42 +++++++++++++++++++++++++++++++++--------- trace-events | 1 + util/qemu-config.c | 4 ++++ 6 files changed, 63 insertions(+), 9 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 57c18f9..f0656a8 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -383,6 +383,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); @@ -917,6 +931,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 8965dab..fa53734 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 memory 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,10 @@ 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 memory using memfd_create. + (disabled by default). + ``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 9b171c9..b149250 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -64,6 +64,7 @@ #include "qemu/pmem.h" +#include "qemu/memfd.h" #include "migration/vmstate.h" #include "qemu/range.h" @@ -1960,35 +1961,58 @@ 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(new_block->mr); + if (ms->memfd_alloc) { + 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; + } + } + 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/trace-events b/trace-events index 765fe25..6dbcd0e 100644 --- a/trace-events +++ b/trace-events @@ -40,6 +40,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 84ee6dc..6162b4d 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 Wed Jul 7 17:20:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12363145 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, 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 2A14EC07E95 for ; Wed, 7 Jul 2021 17:46: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 9276861CC8 for ; Wed, 7 Jul 2021 17:46:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9276861CC8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:32972 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1Bci-0003Ob-JG for qemu-devel@archiver.kernel.org; Wed, 07 Jul 2021 13:46:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48384) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BLR-0002ZX-2J for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:28:22 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:9202) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BLO-00070V-Sl for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:28:20 -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 167HCO4F029361; Wed, 7 Jul 2021 17:27:16 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-2020-01-29; bh=B7thqYCtugzpzpKDd4BNDeOqSRJYuranoqPGv/pNnDA=; b=OBREZ1OtbE8xMFRbdRVzGBvVTK9DCnfj9e6NFg+Kn/etnPlQBhZdC0rqV12FfAsQr8Y1 oWOiswdy2YfawXq8BTuIy1ByYr9Freae7GDLU/c0nCmGDWtV6hanGVUG7WXDLq5B2Dw5 gMWnXAuNB5bbv7yp8nsd1NfdiZCKxsR4AwSVhrcoh5qzkCaHz9tSBgAEVsr29LerE0oZ ImjQjtVevV3dHCndrUtwYIaKRhsWHGsBgd4m/kKdgqgMomlEPpOiuDfy7R4wz/wCk9xD N4+him70IWGbWHQh8L2R3u+7N5hXqRRLuQaD1gzhgRwcG2Bn0TDEbq/6+uvDEG90jBYY 3Q== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 39m2aacpaw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:16 +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 167HA7t7026057; Wed, 7 Jul 2021 17:27:15 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 39jd13ubc5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FTaIguH5h29/zGj2vObT2bTJ4FgaBbgpNU/M4HuGL4jLREui3HbOBWgAXfeUkXBwd0UywCyFeyRY8mnkbaL+Cz3UuHKhKSa0qUCMJ8FswYW5R2NQ+ueRn/8KAlK4ZIvh/jR0OAwQFAiHCr3BjbL5gHJ/EiXKpzn8vDd56MF3N/5SFff5OWZJCxx3tobeDfkskjpWIp1few1wq0+rWOGhzetscjsWGnkGrV43lQTZx3Lkch7yHKZ0NjmebNySketgKfzLvtvfd7SFdzRbF6+2v0ZkhzvQqBdvSDrB3LL2AZaDRuEQe+9A3AVFElyICgwrHzHiQAZJ6M7aCjcDvHqu1w== 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=B7thqYCtugzpzpKDd4BNDeOqSRJYuranoqPGv/pNnDA=; b=F1Dsox6C2K8NOq/hbIUaH7PyZjoZb6b+Hel4H7l+Ze7Uc9897MrOO4qxm2u5tXSVOehf3JvtBCh0pIT8o6uMpoDswLlg8aXbeupu2CI/Cm6aib1Ap2Jq/rZl3ps9cfIg2OlGCtKNdfqBwKYamPprWacg6aczb30iiKV152vr3SlgkiSBqZHFQAr9OCangOTLVnEIWMY34pM158q6WQT0aesoxR7OtYPGmJALy5DWJathrBQTxURJJ/P16q8y7VSVLdzfRAOJRKfu5bg6bln4jQlPncMw3Vrn6zbK+KfhmcIgTmebtpYWhmU+su+JLTyeWp6PJbtQQbG2EcXUE00g8A== 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=B7thqYCtugzpzpKDd4BNDeOqSRJYuranoqPGv/pNnDA=; b=d6rEblDKLDrOx3rwjPjUcpHGK9VZkPnAfi/p57bjeptDrnzxnkxMAVuswCPRE8km3T5FCczyf5x5EUPBoiojyW7AYnSEt2KXdXc/wz2qAFxDYi004e6lMp49ILPtyP83rpXp3SeSvjdgtTOTUVh01qUx7KbKkOFA4yau5Q2kdIM= 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 BYAPR10MB2677.namprd10.prod.outlook.com (2603:10b6:a02:b7::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.23; Wed, 7 Jul 2021 17:27:13 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba%7]) with mapi id 15.20.4287.033; Wed, 7 Jul 2021 17:27:12 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V5 08/25] vl: add helper to request re-exec Date: Wed, 7 Jul 2021 10:20:17 -0700 Message-Id: <1625678434-240960-9-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> References: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) 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.13) by SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21 via Frontend Transport; Wed, 7 Jul 2021 17:27:12 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 77f930f8-96fb-45d2-a1a5-08d9416c7518 X-MS-TrafficTypeDiagnostic: BYAPR10MB2677: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:949; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qGUQnPG7YhBKLAdxfdbhI3po5J/So1OHVTUAWdu+9hOmHL3v4fzFIiz6M7p0i24AIcFWuVRgdIjM44ITbBN3U8z9q24+fNqcBLBYV5VRrm7/0SH1qf97SJRR6Lp+SeEWrXXFqfccokxd2O9B6RLM7vAVQ5t9RVyAgwwKsRFWT68UgHZYMXgcYqN668+f1Xtwmyja42uuX2xiE6FAmARfjOFiiMasT63A8OJSnYckyNvqW69IleiogrBHB5Ix2xg0a64lFmrnR/FS77LASJpK2GIyXxLjahzR5Kp9s/Ag0735bahIYjO+GMMysV9aZodLEgdMJ3/J/zTAUskmY5TpyIpcsLEtL7hvCoAY0lBATcyFVaAQWmXyepY2QhyG2cRNRwHrV85P1b0AJczlloOdXcML+Peg2jHorTv6Y8zpOAE883Ns89tVovoxHw9/T0WYfsiDUJNJOv30HGwnKeRv23iyiYzYX0jgKeFavioIYAOX6zSUwaUgRrDSm/c0HHqSVVz+A5Mviljwuujba81r323kYaRCyLGDkEqlUQKFHjBmaHXAGls0TUM3QsbnQ+yXxcmvv5qUXvmD0OVhqo9+y2fuNzsiiW/OmY8ehi7A+cgC1sq3jLXoG6aPPQaEubFW209LuCC5MaeL+rtriemxdB5AMUUz8wd+ILYjlEYFHTwu8seNkShUXmw46at0eRw5tdBa8h0cOlDfnF/PeY2giQ== 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:(396003)(136003)(376002)(39860400002)(366004)(346002)(6916009)(107886003)(38100700002)(66946007)(7416002)(4326008)(6486002)(478600001)(2616005)(7696005)(83380400001)(36756003)(52116002)(956004)(8936002)(2906002)(86362001)(186003)(8676002)(66556008)(54906003)(316002)(66476007)(5660300002)(38350700002)(26005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PCtDYp49Hky/Z0j2N+tYsefpzdLmOQ1Y758tNpaz5Td3hz+CzWFqmIG51E9rE9dzoumjIBBpD4HmBdFGv9NIHyXiyCekUmcKxN3uoW38+5HiN66jXqKNoPyEhZ20WoOAE9sWUXfvfoBr6jhtOTX18zFoa5+FGE8rgoEuREVpVwVzxOj2ef/Sgxj1l464DwHNCP90WCFE8bRnQNxX8/qDMXMDolMg7lQHrz6dtLhIy1/rgqEeA0Lyq01t9pW52jXGulHO8bIPYTDQKHE6sOqGj6VF+SAqwq/tkYXCJmPEC0htf56dm0dRsCZcTj2tcL/MxOCTk/Mdg9W3UoRU1mP5VdtMo7/za5KV4XZnGe5uwVi4m7ORHl5f0GcxL6EM7Cn5HolQb1wXd4JqfJKPi6gV9J2En/e8nubpF4TpeRpLVdnxxRTT5WKZ7COsMZEMXA3M/C6bm/sg/GWK3fITJLkc8Rd3V/ZwcHVFnBMMGE85QVRiqoklK9N+perybiqE9AutsHhRQf0RTExbHeolaZcBtlKAQDDysFA3VZEe0GxvAIPzervN/ggjQncdKGMAXfpl01UJIY+RxdKIURPglPhgbPdfh4KNUS28yaKGuthlQs9rM3tT04kU7egWiNJQA7x63JjMwS4w3j6zUNKgLn2Q/FP9rjcVpQwM4ZdeEoZiOl/9leeLPyW8hsMlYYFVqGqg2Tu7f7Ibe6iXBgKqEUxFWPxWtXFOJP9qKhzYqa/WliuzVVYwZSjgNZuEhFIA5VXlB9+BOxWTUftbGK0EAIoRBi2CZuwO4oZjXF3b0cKMnk6HADZX2Z7rBOxmoP/Vk6hM6rrLiZiEhXav0IL790Q5REhgy0tpeW2oX/I1EBsTiwP/TJmbNaFVesb7t44lkKk48VmaWKbMwfpkteVtpV7YfUpP0iqc20htRmNKQbJwCBJGSDxTgATmmOFVf8mpUZNkkmXY/AcE1LDWSZsqjYC6yfdC+tg5SjITo+5obWUDO+e8lwxN0D5qqNfwh4MzqJ303cr/w/0wCAKfb/eEPuFZpNuKtJROsYWoT8XAg4+kFvQqezo7iKhvl7m1bQLMXblmsmqltLPHJTBZxHCVSQW9W/iJOnk+96zj+E3j6twaHiTC6IQ2+aesCFLoHgHzAOJBj6Z5s+EsC5Dwd9kCYEPJ5OealxjYaKKwINUW9nPNV+owXd9Gy1L6csGt8a+q+ldM6f3lGQ+gu3nOjGLXjRb7ll79NcSCGGfuU2CV3GThEyE6UNgVzgqeeh7ZLUKKX2N+m/KfkgySifLOyPXQp+Qzx8Rj4C7bXpJkmkHabvPJrxaAKu2yWS7Kdvu12moSuIIS X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 77f930f8-96fb-45d2-a1a5-08d9416c7518 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2021 17:27:12.8906 (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: iB5cSqKH3BeP+NACt/X13xcxSh5bvRRALI8PxeS7nuG/ZmY6A/EAU24+9d5FzNgo78AdyBLAi8CvP/uQD1f5SFqqjJ10/j4cN94TY6GF6Is= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2677 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10037 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 suspectscore=0 phishscore=0 mlxscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107070100 X-Proofpoint-ORIG-GUID: KgXN5GXI2pik5lS5PIw0q__U9MjQxzda X-Proofpoint-GUID: KgXN5GXI2pik5lS5PIw0q__U9MjQxzda 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 , 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 | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/include/sysemu/runstate.h b/include/sysemu/runstate.h index ed4b735..e1ae7e5 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(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 7fe4967..8474a01 100644 --- a/softmmu/runstate.c +++ b/softmmu/runstate.c @@ -355,6 +355,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 +372,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) { @@ -645,6 +651,32 @@ void qemu_system_shutdown_request(ShutdownCause reason) qemu_notify_event(); } +static char **make_argv(strList *args) +{ + strList *arg; + char **argv; + int n = 1, i = 0; + + for (arg = args; arg != NULL; arg = arg->next) { + n++; + } + + argv = g_malloc(n * sizeof(char *)); + for (arg = args; arg != NULL; arg = arg->next) { + argv[i++] = g_strdup(arg->value); + } + argv[i] = NULL; + + return argv; +} + +void qemu_system_exec_request(strList *args) +{ + exec_argv = make_argv(args); + shutdown_requested = 1; + qemu_notify_event(); +} + static void qemu_system_powerdown(void) { qapi_event_send_powerdown(); @@ -693,6 +725,11 @@ static bool main_loop_should_exit(void) } request = qemu_shutdown_requested(); if (request) { + + if (qemu_exec_requested()) { + execvp(exec_argv[0], exec_argv); + error_setg_errno(&error_fatal, errno, "execvp failed"); + } qemu_kill_report(); qemu_system_shutdown(request); if (shutdown_action == SHUTDOWN_ACTION_PAUSE) { From patchwork Wed Jul 7 17:20:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12363121 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, 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 64097C07E95 for ; Wed, 7 Jul 2021 17:36:09 +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 01604619D2 for ; Wed, 7 Jul 2021 17:36:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 01604619D2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:36674 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1BSy-0003ne-09 for qemu-devel@archiver.kernel.org; Wed, 07 Jul 2021 13:36:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48106) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKY-0000SX-U2 for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:26 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:27498) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKS-0006k6-Cy for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:26 -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 167HCNNP010636; Wed, 7 Jul 2021 17:27: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-2020-01-29; bh=+odAudg6fzmwU2d1k/Az+04Yen2lOttTvaitiX4jwAk=; b=mdYUsvlWQZyn6+zRsE9IWhC8Yh71Ka9sXmAApBzgsUMHbDb05tKAMNHMot4Ex0fdpUFx GB06UnHnyjji4GrMZqxFXuUhvj4L6Z1v6H8LiWXj21XdcaXVd1Ab73221TGImDuPS2Rv 5SxqNyrN7wFsU/bPL+QopzQ3xxY5shTjoAeaNIuWgFhXFbPpTipH44US9Dfx0T1v1P12 GrR2GuVdqf4LP2RPDLkRwPKRmMFp7mw14bIts/Z/7muGRHm4dMYxTWL98r5YxG2F6p/L 1jKczVtK0bExhC9ABSJCgxIURitF2gfAOS4oJXlhsUoaQhxDBioEmQHmMcBcjxgbKX5V VQ== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 39m3mhcngx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:17 +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 167HA7t8026057; Wed, 7 Jul 2021 17:27:16 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 39jd13ubc5-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QXx2KQnq5F7LoyR3pfGmd5sqMM/b/zRaTa0R8cWZOIHfmWrYXFTt7Q2EIAWRzVYT64Ysfy2GuH65PqFZo2bl5nlXKlhHgQDMGFbrcqdhZb1KFMcOgtD+L0owXUXvPwys2EY70IBHQJ87z1gmGfrzg3gOGQ6zICQFhajxP8Oan1W/4yNXs3S40IoDkPAs05aeTkDHUUZ1X6mBmGHV0uQIqK+KfgJH1XTIrsfQExH1Clo1Q93LF55/oWDJygu50Ig0QZ9GrhwngwPVaBYO0pkZMEkBodlTZtVE5NJgbdT30lUZz7uVcXCuYDaOPbW32JC3RFSRpTejyGrZSe6+lcLUiw== 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=+odAudg6fzmwU2d1k/Az+04Yen2lOttTvaitiX4jwAk=; b=G0QecN4pZeZnKHJV1cUVKHeTMaseUgR1AWFyuddCu5MiewmcUpET4JtgV42fwUkUDFtfRQp1fhzWzapSpDIk9jCCzuVMHmHyY6KQ4ITuD5/qvkdwmH5kI4WCXq1t9golZsd4eNg+z4pns7rkf7MzGqLa11H0g8pfL67q/M+werujP9veEq5FecEo0TVafWfpzbkZ88H/YyOAuPS/AGnakjh7agsP5t4LPRwP0bfI97hGOEYVRS/ZWw9fxCSDWlgMZfxflOxqH716k4KUTkAFqof+vEHOiI1KlWW+IQRBZ/ETLrgE1awUYk+ouYE2LxizumQklQwFa0qU6kiO1QkdRA== 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=+odAudg6fzmwU2d1k/Az+04Yen2lOttTvaitiX4jwAk=; b=xo/ruztgPqQQjlpaZ9Ani2cyh0seipP0ZnNW19XVpRA/MNzeYUi2SR8OMl5rdbcw8+qOHiP/7SlO63IQABIkEyyOKnYMuCipBrphYvInrdLVjKsZrHRMeIONRBfU4qEfnlebUfLX6Bnke4mXDNxvZLF274F+B+1UDk18Kuj6SgE= 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 BYAPR10MB2677.namprd10.prod.outlook.com (2603:10b6:a02:b7::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.23; Wed, 7 Jul 2021 17:27:13 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba%7]) with mapi id 15.20.4287.033; Wed, 7 Jul 2021 17:27:13 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V5 09/25] string to strList Date: Wed, 7 Jul 2021 10:20:18 -0700 Message-Id: <1625678434-240960-10-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> References: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) 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.13) by SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21 via Frontend Transport; Wed, 7 Jul 2021 17:27:13 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 70f0196d-24a6-4285-18f9-08d9416c7578 X-MS-TrafficTypeDiagnostic: BYAPR10MB2677: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: c+o30Sl+9A5qwNU04xaiRfRkxouA29uphQgLwL3cKwnmfIWx1PQ870fieQBKbhh9EXGY1EbveLXFoB2/H+YaVfOdWbK/fGZa3ue4FX6pANPxlo1qlGrRR7DjzIJNA4GUTlGakWB0Ip5JQmb+tqxLub6b9UA1NH6eIcm0x742qtUnZSB8ypK8NumkHSs7/DUJzIYRuFES5BiQRVQXBnquL+zgI8gsy86XNVNoT6Raz7jvWMV9/byuQoQ/ycpTcbPXnmfistKd1nnRVkKINY7VlcDPHr7N1dZOGAfw+5WWDPwkC2aIDJf70F7NBY11M2cfD6/7tFKRC5ts1lQRRXWj/8mbZyS9kgwhirVQOTwCNtbhVlgGbhYbnYdCKpc/+iilKmY9W1ihf0J/5GaCf1yrifvKiMPyAauUXoPU73fodNx955fFa+ic3XgKlp1UAiD1YvXHBAQWJs3ndf34z+kY4H3lW4suw96DGhZerWt5dsk9z13m5IBhvg8rUFoIg+153C40EC995RxLLCzaGYcNAbUpBG04P7QyadC8y08xQvt+57Zcxqk9VG6chIEsg62aNEqXQvDEk4mDSEPtoUpah9RACrP0UoqeSv3KLuXBrjbjhj4U3TdIjvCIAXJY4HOUZnHg9Tx+DHTNDA46Zj8sYnn8oxl3tJiWgGwFyQb+bvElb0Ev0fg132rdF+s7TDkM2VjAVZRVbIZxZvnDum+qcYadf9jBt3FZ5GoXgp4XnDw= 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:(396003)(136003)(376002)(39860400002)(366004)(346002)(6916009)(107886003)(38100700002)(66946007)(7416002)(4326008)(6486002)(478600001)(2616005)(7696005)(83380400001)(36756003)(52116002)(956004)(8936002)(2906002)(86362001)(186003)(8676002)(66556008)(54906003)(316002)(66476007)(5660300002)(38350700002)(26005)(309714004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: I4who2b321tWoq4Y+ZAggMq82nSqrza/62B7EzIEDMDEpJ0xv4SRYGUkEWlh9TVdqe/EBuDZ7umxzW1rXO1ldSTr9WdukMaxtJK3pki1qgPsRb+EOnNK2iPJ/iEuPEr1hFDf04m3Xq/+YRUZr5VYeeVwvFcCGHKLqamGun6drtruA6wu/SiqqF/mboqIK8JCpUR0XXbAmenotPa1jc9fKnQPdYaK8FeFNjcwaEGcni0IBe5gYqbEBteHTZm6Gsn+FCPdz69NqM8pJFTJT1cVT0wKwQrNoUkVNx9W1JtupNqFsgx5j9cwlrpSXFj8I+LJaSNPwS8DGsYvE69ay58ypPhi8Nv8y6qxHZSpAVne0H4z9aEDxRMwMfkiV0ZjqnDd5fhyNlQX2uE8oAbGMBgIixKViCN9a/yI/BuftMYFtKmPoFnCnFAVReF3NDmq3b6mQ2FRz4m2Byzkazl4opNUlmHVUmuV9dzmqQNyj4qEbKW+M0Mu6Z8dq1cSwnI8bBKj1iQiqEDp7xguzGrs5c6kW46IEdal4NlHF8Dnkozo6zzVIv6auS/gre4oEII/6P/Sor9UzN/Z6cDmYAnsKlGlQlFWD6lXxVUUR7tD2BF7brS6mi45jzEwbqA0Ya5SKRBXGb8Gq+RmA6QYHe29fh3oNR0qjwvjISY5Ce03zl7RwLB83KNLyhcN0sDxxK+7ZZnT2bbb4GbovuPcrCjcbRfQJfUih8AYiB/PyJ7hG2VHbIVZaQaRQ61gc87Ti9l49UXmaWxJvM8C99kpgAnWMOyIOxgnqodP+Humq0WUa6YjDJOAPegU099jIUZWT+V6WahJgCby8vzGt/CgzkIA9kt6nRTRtBX3hSVMd1m6YZeewvN1ZI445LJ5EzdS1MakTI1r3+MG1TUuLh5qVrD44ghevWyfJBvEWLuirA+4HjVWEFDqKeYkb7+jda91toBxyg3EK83+hi8KTOCl7eNg/0VyNLd0zyP6viKZQ03KuspIhOMTC35oulNE4qL0Ds9tsTvW2NKXuwxo1YR78ol71ZTEhxbxdVUlVhKG2tKRXgXKvaQ0IegQWYatkuDmBoCwTG49BY9CjalSLFdVIWxnXa34HbFPSvtk3VT/iRqxHLZaqJMVQ9iOnvhHxPx26pF/K9S1aWl1U2ZAIaCBne+jUA3Hj16xRzgaXtK+WPz3Wp0WMxgtXtsH3KfaN9g+F6sO9IurVO5E44f8+6sn2VxynuzzpGxwNdmcmwX2VK0yG5ShgA/9AH4Rl0tP5datTzzXpF1qy75lVJnzToboOjCtzieWgOBZDlAoQDtJ/kpAsChtItri4I33ikETag2+PJvoNXbe X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 70f0196d-24a6-4285-18f9-08d9416c7578 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2021 17:27:13.4823 (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: 1ifHQmaRH8endDdba0FlLh5kPGx/jwRh+4AUVgzdF4F7cS3y09NXREyRlxk2ObEO40b9g/ZHSZQbztqDt/QiZePk75JFBiI1BHqJ1H6Eqj0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2677 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10037 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 suspectscore=0 phishscore=0 mlxscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107070100 X-Proofpoint-GUID: fgU8D3x1bmSGOKolMKFxT7vHbJ5wCr7_ X-Proofpoint-ORIG-GUID: fgU8D3x1bmSGOKolMKFxT7vHbJ5wCr7_ 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 , 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. No functional change. Signed-off-by: Steve Sistare Reviewed-by: Marc-André Lureau --- monitor/hmp-cmds.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 8e80581..a56f83c 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -71,21 +71,21 @@ void hmp_handle_error(Monitor *mon, Error *err) } /* - * Produce a strList from a comma separated list. - * A NULL or empty input string return NULL. + * Produce a strList from a character delimited string. + * A NULL or empty input string returns NULL. */ -static strList *strList_from_comma_list(const char *in) +static strList *strList_from_string(const char *in, char delim) { strList *res = NULL; strList **tail = &res; while (in && in[0]) { - char *comma = strchr(in, ','); + char *next = strchr(in, delim); char *value; - if (comma) { - value = g_strndup(in, comma - in); - in = comma + 1; /* skip the , */ + if (next) { + value = g_strndup(in, next - in); + in = next + 1; /* skip the delim */ } else { value = g_strdup(in); in = NULL; @@ -1170,7 +1170,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; From patchwork Wed Jul 7 17:20:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12363095 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, 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 C6CB9C07E95 for ; Wed, 7 Jul 2021 17:31: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 55BBE61C9A for ; Wed, 7 Jul 2021 17:31:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 55BBE61C9A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:47762 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1BOh-0000x2-Hd for qemu-devel@archiver.kernel.org; Wed, 07 Jul 2021 13:31:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48030) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKV-0000IY-SU for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:23 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:27600) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKS-0006k8-MU for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:23 -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 167HCEqO003527; Wed, 7 Jul 2021 17:27: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-2020-01-29; bh=NPiCAPVL3wacx/GUjV5qGsrURtWdPeMb21Lfx2em7xM=; b=e5rShr7O7dX2zWbMxY5nzEZXyww2VV3v2jrJnX4682LWQl2yZiVmX27h1QmRJyKgLhd1 7AuVai2boog0NuwLpSN83hdSMIn0AnSrC1Vykj2t9LgHcFS6YvamRJcp5i3EAn3ghrH2 6bXUbGAs71XNwpdeyBzyBl76t0P7nywJWHSQ5j4xzU2THkpvfZhczo4b1tQ+onbSKAob lx6kRjngYSXTnDNTnYGkHgmgW01XzFP2cHe8Ts30ReoOvGYZ76+2ZGxjvO8C6JnsRDDo G1FDDWtQtEm5cOf0BD/0TzN3iAV9quXaSjDzvwIH3Z5klJ91Ub/yKcbI0+AJAdOKF6dz RA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 39n4yd1erf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:18 +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 167HA9Ao026129; Wed, 7 Jul 2021 17:27:16 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2177.outbound.protection.outlook.com [104.47.55.177]) by userp3030.oracle.com with ESMTP id 39jd13ubct-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gDpklX6EhR1/HW/rsumex0yP6LiGNPO9tkCzpAgdXJ864ooM1M+nDH4KAupd46ARJk314hj3NC6co2KJTRpP0+r2x8J0isNv+usLQXvxT3traz0ibD6W40+I8IyrKxrNUJReeqpa+Zz0XQhtXt9vznmsarGkcUtKKtFP1J4LptoHl100Mq7nhRML3R5GIjnDS3ztzHaCbmdU2kNjZmwfER8KO2c+fIoeQ7KxKdhLCF21vvGLln1RZL4KFaguazrnw+3hl3dxpU2cfOwmNg3tbKsLJR1MjnNP13vuHQJh03a8v/aiN9qgyo+FiUQ8OHkd6ruruj382d+OFYgEu8EoVw== 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=NPiCAPVL3wacx/GUjV5qGsrURtWdPeMb21Lfx2em7xM=; b=itx6w858eA+D2Sp6/DgosI56wupskK3D/qDSEyQ4rQPYeHU7kqXzN7bbAVTbZs7N/9tU7BuJrdLQi0aH1OKnAPhXBbTzGx8b/WhWZbZrMlKE1ExejXv9W1mNqbjdSL07XKETlWZdR+zDY2NzW6L0ESUmADHvdA6asfTXvz2oULQsxDvk63D3u+sr9KqF6rBtbXTLh6VR0JyfVYwgtTx1QoxBsMQA0rU/QLIT0AUZjPCMSP2whgYRx8KyHQ0Ic3vhzi3zXDZAjFxLm20pfH6VJ/WOz75867zqmXcs+matHzdfHdrihVffVZ45+9izo8M0ir2r7klAgXXUGprAv/7ifQ== 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=NPiCAPVL3wacx/GUjV5qGsrURtWdPeMb21Lfx2em7xM=; b=E8UqTGHO1vvVhZIuYQvnZoaBF2dpy3mmr/WW5+cAHjcR65HxxlHwRZKUhyKFEUadvgXsPG0f8CzWC8+ttyl3r31vQA+1xwOwBy0ImL0th2gC6RxP87LH/5n9W6fXd/FbH/ERAmQwSCBKd1yU5GktO/nhWsOYmS+HQjExNiU3wL4= 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 BYAPR10MB3285.namprd10.prod.outlook.com (2603:10b6:a03:159::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.20; Wed, 7 Jul 2021 17:27:14 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba%7]) with mapi id 15.20.4287.033; Wed, 7 Jul 2021 17:27:14 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V5 10/25] util: env var helpers Date: Wed, 7 Jul 2021 10:20:19 -0700 Message-Id: <1625678434-240960-11-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> References: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) 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.13) by SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21 via Frontend Transport; Wed, 7 Jul 2021 17:27:13 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 99b5de55-33df-45ab-fdae-08d9416c75c9 X-MS-TrafficTypeDiagnostic: BYAPR10MB3285: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:473; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G9XyECQDwIu1cmvzOu2V5MuaSLeoMpj1jqDx9eL4JtnX+hFuq2k73cnLL8cVhHCgm0kQmh6kcX+HZ2uunN6Vu8wVlRffkpuGSsRcbDJgYPINJgxTQN819OrTIJglGHESI9XiLhMHxRB+lf11UiPFMOFjF+3C1SEkiBlcGsj5akGKd14SyWjTDcCdBRQ7FvF+6lpe5h021RFQUX4aw2gWLs8HtKlZeMsjwWpjBeipcevG6wehPNCkNvu45g43/2lbzJw6Vq2X0UD5njg4Y+3H/5HdqT59DUwngK4aZA5qFShNeGiDeeEzbMiGrBfV83iGQI9pVA8Htg2DsUMzq88RhfSXKr+Nrjcd2ifRXl+CN0rm7qX5hm+VHg820awc1SGADkcVOKDf7CFtuCJwGTAG+RzWRcBLXu88ibnkLuVGk/uuhoOg/DRiqQ1RjvbBBwabD/joGO8z/mxva9Zo5BpQqU2qUEpMV8VmdXmA1UF3TWhfi2fgzlJQ4nZApGeLb5Ru8tgZv9MCLFANpuGU9QpckXuSHCAT5sfjqsZQxih1Ho1uHyvGlTDfgRi2ij13jr+5o0ZKYo/OGW1wHMzMAJzW+DH3sByD5sl82gpug+Os7LWb/n0FjnSiZ40ZCCjOamBtSxI9GJsSRGZOXnBIKk2C3hB9i/9tCQEXkMjPsP2fU06W/Y1Hut+Qk5vBz1sLsi0VDIW17j5WeFAGH2pDmR+8tg== 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:(376002)(136003)(366004)(396003)(39860400002)(346002)(4326008)(8936002)(54906003)(7416002)(66946007)(38100700002)(38350700002)(107886003)(86362001)(7696005)(52116002)(66556008)(66476007)(2906002)(36756003)(6486002)(5660300002)(2616005)(316002)(26005)(8676002)(6916009)(186003)(956004)(478600001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9C6fuOdFV1yKJ1yl+98gJuL1n4FywTmaPoiuIGZ2OopbpcPqRu/a/KCulyqUDQ61vXHOztvdloPyBlGCYbZYO5hfsyyM8cPtYVonm4CsRodd7+ARWK7bdcTsy+WlbOl9TLR8k2TeVPrdn6a56hNOap/E+dcq8AzlmHI2c1WtB7Z9o9yPvzpRkcpk1Y6crErYPKPPtcTO1qjxkjrQT5fyQBICy1gJN2O3hCo2oGT8Jth3ry6n9yiBK7ofW0DJgDKDDbIDRnhvARI6VOghaGtSX9ie3fsjRW7JngGAFxkQ62dLbrqRp52ArzLRecH+eRkbMmSAxK2gFxOAAY0sDUGHR7ZSNxbEgctIouMt9eWNbVxrh0eVj+lJJX16KIBaw7kjoC2xw1PI9oWTFNVQYrb9qhiox5K6NEoUbr8cETgW7lLKLYIb3Y/I2eBmKH2B8IX2eJEhfbwl9mpCb/8f0aCxHxyvFC4ahVn8fsX4UyH5W+85OZ1oIBt5KatRLGxp9fe3kWAv2JqVkD34JF4HfFCeUWhAeC7o+NjSIdIQbmFnPeD3wYSylTx+Lwhv5HgRMcQQHkgciqnNxHDqhwxqUEhk4EtrbjX4inpbncVH/gwfD6MaBjRNTt+v4WQl1UdOg5Wxr/14LHW7KQGoC9j8W10xfwH+ujLpcF2t7av+8F+9WtZ42mTAZcerqf1Sh5OphtVEDihYU4rhBjAVtBbqyH3zcQ7bVeYvOFkO60gTeIolt6ltqOWWk4EP1B0ly4yLNmuruVZsAl7HCHQ2nEopSkDwa/OxuGi61qDyY7eH9yR4+Iz0m3CzEN98L4/q5GxBZIbhyqQ5lAmVU6ReXAbk23njHkYH0UixFR8IbfkSylAazLmLlsYo67MZgfYqB3D6ynZ7saVTJU5v3xEOwBbPT2rI9YpR7QC62skwobYgXNDj0IVhK5/XwUGThX9s99Sqj5w3eROOzvRITo5WKBXjdYfKx7u4p4GPyfKWhFQ2O21umuRlE2pDWlA8iYw2L/kKn4lnamQKFjMt2xArStYm3hbRT9k+4RuLNSmg0REuHnEfZjsTU0BPa2Iygr99hNR/c1YHD/zkYvfohQiVBv2FhyPyfTldRfIhQYarMpO63A0EhVMju0kA5x96TPhs1vwQEkQ8GzR5TGKyJvP/m46480olLOXKpley0cjMsgif3pz8az0bflBEvMiMfEqdpAu3+4B0WZKkYLImSROFnX7lc/DUYtuEMKmkv/gbyf4mpCr968FnFYOjdAlaZ1wOYyxn3ZiYB/C5joAJ0SL3eT2GLLee9KDpsxX4RSufYXG0e87zjaurtE1RY3RmuQpLx1lz0siK X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 99b5de55-33df-45ab-fdae-08d9416c75c9 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2021 17:27:14.1199 (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: WJtEsYp7aR8AfjvF9MFeMmTf+2afpTOonLFTjuykZk16lVqdgd+lqNJOzrEc2NYeGYONsNHg3LK3ti3W4gG/g/bD3lUFmhcdZHj7aV6sghU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3285 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10037 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 suspectscore=0 phishscore=0 mlxscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107070100 X-Proofpoint-GUID: 6uvaAJwo61ZzylcIpbX-DFljlg4Aa1tz X-Proofpoint-ORIG-GUID: 6uvaAJwo61ZzylcIpbX-DFljlg4Aa1tz 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 , 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 functions for saving fd's and other values in the environment via setenv, and for reading them back via getenv. Signed-off-by: Steve Sistare Signed-off-by: Steve Sistare --- MAINTAINERS | 2 ++ include/qemu/env.h | 23 +++++++++++++ util/env.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ util/meson.build | 1 + 4 files changed, 121 insertions(+) create mode 100644 include/qemu/env.h create mode 100644 util/env.c diff --git a/MAINTAINERS b/MAINTAINERS index c48dd37..8647a97 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2865,6 +2865,8 @@ S: Maintained F: include/migration/cpr.h F: migration/cpr.c F: qapi/cpr.json +F: include/qemu/env.h +F: util/env.c Record/replay M: Pavel Dovgalyuk diff --git a/include/qemu/env.h b/include/qemu/env.h new file mode 100644 index 0000000..3dad503 --- /dev/null +++ b/include/qemu/env.h @@ -0,0 +1,23 @@ +/* + * 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 QEMU_ENV_H +#define QEMU_ENV_H + +#define FD_PREFIX "QEMU_FD_" + +typedef int (*walkenv_cb)(const char *name, const char *val, void *handle); + +int getenv_fd(const char *name); +void setenv_fd(const char *name, int fd); +void unsetenv_fd(const char *name); +void unsetenv_fdv(const char *fmt, ...); +int walkenv(const char *prefix, walkenv_cb cb, void *handle); +void printenv(void); + +#endif diff --git a/util/env.c b/util/env.c new file mode 100644 index 0000000..863678d --- /dev/null +++ b/util/env.c @@ -0,0 +1,95 @@ +/* + * 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 "qemu/cutils.h" +#include "qemu/env.h" + +static uint64_t getenv_ulong(const char *prefix, const char *name, int *err) +{ + char var[80], *val; + uint64_t res = 0; + + snprintf(var, sizeof(var), "%s%s", prefix, name); + val = getenv(var); + if (val) { + *err = qemu_strtoul(val, NULL, 10, &res); + } else { + *err = -ENOENT; + } + return res; +} + +static void setenv_ulong(const char *prefix, const char *name, uint64_t val) +{ + char var[80], val_str[80]; + snprintf(var, sizeof(var), "%s%s", prefix, name); + snprintf(val_str, sizeof(val_str), "%"PRIu64, val); + setenv(var, val_str, 1); +} + +static void unsetenv_ulong(const char *prefix, const char *name) +{ + char var[80]; + snprintf(var, sizeof(var), "%s%s", prefix, name); + unsetenv(var); +} + +int getenv_fd(const char *name) +{ + int err; + int fd = getenv_ulong(FD_PREFIX, name, &err); + return err ? -1 : fd; +} + +void setenv_fd(const char *name, int fd) +{ + setenv_ulong(FD_PREFIX, name, fd); +} + +void unsetenv_fd(const char *name) +{ + unsetenv_ulong(FD_PREFIX, name); +} + +void unsetenv_fdv(const char *fmt, ...) +{ + va_list args; + char buf[80]; + va_start(args, fmt); + vsnprintf(buf, sizeof(buf), fmt, args); + va_end(args); +} + +int walkenv(const char *prefix, walkenv_cb cb, void *handle) +{ + char *str, name[128]; + char **envp = environ; + size_t prefix_len = strlen(prefix); + + while (*envp) { + str = *envp++; + if (!strncmp(str, prefix, prefix_len)) { + char *val = strchr(str, '='); + str += prefix_len; + strncpy(name, str, val - str); + name[val - str] = 0; + if (cb(name, val + 1, handle)) { + return 1; + } + } + } + return 0; +} + +void printenv(void) +{ + char **ptr = environ; + while (*ptr) { + puts(*ptr++); + } +} diff --git a/util/meson.build b/util/meson.build index 0ffd7f4..5e8097a 100644 --- a/util/meson.build +++ b/util/meson.build @@ -23,6 +23,7 @@ util_ss.add(files('host-utils.c')) util_ss.add(files('bitmap.c', 'bitops.c')) util_ss.add(files('fifo8.c')) util_ss.add(files('cacheinfo.c', 'cacheflush.c')) +util_ss.add(files('env.c')) util_ss.add(files('error.c', 'qemu-error.c')) util_ss.add(files('qemu-print.c')) util_ss.add(files('id.c')) From patchwork Wed Jul 7 17:20:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12363097 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, 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 C11ECC07E95 for ; Wed, 7 Jul 2021 17:31:49 +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 637B561CB2 for ; Wed, 7 Jul 2021 17:31:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 637B561CB2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:48202 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1BOm-0001EH-Gt for qemu-devel@archiver.kernel.org; Wed, 07 Jul 2021 13:31:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48044) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKW-0000LM-Ma for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:24 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:52756) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKT-0006ka-42 for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:24 -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 167HClel005035; Wed, 7 Jul 2021 17:27: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-2020-01-29; bh=E9WGCTEWcKfyHWkHeM0NWPiJKZAH0JTM5DaTNZpnzYk=; b=pxUS7Cpec+dHh/F/M7iecgHHqwajyblgPiIx6HaumgDK+HP4ZNh82/Dna3ImAGo9enq7 Ji5gC+7gnNi/BGsWbN+1nP+eLmco1AGw4JJ626TBL6YWK7QfChpgPUmUkyv5IUcsrv1z GC7WD6HkmCIsmEQASEaYdVAnMCavkmBjhAmg6JHHG77WE3RZ4Vv262EdFknRA5kBpClQ NxNHcx+8IBlZtkgBwwzGSoYqGo1VxfV+fatnXsDivxQ9c/Sb28xoVCkzoGlinKL9Q7uN PBcWpv1jkDUQdLXkhBtAt96yHQCl7x9B6GjtxfBLvRvX/bwfDz2FKfxG1LJqxco/QkfU Ww== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 39n7wrs7py-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:18 +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 167HA9Ap026129; Wed, 7 Jul 2021 17:27:17 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2177.outbound.protection.outlook.com [104.47.55.177]) by userp3030.oracle.com with ESMTP id 39jd13ubct-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NYldjOFfz+roYeue1u3xYGpWMuwnRobheG3lM4a06i/meFWuB79Qoc6fGZFrkYQ9LsOE65h+zsc2LATMHFwTUxZlEIxpt2unRgrYz9Zvde2UNfB3QI1Jt1ki9ErNTtCI9CjeA1c7s87YN5Pzo0N1ViAWt9fxCcYK+UilGse1Pwla6SNC3MOY68qAPFocNvpgF4VAqExf9gqkJJw1yR+T172joUlhkWEBx79x46pZ3rbwc2Uto1hQSzkn2n+igjYQBrhiR8nW7M4V60AdNohnnAMpYXR540JmUBfr0ZLcbghpWsRYQXsufaRbPUuHDHTaZHwsDPviUnrL+rraIJe9pQ== 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=E9WGCTEWcKfyHWkHeM0NWPiJKZAH0JTM5DaTNZpnzYk=; b=YQzuWahd6GAxwKSxhMe1T+RxrIJ7ibkbOCG7yYUcRE8Xpltu01U5UQJXxhr1bb0pR3GGegxEkPOBeWpD3pkBJLGsSMz2ZCfLW8ftTKLikJbMZPV3fyfsQXknaEgALBP4K4/zYCwN1aXD7zhvTLqPelVeqRU705xVLAuBbt0BQIZcD5UQ2tpNp3m2YBdrqu5YRZpIMugH38EXGtrdiyiNdP2Ary93uWWmIFR9/J5Iv898xcQvNik7bvTqi3rKbRwXSDVDZEl3gPzDmqn7mVW24CC95VVWxtfiyqWPsMTpVShTnH8koarpDDD2nRbKQf0IlORjp2yuNlaNOT3asGHQdw== 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=E9WGCTEWcKfyHWkHeM0NWPiJKZAH0JTM5DaTNZpnzYk=; b=wIJloxtYRrc69ljXz0JKa2WD2PNlHG9QU9kxXjaZjLIBvRgktHa9paJMycxfBXM04huQA0KeVs/sXefYSkxMsJNzmJ3v1/j3EN9vtpQJl9aepoh+dgg3Xk16yOxdJKKiETY2Dh+I0onc10f6wPg5Eu/cbfuFGdusHePrv+JlBL4= 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 BYAPR10MB3285.namprd10.prod.outlook.com (2603:10b6:a03:159::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.20; Wed, 7 Jul 2021 17:27:15 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba%7]) with mapi id 15.20.4287.033; Wed, 7 Jul 2021 17:27:15 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V5 11/25] cpr: restart mode Date: Wed, 7 Jul 2021 10:20:20 -0700 Message-Id: <1625678434-240960-12-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> References: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) 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.13) by SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21 via Frontend Transport; Wed, 7 Jul 2021 17:27:14 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c69e947c-0156-4bbd-8c2f-08d9416c7653 X-MS-TrafficTypeDiagnostic: BYAPR10MB3285: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RA2ttV0HhVuQgWazZf40O1mK/zgWFxiEUhirtmIqWYaEAw0sYEpkDSajE4LNKFOtJVZktpo6DmH39ZwmiNfw/t6eLSHa2FsyTf+aKJNTXSLMMmZIfbemzdXxe8iF+iDvHum04fuxA40KQYoU4RB5D7zRcN2z0eHABx39H6iS3By8Tp8tVM61qaszENHT/zdp92snvatIDLS0GQnUs4qlesouYf8qnza6JmbFrfzGkUDdZtKi7M/iGFsXcplK/se6SGz5U2VlFGveotMWa+2vVTUEQO8Aslduh6p3n3FGCJYAkCPu/O+Qucv/gMUVzg8ncYBL+BF8kXG+w/LSl0fWkWA970QABLHymT9g901FfKnNNbpMxkfuLevlq1AJ/PKseYkYxuy1gAONmahbj7u0Fe/jNqMU8++q5Z1IMXzjsHNxM1ZEr0j/37H0ghNzWrQhH0I2cCcENolzzSE90lEEtU+yOsa0/rFbAOBu+/s0DLnZdL4ji9CNViCe+QV5wx1JFv/LJ/KXVOZC7SGVWIjWUVKhyqqIyoSV+qxD5Hp8GRd0xA0ahVWNuT7dyIrlUMkqL51sQmi+kZmT9scCdVb4aNu30BfMwcEXC+qngt4/fVk/gA0541/YLhKDvQPLvwgKeQN+lL8QqtDTYTbgZD9sok3cEPbvPBLeHO3Ogwt8Yz2XVqsMWl1nCNWDR9LiSycpLI9apD1rWTiBQsuEbcwUmQ== 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:(376002)(136003)(366004)(396003)(39860400002)(346002)(4326008)(8936002)(54906003)(7416002)(66946007)(38100700002)(38350700002)(107886003)(86362001)(7696005)(52116002)(66556008)(66476007)(2906002)(83380400001)(36756003)(6486002)(5660300002)(2616005)(316002)(26005)(8676002)(6916009)(186003)(956004)(6666004)(478600001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nduAvMUteXvaB1OdWIlUdNZtQq6v86ImJmWrBlw8HS6u0kaserE1NXX8rU89JVBsMdc/Qn6lZHPYmB1rRBa2u/yyFORcHU3cEn/F3oA1qYluNaD+SSIgOrSoIwye+xy0XANJgEl6otgCxIQRhUJpT9ZWKThLzmcS8a+aU/LVi2xS1kpacL76dZn8OheaNd9QKqkCqzAY2J8zY09AE8BU5VMDB6hfO1SSW2ai2sNhdmp+Ugx3dHjAQQ85cAbKVnyZySy+Z/ZKLN+LP3238a/XvkNQ9NWsVNxo79sadoyXD4U9zD8GT4HiLG9oTH2EypUgI9uUn+424guv0hDF6L8bddgMdwEf3cA5oRdEDSEKev/cOiL5lkKOEjr0pRsjFj8RIxphRBhM/zNiswDad3gkL/dBnQ/phHQVOfilqMtEm6kc66XsZsi2FdlqXL1/42UlZVdWjaFQTulkH7aIXM6xq7YCzHCIqjpKs3BYr8hey52DhAHUdIlVpIsSBjg9Cs545+CWXNv0ov62MLXXqf7A4KPUv0hEDY1ADuTQmHpYxSL0SGZoBAWYi8ielrjjAXsx3DU95l2wjkERwdWNsyMOBmYWBUMU8FShietxfUiV1i+5F9YI54yTVqKV7VS3H0jOvC43T7eu2EtZOTXFfxCTim45EhDzpdw60nCJEft+DGjlb6GvLSoZnCljDlN1x8Ftp/AWh9SnrYcWyRW/WntJt/ITHCt+g5Nv9gNxl53I3FP6SlBpsqlhW+GZUMXrPfDv5pVrvpG7qLF+sNyT4ZhG5QsDjhZGrQaqYt5SAuqYl26GeFoutf2EDhlJ0P9lh5Ds0APZt9XqE2/dqXtI/BgvEgRFNAxUs0jXBy7ZQg9J9onIg9rOcv5kqQ3VIi+Qx9tzpRLzAMtMnTFL2YZbsqAq60+gHJipJA4MElmah1UJDO9KCPTWR6uoawSxazcc68yHGCPh0v3Ux4ITA2eXrKKSJkwIzTNDZuoDTiTkSkg6wnMY0Yjx8wOYFNS89WWph/ZroyAgnc3gLLPXy6q7TZftAfw7TYdJqzWBQN73mUi18JR3/0wM8ji77/+jkVUJtg8xMG2GKMZIA9EAVcZYsVLPoqobFhTs1ZFk05sMzC11DskyhkvAKylkRfIjtRg/DKLv/eG0tVkd+po0ycmBUyPDZppR2YyT9XDNnVUu3WSsLl4UEWyts97bdPAuKbdWHAUX0QWy+ryItJfgbbld4xfbS2/dzIosdqpPjQ8hWttPYT3GilxQ0ireYcuk+9HCUD7ha1lkmHylOr5WWKy9gexXIvdTYfpL0txnMrEpa5xzekX1SarUWORpPC9EdP1Kqu5Y X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c69e947c-0156-4bbd-8c2f-08d9416c7653 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2021 17:27:14.9314 (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: B7SUrD4XZzbIoz9ClupUclHrE/FDqYC11l8taAlyMslAu3LbdaT+6Bjg3Yn1XEAkB8o+yEoeFBwABRUVaNZwa17comBeYhRdopYgqQuXahY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB3285 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10037 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 suspectscore=0 phishscore=0 mlxscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107070100 X-Proofpoint-ORIG-GUID: JYhqKQMNpAT90_TRT5ssaHIhmEwS7pI1 X-Proofpoint-GUID: JYhqKQMNpAT90_TRT5ssaHIhmEwS7pI1 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 , 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 cprsave restart mode, which preserves the guest VM across a restart of the qemu process. After cprsave, the caller passes qemu command-line arguments to cprexec, 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 cprload. To use the restart mode, qemu must be started with the memfd-alloc machine option. The memfd's are saved to the environment and kept open across exec, after which they are found from the environment 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 in a subsequent patch. Signed-off-by: Steve Sistare --- migration/cpr.c | 21 +++++++++++++++++++++ softmmu/physmem.c | 6 +++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/migration/cpr.c b/migration/cpr.c index c5bad8a..fb57dec 100644 --- a/migration/cpr.c +++ b/migration/cpr.c @@ -29,6 +29,7 @@ #include "sysemu/xen.h" #include "hw/vfio/vfio-common.h" #include "hw/virtio/vhost.h" +#include "qemu/env.h" QEMUFile *qf_file_open(const char *path, int flags, int mode, const char *name, Error **errp) @@ -108,6 +109,26 @@ done: return; } +static int preserve_fd(const char *name, const char *val, void *handle) +{ + qemu_clr_cloexec(atoi(val)); + return 0; +} + +void cprexec(strList *args, Error **errp) +{ + if (xen_enabled()) { + error_setg(errp, "xen does not support cprexec"); + return; + } + if (!runstate_check(RUN_STATE_SAVE_VM)) { + error_setg(errp, "runstate is not save-vm"); + return; + } + walkenv(FD_PREFIX, preserve_fd, 0); + qemu_system_exec_request(args); +} + void cprload(const char *file, Error **errp) { QEMUFile *f; diff --git a/softmmu/physmem.c b/softmmu/physmem.c index b149250..8a65ef7 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -65,6 +65,7 @@ #include "qemu/pmem.h" #include "qemu/memfd.h" +#include "qemu/env.h" #include "migration/vmstate.h" #include "qemu/range.h" @@ -1986,7 +1987,7 @@ static void ram_block_add(RAMBlock *new_block, Error **errp) } else { name = memory_region_name(new_block->mr); if (ms->memfd_alloc) { - int mfd = -1; /* placeholder until next patch */ + int mfd = getenv_fd(name); mr->align = QEMU_VMALLOC_ALIGN; if (mfd < 0) { mfd = qemu_memfd_create(name, maxlen + mr->align, @@ -1994,7 +1995,9 @@ static void ram_block_add(RAMBlock *new_block, Error **errp) if (mfd < 0) { return; } + setenv_fd(name, mfd); } + qemu_clr_cloexec(mfd); new_block->flags |= RAM_SHARED; addr = file_ram_alloc(new_block, maxlen, mfd, false, false, 0, errp); @@ -2246,6 +2249,7 @@ void qemu_ram_free(RAMBlock *block) } qemu_mutex_lock_ramlist(); + unsetenv_fd(memory_region_name(block->mr)); QLIST_REMOVE_RCU(block, next); ram_list.mru_block = NULL; /* Write list before version */ From patchwork Wed Jul 7 17:20:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12363115 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, 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 EDF79C07E95 for ; Wed, 7 Jul 2021 17:33:34 +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 68C9461CC0 for ; Wed, 7 Jul 2021 17:33:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 68C9461CC0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:56428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1BQT-0006cw-Fu for qemu-devel@archiver.kernel.org; Wed, 07 Jul 2021 13:33:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48056) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKX-0000Mv-41 for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:25 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:52620) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKT-0006kY-0a for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:24 -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 167HCNpL027395; Wed, 7 Jul 2021 17:27: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-2020-01-29; bh=Ql4BaF/gK2L7/cYlLylEl2VIg9AptK3OxZelqg16maQ=; b=xipHHSMwGUAiNq2Ifzwvq8CH2BsHT564qmH1PRFLy+GgInJbi24msrrWu8uo+0FNlFf6 IAhGp+deto9Cw5xyK597fUlgA7n+0LVAQiknGKi83h/uIPczQdOLwJVrqvbJ8zuW2XGY tkC97RDjl/R1j30GNqLyFO2AXyqOl9DlabX8CQBHpJ2T0u3vk8So1bDcK34kiUWdwarc NYwywUeFIuCyImdsSxLnWGEjek79H39hz57DBTf6rcwLzSDq2iBiVqM4Tl+J7m+6TD3G DBbmHokWDRAoPBIhB8DDIXA5Qsku5yVp4YC2TxgJ5QsddziF4Gj5Gn6sRO0SPoj5d40W 9g== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 39m2smmq72-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:18 +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 167HAKTD068866; Wed, 7 Jul 2021 17:27:18 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2048.outbound.protection.outlook.com [104.47.66.48]) by aserp3020.oracle.com with ESMTP id 39jfqayy1b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V33PLQRimgdgR9HxFj5xL0L1oBBtIGEcoJ6Anqjh2Epe/Vvkhc51nP+Ra9gQyNIjiMR4BZF5envwtUswnwYuL89oKkSkGqvWUs1ryj1ewf5BG1VTFOTVo48xcrqwC3k8EdVcLCSkQhljLBPInbbhDyMqueYdMayi8oHU+szrcDKFtAWXgv5Xq8XvZmUojtPmIPLDwOQvsuKH0VSIT4gmiBMVDS9Dr3wotGEQfo5alRQzRROksgT+opfJgZCSPPaZaG5kRJTi8VOriRom9fFKsAWi6EZU7TXewA9K1rVS+l6/5vhyZ/nypt6SGNXqMKhgqNmEviPfbXVR7IDnUKO6/Q== 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=Ql4BaF/gK2L7/cYlLylEl2VIg9AptK3OxZelqg16maQ=; b=OTEv/gnYsqY7I2OKhRWFBVD7LPtK7KP7j3gVpT2fYhnNTVu0gBoE9OOAtP5DDXr/SjqvLh12YvndUE+l36PJLByhNHKNLcblZnEDRuXdGKdi+T0bK0O3it63msgae5NXOC3zKakmNuhVcjUyxp4k1kkwN8bjxy2HyN8TqyuZjREZxraido0u5YAFuMpxrIy38TycxkQcQBEW/9Zwgzwdh0lCwlWKYysB3CrIRpT3OGBOewp37iIIdwAAiKAqBwPeJP5fRQy0kY6sTaMGLq74NHoOb+QBC8hnA4an21padGTua+xqcJJajH1HMXy3ES1rcy1ps8YQoo+gdQMEVGZWfA== 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=Ql4BaF/gK2L7/cYlLylEl2VIg9AptK3OxZelqg16maQ=; b=s7r5s4akNh+qeblo3FkSpRF0JkRfRXPgTSKX20PYTlyak27fU7o8BJCjPH35lVYhj7MYChJ+h9jfJDtR5aRDZj949AT4pxmFbCzLBPAgTTfz1If1qyaa2Q6mySNBdaHb8Qihyec6nn/2EEmnRy+rauGTPwayNCarc1AmonUEVD4= 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 BYAPR10MB4104.namprd10.prod.outlook.com (2603:10b6:a03:11b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.23; Wed, 7 Jul 2021 17:27:15 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba%7]) with mapi id 15.20.4287.033; Wed, 7 Jul 2021 17:27:15 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V5 12/25] cpr: QMP interfaces for restart Date: Wed, 7 Jul 2021 10:20:21 -0700 Message-Id: <1625678434-240960-13-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> References: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) 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.13) by SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21 via Frontend Transport; Wed, 7 Jul 2021 17:27:15 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a50d6463-fe2f-48f8-b9df-08d9416c76b0 X-MS-TrafficTypeDiagnostic: BYAPR10MB4104: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2150; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: d0hbcMmMGImudvYRMFU5aOtzAImGtkVa2sOq2Jiao8uBH7hFeNVxvYaVETs9kDPs6uA5uQZJykpi1Pc3KyWEfEm71HqvDkt+2RH8Oc3U1ByN2epxpOjbQ2YBkebtNbi/91a9DgRlP0p2BOPN8GqI34xt1aVsr9Sh4f7R/1JxV9jhm6iCfl+WVEvEyeImt3mR2aNCdqu9LNclGnuozxcQ9oSghliQLuh4kfz/HHuQt3rbac6EkoutqAm5C0qLoIo2wLhiXkjmjByH1PMqu/g8hRK3a2rtOECzRGCZ2NwwDav/uzFWdh5iOqr/8GQhija6IDPEKcPDAXIVYsFrEpkJevu0xFoXnoI2iXcDAauAOxo4gfZ+X57xzoaWHEPuxc42T1knE1Rrf8I4klvq/15Dl+TjwWlcUviAsm+evQztht0tCaWXPnQja/IVRI69sN6xIk9vpZsZ0HTC+OvyUwMDGqvjMoFf+MxCNSgB4WnOEfP+E+LZhROQfTupNGiWFoOGdl6aRdqpMVAEJ7p5p14lNselwh1haU/yLrv3XbbmLRt54Cj+FL4JvNfZdVF8DjQwcgHL5xKmT30vPpJ2TDzyJTmNPC/M7lShUvA4QfkAH3Uwef0v3usKYftiu6c5KymJVhIRjLs9iDP5/cMY4KM0YInE0vvu13gfzL+0bNTRXHC9DBnK8vNzo4M3YMy32plLLMsAeK5JfoUz6ePXFIRXoA== 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)(39860400002)(376002)(136003)(396003)(346002)(478600001)(36756003)(2906002)(2616005)(38100700002)(186003)(6486002)(66946007)(8676002)(7696005)(6916009)(956004)(8936002)(26005)(66556008)(7416002)(38350700002)(66476007)(5660300002)(52116002)(54906003)(4326008)(107886003)(86362001)(316002)(83380400001)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Og0g67iTIR+EQOCNnisBvdJD+3TvDyqcEik9VyTh0gPNqu9GfsJmlUwm09NsXJWC4YfFBS2ro0rvI5nB0e/wAlFajf9YjzUxs/HPgB8FJ468nD5i405IuyPGxaDTjaGtXnAHogUYEgZTKLuzSrKgWtkgBqrkFbHi2VqSlczmu3Od4a5pWKvehldDQzdWC/6DksypVWjWeqzZqcwTHNyhFpbtmZoX40ygeMtYQnfZnvvgktase3bdvoB4bNdBI/TrzfK8hpGjcPEeFkN+We51Sv7tNcXeyF2pqln8PgSU7GOrmswDxe09Vy93V8IyG22UXvXUya7jF5L+DVgwMuk4hX/Q6WDZ8Z79isTRR6OY1irlD38h4UkPwGJqaroblVA6ig9eDVZiEvkFvrkTlBTOIEmefuIYD2WuQOyM6dmML0/sNMbdgu2zvIqSF+bYaFnQgV47GIv0a03P2qCMwcGEJkaAaiQWdBBxh0LuYkymsRAsMyWxpIIrCAA7a/tANnW+w+NYMYc3TDBfExwqKfnHRVS6perUmiy/z+Shao25HNmG+UrGnxuZJ0aWMg15Ht/4oWxB+Hn07aU5cQffICEw9ZdliWiTgNE5n0BW9nr7+L9JiDDejJkn60UdwwTYTk875O7iT0nlRVnd/anVrdWho1eb1Y+7Vp0LYrfF7WnglE8QrAsKSYQORrlz2cD0ujXeSCc37g3pugS70+elO1bMT4sN817E/qhCFMJ7suZEvK/qCo6zVR5k5qUwLX5hwWT1gyLOHwJhotkmdCd5AsZL5ar287EOBnAaq27pR0VYF06Gm4negz4phKVp3hGRTOXvJSeRWVjWpyRsyCJbCjDyIEV612jV15Lo4H8sBG3BWxuLGvmQCPZ2rOvUvQmXXcpNI2Pd399RbCQeqfzsX2FHvrsPsBEfYUcGr0ZvXoIulyhF0rgXVh7C7vljQ0EFu9EbKZLMhyxh5on+SBDtONfjHksBM/Es3I9vIZWfhlofv4lfxllKU5ohkGujGhGtMGlJnCoS2a4MGNUFXsOE02iklxVLJOcs8J5zIZf73kT1NeDtHn4jzKP6Hw8mre+7Kr9dUk4BvmXlIzRMiRlgT8rqmbsrDyypPCVKogPaYHEkE9Wv3ywU5CujibPt46b5RPpc9VNpWttl68SAQgZaK3vQpAEP3UFTOl1HBxdRsbs5/U2DQASwkyi17Qt4KxswLVcbUcdBxyXJLByNtJ3ZY9/1eMatThgNTVAaN1qfMBlRVFvv8CXwGhFfu/khLDHCsN4cRjg6yCHe315bwjTAt/gapr11U3xkJ9Ox8cgRF0A4AgCdifCGdlDgUJHC1QkIQi2B X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a50d6463-fe2f-48f8-b9df-08d9416c76b0 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2021 17:27:15.4621 (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: FkBbvqDB067lb9/CbUIB9SacAKYFpr8zq0VIEDq9iuTyECP5YwKWLfmwrm/lg0D1NG6YGAh2GPgpg5m5FhyqeCa08P5gMQbAXW7N0+auE3M= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB4104 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10037 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 phishscore=0 mlxscore=0 bulkscore=0 malwarescore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107070100 X-Proofpoint-GUID: HGXKVT_jyeJZQvRaknTW1QWYCmQdozo- X-Proofpoint-ORIG-GUID: HGXKVT_jyeJZQvRaknTW1QWYCmQdozo- 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 , 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" cprexec calls cprexec(). Syntax: { 'command': 'cprexec', 'data': { 'argv': [ 'str' ] } } Add the restart mode: { 'enum': 'CprMode', 'data': [ 'reboot', 'restart' ] } Signed-off-by: Steve Sistare --- monitor/qmp-cmds.c | 5 +++++ qapi/cpr.json | 16 +++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index 1128604..7326f7d 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -179,6 +179,11 @@ void qmp_cprsave(const char *file, CprMode mode, Error **errp) cprsave(file, mode, errp); } +void qmp_cprexec(strList *args, Error **errp) +{ + cprexec(args, errp); +} + void qmp_cprload(const char *file, Error **errp) { cprload(file, errp); diff --git a/qapi/cpr.json b/qapi/cpr.json index b6fdc89..2467e48 100644 --- a/qapi/cpr.json +++ b/qapi/cpr.json @@ -16,10 +16,12 @@ # # @reboot: checkpoint can be cprload'ed after a host kexec reboot. # +# @restart: checkpoint can be cprload'ed after restarting qemu. +# # Since: 6.1 ## { 'enum': 'CprMode', - 'data': [ 'reboot' ] } + 'data': [ 'reboot', 'restart' ] } ## @@ -61,6 +63,18 @@ 'mode': 'CprMode' } } ## +# @cprexec: +# +# Restart qemu. +# +# @argv: arguments to exec +# +# Since: 6.1 +## +{ 'command': 'cprexec', + 'data': { 'argv': [ 'str' ] } } + +## # @cprload: # # Start virtual machine from checkpoint file that was created earlier using From patchwork Wed Jul 7 17:20:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12363093 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, 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 B23EFC07E95 for ; Wed, 7 Jul 2021 17:31: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 4067461C9A for ; Wed, 7 Jul 2021 17:31:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4067461C9A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:47530 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1BOe-0000ms-EG for qemu-devel@archiver.kernel.org; Wed, 07 Jul 2021 13:31:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48094) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKY-0000RE-DN for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:26 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:54156) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKU-0006lL-69 for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:26 -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 167HCNpM027395; Wed, 7 Jul 2021 17:27: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-2020-01-29; bh=BBeWnLRn9nNNpOjCplQJxzFvlhXSUah4N1iMBB359ns=; b=eECbLmCqBt/ZVTL3Z7hcAdOFK1/j/T7lJ+GdvzvdEnUriP4ijcQGLla4BNjg/iTkFwiD ScDfZu1L4vPZirV/grL6ZZaIWwrmmYatTQU3231XJw/IrSSlONXLyzmjAvUqj9lWDerJ wsQ2O1Onq8vmbGvpB0f4i/5ykhCnntqeLH1SNr4JYDyAXvPWmu4Dz4cgRFrLlYtlljK1 uC+v0Sm+Bn+naTMwEi2z5Kpwuk6gcyqt/aXc2MLDyKsqgLFXLO4pFPbdS/VLAyclEFyb si/JF6psPcB/1uH8fkOdDDyg08UpzDshhpDkv+19ANMbWlzLAJDISjQj2rD7U4tKk77A LA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 39m2smmq74-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:19 +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 167HAKTF068866; Wed, 7 Jul 2021 17:27:19 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2048.outbound.protection.outlook.com [104.47.66.48]) by aserp3020.oracle.com with ESMTP id 39jfqayy1b-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CyhsnV7cQgjw25kusADxx/ucFDwKm7WwyHU+BpN6ALMDqH+hiepaeeDYxHq2M8DZkMTpAIOnmr6RjOS6VwfhDwqCcl0Ma48dX9bCIxkCC0UfOSqkEr35M4MnZC+bwsPPLtsY42d/7s3OMR5JtvYvKXOdy473hM+HIiiOmDTvLy5gzJ1YkHJlkNDGg638ofAGFFuodpb1GxS4tcqrFn54w7HfoFaavLYl+rnFEaGDi4xyr7nBYWxLtOf0VT4z7IoUiR/Xt6fEoIvPDhEwR6hmFNjN9AEHFmRF3EuJ/IL1OKNyVN/3/O39Kfj69dV5i5IGKUeTBwQfOCLlauZlJ4Yw4w== 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=BBeWnLRn9nNNpOjCplQJxzFvlhXSUah4N1iMBB359ns=; b=lqXKgvJAkKoEZr7nxFKki1VlXkHC+cyGFM6n6EvKj30svL5bKMEhuUOGC+2GTj9/hb98ldvfqS7yAOmOrTxh4K6T+GQ46aXI/sQB7oP0rBAAsDfMsxIIGkVHZYqqB/uYq7yVHfkZ9mjrowiWNf9GeXM9kSvPVYqkmvkVM2Kxg6K1GKJR7eXwyL9hVSMJapfc388uPJzA7HNb2x8ByKlbAzsWNSzYUgcaiSVaMEXQJxTpG4UJ6NxiJMj87O9686dJDInRvtIeezshuuq3ujXtRH3xjVRfcXusK17ORCj8E5Ie5TTLj264EEL8QaPYFhg4Aw87nhBb5AvUrFVOHc19PA== 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=BBeWnLRn9nNNpOjCplQJxzFvlhXSUah4N1iMBB359ns=; b=rlFSiKYYQQYpk2xUNScEa2l2cbeXuXT792fSbNRlbt6lHORbLLg+B+W8aBXkZzDjSfBDJT4xLxZexREHScSRJsmy7J06V/uUNsiEqlSwEqB67bhY8Y0b4q5qKZIXkP9YPJ6719tpAoarA/J8HNb/yCk3/a8fSZNLy0UfeEQFr0o= 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 BYAPR10MB4104.namprd10.prod.outlook.com (2603:10b6:a03:11b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.23; Wed, 7 Jul 2021 17:27:16 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba%7]) with mapi id 15.20.4287.033; Wed, 7 Jul 2021 17:27:16 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V5 13/25] cpr: HMP interfaces for restart Date: Wed, 7 Jul 2021 10:20:22 -0700 Message-Id: <1625678434-240960-14-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> References: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) 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.13) by SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21 via Frontend Transport; Wed, 7 Jul 2021 17:27:15 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 77bea887-b7ff-4c5f-ca20-08d9416c7700 X-MS-TrafficTypeDiagnostic: BYAPR10MB4104: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:327; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bdYITMFtfbNqpyD7aR8XvcvTDcmAQvOXDuBxg/3s0bX77hiH9YiFGP66Ow0nUfjqysIdxBgcdVew6LSYFk7YQlfC/JpSTt14qFaBKbEwD24Bkatt73SU9JdLEk/zUy2IOYpnfwbvrQBIME97sWQvtgIwY7BDBK6h2DHjYIzt9/iCjyZiueJro8r9CsKOVNKLkLqdUeLBLA29Mm6QHZXDM+ngCacNsb7wr5864Ossk1pZ6WcbTNH3XI8Ro9ZguxSCto7JwLBiCUwcPlR8PBNlWQ3RW3O9vlcXkvbxjEYWAWKyref3L39eGYu8ru79aPEIrWauQ3SGZSxG4nQXKUYhOjDjvf5Oa736FYVuzjEfmgdVlYR4sKrdGEtLnqOHmkYaMU23an2afkDNV9k4DiVYFTENKSLLxKRNgOn2zzDl6yAYMQ9nOV+4E6coOJfliaAwtOwDEso5yMlyQCoEN03f8SeOqaPv0Mntypat5a1aGYlCq3FUvZSMuk0zTnx4csyiRYQGTpyZjc8jH7+QLNlY6d8Qu1tYXLbEz9WUzEYzDwatqErZ+/8M2c1XdVK2rXYrjm6Zfbw7jSG0Mmo5AcRLwFjuO0OMyjYkgZIGnnNN4B00lOW8hSveWj7uER8anwd0frL2XYiuTJXw8CupRzz58FZTP7+EJfmHmTIJrPyw1Y1bIndpbBJThoJx6OJ8ji/gvhBjs9IiUjsSv9fdiZNn6w== 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)(39860400002)(376002)(136003)(396003)(346002)(478600001)(36756003)(2906002)(2616005)(38100700002)(186003)(6486002)(66946007)(8676002)(7696005)(6916009)(956004)(8936002)(26005)(66556008)(7416002)(38350700002)(66476007)(5660300002)(52116002)(54906003)(4326008)(107886003)(86362001)(316002)(83380400001)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1W6gOfvgCunqjHUU8GuKNIvd3pL2RU+/IQ0KWtSzuDZtGEVhdoGOy7tKUx5V/yldVHd/A3sAnH3jB0mB6o1SELPyEfmWSJErFoOv94bX5fHo7KhOOn4DjRL9gqrOUf1HbcPIyLG5Zq8wS3Rim9b+MxCWgZxv1BPR5CpfnMrl6L2M+rrsNrOKRCMD8mVp9Z4Lh0rsgJ5IHKfVihhbrBXIFydyea0d5/rnezS9C4ivMqrNn1jfnzCTf9bYFmY7Hvuka4C/Ya1jwhk+/daBuc0doB3iDB6en82jqUu3Phm5zmT+Z230/v1NWnjarNXVapgCYyULEoOGB0ub3a3WiVAoQ4vMtB2CsJH9E2zSao2QPkyiPt2wn7Mt8OIqBFWgjeuy/wetysofGDq+j/SJAuwmvgviaJJ5RfxMDzRI4BMGVJGmlHSCrX5MFeQycU3aKEnHf2HHP7kmIaR91TftfRVdDJUrLef/Vd4U8X8OhGRC3tOP7agj9F30U1jLd2Viw5WwwgXUMYUr2asUqeVn+cl173ArSxhNXtObCNsp/hmsSyrGRyj1dMzyUi+RdSzhz0gQSqvhw1QuW3TWmZ24oOJ5J8abFj9DrmYbR4kfTcvARN7xH/DxRfWgYRm/9djZYr664WJEIwY8AwKQkePsqJo6NZ0PrFpI3QaSQNwqqnhWSmpzwEh92SSKWysRX+MXFFCKnlbC/f+iNMxYgtAJ1HNxLP4rKrTqZDkudpiJBRQI1+MqQebKJLuL9GonihIhbq2EFIU+iiB8aNOWWfre74GpYosT3zusji0ohC/YmQDxOb/uva7LtboUQxzDyt/m4lWcTKrZQN8EFZ0D89XejCWMgLbAbd9i/YScujIvVQJhzWhRTrsxjdSNnKJSszjFtL7Bdgj+ZYLkxzwboP45f5rJKDYu5pdX85bQZ67isxO1/M2aBVmVUCCV0GOL8QpCr6dDcy2XJTuGmJsmBwN8m+Fxf3t3qxiRCdMIM4l+dx8Y+haUZCfpSXyHZCGbg+t8O+5q5d/TmBf9fVwnpAwIRA3z6ONFdcXTjAUJmnuN4pWwcmvhrdL9qig3KCCYzXTUxLj35mPFpbx418EPab90SAYpKyBJz8caMtI1tQgLzKv8ABMOTPOr3GebnOmbK23YtWyLA4FvNFgi/Xaxc9TrIV+BaOwDjJsyl6HCq7GY+ET2QL12Wdq5UFsW94MO5vExqQReR9rhaz0C1t6/NsKbf82YHKr6D0nbDk1Jc274Osqst2zUtkMAC5IJx55ue0PCG8y5HY4Rs2WqcAoLh8xRudjQtBeKV71Jinf2enEQdYrhumdEPPO4n7B65SvBTyINE3zz X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 77bea887-b7ff-4c5f-ca20-08d9416c7700 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2021 17:27:16.0998 (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: h2CJ31efuyq2mtp+skzQefNkwkr3lr2DfY/gAc+O4sGjh7QtkqMf6OZZ9CS6GbzKNV/GWZu1mDbi+Q8G56NQOQIKkaZVY1DKv6JdhmJZ0dw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB4104 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10037 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 phishscore=0 mlxscore=0 bulkscore=0 malwarescore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107070100 X-Proofpoint-GUID: mCuuVS-UdjLW5Kn7_Lb1Ju6Fi42BkCTw X-Proofpoint-ORIG-GUID: mCuuVS-UdjLW5Kn7_Lb1Ju6Fi42BkCTw 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 , 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" cprsave mode may be "restart" cprexec Call cprexec(). Arguments: command : command line to execute, with space-separated arguments Signed-off-by: Steve Sistare --- hmp-commands.hx | 20 +++++++++++++++++++- include/monitor/hmp.h | 1 + monitor/hmp-cmds.c | 11 +++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index 11827ae..d956405 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -366,7 +366,7 @@ ERST { .name = "cprsave", .args_type = "file:s,mode:s", - .params = "file 'reboot'", + .params = "file 'restart'|'reboot'", .help = "create a checkpoint of the VM in file", .cmd = hmp_cprsave, }, @@ -379,6 +379,24 @@ If *mode* is 'reboot', the checkpoint remains valid after a host kexec reboot, and guest ram must be backed by persistant shared memory. To resume from the checkpoint, issue the quit command, reboot the system, and issue the cprload command. + +If *mode* is 'restart', the checkpoint remains valid after restarting qemu, +and guest ram must be allocated with the memfd-alloc machine option. To +resume from the checkpoint, issue the cprexec command to restart, and issue +the cprload command. +ERST + + { + .name = "cprexec", + .args_type = "command:S", + .params = "command", + .help = "Restart qemu by directly exec'ing command", + .cmd = hmp_cprexec, + }, + +SRST +``cprexec`` *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 98bb775..ffc5eb1 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -60,6 +60,7 @@ void hmp_savevm(Monitor *mon, const QDict *qdict); void hmp_delvm(Monitor *mon, const QDict *qdict); void hmp_cprinfo(Monitor *mon, const QDict *qdict); void hmp_cprsave(Monitor *mon, const QDict *qdict); +void hmp_cprexec(Monitor *mon, const QDict *qdict); void hmp_cprload(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 a56f83c..163564e 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -1217,6 +1217,17 @@ out: hmp_handle_error(mon, err); } +void hmp_cprexec(Monitor *mon, const QDict *qdict) +{ + Error *err = NULL; + const char *command = qdict_get_try_str(qdict, "command"); + strList *args = strList_from_string(command, ' '); + + qmp_cprexec(args, &err); + qapi_free_strList(args); + hmp_handle_error(mon, err); +} + void hmp_cprload(Monitor *mon, const QDict *qdict) { Error *err = NULL; From patchwork Wed Jul 7 17:20:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12363091 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, 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 0AE1AC07E95 for ; Wed, 7 Jul 2021 17:29:01 +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 6B15B61C9A for ; Wed, 7 Jul 2021 17:29:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6B15B61C9A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:39480 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1BM3-0003UU-GL for qemu-devel@archiver.kernel.org; Wed, 07 Jul 2021 13:28:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48140) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKa-0000VK-3B for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:28 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:30834) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKU-0006lS-Od for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:27 -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 167HCO7H011975; Wed, 7 Jul 2021 17:27: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-2020-01-29; bh=CXjA6O10ApJ3Orff5/HyR0N6EBqwAEKL00jhNWsaNZk=; b=AnClhxPpYyOiAYcJ1w6JzVNn0fTvNwCVNjCxkCBEuuRyHuRo8Fmcr3vMlXKVw51LyFYB BPYGJW1wNbnedAMGuESF+2QiFyfXpl2g+H58vXPr+lFhcUyU/1zMAUwHXCALWJxuiBSm JaQtv2WR2yhLTf5sRltxkDCPi774PDuOGhJuhHXfVLMdahjRRIMixLWjeg0K5pGj7gOk CA/Lr1lEf984tJ1WcU0gDCsLxKMQmMI1IOnnrTKK3kaHMp2bxH4XfUpzSxvkh7nfuAqS H2iX9HOLijYm53rRWhsmAk1/W2VWS1+J5wcpzeCpWtja+Glg1OFaD6IKw/dD2wDWszKT gg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 39nbsxrqn8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:20 +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 167HAVQk053006; Wed, 7 Jul 2021 17:27:18 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2108.outbound.protection.outlook.com [104.47.58.108]) by aserp3030.oracle.com with ESMTP id 39nbg2je13-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e5eV8Y4C6UNYVyClaeuAhpmb5Qv1C/xWNShMXvXxgU6g6THZK/PUaszWneLDdhO4P78bHnYn8gw69y4yJpcAIUe1Fm2f4VVHmsg/kYBiPLyUHMlf/JTWhKFEjt41tXw9Qxp9+6fe4Ak8Cffj+91rm/wyGgh0JwG+z61xSUQYUX01IDL/4n/VGbLn+Wassk+Lsz67yWN79vTCO096ZsC1k3e6XN7l8V/J1Q9fnJMMwjA+zgeXVFqT2PVr9O/tyUvyjDkXqEIAenpAd1u3T1Vk+EBsoS3wE7VjlFC5mmLEgiLp3GVqNlo8SKnnAQZZMcmQF6yY51HnRsO16h1ZvkuLiA== 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=CXjA6O10ApJ3Orff5/HyR0N6EBqwAEKL00jhNWsaNZk=; b=m02FqeiZbpaD43CWVwnE/Fd1m98jgOLGHNIVoSa/amaW5Vdu/dBV1CHmsBi6PCmH8TogYm8t88Xr0fABmu2w9XmxAyDb6htmRp86OF3WySYh7V3jzcioYw6jcPW1gF4m1kkvLHI7GjwTDURDEZeDUw8i5lKboosmQhceCeKSFxEMvp4f8DTzAmrFHxZKNQfuIKhE93eqrRGPHHH23FmbzlThjcHB1BCXaCxUzGNtbtdG/F19q2yVwQ6sGT08wBEImXsEVKDxqzhpySlZ58d/hScqNBbHQmg2Vu/Sn/gZMPs1i6Nd1OKXwBn1W/cXnz0aWoxgFKdN44pnD4JKKMNhnw== 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=CXjA6O10ApJ3Orff5/HyR0N6EBqwAEKL00jhNWsaNZk=; b=a2csfGkz7XUOYTD5j+TD+SBqqzlUaDT+xouNHhs4vk6QPb1CHOZSh7ZWTIFwQn6KjVfGb32fnPMMmk8pj7Ho3lrtf7MJYjiZAN464nXJMvZMApjUMUqA/GcfMa/upSOOmSAgqtbQ7FVNheJ/m6WsY+nyixrnU7i8xK8Y4/oWgkI= 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 BY5PR10MB4180.namprd10.prod.outlook.com (2603:10b6:a03:211::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.20; Wed, 7 Jul 2021 17:27:16 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba%7]) with mapi id 15.20.4287.033; Wed, 7 Jul 2021 17:27:16 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V5 14/25] pci: export functions for cpr Date: Wed, 7 Jul 2021 10:20:23 -0700 Message-Id: <1625678434-240960-15-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> References: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) 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.13) by SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21 via Frontend Transport; Wed, 7 Jul 2021 17:27:16 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ab13a15c-9817-4bd0-e68c-08d9416c775c X-MS-TrafficTypeDiagnostic: BY5PR10MB4180: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1013; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Vvn7nUo/mpQUMmCU4YzaOEzKdItSCfg7CjO3o5qBDeq2WHsOd/pgvN73jBsfI2AdmqNuQINi6yILFxc7Utp5hd2pSx4kPMcRDRAj8E/skPVaOqGRJKviL2YGrqJ6zNX8Lds9IuTXFfuc8epgrhc3N9sPDuADPFXss9JCl+pdCu6KV0+xAogDS8fyE8bQUfYsUhT+OmF/6BK2zODql8Flh0s2WJGOfH/DZ23SJlgIShjFetIE1hfdk79/xqOUfgzofbvmdOiTO3bNFxNOU1ZDhYF7d8PwMgiPy5wINHeYyqfFPiBA8JN4IEf+fi92aX0btU/7dZ7meesyZBgXqxU2Aakz/imspcAzPzrf4fHipz5mhz7eftVyq5Dpt82j9BPhEloDR7b1qPM/e35Br2pd5Pj+JJCs9RnDjbjcpRc2FrWsYSgAuyc18VIXRRwOgIBSDQ6GtnqhP4XW3qHVZjKRsdbSlXKqvmGeVhI4VyQTau/1FcKz3TCYxWAOtEcdz43Cdp/faoMaPG8BY1WH4q37ONBsLfQWNB+0/lp+Ts81kBhNBjmOzvHC9HHHoNXgjuvd/HlkpjwYhYZRtPtw/68gkJGIQRNMXUsNJ75yHvzAPz6HYIHeXLeU8QdRNqCBMdMAi9xbFHzcZX+YUcRHB+yg6P3+2t8DyKlswhMAUdWXaO2XzfeJIeGeerx4Wjj4jlbm9uPSgp3EhaumzOW8LODNrA== 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:(346002)(136003)(396003)(39860400002)(376002)(366004)(52116002)(7696005)(66556008)(2906002)(26005)(478600001)(83380400001)(316002)(107886003)(6486002)(8676002)(86362001)(956004)(2616005)(66476007)(38350700002)(38100700002)(4326008)(54906003)(6916009)(66946007)(8936002)(36756003)(5660300002)(6666004)(186003)(7416002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Z9EtdmEg6EBMW+ReHXPEMqj62E/XJqDbWReHpHAA2hEm/ITDbtlrQkUSj2qpeLUOckCf0jFqXYxDvHJoGWbKx3GIXqSwmyhE+sbJJRqux7QqAFN5ldGqinbHhiuCYipvdlPY5Ipgo6RUllT4WmD0+szQqpFlc9Nq1YnNV1ZxAxU+DJ20MHeRtkNpJDM5AwotPPdZRHDIjiXY/Dt2yNMZVPOJlAZS8Vom1LXDKK3tkWzYsXkX1kcAzSo/DelUexlpg/Vv4Gz60yNqe+2JwKR36Z49UB0NwuzKEuMuy+R1TPRuwawySnaY1Tx5mQHUKSxUXu054Lf5vw1Ltnc3h7E0nW4bD6IzsjAIqPupptQR39VN2smRRLYkVlwnPJXc/iqi9PH9pZilLN2RGuYUwqrVcQDS9cTohpH3l1XLjrqz0mHZsJqXnY8Qvt33O2/gxT0lz6dcSde3/mEQQDfmiqtLtyHA9ad3uryse2iLXY8f+FPRLks/lKr+0fIaMPX55b+OM6jJqn55qviPqZcTuF9RnXHXBqEJLsEV7aTbQrjdTHV7oNRmJvmLiMmkrr5NNWkKV44X/38wap3lwK8S6oePRe8EEBoZyuKblFmni+XImNLpsxoKjxjAHA+e5LoGToCef8iFgtlQ4Dd9U2rnzjLt3pAU4JvF05eIEh/SM4I9iU0lqUUlk9rd+CTYrMBY2SdliE+xJY3kEv6BopWSmUYyO9BV2YPbTBsiesbN8HQHX+OIN2G4+sSQxp2u2Y/VlLMNslkv9HtymEzb4Cn7/v894hmDk55wKR6YJU8nQQGpQ8IWNPPoWfxDFEt0qe4cq54mSeilNI30AYz3iaEsQHaZLR2fWqjI6o/8WbUz+nMGkvaP+9x8lNTNjdy1SUeZZcRRY+ORLmQRlZtf9YAmWrQVyQeWXBLUSGGMW8KSXWGWmJWgKpFElgdpNPiRnhXR4e5sM8cF72EcXOurZBFwXouFepDQjjFGyOeJT+YDk/9LboZrThyL3AkLv3r9mqPY5UFeqdGb09G3LHKy7VXHkaFipq06kbJScJIj21No/qVE4snTHnTM0hlZGMfY2ETLOejopC/sBC5v1EGRFW404Pm+rcJCMrHOiuHWopYlIIDSa19zBMht3G9/VX6Ct/v1BkvhyM7sCr3EAPDv8ROJ8RNF/3JUtqLKEMYxpvqh0H2B9+OKV7EIab1X3/k2/3iDIz1DiMnHWgyalRrzF6owgjcNGaIjNyikQd3UQHDG4ygm4YXVd4jK5rGxgcmw5HblXMch2OSBpshK2OkpU5jhGTTi8zABhGS8QaGbsKNE1ZVnBT2OW/RXgfxFB/djdNvlvOro X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ab13a15c-9817-4bd0-e68c-08d9416c775c X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2021 17:27:16.6015 (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: cpiiWXnr/+jOHk/WPx4+j8MiGgCY67zX6Xy52xB4c6DPIOsh25JcVZSidxhxFc/QUvis8jNyB90kHnsB24gemLC1UBfCE70NQFHPM6t6AYc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4180 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10037 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=999 phishscore=0 adultscore=0 suspectscore=0 spamscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107070100 X-Proofpoint-ORIG-GUID: 9kadqvVCIknq3GlvPYDDg5o3q7j5VLhe X-Proofpoint-GUID: 9kadqvVCIknq3GlvPYDDg5o3q7j5VLhe 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 , 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 377084f..2590898 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); @@ -1334,7 +1333,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 6be4e0c..bef3e49 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -902,5 +902,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 Wed Jul 7 17:20:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12363113 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, 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 D38CAC07E95 for ; Wed, 7 Jul 2021 17:33: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 315C061CC0 for ; Wed, 7 Jul 2021 17:33:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 315C061CC0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:56178 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1BQP-0006TH-DU for qemu-devel@archiver.kernel.org; Wed, 07 Jul 2021 13:33:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48160) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKa-0000XG-NW for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:28 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:33448) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKW-0006nx-KW for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27: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 167HCHnN010589; Wed, 7 Jul 2021 17:27: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-2020-01-29; bh=MzVpx/83Az0SaSqZ+XvT0Su9WlhJCCV1+yFN9rzVNmM=; b=QinJt182u89LFj+r93V7klmS+9EeevRr/YyVPcV0u4by4ENEhKbfJFZri4SYODYt+cVI e2mvh3bogxyKPX2/P3uzEJBopRZbaKGGmcku1dG/wxQ8f6/CkMAtdGAxhPJZOfjIo5RE ZvLItnrw3nJdhdgDddb9+I989Et/UfNb0qClXLfQw/eZhqcQITq43DO5EvNp6d7ofBrA GSOveJ9xrx4wMPUZuzxzqX5BuW3LPPN8iy4OjrkS85nsVG+TXw/jeqOOmQA3XEaN41e5 B2iuNTNrnuYoaKDJF9SRzrLEA8lxMqW8hwTy7EnbMf6KmizAS32wA3gNezVNDpwwHUl2 eg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 39m3mhcnh5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:21 +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 167HAY3w155372; Wed, 7 Jul 2021 17:27:20 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2046.outbound.protection.outlook.com [104.47.66.46]) by userp3020.oracle.com with ESMTP id 39k1nxjv80-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CnjA0ZlWQkqjXHGx55jmob/FK+Qczxvrcm1E6jgCzgEOCcCy5fOB2YcCv4LdLkQEIGMWfa4/zKbHVGSIN63oHSW7jg5dNUQsKVXw+yGmcztD/FePZGuUZrWRrLfnjWvYz0wfzw4LGKqs9qsFXWSOreIcx8m1ygFjba5j3XoYC+WkA99eJsehom+GZI7KvtFd0wfI0TyYG8wf2uz7EJHUsBRPx8bZ/olJO5DNjdU7oddoYdCa7lP2MPU7iJPt6RBTOJUGPuL7tQzaDGpICa5dSB6pxGkOIgfAMDQlhak0ogyBATdj7mwmfTIC2FfMShkytx6XGkBi31uHwzQj/c37LA== 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=MzVpx/83Az0SaSqZ+XvT0Su9WlhJCCV1+yFN9rzVNmM=; b=Nd9sjU30G4Fn8RKU+HGhnXRWk7mjXWl6DKRZ4RDoWMXkxkBEEw2QLzg7h1ulx/pDghrzP0Y+bLmzf0+zUrQ/Xn1/5crj1NUPXM3pyMKV5jJLnvYu3h+VAuxO1eji5G3uCqIkuYJUmOVWrE/YpD5uAIBdIW601lxsa0eSPlNrw5vjtRb852vjpLOwPSQ2rdD/9qeb2d6I3NhS8s8VuxrLmJW7LaGlZXncKNz3laYf3fsYsD4HIzfvkkcP7JLqpyWROfLX6mBvv3ra9r5rLCUfch4BDRYPsJGFWlgI0v7Spi/emF8ZjfRAuMqnwl/8arhO8EitunMAtrCf5aSSJxx5FQ== 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=MzVpx/83Az0SaSqZ+XvT0Su9WlhJCCV1+yFN9rzVNmM=; b=dfo2Yva8O5YGnSTdARGWTgsz1YqbymAxxEFWXbFOS2FHOUoYkCslwh8xuDpslHMb4Bp8Yz+JRZrUneyxArQKdyWT9Ja4iG4xN+NerNNnCkkYPitK9qAyiUpXxO4Z+a9ruA4aA3eUNIFQKHRl+hoFfnplRwIlM7QRdD/fGgbwXXE= 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 BYAPR10MB2534.namprd10.prod.outlook.com (2603:10b6:a02:b1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.29; Wed, 7 Jul 2021 17:27:17 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba%7]) with mapi id 15.20.4287.033; Wed, 7 Jul 2021 17:27:17 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V5 15/25] vfio-pci: refactor for cpr Date: Wed, 7 Jul 2021 10:20:24 -0700 Message-Id: <1625678434-240960-16-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> References: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) 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.13) by SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21 via Frontend Transport; Wed, 7 Jul 2021 17:27:16 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ce7749d7-8901-426c-0d24-08d9416c77a3 X-MS-TrafficTypeDiagnostic: BYAPR10MB2534: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:168; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4thP4HHTWYvLR5L4th4dP0WfqyZ/3lHRGJDJCKQDct7mKXvE5iq821JoB0d4ouh8OFrD2jrOqGMN1+mEpGmJUL/MRaj8amPqObdMXECLanqehuU3fASBlZDRf/vsu+ktQHslp4GstdWIZBYX1SWdklwPWi+R5TELPUxQP1kF+4w9+EvY5PYLmPni4w4A+6GxzQ04VlcG2gV23nooEOAHmQSKHHObP+9oHbE2AJCEkukiMWWD0z734gXl/2VSF99wa2QOPwqEE0uJGtluJ7lfhhFMKeAr5bZ/ex5lArR4tPhi64+yWKc6GMujBjugDDEvBza0QHSzBIFkG/ApbbWVdpK42TZ1iTLjEDWX0HEIyfLW063TS4Mi1tlm3R0wrMEDIcAEYinGCt/f2JKu5xvC69lQsWTI8txoT+PkBzo8UfNCbsXdPIes0d3flC9Fh2qzjgMuHYeQou0hbfajzDt/Mj45O2iZrq6hpVkIY41UkhHcR20NJ0Qa83/+R4cpkwrlg6p9jO04PXBKox+D/XThB5KE66qTZfLFZ1pBSDMryFwxRRecZ9qKTR4+lwQzSaDgGuUrS38/fZeetDVi4J3aPTMPWepuTOGNW0APw8pOnrenm44hJuSdoH5zONbdXWL89IgPxu4GDsgbLjS9CRJvaKlFpdfcIAXu0LEElRWcAQJsFqew1k3TP+NySa+E6dQCNEwvG6SmrG4fsktg0BPIAw== 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:(376002)(346002)(136003)(366004)(39860400002)(396003)(66556008)(4326008)(66946007)(186003)(36756003)(5660300002)(956004)(2616005)(38100700002)(83380400001)(38350700002)(8676002)(26005)(54906003)(6666004)(6916009)(66476007)(478600001)(7416002)(8936002)(86362001)(52116002)(2906002)(316002)(7696005)(6486002)(107886003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wcOElh8hKrElWE99DC7tQ5rmWDdhRwi7qdCxu3R6z89jQSfvaFXYyW0C6mEo42lS0UVDoBFA09WwmIzh6qeiKRqGmz8SmppjrGWk6IlUE9uVIYNskJFopKHveWzSBFBs5XtpScVNQdzmB3suf+M7Us/95pRTqKrvizTU+oQcp34rZ0ZR3pEgM+CzLlSuKckSPgci7s7Y4bEtGgyS1NFTGbFf/vSbg2WqUCtxhUfwESdqZjLPzOe9Q5g3f/Wi9yuax/VcfVVtq7DozGv1R9QQOOAe/Y8OkS7sLgdyuo/6Ly/RjycJGEIUFgcU7HmyhW6YeCHKPwQ6cPH+SXKx2kyy6xpTo0YWjzMNKYczRj3qyxPnkGFncMurHOQH7r/KpV9CE79XjvjncmWB68aCGCuj7+7Bw7vNPVfQf8/xEiLefik91A5GiSLF83gHXflkOWPmgBxkU5IBXWQswN9tKRKa0ZthrqwKpZMWLKNp89YOqEzZrV/uLX3OBppX9yFRz5abu3Eax/zDqwAUxcWgo7c86PRTqq6FbvSn8WwGB5ZklUMQwxUnq9lFuJ/LWNtrwEmGF/KcFVBsXY26uqWlTi2iHOBV2yqIN6PU58GYjCUSldDFMWMVxkhvPA0vF2gaDwhWLb49XoBqdIu/iLuCCljDT5YX+Aq6UfCu9kmfHNKfRkDhDoqFhAlS4LN4ItsgvQ7MYW4t3FdGRqmUdVJKBHcE5eGxSNKu6hwQGz6oT+H0LtMI6H0tgK7wY52oN8XkOEjdpFfflBSf4QDZpJa/q3nG+kVsRDM5MVz5A09HB+7r8yd6qOJj0T+meTL43Bn+ZTFLJK4kwQp/wDByRh7V3gfmU42hsJAg2NcX22t+gtaOXk+D4pMrssgZWFvvnyXfDT6EEAZv8jFFJFWNvTP+O4x7WGMDy9IPzlQr5SBlv30PDWwJGMRc8O6L0qby+pKWiiNWv1P5nVnYMQr6TsiyrwuPE2fvCIMlfT0PjDY4JS9a9A+Q/wouUWHCpgDL158IREseZoX3EjHSdqQTugRRft0XvhIi4kAz7LBXhwp2HxTcPwJeacQVxD68LcnIJ3Z8GmZ5MKvvYFIE9tlUAo49AEgmjDzScLnh1KsqtPD86bExDYWaZz4fbfbTa36UFD//1p4vrSyPKWSclaz9I9PzOkv4YDy8V/+aqE7+NqieMH3ORq7mOV/eb2fBsPC/E0aq/gNtr8GGRKUR49PTVW+J1JRuqQ+Xv2lOxYw9tgQ5gVc5vlwAJJzlz5GtM16ZEhmQobfGKc39qqoNs5ipoFUINk9dpmKJGuXYD0fM23dAAK2R09v5+5QX3hYpAk7hJ4TqXMkh X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ce7749d7-8901-426c-0d24-08d9416c77a3 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2021 17:27:17.0692 (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: 9X+IhQZql6Wx+ss0h37lEX+ToCyA3M+QMj4Har3ZgBRnm5DF7LkqtnTC/RlpXNwFaud/qkQ57V7IRB0EuEFJX7FPeAOmF+pDr6QUmm9HKAY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2534 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10037 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 phishscore=0 adultscore=0 suspectscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107070100 X-Proofpoint-GUID: uR-nZ_8-BO9iwzNzP3BiegPw1wz_-ROq X-Proofpoint-ORIG-GUID: uR-nZ_8-BO9iwzNzP3BiegPw1wz_-ROq 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 , 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 eventfd 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 | 41 ++++++++++++++++++++++++++++++----------- include/hw/vfio/vfio-common.h | 3 +++ 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index ae5654f..9220e64 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -42,7 +42,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 @@ -534,7 +534,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 ab4077a..9fc12bc 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -409,8 +409,19 @@ static int vfio_enable_vectors(VFIOPCIDevice *vdev, bool msix) return ret; } +/* Create new or reuse existing eventfd */ +static int vfio_event_notifier_init(EventNotifier *e, int eventfd) +{ + if (eventfd < 0) { + return event_notifier_init(e, 0); + } + + event_notifier_init_fd(e, eventfd); + return 0; +} + static void vfio_add_kvm_msi_virq(VFIOPCIDevice *vdev, VFIOMSIVector *vector, - int vector_n, bool msix) + int vector_n, bool msix, int eventfd) { int virq; @@ -418,7 +429,7 @@ static void vfio_add_kvm_msi_virq(VFIOPCIDevice *vdev, VFIOMSIVector *vector, return; } - if (event_notifier_init(&vector->kvm_interrupt, 0)) { + if (vfio_event_notifier_init(&vector->kvm_interrupt, eventfd)) { return; } @@ -454,6 +465,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, int nr, int eventfd) +{ + VFIOMSIVector *vector = &vdev->msi_vectors[nr]; + PCIDevice *pdev = &vdev->pdev; + + vector->vdev = vdev; + vector->virq = -1; + if (vfio_event_notifier_init(&vector->interrupt, eventfd)) { + 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 +491,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, nr, -1); } qemu_set_fd_handler(event_notifier_get_fd(&vector->interrupt), @@ -490,7 +509,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, nr, true, -1); } } @@ -640,7 +659,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, i, false, -1); } /* Set interrupt type prior to possible interrupts */ diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 6141162..00acb85 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -204,6 +204,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); @@ -222,6 +224,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 Wed Jul 7 17:20:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12363147 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,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 15C11C07E9E for ; Wed, 7 Jul 2021 17:48:32 +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 8B58961CC8 for ; Wed, 7 Jul 2021 17:48:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8B58961CC8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:38338 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1Bew-00073g-Q6 for qemu-devel@archiver.kernel.org; Wed, 07 Jul 2021 13:48:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48208) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKe-0000jo-Gz for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:32 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:35382) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKY-0006ov-3f for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:32 -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 167HCGFZ010580; Wed, 7 Jul 2021 17:27:23 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-2020-01-29; bh=EEU7dUFfkr+7Au3UAHKsAJRejRc3ySaSgQfMcMrHxLk=; b=hSTFN7vI8EMZJOom6GUvMDzQaDF5+LWCJK/FvXPTgZO9Sk+YwckfNhL6aGIeh6985xDs 4/xUgPl1nwOga4Ty+sg8rBzZR5RrcH5Woi/d0TRYZ1pt8AjVdDY7z4xjgJUmDed7H/Dv sNheOk1Z/9BGS1aGnQP+qwlfzw5IA8DV9srNC6zMPsmGaOtNctIz0B6g7c7gJ1vM9jV+ uwqCZ4swMLyCN8kraZ0lgtlFhzenNaUZRSCB1nSh90bcSCa6rq7A/RVRJe/jT0zHCC5e Pixbg0n6sTg/axOhzVIkBaZz1O5YPeSp+CHJDb78fvBJ++WbA420eRmJeka3zsw4NYGh Vg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 39m3mhcnh6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:22 +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 167HAY3x155372; Wed, 7 Jul 2021 17:27:21 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2046.outbound.protection.outlook.com [104.47.66.46]) by userp3020.oracle.com with ESMTP id 39k1nxjv80-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TY+QetXSEXRljPVY4C6kjGQqHBXai9ws/qfymrhiVNV1iF3RxjEvanLdj1P5ZilTg35s+O3soxCuM3rva4kUas1Ym63YUT7QJLU6UUGCKDa2ObJI6jteplTFN7VE/uzfvIT5dog/WXXd4kAteQMWVbzvNVAX8hmFsfMg6cPbU/S/iYGOTTuqw9eIyYbLMP040twrNGcH2WBBxWMA5L/Mcg1gRz5qdwB/TKnyhd/Yx0Gb6EGtYSr53alHNobg2SvunijaE/TBViUAniLeUrrXCmFTIzwjWfe0/1sjpFINus1ovSS5Ye2Ke0hueXt4+dS2oRhsP+DL3cA1C+w39np2Pw== 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=EEU7dUFfkr+7Au3UAHKsAJRejRc3ySaSgQfMcMrHxLk=; b=lZLsu0vKuVB461k5t11999X67663a821CM6p+8jgBH4z2MO66fCMwdJwx8N652v6AaC5TQT7zNQvRk6pkvkGyoI6mhQtiCVc9arr4H709myE5ZRrW548Z2k3xBL9GjE+Q0uL/iDueMsKx16rOvKzKmcwKKehM2O7FmRb+mAZDOppHEuJ/3NHa964b7I2fptuhXPCKTCwweg1X2oDS40IQxkLD/0bnm0qX1IQhLfgfuCZhqU6943OX4XT7Rro4jOzm7EILBglM45r6rP7clWiCGvvDCMnxMX9Isjwxh7yhx5QrpCANcKMnKns7f8xB2ggoX1ccWl5zjsS+CvpEACwkg== 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=EEU7dUFfkr+7Au3UAHKsAJRejRc3ySaSgQfMcMrHxLk=; b=GxAu4h+uoKHwXWanm4x+yl2Vu59O2gcSYGwF7LS5VqiWbKWSYuVrSeh+xO/DjYG4HqEr9e1kQtRqIMxTQCuYEHg6MTcJv2dnW2WcaJWZwChaaSDbLYiLSB4Gyw0ZVeQ+VowGh8WtYlJ/t5UwHIPDIg8sXVpkDtR6LZHrqoZGbwQ= 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 BYAPR10MB2534.namprd10.prod.outlook.com (2603:10b6:a02:b1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.29; Wed, 7 Jul 2021 17:27:17 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba%7]) with mapi id 15.20.4287.033; Wed, 7 Jul 2021 17:27:17 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V5 16/25] vfio-pci: cpr part 1 Date: Wed, 7 Jul 2021 10:20:25 -0700 Message-Id: <1625678434-240960-17-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> References: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) 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.13) by SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21 via Frontend Transport; Wed, 7 Jul 2021 17:27:17 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 07a82204-39ed-4a8d-7cc3-08d9416c77f4 X-MS-TrafficTypeDiagnostic: BYAPR10MB2534: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:513; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CiR3Fz22nxxTDQjrRih/EFgRlYF7GZYqjwCyfYU/lnspwFF2aUWtN+BmQTMs/GGWXywuGvW2e0R0I9i4gaBkIAIp4qSrE82LYXy/ORutzXAeGcyrxa27tO1/A2GhfMBNDeUO6r1eEvKM+S1kbl7SpLznAy44vdOwekxhtBb09IfcI1lao6d/gpqPn1mkiHYlSVCZ4LYQ/1HrkdnT6f6aLvh+nVzw5e5CBX04VhCko8yVVbk+FPDdM4cC5BDzLjL1LlREMbXa6RKuCDotsrAtmw2zHVjhD1OkzhqEo4LxSqXt4IQS6vnhcgXGtCTv94i3lvxbNh/vEoLow1zMkshOj2gtEy0+ahOXV4fL6qLUlH1LgYI9ykW3ehjlA0nwc3QB6b8KK+GVI9zxZemo9Str1ylkgnPtHM7Kbg9k6NfCasqFeZXeWoK9ucSHVJdoMzusVgLmHKNYqYVpnosf0cV5QQyPJHOV1bcRGT079APX/OwpuIODnqEJnoW+G049+AWoHmwEg4WSEtFx0oXqrlcBsYZeBlAlHfHUioLSsalLT1n8sOrZOSiVzJhGYnVdrmdXvGXjJIIqusiO565wkgL6WdPhQRKJz2bZnBJXrf+KCD+kdmOpIpAIuPe1xl3Mtwjd8m4RQN12G6yBeqGjqdfl++lmUbi0g/uZYk2jZQKrZwDZP8yU3nEL3AvN3V7A76YIq8KiJbTpyfm8nn8RgPBAWg== 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:(376002)(346002)(136003)(366004)(39860400002)(396003)(66556008)(4326008)(66946007)(186003)(36756003)(5660300002)(956004)(2616005)(38100700002)(83380400001)(38350700002)(8676002)(26005)(54906003)(6666004)(6916009)(66476007)(478600001)(7416002)(8936002)(86362001)(52116002)(2906002)(316002)(7696005)(30864003)(6486002)(107886003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rmTrC0XevvBtgJRqiUeSFSg0SgixpajipuGAr2SdmDNMi1cPc/YuNpwA8TJZo99QOIaIqJj5Tzqa8tAF00CMjV8OkpCtwAk7Eqkv9gvVCBkTJ9FzqWeyW168DAcWdIvexcyqdTCY1YAL1YY6A64+64aUuU1SvoMESBEyxUDKbUtdhPQQ+hSjKgkfRZIUJv9dx5x7fW/CmR4fj7wcjSTBfSLxJf7XtPVnB4bLoR5XV2iu3XBEGNbjU5Tq5prQvL99qr3RS9Oyw7xHbvYWhSfWeD6invrjYif0ZkHVc0aPruv0qB5DZTfPnnXlN8k56erWuu9+YVia0fIwhCBgTH/uefLh37bLAbYGHrFaHGlEIn+f6fp9Ph2sw6chZDwk+XHSaz3JP8FIwQn5W/AMO7I2nmsUgnbMiQzsT1oki4Oq0f7LC/2iz8f9/PFOJQJZSrtsTWXVu6/Ur7d7g2g9hqKsWE9JQ+FDRUBCsoL+WvV8yA01+yChAIL+ZcJ1pZHTsB7vCtS8VZ2av6269oHitwleRh+aY4Ap0IhdYmpopTtjV2mIHziisrxHy+w+1+bbtcp8Ic+u/F4c6imxOw38Wr2RIt5hm2gMaB2lKKUTMEgpnjkvJAEce2vpo23orB3G/qn222YOsKRbfNm/r4CzbxvOswLT7PFfTM5ah0Azca540O95qhUEdfNe2Qxn2y0jY0AwFnlxzJZxvt+aEygsKuu/8rEU780awv3dFj6k7ndaxHOslCSJsMyNweGg44oQ5DIULLM2iCpqjCJQar4MmcLkbkJvf1qDDCCgGyR/QG3VEFwNRoa08I7P/yynYTlgnj50cyQVUyMznZ7RBXAmbOmc31xlZTM7zdrjecMInNpIXMV28rLSp0+pEw6ius0yVbImUNn4I7qOCzcmpeBZELzIvvSa/f0phbUFwiM2k1onRv4wbltWxowi9JukMLadHsDmkuduHoODHhMg2frgwbuBYk4bdAVtui20Dkm1MGP8pRlVP+qK3TGXSQAiGj7ccBIheXbvFtI7mgPHErRLi2LUhAL2hRLuU9/qauThy+XON/fasafjauw/RXB5VV6D9IZqg52p4sZPc3yzZVbJ7/vj8JYEu11znddOW+ZWcOYM8s66qNx8nxDTjTrvWqVtvDMS6fIlP2GcGxZ5xYb4YcSLBXEsni6h8apbeRD25Iq7t47ET1bmj0GfqkGkROc7haADMG05nUhsysfPWYjYCMeSIEWHrnFDC/CvNnhMAjzR71xfGSk9W0QNx3HiZf2Oe/w236J6zc28V3eFE6tpbeV3kMNlAtjRUqjvgYU1rqVjy9YSLfU126CRTV49wJFGyaUa X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 07a82204-39ed-4a8d-7cc3-08d9416c77f4 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2021 17:27:17.6799 (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: WUaUltToIbQ8ciq+Q9nD+npbJ1QjK3x0DMOXyt4q1qFc5cgHDq9FsEwQdkVlfVHBlBKkKG0JduksVgmdYWelAV/AugZKMMFWX3re4HLo7h8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2534 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10037 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 phishscore=0 adultscore=0 suspectscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107070100 X-Proofpoint-GUID: d5QbTqZPdcT7Qwc8OyD_UMWhTo9oIram X-Proofpoint-ORIG-GUID: d5QbTqZPdcT7Qwc8OyD_UMWhTo9oIram 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 , 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 the environment. In cprsave and cprexec, 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 the environment, 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 cprload is called. cprload loads the msi data and finds eventfds in the environment. It rebuilds vector data structures and attaches the interrupts to the new KVM instance. cprload 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 2 patches for clarity. Part 2 adds eventfd and vector support. Signed-off-by: Steve Sistare --- MAINTAINERS | 1 + hw/pci/pci.c | 4 ++ hw/vfio/common.c | 69 +++++++++++++++++-- hw/vfio/cpr.c | 154 ++++++++++++++++++++++++++++++++++++++++++ hw/vfio/meson.build | 1 + hw/vfio/pci.c | 66 +++++++++++++++++- 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 | 20 ++++++ 12 files changed, 323 insertions(+), 8 deletions(-) create mode 100644 hw/vfio/cpr.c diff --git a/MAINTAINERS b/MAINTAINERS index 8647a97..58479db 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2862,6 +2862,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 2590898..fa4a439 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 9220e64..40c882f 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 "qemu/env.h" #include "qemu/error-report.h" #include "qemu/main-loop.h" #include "qemu/range.h" @@ -440,6 +441,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 @@ -463,6 +468,11 @@ static int vfio_dma_unmap(VFIOContainer *container, return -errno; } + if (unmap.size != size) { + warn_report("VFIO_UNMAP_DMA(0x%lx, 0x%lx) only unmaps 0x%llx", + iova, size, unmap.size); + } + return 0; } @@ -477,6 +487,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; } @@ -1603,6 +1617,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) { @@ -1703,6 +1721,8 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as, { VFIOContainer *container; int ret, fd; + bool reused; + char name[40]; VFIOAddressSpace *space; space = vfio_get_address_space(as); @@ -1739,16 +1759,31 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as, return ret; } + snprintf(name, sizeof(name), "vfio_container_for_group_%d", group->groupid); + fd = getenv_fd(name); + reused = (fd >= 0); + QLIST_FOREACH(container, &space->containers, next) { - if (!ioctl(group->fd, VFIO_GROUP_SET_CONTAINER, &container->fd)) { - group->container = container; - QLIST_INSERT_HEAD(&container->group_list, group, container_next); + if (container->fd == fd || + !ioctl(group->fd, VFIO_GROUP_SET_CONTAINER, &container->fd)) { + 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; + setenv_fd(name, 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; @@ -1766,6 +1801,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; QLIST_INIT(&container->giommu_list); @@ -1893,6 +1929,7 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as, } container->initialized = true; + setenv_fd(name, fd); return 0; listener_release_exit: @@ -1920,6 +1957,7 @@ static void vfio_disconnect_container(VFIOGroup *group) QLIST_REMOVE(group, container_next); group->container = NULL; + unsetenv_fdv("vfio_container_for_group_%d", group->groupid); /* * Explicitly release the listener first before unset container, @@ -1978,7 +2016,12 @@ 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 = getenv_fd(path); + if (group->fd < 0) { + 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; @@ -2012,6 +2055,8 @@ VFIOGroup *vfio_get_group(int groupid, AddressSpace *as, Error **errp) QLIST_INSERT_HEAD(&vfio_group_list, group, next); + setenv_fd(path, group->fd); + return group; close_fd_exit: @@ -2036,6 +2081,7 @@ void vfio_put_group(VFIOGroup *group) vfio_disconnect_container(group); QLIST_REMOVE(group, next); trace_vfio_put_group(group->fd); + unsetenv_fdv("/dev/vfio/%d", group->groupid); close(group->fd); g_free(group); @@ -2049,8 +2095,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 = getenv_fd(name); + 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); @@ -2095,6 +2147,8 @@ 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; + setenv_fd(name, fd); trace_vfio_get_device(name, dev_info.flags, dev_info.num_regions, dev_info.num_irqs); @@ -2111,6 +2165,7 @@ void vfio_put_base_device(VFIODevice *vbasedev) QLIST_REMOVE(vbasedev, next); vbasedev->group = NULL; trace_vfio_put_base_device(vbasedev->fd); + unsetenv_fd(vbasedev->name); close(vbasedev->fd); } diff --git a/hw/vfio/cpr.c b/hw/vfio/cpr.c new file mode 100644 index 0000000..28f8a76 --- /dev/null +++ b/hw/vfio/cpr.c @@ -0,0 +1,154 @@ +/* + * 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 = TARGET_PAGE_ALIGN(offset); + roundup = iova - offset; + size = (size - roundup) & TARGET_PAGE_MASK; + 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_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_cprsave(Error **errp) +{ + VFIOAddressSpace *space, *last_space; + VFIOContainer *container, *last_container; + + QLIST_FOREACH(space, &vfio_address_spaces, list) { + QLIST_FOREACH(container, &space->containers, next) { + if (!vfio_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 (as_flat_walk(space->as, vfio_region_remap, container, &err)) { + error_prepend(errp, "%s", error_get_pretty(err)); + error_free(err); + } + } + } + return 1; +} + +int vfio_cprload(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_cpr_capable(container, errp)) { + return 1; + } + container->reused = false; + if (as_flat_walk(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 9fc12bc..0f5c542 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -29,6 +29,8 @@ #include "hw/qdev-properties.h" #include "hw/qdev-properties-system.h" #include "migration/vmstate.h" +#include "migration/cpr.h" +#include "qemu/env.h" #include "qemu/error-report.h" #include "qemu/main-loop.h" #include "qemu/module.h" @@ -1656,6 +1658,7 @@ static void vfio_bars_prepare(VFIOPCIDevice *vdev) static void vfio_bar_register(VFIOPCIDevice *vdev, int nr) { VFIOBAR *bar = &vdev->bars[nr]; + PCIDevice *pdev = &vdev->pdev; char *name; if (!bar->size) { @@ -1676,7 +1679,7 @@ static void vfio_bar_register(VFIOPCIDevice *vdev, int nr) } } - pci_register_bar(&vdev->pdev, nr, bar->type, bar->mr); + pci_register_bar(pdev, nr, bar->type, bar->mr); } static void vfio_bars_register(VFIOPCIDevice *vdev) @@ -2888,6 +2891,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) { @@ -3157,6 +3161,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); @@ -3264,6 +3272,61 @@ 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); + 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); + } + + g_free(phys_config); +} + +static int vfio_pci_post_load(void *opaque, int version_id) +{ + VFIOPCIDevice *vdev = opaque; + PCIDevice *pdev = &vdev->pdev; + bool enabled; + + vfio_merge_config(vdev); + + pdev->reused = false; + enabled = pci_get_word(pdev->config + PCI_COMMAND) & PCI_COMMAND_MASTER; + memory_region_set_enabled(&pdev->bus_master_enable_region, enabled); + + 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); @@ -3271,6 +3334,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 bef3e49..add7f46 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 00acb85..b46d850 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; @@ -124,6 +125,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; @@ -200,6 +202,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_cprsave(Error **errp); +int vfio_cprload(Error **errp); +bool vfio_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 bffee19..1ea5046 100644 --- a/include/migration/cpr.h +++ b/include/migration/cpr.h @@ -10,6 +10,9 @@ #include "qapi/qapi-types-cpr.h" +#define CPR_MODE_NONE ((CprMode)(-1)) + +CprMode cpr_mode(void); void cprsave(const char *file, CprMode mode, Error **errp); void cprexec(strList *args, Error **errp); void cprload(const char *file, Error **errp); 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 fb57dec..578466c 100644 --- a/migration/cpr.c +++ b/migration/cpr.c @@ -31,6 +31,13 @@ #include "hw/virtio/vhost.h" #include "qemu/env.h" +static CprMode cpr_active_mode = CPR_MODE_NONE; + +CprMode cpr_mode(void) +{ + return cpr_active_mode; +} + QEMUFile *qf_file_open(const char *path, int flags, int mode, const char *name, Error **errp) { @@ -92,6 +99,7 @@ void cprsave(const char *file, CprMode mode, Error **errp) } vm_stop(RUN_STATE_SAVE_VM); + cpr_active_mode = mode; ret = qemu_save_device_state(f); qemu_fclose(f); if (ret < 0) { @@ -105,6 +113,7 @@ err: if (saved_vm_running) { vm_start(); } + cpr_active_mode = CPR_MODE_NONE; done: return; } @@ -125,6 +134,13 @@ void cprexec(strList *args, Error **errp) error_setg(errp, "runstate is not save-vm"); return; } + if (cpr_active_mode != CPR_MODE_RESTART) { + error_setg(errp, "cprexec requires cprsave with restart mode"); + return; + } + if (vfio_cprsave(errp)) { + return; + } walkenv(FD_PREFIX, preserve_fd, 0); qemu_system_exec_request(args); } @@ -158,6 +174,10 @@ void cprload(const char *file, Error **errp) return; } + if (vfio_cprload(errp)) { + return; + } + state = global_state_get_runstate(); if (state == RUN_STATE_RUNNING) { vm_start(); From patchwork Wed Jul 7 17:20:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12363137 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, 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 883FAC07E95 for ; Wed, 7 Jul 2021 17:42:52 +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 054B361CC8 for ; Wed, 7 Jul 2021 17:42:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 054B361CC8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:54258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1BZT-00079q-4m for qemu-devel@archiver.kernel.org; Wed, 07 Jul 2021 13:42:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48128) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKZ-0000UA-KA for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:27 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:32370) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKV-0006ml-RP for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:27 -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 167HCO0s010640; Wed, 7 Jul 2021 17:27:21 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-2020-01-29; bh=UqXU2DX7ZZK0VdAu810lCJdH99d6CGCunQKp3koZf50=; b=u5KcFkML2JjhAbxzWAt8jqmTCLFufQr2vlaCCv8oTTm+eyJcDBPtgLzx4wbcWfD+37QC yNFCbZcfG+8S3IADrVl+Q/UkDRq3oz4F2ZDCmcFYBflsdBPA6BqcQUXZeTU4bSXhex2N fPSQkXHU2icZR8OLttv8WvgxS4Iu6pi5Mx+zDZM78QyHR0xi2OVAdercT1ZLfLdplcKF jAQAwRoqOHSGjEnNVVJMYlY2s7hgUc6Vs5TxWzaKhp/EKbdcyeU6ciocqcFFwPemVPAl tpEQLz6KkhxTSIs4dpXQO8UihB6k5n8J0weGKIcuib/c4RXXSq9m4pp2Hp5tvtb3mqkP rg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 39m3mhcnh4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:21 +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 167HAVQl053006; Wed, 7 Jul 2021 17:27:19 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2108.outbound.protection.outlook.com [104.47.58.108]) by aserp3030.oracle.com with ESMTP id 39nbg2je13-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M/KQGpBpMa4h832ZJ90NfimwkPSquSs4mJV25SYnO6+apCODlsFOdZphRLAVw+VtH5Kz3zFEiMVKabLwJYUmgMXKj6Rt75B57b2AjENc4OK0hVwaL4Bq+MZzrA0ra2/7OTpo027zp7iAC9C6QVSs0NpNiqIFxi94MxcOMkrJIFM1fOd8q5ekHm3qu5cbiOnL3A0s4Q+z2xJtW8QBDlgHrost6Fo+R6g3duV9zr1POkAhQx2xIEksL9ZliCbhZmjTodpJY1HtuDv1STA7ZlwsaKhwXvQ21E7kry2pfIVU/dhMnGtJItTn7aa4HArZmL112LuusxwYaBibh59CPel/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=UqXU2DX7ZZK0VdAu810lCJdH99d6CGCunQKp3koZf50=; b=EyWv0rh+/VEIsSlrj49pFjEa1g+Hpb+tVukb6yBPtlu8bMWb0Ucr9wsnv160O2pKjeVK3/RXMd9uRFTmkcfzyr8dJKJuY0XF5pEBDJs1bxF4MfUH29cnvmzUPTqZr2yixdqAC3iAl6WcpS/XiUx9cxQuZjXxZlbL79pOGB4Mm/cfEntyWweCmYVOY6ShsXdrh79amsnd0iYnUCOCiYKdfF4a3HWPhw4HXx++9SG8kTnjxM1Y13Y5P8BkhSNf4Byv/1p93w2piNUwLif0TVsPFEkcoBNakPE7fbCZwNRwTBL9oqOzyNzm+t9VAP4P1306xBMwQvAxgm0eyh+uXhZnBw== 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=UqXU2DX7ZZK0VdAu810lCJdH99d6CGCunQKp3koZf50=; b=l68TmdD7+pyRemk5awsBU2Vk0YRxUjif/WTOdznoF1zq+ao2fG8mMa/BUl2N6kLPjxZrxjXHhi33KK29KIa647QYq4+IqJ4RCXL50juiHVCV9Z0vagYlUTX+aHD4741iNMrAdSQEqw9edLxZ6zWGerZO3bwOlD59IXN8HrBhccE= 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 BY5PR10MB4180.namprd10.prod.outlook.com (2603:10b6:a03:211::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.20; Wed, 7 Jul 2021 17:27:18 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba%7]) with mapi id 15.20.4287.033; Wed, 7 Jul 2021 17:27:18 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V5 17/25] vfio-pci: cpr part 2 Date: Wed, 7 Jul 2021 10:20:26 -0700 Message-Id: <1625678434-240960-18-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> References: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) 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.13) by SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21 via Frontend Transport; Wed, 7 Jul 2021 17:27:17 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 562cdac6-2e2a-4f3b-cd0a-08d9416c7853 X-MS-TrafficTypeDiagnostic: BY5PR10MB4180: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:147; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aG3dTa3O/ebymIMlA3DKtQWUrQQOBYNHE6MdRSxG8+CNxWaLDWJ/femsqbZ7F7ZRewm72m/4Tp8TBjl3QW/SlYzySsaaxGZ64OKlbvoGYi6SC23U2RVNvJu3fXS5P2uVq3Dtlla9zI+rIfSQEznzI7byHU3OYJzTyiizuAEOYXH9F3Egt+TktYy5npoe6WeVKHWej142P+LjK1cjSGbwkX3+eIOOqF0BSpW/4LhXgP8v9GvogwacRw9ijdWohbXA0D2LqEhZ8AUmKL35H4+vLiAUjVTICqcRAC65HbZsTGZh14NvparwTLcuGBdtc2XOew7NghhcLozMV/BJJBcdno3KXv4Lwe67HNT/TJOK83InINNwQ7omWEPbgu76BEj3AQcHsCswk9Rul/wgcCBTTwWIH5WJfSrpFDNaxJ/1ZhCs+nFgsog8PMNOLwBOLSJ0PhQrUv+T/26qsaXqKbbwoUSCdG24HUr7T8PUPhVCccQHLebJx6gGY7B2Cxde1VdNwkHT1Qqz9JTNKhRi4bsL+JeeoL/1t50EnMTu0z6WqAPaerm/rw56pLniYt5Ds9zLW+oU7cz0CNkx53br1gWPILMRwxKL3oKciozDOTmpmYX35ItWQoM7nlAtdHAX9clWwFR8rHxoFanKTsoMcJHkAJMr/mdvyB8WBvqyV0Uwj3LxRZt6XqKqY2HCbzALSq1jthQThCPlZ25/gnqBCBQRGA== 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:(346002)(136003)(396003)(39860400002)(376002)(366004)(52116002)(7696005)(66556008)(2906002)(26005)(478600001)(83380400001)(316002)(107886003)(6486002)(8676002)(86362001)(956004)(2616005)(66476007)(38350700002)(38100700002)(4326008)(54906003)(6916009)(66946007)(8936002)(36756003)(5660300002)(6666004)(186003)(7416002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: G1Gr9ivYawPA6f3KOppaA1qlgMZfsGc4+hUKhs0Z11f3/4DLzVeqcNsE/m12N/SD9tSGSX5ZFqg4IlWnSDIuRXoGJxiF/qsEgt9Wh7JaaGlLkpezsqUiFj49oo6zcbMryYIDr9tPyJH1qxSumtznF6x+hMrE1cPCKVwOJTPOqpu9TVca4PLbSdX2zHEIRvzyhN3NLRYmRVgEV41Sq4KKNt228OOrbkBRwiveEUGHQExCtxmmiFMuTPWfZGlQ8jg6TlxpKkA6qaNl5BD37MdYRsHjUoogBr+ujnaNlMPJHqBYJOwI9qnXDSBRtLS/4+SCcZKiq3FtA7myb46giHhdP0xbyMUS7R4e5zZIHyyClbMaBjSbEQ/7keJzwkmH4HX515UNYJOP1cSI6t176OkkFCfdcLSpj8uH2GhVdRseNNZhJ7RZeidCS3EriAODzU5bOTQI4EpLtVT6qvof4RqguvN2azCggC40EqujjhxtNETVFNpY4UKo+FtYQ4f+5GHEb3eIxOgJzOIyTAsTwqhdQ5rjP8ArcW3VleeqxAuJPTHCoHi+IvujzAx+rsUZ5KpE6buAhsciwCdw9Ja2Za5Y3zPTr6RrqiMaerx1rhQkMUNr53fhE9dZMhGgHV/Eh8D25I6RSyrq711k/A2Kkc8eo+EMVrKwPU6Gtvxuo8gNQ4+wddwKPx9SL2Nvw12gXHKxSaM075lggLChzyersURkhrN2Fmh5R0rax6MCJkVfcyhrq0o+pTAcmks09dq1mkgDn1EbpgrJDdiGwgME+ZjWeX+trzjqNMxAB5mS+OS34WN9P4cA2JOe202jNnOKtAfzhSFx7SqU93n/PoL5gPuPOsRMKjJ31UtfdFeuTDmCpanob330XDMxKrtS0A6duZc7rJnleIBSu03r1rQkOpoLR+Mn0eflBdZb4qlZ50mtC1nW2mTvmtjrd8boPLBFGIGC1NA8KoEdQEFDecSUNVK16eVS11toMSnfaRc9p0tMVZZ1i/2cUwPznuIIz8ZpDfbSP3rL1HfoQSH2M8ragXDnB0KCanMYtsSSqovpRDB/khaykhEuCutFDeV4MCqokmdaeDRm0+haYVXdnl03q5AiMonGqGTG7N4JGJibskv1fQkWPtmP9+dfdnGkF0AzScfcIQRgeI3i1MRR/aPt5zHooxdjrQd9BV+StbuWdFtAObQUNUoIrXONrQ57gigRWesR2Ibzaz0mbywxRB+NkAmc1KKSycEX8WXG+f+A9Rfg9ckvX20GSWdvYt7jcVkCo8E0eaoaWbtjEgD+2xEdET7I5GUm0OowIyGoMmaGn1YZGafFCecnnB40ztNwMUtsmhyR X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 562cdac6-2e2a-4f3b-cd0a-08d9416c7853 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2021 17:27:18.2316 (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: EA9Qp0HDYLy+org+0SKoiG31Agik5ANeGQJYTtUgyWeodp3Q27Qhw4C6n3MUE1ypA903FfuYBbGba/yqiLov2jJJExy+2lz2BxAeul4AZ5g= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4180 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10037 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=999 phishscore=0 adultscore=0 suspectscore=0 spamscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107070100 X-Proofpoint-GUID: A9KE-unl1bLJRpkJkdMGh8GpKXZB20JD X-Proofpoint-ORIG-GUID: A9KE-unl1bLJRpkJkdMGh8GpKXZB20JD 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 , 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 by preserving eventfd's and vector state. Signed-off-by: Steve Sistare --- hw/vfio/pci.c | 118 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 116 insertions(+), 2 deletions(-) diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 0f5c542..07bd360 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -2654,6 +2654,27 @@ static void vfio_put_device(VFIOPCIDevice *vdev) vfio_put_base_device(&vdev->vbasedev); } +static void save_event_fd(VFIOPCIDevice *vdev, const char *name, int nr, + EventNotifier *ev) +{ + char envname[256]; + int fd = event_notifier_get_fd(ev); + const char *vfname = vdev->vbasedev.name; + + if (fd >= 0) { + snprintf(envname, sizeof(envname), "%s_%s_%d", vfname, name, nr); + setenv_fd(envname, fd); + } +} + +static int load_event_fd(VFIOPCIDevice *vdev, const char *name, int nr) +{ + char envname[256]; + const char *vfname = vdev->vbasedev.name; + snprintf(envname, sizeof(envname), "%s_%s_%d", vfname, name, nr); + return getenv_fd(envname); +} + static void vfio_err_notifier_handler(void *opaque) { VFIOPCIDevice *vdev = opaque; @@ -2685,7 +2706,13 @@ static void vfio_err_notifier_handler(void *opaque) static void vfio_register_err_notifier(VFIOPCIDevice *vdev) { Error *err = NULL; - int32_t fd; + int32_t fd = load_event_fd(vdev, "err", 0); + + if (fd >= 0) { + event_notifier_init_fd(&vdev->err_notifier, fd); + qemu_set_fd_handler(fd, vfio_err_notifier_handler, NULL, vdev); + return; + } if (!vdev->pci_aer) { return; @@ -2746,7 +2773,14 @@ static void vfio_register_req_notifier(VFIOPCIDevice *vdev) struct vfio_irq_info irq_info = { .argsz = sizeof(irq_info), .index = VFIO_PCI_REQ_IRQ_INDEX }; Error *err = NULL; - int32_t fd; + int32_t fd = load_event_fd(vdev, "req", 0); + + if (fd >= 0) { + event_notifier_init_fd(&vdev->req_notifier, fd); + qemu_set_fd_handler(fd, vfio_req_notifier_handler, NULL, vdev); + vdev->req_enabled = true; + return; + } if (!(vdev->features & VFIO_FEATURE_ENABLE_REQ)) { return; @@ -3295,14 +3329,91 @@ static void vfio_merge_config(VFIOPCIDevice *vdev) g_free(phys_config); } +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)) { + error_report("%s: cpr does not support vfio-pci INTX", + vdev->vbasedev.name); + } + + 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, i, fd); + qemu_set_fd_handler(fd, vfio_msi_interrupt, NULL, vector); + } + + fd = load_event_fd(vdev, "kvm_interrupt", i); + if (fd >= 0) { + vfio_add_kvm_msi_virq(vdev, vector, i, msix, fd); + } + + 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; bool enabled; 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)) { + error_report("%s: cpr does not support vfio-pci INTX", + vdev->vbasedev.name); + } + pdev->reused = false; enabled = pci_get_word(pdev->config + PCI_COMMAND) & PCI_COMMAND_MASTER; memory_region_set_enabled(&pdev->bus_master_enable_region, enabled); @@ -3321,8 +3432,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 Wed Jul 7 17:20:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12363117 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, 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 B204BC07E95 for ; Wed, 7 Jul 2021 17:33:38 +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 53F0861CC0 for ; Wed, 7 Jul 2021 17:33:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 53F0861CC0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:56776 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1BQX-0006qn-GZ for qemu-devel@archiver.kernel.org; Wed, 07 Jul 2021 13:33:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48192) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKc-0000bz-C7 for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:30 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:59406) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKX-0006oy-Px for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:30 -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 167HCM48029339; Wed, 7 Jul 2021 17:27:23 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-2020-01-29; bh=2ylu0nrbapz928ODfW6tooyy6gNxR15ENSoHZRlcTrc=; b=vL6GBBcwmzXX71pomlFivwlYGBg5cSQEa7zJ6Rvyrh39mULVuuved1JvLOfxauk7OeXn eKlbEnzdh1TeriXmmzGwOV7FrhQiFhLjmB/y2MpNoAZTEtC2c9/aY9kCPiUdXNAna7by k0uk5lSCgiiDMWPHrDkUTlm1dnVR6mzbJRzCBRQ+2T9oVu+fym6xnKc6u0cSPRJhV+LV gvYLs3TuCQVh6rhzXGt4Mi2QZKcIJ4tqrX4zuprpF0kCgJUMNhkjCUKX6kZ/6lbc7BfW +kuA1h1z4rtUSpfZgfudiv26yCjPt/+ZhWnKhU0Or3n3LE+EGFd36MoY+h4PYoZb4zI/ 3A== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 39m2aacpb7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:23 +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 167HAY40155372; Wed, 7 Jul 2021 17:27:22 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2046.outbound.protection.outlook.com [104.47.66.46]) by userp3020.oracle.com with ESMTP id 39k1nxjv80-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GJI9az88Kd1Ujw62aa5GlMJL/SZVy4lYEI33MBfxsQWAdxUenXrVxjbMWQkgVEpleHIkO6veoiqkx30dBenNfPt1RRY5TQ5fDy9zqKh1VT1ln7YnWAdSMyE9+8OEN7jTD2DkFNBr4KfDr4WZRPFmsywJMneeW7rRQZTZHRZtPI7iCBhb235D+8kAD9OsRS4B1BB9Z385PyX7Ju3FdycTA3AFm/Hy85BBadRVs2Y5KEyahkfFPWhzp9HsQj4is/2Izj1XlWjTfaANZW31vM70MByIWOSEzE3oPoaaUl7+1DjkoGYH3i6sR5oFUuh/bbAEVw3FoHgPuUE5UIyCG51vKQ== 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=2ylu0nrbapz928ODfW6tooyy6gNxR15ENSoHZRlcTrc=; b=oDv7Th5qoDtkyZWxYZTiLUygYGpYkcvYdd4MAzi6xKhYlzppExtlljmZwevOTFTKHCz/Zz3zM7jJ7Rk5ncRtaAHIWMqDkvh6TX0wrdkWdXUwImzFnTf/Q7OdVumgFeOVIj0wdv/GN/VdDe+6kdl87TDwrqYkU8kYyat6Sc3B3plbMahGdgHtAMgtNVh5cYGHXfI0LL/3SL+MCZy0ULswbdmoonws4UF/D7owcHJrhXyOsGrocNUO3lpnjRddpfbH/Ph9upciJnFMoLcY8nQScri6w/Ldg/HW+PyFUvBuVBTo585kd0UCan2KLHlG0/smqndFWz5CeJJqfHOFuAcchg== 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=2ylu0nrbapz928ODfW6tooyy6gNxR15ENSoHZRlcTrc=; b=RKpYQGHOQWSOhhjW6hXA5dcq6whtRevhzoo2w2onlMDNf1hpud/xyDdEtlVOhjjaVossa/F8J009mbRgnmo4DLWnHQ4Od61S2udg7CjVO1LdE1VmK3wRnNIwJyAMwj+Z2yReLUyYbwf4AZtqStPSITfoEx+Ws/RQqBIKaeCfhAA= 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 BYAPR10MB2534.namprd10.prod.outlook.com (2603:10b6:a02:b1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.29; Wed, 7 Jul 2021 17:27:18 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba%7]) with mapi id 15.20.4287.033; Wed, 7 Jul 2021 17:27:18 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V5 18/25] vhost: reset vhost devices upon cprsave Date: Wed, 7 Jul 2021 10:20:27 -0700 Message-Id: <1625678434-240960-19-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> References: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) 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.13) by SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21 via Frontend Transport; Wed, 7 Jul 2021 17:27:18 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f68adab2-3080-42db-4e8a-08d9416c789d X-MS-TrafficTypeDiagnostic: BYAPR10MB2534: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5236; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2ecMUnKMYlcEr1dtEA2wrLLogceBCMrivkiAXgZOaOspMeuv/2TaEcOAjPJhR215DGCKwrakMN6K8ykjQtbDjJNn2pG2VR5ZVx25L0+ZFEfwzIIhcc+Jifv995QoVLAadJrmbGl1uuoFzzTrZNpJYIbF8KyRRzLuzP+6ISB/4GfWRtKwI20c89BmabK3+HOOXKNzeiIpU4H74ERjzx/cRl8+x0bWBUySZ87Jvc6zOeE3ZKer/mGDS+092Qmlw+jO1n2Gn9/mB6Veyb3Hoiju9ED5qLuMjdCbfyz1Hb+YN04JyXKNtwQoyX8+batIcPnJosi35QrHMbGd3nEghZcfNsNtnhx/SnR8VWQNkrtKZ2WWs+d4k6hLo02sd3CenKcBXPEhft/UI4k5f+U2Qz4RFnBQ6aJLAque7DvtYSSB5PDBeeBI56sALMZzk8ERNmX0RIxRqfnIaVUU2vSN9ZUTyvHxSF/MZRxGsScW7fwSYC1No0f4o1YD+FL48LtO8sUchRIObWr9gWfaSDNUifiXcgOLsO8XylGGE85ekVD3EEFUw/8OOM8WjRatBrBCPgcxAdmQa0Y80yzjkrVJlwmkF9UdKPjE3/MhP2HcG8zg+VkjrKmMKn1t61USsYoTDfn0empLaLuRRJ7vyn+hcegOuIYufmnk88Rtd17OBTZzqQHpTJuWsQkQ8j6wGwGeXGxz9i7sI+CqVABMR9o08faDOg== 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:(376002)(346002)(136003)(366004)(39860400002)(396003)(66556008)(4326008)(66946007)(186003)(36756003)(5660300002)(956004)(2616005)(38100700002)(83380400001)(38350700002)(8676002)(26005)(54906003)(6666004)(6916009)(66476007)(478600001)(7416002)(8936002)(86362001)(52116002)(2906002)(316002)(7696005)(6486002)(107886003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: a3/ED28tT6zdJXtpAj/AUFt9VTij+RG46tHp0zbXErWSRiKRxkMSUoCb21OtsjHbMEAXg9VY9JzRRtZZAPB3Dvb9XW3wERD3M884Iie9nfw2Pfe7Eaw1R35s8o+Y5iykiVuvyyow0HFVgrXmje/fBfrAnoTRZhHnATOti5y/rjirpCizU4WOZ6YZg9iAc/WU09H/Dzh5MczH9zH6P6OUYVDexy92QxAB/8be1V1f/AruNuwm4ACFRMfUTJ1iYCpsMXSbr28+DrTAbaDpMeTzELqnZTMstr/U3U01i+tPnVuUVLsaWeU2V4YTCto9qlgVBADfmELIq/fvtI+MzYOpzTcaX7x3Yh3nrWdvASv2am2N/VvSNIGAtWvYNWVRVrqpM8HYnNfHVqo20I7K9E+VHOWNSH3cqXUcRoeBa49GxoCAANnzQL1ddx8fuIFaX7xkfU9UO6gDXFbsIX6kvjUGxvOwhXY4iV+/4yqnbC53VmbylKD99l5pd3WUsJX9qNDIp14lXuhkZjZPMtHdrCjmw/nEt5+AMJ5eEKWDW6Be/XPLsUNdbOeBV1+jJn7SSxiOXbdlT9T8uDB6N2Urm4RBKsp8nkCjDOZHKHbwuesFzJ6VfObRq566NOqozEg3NznebijOoH98uEiiw5S+8gyyxk0R7X1i5mCAgnTv3IbAMStmvnvTF2kcdEb1ryQjvA/OztkSaXVaHahTGZ5vkQzgwhpiI3/rBa2hIdh8WLC7iSSjz/6WmKfBJOji6ekhaLjqU1lR0Eal/QHtd1lkb4gaYRYuGByuDNIbF9gbgWpGwpBvqQo00ESW9E9YsDQLGkWmywJoyvwAicein3weoEzcATB514Ls3I7ipmSeze5/q798Svnu76RIp4K0pUEqPmkYtxEOPdxiDIinj/TOFMzDI1kK1J0O13D2JdfanEB2gbOthlgPii4ZR+1ut8Xu+h1exQoX6bgYIUP8/5S28qHkc6iKJaJItMjSifzwA462jAfnWbAm3yVu/TG0JcTesea+2yprh6udvBYnBF+qwcBwLx5aTs87iBsh2/VmpfIh4ftGjxKHelUPmQHdVenco6s/lzmNpZkTIeYYSA8LIQ6WC6Iwfd517slGSNzpFaQWb/kkygrx5bmMzZnEnH1pbOh9DVg64527Voo1nLfVESSjvXjE6e31K16JjRr71s3uRt/PzEFQu3Q+qEF0qcBXmMf6VzPJE/DTO1m/jcKr9SzBEF0moP7Zba+m5/c/JvrZLZFdYM050cjdjJo/NCy760aqmzKDC0dWxOmtABIy21tU3EIIdH36f9Qhj6GfCNY6adeSPz2I6q6e6JkwPo3anyTk X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f68adab2-3080-42db-4e8a-08d9416c789d X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2021 17:27:18.7073 (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: 1dk5fMJ4MfXPus/Sl4KHa6yYeWKN9ft2Rk+rG5cPm90Q0paoVvc/IYWWZHamqGuXsFVl09I5crdZop+oESVycBTAPQ4lgXm2dxXG0b/WnKY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2534 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10037 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 phishscore=0 adultscore=0 suspectscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107070100 X-Proofpoint-ORIG-GUID: u5kpwLmOaqbSO1vQOAQedIUlZAJ_QjLm X-Proofpoint-GUID: u5kpwLmOaqbSO1vQOAQedIUlZAJ_QjLm 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 , 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 | 1 + 3 files changed, 13 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 578466c..6333988 100644 --- a/migration/cpr.c +++ b/migration/cpr.c @@ -142,6 +142,7 @@ void cprexec(strList *args, Error **errp) return; } walkenv(FD_PREFIX, preserve_fd, 0); + vhost_dev_reset_all(); qemu_system_exec_request(args); } From patchwork Wed Jul 7 17:20:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12363141 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, 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 F1D9EC07E9C for ; Wed, 7 Jul 2021 17:46:01 +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 83D0161CC8 for ; Wed, 7 Jul 2021 17:46:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 83D0161CC8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:60844 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1BcW-00038M-FN for qemu-devel@archiver.kernel.org; Wed, 07 Jul 2021 13:46:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48166) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKb-0000Y8-6D for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:29 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:57790) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKW-0006o4-LS for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:28 -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 167HCmFa005054; Wed, 7 Jul 2021 17:27: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-2020-01-29; bh=GmDaYeOcxz0kSqnxgEbfhgR865HIOFZlsv2d1D6ULWc=; b=m6aLgzG4zwcB1aRXYmTGvHyrnNzt+r+1ktxgN6PrgEjyuJeDbOhTEWUTVY4r5UExvQhw GOz6YtuPc75CSc7vu7D6mxIewPFXzfSQKkqTxxI0knZWUhpo202hJHmU9gQMa5G9bgp0 1QwASombaclz+yUhHy1OzsF7en6wtvcazcnMM1ZirTAyVzlY9QhUGkUUYsRC+3VDfLfp /WRLm4cGcm/vQGKsjKQQHgCxBqbvGCsGn7EA/razfdnVjOCNk5SNnL+ZyzvRm5HLnNFu 3hHY3TMQkRIAMXTlYdoGF94DYD8B5RPmlHsN2KjyH8U32FyQVNIM9OriWbNLlQjTtIIe eA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 39n7wrs7q6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:22 +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 167HAK1Z068884; Wed, 7 Jul 2021 17:27:21 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam07lp2042.outbound.protection.outlook.com [104.47.56.42]) by aserp3020.oracle.com with ESMTP id 39jfqayy42-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lHHUS8Ew/xyhYpPQzDTGIizCHU0SWwlHgMslAsR0uFPmUNnx6bRqCzTSYWWvuUMKmBuD2FBPK/REoUvFmhDaHjWU/CjOEArzpfFJfRzLyLq8lY5j4cMGEaEuSIybXMJdt9OIYx7uAeAmds6LUwhCZ1arE3ShVWKM3ZKBNJGSGU60TAajOqYThPNbGMjObdmg4FvyzQbN17+BMfFjEq8FsvowL5+qOVzYNKXqgpb/KAuR2W9YCickspBnkGZeE8LJXvboyhyAa0M0dSbJdFr9u6Mnlt3COlX0L3IHTY2PovO3ElleUHNR/EIzkVfWWqtjTw/z8gKHMxIlu7gtotWc9Q== 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=GmDaYeOcxz0kSqnxgEbfhgR865HIOFZlsv2d1D6ULWc=; b=MOTjH0QFLFwObt2l/fEQPz4x8r71uoSoKR/+UFYDeSp7hKLMO+m8ruGZiEqug5h1Gme3ttG7G9EwbDtgBLhmOacVCzwv5l8MfgxCg3JLzxUZU+G1fENdDEogTjA9/WuWnI2cj8uMZm0hGU3TM8MjZGx2Eccbwr9KUA5FNaRU9cxzTW64J+QM66dcR5ADwkVj1/VFO8D1I2UV48/oohGGIHdFc0Flsw4XbEw7QLgXi0wp3HW6TC0dX721pA3WAlmX4F8nM9hQsbbvPw6Sr0p8mMFHx1I+UmnmMKS/+C05qfEB0OpcE5/WR6hGNSq00gUOkSzUaZci/fXZSXQrY3PrMg== 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=GmDaYeOcxz0kSqnxgEbfhgR865HIOFZlsv2d1D6ULWc=; b=NazrbplJKLBhezmnWdIW44ANyHeXzMh9nO/XXkS3Gm0HNKfGDuw6Y8o6hsz/p21Eka4LHptntP7aBSxHBRNsbkHZjiPmFG8c30OmVaUMBdRw6+xamEhjjzIvxSKuZO9df3oN29OE1h0+YEyzvK7RThmmTp8MdBHqMKnNKI3/tuQ= 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 BYAPR10MB2677.namprd10.prod.outlook.com (2603:10b6:a02:b7::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.23; Wed, 7 Jul 2021 17:27:19 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba%7]) with mapi id 15.20.4287.033; Wed, 7 Jul 2021 17:27:19 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V5 19/25] hostmem-memfd: cpr support Date: Wed, 7 Jul 2021 10:20:28 -0700 Message-Id: <1625678434-240960-20-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> References: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) 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.13) by SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21 via Frontend Transport; Wed, 7 Jul 2021 17:27:18 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9f1a089e-0ff5-47f4-7010-08d9416c78ee X-MS-TrafficTypeDiagnostic: BYAPR10MB2677: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:404; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EqTTawAFMUDG7sZBZ2RxKfd8m4lF+rZhmcMybGXaoQCXyDVb09rI4FjYWZ5bBZuow8lgoYF3vJz9uyq5JNL8z3jlKfHGbti+TdOABUh1F2fjw9/eCg/yck40H4frBus98DnmhOIp54XUSVv7GxfaJmHVVyFm5zFB5ibEh3N/Z32W9rjk3McNJWuNmtRnCwtIs2vAWnMdgFij3c3KsULYbffgEKS9x2f9znFYImyrfUyun1gIvntN2XxFsRvgSS9EzQ32MwwXH3VPUReokN+d/8cQPaWA5D6TXtasl3cjgo3ancCULtjE3BSsWGwbE0c71rBFh5+ZORxLfNiYk46ueEKp3s1Jh1tj5jZlcQuTcaHW7wS1FVD5ujHkIRXUlLjTjAfwp4zfhwCt5gwh4eyW0JptXBXwmIGzdtU98E2+Y9Op287K6MfP8k7aIvKS5ExTF7uq7k1Br0ln9YLp32Aj8+6D5DxknSS0nH8m6eguft/KcMVgpBDYHP4yjBuPZjhvwEj8JrPLXT20GH5PD2YNoyyPDIAaxqfDeWwa7Z2Et5cz+b0g17x+flUayJ3rhylorNl/oros8L33UBsITa/SsP5WYlkX4K0vcsN1JOoxG8jlJmtzc3AYEVe3nR9ZJcjQq46HqRZlJ7kYm9SugCnYCnC5udDJSRHsD1cPHbBlEnWAd5WZRAB9FOPGKphSm6/f 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:(396003)(136003)(376002)(39860400002)(366004)(346002)(6916009)(107886003)(38100700002)(66946007)(7416002)(4326008)(6486002)(478600001)(2616005)(7696005)(83380400001)(36756003)(52116002)(956004)(8936002)(2906002)(86362001)(186003)(8676002)(66556008)(6666004)(54906003)(316002)(66476007)(5660300002)(38350700002)(26005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gPJEQ8NSAPL084VTRTw/9/DWU2RcdZ18YGWS5V+Bmd4s732LvS+lb2ZYfNTdim1KDp/nS8+zC0K+fOiMYVbQE2ojQ6XT2gali6DPFl2OXw2lFZt0MByrtw4Ak4R/tf0W4i5KaBIkinoiKmrFAfT090uEKHqEDe33f1JcqWwMqchqSvYb5qo9dpnlh58UCftLSnTiwY+7TxqzR1PVk8UCteyRNwSEu8EIk0y0dJfOJue6JMsZcngjMZ630PzeRw8Z+ytIz5DYoRq0V00HbPmHscbgB+E16Jez+GWh/UjUdxVLYqC/7JPHhsPDsLueud0ZHrwEMOCNMA+fdw3zaGGCIYSTYXcteygZFxWNNIgh/YTOkPJJ2xBBHp6FQsbr40jlxgC+A5rwMnMwT2eWgpz+9fJ9IJiK8EXh5jh/GwnyxhPSYOy+k6JjlfN+LEbj37QPumLYQVA03YhyIk6Z2DboWTSVpmTmKV6HYwqY/Io9h9/0KrhDg94QAU7nY3ezaWmhu7KwCBI4aAWPsEgC6OXh8+dgTKF0SPYIkCEzU3OPSTechn5Dy1bKmpyiN+538gSaCjj7xfVO+n0/yPIXo1iZEKrMittNm/D2tGYyWj7UIrBhWPcueZQT/8+C4u6J7I4KgETGu067iSEQw30c7xKCqz4H7VW52GXwtMwzwtQ2Vo4B7gsVC+lGVoPV4K68AE74q36jeThrMkTaPvZShOY/AdIn3dNZPnbPMYy1ks8q5B6Bj1MLpaBIRdCu4BKkb+EPSrX0mOfIWfJ7vB6PsA19YsL+UVKOqYsYj1KS30bZuJqdyibbaetG3BPgE0DJjYYPARU3Qbvl5eH+3s064zITiEqsVXmNHB8FzPDuMgJftD8mdtEmYZ96yerv9TM8aN50dhWpXThvZj1iLTvt2x4iaisX2xYV4ClGuoxrLT3ZEaZr6TWCnN/U0XqvHLBxwZANlS0i3cxSd0/DAV6ThT4BTnb14PymmPaoa0dUbPOXtvyH5YaaUqGK2AcU3+9CNJoKcpcvPd2MDCph/1Ns7UmDstN/Nk7EHdKsS42qgDjwWg3kJDAmISjtA/f+aYW6Xb2rSpq2WTaAbFs0dzcX9Z8QguCfWC208OswknqSoF2021+y2S30Smj9vft1s5XASRfWpveR/YJ3b09DZcbL5o4k5h6N9cdAH+BkH9h2KeOq0b+w6BEmIWx6r3q7nfJ2n7np4zq9POU4uh/OtpwHTzLQ9eOslGI+reSp3ndcbPlIYEfLLhGaEpCdjkxOu2tCgx/DsiJYPw2aTAwXGGn/Sms4wX6+i2wMV2tKtz8e8zpPrKQhAJHKI/b3IJoazRv3gV4A X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9f1a089e-0ff5-47f4-7010-08d9416c78ee X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2021 17:27:19.2460 (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: Tht4x0U3NjvA1V15amQ63zjDJcbsKHLWNlm0CbDemy8kcCsvykHCVKEMM1J0j6TV8lqYKwP6LVu/lNz2ZLjEcfMoTpkjAG4GgRRymgB0XoE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2677 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10037 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 spamscore=0 phishscore=0 mlxscore=0 bulkscore=0 malwarescore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107070100 X-Proofpoint-ORIG-GUID: C7T2GQCwhtZCGAqRv2DMRlLdLzhOaWrx X-Proofpoint-GUID: C7T2GQCwhtZCGAqRv2DMRlLdLzhOaWrx 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 , 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..f6c193b 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 "qemu/env.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 = getenv_fd(name); 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; + } + setenv_fd(name, 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 Wed Jul 7 17:20:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12363129 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, 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 1DAABC07E95 for ; Wed, 7 Jul 2021 17:40: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 82B1161CC9 for ; Wed, 7 Jul 2021 17:39:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 82B1161CC9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:46362 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1BWg-0001s3-OG for qemu-devel@archiver.kernel.org; Wed, 07 Jul 2021 13:39:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48198) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKc-0000e5-T1 for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:31 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:37654) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKZ-0006q4-OE for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:30 -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 167HCPEl011986; Wed, 7 Jul 2021 17:27:25 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-2020-01-29; bh=Dk4a+4WEUNVhnxOqffn7vWAGVx8wK6B+mqjTQqEBC20=; b=OXz1gtHqup7/Dp0zsAqIvtO9L1a4gzPonP+p6YlCpOFHssjbHDRbvgV1bt4qzpiHQCaI HSzM2CafuTJLLF+w3FdTPn3VSHwQY0Nqf5kQVyAyNJs0J4XSc7UMMmU4z99ThfjuuXBn NFjA9uVO7fQ3xq+4NTAt5hoSBg6WmjML3ZjGgpuyZAEbmA2zeacs92mkJ0ri5GOX80sL 1RxESUopJFZGF/jhYwU3REf8xa3mhOBnan8d9PyA4EdnfFUHWVVlYpgt+3JU0D4N4vNr 1MQHJnLm70lMEhG0Ah9u8pGkWZA7mlGA1PMa1FQ9Kbjx/f/XW4r3UCKj2t6Vmf2ABJPk Ww== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 39nbsxrqng-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:24 +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 167HAXXl155319; Wed, 7 Jul 2021 17:27:23 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2109.outbound.protection.outlook.com [104.47.58.109]) by userp3020.oracle.com with ESMTP id 39k1nxjv9e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EcpLzXs2+YAhFW3p3BxcBNL9tx3UTfE0d85/Z7V+mSJdDIyCYAbyNgFjpLaNP89dbcPQ2VtU8BRqZ2ZQXMjoF3FAsPX96nyS/Y9Sr/nx9Ez4sAMqRZLR+MmKLmCZ98sybUOT6nkwauKsZKq+60NdNwrA0AHgplxTPKMlAcklZkwcrqegYrkn2jwex1hTFbB+J3fAfDapH5f0gtFxswupPZOVN/Z+lbFso3Pmp5uQv6Igk97yFMc8etir1eapo9zlHiP4yZtPeBUzIzWAPPn2dbvwF2gA4RfYlzAG5Cskg8Dg19rF1h4cmvZXX9YhPBrh5Ol9F9ff71E0AOD/rlfv1A== 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=Dk4a+4WEUNVhnxOqffn7vWAGVx8wK6B+mqjTQqEBC20=; b=kzxWvH+KJg7aC3uVfOuIpEVf+ATvHsodQfKzmCXe5notuLxRwB57qesRpNewW2gVx7wldSlTT4o9G5b2NyXivE0jUUAwO+VYP2a32kLM0LkvKDq3HaSeHDP0seSHAGvUl8ql4nDL+UhDDOfvdrUTv8UpD6V0cbp/gtahFR6n36tdWtpDIpU2g/YIwAxsQgIrBQh0DsOLJnA276z7ATXjSqGwsw25A4fBlNRO6v/JImu4smJLYGzVwpN/uejDshZfGo1ovusQUlSurvJJNIzm7lXxbQLSJpQxiWY6n+GW6pAwoHKYDjVdjKYivYNpFHX4hbBBYBUqdEGWrozeddzPfw== 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=Dk4a+4WEUNVhnxOqffn7vWAGVx8wK6B+mqjTQqEBC20=; b=J5qF4TLNGWdbc7bb9yIKq/Uj80GwlQBuCasu+UjyUhFSJ8oytxiFVqX1CrXxuesuzmVSJNyfVd3s7qB43wluXSfaWxlN/gl19/eOEay1i/Tj/q6uwnJFbpaYPXVckRe+CMb1yqaixLa6NSfRLsBM8S52xEnaQ+KFkDIcWtZKDdo= 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 BY5PR10MB4180.namprd10.prod.outlook.com (2603:10b6:a03:211::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.20; Wed, 7 Jul 2021 17:27:20 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba%7]) with mapi id 15.20.4287.033; Wed, 7 Jul 2021 17:27:20 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V5 20/25] chardev: cpr framework Date: Wed, 7 Jul 2021 10:20:29 -0700 Message-Id: <1625678434-240960-21-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> References: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) 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.13) by SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21 via Frontend Transport; Wed, 7 Jul 2021 17:27:19 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7224cd97-6bb7-4a01-7b33-08d9416c7949 X-MS-TrafficTypeDiagnostic: BY5PR10MB4180: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:85; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gCM7FicXHD9swsknTNAji7wTnMwUMmMQjL3fWZXG8abSmrJuWJuLidE/P413A5p5myuLn5VqPBq9pVVtR8audqOxmQtgIX5M8TrQ5y3A6EssML9hNdecqUwDRbQvnTZditm045yR6ByUR0q1MVPrSkuU631EUKtcLGygl0UQlxNFA2/nYlFsTpOxZO9PRjsjP6Y/dJlQA0wZrIFRg6sY/d9AfVyTW+Jno6AtLYj/ReZd06KCra3toW1N47WnCsZ125uGDqqnj1RqyFICIiVop90zA4fZP1Yl0IOg1Dx4rBj69Viz6YnbNWc2tjX6FhMln+PlkiAzviZiW1UHYzBjj9t9pJGRCIBE7zkbv8n8iMdZ9S3Pb+d3NkRBDpaSvvonSUuVk/ymykut2v07afMjGtaxjB8nrlpeNFxIZ7nhe7ypuZ4LaMdDPd/xWOAdbR9ADd0xDZP849CxHqquG8h3LoZ1bhjI6gDdO7tiRjo8jAK0pncQHCwjN5Zgzvga7vGLxwl+MpxEwlWaHcbDSTU67jz5fb7IvjaTnTmIf/3EPhFLpCWQ4wg4CfkDqT6TOt/mioaQc3+8czjJ3DLmfqVQ+R1Vgm4501ZdhQNHVjHw3N13WO2ZuFn601t5fhH646CEkqYXQHAWXmMlMgzWVo2ikEBtEmU3B4oh5coTzBN01a5Cijw4uoy9le2FFcXokV7IyvZY2hTfLC+usCfLgOqd9A== 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:(346002)(136003)(396003)(39860400002)(376002)(366004)(52116002)(7696005)(66556008)(2906002)(26005)(478600001)(83380400001)(316002)(107886003)(6486002)(8676002)(86362001)(956004)(2616005)(66476007)(38350700002)(38100700002)(4326008)(54906003)(6916009)(66946007)(8936002)(36756003)(5660300002)(6666004)(186003)(7416002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Bt7fJk39VGISHsLOGpMLHuF/uLEXTNcnM/PIxyN9vnL/5M6tvF29MAH3TEa4WTa+7Rx1XTDQfbNusXxa35geomTwzdcEflYQSG1+dw+kxXC/DBn4iOcDANe0koIMOGOr8ZjJINtViHWiQdLA/95Iwx5m84fH5/zaWpW/CpkorR55FHbZ4U83T9plxqn7o9224O0+XPYWiKIRvn0YucYJG0VytBqJXZw6pmHkysOGyq9G3rImSvKmFl+BJUJVldFQ8xvjy3I6vfBXDlThRVUdZtbnDGkNolS8+U+ic0mQhPlF7fbcJtuWLqMw85Ow2EyL9gHdNZXbnVHWRzP9z9EFq53fQMEc7W7PyuiH/18QAIEkB8yWdtDI/CPBWcGWR3HH024YPjkB0StgZp2LWaGGb1VMB9pLLc2IPonTWJaw1VsOaJS6RP6vVOh2+HxpOo75PC2SEZTwpFMjb1nop0MZvvSIblHUfITCBP94jVb/WzR/H25t1Eed2rkkXPSTwhfzFslonjPY1zshJSMA3XaHdu3jFhElYUi4/4CXJSLVvcDDv285Z5XjxUqdDrZBU5QxQTjk6G/zzZ8sZbNlbrJBqCz/ojmRYsYoFvRTRwLp3avxG9tO0jrmk9UsMUTrR/i3uGVhI+l4LWnS0Y0hGSsb4YNeWPw58GMy4CgaoJD0M7JKfNPq8eoi1r5DAtvRJmpgM3u7SqJigijX+jk+4t9Ck/GhEypRZkb0j1Zr7oKHOp7pKr0Wbuor5l2AJF1oDcO1kIABNZCd13Fsh+OEXeS76f0xLPlxcwDM3I50DcWc/9bxuGLAj6UTS9ZSMahQZrFfUkkBONU+C29LBh7h/ik1P41YOBaj1tTX/eo5wCTrdvM2vsGpJ0eOA8+3DgjA29jcEb9sXb5IAXBX02MZY5rDWrg4uB309RzdU2VlraLadRuvreni8lRRiVzAiKgzA1nPLb9TvxygTdjV/Koe6UWMoxzpu83e+PeEj34tIq+bfIU7ohC4FTRe2XVe8Hjuu5iMS3ysgOdnPAiesoB/qVk5o/W/iKOZWZHfDt/hUKwijrqtdQvgvmgLon1Cd7dhIfdIXj79duikh358cHxmbM6adzb4TBFClPwlRKtoeEQcEZKZPmE1Dvv4fkLuIKk0+ht/Hx5caCXvPc8DOq+3jNDQkcFPF504vhduhNY0R3oFSB8S2+CwBlGCsBOL+Ymbkm2T2u7ITFgbhdz23fEsNkM2Z1z9nI+od8+6nS/kjQhhqeSxue18IQrlcgJvKN9bmYhweSe+UP81MSIwWdIca6hy8scyHbG51Adk04hppIPuyUE1XJ3vyMYHvhA4OPm8eOq0 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7224cd97-6bb7-4a01-7b33-08d9416c7949 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2021 17:27:19.9456 (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: wkzVNMnO9Ddw7fEyEE9I4/7aeiyOslORQq4JqEVISQM19+ijB2PHsKBE9drP9JYodiLB9SiZOEGN8Ky09TtuosV7Vn8wzoe/l2ulT2MMMvA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4180 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10037 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 phishscore=0 adultscore=0 suspectscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107070100 X-Proofpoint-ORIG-GUID: VFcXaFaLtgEpxdzFGlBPPXfmTBMAO1eF X-Proofpoint-GUID: VFcXaFaLtgEpxdzFGlBPPXfmTBMAO1eF 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 , 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 close_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 close_on_cpr is set for all chardevs in the configuration. Signed-off-by: Steve Sistare --- chardev/char.c | 41 ++++++++++++++++++++++++++++++++++++++--- include/chardev/char.h | 5 +++++ migration/cpr.c | 3 +++ qapi/char.json | 5 ++++- qemu-options.hx | 26 ++++++++++++++++++++++---- 5 files changed, 72 insertions(+), 8 deletions(-) diff --git a/chardev/char.c b/chardev/char.c index d959eec..f10fb94 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 "qemu/env.h" #include "qemu/id.h" #include "qemu/coroutine.h" #include "qemu/yank.h" @@ -239,6 +240,9 @@ static void qemu_char_open(Chardev *chr, ChardevBackend *backend, ChardevClass *cc = CHARDEV_GET_CLASS(chr); /* Any ChardevCommon member would work */ ChardevCommon *common = backend ? backend->u.null.data : NULL; + char fdname[40]; + + chr->close_on_cpr = (common && common->close_on_cpr); if (common && common->has_logfile) { int flags = O_WRONLY | O_CREAT; @@ -248,7 +252,14 @@ static void qemu_char_open(Chardev *chr, ChardevBackend *backend, } else { flags |= O_TRUNC; } - chr->logfd = qemu_open_old(common->logfile, flags, 0666); + snprintf(fdname, sizeof(fdname), "%s_log", chr->label); + chr->logfd = getenv_fd(fdname); + if (chr->logfd < 0) { + chr->logfd = qemu_open_old(common->logfile, flags, 0666); + if (!chr->close_on_cpr) { + setenv_fd(fdname, chr->logfd); + } + } if (chr->logfd < 0) { error_setg_errno(errp, errno, "Unable to open logfile %s", @@ -300,11 +311,12 @@ 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) { close(chr->logfd); + unsetenv_fdv("%s_log", chr->label); } + 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->close_on_cpr = qemu_opt_get_bool(opts, "close-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 = "close-on-cpr", + .type = QEMU_OPT_BOOL, #endif }, { /* end of list */ } @@ -1212,6 +1229,24 @@ 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->close_on_cpr) { + return 0; + } + error_setg(errp, "error: chardev %s -> %s is not capable of cpr", + chr->label, chr->filename); + return 1; +} + +bool qemu_chr_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..e488ad1 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 close_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_cpr_capable(Error **errp); + #endif diff --git a/migration/cpr.c b/migration/cpr.c index 6333988..feff97f 100644 --- a/migration/cpr.c +++ b/migration/cpr.c @@ -138,6 +138,9 @@ void cprexec(strList *args, Error **errp) error_setg(errp, "cprexec requires cprsave with restart mode"); return; } + if (!qemu_chr_cpr_capable(errp)) { + return; + } if (vfio_cprsave(errp)) { return; } diff --git a/qapi/char.json b/qapi/char.json index adf2685..5efaf59 100644 --- a/qapi/char.json +++ b/qapi/char.json @@ -204,12 +204,15 @@ # @logfile: The name of a logfile to save output # @logappend: true to append instead of truncate # (default to false to truncate) +# @close-on-cpr: if true, close device's fd on cprsave. defaults to false. +# since 6.1. # # Since: 2.6 ## { 'struct': 'ChardevCommon', 'data': { '*logfile': 'str', - '*logappend': 'bool' } } + '*logappend': 'bool', + '*close-on-cpr': 'bool' } } ## # @ChardevFile: diff --git a/qemu-options.hx b/qemu-options.hx index fa53734..d5ff45f 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3134,43 +3134,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][,close-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][,close-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][,close-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][,close-on-cpr=on|off]\n" "-chardev msmouse,id=id[,mux=on|off][,logfile=PATH][,logappend=on|off]\n" + " [,close-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" + " [,close-on-cpr=on|off]\n" "-chardev ringbuf,id=id[,size=size][,logfile=PATH][,logappend=on|off]\n" + " [,close-on-cpr=on|off]\n" "-chardev file,id=id,path=path[,mux=on|off][,logfile=PATH][,logappend=on|off]\n" + " [,close-on-cpr=on|off]\n" "-chardev pipe,id=id,path=path[,mux=on|off][,logfile=PATH][,logappend=on|off]\n" + " [,close-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" + " [,close-on-cpr=on|off]\n" "-chardev stdio,id=id[,mux=on|off][,signal=on|off][,logfile=PATH][,logappend=on|off]\n" + " [,close-on-cpr=on|off]\n" #endif #ifdef CONFIG_BRLAPI "-chardev braille,id=id[,mux=on|off][,logfile=PATH][,logappend=on|off]\n" + " [,close-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" + " [,close-on-cpr=on|off]\n" "-chardev tty,id=id,path=path[,mux=on|off][,logfile=PATH][,logappend=on|off]\n" + " [,close-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" + " [,close-on-cpr=on|off]\n" "-chardev parport,id=id,path=path[,mux=on|off][,logfile=PATH][,logappend=on|off]\n" + " [,close-on-cpr=on|off]\n" #endif #if defined(CONFIG_SPICE) "-chardev spicevmc,id=id,name=name[,debug=debug][,logfile=PATH][,logappend=on|off]\n" + " [,close-on-cpr=on|off]\n" "-chardev spiceport,id=id,name=name[,debug=debug][,logfile=PATH][,logappend=on|off]\n" + " [,close-on-cpr=on|off]\n" #endif , QEMU_ARCH_ALL ) @@ -3245,6 +3259,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 ``close-on-cpr`` option. If on, the + devices's descriptor is closed during cprsave, and reopened after exec. + This is useful for devices that do not support cpr. + The available backends are: ``-chardev null,id=id`` From patchwork Wed Jul 7 17:20:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12363125 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, 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 AC865C07E95 for ; Wed, 7 Jul 2021 17:36:39 +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 4695E61CC8 for ; Wed, 7 Jul 2021 17:36:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4695E61CC8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:38962 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1BTS-0005LO-Gj for qemu-devel@archiver.kernel.org; Wed, 07 Jul 2021 13:36:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48236) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKl-0000td-IQ for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:40 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:61346) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKj-0006pn-7N for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:39 -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 167HCN0G027394; Wed, 7 Jul 2021 17:27:25 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-2020-01-29; bh=aMAs8xIWZLKcYZygmGKKyNoVgWQ6TnFfTwQOquWl3D0=; b=Qq3BWYne8Php5jgPSpnruWFo9nrjchnQ1+MIwniUzhuv6AHTrowRVi/pQzK795X8IqdP 2Tm5W9tw/0iMJqajUcBEUKOJS+tOYl+9r8GuQmXJls3ALSW+e2NU03+2eHRN29EJk2kO 2MJeK3xwJmMAd4yMEILOUOb8NsRGbajRZVIOiIlXcect+58QTIAVct3RxDKY47nMbWKe 6Dj0jYcHC7V99HwTqQqK8ID0EuopZKdbZiZ7URt5YNubihrXojOhodVttLy1Xp2EWAxV ST3Qf+S5BWM5HF+QcQByd6qz++yjCMJFU1q6mU5st/+yApjqQvYNXs3MKeqPLYz2Q+Tw 7Q== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 39m2smmq7c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:24 +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 167HAY65155401; Wed, 7 Jul 2021 17:27:23 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2170.outbound.protection.outlook.com [104.47.57.170]) by userp3020.oracle.com with ESMTP id 39k1nxjva6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fx5qfEpi4C/YKx7ol1FLr1LiZvhXsPiOBEexX+Iabkea0dB82PNu86sPybsWVJiFUgfvN+SWmBRlVm800H29F8pp9LqIB71j00eWrLGbMXwn+7US7yVRBgQPecT8PaEWMRb6kY13IljfG/fSo1i9/2Ma9RGXHiEupqqM4gmXrpE/FWfv1Ya16746Y2SXwFz5YMqIE2lPBVg1oYNL7ZV1Xfs94UqsfQ7F3RCMNBkDbhed97NIBGXEr1xsi5qxBPexLInhttvsFC5is0ezj1NsNK+pGS6v7H2/Scs4DKitxqdNGa3rmDvgs79e3XG8BdwyVL88cw9b67K9SOaYz+r3sg== 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=aMAs8xIWZLKcYZygmGKKyNoVgWQ6TnFfTwQOquWl3D0=; b=ibyDUNHFtA+L+iewIOzstOWD6d409RdK4JESU/Vuo6DvZkhxUw2Dc+Whs3ap9szCfqcbAStXxtev9i+seJLEGac//ZHZx4achgeACb/RhXziOA8XvtffpbHBxJEzfUzieUGTrxopakFC4SySGsdHp9AFpT6epIZOB33KGE2JZQVvNLNVsVhHkuTHKuqI2PD8iRlyymEFY58hgsgBnU1Uv2IsH3GpAqJIG/tXw6vjR7nI3fIQ98yQp39Uzv9sZ3diBXwLnSDLlEQBnyqNhoWg3TgOmkjoldOixoIs9gebxuwWDd9aUrYEOI/4EpGN6628mOgaaBs/dFPKAzPIDddr4w== 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=aMAs8xIWZLKcYZygmGKKyNoVgWQ6TnFfTwQOquWl3D0=; b=WEtYzeUrtT/B7+UqebCtu3bMron7MOQvqPaw8kKdjlMxEYydgf11twWtNjHDh7Y7dzholL7VtaW0jtnG+4ai5uerPhlPE266lmIf+CbM5iT+exZSqTSM30RUjXO9X/axNE4+EZ4yuO9zFp1o6rS4lU2AnTY7zwzRWQbkOw9ekRk= 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 BY5PR10MB4226.namprd10.prod.outlook.com (2603:10b6:a03:210::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21; Wed, 7 Jul 2021 17:27:21 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba%7]) with mapi id 15.20.4287.033; Wed, 7 Jul 2021 17:27:21 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V5 21/25] chardev: cpr for simple devices Date: Wed, 7 Jul 2021 10:20:30 -0700 Message-Id: <1625678434-240960-22-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> References: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) 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.13) by SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21 via Frontend Transport; Wed, 7 Jul 2021 17:27:21 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 23cb49bd-7f07-4e37-ed29-08d9416c7a36 X-MS-TrafficTypeDiagnostic: BY5PR10MB4226: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:281; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZQuM+0gQlLfaRQS45iIsdsWCYgo5b1+VLAhEn1g7GYiAGVCuC3UQtwrWg2fQXGQoLQ49PTpn9dzd0YqxPIntl5tB13OsiVa5JENLAbpRrJpTE12uOy/s9CHIiAT47F8uKg3bOYvNtBAhjpiQoU0w8kVlAx/5eT4hsf9+VgRnnvuYr7q4OC/QTBaBnVNhrIBh0jqHCNjyRb9NG0XyaAzDj15NKSJl5zvf6/hYKBiZR8BiFmxafca+YH+QK1m82jKzpm2sMac+lCVf5sqOA/iCmhbme3iAoPr5S+VM3hqtv59xPPXl7ylLjUmLY9VpGwCi6C/wmarBw14yK217A9j3lXnSVMd42BFwol4s/x3b7E4Sxp5EJ+I2PG6FPmZScQMvV0IBD72BwTN8THTg9f1O1vqbKzsU1XE60uEO7QccXqNgqU7jzNwX7EFqcTLkb3XVcmjfM5eX7/MTAKnUfq8xgUY0AfvYPdIYMIGMS9G/sCBrdOEwRa1T9y+O6Y7LU6oUTGf0dLrrYtjn2JXNuejmjHLL7uqWrf/YnepIyQkZ2L3vLYuVpienEymfEFDuec2km1uH0RvXmBeNylhJYI0ekP/boMbV/DUosg//u1QqQKWftCKVX3Qtg/x0KlGBbJxn1+87gCM6XI2mgpLia1dXJYG9NZiUbQcwrn3xzMsLYHsNRYaX0a3qD2dVcCXxcXFM 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:(346002)(136003)(376002)(39860400002)(396003)(366004)(6666004)(186003)(52116002)(7696005)(8676002)(6916009)(107886003)(8936002)(2906002)(7416002)(4326008)(38350700002)(38100700002)(6486002)(5660300002)(316002)(54906003)(86362001)(2616005)(956004)(36756003)(66476007)(66556008)(83380400001)(26005)(478600001)(66946007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sjgpvgtfDgxcVgFpYhMlmDJGtjQyxQtxxiQVJEHkIBf+Bw60yku4jskB3k/gUAVP1rjCmv5cmJHWDsjNocsUukecYH8lOR0oqluKvbMw+nJvTCP9Bd8hmCsQZwHjCZYqyveLcbNIHq88e+dYmaeQwUluW8a/LV+FJNAWzvb/uahk3V5akWRydgHHlrDa2SQ1RXlIwMjshOvDtlDY1uCrt8AGJ0Ca62LzbeE5u6YciS4kqXnnJcozLbYi8c/v3xg3bgw6YCOBec5D/55bYalnS8rwv7rzUgZT5LrD3le2FIAGlqtvaQoLxs0GcwOcuJuV74H4u3tWyX2dppZ6lOqM6Bv+8nBkkNGaJvQvvJ4uVpylb1xtMjEF6sMgMvt5YWeGPKdtkzEewqMX1wN6ubHcgFiwqP3FVCkiuTflCK3l6fAsDaAWZSWO1tiehTIv0JqU373x8u1xPhzKPx8uO5wvV6LovF9FNojJmz+FaWAwdBSDNlK/JOBk5pZ8WOcrml6GLM8Idx1P1S5yrbFpsdTorzvJyMCN5E5VBAP024Hop+U9ZhmsxVqVfKD27/2WpD412uyRpZ7EyriCnGXyETAGEPv5ZdVGh3BWpu20NNJOBfYw9X5j66ce8qHH/4s5zRDAgkaJu0yVRCCZI6kI0aO9MEuthqp5aEeRfUlgSgs4fKlPVpyTLEynqiDeVYs7eo+fzPEFc4Z15OBsSzkVvUgUmam8vrUI86B4pLlY8BsNoOfWntgzYmq4kTL8OCGH1WdB1cbDYbOrTT9cU/3SAkm2hKdO6glawRLO5dPv5he/TjGh6Ru/Dhi96I1knHRlOpX1X960PN06dUZC922zft9wH9AXwruUdoXzQELGiwi5KsNZ9UQOl7KR6rnS3wjbN/fLoJ+tVExhGCUdNChpbMsrNX3xmAyXl0A+sOoc19YiMTjjVCTUPHh+NERegSmcea/Ger4dfQDrNvBImWzC9TOEJWCOTgc5DeCW4X0GyGO0XfPA1TzCq8oRMDY/RQzFf8u89DWGSBVuLtrPhoxOhmL8wgm/3c8CdacEwmKLYyrgbPOlA43Qb9ledNM/etpBHmucDegX3YMSgSk6KpAr4H22bp1n6IUyqFokaTK7duNQ7TLJghgKpwzilR68hOUNj7az5dTqfSb/MWLCS/JwNyXuQqahKVY28pe7iMkWxlEQp4KzTgRvxIcenK4oFMoXE6fASNoHqDxy94+RPFzNtdJZIt+yjgpmvccinf1HWK97wixk4wdYzjQTfSQH6Oby0U++WqgxlldVbRkigSuU/aGonz2s04cC7O8h9BD0ho01pPXsUe1GGJm72pNH9oCFQFY2 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 23cb49bd-7f07-4e37-ed29-08d9416c7a36 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2021 17:27:21.3668 (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: fJto39/YToIMPDNuJuOuTe4yddzCUROkrDEJ2ING1meo8c0qSVwZ1ZvUiPjLJtpgGeNqCCzBYzcSyPvGA1eS0AQOhUO7isqOgB/tNSGsLZo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4226 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10037 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 phishscore=0 adultscore=0 suspectscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107070100 X-Proofpoint-GUID: -aeXYgT-df4lBeJXMEw2_i_nZgP1CpsB X-Proofpoint-ORIG-GUID: -aeXYgT-df4lBeJXMEw2_i_nZgP1CpsB 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 , 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..b014b52 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->close_on_cpr = true; create_processes(&gdbserver_state); diff --git a/include/chardev/char.h b/include/chardev/char.h index e488ad1..96e5570 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_cpr_capable(Error **errp); +void qemu_term_exit(void); #endif diff --git a/migration/cpr.c b/migration/cpr.c index feff97f..4600d8c 100644 --- a/migration/cpr.c +++ b/migration/cpr.c @@ -146,6 +146,7 @@ void cprexec(strList *args, Error **errp) } walkenv(FD_PREFIX, preserve_fd, 0); vhost_dev_reset_all(); + qemu_term_exit(); qemu_system_exec_request(args); } From patchwork Wed Jul 7 17:20:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12363131 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, 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 79826C07E95 for ; Wed, 7 Jul 2021 17:40:09 +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 208B961CC9 for ; Wed, 7 Jul 2021 17:40:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 208B961CC9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:46704 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1BWp-00025v-Vk for qemu-devel@archiver.kernel.org; Wed, 07 Jul 2021 13:40:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48270) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKn-0000to-WC for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:42 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:62594) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKk-0006qV-0y for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:41 -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 167HCleo005035; Wed, 7 Jul 2021 17:27: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-2020-01-29; bh=2hHfE6MEGogQzthqOH4vqs5xuVFIGzYUunqFpRHnOoY=; b=z8pdpVMn2K0Tai1vkDv/+vEIf7K5OwVljKq2AAiDiZLGz4WxQkj67PnFFUsuNEvhLSo5 MPkMpz+nn0UWphrMvqZaOpsrLjmpcZMRXa3fmxr/hnLihfV02IkthbTExVgZnT4c7f5n iCSDIHew5xiAogoycGZQfHJdvoWgQM0FooNItVT8fZJix3Lll3+bvi6S1/WM+4+CRuZ8 6aJL/BedhY1qfLXsXS5kCDG4KvWGB7umP4mPKTRkFFdoV/KaDLp498McQdCAtZTjTExj WOF/Hhuu+dkUJKQ+AsBTWX6p5x17ZuANtyHfUKk7zAZT1u45pagP4CGU4kVEZkMjZVJy rw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 39n7wrs7qd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:25 +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 167HAY66155401; Wed, 7 Jul 2021 17:27:24 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2170.outbound.protection.outlook.com [104.47.57.170]) by userp3020.oracle.com with ESMTP id 39k1nxjva6-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L2dxH5ENMH/tKhjfcEyR9ZOIhaj/cadx4oEp4mWOw003gGgneNl6c2iF+zHvnz7mv+z5LrvTKfUa764O2Zz28m7JUKClF8kAWoe0hGbA2IZrkjeEdpnBljkQRgvpdcL7JD2/Mn1Xitbpszq1w33BzVpu4hR46R0NMRilXLwkmxtQ3dAXr7LHqiT9ey8ZjJZo8iG8W5/6wHUEd1SRVdevVI7Tsd5+Rvdhaky/3RBvh30/GunRedNbEWYdhyM1qCuWeSzY2i51Bm6YjL2WWSQzS6r0z8EDEmo3YH+N2rjv9bceq1zgQqVRfPDYK2K+Czfho6zmRE1zcgi/uIZaZgmC8Q== 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=2hHfE6MEGogQzthqOH4vqs5xuVFIGzYUunqFpRHnOoY=; b=aW9kjXlITGABYIbUujdi7RY817/XpdoYu8J7cYzmMgtjfin/vg7sr5vZY4KxbUlZFEMBcwTPDwIw7TlVcAwiZv44L9g1/xpPS3FIbC8obWf4WIgqSCWvo9MpTslqzCTm1/Gh/AZlWFbQG1bi3PtFGKeTts1mmPpfWBLm61BGILuTmxmoTK8xVWnUVkkzqEtiOE496Xil38JrztJMdaB6CqakhuWT31kmEO8T8dZAMsctBo6I7YZS0qvxVONHwNmqi0bfgpblr5EGWA8mmAQLzoZCafj18RzYw130y51dMMPoWWyfFt2zfguUDYaCry9XM0KZkjB24QVCFFU2RjevHw== 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=2hHfE6MEGogQzthqOH4vqs5xuVFIGzYUunqFpRHnOoY=; b=UrCTfEM7fyYEWnhy24Ai1MrFpoK141qNwy2aPtXS3RCe3dpN8KKNzEu6yJAmkpWGQ/4RBoUWTh7+5HiWXaXOqFOTGwmQ865KJo8rw/2b1VdUlMOSb01qFS7TIFr0SWH36Y37jDEbJOcYGKPBZWKP15gdXCXLXI8e+Ej8vFEyOxM= 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 BY5PR10MB4226.namprd10.prod.outlook.com (2603:10b6:a03:210::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21; Wed, 7 Jul 2021 17:27:22 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba%7]) with mapi id 15.20.4287.033; Wed, 7 Jul 2021 17:27:22 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V5 22/25] chardev: cpr for pty Date: Wed, 7 Jul 2021 10:20:31 -0700 Message-Id: <1625678434-240960-23-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> References: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) 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.13) by SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21 via Frontend Transport; Wed, 7 Jul 2021 17:27:21 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e2d45795-6cbc-4c04-1b82-08d9416c7a8b X-MS-TrafficTypeDiagnostic: BY5PR10MB4226: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:113; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EI9plYld/yXaoPt9iaEXeOpyB1uwrcahpGsUOoLsV6rlkaIrVoYZwYRUYOE8UYWEHj0X2UUP+EexK03bZDmlLb5LOcCmTeKQFqJQl9mKSlpfFr8qqeU1zkSvrY5OnkFn1FZq136an8hBnoFfVwXQho/8S9RcknBCRp4gNzNS/oLm2pBOmlD6h+bUUldeXsePH64//6/SmwsT400RRyD6dPRQ+XzZyAfHzlh+4LcCgDDfbPkT05C7i6pYj/yEJDYMnMyzt4PIbMbdb2BhA0Rq0tQD+M2ib/+V68/4JyVKPMvPh8jJiiw6ngUbrIq8YZmvlRuLacgaYc3KvHL0/ROYf9SS+dGrMGLwb5mQ+4k0p3CSo49GF6y/FQc9T47JJVjtI1OL7KExVU1OqAlWFPO/iroqU9OdNC9eNkWyNFOGPARaYgZn+wCKZmg6uZ5QV59YZ9h6Di94WoCO08f14h67BqPSu/wdlp4SxGdPlmh7/IxOL4nR9mwA46jw/iivLhQ6fJPFoAEYCX4alj9zPdaF5NJKWqlV/9IoSQA+mpnPhmvVGGtS346O06kkLcJTVU8fEnY/twePIKpo0uu+gE14BVFXxIQBTb88iaPVP+6iW0aAswyc4L0udJj2vgVsCLhmUvy4i/VAZ0WRpeGUI1wAsT+M/7LZCx6zWNYSCJUbWUlp+ciujWG7mEazeM1laTYG 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:(346002)(136003)(376002)(39860400002)(396003)(366004)(6666004)(186003)(52116002)(7696005)(8676002)(6916009)(107886003)(8936002)(2906002)(7416002)(4326008)(38350700002)(38100700002)(6486002)(5660300002)(316002)(54906003)(86362001)(2616005)(956004)(36756003)(66476007)(66556008)(83380400001)(26005)(478600001)(66946007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RNEZnlSGX+CYnQENYX53c/LdcuV6eu0GsFcIk9mAvqb0wdy/wSFrPgOM4uPnCVsP1NQgVkQIWhdxk8v05dfxn2zHt6KgZnuZ/XiJB1SIp3dVLotPLBycr5oDy0+xgYOK6S8Pf0+f+zfoHRITeFE3swMBfNNR/kuzsgrBggBaBve0OCrfqyS+RA6KHfrgtYJ5cWoGFYbBg8wb5ey6eM/Y53IJq6WvyfoYv5TysM+CMAhVriNKc2Q1l271KPGl3WSkKYbUkeN/4bnCHfVnseL8stFB4Mgv3OttAWLghGlvY30m1Zg0gxS1ovja3SEAW0S0yCK70dR9JxMY+niHKrvwmAcM/RSZBzQmpZzmYvpTocrkt96Stfwf4U3cVFJ6CORmG6PXRqqV9tNgkd/oEDLUlxj8192rZ8anoDRApswEmz3Hh13gkhaA7gSa3yu++ZvRv4haPv5JVtFxNpyiSKE0qhQD9zY432VhJM+tIQmON9JyjhbmL2iCcJGF+ObCstksTY9moavZoUxIGa2Z4DJBXNgEZOc9vbTaO5mspeZz5skv6vNyk9bDJ+6yD6IL/U53ErQMTaQZEBshBgQIh7otRIBWz/GQdQzc9CkraQ/l4wYRAaAxOnaWhHVAAwsTH/s1iAsraYeikROQv5GPQd/tWrMvOh67NtWBw9wqh0HVdddahcb+v7e+tLuXD+YXGyTU4cOxWzWc8jHHwDoMy+DrANvmIzh8SixHa2EEIIfg13lWSEWQV1yITXTGXONe3Rfk00eHRNJRIpMq29d5VWFQAiyg83YeSuX8p4ZYmBtNAxCXPUKhGBuIIJYjuudDtRn06bt8nnGRNwuHO73wBXDdvFY9CsDglREzKJVPvmez1RFKedbzUqTJjID1Fljt4x9JOLEtxqhnj+lOCGpgi+gQNiI0+ptLtWmZPcktXEpVccBV7qEXlsEPC4fmfNDmuTxYFkkve3hmsyH7ERfKH0UASeTMTJCHPvmrLR2l9gezfUQ6gyKaGp1c8d5jxfcZLWNev3XrWb56Ns13ukA57lEvPcIjnAYlnQpOYjjR2xvN6pNSQ/fQ5k0foNMlZ8MzkTX69woyMKDfJbb3vukoIzmmnTmMli0Uaa2DRdUb6WFLvyydh2pqPOLnF3/7k4iwnOgjxZHkK5+mAq2O9OUolBWon+CH52rDUAZ+Ox/ezj8jh9gzRIs0bLPOaS6U+2ghpK4yXSR5k8pbFAvmmwX2gVAQZZu2rt7JqQ8FMjLNiAQRVg7a9tRY8FtIIptoFhNkudR9HJzueZoCGJYXUqJBNXX3jLQl3f65upk/XuYxRojiJGKyPHzRhNEFMRfyXXDAM0tP X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e2d45795-6cbc-4c04-1b82-08d9416c7a8b X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2021 17:27:21.9565 (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: Oa/gEphubH2mqt7JccUUc1W76EDLOLOszADivfHWKeHeF1yYTwm0foy3M7HJwPKyguAMzijTMqxj6Xgoc7Tv6dL6Kq9WvQIRmUVIYp7ZA90= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB4226 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10037 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 phishscore=0 adultscore=0 suspectscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107070100 X-Proofpoint-ORIG-GUID: dlR_Z1Ek9dLgOedmF0FH9ovDnH20iEC_ X-Proofpoint-GUID: dlR_Z1Ek9dLgOedmF0FH9ovDnH20iEC_ 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 , 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 cprsave and cprload. Signed-off-by: Steve Sistare --- chardev/char-pty.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/chardev/char-pty.c b/chardev/char-pty.c index a2d1e7c..c91151d 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 "qemu/env.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); + unsetenv_fd(chr->label); pty_chr_state(chr, 0); object_unref(OBJECT(s->ioc)); pty_chr_timer_cancel(s); @@ -207,19 +209,28 @@ static void char_pty_open(Chardev *chr, char pty_name[PATH_MAX]; char *name; + master_fd = getenv_fd(chr->label); + 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->close_on_cpr) { + setenv_fd(chr->label, master_fd); + } close(slave_fd); qemu_set_nonblock(master_fd); - chr->filename = g_strdup_printf("pty:%s", pty_name); 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 Wed Jul 7 17:20:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12363149 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, 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 26E4BC07E95 for ; Wed, 7 Jul 2021 17:49:46 +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 A907361CBD for ; Wed, 7 Jul 2021 17:49:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A907361CBD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:41886 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1Bg8-0000ya-Qc for qemu-devel@archiver.kernel.org; Wed, 07 Jul 2021 13:49:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48284) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKq-0000zf-Go for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:45 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:64780) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKl-0006sB-Cq for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:44 -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 167HCNYm027404; Wed, 7 Jul 2021 17:27: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-2020-01-29; bh=ODVcqsNZZUgyrGgVRAilz5u+VITg0/BtM24sLZwVyiY=; b=gh2ktkZ7eNG1laVbNYXrs8Mp39Xf1F4KFlMombzDxnmZFmRN7muChSPo3+X3nGSylhDs M4P6wE7e5SjXWRQ0lT0LQsc8yNeciWExKYS+Qa4zoFoS4QhpjzrJqaJ6JSWxV8u0fg7P 075F7NfGNCrbClchfu+qs94EnK4JT6qI1czmxP+b5eBj0Zfq1eabKCLSlcx40Vs8xHyY hOK9TEV4AMP8hfgZbo9nkzLF5610fybNFwH7PBQaxHFwKXAOLAnxQyoaOPQoj194WYtu AvKwO0E6+S9lxTbWJcquanIfm0ixZa3z2Ym1f1qUMfYCeufI1/eFtjU5rwltIF8odYle Kg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 39m2smmq7e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:26 +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 167HAADG026147; Wed, 7 Jul 2021 17:27:25 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2048.outbound.protection.outlook.com [104.47.66.48]) by userp3030.oracle.com with ESMTP id 39jd13ubju-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cAtHZlWAFKCJVob7UU6S4GN/pbJd3RakGIRPRgQITmPs/PkXwf7HHZ6zoJmsbxsPVexAS6ayEz0M/gDqQRraum/d0DCyyFlN+NkwAhD4nDHktIsm0AwDWJPXBy/TG+tZ4qTmCuuXpKPJf5P/Fw1m3K3mtqr9ifg3vx7iDDD6AWI2KPc5N1jjsm1DoXKSoZJi2RG5YdmMsXc/DeQCFjIjo6DKkYjyEh6uPcQGJsF2PqKRmurb/mU54GgtcCKsEO9EDcIiQXJ9N8VAbF7/Mx6DxrszFWdvhGJ9EhnEkcSrkqReuprO0y2gPGus72Mwxq06VNZ15qBS/j1s1Rr+s+Wa9g== 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=ODVcqsNZZUgyrGgVRAilz5u+VITg0/BtM24sLZwVyiY=; b=FkYYPKbFuEc6C6dLRDVDai9JcwOlpX4I//kGs/4BKwDuUTGP7W4OqFGoqXUGuDQrhClD8Oh17rHLRSOHI/HKsm26i21+zr8V1KMABGogpAJ0nhD8Wa+K5ObCZrvfTY43EFsObsqwkvpaC6g0NezHoQ7HIAemT1/DyqfmF9FceXwnNxU+yE8o3HNYDopcEG4RcJY+SFPOmxFoxX8eLxHgl5amgUTLHlh0ezQ8RmkGd2r9Dgwm3QQV8KPsZYGt26NOqeH3EbJxPCP7ldNajVGBMbenFlL9yuVpjRzZvcDFVP0chzrDv/UWT2yP7WW1LyXQn7kSIi+YKA1lBTf5RNxQeg== 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=ODVcqsNZZUgyrGgVRAilz5u+VITg0/BtM24sLZwVyiY=; b=WUYnf3ZVgblSNItrbDJOd+8IxymkSMPZ7XMtMxTBCtIvr/RfOEkLMdwMeZJM+xYupqQB3gthf1u7xOXRRbYI/5KqLfm9Lj2BPnwrvdxxIgBg6sJzbaZjFl2CBx8WMMq4DSQ1icyZ2NY0uaZBIOh+foMBDJopGscRtTrJhJP++Q0= 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 BYAPR10MB2534.namprd10.prod.outlook.com (2603:10b6:a02:b1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.29; Wed, 7 Jul 2021 17:27:22 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba%7]) with mapi id 15.20.4287.033; Wed, 7 Jul 2021 17:27:22 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V5 23/25] chardev: cpr for sockets Date: Wed, 7 Jul 2021 10:20:32 -0700 Message-Id: <1625678434-240960-24-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> References: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) 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.13) by SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21 via Frontend Transport; Wed, 7 Jul 2021 17:27:22 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: eda7363c-4609-497f-e5fe-08d9416c7adf X-MS-TrafficTypeDiagnostic: BYAPR10MB2534: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:989; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Hjwx8n/4q4ybPW1vASJ4/uaUxzllC1dfwD3lf+EJqBkhlccXYjmPJCr8cCEuy95mMmjXwYCL+9ApSGWhZmWw5auFlGujKTe6hJZITVVLUJ4CGpyAhnEv3kkmOSTOrxEr3S5i30+QShPcyh9wyl3YfG66XZffNOzjyE1OxMajm7utGBcsjIZVEe0Wo1u0WtcosATN42em7gHrlpLuU3p6CCHVUalu5LrhZSM8h5yXgXhjr7G2JAU7U/KLCkUTTbsfkpAmP2OHH+JNmEySHmaGSWylPkUMriFcdt0v8FBJA9c6zvZFrAtkm8cpWIxiMT8WABwM4NKk5w7SpZLcX7P+4a8lTIu5YW5lLAp54vdlwapDtM+Pw87sFzL1a+TkJo4C0PYhVly5vkVwn6cmfnAAiNVLC/VHXrAtodvJ1qe1bVSNYLiU381l+bgZCu29Luu7YtFdFcLH/10niKg8hSalCq/05Gp4wvQ5bMw6eSidVUn8LMlqI2ht8NICPjPDGm1nHxwUGohoEOeua2AlPlkxCeNIkT6KmHwi2NbYCSN/+9FTw7DnWyXAjtx2jQN7ujVV5b5U8Vwbikvj3hh/Nl63PU0t2OoFDVYJTNDtOsY4079TjR+dKfmYvwkjdjyPBT0IT4aN+uE/Rug9C1F8rWVQ8YuZlTjxw6oB0PufrNlePvJhbS+6ish779tIj49vz8SK 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:(376002)(346002)(136003)(366004)(39860400002)(396003)(66556008)(4326008)(66946007)(186003)(36756003)(5660300002)(956004)(2616005)(38100700002)(83380400001)(38350700002)(8676002)(26005)(54906003)(6666004)(6916009)(66476007)(478600001)(7416002)(8936002)(86362001)(52116002)(2906002)(316002)(7696005)(6486002)(107886003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3oFsr2iBkKWstHNkE/Th96rEttVn+Iix4s+rLJrXc3grFqgaP7RF6I8546Fk46i4SQabVzYP5DpKJbVOgKzRGnCKgWseBVfR3gUQL9paWOsd30TtITauXM3NSJVnSEACSIEV1GLYXOmFDGZ7566O4Zoe0n9eZFs5FFO1gffON5rWbxPJKo3TWRvQW0Yv7n126+IRd37WRP7/Hygj/xSZaqF9xP930DoqasxVdczn7GL1SyQjVP4rhDsQzmJSFV6neyydxMElQ0bY7BS1Kp1orgQ2+fjShaO/v853T7W5+Mn2iQ7pVs6O5ppjiwq2+LDWwbfG41t+NwkgHq08rHtThLG2I4M4SNluOB9Wh7kd7nYnoJ3GLDueupNeffz61Zbck96B7ZfkKhXeZLunmmHb2up7PSt1niqQR8v+JyUrLuubmJzaAAMYJs+CzvcMroKnfMzms9ZrBer++AlllZukp/67plpPjr0Jg3/RIC4KIqIKy66WXT+Uq2efEpgbhDlkre9nAEwig7BYgGeoxArefwKG9SW/g50ZmhjqxKHVbDl/TvtUgu6cwoN/z4VT0nRbD8ELRsXz1Ckn3wf8b9WLfa/xuGtJulSprcRmb+ODTxcg33DDtJTw8Nk+2ujlfgyPuB+T5xKEfy9+s/+7A3x0f+zPg5ioE0PUVuec6ijXt4wlvxN0ZKQpJvvyZJpNmbgLtiQ5ggqXGvDWV7ncuWLyzsgyzJzNS528/AG9b8Km/Q6zDw5mw4ycJwWEWP0GvZkyfmsltB/6ELyjBmKPDoa+jrM9hg+UYbsS+S22fsgoDu8Yy45jwbiPFdVj0K6wOZ/cTxvI5vWHxjT6VwKmJVV0BYTOEwm0VUjrxt9SWjbj50BciXoGZju7HDv4rVSDBbYDoC9g1EXE0Q9GfIs6FLElqg07Z5sr2M6L/Ae9G4yUrOUzi3nAPMEn5esKU66CkKeRhl9oLRpWxYXZBHGSxudsDxmAdaYRDaiLgkam1n6YMX8khue2SKDP9+tuo7k2BKZfCYqzVIJkyYseZBMzgFocZnN4+kQ86WI/Zc5v9rKHT8fidkQVkmVBgLSMbfywPdZi18pVqajfxl8KpYMVIqraVfHKReMpMLCK4s8ilinK0TXU56fKM6RAgViDGzv4UKEU9BnTTwcQI0MaW4t11MWjQr2gH8gtOs7nTO2h9scvqtTkNb/8HVyji96l37tenajibCc6M4s+BnVkDIsmw7WORgZwrRLYf6k4EF6FTHzm4UROMK0VKWbQ0xosmYuiAuVZmti+6JgjOY1FjyFUDTUT6B1BK5DhPKP455zhuAGAGxl2eN2lXTxdDxH7MOG6eU9S X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: eda7363c-4609-497f-e5fe-08d9416c7adf X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2021 17:27:22.5711 (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: 06u73bCnznqYruMfh7ObBJE4HLHKyn1U4WqFIFzQ+1GD2JriXI8gAeLWQtWLjaSsXiYwvkP5Tj/Y0kI1RMCG+6Ij2CPCnQxVSJBPcxr12Qc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2534 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10037 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 suspectscore=0 phishscore=0 mlxscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107070100 X-Proofpoint-GUID: UbNjZSmCZ9s7VhyLEddZnyWU_Crr3kmm X-Proofpoint-ORIG-GUID: UbNjZSmCZ9s7VhyLEddZnyWU_Crr3kmm 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 , 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 in the environment before cprsave, and look for fds in the environment after cprload. Reject cprexec 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 | 31 +++++++++++++++++++++++++++++++ monitor/hmp.c | 3 +++ monitor/qmp.c | 3 +++ 3 files changed, 37 insertions(+) diff --git a/chardev/char-socket.c b/chardev/char-socket.c index d0fb545..dc9da8c 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -27,7 +27,9 @@ #include "io/channel-socket.h" #include "io/channel-tls.h" #include "io/channel-websock.h" +#include "qemu/env.h" #include "io/net-listener.h" +#include "qemu/env.h" #include "qemu/error-report.h" #include "qemu/module.h" #include "qemu/option.h" @@ -414,6 +416,7 @@ static void tcp_chr_free_connection(Chardev *chr) SocketChardev *s = SOCKET_CHARDEV(chr); int i; + unsetenv_fd(chr->label); if (s->read_msgfds_num) { for (i = 0; i < s->read_msgfds_num; i++) { close(s->read_msgfds[i]); @@ -976,6 +979,10 @@ static void tcp_chr_accept(QIONetListener *listener, QIO_CHANNEL(cioc)); } tcp_chr_new_client(chr, cioc); + + if (s->sioc && !chr->close_on_cpr) { + setenv_fd(chr->label, s->sioc->fd); + } } @@ -1231,6 +1238,24 @@ static gboolean socket_reconnect_timeout(gpointer opaque) return false; } +static void load_char_socket_fd(Chardev *chr, Error **errp) +{ + SocketChardev *sockchar = SOCKET_CHARDEV(chr); + QIOChannelSocket *sioc; + int fd = getenv_fd(chr->label); + + 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, "error: could not restore socket for %s", + chr->label); + } + } +} static int qmp_chardev_open_socket_server(Chardev *chr, bool is_telnet, @@ -1435,6 +1460,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 +1479,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 6c0b33a..63700b3 100644 --- a/monitor/hmp.c +++ b/monitor/hmp.c @@ -1451,4 +1451,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->close_on_cpr = true; } diff --git a/monitor/qmp.c b/monitor/qmp.c index 092c527..21a90bf 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->close_on_cpr = true; } From patchwork Wed Jul 7 17:20:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12363139 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, 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 570E1C07E95 for ; Wed, 7 Jul 2021 17:43: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 E0CF061CC2 for ; Wed, 7 Jul 2021 17:42:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E0CF061CC2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:54512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1BZb-0007JY-43 for qemu-devel@archiver.kernel.org; Wed, 07 Jul 2021 13:42:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48210) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKf-0000mU-5K for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:33 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:40978) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKc-0006sc-2B for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:32 -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 167HCGvc003564; Wed, 7 Jul 2021 17:27: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-2020-01-29; bh=0U2eUGvdCw0BPtLV1NQZj7cnxIgSx6ecLBDlbPZ+Nx8=; b=aXNAUiykxWFOQ3IS4374zIL5o/zBXSLWNkrG0gx9N8UrjSD3g63xFcoyTUzwKAKdAEO2 mK+0yBSYSIfwfUuHQ/v2nQF3eRPYXHB58bem8uTb76U6/X/LZyErIhc43ps/uwU4w6IC vDiRbt8Nck3KXBS0Hm4kXOHaiz5R4ZS1ZNIQmHO7fHCqXLcl//TM8EM5Shf4/lhdBEm9 EwQ7uBVZHTwK0azCtSItMXn1ZQUFhB9LOjYG3F9W7BE5X/6BO/sQITiXTLaxSTr5clN3 CYuz8DHYpASNe13DdRCTzzIbv6ugCI2XpRz06C8JUABij4coGQM9ZTqYQgecHmBMdu8t Qg== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 39n4yd1ert-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:26 +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 167HAW3Y053059; Wed, 7 Jul 2021 17:27:25 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam07lp2047.outbound.protection.outlook.com [104.47.56.47]) by aserp3030.oracle.com with ESMTP id 39nbg2je5b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iyen6ijjsvhxmMwH7c6iYh5oKX6GI+OHdNBVs0S4ATS/fnXucgckFypfhvj1rMVG7YZ1s5FYsN94TXipKukpqtDeL5lJJniLlu3HNwE+t0Cm4u99yDC/Q9kyuaRr3to5ClAhE+oNK9pvUQkxsLwz5QP5atU3laq+bj05LSrFs/hVjntSjdDxMBEzfFv6QDDALlMVhBtJTfrmsrbsD8xOrdVsVQz1qVXNZw29HwOHJ8CTo7Q3rZ7nETI8N2oBlcnN8zcI//RZZnq6BHgAI8f2uey6qKhWeWUer8UiwFwkLjPKffJjwK+7VOEcfGOerLGTLb5AeurXZWmDE64C2rMRBg== 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=0U2eUGvdCw0BPtLV1NQZj7cnxIgSx6ecLBDlbPZ+Nx8=; b=kFFrvPf3uADP4g8ujv6SlSj0u2i1QaR50oqelFDJ0gp47h8VPFFQDjEMKAAdRm2tn4ah0WevTIYG+v8OZpZHlN5EaNlaQUJxo26h60HnfeRiK5DJsLang5fzBGyPQj8CRKqbI5uBlXl1EUpwKICLAn56yn+nbsX2PPw3sRguDFrnv9WynH5upG35cHItG9R6xsv70rv19cgCyZvrfPf19JJMIVSVnY/EFaCWwJ18YO1hha4Pw/KIcYNIOa5RYL88sCXnGzDrwXtBdpVhpXEkcVvPci3aE/l4phn4OpLPNXG6e0VclSijzETT/qzQiveuOz3ctlVQG3aA3XOZhr2TPg== 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=0U2eUGvdCw0BPtLV1NQZj7cnxIgSx6ecLBDlbPZ+Nx8=; b=PPW7sWFopJwN0PxB6GGY7XmEMZeRURSRv++bMkm/tDPdq9SEjXMP7y9R4o1QVAaCalpP6fN4tTWtVIzLlHyaOjglM/TIdXef7WAH/aodWsPBZcmJ6Yn78kDLugAYXc1mJkdslZrjL0NTdAzuwMXqQ8ohvkx/DWu6qqABmEC3lZ8= 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 BYAPR10MB2677.namprd10.prod.outlook.com (2603:10b6:a02:b7::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.23; Wed, 7 Jul 2021 17:27:23 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba%7]) with mapi id 15.20.4287.033; Wed, 7 Jul 2021 17:27:23 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V5 24/25] cpr: only-cpr-capable option Date: Wed, 7 Jul 2021 10:20:33 -0700 Message-Id: <1625678434-240960-25-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> References: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) 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.13) by SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21 via Frontend Transport; Wed, 7 Jul 2021 17:27:22 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3c1cbec0-bae7-421e-bc17-08d9416c7b49 X-MS-TrafficTypeDiagnostic: BYAPR10MB2677: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1417; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MpbOwBO7tG0T8X86hIpRKHZ7XCA4YKHc29yu/o+e+z3PapMWpG5rh9NFUbOYhjIChfDf+4JhZTC+dg1TktOoPobUicFLfOXoWr2ARQ22UQcf5/rHEHgdce3lph03VoGAQ4ofFzCyjmasjU4x+MNidAIcuqWXwC0fJiIvd5l0WgoffUWB0iVTeNl5i8s6RQyCed9i1yOowBmRlVN8P7tTuboMZ23XFZwtu1UmPhfIxtVT4pkFnghYU2R96mb74AUCdUQ3wiaFZBPoq06a9CIzYS/rwfx2qx/10qdizWhklY6ZnagTrHqj9qfPDVAD7jB0neb837MaNp7NiD4NofeRfApKAfz8i9ws199gSyF0KW9Wx7Euoc67fzPfGcy/iMSPFfCwpOWdzOBN3NVgUIG+nKFRBSm8d2NWJdD8B/e/d86tdY+DOgJEQyZt9OkWfbvTwk5bXeDYAPV6E/Q4ktMXpidzSA6sCMHzN56ARSbgqLPlGzNKI4u7MeSmcPN5dmB5Y+7sFsekVxOk7R0Ond7FpoMlfwha7OW34Fstr/AGCb9ZxL/leEWteRNQFmXzZ/tRJGgs6+gNnYxeSIRkFZdGng2/eTGLXAYxShwVvgRkSN2VbIm4SvaZQbJ5l27h0wGpA9IQembE5K0smlYILWXhdCX16eFPZMANV02OUUcalGUhhenk9Ya4d3rx5pym0gxs 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:(396003)(136003)(376002)(39860400002)(366004)(346002)(6916009)(107886003)(38100700002)(66946007)(7416002)(4326008)(6486002)(478600001)(2616005)(7696005)(83380400001)(36756003)(52116002)(956004)(8936002)(2906002)(86362001)(186003)(8676002)(66556008)(6666004)(54906003)(316002)(66476007)(5660300002)(38350700002)(26005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: elT6zW1zO9O8xfegEGFGoZomYVCWoUQneonTD31x90dC1XZw6qx3sdXBAnXa+kri3Z7t6hgytuQalWUmNqf6f+EJv9oU+uumpkLi0vaOCQMEqV86E9tyGUpr6Jk1Q3GG0MmDZYOY71/Had0muz3HTVOEl1uGwD39wsJB/Qre0Dt0nIKZBkeUvKkiMgJzpvT48q4h02UbR+E5diYHMxM4nT6VtXoIkHVtBuQ28a4Yvd/EYtf3mIg5WkHplj7QXwdQhnj/HYuWiV+Ae6EMdGBoFPuo9ZpjKdJfqhd10SECmfaxofTI+qeyyFh2PhgWZCFgYfluwbwa5lCA7TWAD7bt6WbOgk7s0k+InaF3OX50JDXhvJLNui8+kFZDyVaUnfPcxHsynAwEsL0+TNJ9w865N7uKqAPHrZCORy3PdmJNKXeLJz0Jrwu7auGGqOS7Yc5fJZNXwEU8uE0GeoB6baEM394QbxO1eoXT+97UA8uSzP+WD+sXh4pPcfhc31/H96mde7NMEH0MJ52nOJYXPrWWFZv/TdLm9dU7c3I6Bt4TXjURCY83Niy8WjjrOO+W2IiV91+KUitpw9z5QxHXJlfCoEobm4NEgZKNnc7wIF7yRrqgUs+kkmy4MEE7FNpPlJDOXMelzdlwy9GRcsBxLqhVug+3q2tuL4noxw5BCZdIGTKU41Hg3QIaobNDX1TKpdaTdmf3imobgADU0An15MTXXxw5EzEB2ZcFold7es1ihhdZKtQDl01M98mt2rZ/NV6xvfiy17Yv4829id2PGm+jfElAgv6U95y+n4zreeHg+gZu+pmUL0LIrzmDGvxzcY4FGAmPhkLSaV2TMzgpn10zpUa9av9o2w5N069Poy8jg+PcmcdARwK5J2ssuPtGl+p75e+0EjZz7ig+SkTHE+jwYz4zZRSBtVYoVfk5MQLpBcAGk9p5DO4Pi+g/hybvNtablv0JrUTMkyOuptRw6D2tXE/FcVKvVHXVPc9Q8zYX5e9Z1Gr+R4Ptu5z9DBQGsWBVewUiNMV13tvhhBNKeBsSZJRCx/48JFYTcaa1eao57WnUGFayeMouFvO/9ayzpVphF6BxMVTrn6KyxJPuRIfWHXU2DLaupSQNfcciqF/EMv9TyXYOu3rI4rCvvlFkmgeclCHbkZlOjKgTaWY5aiaujKx9cxUq3C/PLwoaB9+g/gQFh3mNz9SAfWISJI45DfUF/SI3zTifKM7Ts2HArBjW69ulDIKXpA3OdM8XUNlShs8ccPbBzXjjz6BWXypnOyI/m3vwTn9EKSx+gP0dhTi7z6xbZ98AwPgsouCh88AXcM9z20LkkQVmPkRJoqvkYbOs X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3c1cbec0-bae7-421e-bc17-08d9416c7b49 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2021 17:27:23.1608 (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: muBuR7u6ghtDTY2INT2z3sCHKwJpmbzQt53GZQgaF9VcouEO/5Q2fk4273eZ6RYhPnLFP/fKapmaoBISGwe8TEnBQ621O06bwAwEz4cVTcA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2677 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10037 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=999 phishscore=0 adultscore=0 suspectscore=0 spamscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107070100 X-Proofpoint-GUID: CpypkIlqi-ctvZ5z-Dueeyku9cNZ8rTR X-Proofpoint-ORIG-GUID: CpypkIlqi-ctvZ5z-Dueeyku9cNZ8rTR 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 , 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 cprexec 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 | 5 +++++ hw/vfio/pci.c | 5 +++++ 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 + 12 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 stubs/cpr.c diff --git a/MAINTAINERS b/MAINTAINERS index 58479db..06fabd6 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2868,6 +2868,7 @@ F: migration/cpr.c F: qapi/cpr.json F: include/qemu/env.h F: util/env.c +F: stubs/cpr.c Record/replay M: Pavel Dovgalyuk diff --git a/chardev/char-socket.c b/chardev/char-socket.c index dc9da8c..c11ec80 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -40,6 +40,7 @@ #include "chardev/char-io.h" #include "qom/object.h" +#include "sysemu/sysemu.h" /***********************************************************/ /* TCP Net console */ @@ -1462,6 +1463,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 40c882f..09d5e6e 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -37,6 +37,7 @@ #include "qemu/range.h" #include "sysemu/kvm.h" #include "sysemu/reset.h" +#include "sysemu/sysemu.h" #include "trace.h" #include "qapi/error.h" #include "migration/migration.h" @@ -1601,6 +1602,10 @@ static int vfio_get_iommu_type(VFIOContainer *container, for (i = 0; i < ARRAY_SIZE(iommu_types); i++) { if (ioctl(container->fd, VFIO_CHECK_EXTENSION, iommu_types[i])) { + if (only_cpr_capable && !vfio_cpr_capable(container, errp)) { + error_prepend(errp, "only-cpr-capable is specified: "); + return -EINVAL; + } return iommu_types[i]; } } diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 07bd360..f179086 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -265,6 +265,11 @@ static int vfio_intx_enable(VFIOPCIDevice *vdev, Error **errp) if (!pin) { return 0; + } else if (only_cpr_capable) { + error_setg(errp, + "%s: vfio-pci INTX is not compatible with -only-cpr-capable", + vdev->vbasedev.name); + return -1; } vfio_disable_interrupts(vdev); 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 5ff7ba9..63fcd2e 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1247,6 +1247,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 d5ff45f..153dfe8 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -4323,6 +4323,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 cprsave 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 8a65ef7..54f9072 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -46,6 +46,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" @@ -2002,6 +2003,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 a50c857..9012385 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2665,6 +2665,10 @@ void qmp_x_exit_preconfig(Error **errp) qemu_create_cli_devices(); qemu_machine_creation_done(); + if (only_cpr_capable && !qemu_chr_cpr_capable(errp)) { + ; /* not reached due to error_fatal */ + } + if (loadvm) { Error *local_err = NULL; if (!load_snapshot(loadvm, NULL, false, NULL, &local_err)) { @@ -2674,7 +2678,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) { @@ -3428,6 +3437,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 2e79ff9..04fada0 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('cpu-get-clock.c')) stub_ss.add(files('cpus-get-virtual-clock.c')) stub_ss.add(files('qemu-timer-notify-cb.c')) From patchwork Wed Jul 7 17:20:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12363151 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, 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 6B22DC07E95 for ; Wed, 7 Jul 2021 17:50:56 +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 E40CC61CC1 for ; Wed, 7 Jul 2021 17:50:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E40CC61CC1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:44098 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1BhH-0002Td-0T for qemu-devel@archiver.kernel.org; Wed, 07 Jul 2021 13:50:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48300) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKs-00011B-6h for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:47 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:6856) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1BKp-0006w8-Ah for qemu-devel@nongnu.org; Wed, 07 Jul 2021 13:27:45 -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 167HCNlT029342; Wed, 7 Jul 2021 17:27: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-2020-01-29; bh=33ac1/KIJzNlxDFVBmbSwz4lG/xFXh8i0U5a+3z26Vw=; b=WWcGrBZ6roRsPL4WWoPvJKBuYh6DJxgCDqMY1ZQ01/aiKRSWDdoAcleZkyhJp5m/C6RM JtBJkY46skmzd/FsfNSB4IaHruTYTTmOxrHP58Pn4q8jlwcO2YhCrRJ7ovI4bTSfHLdr +Qr3M28wsrvdjANzxoTwiu96D4c3jyxj6fU35JciO6F+mU6TEAa8wAjXAs2U0iZZ2Rgs KuFvPDYf2JNuAuHAUYkFGD6N1yZB8pqvaeVx++iL6M7pUaAaIoZVN6RMmMCfCOSaqXsb bz3S7rEDvbczAuZCCYHrETVDMCCA7uJmPJUSAig5qjUoWHRdtw7vIgAno3txyyYy7FPB rQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 39m2aacpbg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:29 +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 167HAYvf155353; Wed, 7 Jul 2021 17:27:28 GMT Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2168.outbound.protection.outlook.com [104.47.58.168]) by userp3020.oracle.com with ESMTP id 39k1nxjvcn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 07 Jul 2021 17:27:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TFSySMRLwSXuSOzp9dkjOLl0At9k2AfaM6mbQpZug1EJ77IZJbsPU5ZEUeIh4bkGEoqweZhTliFzfDexspKePIh7OnNSrRAvLclPrvQq6gv+SlGwDk8k227u2jz9O0GfHLdKy9gt3xMz7ofLyfufsCk2YFbtCNBo6uw2vQ13L19Mc9ofxj0rdGoHRrkmsy7Cb1dFHw7qE2+cWKFMbrxzUBsNzMu6+GbwzjCKLedbJ3sBrzCGO1jJggdLnpbZztDRnj0/gXbAqF36wyUC+vY4ObLV1ILOC2kL/XL8/b90a4vKliO0tgNjJh9jkgTifik+kl9qXfijZV4cIGnfkfXfJA== 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=33ac1/KIJzNlxDFVBmbSwz4lG/xFXh8i0U5a+3z26Vw=; b=EUs3096Fe7CgSPpY/P1vtPhLFJAU0O3G8OH6EseX9IVwjBvAnJx4P9s6TBWxjCOE6pvokVBSmkUdOucmZluPCzXUBo/Ci0K3MIjhad4/9FNdAZzD/5xkwrtTqLqjdxwGRiKHWCOGN6Bp/d9KnqNJfPhqMSJvtAG1u6G8fMj0pOnBk0kSp4b0pKHMkeoMfstGjj6xwfkYfY3GIKepMM7+S0W1wQUKQGfdy4GQvnEOrmWvCn0ojI++cBQFm0i6xT/mCgzSsVaqOKDEik2aBm3v2ulOAxv1oSzAKHe8aOdodTxAjztrtJxHOz5oJNeCol0AjgbCsU4cks471Vy8d+4SbA== 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=33ac1/KIJzNlxDFVBmbSwz4lG/xFXh8i0U5a+3z26Vw=; b=ytfCXuok3Rj33/kfeJkveLeGA8eWgakAAxvIUtHsuS9lPzkmHeaDVEvg71bAUIG5gQbm2rhi6rmN3c42fPf8xNGjilWks0V9Uo3mACvwS3GkgWvoqPIdGsGt5pMRYLpCpfZ6EQ0qU/ZpETmXUWYC2FuuTX5cujqPP9vh7oTDuig= 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 BYAPR10MB2677.namprd10.prod.outlook.com (2603:10b6:a02:b7::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.23; Wed, 7 Jul 2021 17:27:24 +0000 Received: from BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba]) by BYAPR10MB3240.namprd10.prod.outlook.com ([fe80::59e7:5c8c:71fb:a6ba%7]) with mapi id 15.20.4287.033; Wed, 7 Jul 2021 17:27:24 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V5 25/25] simplify savevm Date: Wed, 7 Jul 2021 10:20:34 -0700 Message-Id: <1625678434-240960-26-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> References: <1625678434-240960-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) 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.13) by SJ0PR03CA0104.namprd03.prod.outlook.com (2603:10b6:a03:333::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21 via Frontend Transport; Wed, 7 Jul 2021 17:27:23 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 278e89b9-a1a9-49c5-aed6-08d9416c7b8c X-MS-TrafficTypeDiagnostic: BYAPR10MB2677: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3968; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fWR0LZGPgco2J4eCd2hVvJP+mvja0XvMoWfLtGsP0o3v73pDAYH8o0ufmW0biQWdC8Qmj2f4AJKHO4ydc9liDKus3ld/slPPlOlveI1c16ruLnxu/d1NS2ZoM0W6L2hc/gHPbGqh0dEjAdtJEOFbRRQKC8ia8kDAzl1qKqkSQIIpxR2nGwVnWSo1lwilb+TaNvNS7i1jSmjC3mm2w0twEyOVue3Zhp4Z82rjXmRPZWm/vsOfanatvHysB3UiM7sHOGLyEe3UI1Qvup9JkiVvowPWJRdE5pNoFXnEJV/2E0b3AS2EicCQnrUYNSIZ/3GWSluH5vB5nzx+6DgVDiuYO7+vUvyFq0Y1Tu7/CAuNGIrnEJLBRfTIq4ZVjnNZp6f2uAC/U9tw64xrnXhSCugWJ78O8S9gJYb0AFI5CvKpNN/gsmIBjvR+Ug2L8VCBrrO39Xm/UhiSjK777uLCXAPgnkLuwCxPHQovbWqM0RrxrO4RusJfZ6tk5ZBM0VZ7cEWvXnZLnpzOD6v/4f1DRkFvgr4qsAX36kpfTa2o7ii6eCuFnB37rByP+6Of+LWQPIIen1SEP4EbXR6iyGOidtMZ9IAoio+twKfMssQW6oDyqPupMfDL8AUqt3vkTXdu+Ism3HFPR1/WF0U7kjGH4b2brW+m5sKrP4MOYCFo9icT0hMfVbMrYL+8JnPXJmDPTYYS 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:(396003)(136003)(376002)(39860400002)(366004)(346002)(6916009)(107886003)(38100700002)(66946007)(7416002)(4326008)(6486002)(478600001)(2616005)(7696005)(83380400001)(36756003)(52116002)(956004)(8936002)(2906002)(86362001)(186003)(8676002)(66556008)(6666004)(54906003)(316002)(66476007)(5660300002)(38350700002)(26005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3gS4K4E6Ff/nY0hNHcKRO3HDt496HXmavqnxBnKGsHUxARdzvnXsveabbIelg/J+mxRyAvotnlP3SBd/ZasMOsqhyLSDeZJCSl78rE9ZLbw0fv71ZuEyMruo/Tvae+UK8ZmnPY//IlDQvVv2bgzC9+bu7LB9HK0QVQJv44mTzppQA9dCEF5nDKM20+4/dvdE3nnimAb/68c9uN68YdEbjjHw+9CKzlrlYnY9XJZpMy1FuZZwutq7knIKMN13zRpjcpVJT+TNNqBb3I1YOou9M7EF7oEw+c32qn7QV5Bx9HYJOhVAGXRM2Ge3m7s5s8yLQ+6f7egcDOiLsf9vLHw8Ni4+dIf2/07+A0Was+g3lNdHYioAzTF6S6dg7DJfr44HjAK/BANwvkrFwoOMMd3FmLmYwBW6IlxarZKj6bCl6zOrjWZQH5uCu+cO9//hmMu8XAysgi5dBsAW/y7Tkv5iJ/QWXaNSKtNpXfeBD0GTuxc6O1lagr+d71wOg99nuPK4VWXRUzrsAfzQ7D/dFRyv7FSRIGsZiqFLuX7iMMdsEcBKDK5PIu9y9yLYHO+LhEPElMXN35TcK5DTfqVeMGnYKfwtaXdusz5b69DNqsy2i6oZKJIMdE75lqu6DvsEhoUb70Px9Zjp2uH6JCPXiYYnCS4SXJPFotOqn94iJzlroNMAptYgMs73ofzkebcjfT+y4tSnPK8qJMA9tLmAfydnd9C3F2HQVBVsco9nyAgAA6q/BMX6CkNHPBo6r/OJvQvtquApJArtYVmjckuifmuU+0EB3Aqxb24J9iZd45RKX35lwcOt33bTeXUuYSXMszp6at9NzR+f06pz6T2gvZDNRqOWlS/H7bHBcfsAXzYTWHuBdS33Wz+3mbBblx0EQPcYXAhp1VQMPf88cGGacA1ZXzQIgocLlBWW8juzD4aBXXv/WVbxQs9Bo4h18S8nc15y7mEFzk6+CjRB0VDIDBiKQkL6wplP7BUoqxJl1ivbb4W7kE6wLWpY7aLlrDU8ZHEgmKu1uFLBDx91aCpRCSKdFfsn1hcxiXtgAa140zZyJmNA1MoViRGRaVYyPdINrD5+W/3cvqvujHyciBGlve5V3voXpMsFs4d4bF2ffvTr/ToOIUfU0VAIfmAS8zGNbivh61NtteLEzQyYz4iHK/4atDANzlQnKtT9qUeKL0DKatMoJ8W6pno3Pzr+8w28q76/baegHasC/QdKJ4iXHHNdSbTOOq3t0nj5KarGFJM2FmY2F1Ghj0h4OXtTTGE0i+i8/8MjB0RKryFy5E+Wa3bOXMSERf7W86DtC4qVa9ibUeHz7KT+wgPmrYM+EYXwcJ4f X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 278e89b9-a1a9-49c5-aed6-08d9416c7b8c X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2021 17:27:23.5816 (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: SiOtWglRFRGhj7a6NNeuLvaAZ3CvtDMdAMWHdQUizmQQ6lVDjCPdEYqgkLlk596ff8lvG/7Sy+xMCWYMOmZRbF9ucZ44baobxprbu1+hukE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2677 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10037 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 phishscore=0 adultscore=0 suspectscore=0 mlxscore=0 mlxlogscore=999 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107070100 X-Proofpoint-ORIG-GUID: ZhXJ4BP4svo7scwzWjznKoTMaOE5gAns X-Proofpoint-GUID: ZhXJ4BP4svo7scwzWjznKoTMaOE5gAns 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 , 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 qf_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 72848b9..ba5250d 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2901,8 +2901,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; @@ -2916,14 +2917,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 = qf_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); @@ -2951,8 +2948,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 @@ -2964,14 +2961,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 = qf_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) {