From nobody Wed May 14 01:49:06 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 1527057383493696.2495791285793; Tue, 22 May 2018 23:36:23 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BEB1630B397E; Wed, 23 May 2018 06:36:21 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 567DB5D752; Wed, 23 May 2018 06:36:21 +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 E326D4CA83; Wed, 23 May 2018 06:36:20 +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 w4N6aHCd017427 for ; Wed, 23 May 2018 02:36:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id DE05E60851; Wed, 23 May 2018 06:36:17 +0000 (UTC) Received: from mx1.redhat.com (ext-mx20.extmail.prod.ext.phx2.redhat.com [10.5.110.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 143EB6090D; Wed, 23 May 2018 06:36:10 +0000 (UTC) Received: from mail-pg0-f68.google.com (mail-pg0-f68.google.com [74.125.83.68]) (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 F232A30B9DFA; Wed, 23 May 2018 06:35:54 +0000 (UTC) Received: by mail-pg0-f68.google.com with SMTP id e1-v6so8952066pga.6; Tue, 22 May 2018 23:35:54 -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.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 22 May 2018 23:35:53 -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=pjzCkx+pVhDdqAxaOkHaJqcXdPHxufpsz93JFLQI4ak=; b=WkQQ55y1sgEH/TTH9lXL1g0DHdsjKhPbSlui/mcC8P4l7NghalSL5yV7dNcSHg0cJj urNxaIwTTNS3q9HMiwJKlUvKSG9GMNAbzpv1j+nE8u5+zC240Hr0i2DP4z7MfQyUgKtV 80NP7F7/mi24dFxDS9eAHirPMsYgD+ILFhudBuYz2OGdyPmoqwg5r1vRKU8RruiTDXWs BPH4Q5civG0Scu2b9KlAXJDeAWXGDTxAmrpjXGu52DI8G9qXZJ3cE5+f2rPQ9Lf73vld ljxGJ5L6lBBt/VKdLI26vpIx3gIJAukpSzAAzuGv0mtl6LBnbcmLC2skhNjcCGK1bOtQ okIw== 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=pjzCkx+pVhDdqAxaOkHaJqcXdPHxufpsz93JFLQI4ak=; b=l6bK2grOlrfYneLyjLcaiX1uGezTe/X7Osu+FkeIFazDWt/8mFoBNd5/JGS+bcnGDi QFwcT4OWoDxeP5YFbJSFVbaY42fbqU1DoWIcZmV+u2YG7zHk6zJbsLO6YaO41VStLkVl 06IPzm5yp1B+QOA+ixWA/ZmVS39NihA/jDr1Q9m0kOOq2azTHT83riYKOWlq9LRe9jpw tkUh0wTW6+9qS9N0bj4sa5NqY7rVFuHebAcmfJXwoa2jJ6QroDWW0E/8Y5y7QI/9N4+N E60ng6/lSPKA7IrCUOchGGnI7OIM1f6yA3eEg/hFPa5cukdQRW2bjBjU0Qa+07sOHmY4 mPKQ== X-Gm-Message-State: ALKqPwejmQT9fWxVjRDpPQ1qGT3J8deS4gahO3Vh/5brBBW/I9ofPQzk LtOzKywEWwEjxfUUBT5W53xRpA== X-Google-Smtp-Source: AB8JxZp/pd7Sov/ATFWOScYbyfNzfw3UOiPpRqZ9RsGX/MYgyrndgAMfpNManAqnrFeUEzhzFNyIhg== X-Received: by 2002:a63:81c7:: with SMTP id t190-v6mr1281224pgd.378.1527057354169; Tue, 22 May 2018 23:35:54 -0700 (PDT) From: Lin Ma To: libvir-list@redhat.com Date: Wed, 23 May 2018 14:32:46 +0800 Message-Id: <20180523063246.3742-9-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.49]); Wed, 23 May 2018 06:35:55 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Wed, 23 May 2018 06:35:55 +0000 (UTC) for IP:'74.125.83.68' DOMAIN:'mail-pg0-f68.google.com' HELO:'mail-pg0-f68.google.com' FROM:'morecache@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.58 (DKIM_SIGNED, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS, T_DKIM_INVALID) 74.125.83.68 mail-pg0-f68.google.com 74.125.83.68 mail-pg0-f68.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.49 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 8/8] virsh: Add event name completion to 'nodedev-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.79 on 10.5.11.14 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:36:22 +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 | 4 ++++ tools/virsh-nodedev.c | 1 + 3 files changed, 36 insertions(+) diff --git a/tools/virsh-completer.c b/tools/virsh-completer.c index 1fab758e12..162b7a0e1c 100644 --- a/tools/virsh-completer.c +++ b/tools/virsh-completer.c @@ -26,6 +26,7 @@ #include "virsh-domain.h" #include "virsh.h" #include "virsh-pool.h" +#include "virsh-nodedev.h" #include "virsh-util.h" #include "virsh-secret.h" #include "internal.h" @@ -737,3 +738,33 @@ virshPoolEventNameCompleter(vshControl *ctl, virStringListFree(ret); return NULL; } + + +char ** +virshNodedevEventNameCompleter(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_NODE_DEVICE_EVENT_ID_LAST) < 0) + goto error; + + for (i =3D 0; i < VIR_NODE_DEVICE_EVENT_ID_LAST; i++) { + if (VIR_STRDUP(ret[i], vshNodedevEventCallbacks[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 76fa31cb47..1190130ec0 100644 --- a/tools/virsh-completer.h +++ b/tools/virsh-completer.h @@ -89,4 +89,8 @@ char ** virshPoolEventNameCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags); =20 +char ** virshNodedevEventNameCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); + #endif diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c index 66cf46c22f..f6bdeadd62 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -870,6 +870,7 @@ static const vshCmdOptDef opts_node_device_event[] =3D { }, {.name =3D "event", .type =3D VSH_OT_STRING, + .completer =3D virshNodedevEventNameCompleter, .help =3D N_("which event type to wait for") }, {.name =3D "loop", --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list