Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 60E59C25B77 for ; Mon, 20 May 2024 21:06:24 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.726361.1130630 (Exim 4.92) (envelope-from ) id 1s9ACh-0007Yc-QB; Mon, 20 May 2024 21:05:55 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 726361.1130630; Mon, 20 May 2024 21:05:55 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s9ACh-0007YV-NK; Mon, 20 May 2024 21:05:55 +0000 Received: by outflank-mailman (input) for mailman id 726361; Mon, 20 May 2024 21:05:55 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1s9ACg-0007YP-Th for xen-devel@lists.xenproject.org; Mon, 20 May 2024 21:05:54 +0000 Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam02on20600.outbound.protection.outlook.com [2a01:111:f403:2405::600]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id bcf79b9c-16ec-11ef-b4bb-af5377834399; Mon, 20 May 2024 23:05:52 +0200 (CEST) Received: from SJ0PR13CA0138.namprd13.prod.outlook.com (2603:10b6:a03:2c6::23) by LV3PR12MB9258.namprd12.prod.outlook.com (2603:10b6:408:1bb::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7587.35; Mon, 20 May 2024 21:05:47 +0000 Received: from CO1PEPF000066E9.namprd05.prod.outlook.com (2603:10b6:a03:2c6:cafe::27) by SJ0PR13CA0138.outlook.office365.com (2603:10b6:a03:2c6::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.16 via Frontend Transport; Mon, 20 May 2024 21:05:47 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1PEPF000066E9.mail.protection.outlook.com (10.167.249.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7611.14 via Frontend Transport; Mon, 20 May 2024 21:05:46 +0000 Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 20 May 2024 16:05:45 -0500 Received: from [172.21.89.32] (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server id 15.1.2507.35 via Frontend Transport; Mon, 20 May 2024 16:05:45 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: bcf79b9c-16ec-11ef-b4bb-af5377834399 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ERN8D9mU+kVbO/1d2c+Vz7TEWRAnhj/etc7AmtIkbTyV/b88ojE8QW6jvbQQciRqh/RTz+WGKQuHw47DO6W17aVgfes3zhUin1ZuwKBUN8bZDeSUTBGX0UMHLGw2i2k84ilZv60UvSIIcrq621tEE9KLANxRnkyprbGCG3Vm9rscXovY40wSj/LdCf6cbhwzviU4iGUX+yOClq03g5uVRIovKI3jcs3XeXP6eQv2TTnv+ucdwvYku8qOerbgICd5suOSWLnENWMe0dy0QMO6FJxaE9IeEiU6UaP+cE/Tk/3/ivVyo44JJVfNFwkW94yZdMKwn2Ss7QYOtLM9TaVZIw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=a1Dh8SCd+uOTZ2/DoKJPBehNZMUCC4Bg5NtdqbgxHj4=; b=i4YHsLAhs+FIx85IE6n1IaGjyDMLuYVzpiPtOh8v+t2v2YzYtFbVXxJunGdUFeQ8zuZ0NjW//tLoiETwkVva/xWKI1Ioppg3FNESYRUml88uqhq73nf8fvatOfTZS2AvzkpixrR/oSBHeayDmdac7InEhsLgguYZeLuDSUNpHgnw8/tq3Dz2FlRukOazT8SLRhjeS2WkpwpfyA8WnHUahS9O1XuRAAGWjvo6Qtvj5SsszxjF+7562MiYvMbAix41I45WTOwTeVaI0CmOgNhFWQJ2pqEb9bdQ40VzYZK/HFlsvJrVH0rZBItGUcipyTC40OIsM1lYrKnv+QqgBAZThA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=rabbit.lu smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=a1Dh8SCd+uOTZ2/DoKJPBehNZMUCC4Bg5NtdqbgxHj4=; b=kxWVcElWhlizgrEem+JbHT1Wo270N3RJmeEn6Gxe0fyR0UE2ZIp4P+b7S2F+9rNIEBXGLbDeISmo60aTZMc4+kGTjVcizPtU2EPDpN66NIpLY6bThGa7RJplNAUhpwFZZK1oAKcX83spgGOsZkTrxwLrsyWpJ6z0I+Ngs50GMf4= X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Message-ID: Date: Mon, 20 May 2024 17:05:44 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] tools/xl: add suspend-to-ram and resume subcommands From: Jason Andryuk To: =?UTF-8?Q?zithro_/_Cyril_R=C3=A9bert?= , CC: Andrew Cooper , =?UTF-8?Q?Marek_Marczykowski-G=C3=B3recki?= , Wei Liu , Anthony PERARD References: <4e9f3590be9f19edb87e05c7b7c2efeae8863109.1709190010.git.slack@rabbit.lu> Content-Language: en-US In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit Received-SPF: None (SATLEXMB04.amd.com: jason.andryuk@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000066E9:EE_|LV3PR12MB9258:EE_ X-MS-Office365-Filtering-Correlation-Id: 16d09114-d41d-49ca-186b-08dc79109ed5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|36860700004|1800799015|376005|82310400017; X-Microsoft-Antispam-Message-Info: =?utf-8?B?NWFneXZYLy9oUGduMlJaUUoxN0ZqZnZJUmFuRTFHWnNVYXhjWTZxNXdsOHpw?= =?utf-8?B?OWVMSHJxUnlTcW9TdmxxRWVHc0VsZkozM01YWm1IVjZmdEJhWjlodERzNWo0?= =?utf-8?B?WnBJbFgvNnZQUWRXK2pkeVo1NXY4dEJGbDhqblpTb3B1eVErWW0wZnZTWjhk?= =?utf-8?B?U1RaVkZ5Uldhdm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TR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(36860700004)(1800799015)(376005)(82310400017);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 May 2024 21:05:46.9564 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 16d09114-d41d-49ca-186b-08dc79109ed5 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000066E9.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR12MB9258 Hi Zithro, On 2024-04-24 10:03, Jason Andryuk wrote: > On 2024-02-29 02:00, zithro / Cyril Rébert wrote: >> The xl command doesn't provide suspend/resume, so add them : >>    xl suspend-to-ram >>    xl resume >> >> This patch follows a discussion on XenDevel: when you want the >> virtualized equivalent of "sleep"-ing a host, it's better to >> suspend/resume than to pause/unpause a domain. >> >> Suggested-by: Andrew Cooper >> Suggested-by: Marek Marczykowski-Górecki >> > > You should include you S-o-B here to certify your patch under the > Developer's Certificate of Origin.  You can read what that means in > CONTRIBUTING.  tl;dr: You are stating you can make the open source > contribution. I'd like to re-submit this while retaining your authorship. Are you able to provide your S-o-B? I'll do all the follow ups, but I need your S-o-B for me to make the submission. > I tested this with a PVH and HVM guest.  suspend-to-ram and resume seem > to function properly.  The VCPUs stop, but the domain & qemu remain. > Resume works - the VCPUs start running again. > > However, the domain destruction seems to hang on poweroff.  The VM > transitions to powered off - state shutdown - but the domain and QEMU > instance are not cleaned up. > > If I power off without a suspend-to-ram, everything is cleaned up properly. > > Have you seen this?  It's not your code, but I guess something with > libxl or qemu. I've found the issue. xl exits when the domain suspends. When the domain finally shuts down, xl isn't there to perform the remaining cleanup. >> --- >> - Tested on v4.17, x86 >> - the function "libxl_domain_resume" is called like libvirt does, so >>    using a "co-operative resume", but I don't know what it means (: >> - there may be a problem with the words resume <-> restore, like >>    for "LIBXL_HAVE_NO_SUSPEND_RESUME" >> - for the docs, I only slightly adapted a copy/paste from xl pause ... >> --- > >> diff --git a/tools/xl/xl_vmcontrol.c b/tools/xl/xl_vmcontrol.c >> index 98f6bd2e76..ba45f89c5a 100644 >> --- a/tools/xl/xl_vmcontrol.c >> +++ b/tools/xl/xl_vmcontrol.c >> @@ -42,6 +42,16 @@ static void unpause_domain(uint32_t domid) >>       libxl_domain_unpause(ctx, domid, NULL); >>   } >> +static void suspend_domain_toram(uint32_t domid) >> +{ >> +    libxl_domain_suspend_only(ctx, domid, NULL); >> +} >> + >> +static void resume_domain(uint32_t domid) >> +{ >> +    libxl_domain_resume(ctx, domid, 1, NULL); >> +} >> + > > I would just inline these functions below. I see you were following the existing style, so this may remain as you wrote it. >>   static void destroy_domain(uint32_t domid, int force) >>   { >>       int rc; >> @@ -82,6 +92,32 @@ int main_unpause(int argc, char **argv) >>       return EXIT_SUCCESS; >>   } >> +int main_suspendtoram(int argc, char **argv) > > Maybe main_suspend_to_ram to be closer to the command line suspend-to-ram. I'm thinking we may want to just use "suspend" for the command name and all the functions. Thanks, Jason