From nobody Wed May 14 01:47:00 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; dkim=fail; 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 1527057361615157.03577183506331; Tue, 22 May 2018 23:36:01 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id A02E33007B0E; Wed, 23 May 2018 06:35:59 +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 6137F4529; Wed, 23 May 2018 06:35:59 +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 E8E4B18033ED; Wed, 23 May 2018 06:35:58 +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 w4N6ZuPn017178 for ; Wed, 23 May 2018 02:35:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id AE6326090C; Wed, 23 May 2018 06:35:56 +0000 (UTC) Received: from mx1.redhat.com (ext-mx19.extmail.prod.ext.phx2.redhat.com [10.5.110.48]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5C4ED608F3; Wed, 23 May 2018 06:35:47 +0000 (UTC) Received: from mail-pf0-f195.google.com (mail-pf0-f195.google.com [209.85.192.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E31433078ACC; Wed, 23 May 2018 06:35:36 +0000 (UTC) Received: by mail-pf0-f195.google.com with SMTP id o76-v6so9974219pfi.5; Tue, 22 May 2018 23:35:36 -0700 (PDT) Received: from localhost.localdomain ([45.122.156.254]) by smtp.gmail.com with ESMTPSA id g64-v6sm34500852pfd.50.2018.05.22.23.35.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 May 2018 23:35:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=g2sTc8HFnWKj1YoRNTzyks3HUp5oidpR3XHcRwjY4Lo=; b=QaTItU7oSS3ScU7MHB93T/fXqdYPFcohm6bo1AakpQHvKZ6J3ZQLOpPasar4YIYOAG rB8dd6XxNheJJGTasEvnQq8jjvCXqajDhYYHRd3S+EiH/zQV2F5YI0UlDPxJkyrkKNHo DMZOqvUCqjbUm4mx9675Luy5Zhqa4srl22QrF6gg5FmjL/7YSumD1GN/N2Sr+VEhqg/Y C6oNb5JHugdCYHzEsq84+DAfNl4lG9FB32d/uBgxNSIcIQRU66mUIW1m3ok2LGAwO+B5 ROHVk3ZNByPMsMjoq8/vILp6AonSgTVWuULe5/AM3QtxkjrxZ0BwKiO64v/7kbmyg3fR T6gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=g2sTc8HFnWKj1YoRNTzyks3HUp5oidpR3XHcRwjY4Lo=; b=lr1YbgYoXQgVEFkJcXSDjEnmIEt3L2oLe1jJF8Cj7PnSSzmXNSRO6Y5qCnd8OsG8+L s8GUXZ+qRxXI8hrCV1F7hA3n+4Q1ZquhO892xVHZqBPEuolRYif+W7W4CYsIPr42a/qn hLlGVAf6ERlvDjaKLGaicCBQc26qc5WNtCO25aTXfDQtQPf0l34P3SsuoFfz31qKHaix 6TIOIVpZVDlbBjQraeIrW06CnAJYvRXWRsqVqMiUsjgd456H2VVPxQp1KqQWfl4miM/0 /UoB6aDLwyrJyK9wmGWdCa2ndx+io0+OXGQoVcYbhCh+tTTLMeqBrrDyA0reYctGQqv7 7Q4g== X-Gm-Message-State: ALKqPwdttjJHYRduiVxdxCqxWZh4x2OiTvqJ9JB+M0nz3ZKfuYkQ9OBg 1X+uJ3e9TQuBmRIsuLROaexSjQ== X-Google-Smtp-Source: AB8JxZppXKVn9FzoUe6Lxx5ftZwJp3UG5Yjlef/MImOfUJew4XoaQC2IyFApg17o5VLop4QPwNy2UA== X-Received: by 2002:a62:d38f:: with SMTP id z15-v6mr1625138pfk.100.1527057336148; Tue, 22 May 2018 23:35:36 -0700 (PDT) From: Lin Ma To: libvir-list@redhat.com Date: Wed, 23 May 2018 14:32:42 +0800 Message-Id: <20180523063246.3742-5-lma@suse.com> In-Reply-To: <20180523063246.3742-1-lma@suse.com> References: <20180523063246.3742-1-lma@suse.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Wed, 23 May 2018 06:35:37 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Wed, 23 May 2018 06:35:37 +0000 (UTC) for IP:'209.85.192.195' DOMAIN:'mail-pf0-f195.google.com' HELO:'mail-pf0-f195.google.com' FROM:'morecache@gmail.com' RCPT:'' X-RedHat-Spam-Score: -1.199 (DKIM_SIGNED, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS, T_DKIM_INVALID) 209.85.192.195 mail-pf0-f195.google.com 209.85.192.195 mail-pf0-f195.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.48 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: mprivozn@redhat.com, Lin Ma Subject: [libvirt] [ [PATCH v3 4/8] 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.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Wed, 23 May 2018 06:36:00 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Lin Ma --- tools/virsh-completer.c | 31 +++++++++++++++++++++++++++++++ tools/virsh-completer.h | 3 +++ tools/virsh-domain.c | 1 + 3 files changed, 35 insertions(+) diff --git a/tools/virsh-completer.c b/tools/virsh-completer.c index b402fd22c3..c0c3c5571a 100644 --- a/tools/virsh-completer.c +++ b/tools/virsh-completer.c @@ -23,6 +23,7 @@ #include =20 #include "virsh-completer.h" +#include "virsh-domain.h" #include "virsh.h" #include "virsh-pool.h" #include "virsh-util.h" @@ -676,3 +677,33 @@ virshSecretEventNameCompleter(vshControl *ctl ATTRIBUT= E_UNUSED, virStringListFree(ret); 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++) { + if (VIR_STRDUP(ret[i], vshEventCallbacks[i].name) < 0) + goto error; + } + + return ret; + + error: + virStringListFree(ret); + return NULL; +} diff --git a/tools/virsh-completer.h b/tools/virsh-completer.h index c662267882..9f8dc3dfa8 100644 --- a/tools/virsh-completer.h +++ b/tools/virsh-completer.h @@ -73,6 +73,9 @@ 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 char ** virshAllocpagesPagesizeCompleter(vshControl *ctl, const vshCmd *cmd, diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 347c744bc9..4af7aa2155 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -13339,6 +13339,7 @@ static const vshCmdOptDef opts_event[] =3D { 0), {.name =3D "event", .type =3D VSH_OT_STRING, + .completer =3D virshEventNameCompleter, .help =3D N_("which event type to wait for") }, {.name =3D "all", --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list