From nobody Mon Feb 9 15:26:35 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=quarantine dis=quarantine) header.from=suse.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1623717559061729.4972710191613; Mon, 14 Jun 2021 17:39:19 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-541-YJcW_EBtNuWKOggKKlWJ7A-1; Mon, 14 Jun 2021 20:39:16 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E981B803620; Tue, 15 Jun 2021 00:39:09 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A289A19C66; Tue, 15 Jun 2021 00:39:08 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id CE2371809C80; Tue, 15 Jun 2021 00:39:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 15F0d30i001808 for ; Mon, 14 Jun 2021 20:39:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 329EC63ABA; Tue, 15 Jun 2021 00:39:03 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2CCED63AB9 for ; Tue, 15 Jun 2021 00:39:00 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9639A101A55F for ; Tue, 15 Jun 2021 00:39:00 +0000 (UTC) Received: from de-smtp-delivery-102.mimecast.com (de-smtp-delivery-102.mimecast.com [194.104.109.102]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-174-aX46KpzPMYeC3sJKjKlYhQ-1; Mon, 14 Jun 2021 20:38:58 -0400 Received: from EUR03-VE1-obe.outbound.protection.outlook.com (mail-ve1eur03lp2058.outbound.protection.outlook.com [104.47.9.58]) (Using TLS) by relay.mimecast.com with ESMTP id de-mta-7-kzKgZRpuM3aHFUXZVEI51A-1; Tue, 15 Jun 2021 02:38:56 +0200 Received: from AM9PR04MB8602.eurprd04.prod.outlook.com (2603:10a6:20b:439::12) by AM9PR04MB9013.eurprd04.prod.outlook.com (2603:10a6:20b:409::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.24; Tue, 15 Jun 2021 00:38:55 +0000 Received: from AM9PR04MB8602.eurprd04.prod.outlook.com ([fe80::cd4e:6cc0:8021:f249]) by AM9PR04MB8602.eurprd04.prod.outlook.com ([fe80::cd4e:6cc0:8021:f249%4]) with mapi id 15.20.4219.025; Tue, 15 Jun 2021 00:38:55 +0000 Received: from localhost (139.212.198.59) by HKAPR03CA0013.apcprd03.prod.outlook.com (2603:1096:203:c8::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4242.9 via Frontend Transport; Tue, 15 Jun 2021 00:38:54 +0000 X-MC-Unique: YJcW_EBtNuWKOggKKlWJ7A-1 X-MC-Unique: aX46KpzPMYeC3sJKjKlYhQ-1 X-MC-Unique: kzKgZRpuM3aHFUXZVEI51A-1 From: Lin Ma To: libvir-list@redhat.com Subject: [libvirt] [PATCH 02/12] virsh: Use VIR_ENUM_* for --target argument in cmdNodeSuspend Date: Tue, 15 Jun 2021 08:38:22 +0800 Message-ID: <20210615003832.5571-3-lma@suse.com> In-Reply-To: <20210615003832.5571-1-lma@suse.com> References: <20210615003832.5571-1-lma@suse.com> X-Originating-IP: [139.212.198.59] X-ClientProxiedBy: HKAPR03CA0013.apcprd03.prod.outlook.com (2603:1096:203:c8::18) To AM9PR04MB8602.eurprd04.prod.outlook.com (2603:10a6:20b:439::12) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a81fda63-bd3e-426a-55e0-08d92f95f487 X-MS-TrafficTypeDiagnostic: AM9PR04MB9013: X-LD-Processed: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba,ExtFwd X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2958 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: tDM/0WsM2FGZNelUPBll1mpgBCC6BVWFX8Fl4uyJoN6URXjkSNmtdknaGCX1T/2UFZX5HKBm4ZKpJ9LrNwuDUthSphOJTT7m1oMHx5ILLKIPEMBkyjBLXcXD6vckQtu44aLkOMAIBV+SS+vW2oYzM9q9+ICSznzy+XOb7H0KjFmCzISAFVa2SKAuryI82pc6/TNQdAvuWp5GaX+lv8bb+6Vwr1C0FLJcrXium9HpEl1F5N2omgy9p+tQY2TtUhXBiUGmjpkh8gvo/NSb06hd1nL4iJD/o3TAyc0SA3u4OQ+rj/vTONWbgHbZsF9L+BCGW5Sy5+TQqx7XjocsvmhaetbIUAxI3VfwVSd6D8veazBlsxYWYYV3J1QPfwbXN13Htl3N3md5y3X1/37X9pM+aTG2r1k/gqLXIN4EEBj67xF54rgwmykfRY3lGTBzVnkfNkVUu6Wg2mcfNBkhF2FDQ6Ok0H1N5iB8TLZ5fUN5EUUCDCrign/T6ERFUfCctqwQlMiF1iL3qei6FJ5Og0wiXEva82dO5rBQxCIMUCljzDixFPHFkl8gmH7RKS+FUdB90ArImzKaaeMGmWhjNyBxWrqTuRIPCLJf1PzS2c/l+rQ= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM9PR04MB8602.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(39860400002)(346002)(366004)(376002)(136003)(396003)(107886003)(186003)(16526019)(36756003)(6486002)(4326008)(478600001)(316002)(5660300002)(83380400001)(66946007)(66476007)(66556008)(6916009)(86362001)(38100700002)(8936002)(26005)(450100002)(956004)(1076003)(6496006)(2616005)(6666004)(8676002)(2906002); DIR:OUT; SFP:1101 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?dD4aFAYpSvlim/e7PlIhhgUT8G3gj3MmNINuIjrJ5wso6IGiuyjJUWORw9yg?= =?us-ascii?Q?ajTOBWtGbhvM07/hii5J7zsR9e9+I0hbpBKySlgV+JPEX9YdeaGKdr36EsqP?= =?us-ascii?Q?x/oVrDO6+qyvlX0tVsf5JSrkD/glYE8DGhA+PBn4E3Xv/kFphP2q1VmIRAk4?= =?us-ascii?Q?6EWhfbkx3hH+nfubGvv18QTdEbtJcJFziIVZuFOBmUyo4PaD4tq8lLcrVNYe?= =?us-ascii?Q?kkcWmzHjrKUa9y23S4JViMFnhZmtlkaJZClXKh0RqkRqw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XJ3W7A10T4Q4OhZOnXjZ0exZ7WwN735mB+xYSBKPPykjnJM/7jN?= =?us-ascii?Q?zfUaTHKHSqRy2Ro5avxXGKTV78UcwPdVkmAxVf98jI0/zVOrU5OQAKHMCnIh?= =?us-ascii?Q?dgBICL6fwsrMrIdgrBLZSUq3CsHRHV3QIs24hBfOwtGdhtzGysDGfiwz0sHz?= =?us-ascii?Q?+lPlcAJV74DObkuFD6R8nDr9?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: a81fda63-bd3e-426a-55e0-08d92f95f487 X-MS-Exchange-CrossTenant-AuthSource: AM9PR04MB8602.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jun 2021 00:38:55.2093 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: nP2ZiYLStDylU5AvykH4Fo40ijsLYLSCM9SXyA2z0eutZU1Qe/+yiWJGnGrkBwx4 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB9013 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id 15F0d30i001808 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, Lin Ma X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Signed-off-by: Lin Ma --- tools/virsh-host.c | 17 +++++++++-------- tools/virsh-host.h | 3 +++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/tools/virsh-host.c b/tools/virsh-host.c index 1eca0bc231..9d6d2b3645 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -950,6 +950,13 @@ cmdNodeMemStats(vshControl *ctl, const vshCmd *cmd) /* * "nodesuspend" command */ + +VIR_ENUM_IMPL(virNodeSuspendTarget, + VIR_NODE_SUSPEND_TARGET_LAST, + "mem", + "disk", + "hybrid"); + static const vshCmdInfo info_nodesuspend[] =3D { {.name =3D "help", .data =3D N_("suspend the host node for a given time duration") @@ -980,7 +987,7 @@ static bool cmdNodeSuspend(vshControl *ctl, const vshCmd *cmd) { const char *target =3D NULL; - unsigned int suspendTarget; + int suspendTarget; long long duration; virshControl *priv =3D ctl->privData; =20 @@ -990,13 +997,7 @@ cmdNodeSuspend(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptLongLong(ctl, cmd, "duration", &duration) < 0) return false; =20 - if (STREQ(target, "mem")) { - suspendTarget =3D VIR_NODE_SUSPEND_TARGET_MEM; - } else if (STREQ(target, "disk")) { - suspendTarget =3D VIR_NODE_SUSPEND_TARGET_DISK; - } else if (STREQ(target, "hybrid")) { - suspendTarget =3D VIR_NODE_SUSPEND_TARGET_HYBRID; - } else { + if ((suspendTarget =3D virNodeSuspendTargetTypeFromString(target)) < 0= ) { vshError(ctl, "%s", _("Invalid target")); return false; } diff --git a/tools/virsh-host.h b/tools/virsh-host.h index 92328c7deb..840f0b4538 100644 --- a/tools/virsh-host.h +++ b/tools/virsh-host.h @@ -21,5 +21,8 @@ #pragma once =20 #include "vsh.h" +#include "virenum.h" =20 extern const vshCmdDef hostAndHypervisorCmds[]; + +VIR_ENUM_DECL(virNodeSuspendTarget); --=20 2.26.2