From nobody Sun Feb 8 21:48:38 2026 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1565166730; cv=none; d=zoho.com; s=zohoarc; b=Qb44WHYfjnKuNI13WiRa98rWfUJTGrB00Ju4+nPY+ewebcELYc7Gv0MaA2Qm18aFUybvPr/l69g4I6CrwiGRNe++ZyRa7BtouVGPWQJA4zoQmwrlGA7ApMgbIOk9TvetrfjlZhyVLZTgHSgkcmyXalxzvnt19iMvCIuaYEeY9QY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1565166730; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=e2wHtygYwjqroJ1PbR0ezaMvy69Rtu8+aU65L0v6b6o=; b=d9UQp2Wt6x4f8kiHe1u5FpwTHUl5clnB+7tie6M1//901Vf+PXOITF+UzyThq86oCAdaPtDpDqpDh2NKMy9Es6M5kVRqygintESrbannQilheUtCm/HyjVV+9WfylHpL9mnyVXS4G1kyDqpEF1dNgZa//W4peTMEdOc/3bd49X8= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1565166730091322.7826040829051; Wed, 7 Aug 2019 01:32:10 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F2CA030BCBBB; Wed, 7 Aug 2019 08:32:08 +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 B6D5C1001B02; Wed, 7 Aug 2019 08:32: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 57A711802216; Wed, 7 Aug 2019 08:32:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x778Vf2K025481 for ; Wed, 7 Aug 2019 04:31:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id 411DD100194E; Wed, 7 Aug 2019 08:31:41 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id BE4751001284 for ; Wed, 7 Aug 2019 08:31:32 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Wed, 7 Aug 2019 10:30:58 +0200 Message-Id: <4290771ae02eba30708bf09303a05d2220279f5d.1565166420.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 15/15] virsh: Introduce virshPoolTypeCompleter 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: , 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.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Wed, 07 Aug 2019 08:32:09 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This completer can be used to complete pool types. Signed-off-by: Michal Privoznik --- tools/virsh-completer-pool.c | 27 +++++++++++++++++++++++++++ tools/virsh-completer-pool.h | 4 ++++ tools/virsh-pool.c | 1 + 3 files changed, 32 insertions(+) diff --git a/tools/virsh-completer-pool.c b/tools/virsh-completer-pool.c index fc01550908..9703589522 100644 --- a/tools/virsh-completer-pool.c +++ b/tools/virsh-completer-pool.c @@ -21,6 +21,7 @@ #include =20 #include "virsh-completer-pool.h" +#include "conf/storage_conf.h" #include "viralloc.h" #include "virsh-pool.h" #include "virsh.h" @@ -91,3 +92,29 @@ virshPoolEventNameCompleter(vshControl *ctl ATTRIBUTE_UN= USED, VIR_STEAL_PTR(ret, tmp); return ret; } + + +char ** +virshPoolTypeCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags) +{ + VIR_AUTOSTRINGLIST tmp =3D NULL; + const char *type_str =3D NULL; + size_t i =3D 0; + + virCheckFlags(0, NULL); + + if (vshCommandOptStringQuiet(ctl, cmd, "type", &type_str) < 0) + return NULL; + + if (VIR_ALLOC_N(tmp, VIR_STORAGE_POOL_LAST + 1) < 0) + return NULL; + + for (i =3D 0; i < VIR_STORAGE_POOL_LAST; i++) { + if (VIR_STRDUP(tmp[i], virStoragePoolTypeToString(i)) < 0) + return NULL; + } + + return virshCommaStringListComplete(type_str, (const char **)tmp); +} diff --git a/tools/virsh-completer-pool.h b/tools/virsh-completer-pool.h index 778ab25df2..510233fb65 100644 --- a/tools/virsh-completer-pool.h +++ b/tools/virsh-completer-pool.h @@ -29,3 +29,7 @@ char ** virshStoragePoolNameCompleter(vshControl *ctl, char ** virshPoolEventNameCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags); + +char ** virshPoolTypeCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index 510d41b508..96ef626346 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -1095,6 +1095,7 @@ static const vshCmdOptDef opts_pool_list[] =3D { }, {.name =3D "type", .type =3D VSH_OT_STRING, + .completer =3D virshPoolTypeCompleter, .help =3D N_("only list pool of specified type(s) (if supported)") }, {.name =3D "details", --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list