From patchwork Tue Jul 6 16:45: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: 12360911 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 686A2C07E96 for ; Tue, 6 Jul 2021 16:54:10 +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 CC31161C3F for ; Tue, 6 Jul 2021 16:54:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CC31161C3F 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]:60572 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0oKm-0002rF-OF for qemu-devel@archiver.kernel.org; Tue, 06 Jul 2021 12:54:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59304) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oJW-0008WE-1y for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:52:50 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:45854) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oJS-000829-Nh for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:52:49 -0400 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 166GpqJh030622; Tue, 6 Jul 2021 16:52:42 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=3v7mR0c/TZn+nw4f84C0Hsrw2waiTd9GFtctahFgwHI=; b=WvsaWIJidu2Byvpqs3a1ImKahaKUxEIQDCzNuF95s1LKV6tT2bVnCJ1MhEu8WQA6ciB8 o67n7pST3cQBZK0l9baXcKh5bp9NJ6yAot2m/fcnkb1Up16OqSBkBM7PzCoKDyEjrNBt UP4RzVeSNAQAPBz7bwCdYvy/e8f7j2SyShz3PSjV2EA7aWh0dE9zbkABO/dnJ1mRKZWo RB0JkV7gxvJWe+ZnPPemzb33Ts+wEbwfJhp+gRUygKZ0EpE8MgTL07YxHdG1zt3je7kx iRBL0quf8ZeaqkCarxCVQN23tNQvMz/qZI54OzsvMwRotqptpp29kBWfpnIEaj5A1eYv pA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 39m2smjaas-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:52:41 +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 166GoUNU084689; Tue, 6 Jul 2021 16:52:40 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam08lp2040.outbound.protection.outlook.com [104.47.73.40]) by userp3020.oracle.com with ESMTP id 39k1nvcpph-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:52:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Tyc32LtrNN++BmEv9dParFbemAjKgo8aqj+Y0fGmkrQeQTIMCPrFNnCb3EFAJobUnMY2z2MNFTYHtlwlUS9WowbyFtN5TX7m0w+yZG6b46wFBascngVMrN9cDDByPxz51sTAsZEAXL7YeaFJ5tZFMR599rF31vnkHhyxiaO+93uM+Hiff/PeeK2TVGqTYAUuD+QoSzy+b7WUi76/4DBONMKs7Ikggz1v2tyD646m1KX8qEYvJgFsRnUeRg4IJbsToF4S4zpzjdBj3i24KM18GYFoihjacrakgkmi+YcAvzve/vwsVpL8Gz6BvHlucoAYyzx5X4POuLFuG1Ld1W6l2w== 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=3v7mR0c/TZn+nw4f84C0Hsrw2waiTd9GFtctahFgwHI=; b=cklHtorDLgTottQ7wxG9KyYBPhduC+VJQPpK8MZkaF1nvpYyDDWcUujQ/ZIP5wlNeXW9z/4iC1AHcb1nNZ8+3yjmvV66BmnAkav2+2Bd0yrtNFXvGjNZ9Cl14MMeLACP1GjMndcA0KED3wujSd0/uIwf8hWqScPdhRwMX5VmtpzH0CJkpPC4YHH+eKwz8HTdTuFZLJB7MGF6dH3ji1m+AXmziu1x0h/b09dvQLOFwgEBzlS5cVTwL2DKvRIzUiwblhv04eCt/P9y+t2+bq0kDj1uKW4/PfBA8DHj8bfg1faCbI5YQcvWaGtQUZH0maKFh6g05OZ5rHzOBTVv4MQw6Q== 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=3v7mR0c/TZn+nw4f84C0Hsrw2waiTd9GFtctahFgwHI=; b=JaQSg2p2LU+XIgJY5UT2u1Io7vixAgFUi+mnIdu0NqO0NfRPSxazf7rCQrYpF2tx9ikqYrpOGNWcLvFbM7Ti2YWn3jO15kGnJbeOAOQPjgoF5D9jHhvUrr19MgrJ+vPWFJV+wB1jg1F9+ZQu5epDNhgM70H//89vSeM726yTFSU= 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 BYAPR10MB2982.namprd10.prod.outlook.com (2603:10b6:a03:8a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19; Tue, 6 Jul 2021 16:52:38 +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; Tue, 6 Jul 2021 16:52:38 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V4 01/25] qemu_ram_volatile Date: Tue, 6 Jul 2021 09:45:32 -0700 Message-Id: <1625589956-81651-2-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> References: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) 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.4) by SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Tue, 6 Jul 2021 16:52:36 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 67a0af2d-5c43-49d9-ceee-08d9409e765b X-MS-TrafficTypeDiagnostic: BYAPR10MB2982: 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: e7Qzkov1vspPCYwpMhSs8EBOf+bNe5GhE5J462DBYvLPXzXe5UKwt1Fy5a//3zwQ5eOORLBiTe7sfKmrAROkjMBMTvupoo+CLKhncDNYmDwg1LpCkgm44pqSGFS9+M55bJbQvJQmPU+tU6xRRCkr8pQ2CM5gGq/7Gh/7a8TkydS1JGKbXfIdOzDEZN6PcMhOqZaQ0cKQAmOGLkcdFKCk10qE2d11SPnD87g9RPrxqQwyBLsor2Yx/4GSr8TFCXKR6lf2VqJAwyyZ+CKXEFaTsLkh02bHyS6yCCcNIBBVAQKMkyWk41y/GKzCavKpp1YKQg0+2al52SQKrj6sTj8F/Gvjl7aa2XRF+B1ImZ2td4y7AEBseChKfjh/qWT0osgDYlEZmCP6j436ZYq8zFjPLCYRZNlyk5UUN073/DSJeE1i/UN5M+3oFZiFlKUQPQJ3TavkL0jk9xk24rN1NjxZisSpUPqqGDvkQZDCDWYKWYjritIlkjaHDbqrSk3iE/s0q9kbMfDi0scuqGCO/NEWPtRoFODImojD3z0yG4Ly/JJYW9AwQkcz6F5oHC+DBjtL+S6mpSyzrl1I5eP17td4w6smqZ/A1YipgzoPrzS9ECIrkWxDQqLqDVSbQGqrjTuUHoRggXc3d+1zbr6qU74K/lpPH7HzX3p6AN6EoTDJjqnMtC/i3XNEOvVSEbgbdEkJrsnInOhOBoFD9Y/T87sKIw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(346002)(366004)(136003)(396003)(376002)(956004)(8936002)(83380400001)(2616005)(7696005)(316002)(52116002)(6666004)(478600001)(26005)(8676002)(38350700002)(38100700002)(186003)(36756003)(86362001)(6486002)(7416002)(66946007)(54906003)(2906002)(107886003)(4326008)(66476007)(6916009)(66556008)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iVcfgg5SOo3ByGNTz6eQvD43PZ+hzeFwevgaHg2O0MAZdZa6Av9fVH+LLSNAz2igS/qNZQHrooHWtet9bQhZ6I64wUxqDh4fmYi69Ih5SICRDrRdMnRV0u1VSDWUBwxq1lk+BtscIps1BgfnxIme22+7WQC5sPanMpzIgkihAL/ETGgOzcm4Ypptk4qGHooyTQQwUDOeg035KeBZYR+LFtprLK99N4K+7jvP7+vJ9VfanaRxaDtUaSBLIo2fARnTjlLeASULYZLvcXh17dzNeFIj3scqEjkGMOfxZK6/cX6BYpsppJZYzV2CdFmA3PhXfVGee+mjRcwqD2c2M7LZZw9TkyPSMCA9i3l8FeoTy7YE8SbRQbb7dxw1uNtzaEIicE0h34UsV0NTZnRRSOqF/SuH5ijDim241Bxd0+mkKRMXhnUeGr82TCVwb0bbsle5qCtl5Iqk6AbY42fjoLCq9K8cavZ72UrbbnOSpq87jqbG48cYIr650u3903pQw+z/pb8Mdkl8Y7eXl4c1WSdWju3pYjXNI0sFnMkpMcZENGoR155FGqED4BaSA4rTVjE2GBfyPrr825uzxRn9CezlIWPQKeKxSXVWKnlkgfn5Dkq72TGOyG2QvH6NxGxRqcGsH72j/He1Pa+zrKMe6lY063IYyQJSg5f9DIuTdJSNj81v1lJfHxR5ZKMJ9K0aK0a0GVcMvESbr5Pive3bzBgxNqLnoPsqCr0ZnA47TeZeoSSv/eXgiNrHzDHzEf3akC64XO5PDk0T5dVhhLB6hG4cW7VMtlSSifh7mB0XlQiw6Ohse2pSIvSNOu36n4f/2Xhvjwy92HIBlZr014PNn0gfy5ncCcobGqxpmf3bO4MayvyOFt2wyr26zoT+9EkK1jugD5GGZbaZEDIV+gQrlH1Ff0M5uIgph6ZjE562w0jc7c03Hpqnswcjtfu2i+tciPRQzrBwifOT7fFUmiS5fd/wphswzB4ZOOZXpmS6R9AsFLsTtlYTf9ljMKZxkJPL1k/JkFWHOOZyYu2LCiUaA5H3/YuG58YqW7qWe2JZpI/pUAn6X12Z/k71bo1jnZ8kH+E2akEr3cVadambdzZi/zaaooyLboIyAjUavhOg8/67uzV6ViLL+41GRWJlG+47uxJZBS/6CXYJJRXEqBq4YNz3uaF4ITSsxOFCqRAiEroM1NraQP/8xMo/J7tU3kg+O7CclVH3mVGRLzYs/xHfGe24sj+XM3c/snMD/MxQllz5eW2iXIBo+mb18pRd2eEz88Oo0nz/AzJdA1TjriY21Lo2vh5RadqYotATBxTfqGz/nmG4/Pa7QJMcNlBOgI0SCeHz X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 67a0af2d-5c43-49d9-ceee-08d9409e765b X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2021 16:52:38.5653 (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: 1Xq02xSMNKGfSEPFAfEUCT2DGxVn8uochSdwAna6wkaXY6bpkwiuXA6gm5n2/8cHpFBQUl4AVYR/zKVowJh2dhcbaD0kyyMoGv27nTo9I1M= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2982 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-2107060079 X-Proofpoint-GUID: 2gNvgA4cKogaL0eSpQkb-M47lxX9o23i X-Proofpoint-ORIG-GUID: 2gNvgA4cKogaL0eSpQkb-M47lxX9o23i 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 5728a68..e8b71d8 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -2629,6 +2629,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 d4493ef..7197559 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -2707,6 +2707,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 Tue Jul 6 16:45: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: 12360919 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9B59C07E9B for ; Tue, 6 Jul 2021 16:56:21 +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 6B1B061C3B for ; Tue, 6 Jul 2021 16:56:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6B1B061C3B 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]:41090 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0oMu-00006P-Jk for qemu-devel@archiver.kernel.org; Tue, 06 Jul 2021 12:56:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59330) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oJX-00006y-GA for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:52:51 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:61950) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oJT-00082H-2f for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:52:51 -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 166GqBZ4003703; Tue, 6 Jul 2021 16:52:44 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=Y3v75j5hEvii0ehO1Ozh5SnoZ9rUZ5E/qmgoqrB9aR4=; b=NEFsU7QQD8+QlxPLCmcSARyJWwTHKsI0MEGsYuBnPE5Db6bZBolNmkTRQRawcDCS04aI iIOzEESRZjqJslPWhu93OWssrn9IBvsy6Tw6z0rpdxYM7q+mdcl5vf6IsmZhxeFTLrKS p9ljLjzY0DR4yAJlaJKdFXxZ7q2Gere0PonzZss87ck5JZMC+Tw03M8NCAu7773XCOPb 0VFHeR4XY6s84PDFffififgq+Tm5meotwcldFc7MFjb+6OZbqBGDtKNTlYWiIuQEwFsE XkLjiLK3XhOeZSJBdDSWpgXiJciyB6JiklNN6KFccA/v0JkVio/hawWrQrgOnXWJxCRs Vw== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 39m27hac5f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:52:44 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 166Go40n159172; Tue, 6 Jul 2021 16:52:42 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam08lp2042.outbound.protection.outlook.com [104.47.73.42]) by userp3030.oracle.com with ESMTP id 39jd11nfxx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:52:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UiGPbJIK/+wUdjzYxGpe6axc5TFNzgZONw7aGHZTQP0Rkikrh2+Uo3WFOc+doKG3osGNn3HHE4j+k9FkiG3rY4DDbGOyaioEBSsHyB0WT5novdLfW71RiVsmaF1kzY8m++orSsHMuk1VvXkAeWZfD4/yD0ynrBOb5dL/40Iv1BvnG72+xVo+qz9cHJIGigt4YS9FUort0/S5i3SSL4FYSoKlmc7wjlBPcb7UAdWPlRNOleHegL7AbwUNoMJ9Pbpr0xBCAk16iM28EyzfCMdM3YtogPVvhjDZiZeDnIausqXU0CdqCi5bRM0wBPR4WPweM7+LeOKZQI8ul6WyHpe/yA== 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=Y3v75j5hEvii0ehO1Ozh5SnoZ9rUZ5E/qmgoqrB9aR4=; b=VRaZIUa0YEdr3h4y0ZdkEBPUoxEJNfq8A+w78smJ+c74/otp27CbzEBegKwEdo2J5G4ljhy9cLvx8Rhjqm41WT7VceIL3WxlXWzemrcFS8tnu87mA6VP8jHHfKJP6Lt2iISqd4Rf5r7UStriUU/f/8e8A1U8P7mo+58Mm5mjXebNuvd/4APcWqvtGXpZSvmX+JvTh/Dtdl1xJZaRgFAJoJzyVKVGlpDbSwwD/WDUs6jHygQTh6NZ3XMM7KApXti6Ku9rGUNYFzfFJWEzZwzU4jLU6skrIH5uddmptOsvifkb7hanBz3s8ov5j4Na/XPfmsprfFP1CRPuz10c//IQBw== 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=Y3v75j5hEvii0ehO1Ozh5SnoZ9rUZ5E/qmgoqrB9aR4=; b=LqObNkeXMbhB3eHbNq/YLje68yu6ZOykLPr04Gxkpv2Of6KJi4iAMvQczaaJr5gc5Z1dVXbk+gf6aNwzkNLbQTxiNsOemplt0yAsB4/EO4aQWT/Ezy+AhyZH80OB0zqGSuL7MC6YdBIQy4C0WevXxJrtaXH3fWdJSIYdw+/GUTk= 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 BYAPR10MB2982.namprd10.prod.outlook.com (2603:10b6:a03:8a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19; Tue, 6 Jul 2021 16:52:40 +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; Tue, 6 Jul 2021 16:52:40 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V4 02/25] cpr: reboot mode Date: Tue, 6 Jul 2021 09:45:33 -0700 Message-Id: <1625589956-81651-3-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> References: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) 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.4) by SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Tue, 6 Jul 2021 16:52:38 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d8b8ac77-72b0-411f-b39d-08d9409e776d X-MS-TrafficTypeDiagnostic: BYAPR10MB2982: 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: vMS9UWEfA8vKJgmEY9MMp7jMhljrVnBFE8gmBSZXQhSkPx97/x6JiVkX5XPtJFzDCcVe36s4ZkDVX7ObQdjP2NGFZU+1rjC0TQAHwHOS7pkaGQdNi7XHs9r2sj+5ZsYcDf8n/rDweB0Z1aTHSHoudIvosLeG8g13j/E+eIivJImYE1wev055w9AIkJDeq1BI4uP9HGJJg1WngkxNfRMuR2wfBHEQyAUsHTRpal7HnhU7EK4tEVh5K6xL7va/bnQ4s6OlNF7NnKF+0KEwCY9pKCcAW42Plmd64vbIXmrwk7Gb0ExniUMFI1FUCRCeq4r2QCkr4LQdP1Mw/Bgdd620luKAZy6ntHAMt/TzMY4NVJa9yfycGKHFgQCbT87Jcvyg9RBBjydcbj1hQZK5XwSXh9kJE9q63MNedmUVnT+9b/8vIAJuIBIZk8Y9CCTrHZIXe+FUcQwkEBUjkgxcwvz42nqJcjAvoo8gol7e8+YL8rUgGkZtLTsmM7f0v3p94NYhVZCroicOPtCbbCDeCbGLeNKU8Oy8DYYP87pI58zTCHvYTOnJRphfZzjyVY5UWrl8rTKjzeRMiVG6XxaMKK83KZujQFFTw9Y7+LZrJJVJ9ZhUhsgiHEKTNr+9aUo45mPLLlJGQirWJI87DGrvhNyV+mJDqHUr7ul8rl4OqHnWvvTdnsPej2F7ojXFTQ8PvULe8cDK9TiR8bBRaVpmBHWwxA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(346002)(366004)(136003)(396003)(376002)(956004)(8936002)(83380400001)(2616005)(7696005)(316002)(52116002)(6666004)(478600001)(26005)(8676002)(38350700002)(38100700002)(186003)(36756003)(86362001)(6486002)(7416002)(66946007)(54906003)(2906002)(107886003)(4326008)(66476007)(6916009)(66556008)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qNHo4yaH37X85ifW6KGz2vPTFOnAV31bZU7vI1ahBs70mLhAMJHBx6L1s3Nnq/DlAwlwPFLqCJHo2keEQZq3tt0vh0hXMHcVg8a8hQ7L5WoCNyyMFU3cV9ciZBHy048RmPZ5XCHLBHUt4DmyVU5BIhcn4MHtyBdZXHZrbysksgg4V1TpJ7wPhmhALBeeLba6VhwJsGrwaIDX+nVw/bhldgX9ChDHEUYfUGCTP6dsJtiG8gt21Kv0FW9wq74MKAWmvzgkSOmCHjc4z6QpgxhOp0DjofVURzldNhfXOzWMULBW3IUPRJDQsJWMOvFPnCWqThLxzo+7UfIBOayaduey4qHMy0u+YTRnzFgYwi73f1R8PiVUN3MynIUrnQpQe5G/SXH5EXwtfh3SgQWiILwn1bcFrekM6pGv5/DpRJhDJHgNc5o2QXzBwihyHKNixbuhu9ctxEnqL1HKoATXJKNibKl+p1xB6o9M4mABYUA7y3GXYOdirCNyB/qMobcsfbadT/WJzjr8QXxck9q5UwlwAkLK/h4+QmLhJ4RPEfFcNBuNWKL5bTTVXcG7wQJzt3GCowaGBFj2hJ7UW2rbq1FrNtl+R4a7LcMtdPbybBtzQyXD7dc5ifNbE236Ss6E4N2N2tzUh4gNHMGvHV7UJFWUYzsNgyBnevwqwqX0X1+BB5gBJnBjGOMIYMB3dTsuKZG3MuAEG7E2fXCF1fpevsJpUAu9sZiFjbQgQxA/Ok2e/PLou19YT0gTnn1lmVYuU7ByxszeGW9Xc9eIutOKv3BisLyyMbbRj2a6LC7mcVzobqSBNbe9L0z3XJPWKMhOt+XAd6NCQee0zpNuCTtOJRZ8tJzH5qgRvTjHGbb7q4nPRzxdc0xT0fkKtAiBO+eCrSX+APa2l8NTffKywbDPeiy/JdMvMXw1WCqOv3j4uCh3ZEaSi7gD3sHAgu9brDnCcWtLK6zy2tDDxAKn7R+95qNkG1izVm8P9l1fL2VYAdS9H90vguhEhyXKEXazmubGDFqyO2OiOzbKhtoZOQLxyBtxzaxMn7l7HzaSXJC4ofE4859ykkSv53VXEeI4Q8S1oL3HCiT+Aomvg/sbZk34vGwchkKrI1VZBeI8jiMXuFngaNTZp1dgF0qs6qJS5zDyGEid6w2RMPB6c5jqzGmVw5HP4lnZV7dWVYmnryULjtepMWubijhPzNJNdek3XA80Q8xKZ2NCLSfnUosLRowkbwWgjn9dLpfFAkx7P8x5X2AQSRRc7Ax8jdA8tXmfNKY0wBkQsm1Gvf9/YNKZawboSBYKJhIt4RxxKqDEWlE2NTGDPT8WPRxa66qEkGO9I8DBqZv/ X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d8b8ac77-72b0-411f-b39d-08d9409e776d X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2021 16:52:40.3463 (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: twmuPvycmcL7XtY5exnx5iL1jC/NTULMy5+9urYoVuFeIrW7bBwt6cbnY6HtuRrLDaFqU0cIypyQbzw3mbEZVc4tIotDT59ZkYJM1hoF5bo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2982 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-2107060079 X-Proofpoint-ORIG-GUID: vpEFUNSqUcAVF7Z0VfaxYky7PZjg2Gpd X-Proofpoint-GUID: vpEFUNSqUcAVF7Z0VfaxYky7PZjg2Gpd 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 36055f1..d337446 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2843,6 +2843,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 3ecedce..c756374 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 ce8977c..ccb35cb 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 }, @@ -334,6 +336,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; @@ -561,6 +564,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); @@ -573,7 +581,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 Tue Jul 6 16:45: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: 12360921 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,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB08CC07E9C for ; Tue, 6 Jul 2021 16:56:23 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3B01C61C3B for ; Tue, 6 Jul 2021 16:56:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3B01C61C3B 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]:41352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0oMw-0000Gi-Be for qemu-devel@archiver.kernel.org; Tue, 06 Jul 2021 12:56:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59354) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oJa-0000BB-3U for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:52:54 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:50280) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oJU-00082T-91 for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:52:53 -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 166GqJtH028762; Tue, 6 Jul 2021 16:52:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=SMpTNDG2E0cq4AafHV3S6T8/ab2s5QAoSTHg7ETYiHM=; b=rWxM5tapof5WgNKZMGHhXlqd3WsDxe6UDZmJdBpXaIA6MYBea3DVLsbmquTJJlbUjM35 9C53Xs10FpbzgpeD5wHXRRIqU+CLzV+Cd52W7ZrtOKsNiEccLReWLpf/Ks94lGmcKYaL erKKI/NSEtf1UBoH6amW953FntP/i1LMa5AvfqjyVUUAOEQKOSz8v/nVd/b3VBTX16u+ tBTvhyP1ujyl6L+pn2zo8Jq33skMR1cfzfCCuRND0eOCPgWOo9HgtOuiE91eOO6f/ITh OfwFwJgOCfvJ8stT5c5h3DPiPT/MwiIpZCN2JZfjIw3Wy2VVtmWigGmPr8KYrL0yEstR GA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 39m2aaaanu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:52:45 +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 166Go40r159172; Tue, 6 Jul 2021 16:52:44 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam08lp2042.outbound.protection.outlook.com [104.47.73.42]) by userp3030.oracle.com with ESMTP id 39jd11nfxx-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:52:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lssEl8mAHkKJcznvM6HnaUggQ51MGpjh802X4pxXzD5SWLFA7ZmDNOSoNBZWAqH0i6XdBy1AhP8LgTZ5QkSjj+81dV7pu3Ma4UG1Dz0DfzFxZDAvfGAM8hxJ017bmxHh/5K4GyAnkaOxKhJStg3prB5kbMr6cUGd/gJN7wQJcnMqhrbDIQaWiE6GrtZSdU/81tCztmgTg+1eSKFUIfnGBzx5Zvx4V9EVMYKkhZqDRx7ZIFbmCpSv8g/U162Wmii8mX3LiuB2U5XIxN/AURp6rx+9xAOhDx+0BMArq6opnzckEiHKz6JRi2IswDjzE1Lafp2CZJSfDF4JfvVg16shkQ== 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=SMpTNDG2E0cq4AafHV3S6T8/ab2s5QAoSTHg7ETYiHM=; b=oBzvgROBLnl4Ja010cVEW4/MaaRHqzT/JKV+yFlx20pvYcH9qmaiHfpT5s/fXlyME3C+8/JdTjLwW0GycRzgR4GDc5lEG5V4pUIK0EtZz6uZoaXtHUppV84EbUFamR6d2Lkr6ScPPhdPK6tC+0j7ID2zY+omxjn1STzW4YfMABBcAHFBOMfQDTfDoiTt1h+uO9dcDoQ/d8q5x6e8NlRpwsYn2u1aZD48lZwQXzivt1w2RxmDm8EGfw16coyAmovDw6RruFZFPweXhTUbcbSNHChAyF3DHvBO2IuTBwezjxEKu09VvinveXz/29yAq+LoAVWkOtVn/+UJasN7qzvj9g== 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=SMpTNDG2E0cq4AafHV3S6T8/ab2s5QAoSTHg7ETYiHM=; b=h4bkeNRA7SbwieAJu3GxYVgzR1EllnZKKNK9x/s3EHy+7fk1wIdkvL6e3j3q8wLEf9nxaAnudiu4aKjGA4atm1UkAXcPzdhSaS9XDIgn/iaLMBE2Wn5Fw/QAknW4qrfSpiQMKASLTXYqCf9PXQk/I2594lxzTuhAAQRf5a7SDyQ= 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 BYAPR10MB2982.namprd10.prod.outlook.com (2603:10b6:a03:8a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19; Tue, 6 Jul 2021 16:52:42 +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; Tue, 6 Jul 2021 16:52:42 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V4 03/25] cpr: QMP interfaces for reboot Date: Tue, 6 Jul 2021 09:45:34 -0700 Message-Id: <1625589956-81651-4-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> References: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) 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.4) by SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Tue, 6 Jul 2021 16:52:40 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 68a903e7-0acc-4696-11e6-08d9409e787e X-MS-TrafficTypeDiagnostic: BYAPR10MB2982: 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: GE3fCKSKwjTTjIHRAVd3ZDs4dcFz94oQOCH++Fuh914CaWI3nxBTZHojwaNxh20V5Hwr2XCY6gGcwYCpFkNx+pNAe7nuf9BKDFAD88ypVjyN/0D+hLpnFaUvdXEACF+GBvgQkIEi5lEZQBrZGLSy08H6PgTaAGOS1KPcD1sjce54eKqFqO9BLJjIoUP1e4mPexorUQGpj+dHC+yF/PFeeUtePwM6jYelIwr+gAvIgwoPqKmvqYN2vQi4TLhSd082VP47u1elUUbjk9J7kMy0lA+YYW3PM9SjpvF0Cp2sFmF8pdSaq6kg5Oc5NLlwaAa5hOj6VMaLlUaLCGDmQuviVhz7JduvfOuk3RuTA+T9YCTaGKhv1qwkQxbRvgKvttVnrr2iuGaobQCYt4iN8Di5nzY5L17UV2upfyFAy+zjUvgzAouuhJek0DhU7kSJhX+v616qkUb6Fu2R688e+35rAHxzRtxxLzU9Kf7ih/MCaIL+8QLQAGc4nwoBceZBs9pUci4z4Ara2NMzDgMxw4/6lJtYkIgc7UsZ4VXFQfJUBn2f9peheIcjuUtejk85vfJGsFIFIsaoBqYTuK03qtopqYqbLT6ChArZGMt8B2pPoLmWITZb9HYEDEM+v+ICEEc5OjGcyACqb36BjCOrc8zL0tx84DjApYRDSsayQupCnyuVgbgxw6qQO+R01ROCz+BeDsIXknpf60i22kI0eU01TQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(346002)(366004)(136003)(396003)(376002)(956004)(8936002)(83380400001)(2616005)(7696005)(316002)(52116002)(6666004)(478600001)(26005)(8676002)(38350700002)(38100700002)(186003)(36756003)(86362001)(6486002)(7416002)(66946007)(54906003)(2906002)(107886003)(4326008)(66476007)(6916009)(66556008)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SN/hgQcRQA1SZEd8000bDtV2CvlDV4IJrnaWQCU4Qb+1yEDIsjLpo/T1WIVNvaFxkxLVuu0UkkyBGBOdQRQ2XqDpfUeYARHbiWywfqqYsdUpfIVz9n4d/mGqlhViEikyZbyWmmnKdPfiVVktlNKeG1R92XdaSXM+I45KBKv5P6WMemDOALi0DwmJ8NtiAFzQY881/N5mXHUGBR+iXdNMjPSlnODi9q/Aer00+fZBiyZK+uFV8NEeF8Wcyjx4pUkHuz+osiHZuzXyg71mtv0GcFfFnCVgcC42MPcH1gM+h+SDlqvoigo8Qi0KWWCAGUPud+QnmCTgsvMfhsp37pBGh1xbBTCk/KhLRKIvMNkwW2VTB6Fk/s/VB/UF3BLBcJRsA5mXU66S9nF0oLuXX0Aw7j9cgddWMMP6O9egMxGpIIiDGQl7BexlMv72JqxR6L68j4574NwuebgiMtz/1f4AH/9U2dAK/9UaB/I0lBWJ9J2z3e7KD3CBA77ygYyJM+sXuqcNH0OPoEKjdkW6zlCHuH9IsKli3xHQPmIkDZVTwJZ/SWhLmDz4RVUVp3tEyOppoMAdLIdKNwURVVwqLqulmfgJS15WQYsICg8oFCcDkM9SoiRDqoCXUEMrlPxnNAbZ7N6HcWjUy4eMUDih6EaM9AlUdfh1ch9lJ5OaKl/beaEqzz8GCYetPSunyEkjfZhayA1qWMbkVBOctJzoTAAi3mddnoCJ+E6mlzSKE6enHAUVfdYtkPSbzbEN+jB2AHenN/rz6QQPMSUP77j6eFIKvwO7Vkmk60XlXiWfvo9tNkxAkDXoyKtVv/NmF+Sa97oAT/p9yuK8zaKXfESx8ipSo9nLm0blMJkZb7+XxAeNBQMtE708xmyVlr+pj4DlnYGFWxHXywWhniGhVrc56U8THtCuSKqDyz+/doxRl3LuSzWSg2LeomH9h3xig1Q3o5yecPdD2bKyLU5g3TNPjBKIFRXL04ycJoQKJ1+JyzRBpU/5mc+nY2KG9sFfZFkL3v693DzSHPIMv3ApJau8f0iikquXVFpwxpaoucCvwksscbmuHv+iVGiinhfkQt2n9S9rQIevd9SOvs6VW28zBj8ag5xKb2N6tco091HUVhuxI0wKGgRaZIO2m+wO2wHWjqqFPUQwCc5n8Vg6HxdmF221wcyqrtMONUQkJRsLxJyL4xIBYcfVj0eFdD/NTSmw/y08SAHPV6DE1YbkCQWx3uiLD1vUQabxPYI/gFVCFUwrRnmKxkvaiDkMj6MlcvaJCeEy7zW5pkg7LaqdHRQ5ygaMl9WTrtYGZAEb6KXLF59yE4IOnEVDG/puEh8fces9Mx5i X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 68a903e7-0acc-4696-11e6-08d9409e787e X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2021 16:52:42.1253 (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: CZJW26jzd/F2Sui9eJr++vSI9MQCLA5Z6cGG5KX1GQ09RX9bNHQftIs2FUxmMBkqjheTvyNjrWT9lsq3aIEhGQ2WNHybfNhDBnanjNUqVSU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2982 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-2107060079 X-Proofpoint-ORIG-GUID: eHs8kheX0nIISBK3jnvdIBKiTNjQJydQ X-Proofpoint-GUID: eHs8kheX0nIISBK3jnvdIBKiTNjQJydQ 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 d337446..d4d1e9d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2849,6 +2849,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 Tue Jul 6 16:45:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12360965 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5799DC07E96 for ; Tue, 6 Jul 2021 17:14:11 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A5C1761C56 for ; Tue, 6 Jul 2021 17:14:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A5C1761C56 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]:36738 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0oe9-000144-Pq for qemu-devel@archiver.kernel.org; Tue, 06 Jul 2021 13:14:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59778) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oKW-0002jP-5M for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:53:52 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:26592) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oKU-00088K-3c for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:53:51 -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 166GqBZ5003703; Tue, 6 Jul 2021 16:52:47 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=6cGzFJW0zbMPR/3Ev2ElJmV1SpOsn9CRc6H+mQTDDG0=; b=qkQMvHiiXF/WbVk8IMe02Ty1x/E6GMjjBOF2oIJegrkduETApfFRn4HS/N7g8hiep8ql 236xCVRdYoCgCQhK2nBUY1JZeur0Mb1lXeDk5v+xYnWBAwcvO0XoPScDq3MpHAucuztf QQ8CzsexH9o4RGRJS2Ad0FECyt43yUo+ZWI9VlL6jIgIhjdcD30GPYwOchYNuaWZ9J3q kBLzKbg6FWfnLgGn9Cey/h/Jj9jFGQr1hG6ytVpY92RwNKWUjyKQsF042YBvGMwC8zYq Dic1QkAIgPyZp3rZwpCiy4RsbOaVvguGcBAD+5Svn1OT6rG36idSJN9+ZV4uX5MaOxym 3Q== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 39m27hac5h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:52:46 +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 166Go40s159172; Tue, 6 Jul 2021 16:52:45 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam08lp2042.outbound.protection.outlook.com [104.47.73.42]) by userp3030.oracle.com with ESMTP id 39jd11nfxx-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:52:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HA5LPS9mcUT9SCU2+IVU7FJjKKooB9289LOvG0sGWW3R008wjCrw2P8qrtgHhxBXiHY7vIN3+XIaRKg92JpLi3GUQxdovZeAjj4FYhevvXJYRXRgemL7TdunGU2uHFaj8u0IEiZZWNOLgMkE/PB/yWohJaDu79AUKQWf9UPvP9UjrPLUapvbyLo6q5u+GDFMsVe5vIk/Mack9/W7G0PmtYrhITcdRpIGKODr54nzdAivuhmGtdKAAfLC750VgLGpaWMYCzYRP3/xLaEbXOcCjSaN9l4+3UhQoDNFXC33Pps/XX3jcOYga2vOQr6OB3GvL+hoXJlYJMzqaekFt1mYfA== 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=6cGzFJW0zbMPR/3Ev2ElJmV1SpOsn9CRc6H+mQTDDG0=; b=XUhSW4odmJZBKAyPRMSaySrC4XgQk3VmNNH1yfKJ3TIbrCLFF16JL1g1T+uHU1vWuA07HuvpyAOZztWUo7sLJZKs7+KJ3wQnP9Vqmr5zrFuVbEawy1OtHJ1047hV+9z/TFee4tyeK7MFFKXseVAOnjkIolMHQC4hbpGBjEyxzOfTemD4Ze8BryjA7OqbrEvCRH2VtFXs9qzYG0zaQXx07CtbUSQJaPB5dU/KpJSlocis98RPzbHq2Y7nNgB9c2nHcfq1Cv4kMnFU8M6qu+jvr7Rlm2xdV88ZB+DEX7rAfC9aEgdazgmxnyjKZWSE6jIa3DbT2eTIkKNRM4SXjSCU9w== 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=6cGzFJW0zbMPR/3Ev2ElJmV1SpOsn9CRc6H+mQTDDG0=; b=BcFGsZ3nEXEMkzHiDpP/3MYZGgmmY8exiMvcpY3qPmWGulDoMqhaBucPmaNmFROzzAyQuxQDsY/gh8IjtrtkVc8ai7bA3fO4IVI1ViWhxJy+fCFXlA9VsCsPncBC6lhEg+DE4z18WXn+N0H9CLtxVyjyqdU1zTKPqIIEUiD4NVI= 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 BYAPR10MB2982.namprd10.prod.outlook.com (2603:10b6:a03:8a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19; Tue, 6 Jul 2021 16:52:44 +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; Tue, 6 Jul 2021 16:52:44 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V4 04/25] cpr: HMP interfaces for reboot Date: Tue, 6 Jul 2021 09:45:35 -0700 Message-Id: <1625589956-81651-5-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> References: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) 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.4) by SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Tue, 6 Jul 2021 16:52:42 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1f7d44ae-43c3-4f71-787c-08d9409e7993 X-MS-TrafficTypeDiagnostic: BYAPR10MB2982: 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: q5ICaFWSxkwK89IbP6NkvDaD7gdE7x6pYhGHj4PE6zg0CuYX+jK3rIFRnQRJsdcbHyfoIrlE5Cu4jD5npb6mqINy0l1PAf737xq+MCQa2mZqrTA2m1d7WtDGv3Cuht560Rww5fZIDxbBuYOAxJY0hCJXm7Q27tvJZR1/9coGn8CemPpGixHIFVNUEFWGtEHSux+GkuMst6bby1LkYPAHnb8I5qMHOApBP+sPgvzqBHG0HJ8JRg+42ANG6ujOFEHA1xZqH/bgg33XFAt2kwEFukhowxOz1lJbdf86QvH1SFMqmakuuk/AxVVYFxZJOxpIU4a7zHiDNr81QesXK4QKvSdbm3pdJH5LjXnU9CRhjIkBZzCKg4DvbiJU3UnAjPoOPYOL5ig2T2BiFA4XUAb/j5SedEFF1QugsiOCa3wl0hRG8Foj5Z9mDufuwdGe5SfpGC1XWG+mNdJLTGBOHdoNUAd5THIrgnMQ3B6a9ZBAJVAyjO+hj5JU/pcw1eczevYmOzv56NAC4QlXTeeRgLraUO0kBYIPtNglGbDekj0ZTuysNuCz7RZBOBJL4I0ZAlHzfCLzrot8YN1gGnd4hxzoOGKrshUyfa6CCwAINGgFjUJWLMeeZJj45TqbCbC+Yhyl0u8VM69vyxZoIBP34VkXsPVr14Vogmq/QBdN4xR9ac9RjeT1tK4rjsZJt+Vb/CHSlcdNik0yEnxN3WPf1sWKtg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(346002)(366004)(136003)(396003)(376002)(956004)(8936002)(83380400001)(2616005)(7696005)(316002)(52116002)(6666004)(478600001)(26005)(8676002)(38350700002)(38100700002)(186003)(36756003)(86362001)(6486002)(7416002)(66946007)(54906003)(2906002)(107886003)(4326008)(66476007)(6916009)(66556008)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FVpmgn6VVgMZS5zqnH2V8T/sFFOPAMBB8OH/NJeSDbOwVON9g+jbferEbXnXmG0+C/yBD4UPd36PhDLtrQYnuUGWq+SjA55fslX2zq5WZi7qRY6f5k41JGyL1Co/Yk9IWfJfINek57zk+6LVKitQWss6MH0Zxa7I2I+lfERb0bwEGDcF8ZuMIB0tgCO0vaF8vkS/flafo29sD6jybaP/Mr08yIlxONvXSEVPQn2tfwG0PCpMc/EkCL4hPbmmuIEeoLHezt0S6h1SqehrWDVWVzJlGdbeifa/orMqnSPmutXD/f4IOWpsK/YXneabFWM72Y+eO/NljYItqaGCBQxJGZ6JX+a2GAgbKDNtFxwVz3c8rqF14I7UdIfa7E6M/CGVeH9hL/ZZUsYIUFfqhVepYZotZd+gNBi3rav9VdqAn+106omsV7nxFRSc3KHo/Gwt+mQsk0TTU3zUfeFdSIZ+7G3QwfNZbrptNV6i1nxOTJvnxIqcFOilaGdsTpJYPLsIXnoylz3aPfKLNvyf30brB5rCEUHhNMyWJ95vSVick5Cdveea6bLWjliuM0ZEPx7l63RYFIg+1WUVj37N1LUPg1EqwGb3ycmuFxFCiJNm1N9zzHp1DTS3DDwRSQpBeR0Ju2JNAIfiebea4ElRehFiOwVMREBbUGdqYgnx5S/Rvmz2btfDu9Ib+aql8EHNTKABQxXLnfU9Jof7MtwcLzRBRn6qOpLeBuLi51/69EgDPngUUhmzZfkuhLfEFXERZyrR6GZQtcTOD1hBizqKRXGE6rbiIvSS1Km0QMP18azdFhIUPgQ9hi5Qkz7BtjJkkAe5P9HrvCppY7W5ga4RyywTtJ/Tp42HpjBaNRreOgkDF2lg3qwqLfU3wr4sVIr/IHf/3zsAUQoYiSdxEJsvFSTTZIbkZ5ToE2Rw/csnFXVzyqcsnx0o5TvB345eFeSlbdIWX1BGY5lP4RRXX+dhzAq0f1nhFUYCiJ8eONhPRD7z1UAsvUPhfsZ+hRs3xQwJEkJGy8BmAZTnTEEPF9qBmMj/DbQGlco01n1E33HNs8Pez5/HTB41kMZUp1z1VtCofL/7cQvunXiAEjqGZlMFROzBk3qMUz4alsd5E3aW0UubcXxV7WO0V1q1pSKj3eW9FcjKYqtNKwALMnNHpR6XJGZMgsYwz7Nk/0JGbmiq9oF5G3vVAw4+nQHSH4PthTHwYaR4OER9FBOn8Avq/+QWtJfWuEoji/T82WTPUGnx1jV2Zj2ohwa7d8VfPH1UAwvoF0CHNQAr6Fh3yYRUnWiqY/darFrOFSRdxmXTYDRa6LrYn25IR+5dASKEFwRh5vPNpaG6 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1f7d44ae-43c3-4f71-787c-08d9409e7993 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2021 16:52:43.9373 (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: neav8aTDeYocRel5hbtY2Jjcg2HLaVR56CwVymt2+8j0BuhUg567vO7yAfbInEo7r2SJaOWoyTBic9xBP3aD4NQNRc652NPdWTbMROggD6o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2982 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-2107060079 X-Proofpoint-ORIG-GUID: SgxzhBxJDbQtoF3T5Lz83EnqB90qr7DN X-Proofpoint-GUID: SgxzhBxJDbQtoF3T5Lz83EnqB90qr7DN 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 435c591..015faae 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 605d572..e4ebdf1 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 0ad5b77..e115a23 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" @@ -1173,6 +1174,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 Tue Jul 6 16:45:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12360913 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2F05EC07E96 for ; Tue, 6 Jul 2021 16:54:13 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9A4C261C3F for ; Tue, 6 Jul 2021 16:54:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9A4C261C3F 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]:60942 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0oKp-00035t-Qz for qemu-devel@archiver.kernel.org; Tue, 06 Jul 2021 12:54:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59356) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oJa-0000CA-Ax for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:52:54 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:4048) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oJX-00082n-Fq for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:52:54 -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 166GqBZ6003703; Tue, 6 Jul 2021 16:52:49 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=74qSSjbCCMVD6ygfQuj+B+R71E8K71xsjFCPAaUs510=; b=b/L8gSQm9+c/QUgg0xqEZpbRCbNixVcTKWohCyUhFdG7QXVkh6FzxAnpP6JaQNVXVpoD EMEj/moRtAR8sYtoVyesuGNfJyYHfc9xNX0U6BWIkJcswQ5PdCU+4lCIQCfcgOWkTbps ATY1kdYS36/W/TZg6hFWCquZLioxtaH8kLOny2gBxzzQE1zLLxi/ViA9JhtgHOB6DlVm zPFYASYCRZWemtiRxsQOZKTL4KKktbB6hDYVyDF7eplFK0CbaJEigP/XBPP0OMtyGAlV 8gLfC5LoCmjwPTorQoxKFSaABPbtL1VWm3LM82DppCPw2NdlNMAQ5lG9UYqZELKnSdIJ 7g== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 39m27hac5k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:52:48 +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 166GoIEv012589; Tue, 6 Jul 2021 16:52:47 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam08lp2042.outbound.protection.outlook.com [104.47.73.42]) by aserp3020.oracle.com with ESMTP id 39jfq8vj24-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:52:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jEYogTb1Eyx3csfYWotp0qH+8EX6IUe8teQfpVjHzy5Ar+i7S0SGGO0PB8mmbOaRfqelDJ1dOQrMZzR9nOjxmZLDOlazb20QBKAoKR6ppbyqitVrWiITkiLCY6y6urBqRmvhmhh59jF4gTzljUJcd9Hr1LYCnNWYXXjkb5HNTJi5pIMPWa8GwMTBtzLGqxvzEOYWbvDi2nDYKB9fRa6zHht9CGt/J2zSQDaH+BqGKdu5YcjfYKsGpRgLAaMqVomRKsr6GoOO5g2rcdPzuTtQOTj8MeM1eE+dcqw4R8L2LRaqvrYO+X0ZTfLfE3b4e0TfyXpWZcMoVpizWQX9P/H7Zg== 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=74qSSjbCCMVD6ygfQuj+B+R71E8K71xsjFCPAaUs510=; b=M+NW4ewCn9Q9CY+UtgVGzJAvQ3pYz/A/PDdzkF9ZuK7/cdVU9ui3Icgq0IA15msHiA+DzzZOI2bI0wenkLnbWMpcKYgWgFZF87olhoA1UQ+n9Kbb/O5tRYDUBPsdbTjL0PRlKFjIjepDiHZwTHJFR6Tt2S12wXlyJMjyUQBIbXFusedgKD1tNTO7baXUgFuQwPfprAH+qu97cpd4OdnTFvku6Janmlv/QvquA5Y0GWfLa02hNnrL/rhgijVpKQioydx1LX9MiGS4S+zh5QvjNGQA1oFscmIxsg0kdgXzgWFphR8uiyremb885HVZUQ5fVWOvDTkssU3ipdaOPKAFiA== 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=74qSSjbCCMVD6ygfQuj+B+R71E8K71xsjFCPAaUs510=; b=0E8dSvIvHTc4DxgooEeo8Jcy/JuhJILIYhEvFNI7ugK1PvG5g9LR4vrZXCqENsfLl2OpYKpH4hJibnJV/Lj8akGoTqejy17XWpQTNMLY53m+oBh3vKdImYLxEEb1lfqVo2df80pu6lOxn4PZUnc29JONDW16hfuz0VazXzMS5uo= 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 BYAPR10MB2982.namprd10.prod.outlook.com (2603:10b6:a03:8a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19; Tue, 6 Jul 2021 16:52:46 +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; Tue, 6 Jul 2021 16:52:46 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V4 05/25] as_flat_walk Date: Tue, 6 Jul 2021 09:45:36 -0700 Message-Id: <1625589956-81651-6-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> References: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) 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.4) by SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Tue, 6 Jul 2021 16:52:44 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6cabf162-77ef-4914-4256-08d9409e7ab1 X-MS-TrafficTypeDiagnostic: BYAPR10MB2982: 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: sfI0OkJtdMR4spFSI/gGb2HLOh0KOT3OG69Vl7tGqhM1BbZKcxYm220i1k31nHIzMsPnXk/iz1k1NzHr2i8kvnl6vMiJoMEdae6pmnci6sMyAW+ezesRRuHKrafD9wfKfQeod2mKEOVZq3aRaBby4UOFTlYrR+gipDe+JXIm0t7inTtixyOKrIFLDXOJ+0B76IGCILlfCy6KRN+NIoOLcqq+fv4YkifFH9XdSzAnDccisw7nS3ogq3zQ0R4jDudZmzmgN/EuiwmYJBIMOi9soiosj/FULl8sCOwaLKZeStHp3dwyv0qePzpT9BUswMU23bac13KM/Orh2sanuOUJnxoxC6ZMb79YSaKxorAqWspn/77yPkIce9+FsWfk2plLdaFp7ANdTQCJIMOMWrWa2iOq/dLpfNjL0wbtlPQqaM0u12VkKf8JiPB+m9NoyTk8Kgvj8xE0pAdbZX/iJSoJDdSdGcEKoBMJfg1Dv5ns1SzelbXZbfdUNeERf/C8st0reHSgcv/wjAl2JJsv6iKMfWbtounsCEw24GtHUASXC7sMjT0sNYDHHVmIoCIomyJHjLpfvmSwkMoR62A8W5jTbQyBa6QBE0IOjKfkqHdMRcOnc3SzV19fR03MuKccR0e0lPF+dtYfSwZV9hvMy6tZgT8JgH40kmIN/BkTIjJwBew7lnIOqIhg7FNzrZLf+oXmSaTaT1rSS2zespQSLe+nUQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(346002)(366004)(136003)(396003)(376002)(956004)(8936002)(83380400001)(2616005)(7696005)(316002)(52116002)(6666004)(478600001)(26005)(8676002)(38350700002)(38100700002)(186003)(36756003)(86362001)(6486002)(7416002)(66946007)(54906003)(2906002)(107886003)(4326008)(66476007)(6916009)(66556008)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KQDYX4NBhUJdwzHhJ7IIBE1veU7VYp1yaqgjgt0EB8+XTGF78PFC866dUaSXOeykMlEF51fRkjoJLltxKRSivNRWDh6J02V1YWwotK25fQQpDnnGMj6DVAG/VzltW7U9okh0Ptm+chFVxSH63KUA0LtJl5Hi58c4g3B2fevHGKmY5vkI8nA3J62W73Gx6KCzOEHd1PxhuMRFOKOOfAvR6BJOJC55Od/emuNGsblEPQTBhWl4yAc/NADlrf2J4cmJs+FQOBDaH7T45Hd8hlVsa5hxFV+U9gXVTAn/nXCf5QxXcqmbf/f/z0j7V+w2WeXyzBBc/FZbjk+qcmkmhgrP5Ayfdog//eYwcBYbaDpYBJe8s3z5PO/djc+27yv/tp6w2XBzSxxjVqF0odBOxYJmRe/tUELEN8l9CEGLRmb8tHmDFKD+/LgEhRlf62FQkOGU/kvF4Yjy+7dMJbNT4z3ABDes4tq+w9Rm3BX0Aj4nqrMo2i3WYXrBGa53pA2rXFwPuj+p/LIJGP2yc5G6SNcsy02XR5yx3J4y4icfRaGYKc4AzlSF5KrRohBOrJjbiFLInQt+OpflJh7IYprDJDX3jvarahfIO6UjuBmV3ek/5K/2i3R+Y986pCTda35lMFKZzY6/yLdQ5xEPc79EEyIvFO6j3QsFO1VhAUr4pFoGZBqY2miHW9WoUXwhLIFKp+UtO9F1sWWwAxbG2zk1n3Jbas2+wlMTcvCehWOAm5Ojr3nPSLdg66tMqcRO32e+FmUxJRv9h2RHMmx0pSPCscCowTR61r3PyM9JFNQr8TRnsuCOIJTqC+kkwdQ29i3IbDQthGEVmqFcSWS5cKUuo0W1qWwIj9381Yl74X+Vv3iRrLp3aTrO3+HT1t0hw+FYw7KOj+xFiSAiYCyUnwxzCpnrmrZq5CauCFIHUfupwIq4iP24L4/+fuIPQ12dha/EunyvWUe0SkNSTEE2JgCPFuyRKj4kKmI64/8Cm0f1LB4+X7H21u3XLBnewz5xdyYJyUwg0s9rD874kob6wlevQiTN6CJDzYTGzgbl6qzpPTlb6yjiD701uAzzgbpnhmXhFp6If0GkihYAKTrgvyuL+0JLDhcObN1XFYd7Z/Pi38l5WTpVYvE9UVU/RGwMHASICt008/5vcivjLsMfMNITI9h4l4FMJKG484c6+nqwd7DuJUnaUPQknAyALxMkpDCOgMjRzI0qjD3/bN0EqhuoCjlS1BKVRNWhenMbN/qsiTyPlhitfnS6AM9nqu106O1GiUQGd2c+Pswrir/9YOYpAKmX+/wFgm2qWhDKDdbOxA6MWEPAVOxu5CJmW4UbCD2O4hHN X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6cabf162-77ef-4914-4256-08d9409e7ab1 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2021 16:52:45.8492 (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: vDnMVjXhMd5iQz1013bLjQJS5ByURbX9Kbf11fdikAqLB3HKCt1+AN+jExc/aFwV7enb1jsdP9f4FBdDCT4yijZ2oHhadK919oBQuIHo/gw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2982 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-2107060079 X-Proofpoint-ORIG-GUID: pXkFC_vWbNJUge1R_Jd6SEs9Rj2GqACk X-Proofpoint-GUID: pXkFC_vWbNJUge1R_Jd6SEs9Rj2GqACk 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 e8b71d8..d87c059 100644 --- a/include/exec/memory.h +++ b/include/exec/memory.h @@ -2003,6 +2003,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 7197559..b2d5092 100644 --- a/softmmu/memory.c +++ b/softmmu/memory.c @@ -2570,6 +2570,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 Tue Jul 6 16:45:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12360927 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C410DC07E9B for ; Tue, 6 Jul 2021 16:58: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 577AC61C3F for ; Tue, 6 Jul 2021 16:58:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 577AC61C3F 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]:48748 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0oOz-00059F-IH for qemu-devel@archiver.kernel.org; Tue, 06 Jul 2021 12:58:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59378) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oJc-0000I0-HV for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:52:56 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:8016) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oJa-000837-Gn for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:52:56 -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 166GqBRL003724; Tue, 6 Jul 2021 16:52:51 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=N+f3B62Uq69OXUk1DnFhmpdUjDdZh056FJ3uuY5Hj7Y=; b=UrY6tJreR0JdxQk6+nr02htxLCWz7QroUterExiRF3BJFDZQwPhAZaT2xQdkJchNlkkK eijotgavoH/iTeGDHF3n/CdEQ3no/BH23CI8w+hFwXPbBi1sf38Ypd7sgDi8Ag5tJRgm PG5VXsqr6DK10L7SLVV7enF4Y5i7IieCTQSWlJf9+xYb2cYKnPiW3rIpfJ7YKSfr5T9a dQP1YLaWVHqTFWhrpvl5iUWue0y6Oo80u9a+0EOilYmqW99UqFshluYKyUY22Xi+1eOe 4VOqVLmvbsS84bnRBucYiXbRtbRwUKWZk4KfWS7Mp14TvKmhMEBljBaDSdllZVXJJ+Yl rw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 39m27hac5p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:52:51 +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 166GoTNd003614; Tue, 6 Jul 2021 16:52:50 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam08lp2044.outbound.protection.outlook.com [104.47.73.44]) by aserp3030.oracle.com with ESMTP id 39jdxhgbmk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:52:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q+S3QDD+Wn/v0lI9WM9qcb/4EKq4nz5jGap+8d6qe/Z9wibH3UUWrzQZbJOWsSga81I4j2FMy88FwNGQDc8ZWIivlieduNIOyOK0ur5NkYFizQ3jD/xbfl3gU/e0vupLPkCqdQE2o8ToMRPsJ15v1XTFkmVA9JFU+r+iLWSV+X7O21CiInAv02HOu93VE3aoCFWqHdmMLNo+TUx2I1K1KPlXdWEdDqbjNdC54ZDxmlLIcu/0R+nk/MPs6n9lnyv6WjBGWAeRs6WDpaV1E9ZueYnPiPsa8OAtTjKF0iRAg6rTd21bqHaAlhlpI3hNykRNOaUxIRdVAgYqFKiImzKeOw== 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=N+f3B62Uq69OXUk1DnFhmpdUjDdZh056FJ3uuY5Hj7Y=; b=byTD1W/PuG8BqCfV6B042q2J8GsVvUp92XDas9vARj7+aW+J0bo9pFVkDKK/EJsVme0wJv7tXoBNV8v0pdVwaMKApqTJ1K87R834WKcggeQQY0lM+9Nx1JfIyIHCukbYab0R9mWt6b/JGaTaRWl0Sdbzj5p8wU4BVvgYkXtDedy/SyUCwPmAGSPdJ1iHDlREfyJbh1pi0cWGcxfd9GnpAMhe1B6rv/8OoWgD9yW4chbi1U9urlNWLJKe0oMQtoeajdi2zCMVhhlk2tJLze41NDpcLk8psuBQ0S8U4ZpzIokAFW4xoKEjKJ6xpunbvIrOp/LHWsv2Zt585EyTBGNpSw== 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=N+f3B62Uq69OXUk1DnFhmpdUjDdZh056FJ3uuY5Hj7Y=; b=HGD1TKNrAC5dZVN1Y21GVR3I7ysxJ6dXG3QreHWYSP1/7Kgxb31JmN53GJ4tjLtzggsavjSK9QX1t3KuGl4f/Qsr/M2q1D0l4MWHI0EtVW/Q8eLJNPHw8ZPtjkAFfsPI+kdDlY/XvonmRa800oBio7APRrPEBqRtAgu2hoQ/jnE= 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 BYAPR10MB2982.namprd10.prod.outlook.com (2603:10b6:a03:8a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19; Tue, 6 Jul 2021 16:52:47 +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; Tue, 6 Jul 2021 16:52:47 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V4 06/25] oslib: qemu_clr_cloexec Date: Tue, 6 Jul 2021 09:45:37 -0700 Message-Id: <1625589956-81651-7-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> References: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) 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.4) by SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Tue, 6 Jul 2021 16:52:46 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 76a8fc8a-2d5d-479c-e999-08d9409e7bcc X-MS-TrafficTypeDiagnostic: BYAPR10MB2982: 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: 0nLy7lkzHsOvSQEJGod0y4xAuvNymiMRs4rWgqf7NnRAxNpz6vLA4DlkBdEOHcqJKtqSr3TzNo6bIu5yZGeILUxgH7tV63pP0uG12oUnZhXM1y1rch7DxRnaTeonqdBZeXCLoJ01UY9bp1SBt/BB0yNDo0SD5+MPFSLM2Z5zUtrWt+bBpS6PxJgSo7St5VJx7wg1MG2cz+UbOprfsncIg6gc0fs9ei/V+AJKea4b/XWk9mhshw38E4qG5HaaBye8Q2Fs0eKfeuglAPZ9Vma0U0SEzvTeu8QjEDeeIMGGlvPMj8EJ7xQi2CsPhwyQdtA5ONp0eJNngLceYUoaJ/WvJTEwADl/uc2Z8p1jXiFjq9Tef7YeGe3sY4C4FBiTD6saSiIVphijC1Y2ZOxCJSMLIuYEjF4CNzEoEYP3rYwKP9VSPsuLsgEiwxlkgGKUBCFSyE2PKyZ6UhCIvw0NPqUUkWczrgCCajHnaggHogDiW1rtz60L+Q1gNes3bVvRLmVQnC3IvdP9cvq5mJghV9sQ9FHB26ixDiJOuOueuF0aSW6ZPE0z3p09Zcjn10Ra5BO8d9Wz1ABCeMoVBdO7Oocx9rG78w1r2LGDbnKTjBamhdV6QpmMtspuqdh/Nuul8RWFnt04aKnthhSiDLpoA8gMs2qOsrRDKHLJOexKw6HykMOUZMDKdCUc8W7AB55ailjSNTAxKLXKUwU2dm9ZmKa2Tg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(346002)(366004)(136003)(396003)(376002)(956004)(8936002)(2616005)(7696005)(316002)(52116002)(6666004)(478600001)(26005)(8676002)(38350700002)(38100700002)(186003)(36756003)(86362001)(6486002)(7416002)(66946007)(54906003)(2906002)(107886003)(4326008)(66476007)(6916009)(66556008)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TX6vkmQhsCIIjnKr1wUtjdoRbU4J4hFHmXpILgj0sEK79fZlb5AwRpG1JoQaF5QJCqF4q55yJ1GZcw24k4ryC0cnXUQnz4I6ulzdUONP1WfOqJbY5vO2AJs9s3ED6k5u6TWDDqVwoft9Tg9iagzgqNiKzQCFCHu/kxPI3lLeuVSIMVoLQ7Sxc2afGUA1vEobr4yUO+Dz34s/0Hx5uuhZkhbENnbmL3uZF/rpIcals4WiNxHyozDi+S4Mfeot2P8LA+xuQa+sLe66kOCryPY8gaVGvimNZtFJJzRcsvfKPTPNNhw+30wOPRYwhLAmh67qfPE4ZOCNQLsHXMgxABD+BDmqiSM8kRXv8ApQsumIK47B+YnX8w4vODIr7gXEyBuGIhvB8VsM1bm4o8Xj4K/dWSex5UxtT5D104N+/mwd8JrHNqMbSFvw2bPuizoL060QjxjKjW4UM2M5NUJkIc6PKoI7VtmEG1hP1g6IYo2srjg4D6FgpW0LPJ2bO4zUST8fN1MDYabUSe/BBUoUGRus7Eqy0BluZROlDo8BD5wRWy21v+/PPyLt8OEfIpWUlXPkEvMRzsYmaZ5OcV4PfM2YGFk/Plq5cvc9wu1xwOqEWcfK3ugVVVMz0ZvP8q61rrGSYOBm3JfPhxhCzi6U73G0fWaX1J5BQbJ2L1w/ocFoq6Ipp7TJwOu+3QG+s9JnLZKuo+3A0jCJSgMtJvsoqnXZZD0vFixoGljGt7AyQAfcI0lSaTx+uHILAtJLnc4Li+72Yu4wiDZLM4zyHGYYbnr2Q0RurN3FShouJx9cg4q15cENYgTK0UNEkDyq3J9C1m4XU2OateWq3Vc7TybpLrZkDvf4Au6ITlQRdMequHQ+b1Q+sVs6GynBTiTqA/KLWMcUdJCnABkxX1LVCnNKMl/KxVul+V/306Y/zhybiM8Kl46sUHbDDTFf+k/zn9cXArIcO1kPMzJ7rNozbU4h3Saf2nIXNWZ0p+EKtaia21QHMcmXsxYy/h7U1rl+F7g6vRIOP/5Zq+BoL4oucggQNFVjBg0cVLWX3fQt5d9UmA03+jp0+AquIHOZuW/7GedIWrhGA5raGbF6oPn95conf13jS26zdrGiBnJyUD1+H0omjCoG4fWgUCGO8EUUGj9PubM9ciJ8XTJ8ihzKQ6RaUB3BFAGcSGfxtMo/PZrFlIM7UlMbqe/LhRA174EV+oNVqHyKtOps6VXXcYajYt1bhfwOlQcTnUSfjjZM+CZ8XVPlUF2XPbK3Tgvdc9QBhBz+OBDZtwZws54+p0SRII5OS3t4KbOJkW77eGkQ/JwMYuBd4EGdUFX8VrwrrbmMhMvFqrvB X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 76a8fc8a-2d5d-479c-e999-08d9409e7bcc X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2021 16:52:47.6762 (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: faZitj48k7mHbSj8SxtsMaGrM8QvWwj96P2Uf+kWieKtShEQKd8VPPRkkCDvSibzTixSIvyZk3yTSZnlg0janhqwrLn50ZzTd4+Nkzv5C4U= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2982 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10037 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 suspectscore=0 spamscore=0 adultscore=0 malwarescore=0 mlxscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107060079 X-Proofpoint-ORIG-GUID: mGQd6HFv2RAa5UfHL48KLLH1HeShsWGz X-Proofpoint-GUID: mGQd6HFv2RAa5UfHL48KLLH1HeShsWGz 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 cb2a07e..de06e60 100644 --- a/include/qemu/osdep.h +++ b/include/qemu/osdep.h @@ -577,6 +577,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 36820fe..ac9229d 100644 --- a/util/oslib-posix.c +++ b/util/oslib-posix.c @@ -317,6 +317,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 f68b801..b5c53b3 100644 --- a/util/oslib-win32.c +++ b/util/oslib-win32.c @@ -251,6 +251,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 Tue Jul 6 16:45:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12360915 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5DD5C07E96 for ; Tue, 6 Jul 2021 16:54: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 1684061A0F for ; Tue, 6 Jul 2021 16:54:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1684061A0F 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]:35744 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0oLR-00054v-4D for qemu-devel@archiver.kernel.org; Tue, 06 Jul 2021 12:54:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59408) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oJf-0000U7-PX for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:52:59 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:12144) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oJd-00083S-3C for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:52:59 -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 166Gq4aw003050; Tue, 6 Jul 2021 16:52:53 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=p16l0WPBMG4jZxEyxo+4hfuLsJ7gQEWt4ArQ0Bp4BeU=; b=JbsnlIcMN4huc5g6V8TQ1yr9ND8P5QZJ7sMDhxNXSQLsk1+6CtugZ6Kk0JI941SvAjeG 3rDDzNHYXA+czxUV6CGg6lSDZaW144YjK9rLcVon4q2TNdOcLzZwOasgSEDJM3DLss9L cHD0PzmzBtnLSozopBgMyivtWgYXbPkHlftN8q/0pFvn6ctOE2/REnAKzbSFOUZbnkGD WchpzkyygRNfvk9hrpKidYL5DVJ6or8MASKWdG11pClhLcl2Y3p3/tLk/92oUKGYf8/P hna9zUFkf90VX3eGOmttEyyHEwasu3iQwEeURo2SOY2ohltCboXDFe59GSs65Mu0I1on YA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 39m3mha8f7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:52:52 +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 166GoTNe003614; Tue, 6 Jul 2021 16:52:51 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam08lp2044.outbound.protection.outlook.com [104.47.73.44]) by aserp3030.oracle.com with ESMTP id 39jdxhgbmk-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:52:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ET57Dwy3ZcnTTOoAo1UnP0AqSFuXJEOFvpZnyJHCTKWajvMQUKqbxtQqiLifG69FFLK4RwvVtwu9yl2kqQekff9xii5YREaA/2yJnoLUrSV9b8EkMUclZLEu00KNTb+RtjQETu+eZQbLqSzt/lfKgah0PtBHL9qnh+EGURjO61BbmOmiumzfGN1efaiqUQH5diXL9BS7+qvo1s8ErWjXx/57ybMXRY2CGq2F2iL1dS/s0X66/TToHcYCHZhWePKFuT4g8zoDWaIhvNg0+Me+iwJZKhJc7XIWvG/qyTJJfBaSyB5uUatAVn2tImG2/Yq7CJdbFKmB5MkqwoS7XmR0kA== 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=p16l0WPBMG4jZxEyxo+4hfuLsJ7gQEWt4ArQ0Bp4BeU=; b=BHMg2vAS9POz/xSpXhAkGVzsV/17MCY2wcyBDNIhvzmcXzLcs+9e9qopoomC9E0Ve6e+Z31B03o0irTV+CRVdIOH9r+8E+Z/XI7zgCmZfAEqQgLvWbRciRh4mkW9/VhloNTz4+LTBEbKLDC32bd+apCKQ3R0rksKDTv3S3/td/9qjBWy4nLXGF4p8Fip2glTqhL+uTn1zwFrEcA2iOnciIDkdNPllLxtTYMia1fYAT18fiUeKxPzEBiYt0F6VVTLmCwrFr/+/0oLYslIx6SpdfWOS50y3kCAJ0ZJ6vdNV3pe3TZcFlfBnOUAUOr/O0MVSNjgNGxnQVE1tnq8daLPBw== 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=p16l0WPBMG4jZxEyxo+4hfuLsJ7gQEWt4ArQ0Bp4BeU=; b=zTzslgqtjBNeBa/H4jqXnVfQF/OBwrheScpwsLJPnVjQTsQmiwEbjtH2J6M5qzcRQp1XIo4PTOjci0KAg/WTAcb9q3xSyqRXYReTP7zG2xHdcVd8x4x0O4abe0AAXn2FDCXNob02rhGOioYhwa4IhzMPkhE3FLPAPby2V4rvqj8= 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 BYAPR10MB2982.namprd10.prod.outlook.com (2603:10b6:a03:8a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19; Tue, 6 Jul 2021 16:52:49 +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; Tue, 6 Jul 2021 16:52:49 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V4 07/25] machine: memfd-alloc option Date: Tue, 6 Jul 2021 09:45:38 -0700 Message-Id: <1625589956-81651-8-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> References: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) 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.4) by SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Tue, 6 Jul 2021 16:52:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bffb18db-b062-40ba-0db3-08d9409e7cf7 X-MS-TrafficTypeDiagnostic: BYAPR10MB2982: 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: hjiTEA4iPSLoiQFKf1Ka4dDx7v9jYhDsy2gziHqMeGoFGN30j5mCHo/LA2pEehsL6hJHNgJ3m/0KuG/cWatd+gMF5yJskmSSnbiBbBxhU7bn8Xsyc48OCHheOa4Moh6wwushx+uyRu6fmyQVlvGk9K4vuYJOasnD/guP4waChdoQiT97Ck7QGDTK9r29yZl/Z2s42RLlgPLwtLsuvUQFwc0v2jTT0F5lB1vZ4ABdgTUZQ059Mr0jgCmmGx3H0BLYxHV7taA2w9wQMGNtQblnaq1KNXCMCGSVMy6AYjX8NWh4BcJcwMtTUXGISEGUs6fAi3seOB3KZjYBYFjEbFgcwSQLkhBpjQfeUnrQjuBxTwwsaRFanAj3Jz+N6rJI8hPqaQxpb5mKuvkKneS7ZASXMCtN3vSws2gctVz3sOHYluHxla+pb/bD0SJA0cQf7AnoZxBAe+rAj0XdQHgTV65GT52aThe34mwh1V6PqlhSRvCFGbt5/u7aFMsSI9qOZWhnycNyHRdmdq18cYlBSt1b8HhrTrNL73AHIvvEQyO2/AAef4LzULR4RUM7AKsc7G13rgV0nXOIhu8UjFx10tUiJqlvY9uIJwyj//d6zom0m2/CIm1+u9nN1o27Ty2JxOLkLsSMDowDbEyWSA/TkmKmHNBhN0MkiwmLzuklJUhCTT0eBp+XNWfXQ9+1hklNJPWq X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(346002)(366004)(136003)(396003)(376002)(956004)(8936002)(83380400001)(2616005)(7696005)(316002)(52116002)(6666004)(478600001)(26005)(8676002)(38350700002)(38100700002)(186003)(36756003)(86362001)(6486002)(7416002)(66946007)(54906003)(2906002)(107886003)(4326008)(66476007)(6916009)(66556008)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: awOAYNd7Cv69SVVe42SbsXMyVOjjCnqOgsD5ovW/EOWRBvQei+8WkAqBmqjXosY8MUVlnq8KZYxS8uW9omhfjlMh9Yu4cUvdfk45z8C6lvl076WW6s7uJuMd9uFUx27qGtmdzBBSgpU4OjwyGUsw+3UrA3bo3fK7LBv8tTBsBp2h9Noqd0Tg/Yj4Hm81gPUyzWdSUBc1dmTjvSgI1yyP5URN1u3lEwW13WUNUFIje6I2ytWVrNveCvsLYx/kAQukm7kikms9h1vkNTzf0Q642we38TZllqIehmdlQMs/veeIWidTiYboORfd19G6rZfIhAE5YRp91/HYLhVOVEEIrZmitxb11S8XeKR7kjozc+lx+eR+t3d4GMBoW8ABo6VxTrX3Al70Dcwdkez6c7Rf14pfmbavg7kSCv/J+EbvU6qjMFyCG7Eg7F0RIlXSCman0I7qd5g3h1B6+Sw/Ye9oYH1MrUG6j9+wUhkT2W6KsPONn2Y8YeruVBq7CkkEUTqrIVErA0lsT92LzhsuBcNrdjfoi8cTTb/hW8LuLJBfh/wB+y8Hm1OpeQo/Ti8tYBKNAMEl/Nr21hsiCWxwudxfnbvTCd/B+/oLyAcJ8CW/eQiKLpdpzUdIjJBBZDKPO4paAm1OLhPYoGt4Ihmn7F1TIvXLKWGJqeeURVf2th7D5WmUEmOB4tcUz/wDbVkHR3GHxpR1T0GNpZgcpXaWzM60yTWPS6vHMrJmPRblM6KhsNjvxfxffx6w6NBE6Ko7Wf5L4szpnfT1IKYaA9U99SCVSY73cjgzB4SEvegESBdhSVj4cNU9bTyhoNMATgaTvuse+iHvKopJNZFfxAP/a0WALxC8rErZOmdkwJ4hI7ne6QcXXt5pvc4ibXDrKWJgvnb7CFjcU4OO/MxV9Bandv4xNfCQflx1z8IsdxnIUi3wi4PlQfO05M8Ojn/nUo8ofCZRNGe0raJawP23Hvf8BZ8D2xmP+RH79DHiyV0XyuvCwrKfS8PNsfCBOGvMH8jtcnv7W8IRO/XQaF8hPDJCEZBYA3qOwOcC0w/8g0fidVzcsGnPBceJ+P/p/ufYJrhZN6DT1mLotljozTYE3Y7oFHFIwLYjzWyBr6U18wEHF8MVtaOPwhxRnYC5CaZcadtMhTyB3BLJNRSwQv8Hl04N2uN1DgZuQRQW2gwKJJYs9F/0LXVkvT2NeA5Q2oHewj5OoGxVYHwvKERa7wJn6dezvydgmwEsvgnsqj4Kc2m0Ogd4JCH/2i8RLNdd3N4RMgkQfypJ/p0XbMy62ArKTPoxTg/JbuAtc/EjKy/S2Bj+svo9j/RY+7oB8jThTpFKCCuH1X8m X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: bffb18db-b062-40ba-0db3-08d9409e7cf7 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2021 16:52:49.6481 (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: rLLsO49uMKCtOQk7IVLoo/eDD+6Ak/+2luD+JDy34lR4FncF3VhKwE+H3QB8naP8wRzXyLCH071pJT/UVuwo2veUkVf6K51i1W7L3ELjSX8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2982 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10037 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 suspectscore=0 spamscore=0 adultscore=0 malwarescore=0 mlxscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107060079 X-Proofpoint-GUID: S0LVfLJjjsEXoWBHJD7D5-Gy_R1FnVyy X-Proofpoint-ORIG-GUID: S0LVfLJjjsEXoWBHJD7D5-Gy_R1FnVyy 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 | 41 ++++++++++++++++++++++++++++++++--------- trace-events | 1 + util/qemu-config.c | 4 ++++ 6 files changed, 62 insertions(+), 9 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 40def78..3ce5303 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -375,6 +375,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); @@ -858,6 +872,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 ad6c8fd..dceb7f7 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 fd21002..3392ac0 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 85034d9..695aa10 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -67,6 +67,7 @@ #include "qemu/pmem.h" +#include "qemu/memfd.h" #include "migration/vmstate.h" #include "qemu/range.h" @@ -1931,35 +1932,57 @@ static void ram_block_add(RAMBlock *new_block, Error **errp, bool shared) { 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); - 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); + } + + 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 ac7cef9..99e8208 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 670bd6e..135ec3b 100644 --- a/util/qemu-config.c +++ b/util/qemu-config.c @@ -205,6 +205,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 Tue Jul 6 16:45:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12360931 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8719FC07E96 for ; Tue, 6 Jul 2021 17:00: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 220CA61C4C for ; Tue, 6 Jul 2021 17:00:09 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 220CA61C4C 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]:55234 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0oQa-000111-8b for qemu-devel@archiver.kernel.org; Tue, 06 Jul 2021 13:00:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59432) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oJg-0000Xa-OQ for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:53:01 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:13540) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oJe-00083b-21 for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:53:00 -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 166GqGfl003973; Tue, 6 Jul 2021 16:52:55 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=NyvYcm5yWnxH/0ptvdnMkvwzCcKKLeTYdU9GCrQo5bE=; b=dJxHV+JeXmXjXFvDSMHI0u//vbzjabMcDdWxvnvZDNgJHGM1IUEwnIAvq7daxphtxDhk eao+C1iMLIclUL2DLnyoEtt8h6ksC0IvllbiHLtD7gmhnCBhf1+u0vunUt0AQJpuJzk9 kzTZ1yO4EQPtwosXbfJqmb5eDx2yYWjE1S9cJMJQJw92RnN6t0wuq/nu5puFv2R+osBe QvfXs0p7RgGWfZrmpezklRTiPxEQ+5XIYtItyS6xREkpTomrmrs/X5Sxr2x+LmoirQLl 3GFQGZrZQ5jKvaHYQuuj7s9CdMuCCPJlAQIn7f7dRe5iXW/B6W4c/ryKooOgq9WyP9lG 7g== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 39m27hac5t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:52:54 +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 166GoVvu084749; Tue, 6 Jul 2021 16:52:53 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam08lp2042.outbound.protection.outlook.com [104.47.73.42]) by userp3020.oracle.com with ESMTP id 39k1nvcq11-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:52:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gb2c1tAVJcsEUmzYK1Xgw1WsQNW/Is8RYtf9wxU+PA47FyhMZ0YJfgAhAhkt7x9xB4UZvpSgDc4/4LajcTPIwcejLtO7kjGE2LYiZyOn+81tsk9PZ99qI2ywSGOzk0mYt67whUhc/W4v8xyKRgAo8Zem1jiaoehPIMRIzETM074x1iKmv5BJBvoutZdY7CFoTB8S6RGt1nRbcjaxTqVcR5bQD1X2G7gtiMdcNjx7tfWErE4ZesUF8PTEjJQCprb2YIQzmY8C+Vgy+VH25NlgXhSNMKaYJiiFvusD9L4SJPrRuxZisNm30oJGZxDdF6Zs6clsaXuin4gaHp/TdscyIw== 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=NyvYcm5yWnxH/0ptvdnMkvwzCcKKLeTYdU9GCrQo5bE=; b=E91OhG3zxbj96W+jvLcDzldoB0wGPcCL8KuB4Fqv8LMbVnTuRhIpJ+MdsJmp5jRD93JHtZLZq+FeZwlzsFOyyn35sa4hRFCfTITWFH2pYyWJHyQULZxO5iUwme3T6UttiS8bZEcLdbwLE8LAvZ6WhNDh0lNk/DSqulCMjv7QpcCj4mHUXS+NV5aFVvNETuh5eWxf6fErKXgaR6UjXRGAedQopTnGmm8BYa/9fX7FcSsfGXtf8/FctDIbT0g+ACyOI15TFaRKS+0DAPUJSxe+VpHCVghvXcifXEvPmdGZ+PX0eowrTiM5eORZePLJDoCOv4CELTCqw6VJWkzfnWfZ6Q== 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=NyvYcm5yWnxH/0ptvdnMkvwzCcKKLeTYdU9GCrQo5bE=; b=Y6zKnlSo/CJ/MliQkBrBQ53AdyzFWnVgoOvzwICtGhYLytoyI4ySuzofEHjyleWbY02iQCCaf7qwTVQYdrb4YgYw4YA+UdLA/JbzJhhXqALxMfk5EVQ29Nnv8VkDU43ghK/W7TnYfowaH+1/Is1972PtAqBu5hEeIIVy/TUOu14= 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 BYAPR10MB2982.namprd10.prod.outlook.com (2603:10b6:a03:8a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19; Tue, 6 Jul 2021 16:52:51 +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; Tue, 6 Jul 2021 16:52:51 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V4 08/25] vl: add helper to request re-exec Date: Tue, 6 Jul 2021 09:45:39 -0700 Message-Id: <1625589956-81651-9-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> References: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) 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.4) by SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Tue, 6 Jul 2021 16:52:49 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3a4bfc95-041b-4156-ee8b-08d9409e7e01 X-MS-TrafficTypeDiagnostic: BYAPR10MB2982: 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: QGXElUH08q41NZeZ4ko/yvySxTi+Kn4+BU/VRJ/emgrldQ81nMauY8wZJkEDa6m1vSYRsyHNOdafnSZA7w5A/OMlPy7oDtb1fl3HFdJVJswsGMQyllUU8wTEd2amb/6Z2wlSU2IH5SMnitDaVjgKHGxH/k/ARNDltnhz4Y0ngV/ekXmQaPPX0Qaw5i72Czax6jGMTCo4prtDMmYCIkCKpTNcXMog0H4Utv0gtu14jVt/0gUtbfoO0/yPBdUYh0zwln0jvOt/L5sgtgcLVQIi1uBl/X6HoawLrbk20/3tFJ9KKJ7EPtsc7BU1Jy1aWbAiNfeBv9GxlB1NiZpXxu+0jsiKbRPRwjaGbs1UepSWhTMAUaiHnrF0V7rZBn73MmkJbe/At1VL/LTieQjzDBG7PyN5qIMnoVDOCL9JdgaL1U7yBdaCPgl4R9WVyrLBWs+nAAMmMAnF/Eo7Xr52rOZ3YLvJ3bIpFk+hXyaEVwSF03UuMpBNjn1EISoDi5C0sf9Nv2pHWyN7mR5Ty+xpgfJD+26fGK1WEe2r2MqOpr5fMGL6DZwB3IIRHT0IvD74o6Na3w5jEhKqyyjmfC93FBK7961+aOY+orOQy8l5/k0cUjbE7jyubVcS++OrnsGW2zD4iVDv6bg0MomLSo0WkhXJpwe7i+28Zcx1w7o5Z6OdKQ0l7fLIsSMJedJ4InroN8OKcCQPGGukX63trwdkRfv1oA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(346002)(366004)(136003)(396003)(376002)(956004)(8936002)(83380400001)(2616005)(7696005)(316002)(52116002)(6666004)(478600001)(26005)(8676002)(38350700002)(38100700002)(186003)(36756003)(86362001)(6486002)(7416002)(66946007)(54906003)(2906002)(107886003)(4326008)(66476007)(6916009)(66556008)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IeMQ1fX7BTqnqKrQO6op17PozRHg/xeZ3kTdpvq3kxVPMYcMpjrXK/QWFFuWOpLsMX6uMjVbszt4zf9nYCC7H+mcjcwWKyYnJAPsqSR2TvYyJzVxfl0Zt3C1oZIYEiexgL8Eu6clXjcwfGn8HpzFSKAigXSMiIkMuG7Fo9N6nFuZ31KZ/fzN9Osvgr6sbVYy7ws/sCkSkZB22WLOg00H955h0/UvjfkX2XgVbRyZakOVz9MJdjfqDJz+AK91tlqirxKtYhiPVNWf5MfVv2bPYOV3DmwFOEQWFA0eYLnkn5CzywFC4wT9yh3fWaWFCSFKYJvLrUf65grOPlcPvD/TYd9H6ht1pDbvGTlcuEO62zKTPCnANvodroePscmMlO13jPyk/vVVhFJiWQXCLwtLBXXm7AE6JeJxRCrHt78/v/+gcpZGyZrgd0EPkKlRZC0kik6wLY2hgGLK42oxWDhaZ4c1C+hRhDHfKm7JHDSF8ZZ8lf/XVR0CthvxNL1iItql52w7CC2q8XCf2eiFlKGkjYs/CdxGwJB1rRiBD0Rqbi4ozWJlsUzwVFpvi/yi1nhxAwNFSZ5+t/jlSNSvDYsbFImWDpTo0LrzlnXeqsjXbTB2Gbh5W+/runM22MTalPXZSK24xBBoYv7VXsWSS51sqm4o5GHK5NnuBW3RrsACY9JYjSRC+wdqCdscKCPyPr/42z6oXaAgTP7kgBwtj871nYg73WYKjLqf1aW4IbzuGnmMoGdFooOBlOV6U2MaI2ge6fZUCqiesbd5kJHuZ00xGuqbM5TrYNgOMsG9kC92QCzJCLLZeotapn7vj2IHClb1d6haisAY3E5PrWVEC+4lAgKdbQNrpwmLL3S+iYF3CF02lg2J2tsGUzqtEpVHbUbpD/mmejATv6UpQ4edtZ0huh26pPSGgp5l3D+37STj5ZUtBq2/eBpvlyT5p/lc9ApslA50znWYt/UCCUpM7lf8b+Q3jCLJkyJesB5AgEmmuW5DfDUzjrAIhKUe7U64amKU++a2gPUy6NfKC32XfKVINg6ZrFaS4zvdULP/7OxTxb/uA5gG87/0x9MUhxon8ie71MH9QOCLp9WbZ6ysxWipC4JmU7eLsBx0Hbwmjechi5nPsKXJda+enJztC3lCD6iMjsF0mZYo3DoF3/qkBz8KDp9op3PaEcWXVNBUtmzJHmA6Qc13XcDXbaObHzJPrg3wYDcjTPZ/Hz3HuVPwLtegwiOrWYppyNrFgRv55oS+RUmD7uDxonaHcUaGRQHbJz/1ckyoPo/jzsSz8g7aCYMX4qdUbVrAv2FtwWATBYgchyV4IjU29zu1PoIzqGbRDf1s X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3a4bfc95-041b-4156-ee8b-08d9409e7e01 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2021 16:52:51.3681 (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: z361ad8xjrdZAJVfhByPO+RfAXweiDG6Q1JdMm6EHybZGC7ZWnLYHNPt8fTcFbSD5xzSNzXDH9ulCD88I8qOFpNjuwOpV4FQsnwJH2Sk3X0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2982 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-2107060079 X-Proofpoint-ORIG-GUID: mFXG2mL-U_06TZyM6ZH1fO4o-2kksBp1 X-Proofpoint-GUID: mFXG2mL-U_06TZyM6ZH1fO4o-2kksBp1 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 ccb35cb..554dfc6 100644 --- a/softmmu/runstate.c +++ b/softmmu/runstate.c @@ -354,6 +354,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) { @@ -370,6 +371,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) { @@ -644,6 +650,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(); @@ -692,6 +724,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 Tue Jul 6 16:45:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12360939 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F0A7C07E96 for ; Tue, 6 Jul 2021 17:03:35 +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 222AC619B6 for ; Tue, 6 Jul 2021 17:03:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 222AC619B6 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]:34166 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0oTu-0005l6-86 for qemu-devel@archiver.kernel.org; Tue, 06 Jul 2021 13:03:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59440) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oJh-0000Ys-HG for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:53:01 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:2810) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oJe-00083f-Pb for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:53:01 -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 166Gprlb030637; Tue, 6 Jul 2021 16:52:56 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=wxWwt7seKD1nGteeB+sXrAEUdesC5+4O/U3S4dpdz4c=; b=XTFqKU0Qmk+Z1BIhSKImfndycUas6cNL09K1/dmC1bdoJ8VIOB9EgXrA+slv8XqcwapC XoCr0M4F/AkC3HZV9gzdo6rNI9RRSmQykg+4tutxgQkgpjFLM0IRO3OVXoyZSZStVdCa +gZuvjE4u3nm9gU5f4NxYPhSbLI0Di09YgcDG6hecLZuFyntTK0GLHrhSxsQB9HrWDj4 +WMILxqT6DwJHQybW+JSaPtyspAJd7fnzyErlTeKy7zb+M2Q1ePkd3Zf6c8cOkD2xSPD zMGaHtoWmzQLgBxYj9/a2jpGo7c4t1lx05M4TD7XQYCQepDp8gnyDT1i78AZOjMHEV1n dA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 39m2smjab7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:52:56 +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 166GoHMs012559; Tue, 6 Jul 2021 16:52:55 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2169.outbound.protection.outlook.com [104.47.57.169]) by aserp3020.oracle.com with ESMTP id 39jfq8vj7s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:52:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WX1PYlPJ1pEc9zLfb5/XOKa2WsQCB/UvIcYUC4XYhVxlq5iS9S1kxhnhWVzp8ys45RQXfOZTMVYfhi4uHYAqN1Uc5EGa6Hn9InE9BnQ75gvKm/JbSnu15fXXPgIBo8YEAIVMfcFrVMqOoJKIMa1+x7x1F8Z/sMVF8lQ5qeve+W4OddCKq2sTIA+BJ8Lgw606Yz6eehtDC4RBwfHekR25az4IwMOIbh9BsZynx82z5wWaEhpQP/KReqQj8l+WbY3NmOBRr75aDbVJ+5O3LrxT+TtODOi1bb0QVuqmj22aUS1wsGBnuFQadumhDUkeiXAZZhMkDrlM12m3HMfys9tMOw== 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=wxWwt7seKD1nGteeB+sXrAEUdesC5+4O/U3S4dpdz4c=; b=ScGN297WyGpE4mCSDXGWcueaAj1A0m1OsM9qU/NhnDe+xN/wnznON46QZTluuodqpLoiIDkO0lm/s2B20zAwRrvZpnhEX+9B2WeUKcu5/jK2WKQaMX8VF5WNG6IvmjbR3bLbdHBC0jzTURVdINwAzjkBXyb6po4Z1s2o+G5UtkhsFnGiHtL0OwwOexBcCMwcjdNinT0IyzcK75VDrs++QCkzFll6DUrMGw52+7Vd/BsiJa1zNKx1qoAnSh/B0BJULkrdZlEtwPzD7HTNN8Z5zYiHur65mTA36YlaM45X/OZhTZ8yPOO8bTOk3X0RR3EWbBF/gY/eXlihJQyQuxYMdw== 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=wxWwt7seKD1nGteeB+sXrAEUdesC5+4O/U3S4dpdz4c=; b=nMfhLz9qjhGCAWGaeV73gB+lcAerV77ot3VHx08gbyShQe/HowWHo2t5RAoJIcgnhVwqSr4At6bi8M2QN4AzIdceZ50xIGs5UeNIR1jT4Z8bp/V70Idzvto+aeNgkvMk0m+7yqjVifuTJ2N5J+MKLJsQpUIZ2LV9B34C8SiaABA= 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 BYAPR10MB2805.namprd10.prod.outlook.com (2603:10b6:a03:8b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.20; Tue, 6 Jul 2021 16:52:53 +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; Tue, 6 Jul 2021 16:52:53 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V4 09/25] string to strList Date: Tue, 6 Jul 2021 09:45:40 -0700 Message-Id: <1625589956-81651-10-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> References: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) 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.4) by SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Tue, 6 Jul 2021 16:52:51 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 95d7887b-a2c7-4b58-e8f3-08d9409e7f12 X-MS-TrafficTypeDiagnostic: BYAPR10MB2805: 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: jVpS4gZNe7B9JmIRRy8zDAhpTpu0MuIn9dWb4zPA/g4ZeqMFZPFBeDo3l/aXIl5pRoy46BPI9j2rs4GZiRotW8h83wWgB4gw28do2fnOX/M1eygTuHPwTlZwd8ZBBbeMDIkqH433IdP5bmwWxKKo+mSBgcmzt9LF9/CwWK/GsEqtTmQZZFLvSP3zYgvRLXzRDREef60WXpH9+ijdTfxU1u6nXM2qYpRE6BSjgww8PXw3ZHy2wFwAolQ/CE1u5WYpAaaMbgfIL53Zb/ljMt680RAbSFC3okoLvnXrYybf8VOA4LsgC7yBz9Xu6XdwntNIwoRaC7Et6lch23lMhODuuTfWrNRXrA/eAXQ4VRgBv4RQrf20F/QpUuS/hHnHgvIpCB2hVEisVf4pckFypUkqnmmB8F0h4SeiiSeeNorWrQjqjsDHU3u7WtFp1W9UAoSOKGIYxe4EbIUIzGv3ER5fi68zrirPwPzKBQ+i+onMvIjWLUjrkp3m9ek0KOxZda78aZrUMfJvet+fMePo88KOyE8TnJDERQCbIIF9e9UPd4O/Rsw949akp6CMrAu3Hgb44E/5p9ZMM38G5jwSIDuJL2zXqUqitR3rO/sbDua1EJvfxWE0LLJJYwMSvnTipQ8JpkyR53v0Hnd4VhpzpiGzJuQ5pGrWDCDk6LCtTCQs7CXAhTNKnZ1fACvets6hIIbbBc1XXxYEuWi+YVst6H3yROs8aGeZ3z7jlaYvlL/mFP4= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(39860400002)(376002)(346002)(396003)(366004)(4326008)(2616005)(54906003)(26005)(107886003)(5660300002)(83380400001)(6486002)(7696005)(186003)(66946007)(66476007)(66556008)(52116002)(956004)(86362001)(6916009)(7416002)(36756003)(316002)(38100700002)(6666004)(38350700002)(2906002)(8676002)(478600001)(8936002)(309714004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pynnTiCinKGJKBoWN7zyv5g9gIxE15FfHhz4b/DrRyQ61hdTO2SVFRZZEYtA0vtXDDVo0c/XQjkmIq7UJdvVMb4bilaScEcCS4bZNCUwsPpxXcBOLPaGqzM/DWJmJPqWqM0Q8cdxXGDUjnKnnrHezUbT4FDoxEwG3tK0CqtqgBloGoiudoOICGLuskaPUsuw0WGh5gmM9/NV1pOJ0eCxgwTmRM6H84kJDnUL7u3DTspF8ikLIgZdk3YV8R8uwD5ZrZv51GND/D+HMyZnelyMVY+Uq1hbu1sa1by3gKycQsN8BQFl13mFCrt3SvdpaD7J9yFWMJgNYrkWB7GaFsUmVQQHbVzUgng9lUF+I1tmynog400ySnYiVhvTrYsCJja9LwetnlUAiktaETxs/0ON8YyYfJ15I7dCM/0aJf2mzBaNhari6urEMNf2MLU1LLGLAoevKdbZzPz4030PaT8/mYEV6vaL/DdIwsJLA+RAGxyIbbNUMmNwZCnEFS81x725u6iUcDglo2FMNswZKTkPWWn5r2OhQtAgvBG55cj54/5AQrI3osmOwU7RXBDoQHouijy8YbIT8L6OgLekff3ua3MF4psJACYLQk0cEac5pGTfZvDq4oBxf7ueYEnLJrEM/Mbw2C2IayN/0SXNMnpHk1QbEDJ5yHbnikvBb8YibYKSaypDtFUN1SJ0V8F+xB4HBYyV9DERxFLc0R5DeZmSd4u+G6F5Q279W8U96Eid8yQBQ4TYdu41GDakWyYTdOWKhId6wf9sM2U2fhCGgRoeu4GdEgplzfxUZifNhyVrLp70PQh/r3EiMIxx3gqOzzP1LTlPL6ogdrGu00//32UNyldKfxqJdYk3TebB+up1q0asXpI3fAVz4aO7uWXu82py4Eipv88swXOUeR9bJ7erJZ/PkL+wahwCZ51JdefHoE+9I5gIni4w84YcavFXK6bem2WzJIxTL1TRXDbQ9/X/JnBq3QUhCHUrTgrYF3OLcQrvm5oLQTO6tgPliDEagIxNutFe3vZhPdTu8J2fhU6ozdk93PaLDSt9xNx5cxuclLUrtLGeM2kIrkAMz9A9q1QW9UP3YsZJrp6fMisuPOpa51WO0Namz66uishgQiOG0/x95+9NJDaDytaLZOL02h0sf0amOkYOjGUaFxvog9vYp8ma9uBsBL8+xvPpRub3BPRXgFiEag+ihNrZHzxCrK+m+INgrB6nf+08OH5xoUZUegbHOViSoZC3hDys4MftL2e2FGsMm+4zli8dXNiA0yhmi/ijqKj6+EsqnfNbizugOlfpfhIF5vgPQIypYYsXrOkh9qLFCbFFsz4S8oJ4gc0z X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 95d7887b-a2c7-4b58-e8f3-08d9409e7f12 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2021 16:52:53.1541 (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: GYjQnviDqul2mnRXsV6+P9b7pqdDD7u3U8QU1rjpN+gFcMcvcm3WJRTfhhXOpK8rtIWlo+19Quk61Mp869uamYwwsl1EJULlr2Ee33/q/w8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2805 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-2107060079 X-Proofpoint-GUID: hNYBeCH0CLpLLDIRAR_Jxidqzkd23g0E X-Proofpoint-ORIG-GUID: hNYBeCH0CLpLLDIRAR_Jxidqzkd23g0E 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 --- 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 e115a23..f902dcf 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; @@ -1166,7 +1166,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 Tue Jul 6 16:45:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12360923 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A09EAC07E96 for ; Tue, 6 Jul 2021 16:57:08 +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 2D39F61C3B for ; Tue, 6 Jul 2021 16:57:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2D39F61C3B 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]:44336 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0oNf-0002FX-6q for qemu-devel@archiver.kernel.org; Tue, 06 Jul 2021 12:57:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oJj-0000hm-UV for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:53:04 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:17132) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oJg-00083s-Lg for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:53:03 -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 166Gq1Sj012481; Tue, 6 Jul 2021 16:52:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=dQPNlS6XV2O63N5HaIRgnMAK32dc40qLravTWRbi79U=; b=JKvzcZkvKeMvlB4u6gsBiwFmiM16YZSaHI7T79b2qDbDSKiDBrvc9LtHhYB2ZxiQOvC7 kGx8JihMe74z4Tx/JDhopJrO0IBzxDZcqeA9/ca/3yWShf/19v7o0RQpJIjpkMMuOWBl a7419KZWYyPk0myQsO+3teQIOFaQ5NjtVh/cUSru8FU0pv06tOmtmf2PjssTWwcHImDl zje63gZlknnPiDg93Dxb02h379jEQYkrukMLhrV1SJSs2TVfujC8couL20f/Ce9YDqNT ivCIg4UbC7zSEn+mdg0wseCgojkmwOOq+6kLbjmo02740ZO9ZQE90z6afSXO2NcLmkay qw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 39kq8ebbft-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:52:57 +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 166GoHMt012559; Tue, 6 Jul 2021 16:52:56 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2169.outbound.protection.outlook.com [104.47.57.169]) by aserp3020.oracle.com with ESMTP id 39jfq8vj7s-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:52:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=El2dQIVl9Tj469KZ9wfvUhllDMVOXqpKKJUEnJI+i4nSmexsdTB+j6SXYmp2S1wjnBsu/Xn5sHP5ds9D/blTrzsiklCokP8VW87NYy7KviKB8HVsHxhv4V1ox30wemrj9K6GXi6YxQssNtPy7Iq78s0dqbLY1HP+ryh/dSJVgpPJuay12HNdER6ZgjfsM8COCj+kOHDpSwOzXPjMZufcxKlgw+8CYa6LNhAqqO78WuT4SwRJtFUaIIytl8XDWWJ5u3GkAfMf/G/IflMZU1khA6Bla9V8TlpA1VviY8iCu2/Ok+pNFpvDZNaoyrJlfPWRkdkN8MUUmUjoG/gbvNQX3A== 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=dQPNlS6XV2O63N5HaIRgnMAK32dc40qLravTWRbi79U=; b=bUlr8v2TQEh1kiNw/TcYnOnSMnqiqzMHjoJTTzbD1j++6EyVOYv+o+C2uI4OvAUmsG0MRFAAaF0iw1EdOT1gXAAHuN2MpycW0zYnG62L9SbIwQDrJYNI7Jzb/AYCocrbLW/HIIw7shvrW9cX4GwlVPQ4B5eDg/LYhuNTyPUjoGQRnbcZBEMeWTqdQOxuSL4rvpMT1ofOv/pQaXYhfSM5CRzpRLHmnfq9LQ+1jXB/Wd88CCCdVrzt5ABt9Ldq2yM5LxEdQkoHgNVysADq+0MU9O/zcMJpJZAyi3ZoGgStetEVHT1xu5kKlppRj6gl2r52nU8h12Ir4CRti56wEPybRQ== 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=dQPNlS6XV2O63N5HaIRgnMAK32dc40qLravTWRbi79U=; b=JYw8x8FlMC3EdsCNsMkhBM+G01+kCx/bKv2jyvJCcjEplpcCJGl/FCKDPodT+g1UXtBiUFgcJzsqa4gycKrfOiOdugEudXlC3J49KVMpWvC/YfrefW0GEMPwW4/0uzYL8lGoMmPZA+W04dIlYoF9hnBD2KIA7JvAyb8cIQ9Eh+A= 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 BYAPR10MB2805.namprd10.prod.outlook.com (2603:10b6:a03:8b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.20; Tue, 6 Jul 2021 16:52:55 +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; Tue, 6 Jul 2021 16:52:55 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V4 10/25] util: env var helpers Date: Tue, 6 Jul 2021 09:45:41 -0700 Message-Id: <1625589956-81651-11-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> References: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) 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.4) by SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Tue, 6 Jul 2021 16:52:53 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: de7c2fdc-dbe1-4874-2d9d-08d9409e801d X-MS-TrafficTypeDiagnostic: BYAPR10MB2805: 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: wcWU5hr++EsUOTpC9BvIkmgRxzPRb92bk4s4ke/LN/lnIIKoOj8XNi/ysIno3Ptj0cNainbC3tAZDt6wU8S05AfljzQ/jqiEnptcf5BqGUNMRIWEk1lM2irO8MKbierIu8B/ytdeRx3NNgDOt/g48/qP9GV22uid04KWH1l4yhiCl6vP8gSUPg2w3Im+rVP7ZvLavYQk0/VAq7NFgsWNs+6RMN6B1tOK0wIjaQrbgqPRF3qQdtwvrfxjoQp42PHZa4znzdNggL3oR/WiDGaid4Sbgp/Ry2Mz1RfaVrEQ2fwKZqx6KIBobD+KS0EMTN3NMVZqLG42NNJ6gyN1eNvZnxjmOopFT+JrW4Cf/ZJccSt5QShukiyBlRBoumifgtSsGm0owCjtPb6GUKwZhToeIzbaVyNOxX6bfLdJ2oiLG+r/G2CLSrDPYlI+y01YdVDad3CQh/qCtArINEJWU5Ce4GDulxbvnMRFgjZw47rMBbkNh6siAEGz1N9a2EBY3ZjiSQpzKcnoYJMqJ+meks8EXs2GySPFbIvAG/bgGLD8ycCRYFB4IqNKKEmXujGX8zHkfnTB4wF5KNA/f/NGbaM3ErY9vVqDVpME32wbMd00votMiUoEldaHQO+cS4fevc0dmJQ+sgVtl6L2eX13/WYNw02TLv2c4Yd2W2L2sIvJsKcLy0O3zMUVWGPU3Q5TSTVJt2SM+6lZNuM6Zp7CsuQ4Iw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(39860400002)(376002)(346002)(396003)(366004)(4326008)(2616005)(54906003)(26005)(107886003)(5660300002)(6486002)(7696005)(186003)(66946007)(66476007)(66556008)(52116002)(956004)(86362001)(6916009)(7416002)(36756003)(316002)(38100700002)(6666004)(38350700002)(2906002)(8676002)(478600001)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: j3Q0ifdinLSjKro9nSIk0k7iTlIM75qI0rAnCOYujc4bZbrQr7UiDuG5HMgJnl4IPuUwyRJuULy3IFWYgJxDY//X6vJJUi5g+sEXl/dcGsF8Ll4tVRCMbAsPpza5rWcaPRRPLpeLQe6WQLjSWUfTTe0WTdg17aW6mAx3G2vTB4hGiLo30yjRdr91fF7DPSvFbnBX4O56uFeGokmvfPKPDw/PcRKj1SyD4Za5eA8kNI+NMubK1jZBeDhuPEYrwnKKOS5Z721agFQ/9AgbTIE2ZdZjG/jFtK/+fZB6z4RLdpQVItk5uFwcxTAmsSkl8L1ZVyf4YAc/FD9rR2DGkETod8PtPXZmIRfllOsJ4ufeRWs8XELM0blfJwHQRH0jDrsS8hdtjHUWuiweZyAgkqWAGs/X2QW+Dt2gpD184NapqZ8cKLAgBz+539wOwFcLpozkt5spyJVYycC9ONua8KES1XQ2SjlQ7rXu29R5VSHAZ/lRnk1uw/XUSQaiqNioKfpfhhqj6YpxxbqHYesay5fF+xdcT83WCCCcxzgqFcZChFnlPOcFwiPtzo/RbSRhcoOtO+ZA5+KAl1nKVjJg7IzRCSLr1BHMoXPlmz1ZK/WBbd6y0baR+bFoltW3vJ/TrPMlJsQ12qhwlFZbYYkcINVBki++nYw24KgPhEqJQ/jIYpcJw7+fha4yrleCxGiFUcErBXvKhnZA/htmm1rwmWHzd2xH2BgZV1iKCIBe0o621ndeZ7e+FH0UD1lj4QDVvwVsw/1TEEfHeD+fWB4fQlK5UTe8W/pQZ6INzj3Y+JTtWB/bx1kPCkQALFgXBUqpQgiTpJH4cOwlKJsLYZ51PVbEiAttqwarobTCO4BJLZmQxVGryduQ9vGVSZ2KZbfGzypw3zs8+MkkTKrGkbHNch6bdAP+ds877TXpZ9Ywo8EX6JxtWF/gYItYtfi/PYdpAvzKxwzkG6/CfacJy59mi/PtcjBn+JRCDcrpXA7Nm8PNqEAYIC3lkZXgFQqGgSeEiOsmxYrxsZ1gu9zp8IuNLyfw++mU7zhCNWPnDnH0PZFcqy8xACidvmU+Er402jZJZeNLiU6RSfwyYJB0PVZqKO3Xm/wTQlqbtAlBINnyAk5aLK4beMWLnD8MBkg7eLbA1sD3LHP3UAoYcOwooJUuez1Yl9YcirVwq/QYHurKu0STdsSuLITeLbVWlDMLH02zhf+dmpknmurpywABkgn+z8ym89deASkzk5fR/amLSs9pRAgo7w5MKBOtgMTMnLTrQ1fMrvIGH1nPX+EV0Vn4oIBg0cQQsGlRqobFHRtxLmZVCKo/rTKSFBn42V79HX/AI0FZ X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: de7c2fdc-dbe1-4874-2d9d-08d9409e801d X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2021 16:52:54.9121 (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: NqYqPyNoaJVuKXQfOuzgA0UtMmSNhMED4Sg/QJsBxpbcvQrLVdWpsAyAvDS0tReWQAw9R3hCTetFGGR+BE7BzzSphFuWp2mVFbYESX/XOn8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2805 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-2107060079 X-Proofpoint-GUID: Y0Rjg0NPmvdPRg0VLMq5MbjNMkzk8iOa X-Proofpoint-ORIG-GUID: Y0Rjg0NPmvdPRg0VLMq5MbjNMkzk8iOa 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 --- 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 d4d1e9d..b844f3f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2850,6 +2850,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 510765c..d2d90cc 100644 --- a/util/meson.build +++ b/util/meson.build @@ -22,6 +22,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 Tue Jul 6 16:45:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12360935 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61235C07E96 for ; Tue, 6 Jul 2021 17:01:35 +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 E048861C3F for ; Tue, 6 Jul 2021 17:01:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E048861C3F 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]:57544 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0oRy-0002XB-2s for qemu-devel@archiver.kernel.org; Tue, 06 Jul 2021 13:01:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59492) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oJm-0000pw-Uw for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:53:06 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:9774) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oJj-00084G-Fl for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:53:06 -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 166GqFwA028409; Tue, 6 Jul 2021 16:53:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=nfgeduOdRnDMHuhQUvwviMdkqz3uBP/k3YDIw7MMMgA=; b=g89uQzVMtCzqZnHeciJGhA7/kNFERGmTJhnZLKfXQIXSPvYncGlMTd1Rau7xyrbx5sct UK1XLDLtc+MMeMmPDnc9ks6Eo1BdcLuKmoENkvGrhO+8HoU1lsFxdjpLrFi8IFMTPZRZ exW7zKFaVMf1GXWCvJl2+G+azL43NkwxOROfLQ0E+ROH5t/GvZtSYYIT4FCrx/Lz35wb FrTV8f0KR8+L8D1kafwN3fIxWlU3y+W7A+vaU6bQ0NwyQ5GDjBP3i4g85feWANb9yS/6 Gu/U2Ko9qcpCDiuioZfTA7ZAJfDQZaIGrYb54JkrPIr6Y7v/JsRCg901v9VL86Jz8Do2 Og== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 39m2aaaapb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:53:00 +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 166GoVE5084730; Tue, 6 Jul 2021 16:52:59 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2173.outbound.protection.outlook.com [104.47.57.173]) by userp3020.oracle.com with ESMTP id 39k1nvcq6h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:52:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BlSfiARY/vHCs5T7/BATj3UpAGHcgW3Ab773CdjxrewIkti3PA+0XEG7aIyKJflkF47wSa5JBeHiaLduXHVm36d9eG32QfgS0wxZwxdiBzcTwFva5Gl0eRac+K58WhwQxaNnUhn20oRqMQHUtPjehpC3MBfeTfdg9TmHLLCoRDYyBrfh1SbN3Rk7JhKs3DeJ13xmcNCf+Mk0hiN8dbeINtOSLVM/J9ftnUrXggPnGOT+bFn41qKZuKfi5g/hnDFM4kkStvji+NgXyl9A14bK7Mr7bp3LosH759dhIDH0R+H4mLKMf7UuT6mOTtN7smOjPcSh3eyHcUqrVbPGB7HLPQ== 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=nfgeduOdRnDMHuhQUvwviMdkqz3uBP/k3YDIw7MMMgA=; b=TZlDUKkwxUHMXC1SzFFJEmaFCvEenx/NExP3NvFXF78SYecnD9IqLSKko/gfQUzwMvbNZN14Ruqmje72l2ZcfzcCtp8AoiNuDRCtsijffYusnIjCddA3HIL7I9t0Mm1wFrrigBLqn6YjEYS4nxNijwWqxfNPBrnnKOGf3/KB82BdI5Ua3XnnXFtNhCHnNQSGOUcRTLd9R8VDrUbAym/vk7zTo4jCtzrIa2WqRh1/wA+XqqfMHPlgoo5oV6Qi32YRWcVD/QmF7bh02kbn309V9+ci+oi7YU3zMUdg+UsoilC5krVMHuoarC6lVK/Tepq+5LXpE+DSGruzb0asAd1ljg== 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=nfgeduOdRnDMHuhQUvwviMdkqz3uBP/k3YDIw7MMMgA=; b=us3JfdSDPTH0HuQbl/yTJDuYLxugKEAo+PvzSn5c2wrNHxmfgqfxm/GZdAcsY2lWH+GwbYwZdPwfUQZkcWi9RsrBZPDrVonpkKBPLfQ+6etSJVVTLNO7ySMCvBSzOF+WdeUoKLa8HsUq2VeXVh1SDaExJB6vkYGXp9Ag1t4TgOw= 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 BYAPR10MB2805.namprd10.prod.outlook.com (2603:10b6:a03:8b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.20; Tue, 6 Jul 2021 16:52:56 +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; Tue, 6 Jul 2021 16:52:56 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V4 11/25] cpr: restart mode Date: Tue, 6 Jul 2021 09:45:42 -0700 Message-Id: <1625589956-81651-12-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> References: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) 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.4) by SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Tue, 6 Jul 2021 16:52:55 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2cc793b4-15f6-4dbf-fc86-08d9409e812f X-MS-TrafficTypeDiagnostic: BYAPR10MB2805: 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: FvGL6YbIxVbrwe5ILVhMZhQBcw9bYttBpt7D6BXEw6Clun3eyZb2zU0guoI2I+YVyek9DYdGRW6pn+YH/j03cVAz54yhQ32VrixA5VLdmN7e5ZH84XQaeVrUolTW++H3d+fEpMYV+/rMhho7iBbSzQ3TD3lC8z5S/2Y72MwYLXqQvSftVUSYQFZvabB7raJBE6eSD7NxXcnp/pt5pCWUB1GD3XO6ZCw7NuqSS7jh88UudoC5L3GZvvvou2aZJ4Q23fFKaZ6nnjRXvrbj987dLUoMTBntVb5pU4JkSBG81vuhuVseLg55fOMtu1UwapJpdpqmNYVCcEjMgUlPdNZYb2xPGZXWcWoM5lE1iugC5kO7KG0ylk6twynEgI75m3bUqUCPMAbI+OwhOZHl4g3v0OGyKJwkVEsn/62jqYyqI1s5OdnZVfNt/OCQBGjfii+Dd5bxss+YhJ77V493p9p2vgy0mwZIAjSxo+W3YAg5R7bG+sELycXaJdLOLqiiSWdty/bGe/cOoQdRjGWC4ayJY9qHCnv/ARMYv8wUVPQjwDX3Hm6qg2qaCwcHufMog2HSH2LNFaHOWPG1vLOQxlEhqzYQPhMFCXlUtXf8+KNw3ND8nhxWHbrEV+Co2UbhslEPb6+r6+aQcPnaBczACCIhK4nuWr/v4BVL3TewlX+3mP56P6e4LyaHIpWC8S3yTRAz5TwBdG70tpND+HEgcyvjJg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(39860400002)(376002)(346002)(396003)(366004)(4326008)(2616005)(54906003)(26005)(107886003)(5660300002)(83380400001)(6486002)(7696005)(186003)(66946007)(66476007)(66556008)(52116002)(956004)(86362001)(6916009)(7416002)(36756003)(316002)(38100700002)(6666004)(38350700002)(2906002)(8676002)(478600001)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HgpjDvJ3CFTFHNtIWDPIqd0O/TYnLubgtz4+Pb753PWyO987VNEkt73u5UTD1kjvziej2bNprQIMxiB+l35AYPoQW9hvZ5+/sKf1ZdhaMiRiXOH8n8S3fTvgAWUNg4zMngdy53Igg5AqIYjPEg2PzKW3KrGl5fBYJku6aJDOzS2mdQi6t6B7FwaAsgoY+52+T9EeonNH0q66uXCm8ahsACFC0bJq39/tzdz7G06X9RG3nlk16P4L3M7aTrZApez9BXMRCl8ZtoRJ+dZEQTjMd3+q2GYL/wjmVfJE0CKfqfKqQav1anikJukLKCYBO6ML3xFaKH0twtYifdXLGr/jmJ9rceFcVXyq4a/0WZfbrugP5UvwmAnTjRUnjWAiB6r2C80INqEM0dkv020UUx1gUy2K8JJtmgzlgUVL1DduAMZKCBngw92311AOg7KjKq1/XJuyDFWdwjEAhgnORBS6qvKvBKBSa6GmDG7WEUH5LaT4T5W7C/sL81gH7GheUW4EmmGT8yUEbsDIWqDDxv1LO1LY+582fT4NLqfSByLoLHBGwFtPMChqdM+hlhepESpgWTg2my8KZaEc9vPb+2vl+6LeQOYju6QvO3XDRce/RNvFigyCmSvKTVkIOmcEdyrLXDMxEZLWgAD4ULR5WtQqez3TPPu3Og9LebOZjHCZ0C+3aQ4IhcFr70Zwi3XKpy4k4TMc3cdHLLdibej9OR6MPPgfIr5tVT5My3oIoxKhi2bfmh8x5umN/WuD5UZHUfThHYyHmoVu3ujY+vKsR/KtyXOmgb3W5pQAZAyUM//XnN/rRgmc7RnYxXz9/MQ4wUx2ousZm9bZnhzd13TztS30wWmhahzCD2o+OaQufOKAFxUfphkKTEOnAMYQ2oikwOp+7R4bjMmTlWrsRZpnIBO/1p4X+/7Yu9Vow0IdCaFwA0Jmyd824JlDTcdmwCgbQK84fDzYD9BNkUj8xi2j+fOO2edwYRbyxdAKdpMl0MM5n1hejvjColcuE12VhNN03DbKXo52ij0nlf5QwnNhL+Xbi14YvG2KDL2YWPb6hkXf5BM/WagcFts4NlcQoKLop9KvKwa1rYaM+0wIgkdUCOweNKnIk3KgW3PGI5TQbR5q18/rKnT1tM5z3S8bNWEZyECer7VP78BoCA3b/e8RdpsHqSMKuC0eOJZEpxRkOXZ1kczcBsskLaCDyO8SrsvGL2NHowQmVp/K2QBq4C1+WwrjZsLQ6WNP4KbbC3Z2IYnc7OKaGNng4zVx+C9JM32NmF4zumftznUKDY4L78QZDwDH4FJkRco+rUy68LO4NOt5caEeoalnUn6z3+3TZ6JdpZ3y X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2cc793b4-15f6-4dbf-fc86-08d9409e812f X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2021 16:52:56.6931 (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: zqpRmk9iaXHChbAiHjEv2EcB5x5PIj4g2AfBVX0V/WWl5vuMf+UgJ26+xKjHs9XbYmzfTwLEm0wP7NPkHQuZCoExgWEf1Exk6Ab7O2jUlHM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2805 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-2107060079 X-Proofpoint-ORIG-GUID: MB_vFZk-T-IH1EqGRYDREHkYjC_Fd8o4 X-Proofpoint-GUID: MB_vFZk-T-IH1EqGRYDREHkYjC_Fd8o4 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 695aa10..b79f408 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -68,6 +68,7 @@ #include "qemu/pmem.h" #include "qemu/memfd.h" +#include "qemu/env.h" #include "migration/vmstate.h" #include "qemu/range.h" @@ -1957,7 +1958,7 @@ static void ram_block_add(RAMBlock *new_block, Error **errp, bool shared) } 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, @@ -1965,7 +1966,9 @@ static void ram_block_add(RAMBlock *new_block, Error **errp, bool shared) 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); @@ -2214,6 +2217,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 Tue Jul 6 16:45:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12360929 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 696EFC07E96 for ; Tue, 6 Jul 2021 16:58:58 +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 E909761C3F for ; Tue, 6 Jul 2021 16:58:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E909761C3F 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]:51036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0oPQ-0006fO-R8 for qemu-devel@archiver.kernel.org; Tue, 06 Jul 2021 12:58:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59480) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oJm-0000ng-3Y for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:53:06 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:10032) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oJj-00084I-Sd for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:53:05 -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 166GpqgF030618; Tue, 6 Jul 2021 16:53:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=Ql4BaF/gK2L7/cYlLylEl2VIg9AptK3OxZelqg16maQ=; b=ul8XUsNUxcee4JCD7rfqYTFKZW+6qgFd/AYkC8t65nVqeXZtKsiMmf+BayFWw5bJzulM YMcJ2tiaFIO9KFP7XNVxJ0V/vyoXTyqs+fZxzrGTSjWBDa8H87J4gEC4YB5+X95Hdlh8 G+gL7XEU+rSX4OSQB8FxnVKjpvs0DXY6mjEhXFs3ix/CA25Yv45n5MlQVtUNKL7oR9cz 03q9EdaTj7s5/K95dlC3PCy2nHX/5TB5Bn+Swnk1hXNeBPC+uxSw6lWmpDpfNIHDOpLD EeimYXS9yQj8okjolgd0mZz+x5faw0yTw6LZRNc3ZzPNLJVYQATHbJEyl4oKibjgw9GN mw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 39m2smjabc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:53:01 +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 166GoVE6084730; Tue, 6 Jul 2021 16:53:00 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2173.outbound.protection.outlook.com [104.47.57.173]) by userp3020.oracle.com with ESMTP id 39k1nvcq6h-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:53:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fVcowGXV9xYnFT2ANZ+SB6d1W3P+UtUbSF670eCZCBUbu3KZ3Tiig1ADzkzV4fGOP4bZt4vZuC/6Uql6iszES1wNT01k7IqU1MtXUBB0ZnRA+NfM526YQECGJUgpqDhY8mMGeUuBwSv/uPHFWZRqM6tcvkYN12wLaDuT1p9AbJSI+2tr7R3gIsZ9MetiJTsedehYa6ls8KGtXL7AAFKhkpp0GZXPHdiz/KwMvG/y4fg+e8/GT1/fSmSNcDoGaP2zviVICynTw8+UJB6VeCd4Xtct2Y2FEUnt9LaH+bcfOAZ5QGExxrQu7Es655yRCL3XX9/8sW+IPmJgitdWYlfZEQ== 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=RYsWqfyf9FKNitIMRI9l5oSWgazXV2f/kTG+p2i6hZsNYMdEhmxKgG+sa7FdtCtL7WazrSudoWGfTHUwaBcVeqzxsIxVbE80HedsdH7sI51hLGVrAuw6g1IRJNfFuGaj0bFBAVMuqtMP8UriBLkOfa/t56DYYu/XnQmLXI/HuX5PK/Cq9A6KPcuTun2eAoZhUK+vFK9grW4ycuCJAK5tBIOC9bH0yNPXygyQh/3LkAL0pWU4by7tmTJX02ljPzB1BDJzCMnFnKrqZOHrOy/twaimVLdo37QFYnOZ8pdBIbYcpoX4JuGWGCwvf0K6Ha7d2Hl2wcbsFsP9h3r637rxqw== 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=La9ushhfYwaFwHq0GzKPhO9kSAGkevCJMGjrER+SBHrFpTd5K7AWAaDKJrUw4EPwjAI996T+3sbCJ+NIQOaYdG8n9ax7ZI1uOqYDruwI3DSOuibmZ9yq+mA+EdMKthtZcoNs25meMiM+MUMrrOpUtc2Wp90epF3WED+g2DIDA+s= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none;nongnu.org; dmarc=none action=none header.from=oracle.com; Received: from BYAPR10MB3240.namprd10.prod.outlook.com (2603:10b6:a03:155::17) by BYAPR10MB2805.namprd10.prod.outlook.com (2603:10b6:a03:8b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.20; Tue, 6 Jul 2021 16:52:58 +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; Tue, 6 Jul 2021 16:52:58 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V4 12/25] cpr: QMP interfaces for restart Date: Tue, 6 Jul 2021 09:45:43 -0700 Message-Id: <1625589956-81651-13-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> References: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) 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.4) by SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Tue, 6 Jul 2021 16:52:56 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9b316ca9-9eca-4818-dd56-08d9409e823a X-MS-TrafficTypeDiagnostic: BYAPR10MB2805: 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: pKP5vZ2YHpF+HBF2M05cdNQO8CzyZBvffiK4dubSxHeqMlGXo0Nct24KOChQkwouthBwcDA+hfBpoZzEq9R7EgjBgWgG2hRTDK43e6/7lPZGiW2151eJXcT3S7FJp510GUgcz8HDoyamvNKfiF5DcYyGzOksmjEI33k0A53Nwlcujq35VnytxzVF30YwYaxBpaI2UNqqoFZStG9urDEkrMQ4iqwmc0IZW085VJvdk24iTrdY7hELMGC6Fb7E6fzy6/Xbe+pIiL702h05NYD3eEEsOCRZk8r48aAc0iEqJbsIaq29zJhNdlbuh3eASXwGXmxnPmcI4sG6PmgN30UNem9fXAZR6LKhiwTc/CUKtxXM7KpGNsA98xt8Vvv16QTE8gq5Sn2WoC2qey7u/5AxLPjfUy9E3wgtXJrRwoIKIvzdnrpjIIj6LaptYnUyHIhrgJ5pwX8pIVV8h4AN7a9wvOYGVDMq+hpv+FUeE7pKwA/rC84FTe51Fc0AsWmPS70yLTy/noczBv74o/vJJl5cX4TQN26e7BrXKU+lExqxFZRcgEHowLOTqfkayetCTOrO/Zx1wkK+iFj5/SPfNGa0bm2KHOTfom3NaSBBVio6IJCBH4c1gjCjmumkMFHaNpZJg6sNOZRAjocoKnXZdKYzuteEQXD4E/nHsT9hTN5SBHGg4XnPkROhcFZuOL8I3fmqPCbcDw98JR8wY92n6pVLFg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(39860400002)(376002)(346002)(396003)(366004)(4326008)(2616005)(54906003)(26005)(107886003)(5660300002)(83380400001)(6486002)(7696005)(186003)(66946007)(66476007)(66556008)(52116002)(956004)(86362001)(6916009)(7416002)(36756003)(316002)(38100700002)(6666004)(38350700002)(2906002)(8676002)(478600001)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: DtnlwWWFDSQwA1+IB/8RboCqlF0IIE3OKgyI7a7NVmvNF21GBly8UOXubSfTfcet+y1vobVSo4ZE7R/B2FqBJNAMLk3G4MvUO9fsyFXCeLUkEnvQ3YeWV+fzg/3knBQefVqCsks0gCcIIr0WiOqx0TKfLzbnoqkdLZ4sksK7hVn85X6dS7UmRWqNyL2c3q8BRT6+SPDu3xYyQWBo4MATzRF/YPL9UxTf4/hZxh26mc/tfe/nYz9BsTqve+JwYLcoXPdNqm0SxY/epe2esDpioECVn82C/Qm4DRmVqL+TcgBCPPV/roA+GqQyoMqQ+aBKB9FcMu09WJkVhHuwiLd/G8WfIgcRdHNBqpmQaFOfe6thQyTR/Jv5NCrsLxECbruwjYsQXpupNeya/m0Cj81EbB74QRnic2oflBkNC8UnpSWgdUs8owCdJpOEtFS7G3We7+ZlSvaivweb7shxGNtTp+BhSboUDyj3FARX1m5Uh5yQLXFi+P+UCWihrp4HelRAVeHLP8jbbTQL9iyToh17nTsjAT2mQWPeqxpDtd0MbcWaTaoyRuI3oDssV3nz5J5B1NsamKGw2zhDBEFaCgzcN5U6C39tNt4/IvmRsDysOhp8RURHr8lOCuvmCBjzpypPji4IZDBXiRwBLzNYUqZ3KFut9gCFRxiIc7mWDXFxgFFaNQzYcp3mwh9QNWVCx7JPELgwV4b1wQJAggQYCKc8LdR3pA08lu0CUhHE7xoCpAC2lGmYVJcRgW096uBzm5TqQiSgEPQudTcfFCgXoAlo6jqda9HsYySdelOQDX0QXUrVWw6wYhNhItRgxRlR1E4fb+cNFmuOJ1SF0DKn9avwGQOiAS1YVxugta1gqLd7tBAi6O7RQIv2fQL8jqAWwNgqAWlcwU/yVMseeaXr5HvExkXWYrKNGR7/ApEyYiKyFV3PiOaRIjFl4Hze1FPMQOw5Q2lIvknEIG25QlXsALg4eM+n9CMGlX9cGDIy8XJB/1rRH6i9zuokAc7fFYMJAdG276g41RYnNp+MiWUUhWjFTgadeDUiLhOZ0+T5rpdP71lUhrjNZhy5Bmq+OuaNhPTMwijCbCgBBtuvm7zRh8303FHLEW6H3fHnUKzvyHhTP9711xe6rkhHKRpbdrXx0hO2TSRdXibok1owHyUF28KFu6MCroZWgsDYpqG8B216cQCO0cJLbZ2f7rdmdVIJMujO8JMg67sQMQejk0oe0T1j9GHIi4sUFfWaCwF5ocleXQNaAJDqqD/pbVRpzDocqZhT6AWQkqJ3YOMOHZ7YXUlzvbnw8wLILUMwa4++ttdkVE3F3ka6AksdyAJQZXtJFirV X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9b316ca9-9eca-4818-dd56-08d9409e823a X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2021 16:52:58.5750 (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: BifcR7D/l896h0opzbXC6E/yfQDEsl+NJFHpB+QwVhY1P1Kc8j0ZPWMmYO7oo1G4RvQjoGULPJ4Uwmf0tTaqMTCWUUEVVM3HKLHKPrYzOy8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2805 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-2107060079 X-Proofpoint-GUID: pNTetxE4aQw14MaOqfITtpwclVvCd1gL X-Proofpoint-ORIG-GUID: pNTetxE4aQw14MaOqfITtpwclVvCd1gL 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 Tue Jul 6 16:45:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12360945 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A84BEC07E96 for ; Tue, 6 Jul 2021 17:05:06 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4372B61C3B for ; Tue, 6 Jul 2021 17:05:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4372B61C3B 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]:40480 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0oVN-0001WE-6q for qemu-devel@archiver.kernel.org; Tue, 06 Jul 2021 13:05:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59498) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oJn-0000sk-PH for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:53:07 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:13666) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oJl-00084d-Ud for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:53:07 -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 166GqSuE028780; Tue, 6 Jul 2021 16:53:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=XNAmzhW4ZINLLfVPX98uPV47De+X5lYWvXvGuO4KyNc=; b=Pk4zFmObyJg2OhWeQw73IAhyRUJ8rfMjAOUhi8Hl3cHXJW7Rqz5jU/i2Td/Mj0nZ0N+M NBBeXIduA4uchWZvJWLfRtY7QNM5dybshqicawv9vLLhnhE0rSS1Ms2/9OMvvOtjjarh 8Se5I0+oOnuzIsCgx+ED9GuNn6a4ZCu//Oo5W4Z0fV4TuwiuKeeqw4QJ3NBZigyVmXUm x07tSUXEFeSYa6OfR1aMVaxpjUqU0Ry2cahuu1wqYzKjkXto2zuIveVGTj+XNg2S/LdQ vjKcr+6oGpFMqQyhh4GoteUIvyrBpsBnf/Fr6ib4rape+W3ZQ+TsqZe5oLwBo751Nb+i Zw== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 39m2aaaapg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:53:03 +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 166GoV4I003719; Tue, 6 Jul 2021 16:53:02 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2170.outbound.protection.outlook.com [104.47.57.170]) by aserp3030.oracle.com with ESMTP id 39jdxhgc0v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:53:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WbL4T2iISiYZcBxX9dKVn23EOGA+c9lPerX1sSgT5ZQSKybJfLJ3ja7BkIZni8gr2AtsHe7H3WBhuqiaVyzmGVtFNoKTq9hjmfdFfXUdbvUhQmaSBIn2gM+lVFR32bSYtFnDKNELZa9v8j9wEMUMNImv8xd01nvQjf0xPx+L8qCbhuG66JyQloGKnfDCTjSliseuErxtApYg7BrUQHpCmwxsV6jrowKahC2TwljRzmGbnBF0orzYDm0uVkvhJ3kBokhzQ+b97HpEvWtgFdP0W9QK6gT6J70E0pRCc21K/ULQvTP47/O1cSJ6LpMz+0HpXjA6c7Ww7SKxAC2QblUpnA== 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=XNAmzhW4ZINLLfVPX98uPV47De+X5lYWvXvGuO4KyNc=; b=UuCN4YpvmG3MoKwL5zDrOomgA+6jrPDHFEOLl/PrSEqtNo7ahTnBREqni9pY/iQ4HvJp3AUWPO37Zcmt+J5gyZ7ZCqWFQuYLVUwjj7+tPgxhvdB/eHSEg/eyW1lKDyd2Mpa4tapabW/P6ezyFUGORLX5Mj0zdoC/a4kZrqoxU9bVabBG59aM7xj2LDUKtFPmowSqNdgwOvX/TJ1vrfHwEQRohakBVjGlkIBDo9NYBzkCjHs3hEm4MGioFqIg88HCNLFLDWmDOz5smONAgf+xH8rTVaiLCYhWHyX8VNQGE9SA0S9rWHDlfAyQjeeghnAQ0Pdqd/Bw3Hhh04ExtVvO6w== 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=XNAmzhW4ZINLLfVPX98uPV47De+X5lYWvXvGuO4KyNc=; b=WnlLvFpw03QdStsIlnRNdz/MaKdzT2TLXaivYiyCt00JlaB+IWVdqDK9bnOIDSZEUOh+XKzyO20a0ZKuXzHzEKf53hqrqD3J9wEwdCXrUYeKi56yyZtUID89ApcpVhkNvVHMnXIrbsit5hULtKNioRLzZsOgVDJXRjUe5QrL4Is= 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 BYAPR10MB2805.namprd10.prod.outlook.com (2603:10b6:a03:8b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.20; Tue, 6 Jul 2021 16:53:00 +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; Tue, 6 Jul 2021 16:53:00 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V4 13/25] cpr: HMP interfaces for restart Date: Tue, 6 Jul 2021 09:45:44 -0700 Message-Id: <1625589956-81651-14-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> References: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) 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.4) by SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Tue, 6 Jul 2021 16:52:58 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: eeca880e-d465-40e4-5022-08d9409e835c X-MS-TrafficTypeDiagnostic: BYAPR10MB2805: 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: 8hlEqjrAdOmhV1y8sG0emJ1ujWPOv4uLbaIcg0RoAde4LCAcpL1bk9u/I/MpVmzQKLiSb7L0wcG4SlqHdU4zpK2CaUKtfJdkOOj8cRx/CCAn6WS505KipM+5fMXgFrpSbZwVsInBNaaze3R3T1zZYhZYbrb2/htweKg4cHzuAEI0AP7HP3hC9QgZG1O1U6wM7MKOUR7aoUyVO+4ZZ97CVk/z56JVfmxaZEYSKdZx/S+qM5yXpvB4rj10j2OLBOxk2qywe8B3rCRtqyodEpbGVFiIHPfQOUikxkSPYNVcsDAaZvEdvw+6a+ymy6fCpQoAkmstjxnieoB/fn77uWhsaP4nwHSe4orkkeWnwuArRRXR6kJJgkajwalQkr+IDS12fkxSfBYSggh3aKUsr2oyALsd11ZD4zJEeNCClWU8bNifxkE4WPvWy3jMA6jAAhIWekbVARhI9Kd6sWWb+7IBx9DuJ2Qj6E0TTW2Vx9VaRM4KICQQBGtXeXMPWIne60yt04HEddKLAcmlH3HdwP0cIvrjmg2YUx9HbAPIQRZ7EvJy1nxvhap9mRFgRYaQBW3vwYhYk5edL++sot7q7kY07TFG9Zc9TUKwR6PInwTANtN2JtRk2TWUjOjAHNC8//4pemEyb5W1p9sHNyxzznwLp1akuPpXOMUMx9wen8teJ5w97hzAJXugBJkXjYXKvkuSQT/29M7QhL9lZzLuOcZOpA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(39860400002)(376002)(346002)(396003)(366004)(4326008)(2616005)(54906003)(26005)(107886003)(5660300002)(83380400001)(6486002)(7696005)(186003)(66946007)(66476007)(66556008)(52116002)(956004)(86362001)(6916009)(7416002)(36756003)(316002)(38100700002)(6666004)(38350700002)(2906002)(8676002)(478600001)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: scIYqEqcSFvXTUVBxrqLJJ79NCuA+k/v3fEnePjG0ipEjTWfPu3TtNye7QyAYsG4SJ1mJo2ET0UdmOkFXTL/ah0D07kuTfH4Frh3HxOLra95t1YAyDSZVyLep6qFXtO7rAHcDhNEhKmKo9KbqIQaOKOsx7Hu17ngefxTz0ysTFnjn38X37jWJmlkrBB0JOsdVWev7kh6DjE7bT2/L+tdE6QOvzsvSMQsK4EeBCMQJA9JKrDVwrGwNVnFeVxwqiJejGRm7Q0XQwRxDVNFqkXGH63DdhU6C0MJ43pTw2CJuoqBP90iMOydCB6PHYP0bpbrgd+I6ZIp8gnjjknpyTMwDg05cjFdEHrwlZH6qrcwL/RjBEeslKnPqxLJjXT6l22jgSw6Cb0lVrOxktkrh2zrYj/hIwPnZJLVCI1w7Z7ZG6pBy9L2GTOhG9k1kOrFxaCN+LQMptgq8K3AyImYcBHpSXo0SUvqvno6g6Ve8r4sScxZA+p/++m9B9kah2PBiGkIe5A7eHItFYBN4E/cVG2sinVlP/aBgTg0o3qqAuwwO0pJ8D9I9k/aSRNfXZKREEuhzEUr4gI9lHhRg8U5fojhqTsFVfJhUrdgRl/wDVSFUITXaoWLCY8AZRt2yQ8OZXfXvU005N5kPblaxtaFoAEgHlf0e33xfIKAnwrE4lk256ND0V908opHbIynJe4QTP6odSgV29OmjPMgYb6tmRTh+TcK27VqTxhG+V2FFfbRfA3pV0x9Kfy5+K495mcISOPM5nNiqBhZLvA93KGN1/u1YU7vmNcqjWoaAoVW33TOCdqyDhPQHCWq9WnaW/1HsvCBtjrbU+F1sEIpGfTIwNiuVsXGOX1XLbn0rr7rh+3GyOgNKsFVLWzeF8xGbAV0dKaPXgim+6BwnP8PMD5MBtZ4aLHuBzzHim8MJ3sJwYj1FG4kaBJO58cj8kVGMysyzGXTXORRNUk4vFaooMQ0KqTd1OLarN3s26TqunHjbBHPlRpWr1LJbEZIA/75/WGDKyckesH/7z/jsg4tnmrLc9IBVSG/PzDL9GrmovGEGRsL4WZXis52RuHxl0B1VvHCfViMZpJnj1Yy6TmRDB3QAxi2GooXuuxwL9+xgmMblJZFRW/NpwpHZix0wWzsYzEbK7gUlgGsW8XvoTrmg0fhz2Mrd6gVKh3bTVpvmNgvlEE7buo14R48OSCXag7ECigsFxT3zGd4NZFA0AM3rLP3hhJlrszPEPUbvn28CyuW+FKkptEGq5DmWIpgogIIvB97w9fGLmAwGmVEXKLB4ckktbexMRpJAdQyf/1t4GwjdDjY5ZYhzJtm4FRuwcHuI4OTCPtA X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: eeca880e-d465-40e4-5022-08d9409e835c X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2021 16:53:00.3640 (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: 9paNMDNAO2ZWBmJj6iejkZFfVQOBPDj5w4F6W7H/W8QV57WWELHCEnyoMXTKDFPatxAEfChzPn39e4uIMW4/wlt/7FHCLxSiIIKF5ZvbxgA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2805 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=10037 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 suspectscore=0 spamscore=0 adultscore=0 malwarescore=0 mlxscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2107060079 X-Proofpoint-ORIG-GUID: 7yGELa2Jl4UH6K3p7PW6eXXIuveHTnBw X-Proofpoint-GUID: 7yGELa2Jl4UH6K3p7PW6eXXIuveHTnBw 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 015faae..1066fe7 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 e4ebdf1..c26d0d7 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 f902dcf..adffe80 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -1213,6 +1213,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 Tue Jul 6 16:45:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12360943 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39500C07E96 for ; Tue, 6 Jul 2021 17:04:15 +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 BE94561C3F for ; Tue, 6 Jul 2021 17:04:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BE94561C3F 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]:36566 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0oUY-0007MF-0Z for qemu-devel@archiver.kernel.org; Tue, 06 Jul 2021 13:04:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59528) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oJq-00012K-GM for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:53:10 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:17350) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oJo-000852-Ef for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:53:10 -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 166GqJtO028762; Tue, 6 Jul 2021 16:53:06 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=T4YNtbBFKtOnN5JhWS0xM4UOSmd+qHyZiSfi7Iax8JA=; b=JlZ/0C9fJzJYsQRpM5ecq+cp/fzkMZ3n29W1udZdjWX2f4IZPZ7sLridub9h/UGumLrI wpZCv/faMo0cx0+kxONL2yoXLz1A/1pnKo4BMJd3QkHHuMRXsVOwS0ydRUZeBE+93ynQ x7wIpr1Um2wG272TYnWvyIhAJ3YvSzbQ7P5jSe03OGcsNtu/ETPobJHdQqk10Duw9m84 V3KmnQVwRmT+8mfvAvQJyYpD2tiXIhF2jRF6ESrwymzh656jR1vCTO4Vu+XHZHWKPNBJ vmGSUTUgMW9oD+wvA7lgy72QZ0JPdGWNLrGD6NbtOSQ+Y/yWILc5lwSGmYA/KW3SQ4Rc rQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 39m2aaaapj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:53:06 +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 166GoVBY084774; Tue, 6 Jul 2021 16:53:05 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2169.outbound.protection.outlook.com [104.47.57.169]) by userp3020.oracle.com with ESMTP id 39k1nvcqbm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:53:04 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l60gAXcRgwWjhQ7lGumqxFJRPViJdgBKpvOfRZpoxzffwoj92ymA0lnZLG0r6Et1h85kun58g1E1QrgmK0pS5axddfMdqK3EYAB6dkd1j3P3wTSwRmbuAdwbHSZqZRGlm8jChPSzReKDqyiSBEhbHd5fvupGTU8zwzHl0dOgOQc/PwzThwzCcg45DEWc6io3WEZo5/p+EP8OKNAzgG03N1rl86VrqOrduhnkQCyAGJ4rpGsUzF4UWahhCyfN07Zbm4z2Q/Do3/REr4OGjd5CkQY6CvpCr1uFkvZ+JrF3iksyXkdr+rUkmLikU7qzN8QC+4SS8o9b1Eq3HwJKB/GELw== 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=T4YNtbBFKtOnN5JhWS0xM4UOSmd+qHyZiSfi7Iax8JA=; b=O+tJ1sO0CMSlG1sjSNH1Jh08uMbXRIg1shds2B033gTFoYXAcawOF2DrM8ldde6wo42ZK3PagGBr2y4j9QnlF4KYEV9PkCM8s2ui7n5bqgnuMgooXsVrioZGV91sbyii0fhE5haMXFlK8nXMJepiiaGE1KGu6W0NgbW49VULLTfnYTTOWWD6PcJtfWOKypbGNfoXmAIt9WGTo4zIYgEi9UUidYoBOlt/Gecd0DH0MUpF+y5dqHgSg2eYgBstZySg0+ll9NnGNcXgJk1/bren2rY/+R+oh9nZpVGeyNS8ICCdXtsyQ8O0QgLATmWFJeyXvsphgi2zDB33TRfcmEtFug== 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=T4YNtbBFKtOnN5JhWS0xM4UOSmd+qHyZiSfi7Iax8JA=; b=zJyKxgi61QoGAHBy6lrifJ1ARXrfDTEFLo0uh/+gPKhhndSZRHa0XHTNEfygrFGoEAFeGM94ljuy6WP73YEElESB2Y65Z8F3pIOQad0Rpc3yng3HPtRFu1uE6AMYTOeYUnbxN9IuCYJ/kxkwD9Sfz60E2ZNj6xUGPx1/vHRcyNE= 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 BYAPR10MB2805.namprd10.prod.outlook.com (2603:10b6:a03:8b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.20; Tue, 6 Jul 2021 16:53:02 +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; Tue, 6 Jul 2021 16:53:02 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V4 14/25] pci: export functions for cpr Date: Tue, 6 Jul 2021 09:45:45 -0700 Message-Id: <1625589956-81651-15-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> References: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) 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.4) by SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Tue, 6 Jul 2021 16:53:00 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 310e8eeb-e0f9-486c-4a91-08d9409e846d X-MS-TrafficTypeDiagnostic: BYAPR10MB2805: 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: +32esBfkUqDXFU0lY4sFaWy2FRYWOTEa+ZlMPSITzU57SK1FxCyM31j3c/60BqdO8mmordl/3DBfG5z9PnZwjFc9xJe2Tx2B3djQz3vqR5PJgRf1t65580TwiAMNKxlXGVV6AgaaKufle/IFwz0IZ6S+saZqI0F78yCxPmREPMvb5yD6ktCe1JTgVVjQl6qo6/vrL7XrZyaM5HjQ2qgDYxIORUQ4MeRRKa4eRQ02c/zIybcRg+L9lZU7Et8Enm+DPgIJr33Ktq3nvzVpK8viyXjizv3gn0lI24A2lw8f2X5y9pCUWKQvnFaI/fbzitHX4xtjRtXNQP20jXI6ofsgkP6jYKzS2m1MQc37G554Rp+uOxvoKh92fZDYoi2fSdwwqBMiePqiIyGq3z9EZHBoM6jB7/cRJ+NqAKTxP2llTf3B8F+dIqaoO9P759Uc+Iu7hl8nwDAgrc6FSth2FHzQDMYsSgj22S1vnCbPhtyLqtz/p2Vzo0pf/CijskOuDvqfyEsx+lJkQBD5N6SKtaTtEjKvF21beqwoktYgbglmvLzL9CkK2jekpbO015DVW/OKzP9kCeseK806TzADmn6StDsRkCNmy1duCfkqF/Mvb9kescci5/e5X5FUqoZK6jn3kffctLdzR3fs0K3s69jfODh7euFgQ0Cx3bKB7ewE8B9o1EUDjXtJRvotcpCy/EMhOuPtQzLttuF9MkRI19vwqA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(39860400002)(376002)(346002)(396003)(366004)(4326008)(2616005)(54906003)(26005)(107886003)(5660300002)(83380400001)(6486002)(7696005)(186003)(66946007)(66476007)(66556008)(52116002)(956004)(86362001)(6916009)(7416002)(36756003)(316002)(38100700002)(6666004)(38350700002)(2906002)(8676002)(478600001)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: SALo1D8CBs9osCbNvov+KBEV7RQFnNnsK7zx3QmQY4k5eejpmcgW44LWKQV2kIAP14dzIA0doONB+7qMG5XNR3VSWMZhWa5lB3rIyWtnzS30H5CiYsWgfXi1YXAfZxDSQLTgJoz1qBDTtvZ2+3zTcJblC6LcUN2w2Ut19foqi9CZK5RzrbpF1AZ9MoV6eEmmGH7M3jjlZCT3vQz07anUfdfbg2iYPuDw8zrRQhSh3rVVrMJXXQXxd7Rhpq6dJMnWJGdfXu5hEvP9p6CmxY8ZlrA8aSlOm2YCyeFHaP0mgHtiTkPYTStRsCfpxT/mxyOC5NmiryUlNJkGxe+pMsaGsRKCR+6t4jJo8aCESVXDMW+sS+XCakQwSd76y9WZnBMZX9S0JmFAJnUNTftzecj5mMjeI8UhdycZt92ySA7pl94bv3y4bW3bwfq+qPcBMYzTnLO5C/GFbAlcRIvgr7v9CNroLI6BV89SqtQmJoaVZvQV4FSMYuDJxa/1nC0Lh95xb73wQm7brizb4IlcucN/NhhAPDmsEIzRRx99w/YlPjNOKqyCeV3wjaiE0GOrqnKgRDF2kbPX5cj+AgRJiTlBFhHQ1AHctW23I13OYqMqf4zeYWYUd8xixjgEiobTbA25HNNlstlsIic51HEthuyo+jYvT6e+05Efs8nFpfgpK8sRQab6+9UjNJ+p5p8RDQnGu/gP8v4oUxeVM1ivLUMAMRwmyR9burjoJtmSJ7LKAc9WIrlW6GrBwtSAK/UflNJPd9krnE8STTtrEwFSUd/kYb5Jd1g5Bz9PjPAQdkgzJoBbZ2QMUTifAm7/nsb1vcVW1khlWLtlytGpmU1z8Gveqmh4G/UB3gSJ03K8T+CZQllABQl65zxN9lMGZVFWbvSzWn0boUGzRsI1uUNWSj8vU5a56q2xX38WtY4z3scUiw72MJOuokET6Jn/rz8WTcaeGz4E3vCT0Y1jWnOXAbd/sOBBdh0REL0bDwBae7aDHgNHoHrESrk54zSk9ZFdfLSozVJx8miHOrJej9khDg3gn67bB+9h/fl582XU32JSwKUdClD1sMmE+oEkTS5Krhyn/4bnlYJhwbPnCQT3ybc0pllFmHGMEJz+b4mG5OzNTKkzBMlUDbqppgpHCyAW5/DYduBkXXIJHG2Q8VNqRbCJlYzBWkKDmBizSsD/p1Hlr/Du8hNPaaiRgWYRC88vn7wIvsxthZQnGf3yNrtCTm2sgx9EOdkKuwdUYjvdXZURJD5CwmvPbI6x7bg5g5ofL0STloCp4kNbrI6QK7mBboKE/ezy6+7W0pAOfHS8xRtwWA9XAjfx+pinOqfCI37CGmm3 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 310e8eeb-e0f9-486c-4a91-08d9409e846d X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2021 16:53:02.1580 (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: eDqob7mKiKyvnqwJ3Nd+2VucrAfKz7Qumnf9sH7d+Y2yy0ypZg8+XHTER0/iM4ioMynn/5cS8T0m8qsUz5a6LoE2IevoppHZSOFCxEN9rYY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2805 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-2107060079 X-Proofpoint-ORIG-GUID: r6mg3EkUUDf7xZvY_K0pYhKpjkWAfcMZ X-Proofpoint-GUID: r6mg3EkUUDf7xZvY_K0pYhKpjkWAfcMZ 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 8f35e13..e08d981 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -226,7 +226,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); @@ -1335,7 +1334,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 Tue Jul 6 16:45:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12360947 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DFE21C07E96 for ; Tue, 6 Jul 2021 17:06:03 +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 5D8E461C3B for ; Tue, 6 Jul 2021 17:06:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5D8E461C3B 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]:42868 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0oWI-0003Ay-H6 for qemu-devel@archiver.kernel.org; Tue, 06 Jul 2021 13:06:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59538) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oJr-00016y-Sd for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:53:11 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:30358) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oJp-000859-P8 for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:53:11 -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 166GqBfd003755; Tue, 6 Jul 2021 16:53:07 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=gSQK3TDCc8tH9uAJIpMOgjWelDt8bBTWoq5/mKAXMJA=; b=WrljamtJzKHxcyXDwy5GTsZk40v4f/ZIx335Akqjnak68n0Ova5S0owaX/mrlWVytb9v y04+mrbnvYa8Ac8AY4x0TRFzA9uZg8XtVSk970IhauM4zneyVA2/orX+tbrOqXjLRwJl ceEpfQUzKw0TqcZVr7mwo+tb88paGRcXm5WydsRuHBwPNbkLP7pmEbM0vqBLTG6q7v0B Ed/SiVh35p72HLu9OQ4rUzcfGep59mjcjBK3N7QO8J8TPx1yDGEzBFDtTzYivjLn52Wh Os/2oxlAkP6mohcXbWYEJK+D7tx4NrppO2pMYzhwo13y6rEsW4LsZ2zbr+Kwtrw2IWbb /g== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 39m27hac66-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:53:07 +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 166GoIq7012594; Tue, 6 Jul 2021 16:53:06 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam08lp2047.outbound.protection.outlook.com [104.47.73.47]) by aserp3020.oracle.com with ESMTP id 39jfq8vjh9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:53:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gT6zp8sbLc4tu682dIGRnGZ4xENKvbbm6X/Wrg4svNAHMivQnYl6jacam8gWbBLbmAr7TNIYSJAT134dQ90QkKCeRtvWI08+r+337Zh+4CmnlipiVo15k1V3lL1IsPq3CkSpvKQ0QcLYIj1pn/xVInpKgRtK1cn02mhkvrMgwfEU/7EdQg+vC1AhTKUT2FcKuF+gZokUPfxS36UaP9LDZT/QQflRl+vpsT2zCXb3Xc07TUV8oAoUcQ0Rrs5Y6qB95inbuE3E20HV3ckv+cG6zpT5xosP2G0fiY8dsmehqRnAnzyl3Nen3laVgHMjQuQwwxgR6YQ7xDzAXymBm3Affw== 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=gSQK3TDCc8tH9uAJIpMOgjWelDt8bBTWoq5/mKAXMJA=; b=D7vaL2Fem4Gl6heKzvn23hnTMeQ458ksiQrafOls4MTIoy+8931tYUIagl92FPBPnNyipGui+bx54jjSBBTPZY0eI8tG40sCRsmIrJxS0V7z/MR69JMrytP/YEEtFZ4RNettzsfnbNK8DgElrvfjFJlK2zPPjsE6L6BqBx6Xd4b7VKayu63Fbaa3+ASL7ejXzG1H1Grj5YHEkUWM1zl15K096flJaueCeY8zNrwAcfm574QXL76i1tGazq4DbAzw/wOpReB4qRCt58LT/6tBBEEhcCh5m4mveC+4uzmysXG6VfDzqdsb9GHTHtmpRJ0KjOAWqQUTYX95JORXXphtpw== 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=gSQK3TDCc8tH9uAJIpMOgjWelDt8bBTWoq5/mKAXMJA=; b=ON7aqYgRCSpfjNUaL0NBvYzPGcRheMu38KpULeI9O8tXHYyGAgaTwjRpa6+cblDEkaQ11x5aT3vkUIBsylhzzG5kqAKy5ETfl1167QU0oUqkRmh+KjA0ztP2lPiiMaWHBXkMngzo4R6P3TBkAoqgSEf+G5w0FJALkhw8ft/vNaY= 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 BYAPR10MB2982.namprd10.prod.outlook.com (2603:10b6:a03:8a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19; Tue, 6 Jul 2021 16:53:04 +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; Tue, 6 Jul 2021 16:53:04 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V4 15/25] vfio-pci: refactor for cpr Date: Tue, 6 Jul 2021 09:45:46 -0700 Message-Id: <1625589956-81651-16-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> References: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) 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.4) by SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Tue, 6 Jul 2021 16:53:02 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 86499a2b-b967-476f-aca9-08d9409e8584 X-MS-TrafficTypeDiagnostic: BYAPR10MB2982: 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: h6fQRIHfPagYlPTxJ6n4E+pyg/hGjqXitwVBa5q2Mps7p8Z7KQKtHJxe3AtyxvZmhvjaSRovJcJfHH6eL3utkz7xVeCKj56WIEKjqgvY3lRp+lhfd9RZdXoEuasaXZo61JWzdTXn2vWDX3b43kPyuDQ6l0g7tApS+SJPLzEHz2kw38yspazk32A70qYN5HVmq1SmKIfGBlh/m4cyr5fJ5ERVm8bBzo7a/DKEl5fruxqzmvPCu998/WcY5TwuRq4MgZNLJMUPQ+A7q8yc0/dsAS3yAquZ5+LtukooFqFbrjGOItazmmqItEFWHviHPIXdad1609MoPID9g/D1vhtQKuu3vpVgoLxfj0ai04UkGRBBWBn9H7W7scCou1LJLeSLxrCeCJtabOX1p8UkR1JwZdPTwwMloA4zdbCa6dYCWkCqye4CO9pM1vp4uvIA1uoCu0q+y6zRwcWdTdaqSU0kk6C0Vby3BPOUjibmJx/LbKqGLVNakdhmlaEMkO5wPu7zpXjFJtNNUb6fGy8dxBRiCh103tC7dB6DMvF6pqEhzek0JFniPRSWd0NB8LzsolhiHVZBtd+EIqG8Usdaw6nmaAzATYmzzr/26IXkba0r6yXOXBAGwi+mEp9pBeLhb7GAQiJRxWimgIOvijFCC3IZaLwax8vBN0K8QinJQTw6SXv5e+HSwEiEVo5zJ+ip406Q+1Siuxuwh8lWn08sltVXRw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(346002)(366004)(136003)(396003)(376002)(956004)(8936002)(83380400001)(2616005)(7696005)(316002)(52116002)(6666004)(478600001)(26005)(8676002)(38350700002)(38100700002)(186003)(36756003)(86362001)(6486002)(7416002)(66946007)(54906003)(2906002)(107886003)(4326008)(66476007)(6916009)(66556008)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: nLJSo4H8LRAueC3qWCVkdwCy9LdVKYK65LONeq5G/sDcsLqAAZybyiI07JOAg8YAFGUsIG/TFu+PJLq0YiW6CaFbhawk/hBzBKjv0ZuQ6BkT7eB5VOJZ8IwUWU6nscCvCfjYnCKmaCy/h82pP0aGyYJx6+aQspjqOWsMI6fcbQz7AzSDf4bmxXNGT/X0tjW9yBNKBPwTyhwElkAYUXTImKbvSAjtORbiipelfIZpnPbbTTvMbp4L2Sd6T/XsBsTyDvc4oUYr9W4WCte4EooWO8UV4oulJ6aHkHXF8PcFU21ZWVvr+DCU2b3p3qIE1hmRLMaBkAPN9+fNORUtpilqTIb08e2BS+98wu0gEtj4RQqT/Lu55Ry6lxLolhRZG3TvJf5pwCls1mONjBGZNX7lGOYhS7J4xcr5fsqPd0Fst6JPzEj+nxNIZVKnLMge/P8y9Daqu+BKPfIt47cETHpQjO4By6j+4HSgU5wEJIAfasWw+DVnvHIHccj6UPRLddA4TZubGwWaEgQ6UVhRT6uQ+hzFvgNI/1eW3/lSVnR9Q0OyQM/IiCoByPcJImWtsAwx9AQrXmIQc3xwdBGLWV7aR+tsJKWN8Ok4BwRNk/ZlLEr3hzAG4XrTZeipGiz6elEBnYp+rlKvg5E4Q0/rWFTcGL6OTvTebMsPr5kS2MRxAqooY3wQIN7nWxDmggzbVrSk20BQnrre97JKCosxYMXHaBdQ8KE8rZLNHm3bJIVbBJlguRH04vXUPw4LGzNUnHVBYLBJL98TFMV1+x/K3qLSrDbx88UuktBWI6xxCEvaddiXs0QMt2ovBSUO7j38saiJwpcVk51q05Sn4lfciW8aQ4/YUHoPL1wc55+TnAb1TfFV29ARFGpX3OidWQ2pv1kPfCHrhicnsHAOc4UGINm8131+xOETxAWGZdnbnFDM2zBcMKW8zI2RD1EquBH6uJJEDhscLI8pDY5jIQyJ16wLAs7BYNxFuAYdaPXAqApxFTMpXcOxiW10A5ZfnW2vvOrriKBMEG26L97xHPcAi/gJQoPu9P7Wvs1bKwkmF951qlFWIK+I86qCILvRiI6eKCP74WOIrPdrzn3+upXEKpPRIYGw3078HPiTaL3fYklfrHGZbYtZlTL+YVLFSo7aYYJh+xDoaGfjaqxs7uHlRVNgEC3ugizDpHmfIyYjE4bfD0qWuj8t/UWFXFSfAXlxHhENJMyIAla8bXThF6rz2G7nPVNOHkqTbmdHMky/W5poKwmutasKDO1ONxOXEtH4HXQ7qY8t+aoM409hc3eu3+TMnnidm0Hh6KK3FNT3zcFGA1cuFa4VvkaVfYr6x8ZhUwW/ X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 86499a2b-b967-476f-aca9-08d9409e8584 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2021 16:53:03.9740 (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: KWmP6TL9kjnbGpNYwnaQ/aQuGx6x8qiGlT+LWH9c3v7q3QpXQsvGNi11ykOrkVr+kmqrU9YJ98TsCwJi0k3N5/+nUDwknF3vGvvszTC864c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2982 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-2107060079 X-Proofpoint-ORIG-GUID: DoByVO6AI8LP-p1JPJCieyCSX3lo7__V X-Proofpoint-GUID: DoByVO6AI8LP-p1JPJCieyCSX3lo7__V 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 5c65aa0..bc656e9 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -410,8 +410,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; @@ -419,7 +430,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; } @@ -455,6 +466,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) { @@ -467,13 +492,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), @@ -491,7 +510,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); } } @@ -641,7 +660,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 Tue Jul 6 16:45:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12360957 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 481B9C07E96 for ; Tue, 6 Jul 2021 17:11: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 ABBD061C53 for ; Tue, 6 Jul 2021 17:11:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ABBD061C53 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]:58430 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0oba-0005Bm-N9 for qemu-devel@archiver.kernel.org; Tue, 06 Jul 2021 13:11:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oKt-0004Fm-05 for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:54:15 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:50008) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oKp-00088v-M4 for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:54:14 -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 166Gpkbl007370; Tue, 6 Jul 2021 16:53:09 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=S76s+N5xDhYUe376t9WmNmGhiDCL+3ZcIwsbHLWyF6U=; b=b5tVvM4FEAlkYzTsEsHFv30sTPLSR/j6ozyLL4SeC2UkJYdIOoF6wLsY+gF2n7IR9Zrn SxzrS+DT6kSUNzhZp+oSuHL5EEhFhg3B8d3zKvLtVWWXa74Jg5dY86zLMEUzoPgQNCsY nMpbVEPbbzGtRxpvZd7OtJZ23KKRBVb3RvtrEvjR47LcIwmIb9InQ9mzj/qqLru7e15e 77Ph21Qumdt2j44WBAgkVTJVyZnqwOL25WZ9cDqMZ27gd0+OfAcb6OucNZR6jOGSXmI8 TN3sb10elOaod/M/d5wwaNlhIlVzXlMj1B7l1p3zBJGlWxnT9TvcTwj9D8dYmO1xk2RQ gA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 39kw5k32fr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:53:09 +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 166GoHRx012560; Tue, 6 Jul 2021 16:53:08 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam08lp2045.outbound.protection.outlook.com [104.47.73.45]) by aserp3020.oracle.com with ESMTP id 39jfq8vjk1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:53:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FKuYfdJKtMt52BSuT2b7Nu6vSciHViVO1cDoQ0HTGmM2MkYGArpWPQbjUq5/Ba4f3a2UWI8Di05LCWAOFMAbXGqBF5TOyZ+C5Nmq4Acobk1H2raQQH33zxRZlfNV8l44nimA6zD9UBB6o3kK/FgmR5EEApLvfRn7arYaE2eJaLA99jO6lnfABVdgWAC7Y+R9zEbKrTRvL8wEePjVAWoMB0znGpXGsWT1ZEh/IByvhoG/o4rSIn5mEW8KKVuGG2mtQ/3d3YVLR2fvVStDrOWl8gfu5EbG9nAiI3L2AsTujvZqgHzHJxdLHp0oKQTDybZY+/z+D+ysbMR99PEqFUZNmQ== 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=S76s+N5xDhYUe376t9WmNmGhiDCL+3ZcIwsbHLWyF6U=; b=VnYSUOu+2dd6g+6W5IU5xtWpCxkgS96iZvvh0gX3T+O83WJQ7taoWhDI9XXCankLilZzvuqv1MkhEAuvLNnOcso7lEjtyc0u2oAhFRprXxOa6v4fGhewP75vkWAMPJrw1z8jrZElauFgODDAhYd/IncQ09h6OrpeUfMiDBYrrgQERMo43frfG9xtQKDjhnsf1NuEKREMZh5LuAxiD+8vht2FG21KPZ2oHPZI0M99jHQR/8j13u8RTP8IC1sQ8lUP2MoyjomFLdtQjvNrsM5QgOaUyM7b4Um7npDAlt7t8aERAJU1Wa/O6pLE1LVmAQwVQGMemUMkuAwdNZOK9AtlJw== 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=S76s+N5xDhYUe376t9WmNmGhiDCL+3ZcIwsbHLWyF6U=; b=JhlV0Ql4b7FJA8pn+K3GSu7fqsIshu2gKzRG3nCsbPq98lSJW++USKVk2m4jbRWjMJ+bzsiFYR22wZ2Jz2VepMG5NGYRQ05EtKG/5FEynwE4jJq1M6lSzAoyv5q3sJlvU0591xdkDAd94oBudk4FWTD9sRRNfQbecGvnxe/g178= 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 BYAPR10MB2982.namprd10.prod.outlook.com (2603:10b6:a03:8a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19; Tue, 6 Jul 2021 16:53:05 +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; Tue, 6 Jul 2021 16:53:05 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V4 16/25] vfio-pci: cpr part 1 Date: Tue, 6 Jul 2021 09:45:47 -0700 Message-Id: <1625589956-81651-17-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> References: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) 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.4) by SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Tue, 6 Jul 2021 16:53:04 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 84083592-e9a1-4068-af74-08d9409e869a X-MS-TrafficTypeDiagnostic: BYAPR10MB2982: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:240; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dOFT1Ei+Q5P3h245tL/vvBAWGSgE/1gpWFuaqeTxfb2R9ijAX1CGw8RVbYKkZKP/t9bbNWOdj2nwGF/EVpYOHwfyU7TQtxFGMU16MqR45kpA++QZwiWNyfWR2voDFJcLpXu1jo49cIPGIWUoAukezNSNvS7AUonUedh7G3xdYTwKc42qjRBMqwWc30e6VaR4PI3TKS51g96PLuTLSsdKo0h+T8x68kRj9vyHoPoG0IxTADU8e2KwI2r1CdiNu37TsgzpS4KPcP6duD06txUw9ez9o5N4yw1NyktMbZxaBbdx81hd2PjXWilQVY8G32I0sbVpyyv3p62SwVjq/LCZAtj91ii8qnoxFBWc+f69uL2+IgqcLcFN8HfG+NZIh8Up3bS6rR+s00a8EpbfaIr56HzqBYOYRYNoYibj8TaDFuMd0Zrc59TNVMH0S3XNu+s0YnHIwFWamC6sJonT8Yc5yG8C5yjKgCl6Pwuznk+p8zjozpYmltR8s0q0wq0wpg4xL/mWVjgYp/200e2Xz/znM1YD+MEBe2cey94j1/fInTmXt3J/AseuN+04VUSTTT98qIVzZq17ZzYJRVSz6ENa+BVv2tIfHux6KuqHUqjPNyOyIgrh/tesrCnpGedvNz0rV02Y4oZAXChGf6d9qAtYUxU4secVMYZcywZSRlSkCnbigZebOxZL2dKSdGCcxadO X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(346002)(366004)(136003)(396003)(376002)(956004)(8936002)(83380400001)(2616005)(7696005)(316002)(52116002)(6666004)(478600001)(26005)(8676002)(38350700002)(38100700002)(186003)(36756003)(86362001)(6486002)(7416002)(66946007)(30864003)(54906003)(2906002)(107886003)(4326008)(66476007)(6916009)(66556008)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5Eo/8HaYAvqU7TIIxd7Qgu1u4OCPiCt3YhUEangFdtgQmQDpzTaGuLekCkgw/1bSVzrIhPzJ1E5KiS5pTFhH+1C2YfhyTK2F5PzPL/GwusINrxFovVOVZAe+cZb9N5y7nET9dz8Wv1yVmrTFAVeAQhZPPVZj2YIoGVSo4RBgxIYZDHYD5W8MerfpEtyd2uJZXowxBCeHyPP2WBFyz+SOdHtjNMIVJckYFM3FoSVK5/7TiICHxGOZnDvX0Hzja0pgnc5MLR5BajGygsE7OY+YINn9A9AXqSdQDrM9VOjpjcDyg/sS3hK+E8pf0JnRmWn8Em9r8Bad3amfV1eiDSCxgeRrEZlU7RgisNy3Yrvg3qUILU4sei6dedsKeEysiiXRO4gKgyAOHhgxpoGPQGxWuFu/catNrSWuKYkNjV5DTJPaascH/I/3PLKaTp3CusHluSaRvKhefdTlgPq5uj8Uu4X7YgDpAjagfa00xYstLemweMcbH5AQLnhuc+Nl48Bj0tdBuzhz89o6Pa0Tsa9WGnzrWUdIXpaNhDtowqpEGUAORFUPsqohGpiwW6FXb3h9igVAFGvZjtndQqk9SoRCtYrJMZATqUAf/deBo2DazSSa5r2WUunyuXFoUsiEC8yVt8Zcdmq5o06lwuv2t5hXEnkg6UVKkpW3D2UOF8Z2Lb2AGmbAB385FG7b2qgEsk9nynfev2q7v7Hx91ePazIIR5kFjPP+GaGsVSbB2VENzYePPSkJpXTQkzUkfBuXmn4Uwc1RGFC8k7FQp2ew8/bkSmLV4tAVhMKjBia9u4bKaAKyk/3V2p+ix1szQ+51p9UfdA0pl9GinHJPwy60HLhq8pbBcoD9s0K7Q6Q8FjsF8b2KJWtHXV8x0yj311S16s1QTTaopRJd42To3XynJXLWYc2agRaBikFyCgzzQqujA27Pnvi6mcrPyptr4j1CJxOZz55D95wn6wB6FQCj+eLBEWsvxkFQPF1kodrS8Wx1SQnc3zQqBdibIGuuw7P4lAERfHnEdG+4QY/3oMTNy7pSPV/O1p+PaTjYJ8v8pwCqWEmjzB6OaTUnWduRGf1ZtENad5m1+hk9DsWNJWf0u9vat6YQUCYxZXp7p1NctAaxOnZ2+PSemd1aSm7e43unF+piuEftPZFjRooj6nvsv6i4sd7DyIVkyn7+csqGDixhhFLEfg5ImCa30XwUGCF/ObvlT94qK2XQLooZMGTRLBUocofXp5yvMmDtbYIuWrUEUkEVijdfQr4fpswyf0FCsEIkCRAogjNsjB+ZmKjgWYjg2FLsgHrD0osPMlDQdbEj9grXiu7+2VPKzGwGwS24p+pU X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 84083592-e9a1-4068-af74-08d9409e869a X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2021 16:53:05.8229 (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: /TkFIQLlcyW4AHcXpgBIu9tIYuchjmMhEp9D2x5II77InekS5I9ddyNeHSJjYcEfxDgLJTDcEb+FRA15ZuCmkMfdAbtdWRg/lsIQzjesXZU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2982 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-2107060079 X-Proofpoint-GUID: wh6RIsBtuCOzrAvGveEeKyF7zxflxcT9 X-Proofpoint-ORIG-GUID: wh6RIsBtuCOzrAvGveEeKyF7zxflxcT9 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 | 27 ++++++++ migration/cpr.c | 20 ++++++ 12 files changed, 344 insertions(+), 8 deletions(-) create mode 100644 hw/vfio/cpr.c diff --git a/MAINTAINERS b/MAINTAINERS index b844f3f..b69bbf5 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2847,6 +2847,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 e08d981..27019ca 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -308,6 +308,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 bc656e9..f3a9361 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" @@ -1657,6 +1659,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) { @@ -1677,7 +1680,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) @@ -2889,6 +2892,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) { @@ -3158,6 +3162,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); @@ -3265,6 +3273,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); @@ -3272,6 +3335,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 079f53a..0f8b166 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 609099e..bc3a66e 100644 --- a/linux-headers/linux/vfio.h +++ b/linux-headers/linux/vfio.h @@ -46,6 +46,12 @@ */ #define VFIO_NOIOMMU_IOMMU 8 +/* 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 @@ -1074,12 +1080,22 @@ struct vfio_iommu_type1_info_dma_avail { * * Map process virtual addresses to IO virtual addresses using the * provided struct vfio_dma_map. Caller sets argsz. READ &/ WRITE required. + * + * If flags & VFIO_DMA_MAP_FLAG_VADDR, record the new base vaddr for iova, and + * unblock translation of host virtual addresses in the iova range. The vaddr + * must have previously been invalidated with VFIO_DMA_UNMAP_FLAG_VADDR. To + * maintain memory consistency within the user application, the updated vaddr + * must address the same memory object as originally mapped. Failure to do so + * will result in user memory corruption and/or device misbehavior. iova and + * size must match those in the original MAP_DMA call. Protection is not + * changed, and the READ & WRITE flags must be 0. */ struct vfio_iommu_type1_dma_map { __u32 argsz; __u32 flags; #define VFIO_DMA_MAP_FLAG_READ (1 << 0) /* readable from device */ #define VFIO_DMA_MAP_FLAG_WRITE (1 << 1) /* writable from device */ +#define VFIO_DMA_MAP_FLAG_VADDR (1 << 2) __u64 vaddr; /* Process virtual address */ __u64 iova; /* IO virtual address */ __u64 size; /* Size of mapping (bytes) */ @@ -1102,6 +1118,7 @@ struct vfio_bitmap { * field. No guarantee is made to the user that arbitrary unmaps of iova * or size different from those used in the original mapping call will * succeed. + * * VFIO_DMA_UNMAP_FLAG_GET_DIRTY_BITMAP should be set to get the dirty bitmap * before unmapping IO virtual addresses. When this flag is set, the user must * provide a struct vfio_bitmap in data[]. User must provide zero-allocated @@ -1111,11 +1128,21 @@ struct vfio_bitmap { * indicates that the page at that offset from iova is dirty. A Bitmap of the * pages in the range of unmapped size is returned in the user-provided * vfio_bitmap.data. + * + * If flags & VFIO_DMA_UNMAP_FLAG_ALL, unmap all addresses. iova and size + * must be 0. This cannot be combined with the get-dirty-bitmap flag. + * + * If flags & VFIO_DMA_UNMAP_FLAG_VADDR, do not unmap, but invalidate host + * virtual addresses in the iova range. Tasks that attempt to translate an + * iova's vaddr will block. DMA to already-mapped pages continues. This + * cannot be combined with the get-dirty-bitmap flag. */ struct vfio_iommu_type1_dma_unmap { __u32 argsz; __u32 flags; #define VFIO_DMA_UNMAP_FLAG_GET_DIRTY_BITMAP (1 << 0) +#define VFIO_DMA_UNMAP_FLAG_ALL (1 << 1) +#define VFIO_DMA_UNMAP_FLAG_VADDR (1 << 2) __u64 iova; /* IO virtual address */ __u64 size; /* Size of mapping (bytes) */ __u8 data[]; 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 Tue Jul 6 16:45:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12360951 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A65C8C07E96 for ; Tue, 6 Jul 2021 17:08:13 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 343A561C4E for ; Tue, 6 Jul 2021 17:08:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 343A561C4E 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]:48854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0oYO-0007Ed-DQ for qemu-devel@archiver.kernel.org; Tue, 06 Jul 2021 13:08:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59554) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oJw-0001PY-GI for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:53:16 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:37226) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oJu-00085S-9s for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:53:16 -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 166Gq19l012747; Tue, 6 Jul 2021 16:53:11 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=TxklaF2MN/PNNpG/2+9yDVEFV9alHgCIC0aISxROgPk=; b=lPHSxbQw89jyDAMkzv5K9SUuP1Nr5KkQAYFn3SMOSTCw+m/LWOQ1zKz5fA/npoEkdycW wIkQAwjCMFivaPLfLzHbh6Wvrkr3hHjUtRP0YVpJRBd1yc6AkAgw/ATDoWmFks12iNfc 8eifLfmTPFJHSBertorhlGtKspx0BVT8ezqHoOkZrhl06Z7lEWw6uoI9VQKBDm9eaU0e 9BA2ryaopiapvoYIqAX+k1oGMQjrqVvPuEZZE9q8db1BBPQGUMVW/6IBjhlkoy7MfeQA SIKTVlJnAEuRwb055sqwGnuLOmn0YyiXVv9/7QkDXYyZtMfadm9HDqvmg+KLoIlMNbPj mA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 39kq8ebbg9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:53:11 +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 166GoK5X012778; Tue, 6 Jul 2021 16:53:10 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2172.outbound.protection.outlook.com [104.47.57.172]) by aserp3020.oracle.com with ESMTP id 39jfq8vjm0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:53:09 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eXiUGD57u7G0zDrqLRTSlTafKl06wCt8KMexT9VebEzcfOrFVymRVqDH37NQls1Gkyms5XIALdh9TwIJAZZ4MosC2mV4u/E6slbcfiHq2eZTvYOHEXth4kPGBnHEPbrUpMxUI5FUxcxgyBEvhH9sUrjbJ9eKPdWwtdg0dtHymjt06br8IW8Bc9x9dHkth+psfCqw6pgFt7hm9Knkuw2lxegdQtBlWXZR7jfIh2+pyhTIqvdxC+A3kM1gt2B02aSqdRwNuUwlXP/asRXKyLEEBG9aAr6efKsLIRIfIl77WN4LuanAJlJ4VK/C3fPh/wZ/ho/PaHcRjARA5QGLuEOPMA== 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=TxklaF2MN/PNNpG/2+9yDVEFV9alHgCIC0aISxROgPk=; b=aPNnTO63xCHW7QFIsYsxlIBiPqC3JYpBCrZDMjNMgNt1aCe0hw13FUvcPlas8pgz4iQXk5LZtmOU419eUAWj840CaVA/sFeeWd9SYntgikUnnONQBX5ooMcVS/0ezXjDUFKjI4WMbVf+CqNAPQA+BPB2F0Cps7JA7WzLJj0n9oQwBfio5zZZMyhM2mqEaaOHVeLrGchZW96oy9gsh0/y3GqVq9D0vRpwuuX9DFBU1hkn4byTyg+jiMN3TUP6tUGf64GoI1vo6Bc1bd3Bcqq8YXue77KoxNCmPctEZDOJyR1CSlgrq8wa1BIBIlSSFeZe5SkXNs/Hws6S7s9ml7RPig== 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=TxklaF2MN/PNNpG/2+9yDVEFV9alHgCIC0aISxROgPk=; b=T4M3Q1X0ErqHA9Yf9k6jt3Q6R9HoQIsykmc+SZAiwVM0Pam0sc0aW+n4pedoCq4qbC9UZI+qdpGWEU2pMhcUaEqHmvhhcEk3LlNL4N5Sb3aue0yhoWIdep/rUiWpP2RSHPRr5r0gi6ASOMqT6NPPgNEjwqRqs4ICqQgQyYloE6g= 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 BYAPR10MB2805.namprd10.prod.outlook.com (2603:10b6:a03:8b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.20; Tue, 6 Jul 2021 16:53:07 +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; Tue, 6 Jul 2021 16:53:07 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V4 17/25] vfio-pci: cpr part 2 Date: Tue, 6 Jul 2021 09:45:48 -0700 Message-Id: <1625589956-81651-18-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> References: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) 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.4) by SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Tue, 6 Jul 2021 16:53:06 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 18f39dc4-b543-4154-9d11-08d9409e87a8 X-MS-TrafficTypeDiagnostic: BYAPR10MB2805: 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: yh9qXdjIXRg/4OrrBgc9WS7hzjMCRgSbvHLhyPwQ4iJRJuOinfKMqtNC1LMVDU/CtH8nqM/pX64PS9x4Rg5dBMlvn1RkZBkyY4Gv+BDCY4ndAQ4qzUpQBgzNP9eN16+TUO2HOgjcHs+mKU9KmGzfQ0r5A60/Nbg9Ih8+liHYQXYTB28Q8epPcNcJlTPOcdmQ31OB84Al0irjXluUr5Uh38KWShLyhIKy2QT4niAQEJE2y957nqFTRp0eyedMf88gZANGMTzFMBznuNhImKB66oEYHOGAcwR9wFBvvzZEFjGMXwuZBMM0lEI86NdcSfkjSiOn97mYOqjdAWPZW7XgJ3oos0k8NWWC1SWSpLpYnBt6uaz+L8Y1bT5/npH/MyCBMXlza1g82LIqOPnE+wF6lOuyY+VFUkUNf1spxk/aQ6PinRs3AAq7m1Grp2JWcuGB87UM6YSE91KqnwluzhvfZ7SkeiHm0+r+84gZMeaWxLWUOiZ4LbyP8oEfkj4hBH3/1qj8Fnfs49c40wmSpc1auVVi4Nkf0s0l0Ju4YTUckNapp/1r9QjC2dr3fXwrc0HlAoao7895Kxq0YdRLAz8OwV/ke0vIpbJkL508Oc2tDlLPGP6i+B67kfSuL73RxIgB4N02aVgck7YZuBC9KQXoJU6zpF/1otcE57u9AIwx/sW5TihDoIGf0CjcGaFfoi0WtlpvAhiZ/i7NG5XLevbzQA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(39860400002)(376002)(346002)(396003)(366004)(4326008)(2616005)(54906003)(26005)(107886003)(5660300002)(83380400001)(6486002)(7696005)(186003)(66946007)(66476007)(66556008)(52116002)(956004)(86362001)(6916009)(7416002)(36756003)(316002)(38100700002)(6666004)(38350700002)(2906002)(8676002)(478600001)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: eEiF34jJFp3pbPtRkT4djmh3XLUP5dFJcvQk2bagywZNCs359r8WMdZAOZ9hDKWzUoeCRUty4Z/V4XVTGRb/GHnUGpw1cnNo3hVwzRSOtlkNNCDLFSA8MCKXOU9jd/GF2drOrwHl0TdnwFczdVyt4YgQs0QvSm1zH5nVTu6EiRF2/phSFgTv0axhIiSfev9LgdwmGxb3XTueyXINX4XiVSbh+0srrTwBwKjzar0cFG21CXhVkd7Mv2pwtbhSxZG6Fz27HWFfxZ+4zDNdJ5JPK1MwMRr7NY5+6Imewz0jImwmUcj+nms6iwgQ1M4RxZKXK6F4vSaGQZ8Sg+pK+tfvWz/E7nZc1lpWUm0sKmXvdL/cWchnJxixNw+szeC9iwUn3XZFgEa9veW36WxtUAy0wJyT+td3b5hBQin1hk8H62XsrLhRM9IT0l8+PVQ4AGFnuakzjqOEJHBwVVUvYi2H4Laj3sMH1T2r/ZPb/YuENPL3iKENh4MSRffLsjXZLZQIGH3ITBig2yDjOpDD7U674C29AtxIS14hzs0cMGl1HqnH5mH04/QISZxPyYK3Xhl/Crm/Rz84oFcZZW0uD472QxIv4mV+k5EAo5dFY2Fj4Spc/x1LfUnW5mI/A4IJK5j6LoL6ctzbIU8ZiV5t1GF+p0XsPSOSqUB4j2HgR/hfuMfwdJHajU6e2VxM79qcpV2Sr+7FAzUA/S4ZIzQpQ4MmwQsD3mdipj1tXU0AujBsslGTW+5sFn0kacTNb3rmheU/pVBDifFSwD66tbRdkGtRUGTY7zXL7ncRorB5OoEI6bBuKTaVfNisZ47HG2SKZ9oik2P579XqLzbe6I7Hx6lyQcdnNbAdvH0aQUbt2T4T8InCZXd7vwK2H5TYWrTIckHoe5OmC0qzxeAjDknL1tQM0V0H1k3Suo87l75LY7L4ZjFpD9xiW7Q3zRQBjcXVkS+ACHim9gzXYt/AzeYrZhZNeusdD953mdHmMBvolUusmsuSlpPI+sRR7tvXQf8NknVagSh6V3XDlQy2jgNwhMW5eoCCyea/f2aQh4ocQ+2z5OBZ0C3OYgFzsOAth/bE1OHlPok/I/bISjwtufnHj0bQWAI+B+of0ZSFuPToUrkluNCMaSwXpIFSE8OakqyQu1nx5kRxKBRGY6Ou2Yr7hPFMFg87g/8bAMp6WABTZft19soLDVk/BJVBXQ4FqdnrWnfapbhvgl7/V3KMpvViRX4r/gDIlkg9bXh7mwBSsATeRMiYtXZPvIqBRBhyC/KTDP5ff66jQPCnX3R0knJtx7Oo/QRujHn5aeLq+KDCfgtOv15T/r4ZGB8Hw67PdUI1LayC X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 18f39dc4-b543-4154-9d11-08d9409e87a8 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2021 16:53:07.5460 (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: dfr9rh0EWZb3z0FzkBQaQc5qcOhBtPmwC6XKkT0b5NQV7FcHShIABiOLUPemYKr8zwwWmjdPoWagd01MWTYnILWI4FdGO9bc8RZkWs9psw0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2805 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-2107060079 X-Proofpoint-GUID: 3O33SsyH6OhLl6wqi97_Duoq1UVSourw X-Proofpoint-ORIG-GUID: 3O33SsyH6OhLl6wqi97_Duoq1UVSourw 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 f3a9361..492ff31 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -2655,6 +2655,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; @@ -2686,7 +2707,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; @@ -2747,7 +2774,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; @@ -3296,14 +3330,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); @@ -3322,8 +3433,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 Tue Jul 6 16:45:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12360949 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 505A0C07E9C for ; Tue, 6 Jul 2021 17:08:08 +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 EB0BC61C3F for ; Tue, 6 Jul 2021 17:08:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EB0BC61C3F 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]:48466 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0oYI-000705-RB for qemu-devel@archiver.kernel.org; Tue, 06 Jul 2021 13:08:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59638) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oK1-0001gB-06 for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:53:21 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:41838) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oJx-00085g-Bv for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:53:20 -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 166Gq4b2003050; Tue, 6 Jul 2021 16:53: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=Mg9zaUq/68cV4jCumT5Jz/9HgCLRYSFt1ol8+CqmjyA=; b=uvKB4bexWP2a6UlpUrmhnR5j/BtE3gfhHQor+90ckSti4pxJdh3cj51SqQYSmqbzXJ5G Om0F3O3E9vmecie/m6ZKZHV4Ep4INe0MtJXg1yHqZn41KKJyTKgZmslpsBliOtf315Yq m4j7WxSayCWiQo73PIuG63ALbnAzEpbUTbZ1fzGjf/qoEmutvhgTWmpZE0qBIke23d2X 7sl+MjM2AHoMOwIu+rGCij3HNaVT9G0H1WIxeOd8LY5tyWiGPeA7TbV3LWE2jAQrfFHQ RLwe40x8CsOxq/KQCKUANmpdFBHyJYoOeHJdWsW7qbXxIE60vaV4p3IEYR/yvA2p0NKk lA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 39m3mha8g2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:53:13 +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 166GoUJD084680; Tue, 6 Jul 2021 16:53:12 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2171.outbound.protection.outlook.com [104.47.57.171]) by userp3020.oracle.com with ESMTP id 39k1nvcqh5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:53:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FPOBHfgOHHBVMshDDmRPHArXJbSInc/wfY0uP4usyQZnBIZ+x3tJ/bO7FVhfu5JV+LBjAsoLIv5mCAMlFVG7oKFeSuuKypIYZ7GuHZVcVihmfYVBTbALVuUBXKfMZ5qIbb+9y9sfweHu9QE/XhglBfzyJnh9MnTeLNjwT+rUwrC++GXX43GNY5aq9l9uXEt4NjeFbBXeIF9FYTZiEkvSwVJg/WYrdo9+UjRhSum3ET9M+o4CbtvBCbmrEgi9M8jAUsWR5iTggYHIUZ6HPR6bJkPFKGnDnAOiFK6tlHITTSmUwkGLMDKfBOZqvNlxnOsfVumwUuNfbx+Omt4j5eu2cw== 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=Mg9zaUq/68cV4jCumT5Jz/9HgCLRYSFt1ol8+CqmjyA=; b=dcZwb+p/fW/PnXN7GRuzpbT9qktZHs2350AvE/7W+havCMKq5B0y4Kj3mAT+rU7YliI3q8c6greWGBxir/LhYj96yJg/YMCE6bo0me4FLz0y91UhhfjLmSiFaBTgM/X2BSC0H8oPZsDY86KF8AYiKxadCcPyigwA6sHIDUGQkMw04k9cvVasGWYDy9gDHbhp30YMWkV5fx55I9xNz8dSIX5B25P5zpfPqtD6pm4hXhUbH8+li4G61cIpcSHhG4++euY1VG2WJqwHi14OkLYACJUKeiOVOCidY2hlr6e3vbmOiqju65XXoJfGSGZswyBRK+Fn32L3PzgSX5X5UXQZ7A== 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=Mg9zaUq/68cV4jCumT5Jz/9HgCLRYSFt1ol8+CqmjyA=; b=BEEhc7AhVVBpTmG7po7ruppt6bFU/dksul41SoTgVX0IwQ+FL6AlW3kFw7eFByIji3R1hqDKmZRNKrPLgPQzH/6dDnkkxgkzxEMPN7Bjb1hVDwb3KRPtSGKMu70Ssr5Fy6ERVvFK/REe65xeV/4OjMoWrFt930eNNd0dnB7D4DM= 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 BYAPR10MB2805.namprd10.prod.outlook.com (2603:10b6:a03:8b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.20; Tue, 6 Jul 2021 16:53: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; Tue, 6 Jul 2021 16:53:09 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V4 18/25] vhost: reset vhost devices upon cprsave Date: Tue, 6 Jul 2021 09:45:49 -0700 Message-Id: <1625589956-81651-19-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> References: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) 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.4) by SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Tue, 6 Jul 2021 16:53:07 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 065ecd09-0f2e-4ecb-d8c3-08d9409e88b6 X-MS-TrafficTypeDiagnostic: BYAPR10MB2805: 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: SrmCo8h6Pou8oAZv8nZjnf8GkXNn9CHQ9voq80ZwPyCBJJmzw8rT7OaQrcDW1T8xMi3LG7vrSYhgSeOyronbChvZpX8WOhKw8wfwD4lS3mBf46nmCZgtmICRd2aBxYjnTRFldVGMWfOzPlnwMV9bhTJVA5z+KKqmKPHWjkLxGY5gbXtEwVdACVGGJArqopX3pxdYB+2DzYgtIcmiNvUxVeK26pQK2fZ37+CyiKyTIWdv9r4Hvxkqr6nUeAnWV8F0PG14zsKkr8W9E6ZziZO2hXZC57ItY/f1iS6RQP+LB4uNEUgA8Z9lEMhBu+BUa5UvYWb8sBVFsT5GZKpS4cvYIB+c2ITJcAD3ZnMzk9HH62YFs6UcLvVMQj298OXcA16i/Tuv2X4q4i10zUEIWkmQZcNT8UEimaPm7Mr7MOHjK003ncNboVOVzMpilb6E9s2dnJkBYfuhZtpv0yXEjJjlQRz9PLqhE2E2DvEp6p7pu6Xdap0848Of9DM4sHrL72ikby5BaBlx8qFq2x8c5Ttztk7JGC0JfZUIaEaHFRgbu1pPK1FyqLPrJBqCE6ZbgfdXs95QS26EpQgdIMOVu4bC+L2dTl0FnIBBgNEedbN/oCaPQ+YmOjASpSxeRDiuWgwoJpHukqwhBU55DEXHR6HDULigi1xdC5+NOIYdhnHNIikssDPScM49HdPjufeh6f0Pos/sYNFLyJVYvmYfrtuwwQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(39860400002)(376002)(346002)(396003)(366004)(4326008)(2616005)(54906003)(26005)(107886003)(5660300002)(83380400001)(6486002)(7696005)(186003)(66946007)(66476007)(66556008)(52116002)(956004)(86362001)(6916009)(7416002)(36756003)(316002)(38100700002)(6666004)(38350700002)(2906002)(8676002)(478600001)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6023hENl6AOrXoJUATmKTB6899OuQHM6aA8nMAT4un0ILHA0hynWDRTQtJeXkReox/GgGN1Qz14w/VG9xPRQUxfpOqskCtc2UCnuZ/OVa1VHHZbWO6dgNW2ly2drH2osrhXXBnle3NazYGZuNtAHKpJqEMwZbBkNZLPxcKwoXZhv2nPeUIFtDOD3yT08plRu/r4Em236TD60U38rrmreNFNh0ukHwr9zFeSpbMFUiInwLrfyRerOBqc6PLeP9khYBKdKALACwNl4FYPojFIeNvVIIBf9fpvAwGbVQp0MLbYgUlY1EOpgaDsaemdDvgcYvpa8TRjA4WV2WSwV7DbFVa1UP8krEDk27tg/kMDapA2Yza+69gZFnH0LoMzeWXy48RFKixAsLUf/tdDl01+dPqMDroe946cthhTQM2HLYxm3hIiOfq5H3P/xtu4czTjjM1lqdfxInoJqpDFv6ZsgBUuV2lIIijpiuaPQ1O3ESPAEbHHa6l9Pc8etvvjuoCRyind4apgOVjfrisxPeSS7fk/sAMtaKacQ0eyTo45tOGXpXuvrfnWIu1pOgOfB3s2ujIRquRJZvaPvczm5RKpY2ZL3WQWIQMSJy9JOaimBeLttVIoIq3aOpTFSEfHMF8YSMkkgVf3RVa6U8M66Pv41DsSPvy6Q3eO2o4TiJU21SqQINYyP+tqs6EQUstgISbytDAKN+ANQjP17/jC8R0aUTvlz9aWaNfP1uUwOJtxpTMW7YqOP3XRL66phd+OBEeKonqBG9oDF0gjPh3gF7q01hwsxOmF2kZ6EYSenYHi8IDb+A2qkURafIbXTkAX2XJboZCBjyV8IVYw9zBUwMZTwaS27+Wl+6iI/IurQptoK5txmwnONV5U46ZPPkZ/ctfHklnx+2Wx6udqnBEs8MrkeXNvXbDkcVnQpztWCOGB7okpqLMwB0VeH4Gw7OvdEWUEFOJ8iqiqCmqrTHTDGLAM2tjfdWXlR61jdnMx6VduKqQxgY3MlLhm0aXQJr0NwrZWNcO0tp/y3876JHJgGajOKxbifoxdZ5ppAElKWI6yu7/mJ6ExHMOx0JUkuGEQPrt2mhZxub+BSfKhiRk6wPj0LBUPM9crAbv+c5owYeBaY/NM7/ieZBNQXOsHxmve5H0ZqzQs3dq3iEc2ZGOazsB2q4ZRPzGE4jmGGeV6vur6nK1LhmFjQRfIkkk4AueQzxypveOrJdMoMj2P8htju2Kl4lZzy2sHBac44+eLaSoLF0TAM4MNVnQA1ZWX0SW/t6JJqDcK89wvmBvmdLCsDYMbDrVae+nX0IQlIkWHnCtHhDEVmGhH+/iaz+PAH/frRY0ym X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 065ecd09-0f2e-4ecb-d8c3-08d9409e88b6 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2021 16:53:09.3979 (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: QRHFAURRg4nYt2NlzrSajrM0quQK/VxC4hlHfIgqp334Ld1/Em1j47kSXvHu/grQzEZ97/QceHSXADsgqgfglrD6S3ohC+49HujKVwc0/2Y= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2805 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-2107060079 X-Proofpoint-GUID: 3iLyNYLZUvZzqLB22ep3JQJS6WSpLaK0 X-Proofpoint-ORIG-GUID: 3iLyNYLZUvZzqLB22ep3JQJS6WSpLaK0 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 Acked-by: Michael S. Tsirkin --- 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 e2163a0..8c0c9c3 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -1820,6 +1820,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 4a8bc75..71704d4 100644 --- a/include/hw/virtio/vhost.h +++ b/include/hw/virtio/vhost.h @@ -106,6 +106,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 Tue Jul 6 16:45:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12360955 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FB4DC07E96 for ; Tue, 6 Jul 2021 17:09:29 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1A8B661C4C for ; Tue, 6 Jul 2021 17:09:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1A8B661C4C 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]:54272 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0oZc-0002Nk-4u for qemu-devel@archiver.kernel.org; Tue, 06 Jul 2021 13:09:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59632) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oK0-0001du-Bs for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:53:20 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:31536) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oJx-00085n-Fm for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:53:20 -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 166GpqgK030618; Tue, 6 Jul 2021 16:53: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=c0E/zcDJGjSGN7JHoqA7EjNGE+X5H2Tp4mcfHSW8Qr4=; b=hTlwyGWI3w0GvuGgIp/eAxqVCqzs0WJnrDKT7XWeKHjOjblr583s9w2DOlFqFxFvvKmA R2Tn9FWMF7xWPKM01jMFZSPtUnCGImUShcq5Q2x7ZLZmc7u7/9eJk03FDr5JRh3TMTSC OLCtmAvIm7/OGgUGeBEauX0lOdTfMYVJnyFeVzexVf8I1HOLPL/1GKfIJVmNAKhRTTj8 TafMDL1zCdoOnI7m8zUdJQo04B7R18xStpgM4exxTPexPtLgqKWWYPODXGW/4MzA2N1Z AQSwUNTpLg8HojYBMmyqgstGpWXko7XBTzmNqyC23G9MY38/+7EfzqWSuRsXyAtJrkyz bw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 39m2smjabt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:53:15 +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 166GoUJG084680; Tue, 6 Jul 2021 16:53:14 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2171.outbound.protection.outlook.com [104.47.57.171]) by userp3020.oracle.com with ESMTP id 39k1nvcqh5-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:53:13 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dmzDzUjQOEpZhuLwcxt+rwbKlvAXG/kCIzRJu2FfXFE9xJypBx2m2MjpZRK11IbeaCmWvve5c0ifbrFaMjfvWpSGln4Nkx8kdYZg2SUToekvvjR5K+i7N1PoTfrWX7uPOa+cvpVxNQEgAsa9c5l64vu7C0IcNwC2Pa0DPHJkcvIYosRLFcU1fKuCR58Zi/VfJy6jCR2q8sDkMlw0fqkySvVNb99GWyRnPQ38JgTXO8tXVxgaKLx5K9Gff9Imo6rshqLdkJetswK+yAAJlAZzsLD6fkjHj9Ff4H+pon2wMDLcmFT0LzpF5erD10Fk6YvSfn+LfskBOSnEOKZjYPrcsg== 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=c0E/zcDJGjSGN7JHoqA7EjNGE+X5H2Tp4mcfHSW8Qr4=; b=Pg9ctZajk3H2sS81xKQSKsdHipldarIMXVERkr5jVMe0FkCDCO5ChFYYuHoUpNkFnaFNZCrpPRfP9ZRtNWGKFIiolo+0+BjE0HIr+kU5zhv4PAOjGVTy8qeXw1kY6uGFdugq4ToFrfHh3sep3bhHrxkssFt09ZoWLw2x0HCjTjIl1anmE2ke7wIiJ6hn31vw1IBzwEc8B1NRKHh+0I6dhyizDnhxX2WQKbwSqxIszR33XAALQ/ijDIYWubtrMS3r1OdUHRTIGsT6uthPJHnxl+VTpl5LzTJ3nesR0YydY3Xa0pJhS9f6QYjZraC0BKMBcn0NvUqeLersWqPnoYQLrA== 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=c0E/zcDJGjSGN7JHoqA7EjNGE+X5H2Tp4mcfHSW8Qr4=; b=A6HF23XF7IllNSk3Itlx/RCrOPDoaHRdHaUA87HwTjCm6N4a9BAJk4/4CyCIxB0R31ysI60p2anZPc2Ji/lS987xFjiRbwKgqO5HhcoK8TMMnlhM8M9VxOIOtcXZYQQOtUeUffPWKwSX7x6b+x3QWd4nfq7kvAyyKq35egiY4qc= 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 BYAPR10MB2805.namprd10.prod.outlook.com (2603:10b6:a03:8b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.20; Tue, 6 Jul 2021 16:53: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; Tue, 6 Jul 2021 16:53:11 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V4 19/25] hostmem-memfd: cpr support Date: Tue, 6 Jul 2021 09:45:50 -0700 Message-Id: <1625589956-81651-20-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> References: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) 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.4) by SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Tue, 6 Jul 2021 16:53:09 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: db5c3cef-25ac-4993-fe17-08d9409e89ce X-MS-TrafficTypeDiagnostic: BYAPR10MB2805: 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: 49XgACuDOXtljfcngFUO7WKhuI+SrHYoFMPuABqJvFnXS+h5Z2EsgtP61en5mWhKHmX47ePZd2VSHC5857IwOzboNY4rlvYNTDv7HAyeD1WZzWZm87X94ukKOgrJ40SiAhAGJIKAztzvuaMX57tdoHQQl+osvCyOQY6Om/M7jS83Ev7kKX+sNF2tAr2odek78l0z/+gKJwamMW2XtXshZRabY/inKsmfEbyt+jgOwXZ+kRKbT5tABysjPndM2MvGyBxXVo0QYDvC2Q2oZmXwv0VM4Z9n+Fllh2TatpvC5dY/k82drlqwJCCn4+8+MHgSTHnGK0MYquoksJfp5E9gAlaBqF1n2+/HPYxjuD+jU+aljoiYrmi9fpAqAG0cNyzKITt2rQPwuQk2jrhQLPs+aXosIe0kdiFRLs37rDj9aBudFaVspZKqLvjHR9La1otAX1mLYmumnoTAotpHqoYZvJ0S2K2pxuMkjnCFvR1ot6FqjZE/i4t4uv2Ku5oy3MCyiK9XSerYrGufR5zdu6ocyBPNoD89PUjL7ZIzEaOPOo2j2S6J3Ul+BTvIEADqF6HvOO2byDQzZK47c1oIzmmn6EquR5UgBbRLYSIrORAahcs+8hR5ZOnfKWWR9M3JhIPDbRQRp5vuOzlhbuVkCi2vQQhCQlFf3UiBGaG+AYVn9jLXjj8MMYKJeS1C6D9OrznV X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(39860400002)(376002)(346002)(396003)(366004)(4326008)(2616005)(54906003)(26005)(107886003)(5660300002)(83380400001)(6486002)(7696005)(186003)(66946007)(66476007)(66556008)(52116002)(956004)(86362001)(6916009)(7416002)(36756003)(316002)(38100700002)(6666004)(38350700002)(2906002)(8676002)(478600001)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IyH3t1eCVZXuM4ObhNR1hPMlrvlBNYWzntoTvNpGxV42nBoCOO46BnhiQUn+6O9bYazAtJOPRUv6d6IEiKS4tssNvMB0KG3OohXG5Mi+LqqD5RiqVwsAhowlCpKzUY4XenZYsCT9XCIQYJYfWE6U/MTVux4wbeHBw9qUdJwsqR7kaZVp6qjd7JS53bYa5LKp0RCewPrZp0PMubRe35zqSVbriMMZAd2D3opqdJ1vqBK7lOIFMy1LpySrQt9ENFGL8Ig8VJynvtclYnxE2SDKNRBb8vYAnyE1cOm35fkq5KbJ+FrDKqLibLICsqApae+D8yDRF2dpqTVi9tYcRJ5qAI9OqQJvgOJDg89rWU/HNBqgQ/DhdJqy/zyaQ0IUVml39h3NfesTogVugtdapWKt59PUVeruwDM5Zjn0ncJJ3i8O3eZ+bMmMAVA7AtcFHrfJEmEQrvrzp+7z/V6VWG6G4oluv81LY9krO5i4t7O5yeCgZOYikXdIP2i92a3Zr2JFmHpdiwM45v7J9BqcLHRtVvSXogX483YZ/z3Xcl0J6kaKwMN4otObLvPAnyI2bOPTNWkv7hqh8D+vqQ5rqOByQe4Q84M8qPYnKcXzNrs0Bfu9QauqoVYndt4lvdrCOtvuI9d21ZJlIhmPky//me4AtIYblKVSQ3T+mmafl/yG+i04p7Fzh0mlo+lOjW4aGMtwDa/GAvIDaobKDqhU/TlOATtyAJlLA0ziCUKwHHAmf6ve2oqGgf+LhgPZUmB8TzNqGYijVmCUJw/Fp0inCtiiNL9+6YsY/pUiJOLtAOKRXqrwNuSgLQjh97T0LYL2ppYUtvMMXTWF2Ppy1iVhoUVyafwAW/RkZZstg1yq661WETZr04/Lg7RJPZUOKL3PtJlxWA0nl9k45qvTWYT1Of/PeEpUrST9Aio9upST59SUUj65vMwo/VyYM86pAr36oFUd8LAUNnyGNwBvveJYWzUJyr1YVKaEyf+mcCEkuevqd7j4KBvIxj5hUsVRLNYnEpPBV+cf2dnsJ5/SfAj9UKgiH0ptMajee8XMml9jNvZSHsvCcjcZBBsYZBNK3dI+DV+9WjinLlkR37psQSw/e01q+S4Gqyd9Mk/WtScCZrikkIgcmFHTbPiuWQAUSAPZo1bRdiJUDrUavH+heQeR3kSjuc0u99mtBaTmMurXayBctIPWe72pTnjgKAZQD047VVGeNwR1F3UGIjXlS8PiFbRtbyosKH8Zoenp/27sc+lzn0h6TEOMkvGKVwhog/P9NqvIbBKqmlDXEyQrMd+Fu8s4bLeYz1M9KXnA1jYN/ctu07U1e9BYUpWHdtP2foChHLRH X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: db5c3cef-25ac-4993-fe17-08d9409e89ce X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2021 16:53:11.1979 (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: KGoiSsKP6WLcsXh4XNqBk7mEbHeofqa48DMFwUNikPggUecTnNCIGRo22m/vbX2DKb09YSZQGMTDJJLUaTjr/R1RRTr3vWXs/a7mNpDI5jo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2805 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-2107060079 X-Proofpoint-GUID: s5Sn8OvICFPuL9GjzEm6ral_65bsekMP X-Proofpoint-ORIG-GUID: s5Sn8OvICFPuL9GjzEm6ral_65bsekMP 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 69b0ae3..3503c89 100644 --- a/backends/hostmem-memfd.c +++ b/backends/hostmem-memfd.c @@ -15,6 +15,7 @@ #include "sysemu/sysemu.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 @@ static void memfd_backend_memory_alloc(HostMemoryBackend *backend, Error **errp) { HostMemoryBackendMemfd *m = MEMORY_BACKEND_MEMFD(backend); - 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); memory_region_init_ram_from_fd(&backend->mr, OBJECT(backend), name, backend->size, backend->share, fd, 0, errp); From patchwork Tue Jul 6 16:45:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12360933 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B16BC07E96 for ; Tue, 6 Jul 2021 17:00:26 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 617F161C4C for ; Tue, 6 Jul 2021 17:00:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 617F161C4C 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]:55424 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0oQq-000190-E4 for qemu-devel@archiver.kernel.org; Tue, 06 Jul 2021 13:00:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59660) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oK2-0001kK-2n for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:53:22 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:45016) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oJz-000862-5R for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:53:21 -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 166GqGfq003973; Tue, 6 Jul 2021 16:53: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=K4qwdXCNInXYoSj/bD5RpaC6pHzae8FVRosgaClWmfQ=; b=eQ/gkt9/76ykiT4nqr9z/4YsJ2FOdNUpkoO0Or+OAsfudWsFM7FTDmTbkdbI1ytM16SQ V6r6Os+y0Trzf4jVlVOJHI7vt3pfwEj5+AcashcqWxraIMcemWNgHPvRirnb3WhGaUoF p4NyoJF1M1PlBwwjeRRMiItMfFxtzMtrxHnHeQx0WGAcg2RF7qAKoeZLZkZ67dVsU6jy ZE6JGg0dZ5fklO73NVhVuo6ZaNiH47XJFPDtMxqENEiyL6ZlbuCrHyjYrgLTMU3cv0+u S9vlZsd5srKV/6Y4nY+k6ckhK0YIafnTsJo+9SJ0DZ8C7nVFK2Fx3LmKoPeCpriB9M6k Nw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 39m27hac6f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:53:16 +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 166GoUJH084680; Tue, 6 Jul 2021 16:53:14 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2171.outbound.protection.outlook.com [104.47.57.171]) by userp3020.oracle.com with ESMTP id 39k1nvcqh5-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:53:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TFBD7XZw5WBZVvvjsxf2wFzh6uyhqP+vtaniIiCUMn5HR39No9Np0cPub8FlMDCWsOG+rbUQDaKT6IBwt4fPOWUUP5qBw/OJeHoKGNiT7FdXCmJ4E5Ip44TrWOrtynExtOsTZpygbi7SY7A6Xaab3o3A12XEaG45+18PSRyp+AkcyCQOD4wAunNXkNrOjAH/f0suW7SdTkIQiC/WB6JrWxnPjVPkN0sQWCuJnEdXZRosF2Q03+Az3OhP/qWqNiOqCMSLFdxT1Z166XwTKChU1i3ndPSRYI4PFwwwUb4UGOI53xJoRyjMgdnDO51SStAwq/02MX5hSPlOQ02cA+xCyA== 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=K4qwdXCNInXYoSj/bD5RpaC6pHzae8FVRosgaClWmfQ=; b=HHONSElXqY6fdde/UE3g6/unXwvHd/rtW4GU+Mpfj83iwZJE54EcZm61COiaLfOIQTXvTL6QNuoiI9zB98KgbzE3hhg6m7mCw6oRkCXUXRzWwStNhaoVtVIbVWB59neFB3htRdX/6unoiI/aE9G4AZnS6vETL9MA4N3MuYBEY0yNZn0X3kMxbcSaSr4iBFDLvSRWwT19bqt0uEWFz4qNM9pBulENJwWt+2AIF8XMm4Q1w20QtfIwkXyVqcI1VzOtjxFU/OzwTBnSLzmi7TQJU/1LmC1tzysI6YP6nWv4GyVaHy29wUEehMWx1kuM791O94Ou8qKR1cmHGBi7GzFxbw== 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=K4qwdXCNInXYoSj/bD5RpaC6pHzae8FVRosgaClWmfQ=; b=SZZfiJSDMhVM8cbePilCv50MdwWqITRPupkVXu9BlVnRA6Il3tAW9AOQQzT/sYc6EyhuClSnQJWu2QZas7QpXql8LTMkJO/oFfjFuElUVb0RXycBFi6wr/E1PpXas5tA9n76VmfCnN1WPQRA1jbGw5pF4pqJcG73XYVelXBc4JQ= 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 BYAPR10MB2805.namprd10.prod.outlook.com (2603:10b6:a03:8b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.20; Tue, 6 Jul 2021 16:53: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; Tue, 6 Jul 2021 16:53:13 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V4 20/25] chardev: cpr framework Date: Tue, 6 Jul 2021 09:45:51 -0700 Message-Id: <1625589956-81651-21-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> References: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) 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.4) by SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Tue, 6 Jul 2021 16:53:11 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bbec6932-e13a-404c-0042-08d9409e8aee X-MS-TrafficTypeDiagnostic: BYAPR10MB2805: 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: zpTVyG33izUTstwkuQn5bXOHp8e4KMnPFEuJiQoQwTslYviPgwTnBsymLpBaICIDYAVrL66eUM68NpJ28m8bzC1yp9mnlYZFMkiKOJ47zsscuxOBYHeRvDW5C+s9xfZJY6Og0iDfdWZdNpr1Pkyh55B0psfDVyK1OIHdgPZXh0KlMZukkVlrJ9jpM0d5/RqW1WIAQCIbdUjJiF4zRVhm0WZekm92eN2YaWUBrRc+VbpbOsAjPysFp8lcUfutmxevUJ1mrs1A19dKfBhwq3+JorYLiRRz6p5gR8QgZdETCJq3C1IkO8yq/gRg4o24udtAneyZsV5zPWxfYRnFw30FRYZ51kc0lBm2qYZHYyDP4R8ldagmYe+KBCM5F9ONV8n/gC1NMIbPc2RwZ+pC+7V3tX+rAVWy3fcUuetKf9R00ZdXKRsOky9QZONdryzCL+y0Q0OoKvORXXwqeZ5GN0rhM8KukvrEWQPLrfNaH+W72d6c51rxBAAvpaHHLusfK5LrEsBM6JeyCvLTFe/Ub52tjVh6bpjRUNYZWch64qiD9qd+oTAYkQ1QS/qzqwOEisqEuHzWWikdMgwlm6R3340WZAH3cJ/RtMNzWLH1672EsQ1316wtgkRBi9hzOImM4PQbmBBkTGatBh2WTwx0D6g0EmjNATfhYsecyWeQzrYHqGM/XjhqV3V4f6hRB3Mcpq+3VrnQGF+JpwXtcRJemwvolA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(39860400002)(376002)(346002)(396003)(366004)(4326008)(2616005)(54906003)(26005)(107886003)(5660300002)(83380400001)(6486002)(7696005)(186003)(66946007)(66476007)(66556008)(52116002)(956004)(86362001)(6916009)(7416002)(36756003)(316002)(38100700002)(6666004)(38350700002)(2906002)(8676002)(478600001)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VsY2Vvxln9wj1DXUC22wZs9PXOATewtlnxvsCG069sVArCs7TRPVVipZ6l21ALvurwhEIRMluRG0EXzTH7Kp4q+GL6zZ7nUVP1UfpL9xCSK4rUIW+Y8NDSZicNggY8RnZgppWhOp46wiFMwQwfabnRlbFeQlWt4vMIqTMTzb96RkRuS3mGvpntEoFXih/5//zJIqh6Dv3Vp6TQHS8XFK1BtHk3ZEqQNtTcSmxMNlR2tezc/vnbYWKctvdJi3dg4xFAzvpuUboxQLjNszw+3hI/tcPYlDJJOTj0Qz8WCIzzidmJ89YtAV0XFNug8eU3L2VjscChwpv7BZjr2My08wC+mtc5BPjqofyIqw6qMoUILt6+EWOC0kSspEoLXN6MLTOZanXASMn9lDnnj2RrCaGd3mKJ1ktbhn3rPcf4+ptCiDSezsN7qORlvlRH8arWZz/xRLyHpajwNR3jgnKrUAvNsHGKZQYzqFhHlfshcO1vZ5zQ5eFzqkYJl5gYyEfIBUc5LBaUdjJcNCuHriX/C4YFq1byV7iqe8ew1my1rK7BtBESR4OqJsNYW7CkzYyzKIQXo56SSRRegAeVybUyzHTd5R1L5cA/s7OlU1T2RjofRgGU/6Y+QBHJvJGIE4alBcgMhu+zLg+vW7pZ0AamNUnUW9nV0GzNScwnRq/L0je0AO3veE+dkxnJ/7gIncETNwP1pegfeaDV52VOOyHfcNCY5nG1Kb7EUFKb7BIiZ+lN4rsLeF+4gab9rlzsGBDb6Gw7bd1DhbPYHbnK9sFFpEPKHK0fF248fJgSSbffhHtLiiqypQVXOf3K+NThZ14Dw1BAXnCZmu+LSYKmiw2RNfp5zO2JYneuezSmd+TslQDQe9SzuZ6uQ4X8RF8vWGQ0r0EWzmJGFjZH3zVuEtSAq4T13ZUM2Q7WAItK+QSgCm0JAYBSKnz9snCIRx5XLNqjpQceWSKIZsn/+KbP26vAxRTO0Bh+tZ4ahsty7fcZn1875nCQAChPXGm3HDmQM3TmKHJa7ziyDhkK99terWAN0jYdYcaWw7mSeWbjAgP04zm510Qmr/6ps4Gnftg2odUHnnyxsmPbBRnoI29XVT0KqYiZMbhXoVxD3TkwPB1jTbzuA8HbA9YSLWounP7Owe4a5gnMZI38OmUp8JGHn55fJ0AXA19CP7lNEK6ftj5tDvbE4uNc9vKSIs2aiCtS/i6y1MQwu8nbhmhDFTCcasK54dP948yx5w6n9EkujqBUVnO4BTh/JDBr7LhCMl2MjnzapcdLmraKZRQBb0ypjAYld3DajxsLYjiokJnkiZ+DvvTT8tpvvJHdOUR7fTlvLKDF7f X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: bbec6932-e13a-404c-0042-08d9409e8aee X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2021 16:53:13.0569 (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: TgeZPLPip6bFAqcpKCLdYQwZxq550X6ZMnzijXgHHl6b/Wa2FPHCkviVRcIBlxqZiI9qdfw23MSPEI750w2wSHzKVm6EYCXR9yAgM9OnBU4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2805 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-2107060079 X-Proofpoint-ORIG-GUID: gGvZAIGCHbRaPRfUENQJYyMplWmLa7nG X-Proofpoint-GUID: gGvZAIGCHbRaPRfUENQJYyMplWmLa7nG 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 398f09d..596d4f9 100644 --- a/chardev/char.c +++ b/chardev/char.c @@ -37,6 +37,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" @@ -240,6 +241,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; @@ -249,7 +253,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", @@ -301,11 +312,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); } @@ -505,6 +517,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) @@ -940,6 +954,9 @@ QemuOptsList qemu_chardev_opts = { },{ .name = "abstract", .type = QEMU_OPT_BOOL, + },{ + .name = "close-on-cpr", + .type = QEMU_OPT_BOOL, #endif }, { /* end of list */ } @@ -1207,6 +1224,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 6413970..194d88c 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 3392ac0..ef2d24a 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -3071,43 +3071,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 ) @@ -3182,6 +3196,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 Tue Jul 6 16:45:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12360953 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A8C7C07E96 for ; Tue, 6 Jul 2021 17:09:25 +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 8A66061369 for ; Tue, 6 Jul 2021 17:09:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8A66061369 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]:54000 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0oZX-0002D6-G9 for qemu-devel@archiver.kernel.org; Tue, 06 Jul 2021 13:09:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59674) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oK3-0001oA-3z for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:53:23 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:47944) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oK1-00086X-3g for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:53:22 -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 166GqBfg003755; Tue, 6 Jul 2021 16:53: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=Z8PilpzSahsOQ/gZZWaLba9OJaFpBqu4rQF5mNFBzp8=; b=HQL1TK9xd1scogznNKC0q9QXhpLJHOwRsA/bdKrmLdBZAPpGEs6rMA+AAwC/Ow9iq72t P0RKxHLMT18+PSC8VpOH43XqDsU9O/fM2aeTPuSUUzC46XA3b9WkIihw2rjx3eVxWHRL ez+lGk6luTLKqklDBpBogOL4//Z95NbDSx/dA+uiYmWJz+NlnA8CUooI+r9jf9NIL6jL hS02kvBmIWoTWNbEEWumqf+wZlM5I2F2fuXdqgeYg74ft5XtlituLxQtHyG0VtqR3WtZ IfHZP2NRizZ1phvBm+vstPakgJPLjsHYHRe5QdB0mEO2ikrYULRQSTmVhcuKr69/uZ3g Yg== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by mx0b-00069f02.pphosted.com with ESMTP id 39m27hac6h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:53: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 166Go5SL159199; Tue, 6 Jul 2021 16:53:17 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by userp3030.oracle.com with ESMTP id 39jd11ngtd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:53:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b3diY+POdiPouv+MVJJy+9bftSRS7+ggYwXl68Z6AbEqVF4lGCzOz2cussrd/UYMU4sTowSfkR2F7DXbue5ANnVBA0tgwV3Ab/LT2UFKMVPBVBK9Yv37JcR1mEv96IiDxy9eiIrwo3Slq4BwQW43pjLZgqRQGPWZ+MP0K296gfMQFrMsaZ4Gv75c8wUIHCsrZWiXg2ZkXgaV3R/yeIVW3UoMlCeWaXtu9EO/IqBqVkWuoiqKhqhWHodpFv4IUyrru9G2/nEzz5hRoNGhzJGV2nRI/KOG9EElb7PC90rwxBoXGxXBhezMJyuoy9ElA31xkS3lelq9Tu9FZtfP7CXCsg== 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=Z8PilpzSahsOQ/gZZWaLba9OJaFpBqu4rQF5mNFBzp8=; b=AEpzZSt8hXzb0oS24Y9vZXKyeTLiED5thiL8cr2ZTxfBaOzMpaxz5d/VmFP7+SIYXuCJToe+PVo6bjUho5mnwgMCi0dQWcjA9ENnUvPT2wdSLEk5PhnphS59M4j1mgf5S+Ix1zY6JeJEhaMdGVgVJYyVW8EMg/yXheM1fC6pb+V7NQTWJZfQRrqiGZXr0AONjVY0vS7A6S4rm2sSVBhS6W9CBR2KWmCmCyZoorAAT/fCe9Yc0XAauC29TxwllXM9lcaYjidB8qXGBvw+jsYc65plv6XVYn+5ofE+1NA0dtlE8UhBYhLP699E7LxkyQfTKDa2SLU9yGXv8JsUEzigrQ== 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=Z8PilpzSahsOQ/gZZWaLba9OJaFpBqu4rQF5mNFBzp8=; b=Q7p1Oqp3L899A1UphT4xHBkw+jTYThl634ogwF/ENAEM4SIIZ/yEkbq16wfH/6QH8fyOPfkhOsi66MB9F9TzmiD0c6E9KfGYaxR/mgOu3RbHJfYEdl5FDHPE7HZ7QSgglCPyUkk140C2EAiRiKV4AwPhtontGih/yGLuDFfvcxM= 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 BYAPR10MB2805.namprd10.prod.outlook.com (2603:10b6:a03:8b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.20; Tue, 6 Jul 2021 16:53: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; Tue, 6 Jul 2021 16:53:14 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V4 21/25] chardev: cpr for simple devices Date: Tue, 6 Jul 2021 09:45:52 -0700 Message-Id: <1625589956-81651-22-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> References: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) 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.4) by SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Tue, 6 Jul 2021 16:53:13 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1854a33f-3bc6-4314-96d5-08d9409e8bff X-MS-TrafficTypeDiagnostic: BYAPR10MB2805: 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: qMGDrwOicjuCixshX4g7d3QEPsdbWWRIEJbrfNpsByeXniQz0xlOKrA1XGKMxCKVi/8Gwl3rFQlzy4lI3AZzydBQ7fOuafkFu/SR2ph6xwXVq0V1gxDyV1wPvt7L/XU1L4aOj4YRPB1k4jdnpnS+9KUCMZplc8P/no5azk9THbREAdLoeGBgFZYNkTMjMw49L066SgrquI3bbRsn3L5KCkMLgHoHZxd6GoYF0oEXeYdiGFe0D5+5pj1tRKFGa4OsjPxIXKRwzHLoSXyPJbJTTWOC9nF0FIUPA7Glnj7BwzJ0W+kGG7DPARrCZ4wrfvU82lG3kvTdn+6zS00WTnhAnPJEYT2i5IoiEPueYfXyJYxj0HSrR2iyYP8Fy5DQbdk5ni7bYB1o4RZbdOT3FHyfl/y5hsUpPomU3YbKmtnx74IrIrNDh4ahUKBBA2RwTuBORvDhJpdlgCALI3HsHGlq2gPtM6c7MtiGgZlvIrMHfaAUYaEd9bYBuCnAvn8cwX98PRJCVWavfvdwLHOc9+NnsNokGFq5e5LvidcQUebkKKVeqma2XH3Z+eh4y1bgq+HWVNFsItzI88LZ40NefK0dlQYQ+ytSA3HtCyVjGFOtUO0h0rFqVL7hJVg6J3f0PzIhXPijUufW2qp7R77QCbFCcf1hVs/b5uYM1stxWBErwmrhAZfxm+/pyhw/dOB+Saeg37CnLNY/E2A/MfAGSv4B7g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(136003)(39860400002)(376002)(346002)(396003)(366004)(4326008)(2616005)(54906003)(26005)(107886003)(5660300002)(83380400001)(6486002)(7696005)(186003)(66946007)(66476007)(66556008)(52116002)(956004)(86362001)(6916009)(7416002)(36756003)(316002)(38100700002)(6666004)(38350700002)(2906002)(8676002)(478600001)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: x+9EGPTeVsHD7m/D8aar5bN9sfpCrl/2U/rkLvxZ1YrYnaAdkwpuMuNlUcGLiEQU+lCLGVp5FCOftWj33j4763SEyiO1Sn6NpIXyxVbr8lAmt5GpUEXCIP3Dg2p0/Sernyq4tR7ePUbpLUjEr+3CB9+WcrQL32Z6FXHcWNGxevGe0up9GewCqFIY9n5L6c370QT4MtzeK1cnKp/yat9J5L2I6GZJPrEo1NVoRajCU2gih8yibjwUyQXjrcaH9Da+9t7I9lRa7mr9MpxgMWd95+H4BuLthHhrp84pO9HNt3WpcddRWXJwiysz8sO5pVztgmaP2APXury1LfIpcCCJMOlEO9dqU+NaxJnZ2wVqwl92VKXlZrq8DgkOA32VuOWCQDsxEuaIKLeNG6Z0vmx8wSEjw0ncz//5C4ndawnEC+rxT5AeYnVmeI2gjbEu7uKEqo2bLBZLHRQS0NDHUiHhbOoGX53l6OUJaH/N9t+K9Z2VGYrcYmgoCH3PmvJbgWMo7dju0VBOSMYf3leojTSrsPJhdsoKB1xUCsYL8Sulg+LDMnsPYq+Wu7BQn6ndZL2J6AHwps5Ru59sXwbaHA+SvoGNtIa91r8kufyarQNDEWDIgK6r1U0HAs7E0GGKAuZnpTWqqUuCDJ9vNIrU0x8hGmxv6WQ9rGAFuIdquBW2d3INjz3Iab1jjguvMOw7Ys2O0e7FZAZERAphe6m67JOOxsuZjGV+Q9P8qC4zlWBtl4gkJoRcNoZzd2IFF5eBmrBIohnZlX3AzvNWVnenNY6+wiND9BtUrBEyt5hSzdDKT8WxQOR/J0U0DwR1PR0sQND/gPsKspEfk7rWjAI1ZrxAEs5DCFjwVs2i9oBc5BGYYBCf6SnOJIaSFKmBz0c6DXSuAxs7H04vlu2BGGK8tbIoui893g2Fv3a6Pvi6fpgW36324XTfuAAk/rY2tRo+EFYHB5bbHpeAZrBGu2UsIzf3AO9J3i7mPlw7as5/5y7ebbYoIcRD0yRrtve+IhVaShI6C0TgxGN66vEi3u9dnIKZTW+ACkTPsmSIcfeWxV9Xkcsd5dAtv4gsZhcCNEEArgnWOYo0j2fADIAH5stxqd9TejQ2JQPWOpS9HGVJJz8Jv4AAXh0xnJWahU8Sr8m1AuVEFoAm2ZB7/LY/xiQlB+1EOaBgrstOQyK7K4Cmc4ukDWFnIVutqXIniM3AhQm4je1Qf8azWM7ZjhIg49DplGmNdinJP+GvHFgRfKP9SKIWqGkigEm8uEASM1iCcOn6dKdQ4B3KGPT+pk8HxP8BCAUlvwqAUPXHXdkqtdPgNyWO+S/+vDrCqr/xtGpb1+TQIWZG X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1854a33f-3bc6-4314-96d5-08d9409e8bff X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2021 16:53:14.8748 (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: pzgAmnICFFmNrKAUCTuEKC2mlmuf7m33R54BP+XKkBB9WiBaW86I92A65bINLrX+JTLPpuIKBi6K5m41Sn8OBQixJaqiZIDSmSM8ovpdVlc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR10MB2805 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-2107060079 X-Proofpoint-ORIG-GUID: sMMDmfhsGN9PrL4ZqwVRfZ1g2FVJLqKz X-Proofpoint-GUID: sMMDmfhsGN9PrL4ZqwVRfZ1g2FVJLqKz 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 72beef2..af74eaf 100644 --- a/chardev/char-mux.c +++ b/chardev/char-mux.c @@ -337,6 +337,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 054665e..fdbf531 100644 --- a/gdbstub.c +++ b/gdbstub.c @@ -3540,6 +3540,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 Tue Jul 6 16:45:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12360959 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C33BC07E9B for ; Tue, 6 Jul 2021 17:11: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 E6D8961C54 for ; Tue, 6 Jul 2021 17:11:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E6D8961C54 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]:58604 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0obc-0005IB-Tu for qemu-devel@archiver.kernel.org; Tue, 06 Jul 2021 13:11:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59702) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oK4-0001vp-SP for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:53:24 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:50990) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oK3-000876-0m for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:53:24 -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 166GqBZE003703; Tue, 6 Jul 2021 16:53: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=2hHfE6MEGogQzthqOH4vqs5xuVFIGzYUunqFpRHnOoY=; b=cTSIcpSS1HI5QgeJdiQFUErtLrLAcFr3drmN50t2Pe18GhQE5D2wNkAly6PVCzru9ALL oPA6mDvxEhvb4bE1Olr5z/vwZlgRlK0xfMg29n1+N0uPyGgsiyRJtDFPWSNCWPAxn704 fueuLzmIl+AbxOp8rjPjoher+js3ELzI+d9eKWu3pr6BGFLhgXs26raVHyfXtL8Wi/FF dt8EUh1bEwDeCmd+URStdQ+tVNpoJ7Rtun92Hujt2b2bnoClLWx49D5Wpi5mRHj/s562 i/ROXVSBD7aa2+U81SXt9DSU4/QjDWSA7SoE8RZYSSEgjIXXOJM961U2jTkqApUfR10i Dg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 39m27hac6m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:53:20 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 166GoIJc012592; Tue, 6 Jul 2021 16:53:18 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2106.outbound.protection.outlook.com [104.47.58.106]) by aserp3020.oracle.com with ESMTP id 39jfq8vjsu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:53:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=E15qcLGUps2p7Rj7qgLoEB4Y2sIF4FpMmfqrPJH54XhND9wmjpBvZbVQwPyxFLxEzbbgsrkfOUIKJ+X4zy2Rmvv9qf17sT9X3cp/P+FeQrxgPRuYXcdUx2QbX3YDFrh3/R9+RIBpMhqj/k05oqb7PaQy2DFYcJPqZr2so/46pa1JFYFyG8EHAoNoMvNRKy1f6bHFUxKmpoxetnawaCpyvF+oisd5wldoO5B9/HqGrK4oWpqG+M7dfh9tdDekhVdOKXLi1wTTK1ck/8lkAo9mHWCp6XquwjlM567Xm0a81FjzOy0SVuHY6RfA8PX/1te+atROZmilD8IVkK1H7eOL8Q== 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=Z3hyujudAIk84Ab3we3kEslHip2kMt4nSlpx4BmLAUGxzfUMK/VQoJalfv3UyH7C/btRNIvijbaF1p8MJm9Tue1Kk1bafAnX6Zqfo7JryRpyt7+Zgu9/UpoPsOYNHmX6eSv4sTP5+vomVC/CoudarQILuL8dTvj64VsgLMaisFBjJXRSJCGCbSX+OrOZAch57OeG1vOUgqxprLKo+dIMEsUmhcRTUVDXUUQEXST7yqHMr90ky0Nmxi8MsFghStxPyRMvadwJCB73SMG2QlzN1TwDV4J2/KNbEXR0kb7xsQ8o/fkSWQrmEx2cwtEHMERzFsbBpZnqyipZ/ssd4QBI+w== 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=zeZn+Czz4hmk04VOrmksz7Gh1g1F3GhPluFd6vnN7mjoY3EE+/8VcqYDKXUStz2AX7J0t0wwFMlOlIIWsufsjnXFYt52iR7f4Sz9Y9Tt3dm6PxfWxAfZ5N6uR4cctyRWhQH8lp5xhTHjxJi0b80VQ8jmYGBk2AQ/X+b9PLqanFs= 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 BY5PR10MB3841.namprd10.prod.outlook.com (2603:10b6:a03:1f8::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.23; Tue, 6 Jul 2021 16:53: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; Tue, 6 Jul 2021 16:53:16 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V4 22/25] chardev: cpr for pty Date: Tue, 6 Jul 2021 09:45:53 -0700 Message-Id: <1625589956-81651-23-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> References: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) 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.4) by SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Tue, 6 Jul 2021 16:53:15 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4625c0e4-ad78-4237-3ebb-08d9409e8d12 X-MS-TrafficTypeDiagnostic: BY5PR10MB3841: 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: Bg0LHX0gUUOSLkWVGVfrkbsDQ7y0JegK0zdu9gYcFgbGivvrUfjWTII6IFZx+ln+qgYZX4LATRumaD4ZKkCHiZoIoXK1EkphEyP9DZMqR7ER2x0664qY1Hyl198Go42R57u9nGSWhjEWMKbXULT54BkUL6tSqn3TsiXD5kAB8/MeVxGuF9Z6EFA+EdEgu8BjKz6FxfobxW5eqiDIresfPWJYqI8Z9OkNJZ/U+21uBIpi9Wbb1FY/cUCFFwG25fw2fN2NgjdGElrp1tNmvQWG+okteLdG7lzYqnlEwr6PcdhAUudrCwoTrcmWMnbdeirEv3Ldb+zdzVjLQjQJdLbMw8PfAy/o0ecdnfZ+MectCYLAT7o1ec8M+6HlWbVA0Y468l7aAiaV5SSE1t4XU4igOuFyORElif5pgx0yGDVRupGcNxNm5bR5yazPXix3GtJLGbVRyOPPddoilEjBcHEq004JdrSSf9EJmklOHO66sDVIyQvKp+gLhSwms6KhlU0DV6jC6sgQ8K8azBIih6DtG+i+32qA6rIiJgg96eMT01uMr3D8jJf56bgZitsJPPnjgTZZ2T65T0bsuoQEBy0lv/mpdiOBHfQh+GisnVG93ylCCMVgF8Af4pYUiX9hLrxobhw1c32vbq7U0TQixeLb6ydtp36Q6B75Aqae6LvJy3cdlbvB2jt6l7acIIg5pVnr X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR10MB3240.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(366004)(376002)(396003)(136003)(346002)(186003)(478600001)(7696005)(66476007)(8676002)(38350700002)(66946007)(38100700002)(52116002)(36756003)(5660300002)(66556008)(4326008)(6486002)(26005)(2906002)(8936002)(86362001)(54906003)(107886003)(6916009)(83380400001)(6666004)(2616005)(956004)(316002)(7416002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iaLHj6KPYh8tHP9NebXIrWgsugFpiog5AvTIWa8rpTznp5jgpFmwHuIJ/obWNXC71IW5LA8qFbsmuuoWtLLW6N5QrwI26i6U5PtC4/8a8upwW6EwqbS6WXw/D8XZic8gFO1+d6WxrE3FEfJl/wsCySOVsvob861Xy3cLJYNtowm9lRNwsBw3SLP+Mf3Hgyn4QbKhO614j8TgaeXBtadFcTnGuGCcqewLhuKsYX1LCtJ+XWUPw6XxStJo7AxQLGolvkbZwtneSI65hEGlVTSQDy8YeoYOoJ1xvr+I1XDzELr2cyw690BF5V0jf893VPT/CRh4/I2tJtwpwmXIMThvKhtbX7Z6+ioQibCvsjUqgjvKbs7ovRksrsDuCRcxJP7mvfK03ZkkblEaZjGyQRyU9a3Tsk4kgKqqZyNgFDjNchhAjDj/cCZxq7t05h9jD3kN0l8ClOBlTtsc5VAoxx0BM1RNq54yNpg+f5fv4I4WFee/cAGBBzRGklZjh/3BYUJFgYjwc0gwE3jynYHSCLs3eeO/1kwG4eNfZLS9LDCHRGbbfVFUsBaYgudCvV15RHR2g31P73oP+zFj/mmIZ0jdU3UonVSDfv8hBEKp4t3vvZy2YCb5ZbRoJq6w1VZZ6CZXiJscmzdXG/IqZIx2rrDeOQhS80+NzAM1WTyunIOfY+nPYisyxgiv6Db9QYRGY9/hOXd9hCdDf0m4b5V6UKXeb7EoC9ncsbqMcgCd9vnyYg2hHuAP7I+tLcw6BYQt1P6av1iImICrtVLu+MP6i8Geim66pMvxaUrQNaJWgSDFG1EYDqOYA1WUN0rzS9W3aWfCS+K3QpGtg8qWJl8OfoEV4AUi++gmVnsqF2GFk/zRVQ3dfXaQ38s6h0byEsmpj553n4obhRpZ0BVRwg2aah9FNTQZ/KYVL1efFXiGvYuobWbJ1H6w82cy24un8JzNzxf3flhDUfZH5ppa7OGSMKdvtgqVG6+VkQYTZQEB+YPVc9GRX3pJ43zRmmccpVaItMaSSZDaxmG4fk9gkuayOz6z/uI+w7EvwhGo2aAvVZqHZIDpY0iDizW7mJcwIho8MPbSP6LaOm8c/eFIpJAo9EKsTIck2tvVPb0sXlwjz14WsA1Eva1oPzNB/v2aSJhAigV3hHQCH652Ds329EMgy6PsWmaXNMu6Xwb+DSAoettuOERRu8v4sQC1rd55l81wJZAZMAyQcjsA7BcO71M2NopqWsoprIUXv7bfLw77YZsg88avy0bcqHXMXXwGCRSZtPjgFCsNYv2cLLNygMuEiv4VDYOhWDInaNPncPBEdaiy6EmGcl9WqpHPubtJvDCmnsuf X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4625c0e4-ad78-4237-3ebb-08d9409e8d12 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2021 16:53:16.6958 (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: 5xOmmkJUGx5GgM5hF/6dZxmeXSQ1ytrO7GuyFc+YTG8BKV3qIgfAm5oOBuO8EuJoxxxPMBqdrUTlYvXto6dQ6uIkUe7e1Aa1rYr+uN/MlDE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR10MB3841 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-2107060079 X-Proofpoint-ORIG-GUID: DNrouV3MIz3Il2K_PeUAbSB2NziuEyZI X-Proofpoint-GUID: DNrouV3MIz3Il2K_PeUAbSB2NziuEyZI 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 Tue Jul 6 16:45:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12360941 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58557C07E96 for ; Tue, 6 Jul 2021 17:03:47 +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 C8578619B6 for ; Tue, 6 Jul 2021 17:03:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C8578619B6 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]:34538 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0oU6-00060e-0Q for qemu-devel@archiver.kernel.org; Tue, 06 Jul 2021 13:03:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59712) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oK6-00022j-HQ for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:53:26 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:42606) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oK4-00087Q-J7 for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:53:26 -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 166GqSuJ028780; Tue, 6 Jul 2021 16:53: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=13ZPN0OngDIInQqWARKofJJbxucdobxgXa/doKPjdwA=; b=h9WTmbgdWZg2IGAKdVKa5wDVldCM/EHHiM0YwyzDA2xF8Qt7rMkYWGauKeyjLMFZYrqn OvVR1OaugYNNWMLBkkatBU8njt0UVZ0A7fgzGJYE9YzTQEcdVoZVsCf72AEvBT0IgXaE ZPM/U+r5rUAOJEqI2cpY3xKwu/G5ArUIgNQApiDvNKq3uoPaNdOEJbePILt4BIzWt+WS 4iHtd5O/snEjDafJa4c5SAa9QcnrDJB83fEUV4is08EstQa/jW14WwJQfnWbpfVO2wD2 08fF0sfmbR0QG1MWmNn+dktV0twatDrEuaEvPY26XVfTpzsd5UvFTfQZqVAm29Jq2C/2 4w== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 39m2aaaaq3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:53: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 166GoYli085104; Tue, 6 Jul 2021 16:53:21 GMT Received: from nam02-dm3-obe.outbound.protection.outlook.com (mail-dm3nam07lp2047.outbound.protection.outlook.com [104.47.56.47]) by userp3020.oracle.com with ESMTP id 39k1nvcqqk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:53:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=R3hcI4PErGKaBk/C9i4+exbwaND6xEeCVX2Nk6dMT5nAcI+QKj69Sy+RcgFvAg5mlraqqhFlQOWbPUniQki4oEcmDOYRTnkgpXLil+2LeTryNflNHdyLelNknz26KK1U3fiU3ZEJ69cvHtyOY+O8uZuSlaIHkgmbc/IDLwa/PoNhZ7Kac50OWjJ+byxYRKKjZQTxBCmp85LgmHSsDOic+6wg7+x4db+P6MQ8pXc/UgHbPCcZNqQ4q5F7FS0zNLbdT3gfTtj5iK7ak/WD+qHMFBWVYZuyDZZyXbBNM1x+7wiahHqMJzxuWDRnYVgzMAOlzyhl8MoOg5HKJC1h71ug+A== 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=13ZPN0OngDIInQqWARKofJJbxucdobxgXa/doKPjdwA=; b=jngKnWbHqsBHsJJM0siYmSgK0NQySUYsqjjKfYH/G1PuxvPci9M0Rh4mZHlb+MfgoGpEjTgaq95zt66f67y4WOWTzgKwdmJq93EvwQ8DH36WJVzWFw55+EyEUnkZEFxiW7W+9L15F19zzt7GDPD7YJ87kmHT+gTXxFlaYNc0IhYLVP+9cwfKqfqdluZiZb6zo/zDCu2/MbTd/c1SLcTM1UsO+JCG51/A2Pd7NCyVLDhfMo8hmWl7qfu+efSR8sRj3/3dHFaGR4fxlcS2Kt2VBENthNuMSAnj9Hel1kmbS+VRphBP8l9YIemMrmMZG+jZ4nTW0S6t8a98mfdOZMG+OQ== 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=13ZPN0OngDIInQqWARKofJJbxucdobxgXa/doKPjdwA=; b=brhsjX7Jkv1Vc8y3CfUhsX4eAFt5SWZlGYqACma3NHli0RCzDsao9LZfgTGFTJOBQqurIjyCdV4sX+1dIaLTzGrRzgwvV9KKMtQGGlJ1FEhM0Zc16t8cqbNSwYY8VcaCh4PbyXJGBnmT2z5yHcaTf1ZvTJ75pefxbLaH8I6O7vU= 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; Tue, 6 Jul 2021 16:53: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; Tue, 6 Jul 2021 16:53:18 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V4 23/25] chardev: cpr for sockets Date: Tue, 6 Jul 2021 09:45:54 -0700 Message-Id: <1625589956-81651-24-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> References: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) 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.4) by SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Tue, 6 Jul 2021 16:53:16 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 318aad1b-e237-4d2e-9cf9-08d9409e8e22 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: SKH3HKrWt9vWIpyXPRjmakEdTXDAvF28Mihx8Q2BmG7g1tvkwY8I3JD8B6Are0fQ/6O2/qPowJY4En/DOi+wpfaGIjvbFw/DX66OQ3kNCvn01EfXfN4+qoaX1/EcwBTYVCC7rokawx9eDlTCccWkH28nCTt52xQRBAway7CP8Dd0zTEgayPdgHxl0Fq8aJPSQbwKV2daR0XSfEHbNEb9fCgYVIH19fUl4VsnFhasakbOxFlaK9aF1H1ihdvoZfxjfYWdU6XlYcToBKnisCeB/yge2ZYVEsyPzJnMWOLXhZcl0IzhkCGDtLTSE4346SG19soCJ29U5BRdmEpU0jyxRrOFCoCM4WrXTY1AdhG1InQ6pFmg9js6zJzS+kUgsHw/IVYPtow6uKKRdfSXGaw01L+vWd0Ptk2/zSTfeB84l0ic3x5N+P8nDCyNeVYnvSjIBjcdQKGiXV4eJrDgCYVOeEGdqPEj3FIG0SeItJI1y0YkiB8q+d5lH2Az/eRLz5jnQ9PyE+c+lkCpr3Ed5tvGPg87RL0qNonV+AVQ6EFgovfVaQ6oP10yklGX6/AnVP7ldnDBvbTX8dAJdEX8h2xBlwaz4tmpA/Yzx1tjUU8eX+t29HDKPsAQWFalMbXwGBWMuwzKb/rTqQZ4d73TnK+myKnxDRvlSw/ovzm2bLd1mZkTf+uhuLwDrmlpd1DsJn92 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)(376002)(39860400002)(136003)(366004)(346002)(4326008)(6666004)(54906003)(36756003)(956004)(107886003)(5660300002)(186003)(2616005)(38350700002)(8676002)(38100700002)(66946007)(26005)(66556008)(83380400001)(7416002)(52116002)(478600001)(316002)(2906002)(7696005)(66476007)(6916009)(8936002)(86362001)(6486002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Vt5Sw/I19ohD5qMJ2YThFSGCRVeJN9OraZssdptiRpkEEvfvhw6iAPCSJRJEHqNxcqW2SH6FAOBM3TkslrTJ0Ys8K2SdrN4nVVuLGnhfMCUDaQUvNZPvlWnKB2S4ENIU4BM19B1pJkJ6yKu/9FDyUNb+oeAIfSuD5d5vX4y+ldtQzu7+JwG+a64W1Pqi4RaY3NsDhO+8/HCleVHNZ0jf3Tcf00M6LLzWrCqWRCBSI+Y3fQ2jZ65PYKVGClDb5o/gRT3QPHO+taaRJA0mQzEUVg6X60MZMIAo1HH+Pgvut+0UWGCRI2H90LEByuk64Fslkd3QgWObtoRkS0HuANnpUmhhX512Op1b0XuOpfZYeKLmbi0zu+pfnoHEM3kLAcdr24QK2pJe1uBTozGsXHyVka9tF4upV7Y8BMsd5Fr7fk3tRZNuPDmzBJvXVm2SiqqANLnSsQH8Pl/MvoRpGoaKjlA3mUJzBKxnmjEG4JIwFYMimOgNYxzcAuRNlkHxI3r0gbO0nzphTyCkV0NWlN+c3ToupI3iOevuEp099S0iCu0nKUHT76CRx85IuIGv6HA/AhJR5wcbmQL7e0pVL4XmO5ecTBnpFU4jlBfPr2HTBchsylHaLvkfHWbPAeKkD+cPVUT1QKSLoNM9fzljFIhhrghhUbrvNkhCiECi0DxAA45ZhmZeJvUJ3DmRLxhvtaNGkekDRVgOVMyJsy2kXP6AGA+JSwUUuCgo18gEgO68xAh8ICuV0I1XvgOrR4hRd0uO3JDvWUklfR/R2arnnoQ8cIRT+z7sDBL/dZgfAdJz8i4GA+CHW30v6JGFU/eE/0CoFFGEu0/JpKpA4Fj9xOIWF++LVCcAUr8iKdvQ1tOxir3Rug7Gk4c4sKAW1+GKz5IdSDlEJhcmVdeVuoC35iSibUp0IZ7/oBBbC3DhyIeCA1k7iJqrTU+ufGxc4REqKAjvQMbsmeig5PDNujcVJHXqHGvgfd9XeyTEQBdBXPK2R1bnTK/4uYYv1XSWp4oO5jCNDGxQ71DJb2Ctf9kvdi/kHgl0z2z4YssQRAZ3FG7XS2pR9AsUAKTuGqlGpDwnGkNIb0zZR0ZLR4xtlTWDYYy2m7NwIHhxpqszCJDVuH9Yscf4HvcuphWZL1V1LQZL4c1A+1M+GM4lRZBX4cop9w2WYS5DWbqN1wxGY5u9gHmCTMRJ+K5K/h0qVvGXzE0LBd6vyXNuv/QAPitpa7NdVI4lAdO7qfohIQoCf1W2m902Z8RRSJEZDK43MSpp/1Lz/2jhX+/L/lKaEV09wlL7Bbc34y/BTjmz+Ryq1oPZCD7oZfEFXwIqJ/ih9KoKSyX14lfR X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 318aad1b-e237-4d2e-9cf9-08d9409e8e22 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2021 16:53:18.4438 (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: XoD/gE+vDosnwePh+DXsiPObIurNg9DcFz236zaaY9ulRha3BBv3v7LuOvkJ8ZhXB4dX2QM1v2gdfOPZjmqVyhsDH5roi3H+BHx7OIy/PFY= 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-2107060079 X-Proofpoint-ORIG-GUID: yKlKmPQ28cjR9u4rywoK6IH5ZtJjhqUm X-Proofpoint-GUID: yKlKmPQ28cjR9u4rywoK6IH5ZtJjhqUm 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 daa89fe..110f263 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, @@ -1441,6 +1466,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; @@ -1456,6 +1485,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 2b0308f..495d68f 100644 --- a/monitor/qmp.c +++ b/monitor/qmp.c @@ -531,4 +531,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 Tue Jul 6 16:45:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12360917 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3249FC07E96 for ; Tue, 6 Jul 2021 16:56:13 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AAC5761C3F for ; Tue, 6 Jul 2021 16:56:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AAC5761C3F 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]:40548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0oMl-0008Cm-Qk for qemu-devel@archiver.kernel.org; Tue, 06 Jul 2021 12:56:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59740) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oK9-0002EO-KC for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:53:29 -0400 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:57150) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oK7-00087f-61 for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:53:29 -0400 Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 166GqBZG003703; Tue, 6 Jul 2021 16:53:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=qYg8GreNAWPes91dNHrr8yVLXP54kqPqIjoLSlai4uU=; b=JP6bq3WgoRJ3cc9zyDALLmyCyvGk1VUHQZobpREbPEQPya2vW9P/HkHUN47PAZcz12iR o3H5Hqx3LfJSB55hdjqPiqCLC5lDjv01/Jdhiz93O+AXwJaydlez3wUt/4uN68K9ovX3 0A6JD+1bxFLlog9hd+aJnhJqOy8GE0OxefBVR087QBgP5El2YpeNfhYpXaFzVDljaP5q P5KHN257Yq52BqK/8rBBjhXuzCNyY6kcMSYIVvSKs9hk8b++ETfMwqk2Q/I7xM8VSs69 jCLisjDFlge20u2vZdpsHFbChx8WEGQZPyD6lNuQnZvXcFoFLxWvqltASXcQDRky10Xp /w== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 39m27hac6r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:53: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 166GoWZG084855; Tue, 6 Jul 2021 16:53:22 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 39k1nvcqsd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:53:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dvUNS3B8xVLTFy68VS+SNATnSX2HmpNfLdho3fwOLwxDY707rfPJxxbxjiR6x3Jlp+vZJ5by7TEbTn1SBZxn7DYTUDtL4Fpw6R3T5zDW0Hk8ip1D5YcvVY4T+Y1DxEfhI0m9/IkM2THUE0aYSokJPYHTX5wU0A1tYP2TOb11epIQdRtCKuJaHt6Yry2wGVOFvBNwDuaXjjXdmdXpCiFJfuertDlUyFc1wA0fj1dzIuXUCwOwjnFgvDmyublnTKx4grJyFmsS9K4+H7MKGp2NUSzZKFy4VxQMs9wLznN6oUD3sZuQrWlfQHUdJbirqewv/q1XgMQ7m3aIsR25tVPs4Q== 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=qYg8GreNAWPes91dNHrr8yVLXP54kqPqIjoLSlai4uU=; b=QJIOhYH+jFOL6He1cLiI8gxWcbX2j/FlHfSw/1sQF+q9rd1/Lyy/r4JmPxZu6ogjdlY0vvJyZg3wXoHHGIdDkp6qDldKPLUaEGz5Ydo46fJaEXNCtsmeIaiSTDuZ+u5/zYrO8BI8CrcOBjpYnPRHQZuePAwQkokUNdbyJcsj0F3XRVHNGfJm6FoHAVN6B1JKq1lq9X6U3z9+yhxO8cMT2Au1XScreLd4p7sOTISI7p50Ak8RfbTlYR1ENSOHGEMqZBLrF2akVIkYrBEp1saVal4VJi6qSEXnWk5vQDVsUUCFyczREEDr+u2GOCa3cGUbPflxLTp97vKq3k/J5j4Vqw== 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=qYg8GreNAWPes91dNHrr8yVLXP54kqPqIjoLSlai4uU=; b=SxvxVf17+H3OdSKr/oDqA4fKtskjGkGKn0n76xMYUHDqZpM8PweIhw0ZCj/eeyBBccOB03KGc9Mt3qpaDIls4VdXgPk0xE9pZRl5HFyexFd1K3qNL/lIpaCESSR+7Pk7k+aSQIxt0V1uCW+KBZ4K0otl0fYmr8wHnAT/8lRKgRA= 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 SJ0PR10MB4416.namprd10.prod.outlook.com (2603:10b6:a03:2ae::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.23; Tue, 6 Jul 2021 16:53: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; Tue, 6 Jul 2021 16:53:20 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V4 24/25] cpr: only-cpr-capable option Date: Tue, 6 Jul 2021 09:45:55 -0700 Message-Id: <1625589956-81651-25-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> References: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) 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.4) by SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Tue, 6 Jul 2021 16:53:18 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8659cffa-0cc3-4d1f-b1a0-08d9409e8f30 X-MS-TrafficTypeDiagnostic: SJ0PR10MB4416: 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: GQaQZx6s3oRLeLJlaJPMKztUnKx2vTcnHmqTk5dUHRmL4hvpgrZAj4J2M+bCPqdkkJdZDXHih06K756kmwC2Gcrc2eqYGVZ3E69gnE9SDhjsigjc+wBU2TiNIcEcdCrzccY2ECju0SvG+q1F78TieAAQ046+jshhjotAdfyRQUY7D/S6ghfgmRI3dQ9sp3oyEPI2MIBaAX+HFw+OITff1ub5qWw8USIp1hk3eIYE+YY17dfBVU5+CtDCI5UoihsPsPQozkNx3j+cuMNbJhDOfFEUZCvSp/lSxXOqnDZxvM0LZOrCLL3Al8mZUpr/C4OAq6pDT8RhvSjuBnyqPbmPNcV5mLTAaWsiA0ZVpDO7bTfX0hZJqVQXtvLoVE8CEUvqof+04gawxgyq5EJAOoPujH7nDBojzHb08MplfoV3UXX/qcL4H26IN93s8BIM1VZhOT3/7S//OsHzNT7qhgDQV4fbD3H4jfFE0ceSLhnKSRbK0TZvGiqBkdR5l3tQoPNlA/Wo0cYp+fcU8F+Bt1JMoA2AvvoTpzrFRa7mSiUN2F6QFdCYHCz9PsvOABZazpXWi3wMHtLwX8sKc9XBFIDE3Tyisq2LitC8SoAEA0sfZqyEpvvUkEaWpq/0j5KF4UYQlpk8CHFFHD2nX/JygDXCu51YkqIwGt5YYOnVwPNRbpql9c+BPSyf3SD7ehqQZKTBJU9nZx6DDl/dRXYoKxRTQQ== 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)(39860400002)(346002)(366004)(136003)(376002)(54906003)(83380400001)(7416002)(38350700002)(5660300002)(8936002)(66476007)(38100700002)(107886003)(4326008)(2616005)(86362001)(478600001)(6916009)(316002)(8676002)(7696005)(52116002)(26005)(956004)(6486002)(66946007)(2906002)(6666004)(36756003)(186003)(66556008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UELPtLQdptl98OVBEGMM7yJuvy16tHhPK9HR011OcuvJVd5P2JiXYYDcIV7iMnTwcNrWTlwhtrN7sjpAfvPFI4TSH3E5Qlg1S2Ri3v8/X4tfNbzOxwxDByu8ZW1RWvesgxt8vko6cGxIc9sHAiQc9Uz4qD2QpfDi4AozfEyylJbnHJfmdNXPT7Zv/mqNXJRMFVEMMqLtDOgdBH5YaiHjhYEDcs7jDPJ7+7xmKINaBzf6VLtLP+kqepNpIzAhOHwoOHFOOhksv1UezVmehisya2VAYGh09qoEToTNu00Zz+YQwSwK+7nVncD7TZWnxJzfUVVpx7VnvyfQ5qICPkF1lkJdUJGFzcByxgolBPMUUJnboldhEuFM3O8wWKpmKn2iPnv1ZZQrh4YXq6oQvg4OpfJ9IaZqylVBBf0HdwhbPC1ImIjQetT8fUgmMIK8Soo8bOcWE4p0AfYhBkaBydb2P5Cezw3vyLeq5o0Sc32/ybwemajF25HDhD2iRm8ZNnyK1yLZgc+qX6/hWUtgxpQUYoaPmmv6G3wjzduYAZ7ymvfrCYBzJQdPO3+A9FU7C4QpzfKeIfkhC1r5kd21eiwh7kERrlfTAFZzv7X+1jRQ08GulEVyLrqdXnSxAQL+sRziMW+/k/7f4DD7yiAnVezuNK9G+dlVYPiqs5Cqp1uOLf1kbll1O3kDowDUR6XaaJ/RqusKk9t7sKB/HI/GWIk2DBOuy00CQVcti85fkY3x7ygGFGQml7735rtrjzY0mRqB650LXVny3xE3DRbD9YdP7qs9BjGT/1C7GIwLuu5OiRCcAI+3eTZk4QJxlXidiFcPCSaONh/mCpHeHnzpAb4gRjSL9d5SVUKzCuM/aGV1QzYwWq6/EwbR5xsrMgjPYWu4h1HHne2WBKuRBCvtsR6amYiCmnXR05L2WPxroNJvpJFzsd2G68A3aIg1vGRklz75sp4d2t7jafXN7vKeYQlFZPHZO5V+syDTGNguSw6l3dBOg2Wy5wiIIbNRiKWJBfM1KkrmxKGrV7U48mMKTvqlOkgDWNwAQJ+hSvlBT6Mxt1xeXAHRAKWPdsF9rueQCWZQSEMtjcZSnNWSVWhQLsdO1u3ISyRxZ2BGTmufLxZFavJTPJMgDCFxKz5CGP4e2/jzAi9Q6gVedzhhJ9LSi081WyaiOAUXKrTHunMWS/M2TEJfhpftV4KrdzhGz9V0mxxGvjoUZ66+rXSOwhgi/1GR60nBYOEOBjqtZxtf+uIam7WrDNRgJkc5g7GSgHAzqzI6XZf5xc/pWUU90AomM7BQd6EWhxrhH8gol4LNa8UiMnOdUTzZ187/9fb4wXFSCBuF X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8659cffa-0cc3-4d1f-b1a0-08d9409e8f30 X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2021 16:53:20.2028 (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: kSIoHDfQfl7PImH8HywKx5kVYoq21vTp1Uju5qyQPl4JU439CVUGCKoXPPpxv4GnNC6SyJ5oSFPzQdF7gHaHB8oq8rJRKLPPM+SRWlPBhVc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4416 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-2107060079 X-Proofpoint-ORIG-GUID: Bwy5lLfqr3FuFKTgYN0GdNNcW9-NI9En X-Proofpoint-GUID: Bwy5lLfqr3FuFKTgYN0GdNNcW9-NI9En 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 | 4 ++++ softmmu/vl.c | 14 +++++++++++++- stubs/cpr.c | 3 +++ stubs/meson.build | 1 + 12 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 stubs/cpr.c diff --git a/MAINTAINERS b/MAINTAINERS index b69bbf5..25b5bc3 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2853,6 +2853,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 110f263..b8c75ff 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 */ @@ -1468,6 +1469,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 492ff31..706fc0b 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -266,6 +266,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 8ca0341..181c8d5 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1262,6 +1262,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 ef2d24a..f1b372b 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -4257,6 +4257,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 b79f408..04e3603 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -1973,6 +1973,10 @@ static void ram_block_add(RAMBlock *new_block, Error **errp, bool shared) 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); } diff --git a/softmmu/vl.c b/softmmu/vl.c index aadb526..78f8829 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2589,6 +2589,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)) { @@ -2598,7 +2602,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) { @@ -3339,6 +3348,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 be6f6d6..2003c77 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 Tue Jul 6 16:45:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Sistare X-Patchwork-Id: 12360963 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1FCC2C07E96 for ; Tue, 6 Jul 2021 17:13:03 +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 B0EAC61C56 for ; Tue, 6 Jul 2021 17:13:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B0EAC61C56 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]:34190 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0od3-0007oH-Jv for qemu-devel@archiver.kernel.org; Tue, 06 Jul 2021 13:13:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59738) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oK8-0002B5-RN for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:53:28 -0400 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:46374) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0oK6-00087h-SN for qemu-devel@nongnu.org; Tue, 06 Jul 2021 12:53: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 166GpkBc007364; Tue, 6 Jul 2021 16:53:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2020-01-29; bh=+vyo8cyFeJn4HRpXZj3DzYe6S1G5SWpclntcSWRLX3c=; b=dHaiRPVCy/lR3L+uVE3b3EGAhSF4omWg5CG1hVa0zNrqWU+kll8zh7YFDG1uFOXRr7Cf LwhXu9h87TIipF6tAirWHyE+vpyAYWg6nOSKACvq900Fcfd2jEG8kEjbrIxZZV3Tib5N JFhHj2gVdVSTbApNgUQTv75sMEi3zogjm7FbfFg9/ZpAnHLop7B4liaf2J3yjcta4dtk 3T0VB8KEYNN2swRwWWOTLu0Rh9aJDSKjxaV1oJ9ERJytqHmtamECy92aC03xewOjA46O mX/MBhfH4rzcNrsVB2oLQzwFm/jKhJwrqs02zL2yy6mLkIbRKDcKC+BDzPFgPbIllyxT Xg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 39kw5k32g8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:53: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 166GoWZH084855; Tue, 6 Jul 2021 16:53: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 39k1nvcqsd-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 06 Jul 2021 16:53:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XbPcOnIpE9Osq0FwbntzcDFDtQekH/ZX4UKF4UNk6Gn1ReRXyVBqp+ZL6o/qljHJGhz83uCS4+eMSPjC5ZH+v7yrtiFTsRCJLW1KV2iCli3jBcGTYXqom8MjtwmQIwAp+m6jG2AFocKpV1AD71b/KdUcmOi+u8fageHBWZRoUMDGJrY/ix0huDIWdJM9CgL6+AMTc3pTXgj2zuvzCiQtbOnJgBzlSQje9FDoOm4sI/Rygy9FXeeERe1vz/9vOD9iWx55TkgDtFt0onKz92idzEz/ZOkMhrLI+IXIIUYrS/bxhUmKmsai7i6X5PBr8XCzdxbpPw3Z672UoCIEt5r0LQ== 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=+vyo8cyFeJn4HRpXZj3DzYe6S1G5SWpclntcSWRLX3c=; b=JXHMQ7qja9jh3OY10lhbGzKDyjSY4U0dSZzTnICVXrCyWe32M1mSzscR0f52a0Y/7plNrVadY2WezEbqpKK17HwUeHFhQ9dmqTjvSX3vG74XsA1I+7ruzTJT4JbJBYEefn+yfegCdKeQktu5DP4U/keU4qUKciXT2gxyqwBDATIEla2aImDCCIMYtUiKinYAXWz9ef5JoVRZvgK7nUHu0ayf7xrm4/x05N9B6zk/YyE57So0/b5XaLJNHgCVhwcvfoGj8trG/h4SY2oniuK4MtlNKNKVSSkbtyxK/mE+Krbcgh9p5WgGQM1zKFFoX5ClqwG6BrMO3JxXq/tFXivWzA== 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=+vyo8cyFeJn4HRpXZj3DzYe6S1G5SWpclntcSWRLX3c=; b=c1XNkfhqwrGzhtwc0bxxvR/PiPSs5rwiDB8KDJOnr1ZuA02F9PgrjeujtIVH7CRcWqj9B7+CQVRmg5s50Q0Tamrwh3RSEpsVhygmdFzxb24IVTEL45G6KJXZ9KYw3s7K1Ou90vTXmJf+XG8uNBCHhJkR64UfVuQGdCEUxWqcE+g= 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 SJ0PR10MB4416.namprd10.prod.outlook.com (2603:10b6:a03:2ae::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.23; Tue, 6 Jul 2021 16:53: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; Tue, 6 Jul 2021 16:53:22 +0000 From: Steve Sistare To: qemu-devel@nongnu.org Subject: [PATCH V4 25/25] simplify savevm Date: Tue, 6 Jul 2021 09:45:56 -0700 Message-Id: <1625589956-81651-26-git-send-email-steven.sistare@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> References: <1625589956-81651-1-git-send-email-steven.sistare@oracle.com> X-ClientProxiedBy: SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) 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.4) by SN4PR0201CA0041.namprd02.prod.outlook.com (2603:10b6:803:2e::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Tue, 6 Jul 2021 16:53:20 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 46f3590f-dfd2-4ea7-3314-08d9409e903a X-MS-TrafficTypeDiagnostic: SJ0PR10MB4416: 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: Frr5E+Ra68CXt7U14KcSEGCxg6dj2HXVG7KwmdfXkR4IKmqOM2DpNTay5G/A306UokmcV3vtHqxDRHwHLjS0YLFVD/q7WnFaCEhNVZIZ3HfvtXpQPbN6TehRORE+pLV5wu9FrP3kcGZKh2fG+53xXqo3Rb+Upfr/8bgqgZ8vBsUfiwPlAwhv/wijV6Rl5CE5KT6uUWi1HgKp/yKUk4etCoVAUrb/ZxLsmJPyFjQohmUcPhUDvtHyE054uEQpb7CU5Ga/zMnZkk1j/nnjNUTJSzxo8Ra0iN8mdnY4mwY3eBlcFMADmbpgIgeYWqdZTBgc1yCxji2/vSlhxM012S2YYENlqzI3OSkuERtK6hnA5zFQ8dJ9Q1tDzON4zT/gfXO2mGXxalC4cehvkidmo712CSwrdS1cvB1Yo1aq8yjHquLbPhU+GP10RseXpZmNu3mImJ22B9p6Jw0Fo3wNz6cgwyqlL4eqOOSXsZGqKT6CTw+mMLTadurOOEoMNonzi/mjA38p/fuss6f9vXa3BolqTMcRZ9NhZYPTZlmlzYRVS0h8UDv5QuFMdYUd8rPlpTa2G+Zmg/L72V4bppH0cgedzqa15mCL3FTG6lDuS3Q5NbHiFjUayrHYP4TE+BS3vk2wBDDpaNkQipDKNb+J7SF7LlYXPEbLLziIYxIlVIHWTf3jvi4V/x3ZvJ4mviV5/sjRB56xS9LU8Dzq4/5VV5fmdg== 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)(39860400002)(346002)(366004)(136003)(376002)(54906003)(83380400001)(7416002)(38350700002)(5660300002)(8936002)(66476007)(38100700002)(107886003)(4326008)(2616005)(86362001)(478600001)(6916009)(316002)(8676002)(7696005)(52116002)(26005)(956004)(6486002)(66946007)(2906002)(6666004)(36756003)(186003)(66556008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BvStjq1Q0tKyibjWuzUqc8NEmP0DzZ7OIP9qOe6yxnnWeTVf9I2TAmvIaE8GcqQao6nly4zWYQGwFqmFCMYdagvv9IxArywaK0QIy0qxpVeMpNHSSF2gPtjanmGa/xQ+df7kQe76yPWePr0ABdRhew98jtu1g03sqGWfkRwDPd6Z64cp+N7BJPsy+T67zYjclt3uWRqOulVpUD2dI3zZx1hVrXTfnDm0OX5KuoaAybpLvp8q7EtXVMuqJupTsSItBDDifFo2fjlGXTUz6cau11qhInTHfMKl1vOldHPe3BcPcYXd++PqIgWT/F/1Jx2lyWU4triQ/gK1QQl6Cb8TK4OQ2QaEGrtsqLDauxXfcJ1/Rm6J8Nc4NYeqBB2lURgFMoAxyYy/i5HW9GvOO6K/VnoLVltjC9XIDYcMDB7EXFquunlXc9SpPnquLO5FnzAo8Ab6sllxEGGM1au2vJsenCjdmSSXNSeb7KCwKo5DVWa9FfCs4E7MjoDXw52KekIvwYbAqKTrLm1iGpdGRtTzYxLxb6m0pMNMHguZzlpKGU5xhlm74oXv2BzVZv0uxeRZnSQoN6rlnEJYMfv1avX16/34PqDK5bFDIJUvkrbP5inWTRRLc24KmyfmN3wMb/sPRsKaK6FeWuvJL5vC68Q6b40TlykZM3yD7mFhiRgwf21EjaCdDXlurecbgyTe8N2haS6Gbx8rnXO+2J9+Ii8kQ1xHUG3Y+zheKNUIdN03ZImOuHrr8Ab7CyC6M7/b7DV20kIqACAGjIH6HVeewEezJwE4Qa1gdvrPyVYmCj4BHQ1Ec4J/vDu6gzFq98f4Fw/KxfXdD6nRWW/9wk3YRPtPM8JHaGFC8074ZKAVJd6gdOsKuTEbKtVAhujts1hVT8DsGh0quqwQHcrZ9W2STTV4iYasVmcIefyub5wvSLqh/NHD1FupGGIKZJG2ilmDNYFdisr2axAZvdykUgyZ4rU+tV84qwqX7iz1RUh20pWI08NYqY6URbpNh8LTLbHLktP8zz44rZ88zqKSCKvpU9tD5g4y+ZscjPWJcPAhQj3tTPAAcriJ60oZbMf0Eg/AlPg2V2oNph23Q6N6/7elBNMnlIosNKMoIiRFvzrkTHqH4e68F4Bo9MfpdMdml/B0qSQWeAzlhr00GkQ3xDcbOw2xDUO5e1flq2j7CJGPiKy8ihATay/vW/n3FdBoOvwUglM/Nr86y9i+3qiO8Kzo0QdrOO8nZ6UNoU+6F4Ctga8kVZjfbcW/xnbIO7wkc1hiZXH9yPjofALAYOl0s405u5lLl7Er80l5evsNk2v5NnVtw4ua85px8mV4ha6BdixmCpJo X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 46f3590f-dfd2-4ea7-3314-08d9409e903a X-MS-Exchange-CrossTenant-AuthSource: BYAPR10MB3240.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2021 16:53:21.9418 (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: gBi38LP4KSsVmzhwOqY+I7gDWa1WL74VQmtm9GfZ21QsmP7yUClTpr3JfqnZ/sSsoK6+CsDm+7YgmdjP5BJcgzIXeF95t9Uza4H5nhj59lA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4416 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-2107060079 X-Proofpoint-GUID: cxURtPg00_S7Q2EaVTTflopaWYsjQkYA X-Proofpoint-ORIG-GUID: cxURtPg00_S7Q2EaVTTflopaWYsjQkYA 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.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 52e2d72..d02bce2 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -2904,8 +2904,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; @@ -2919,14 +2920,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); @@ -2954,8 +2951,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 @@ -2967,14 +2964,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) {