From nobody Mon May 13 19:08:49 2024 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1708421606428396.6765459728158; Tue, 20 Feb 2024 01:33:26 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 2873D1BF8; Tue, 20 Feb 2024 04:33:25 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id B855E17E3; Tue, 20 Feb 2024 04:32:06 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 70F5B17EF; Tue, 20 Feb 2024 04:32:02 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 3AB9617E2 for ; Tue, 20 Feb 2024 04:32:01 -0500 (EST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-169-3io4iah9PPy46oYoMKH5OA-1; Tue, 20 Feb 2024 04:31:59 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 80DC5811E79 for ; Tue, 20 Feb 2024 09:31:59 +0000 (UTC) Received: from ajulis-thinkpadt14gen4.remote.csb (unknown [10.43.3.76]) by smtp.corp.redhat.com (Postfix) with ESMTP id 299022166AE9 for ; Tue, 20 Feb 2024 09:31:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: 3io4iah9PPy46oYoMKH5OA-1 From: Adam Julis To: devel@lists.libvirt.org Subject: [PATCH v2] virsh-completer: modify and fix bug in virshPoolTypeCompleter, now used for more commands Date: Tue, 20 Feb 2024 10:31:34 +0100 Message-ID: <772a8ed5fa43ac6f5e70a38d169484584dee194e.1708420799.git.ajulis@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: QKDAGFM6GE5XASTK65FTVUSP4H26ZHLY X-Message-ID-Hash: QKDAGFM6GE5XASTK65FTVUSP4H26ZHLY X-MailFrom: ajulis@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1708421607739100001 Signed-off-by: Adam Julis Reviewed-by: Michal Privoznik --- v2: - instead new completer is used already existing virshPoolTypeCompleter - added flag VIRSH_POOL_TYPE_COMPLETER_COMMA for the completer - fixed bug in pool-list --type command v1: https://lists.libvirt.org/archives/list/devel@lists.libvirt.org/message/K6G= T4P5S52DSRYMVQD3HLGIN33N4XPJR/ tools/virsh-completer-domain.h | 4 ++++ tools/virsh-completer-pool.c | 14 +++++++++----- tools/virsh-pool.c | 3 +++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/tools/virsh-completer-domain.h b/tools/virsh-completer-domain.h index 27cf963912..fe4af07937 100644 --- a/tools/virsh-completer-domain.h +++ b/tools/virsh-completer-domain.h @@ -31,6 +31,10 @@ enum { VIRSH_DOMAIN_INTERFACE_COMPLETER_MAC =3D 1 << 0, /* Return just MACs */ }; =20 +enum { + VIRSH_POOL_TYPE_COMPLETER_COMMA =3D 1 << 0, +}; + char ** virshDomainInterfaceCompleter(vshControl *ctl, const vshCmd *cmd, diff --git a/tools/virsh-completer-pool.c b/tools/virsh-completer-pool.c index 0600394411..abad0fca1b 100644 --- a/tools/virsh-completer-pool.c +++ b/tools/virsh-completer-pool.c @@ -93,13 +93,17 @@ virshPoolTypeCompleter(vshControl *ctl, g_auto(GStrv) tmp =3D NULL; const char *type_str =3D NULL; =20 - virCheckFlags(0, NULL); - - if (vshCommandOptStringQuiet(ctl, cmd, "type", &type_str) < 0) - return NULL; + virCheckFlags(VIRSH_POOL_TYPE_COMPLETER_COMMA, NULL); =20 tmp =3D virshEnumComplete(VIR_STORAGE_POOL_LAST, virStoragePoolTypeToString); =20 - return virshCommaStringListComplete(type_str, (const char **)tmp); + if (flags & VIRSH_POOL_TYPE_COMPLETER_COMMA){ + if (vshCommandOptStringQuiet(ctl, cmd, "type", &type_str) < 0) + return NULL; + + return virshCommaStringListComplete(type_str, (const char **)tmp); + } + + return g_steal_pointer(&tmp); } diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index 36f00cf643..6936406087 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -1088,6 +1088,7 @@ static const vshCmdOptDef opts_pool_list[] =3D { }, {.name =3D "type", .type =3D VSH_OT_STRING, + .completer_flags =3D VIRSH_POOL_TYPE_COMPLETER_COMMA, .completer =3D virshPoolTypeCompleter, .help =3D N_("only list pool of specified type(s) (if supported)") }, @@ -1414,6 +1415,7 @@ static const vshCmdOptDef opts_find_storage_pool_sour= ces_as[] =3D { {.name =3D "type", .type =3D VSH_OT_DATA, .flags =3D VSH_OFLAG_REQ, + .completer =3D virshPoolTypeCompleter, .help =3D N_("type of storage pool sources to find") }, {.name =3D "host", @@ -1501,6 +1503,7 @@ static const vshCmdOptDef opts_find_storage_pool_sour= ces[] =3D { {.name =3D "type", .type =3D VSH_OT_DATA, .flags =3D VSH_OFLAG_REQ, + .completer =3D virshPoolTypeCompleter, .help =3D N_("type of storage pool sources to discover") }, {.name =3D "srcSpec", --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org