From nobody Wed May 14 09:53:58 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1525789428168733.9329273693966; Tue, 8 May 2018 07:23:48 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C57D581239; Tue, 8 May 2018 14:23:46 +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 963B930B498F; Tue, 8 May 2018 14:23:46 +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 47CAC180BAE8; Tue, 8 May 2018 14:23:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w48ENhYk003950 for ; Tue, 8 May 2018 10:23:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id 30211608F4; Tue, 8 May 2018 14:23:43 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 67DB0611A7; Tue, 8 May 2018 14:23:39 +0000 (UTC) Received: from prv3-mh.provo.novell.com (prv3-mh.provo.novell.com [137.65.250.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9FA1B804EE; Tue, 8 May 2018 14:23:23 +0000 (UTC) Received: from localhost.localdomain (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by prv3-mh.provo.novell.com with ESMTP (NOT encrypted); Tue, 08 May 2018 08:23:14 -0600 From: Lin Ma To: libvir-list@redhat.com Date: Tue, 8 May 2018 22:20:40 +0800 Message-Id: <20180508142040.18593-13-lma@suse.com> In-Reply-To: <20180508142040.18593-1-lma@suse.com> References: <20180508142040.18593-1-lma@suse.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 08 May 2018 14:23:39 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 08 May 2018 14:23:39 +0000 (UTC) for IP:'137.65.250.26' DOMAIN:'prv3-mh.provo.novell.com' HELO:'prv3-mh.provo.novell.com' FROM:'lma@suse.com' RCPT:'' X-RedHat-Spam-Score: -2.301 (RCVD_IN_DNSWL_MED, SPF_PASS) 137.65.250.26 prv3-mh.provo.novell.com 137.65.250.26 prv3-mh.provo.novell.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, pkrempa@redhat.com Subject: [libvirt] [PATCH v2 12/12] virsh: Add event name completion to 'event' command 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 08 May 2018 14:23:47 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Lin Ma --- tools/virsh-completer.c | 37 +++++++++++++++++++++++++++++++++++++ tools/virsh-completer.h | 3 +++ tools/virsh-domain.c | 1 + 3 files changed, 41 insertions(+) diff --git a/tools/virsh-completer.c b/tools/virsh-completer.c index e3b8234b41..ddf7b17caf 100644 --- a/tools/virsh-completer.c +++ b/tools/virsh-completer.c @@ -522,3 +522,40 @@ virshSnapshotNameCompleter(vshControl *ctl, virshDomainFree(dom); return NULL; } + + +char ** +virshEventNameCompleter(vshControl *ctl, + const vshCmd *cmd ATTRIBUTE_UNUSED, + unsigned int flags) +{ + virshControlPtr priv =3D ctl->privData; + size_t i =3D 0; + char **ret =3D NULL; + + virCheckFlags(0, NULL); + + if (!priv->conn || virConnectIsAlive(priv->conn) <=3D 0) + return NULL; + + if (VIR_ALLOC_N(ret, VIR_DOMAIN_EVENT_ID_LAST + 1) < 0) + goto error; + + for (i =3D 0; i < VIR_DOMAIN_EVENT_ID_LAST; i++) { + const char *name =3D virshDomainEventGetName(i); + + if (name =3D=3D NULL) + goto error; + + if (VIR_STRDUP(ret[i], name) < 0) + goto error; + } + + return ret; + + error: + for (i =3D 0; i < VIR_DOMAIN_EVENT_ID_LAST; i++) + VIR_FREE(ret[i]); + VIR_FREE(ret); + return NULL; +} diff --git a/tools/virsh-completer.h b/tools/virsh-completer.h index fa443d3ad7..27d78dc7ac 100644 --- a/tools/virsh-completer.h +++ b/tools/virsh-completer.h @@ -69,5 +69,8 @@ char ** virshSecretUUIDCompleter(vshControl *ctl, char ** virshSnapshotNameCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags); +char ** virshEventNameCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); =20 #endif diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 36278ebc1c..0d58c0ff1a 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -13357,6 +13357,7 @@ static const vshCmdOptDef opts_event[] =3D { }, {.name =3D "event", .type =3D VSH_OT_ARGV, + .completer =3D virshEventNameCompleter, .help =3D N_("which event type to wait for") }, {.name =3D NULL} --=20 2.15.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list