From patchwork Tue Nov 26 17:19:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jason Andryuk X-Patchwork-Id: 13886245 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 10C5CD65531 for ; Tue, 26 Nov 2024 17:20:19 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.843946.1259522 (Exim 4.92) (envelope-from ) id 1tFzEO-0004tA-Iv; Tue, 26 Nov 2024 17:20:08 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 843946.1259522; Tue, 26 Nov 2024 17:20:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tFzEO-0004t3-G1; Tue, 26 Nov 2024 17:20:08 +0000 Received: by outflank-mailman (input) for mailman id 843946; Tue, 26 Nov 2024 17:20:07 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tFzEN-0004Pz-7M for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 17:20:07 +0000 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on20628.outbound.protection.outlook.com [2a01:111:f403:2416::628]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id ac2105f9-ac1a-11ef-a0cd-8be0dac302b0; Tue, 26 Nov 2024 18:20:04 +0100 (CET) Received: from DM6PR02CA0165.namprd02.prod.outlook.com (2603:10b6:5:332::32) by CY8PR12MB8411.namprd12.prod.outlook.com (2603:10b6:930:6e::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8182.19; Tue, 26 Nov 2024 17:19:59 +0000 Received: from DS1PEPF00017096.namprd05.prod.outlook.com (2603:10b6:5:332:cafe::54) by DM6PR02CA0165.outlook.office365.com (2603:10b6:5:332::32) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8207.12 via Frontend Transport; Tue, 26 Nov 2024 17:19:58 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by DS1PEPF00017096.mail.protection.outlook.com (10.167.18.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8207.12 via Frontend Transport; Tue, 26 Nov 2024 17:19:58 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Tue, 26 Nov 2024 11:19:57 -0600 Received: from amd-BIRMANPLUS.mshome.net (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Tue, 26 Nov 2024 11:19:57 -0600 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: ac2105f9-ac1a-11ef-a0cd-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjJhMDE6MTExOmY0MDM6MjQxNjo6NjI4IiwiaGVsbyI6Ik5BTTExLUNPMS1vYmUub3V0Ym91bmQucHJvdGVjdGlvbi5vdXRsb29rLmNvbSJ9 X-Custom-Transaction: eyJpZCI6ImFjMjEwNWY5LWFjMWEtMTFlZi1hMGNkLThiZTBkYWMzMDJiMCIsInRzIjoxNzMyNjQxNjA0LjQ0MDY4Mywic2VuZGVyIjoiamFzb24uYW5kcnl1a0BhbWQuY29tIiwicmVjaXBpZW50IjoieGVuLWRldmVsQGxpc3RzLnhlbnByb2plY3Qub3JnIn0= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FGoTd8PZBTxsibYfTlg5gL9ItuxwWoGfkI7Rqye8kxQH5Il8ID2wwdYDclpZhymDgrjOysyprzHbby8TSm0FCsI62tk9mu6Al3L8Xbm+Ve+dqqTFwRx1gSCuxxnWw3wZES9hzmdzJ2vRoCI1yJ5uO2VHslfG5KkVjXyslYKrdRojPDqYhuoHwOdtGqaIp9EdLeXMwHsT5TaC83rxxwAypKsHSbIzrvAVE1TI0dITsqqAVifS5qDSj44xzaywsu9s0oytTHnl6gkiqHRamak+nAdJXO6pa27W9KqHOvf0DUTCr0axKVflc5WNEjPIv+omKh+L6SJVVwcbNTs1YjL/sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=hhTkzwMxV7eXeFIK7XcXjiaxfIWPWWwchPU8SykcV3U=; b=jbO+B0ursgyD7cx4e0NtsOYz3jQHMwD0FYwKItPNTBDpPqDyiQRPq0BCO3aBZQ0ljg0AbYhn9zQsdn43OopohAZFTcofMoupHgwNfZaYvcoTQaBlJ7MtsGmWyBck0kSD/9KABbFotM02GPuW/kPbFE11ZZjgg2lPpxaOXII5pXwk9E0pqgB9RBS6B+c/W33FLOsUumXSG41zLE4RfytqcXyWomQ4P6JiyM8xPmp8Z5uv8arrjVb0b92FJJfHVEZ3b5bPStlDJP9+/ANv3+icGZxbNnwdZmqE8afsstGugdzRYY9aW+nqD+mdaql2EdMdHRwfNKRf9JrjHZIWmzNi3Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org 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=hhTkzwMxV7eXeFIK7XcXjiaxfIWPWWwchPU8SykcV3U=; b=hWcLAfsqjNN46rx/RXzHZPIQjHqZekj91PQZB5xhbjnr/CyORc2ZluQ88cq1wdDnUGhtIbbz39J8qMTLsEtQScSVDnejpOOMtyyAskZLXeCYobYm4v4mQvt+RMdQLP/9kpq38PjexuyAd1O/9oM5EItiuceAFcq5f5Cg45wfiHQ= 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=SATLEXMB03.amd.com; pr=C From: Jason Andryuk To: CC: =?utf-8?q?zithro_/_Cyril_R=C3=A9bert?= , "Anthony PERARD" , Andrew Cooper , =?utf-8?q?Marek_Marczykowski-G?= =?utf-8?q?=C3=B3recki?= , Jason Andryuk Subject: [PATCH v2 2/2] tools/xl: add suspend and resume subcommands Date: Tue, 26 Nov 2024 12:19:41 -0500 Message-ID: <20241126171941.170897-3-jason.andryuk@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241126171941.170897-1-jason.andryuk@amd.com> References: <20241126171941.170897-1-jason.andryuk@amd.com> MIME-Version: 1.0 Received-SPF: None (SATLEXMB03.amd.com: jason.andryuk@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF00017096:EE_|CY8PR12MB8411:EE_ X-MS-Office365-Filtering-Correlation-Id: 54c6437b-a83c-43a8-6c5c-08dd0e3e8dbb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|36860700013|376014|82310400026; X-Microsoft-Antispam-Message-Info: =?utf-8?q?DhJC9YUz+q1LuaymHIpJtsnU+N0Acne?= =?utf-8?q?Yho9Ddv3ZD6INgXYtZKooMYbDvJqUkYnSOK5zj6hHbzl4msi3+Kr+7GCJgCnWx8jv?= =?utf-8?q?DiLMDQEBqSS73T9x1azAgf+fVPD2b4+WpEWCt3QGJx4SskHUp3rzD61yjFR04qU3l?= =?utf-8?q?a/A/O2o1mP7eZdlXGj2BfcTSIHCiJvVF8zqjUoOe3AsrVGypIvWWDuO37l114i2Ap?= =?utf-8?q?GQrFRbx4uO/dG4YRLWhd7PcbGQweWKI8X2G9BxTWmxfXElETQD3P1zwY+c2jA9IIn?= =?utf-8?q?mAQhQlOfdRVASQ3hfvfjRa3ggEwo8Y8L0EVltg4gGkb9fkQOToCw1p5e9Joa2yG1S?= =?utf-8?q?TqCgIhEHDm4hT7ndZc48b+39soBMSdSbhVGSWMsf4cKpb3lRlr1ZzbupFSFL18Dsm?= =?utf-8?q?KCLn5k7WMjHhZeOgRAgKT8D4a6vCI7/ChZ1WzdTreaskQCegekqIFv/mh6SZSULQC?= =?utf-8?q?R4FQgdrgrkS4qiFeK2u1Jh6H05rs+BZLorijwVpgsrZxx3GnR2nl5Qy38VpQluaAz?= =?utf-8?q?OLOdp0cF7fSryssA606/M0Rnra7MmkILEnDk2u27Tk+/nyG7oFPrrI02m7JoYybzv?= =?utf-8?q?A7LvMrCQwoEXe7U3j8Dm+xKeU7PjZjWSIqLOMnT2ZRAX/fbmtlCkO9Ke9H4mf5/ln?= =?utf-8?q?ax24dFYJCuFhWwpJcwco/TcSnpJvd0dSBo4szFkPGf3mUEZx4cafCH0tk1+zDso9V?= =?utf-8?q?Dr5DqJJSXGOFlfINOOEKt6mahWdGax/cAE78+/qTmoquep9SOcnLqxwRl+3w8DdXg?= =?utf-8?q?96GYP7XBKGLRe94kP9+0W1zxThz6xAoXuy84HPS94qcbU9MUBI7U5idAayZxF1/3A?= =?utf-8?q?yyfVF7V3suU37qwRUhTmT+cK/AIAiMOLk4LXYTARy/vEDZwUVApbFQeGUFnXbkTAp?= =?utf-8?q?jQzzeQ0KY72cTMqnYHuRXVEoiQW63BiAyKwRqsbk57sBgsc+LmyZBm6MpmQpDpZnL?= =?utf-8?q?xtbgl3sdCwIz8rWyguBIilWVZZoDSQ0t1z672TJC685rHk2WVbaUSwaqWhup+o/2w?= =?utf-8?q?Kcb5NInUCggv7Um3hDUbjAAHYnabV5Wk1mCmwQQlA7wbUELRpw1cPZh5sijnhRU/I?= =?utf-8?q?9kQepvg492+eLyWSWNBNSut9xQglu+LjGIPajuPaCzEYwWOVe/53dZA7N72tD2Adr?= =?utf-8?q?VzhIyxg0nQstSe4uBvuQusl03rJysJaL+Q+QbCoVLKS0hbjJpbkAvCbw9s9YITa5G?= =?utf-8?q?LL6lbir+xaBT0vJWU4AJ6n3Y+EDHQLOtdHkzQM77BsK6WlhC72VkLsDk7LSAAVgjC?= =?utf-8?q?DfaTe+PZ7iniOqgV0CA1/Umi1SXXbL50qIwVJ6w9qm1myQVvUMuaM/Ul9Vz4ztmDT?= =?utf-8?q?1or9M5K1K/Ox8mexXCgv0NY6Lp0kF939FClLeYLQfdn7sfwjf4oUi5NjbLgu5Ty/Q?= =?utf-8?q?A7icNlNUVGn?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(36860700013)(376014)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Nov 2024 17:19:58.4016 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 54c6437b-a83c-43a8-6c5c-08dd0e3e8dbb 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF00017096.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB8411 From: zithro / Cyril Rébert The xl command doesn't provide suspend/resume, so add them : xl suspend 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 Signed-off-by: Cyril Rébert (zithro) Signed-off-by: Jason Andryuk --- Rename command to just "suspend" Move inside the HAVE_NO_SUSPEND_RESUME --- docs/man/xl.1.pod.in | 12 ++++++++++++ tools/xl/xl.h | 2 ++ tools/xl/xl_cmdtable.c | 10 ++++++++++ tools/xl/xl_vmcontrol.c | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 60 insertions(+) diff --git a/docs/man/xl.1.pod.in b/docs/man/xl.1.pod.in index bed8393473..fe38724b2b 100644 --- a/docs/man/xl.1.pod.in +++ b/docs/man/xl.1.pod.in @@ -682,6 +682,10 @@ Pass the VNC password to vncviewer via stdin. =back +=item B I + +Resume a domain, after having been suspended. + =item B [I] I I [I] Saves a running domain to a state file so that it can be restored @@ -760,6 +764,14 @@ in response to this event. =back +=item B I + +Suspend a domain. This is a cooperative operation where the domain must +respond to the xenstore trigger. When in a suspended state the domain +still consumes allocated resources (such as memory), but is not eligible +for scheduling by the Xen hypervisor. It is in a shutdown state, but +not dying. + =item B I I Send a to the domain, each type of request is diff --git a/tools/xl/xl.h b/tools/xl/xl.h index 967d034cfe..45745f0dbb 100644 --- a/tools/xl/xl.h +++ b/tools/xl/xl.h @@ -129,6 +129,8 @@ int main_restore(int argc, char **argv); int main_migrate_receive(int argc, char **argv); int main_save(int argc, char **argv); int main_migrate(int argc, char **argv); +int main_suspend(int argc, char **argv); +int main_resume(int argc, char **argv); #endif int main_dump_core(int argc, char **argv); int main_pause(int argc, char **argv); diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c index 53fc22d344..06a0039718 100644 --- a/tools/xl/xl_cmdtable.c +++ b/tools/xl/xl_cmdtable.c @@ -193,6 +193,16 @@ const struct cmd_spec cmd_table[] = { "Restore a domain from a saved state", "- for internal use only", }, + { "suspend", + &main_suspend, 0, 1, + "Suspend a domain to RAM", + "", + }, + { "resume", + &main_resume, 0, 1, + "Resume a domain from RAM", + "", + }, #endif { "dump-core", &main_dump_core, 0, 1, diff --git a/tools/xl/xl_vmcontrol.c b/tools/xl/xl_vmcontrol.c index c45d497c28..3160966972 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(uint32_t domid) +{ + libxl_domain_suspend_only(ctx, domid, NULL); +} + +static void resume_domain(uint32_t domid) +{ + libxl_domain_resume(ctx, domid, 1, NULL); +} + 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_suspend(int argc, char **argv) +{ + int opt; + + SWITCH_FOREACH_OPT(opt, "", NULL, "suspend", 1) { + /* No options */ + } + + suspend_domain(find_domain(argv[optind])); + + return EXIT_SUCCESS; +} + +int main_resume(int argc, char **argv) +{ + int opt; + + SWITCH_FOREACH_OPT(opt, "", NULL, "resume", 1) { + /* No options */ + } + + resume_domain(find_domain(argv[optind])); + + return EXIT_SUCCESS; +} + int main_destroy(int argc, char **argv) { int opt;