From nobody Tue Sep 9 03:20:57 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1747750364; cv=none; d=zohomail.com; s=zohoarc; b=D9us/fFRESBqZoM6kctJSzS1S0ESh4rX4Xxga+woFKr7Dv/0M3IC5maeE6YzZJ+XXalCKFfuLdXXF2r7OOEoO6R0ScRzQU4fut3mSa51AK8T4rNGq9PXOKX1AcLWEbckJKPFSfx0E+8nsfGbFZbJDRWjjR+ZN3ml6tk4tcopU84= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747750364; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=lCj/jxAmVtr6rxomgx7XJC970jG4NoFF6d9/qnLhLgw=; b=YlrVljZuGy4uh6knE4+P10d4HoC9w1kTlPLQY+w2VWe5mpADThJ1fKLpGjLwGO1ADUF92o+mmljgrS129SPSsXCocu8DaWUp2x1/QtQzyDhB3xGRtPo12ppKHFiOU8Ro2IBga4wwk4pcfxVK9Zala3CeUzXqjJB6XDcc9R/g83s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1747750364118754.9776705817526; Tue, 20 May 2025 07:12:44 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id D9DFB18A5; Tue, 20 May 2025 10:12:42 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 5272A189D; Tue, 20 May 2025 10:10:18 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 158DD12AD; Tue, 20 May 2025 10:10:12 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 BF06A12C7 for ; Tue, 20 May 2025 10:10:09 -0400 (EDT) Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-364-lOBjjaGGNP-9kUlSlNwO-w-1; Tue, 20 May 2025 10:10:07 -0400 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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 mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9676C1809662 for ; Tue, 20 May 2025 14:08:57 +0000 (UTC) Received: from speedmetal.lan (unknown [10.44.22.37]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 84F82195608F for ; Tue, 20 May 2025 14:08:56 +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=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1747750209; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iXWPcOXgEr36vtn0nqyzml+QdiV5E4QF0iHqbIPDcFs=; b=TOOEKwlfd3g9mD+A5xashnMHq5z5KeeRvfew48RUmeMqjc0syuz6DZ09PhaX3BbVvoGYyt eHkQ0XtpoRUgdUqb0NGOXCIYKKwXeFX4zBkF6uSQQOnXNvOx1GMaX5fGKH3OL4de9MmypA pHg2w+LC8MsKlX3LyimAb9BRXXiEo08= X-MC-Unique: lOBjjaGGNP-9kUlSlNwO-w-1 X-Mimecast-MFC-AGG-ID: lOBjjaGGNP-9kUlSlNwO-w_1747750207 To: devel@lists.libvirt.org Subject: [PATCH 1/4] virsh: completer: Extract common completer methods from virsh to vsh Date: Tue, 20 May 2025 16:08:50 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: AslWvaGhslwutZAzud4DFnTKWPj2PPeqMaAWhqev8R0_1747750207 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: O6EZVFJKVSEOSVJVV4S3CC5LNI55IXQE X-Message-ID-Hash: O6EZVFJKVSEOSVJVV4S3CC5LNI55IXQE X-MailFrom: pkrempa@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: From: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1747750365574116600 Content-Type: text/plain; charset="utf-8" From: Peter Krempa The helper methods as well as the empty completers can be useful also in other virt shells; extract the code and rename the functions appropriately. Signed-off-by: Peter Krempa --- tools/meson.build | 2 +- tools/virsh-backup.c | 6 +- tools/virsh-checkpoint.c | 8 +- tools/virsh-completer-domain.c | 70 ++++++------- tools/virsh-completer-host.c | 12 +-- tools/virsh-completer-nodedev.c | 10 +- tools/virsh-completer-pool.c | 6 +- tools/virsh-completer-volume.c | 4 +- tools/virsh-completer.h | 19 +--- tools/virsh-domain.c | 100 +++++++++---------- tools/virsh-host.c | 6 +- tools/virsh-interface.c | 2 +- tools/virsh-network.c | 8 +- tools/virsh-nodedev.c | 2 +- tools/virsh-nwfilter.c | 4 +- tools/virsh-pool.c | 18 ++-- tools/virsh-secret.c | 6 +- tools/virsh-snapshot.c | 8 +- tools/virsh-volume.c | 12 +-- tools/virsh.c | 2 +- tools/virsh.h | 2 +- tools/{virsh-completer.c =3D> vsh-completer.c} | 34 +++---- tools/vsh-completer.h | 41 ++++++++ 23 files changed, 203 insertions(+), 179 deletions(-) rename tools/{virsh-completer.c =3D> vsh-completer.c} (85%) create mode 100644 tools/vsh-completer.h diff --git a/tools/meson.build b/tools/meson.build index 4d5c9e4bba..a099148d3c 100644 --- a/tools/meson.build +++ b/tools/meson.build @@ -25,6 +25,7 @@ libvirt_shell_lib =3D static_library( [ 'vsh.c', 'vsh-table.c', + 'vsh-completer.c', ], dependencies: [ tools_dep, @@ -169,7 +170,6 @@ virsh_prog =3D executable( 'virsh.c', 'virsh-backup.c', 'virsh-checkpoint.c', - 'virsh-completer.c', 'virsh-completer-domain.c', 'virsh-completer-checkpoint.c', 'virsh-completer-host.c', diff --git a/tools/virsh-backup.c b/tools/virsh-backup.c index 27777eea74..39e62f9ba9 100644 --- a/tools/virsh-backup.c +++ b/tools/virsh-backup.c @@ -35,13 +35,13 @@ static const vshCmdOptDef opts_backup_begin[] =3D { {.name =3D "backupxml", .type =3D VSH_OT_STRING, .positional =3D true, - .completer =3D virshCompletePathLocalExisting, + .completer =3D vshCompletePathLocalExisting, .help =3D N_("domain backup XML"), }, {.name =3D "checkpointxml", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompletePathLocalExisting, + .completer =3D vshCompletePathLocalExisting, .help =3D N_("domain checkpoint XML"), }, {.name =3D "reuse-external", @@ -109,7 +109,7 @@ static const vshCmdOptDef opts_backup_dumpxml[] =3D { VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), {.name =3D "xpath", .type =3D VSH_OT_STRING, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("xpath expression to filter the XML document") }, {.name =3D "wrap", diff --git a/tools/virsh-checkpoint.c b/tools/virsh-checkpoint.c index a0ac0d7f71..1a168a1c38 100644 --- a/tools/virsh-checkpoint.c +++ b/tools/virsh-checkpoint.c @@ -82,7 +82,7 @@ static const vshCmdOptDef opts_checkpoint_create[] =3D { {.name =3D "xmlfile", .type =3D VSH_OT_STRING, .positional =3D true, - .completer =3D virshCompletePathLocalExisting, + .completer =3D vshCompletePathLocalExisting, .help =3D N_("domain checkpoint XML") }, {.name =3D "redefine", @@ -190,13 +190,13 @@ static const vshCmdOptDef opts_checkpoint_create_as[]= =3D { {.name =3D "name", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("name of checkpoint") }, {.name =3D "description", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("description of checkpoint") }, {.name =3D "print-xml", @@ -837,7 +837,7 @@ static const vshCmdOptDef opts_checkpoint_dumpxml[] =3D= { }, {.name =3D "xpath", .type =3D VSH_OT_STRING, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("xpath expression to filter the XML document") }, {.name =3D "wrap", diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c index 3a165bc4a5..912826c434 100644 --- a/tools/virsh-completer-domain.c +++ b/tools/virsh-completer-domain.c @@ -235,7 +235,7 @@ virshDomainDiskTargetListCompleter(vshControl *ctl, if (!targets) return NULL; - return virshCommaStringListComplete(curval, (const char **) targets); + return vshCommaStringListComplete(curval, (const char **) targets); } @@ -307,7 +307,7 @@ virshDomainThrottleGroupsCompleter(vshControl *ctl, if (!groups) return NULL; - return virshCommaStringListComplete(curval, (const char **) groups); + return vshCommaStringListComplete(curval, (const char **) groups); } @@ -529,7 +529,7 @@ virshDomainShutdownModeCompleter(vshControl *ctl, if (vshCommandOptStringQuiet(ctl, cmd, "mode", &mode) < 0) return NULL; - return virshCommaStringListComplete(mode, modes); + return vshCommaStringListComplete(mode, modes); } @@ -540,8 +540,8 @@ virshDomainInterfaceAddrSourceCompleter(vshControl *ctl= G_GNUC_UNUSED, { virCheckFlags(0, NULL); - return virshEnumComplete(VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LAST, - virshDomainInterfaceAddressesSourceTypeToStri= ng); + return vshEnumComplete(VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_LAST, + virshDomainInterfaceAddressesSourceTypeToString= ); } @@ -552,8 +552,8 @@ virshDomainInterfaceSourceModeCompleter(vshControl *ctl= G_GNUC_UNUSED, { virCheckFlags(0, NULL); - return virshEnumComplete(VIRSH_DOMAIN_INTERFACE_SOURCE_MODE_LAST, - virshDomainInterfaceSourceModeTypeToString); + return vshEnumComplete(VIRSH_DOMAIN_INTERFACE_SOURCE_MODE_LAST, + virshDomainInterfaceSourceModeTypeToString); } @@ -564,8 +564,8 @@ virshDomainHostnameSourceCompleter(vshControl *ctl G_GN= UC_UNUSED, { virCheckFlags(0, NULL); - return virshEnumComplete(VIRSH_DOMAIN_HOSTNAME_SOURCE_LAST, - virshDomainHostnameSourceTypeToString); + return vshEnumComplete(VIRSH_DOMAIN_HOSTNAME_SOURCE_LAST, + virshDomainHostnameSourceTypeToString); } @@ -582,10 +582,10 @@ virshDomainPerfEnableCompleter(vshControl *ctl, if (vshCommandOptStringQuiet(ctl, cmd, "enable", &event) < 0) return NULL; - events =3D virshEnumComplete(VIR_PERF_EVENT_LAST, - virPerfEventTypeToString); + events =3D vshEnumComplete(VIR_PERF_EVENT_LAST, + virPerfEventTypeToString); - return virshCommaStringListComplete(event, (const char **)events); + return vshCommaStringListComplete(event, (const char **)events); } @@ -602,10 +602,10 @@ virshDomainPerfDisableCompleter(vshControl *ctl, if (vshCommandOptStringQuiet(ctl, cmd, "disable", &event) < 0) return NULL; - events =3D virshEnumComplete(VIR_PERF_EVENT_LAST, - virPerfEventTypeToString); + events =3D vshEnumComplete(VIR_PERF_EVENT_LAST, + virPerfEventTypeToString); - return virshCommaStringListComplete(event, (const char **)events); + return vshCommaStringListComplete(event, (const char **)events); } @@ -708,7 +708,7 @@ virshDomainVcpulistCompleter(vshControl *ctl, for (id =3D 0; id < nvcpus; id++) vcpulist[id] =3D g_strdup_printf("%u", id); - return virshCommaStringListComplete(vcpuid, (const char **)vcpulist); + return vshCommaStringListComplete(vcpuid, (const char **)vcpulist); } @@ -738,7 +738,7 @@ virshDomainCpulistCompleter(vshControl *ctl, for (i =3D 0; i < cpunum; i++) cpulist[i] =3D g_strdup_printf("%zu", i); - return virshCommaStringListComplete(cpuid, (const char **)cpulist); + return vshCommaStringListComplete(cpuid, (const char **)cpulist); } @@ -837,7 +837,7 @@ virshDomainVcpulistViaAgentCompleter(vshControl *ctl, } } - ret =3D virshCommaStringListComplete(vcpuid, (const char **)cpulist); + ret =3D vshCommaStringListComplete(vcpuid, (const char **)cpulist); cleanup: virTypedParamsFree(params, nparams); @@ -906,8 +906,8 @@ virshDomainSignalCompleter(vshControl *ctl G_GNUC_UNUSE= D, { virCheckFlags(0, NULL); - return virshEnumComplete(VIR_DOMAIN_PROCESS_SIGNAL_LAST, - virshDomainProcessSignalTypeToString); + return vshEnumComplete(VIR_DOMAIN_PROCESS_SIGNAL_LAST, + virshDomainProcessSignalTypeToString); } @@ -918,8 +918,8 @@ virshDomainLifecycleCompleter(vshControl *ctl G_GNUC_UN= USED, { virCheckFlags(0, NULL); - return virshEnumComplete(VIR_DOMAIN_LIFECYCLE_LAST, - virshDomainLifecycleTypeToString); + return vshEnumComplete(VIR_DOMAIN_LIFECYCLE_LAST, + virshDomainLifecycleTypeToString); } @@ -930,8 +930,8 @@ virshDomainLifecycleActionCompleter(vshControl *ctl G_G= NUC_UNUSED, { virCheckFlags(0, NULL); - return virshEnumComplete(VIR_DOMAIN_LIFECYCLE_ACTION_LAST, - virshDomainLifecycleActionTypeToString); + return vshEnumComplete(VIR_DOMAIN_LIFECYCLE_ACTION_LAST, + virshDomainLifecycleActionTypeToString); } @@ -942,8 +942,8 @@ virshCodesetNameCompleter(vshControl *ctl G_GNUC_UNUSED, { virCheckFlags(0, NULL); - return virshEnumComplete(VIR_KEYCODE_SET_LAST, - virKeycodeSetTypeToString); + return vshEnumComplete(VIR_KEYCODE_SET_LAST, + virKeycodeSetTypeToString); } @@ -1063,8 +1063,8 @@ virshDomainCoreDumpFormatCompleter(vshControl *ctl G_= GNUC_UNUSED, { virCheckFlags(0, NULL); - return virshEnumComplete(VIR_DOMAIN_CORE_DUMP_FORMAT_LAST, - virshDomainCoreDumpFormatTypeToString); + return vshEnumComplete(VIR_DOMAIN_CORE_DUMP_FORMAT_LAST, + virshDomainCoreDumpFormatTypeToString); } @@ -1081,7 +1081,7 @@ virshDomainMigrateCompMethodsCompleter(vshControl *ct= l, if (vshCommandOptStringQuiet(ctl, cmd, "comp-methods", &method) < 0) return NULL; - return virshCommaStringListComplete(method, methods); + return vshCommaStringListComplete(method, methods); } @@ -1092,8 +1092,8 @@ virshDomainStorageFileFormatCompleter(vshControl *ctl= G_GNUC_UNUSED, { virCheckFlags(0, NULL); - return virshEnumComplete(VIR_STORAGE_FILE_LAST, - virStorageFileFormatTypeToString); + return vshEnumComplete(VIR_STORAGE_FILE_LAST, + virStorageFileFormatTypeToString); } @@ -1104,8 +1104,8 @@ virshDomainNumatuneModeCompleter(vshControl *ctl G_GN= UC_UNUSED, { virCheckFlags(0, NULL); - return virshEnumComplete(VIR_DOMAIN_NUMATUNE_MEM_LAST, - virDomainNumatuneMemModeTypeToString); + return vshEnumComplete(VIR_DOMAIN_NUMATUNE_MEM_LAST, + virDomainNumatuneMemModeTypeToString); } @@ -1116,6 +1116,6 @@ virshDomainDirtyRateCalcModeCompleter(vshControl *ctl= G_GNUC_UNUSED, { virCheckFlags(0, NULL); - return virshEnumComplete(VIRSH_DOMAIN_DIRTYRATE_CALC_MODE_LAST, - virshDomainDirtyRateCalcModeTypeToString); + return vshEnumComplete(VIRSH_DOMAIN_DIRTYRATE_CALC_MODE_LAST, + virshDomainDirtyRateCalcModeTypeToString); } diff --git a/tools/virsh-completer-host.c b/tools/virsh-completer-host.c index 78d2236f97..c3919a6d91 100644 --- a/tools/virsh-completer-host.c +++ b/tools/virsh-completer-host.c @@ -178,8 +178,8 @@ virshNodeSuspendTargetCompleter(vshControl *ctl G_GNUC_= UNUSED, { virCheckFlags(0, NULL); - return virshEnumComplete(VIR_NODE_SUSPEND_TARGET_LAST, - virshNodeSuspendTargetTypeToString); + return vshEnumComplete(VIR_NODE_SUSPEND_TARGET_LAST, + virshNodeSuspendTargetTypeToString); } @@ -190,8 +190,8 @@ virshDomainVirtTypeCompleter(vshControl *ctl G_GNUC_UNU= SED, { virCheckFlags(0, NULL); - return virshEnumComplete(VIR_DOMAIN_VIRT_LAST, - virDomainVirtTypeToString); + return vshEnumComplete(VIR_DOMAIN_VIRT_LAST, + virDomainVirtTypeToString); } @@ -202,8 +202,8 @@ virshArchCompleter(vshControl *ctl G_GNUC_UNUSED, { virCheckFlags(0, NULL); - return virshEnumComplete(VIR_ARCH_LAST, - (const char *(*)(int))virArchToString); + return vshEnumComplete(VIR_ARCH_LAST, + (const char *(*)(int))virArchToString); } diff --git a/tools/virsh-completer-nodedev.c b/tools/virsh-completer-nodede= v.c index 72951a54f6..289f803904 100644 --- a/tools/virsh-completer-nodedev.c +++ b/tools/virsh-completer-nodedev.c @@ -96,10 +96,10 @@ virshNodeDeviceCapabilityNameCompleter(vshControl *ctl, if (vshCommandOptStringQuiet(ctl, cmd, "cap", &cap_str) < 0) return NULL; - tmp =3D virshEnumComplete(VIR_NODE_DEV_CAP_LAST, - virNodeDevCapTypeToString); + tmp =3D vshEnumComplete(VIR_NODE_DEV_CAP_LAST, + virNodeDevCapTypeToString); - return virshCommaStringListComplete(cap_str, (const char **)tmp); + return vshCommaStringListComplete(cap_str, (const char **)tmp); } @@ -110,6 +110,6 @@ virshNodeDevicePCIBackendCompleter(vshControl *ctl G_GN= UC_UNUSED, { virCheckFlags(0, NULL); - return virshEnumComplete(VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_LAST, - virDeviceHostdevPCIDriverNameTypeToString); + return vshEnumComplete(VIR_DEVICE_HOSTDEV_PCI_DRIVER_NAME_LAST, + virDeviceHostdevPCIDriverNameTypeToString); } diff --git a/tools/virsh-completer-pool.c b/tools/virsh-completer-pool.c index 3568bb985b..6701436c0f 100644 --- a/tools/virsh-completer-pool.c +++ b/tools/virsh-completer-pool.c @@ -95,8 +95,8 @@ virshPoolTypeCompleter(vshControl *ctl, virCheckFlags(VIRSH_POOL_TYPE_COMPLETER_COMMA, NULL); - tmp =3D virshEnumComplete(VIR_STORAGE_POOL_LAST, - virStoragePoolTypeToString); + tmp =3D vshEnumComplete(VIR_STORAGE_POOL_LAST, + virStoragePoolTypeToString); if (!(flags & VIRSH_POOL_TYPE_COMPLETER_COMMA)) return g_steal_pointer(&tmp); @@ -104,5 +104,5 @@ virshPoolTypeCompleter(vshControl *ctl, if (vshCommandOptStringQuiet(ctl, cmd, "type", &type_str) < 0) return NULL; - return virshCommaStringListComplete(type_str, (const char **)tmp); + return vshCommaStringListComplete(type_str, (const char **)tmp); } diff --git a/tools/virsh-completer-volume.c b/tools/virsh-completer-volume.c index 9a80112e59..5ad2e28318 100644 --- a/tools/virsh-completer-volume.c +++ b/tools/virsh-completer-volume.c @@ -123,6 +123,6 @@ virshStorageVolWipeAlgorithmCompleter(vshControl *ctl G= _GNUC_UNUSED, { virCheckFlags(0, NULL); - return virshEnumComplete(VIR_STORAGE_VOL_WIPE_ALG_LAST, - virshStorageVolWipeAlgorithmTypeToString); + return vshEnumComplete(VIR_STORAGE_VOL_WIPE_ALG_LAST, + virshStorageVolWipeAlgorithmTypeToString); } diff --git a/tools/virsh-completer.h b/tools/virsh-completer.h index 131678dfbc..2ddd5446cd 100644 --- a/tools/virsh-completer.h +++ b/tools/virsh-completer.h @@ -20,6 +20,7 @@ #pragma once +#include "vsh-completer.h" #include "virsh-completer-checkpoint.h" #include "virsh-completer-domain.h" #include "virsh-completer-host.h" @@ -31,21 +32,3 @@ #include "virsh-completer-secret.h" #include "virsh-completer-snapshot.h" #include "virsh-completer-volume.h" - -char ** -virshEnumComplete(unsigned int last, - const char *(*intToStr)(int)); - -char ** -virshCommaStringListComplete(const char *input, - const char **options); - -char ** -virshCompletePathLocalExisting(vshControl *ctl, - const vshCmd *cmd, - unsigned int completerflags); - -char ** -virshCompleteEmpty(vshControl *ctl, - const vshCmd *cmd, - unsigned int completerflags); diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index a5f87243a2..7e5e83126e 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -429,7 +429,7 @@ static const vshCmdOptDef opts_attach_disk[] =3D { .type =3D VSH_OT_STRING, .positional =3D true, .required =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("target of disk device") }, {.name =3D "targetbus", @@ -475,17 +475,17 @@ static const vshCmdOptDef opts_attach_disk[] =3D { }, {.name =3D "serial", .type =3D VSH_OT_STRING, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("serial of disk device") }, {.name =3D "wwn", .type =3D VSH_OT_STRING, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("wwn of disk device") }, {.name =3D "alias", .type =3D VSH_OT_STRING, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("custom alias name of disk device") }, {.name =3D "rawio", @@ -494,7 +494,7 @@ static const vshCmdOptDef opts_attach_disk[] =3D { }, {.name =3D "address", .type =3D VSH_OT_STRING, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("address of disk device") }, {.name =3D "multifunction", @@ -511,7 +511,7 @@ static const vshCmdOptDef opts_attach_disk[] =3D { }, {.name =3D "source-host-name", .type =3D VSH_OT_STRING, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("host name for source of disk device") }, {.name =3D "source-host-transport", @@ -847,13 +847,13 @@ static const vshCmdOptDef opts_attach_interface[] =3D= { {.name =3D "target", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("target network name") }, {.name =3D "mac", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("MAC address") }, {.name =3D "script", @@ -869,19 +869,19 @@ static const vshCmdOptDef opts_attach_interface[] =3D= { {.name =3D "alias", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("custom alias name of interface device") }, {.name =3D "inbound", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("control domain's incoming traffics") }, {.name =3D "outbound", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("control domain's outgoing traffics") }, VIRSH_COMMON_OPT_DOMAIN_PERSISTENT, @@ -1405,7 +1405,7 @@ static const vshCmdOptDef opts_blkdeviotune[] =3D { }, {.name =3D "group-name", .type =3D VSH_OT_STRING, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("group name to share I/O quota between multiple drives") }, VSH_OPTS_IOTUNE, @@ -1912,31 +1912,31 @@ static const vshCmdOptDef opts_blkiotune[] =3D { {.name =3D "device-weights", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("per-device IO Weights, in the form of /path/to/device,w= eight,...") }, {.name =3D "device-read-iops-sec", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("per-device read I/O limit per second, in the form of /p= ath/to/device,read_iops_sec,...") }, {.name =3D "device-write-iops-sec", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("per-device write I/O limit per second, in the form of /= path/to/device,write_iops_sec,...") }, {.name =3D "device-read-bytes-sec", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("per-device bytes read per second, in the form of /path/= to/device,read_bytes_sec,...") }, {.name =3D "device-write-bytes-sec", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("per-device bytes wrote per second, in the form of /path= /to/device,write_bytes_sec,...") }, VIRSH_COMMON_OPT_DOMAIN_CONFIG, @@ -2669,7 +2669,7 @@ static const vshCmdOptDef opts_blockcopy[] =3D { {.name =3D "xml", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompletePathLocalExisting, + .completer =3D vshCompletePathLocalExisting, .help =3D N_("filename containing XML description of the copy destina= tion") }, {.name =3D "format", @@ -3617,13 +3617,13 @@ static const vshCmdOptDef opts_domiftune[] =3D { {.name =3D "inbound", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("control domain's incoming traffics") }, {.name =3D "outbound", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("control domain's outgoing traffics") }, VIRSH_COMMON_OPT_DOMAIN_CONFIG, @@ -4386,7 +4386,7 @@ static const vshCmdOptDef opts_start[] =3D { {.name =3D "pass-fds", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("pass file descriptors N,M,... to the guest") }, {.name =3D "reset-nvram", @@ -4541,7 +4541,7 @@ static const vshCmdOptDef opts_save[] =3D { {.name =3D "xml", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompletePathLocalExisting, + .completer =3D vshCompletePathLocalExisting, .help =3D N_("filename containing updated XML for the target") }, {.name =3D "running", @@ -4939,7 +4939,7 @@ static const vshCmdOptDef opts_save_image_dumpxml[] = =3D { }, {.name =3D "xpath", .type =3D VSH_OT_STRING, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("xpath expression to filter the XML document") }, {.name =3D "wrap", @@ -4994,7 +4994,7 @@ static const vshCmdOptDef opts_save_image_define[] = =3D { .type =3D VSH_OT_STRING, .positional =3D true, .required =3D true, - .completer =3D virshCompletePathLocalExisting, + .completer =3D vshCompletePathLocalExisting, .help =3D N_("filename containing updated XML for the target") }, {.name =3D "running", @@ -5344,7 +5344,7 @@ static const vshCmdOptDef opts_managed_save_dumpxml[]= =3D { }, {.name =3D "xpath", .type =3D VSH_OT_STRING, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("xpath expression to filter the XML document") }, {.name =3D "wrap", @@ -5392,7 +5392,7 @@ static const vshCmdOptDef opts_managed_save_define[] = =3D { .type =3D VSH_OT_STRING, .positional =3D true, .required =3D true, - .completer =3D virshCompletePathLocalExisting, + .completer =3D vshCompletePathLocalExisting, .help =3D N_("filename containing updated XML for the target") }, {.name =3D "running", @@ -5680,7 +5680,7 @@ static const vshCmdOptDef opts_restore[] =3D { {.name =3D "xml", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompletePathLocalExisting, + .completer =3D vshCompletePathLocalExisting, .help =3D N_("filename containing updated XML for the target") }, {.name =3D "running", @@ -5949,7 +5949,7 @@ static const vshCmdOptDef opts_screenshot[] =3D { {.name =3D "file", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompletePathLocalExisting, + .completer =3D vshCompletePathLocalExisting, .help =3D N_("where to store the screenshot") }, {.name =3D "screen", @@ -6181,7 +6181,7 @@ static const vshCmdOptDef opts_set_user_password[] = =3D { .type =3D VSH_OT_STRING, .positional =3D true, .required =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("the new password") }, {.name =3D "encrypted", @@ -8476,7 +8476,7 @@ static const vshCmdOptDef opts_create[] =3D { {.name =3D "pass-fds", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("pass file descriptors N,M,... to the guest") }, {.name =3D "validate", @@ -8833,7 +8833,7 @@ static const vshCmdOptDef opts_metadata[] =3D { {.name =3D "set", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("new metadata to set"), }, {.name =3D "remove", @@ -9086,7 +9086,7 @@ static const vshCmdOptDef opts_send_process_signal[] = =3D { .type =3D VSH_OT_STRING, .positional =3D true, .required =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("the process ID") }, {.name =3D "signame", @@ -10036,14 +10036,14 @@ static const vshCmdOptDef opts_dom_fd_associate[]= =3D { .type =3D VSH_OT_STRING, .positional =3D true, .required =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("name of the FD group") }, {.name =3D "pass-fds", .type =3D VSH_OT_STRING, .positional =3D true, .required =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("file descriptors N,M,... to associate") }, {.name =3D "seclabel-writable", @@ -10112,7 +10112,7 @@ static const vshCmdOptDef opts_qemu_monitor_command= [] =3D { }, {.name =3D "pass-fds", .type =3D VSH_OT_STRING, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("pass file descriptors N,M,... along with the command") }, {.name =3D "cmd", @@ -10446,7 +10446,7 @@ static const vshCmdOptDef opts_qemu_attach[] =3D { .type =3D VSH_OT_STRING, .positional =3D true, .required =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("pid") }, {.name =3D NULL} @@ -10705,7 +10705,7 @@ static const vshCmdOptDef opts_dumpxml[] =3D { }, {.name =3D "xpath", .type =3D VSH_OT_STRING, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("xpath expression to filter the XML document") }, {.name =3D "wrap", @@ -10768,7 +10768,7 @@ static const vshCmdOptDef opts_domxmlfromnative[] = =3D { .type =3D VSH_OT_STRING, .positional =3D true, .required =3D true, - .completer =3D virshCompletePathLocalExisting, + .completer =3D vshCompletePathLocalExisting, .help =3D N_("config data file to import from") }, {.name =3D NULL} @@ -10822,7 +10822,7 @@ static const vshCmdOptDef opts_domxmltonative[] =3D= { {.name =3D "xml", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompletePathLocalExisting, + .completer =3D vshCompletePathLocalExisting, .help =3D N_("xml data file to export from") }, {.name =3D NULL} @@ -10919,7 +10919,7 @@ static const vshCmdOptDef opts_domrename[] =3D { .type =3D VSH_OT_STRING, .positional =3D true, .required =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("new domain name") }, {.name =3D NULL} @@ -11022,7 +11022,7 @@ static const vshCmdOptDef opts_migrate[] =3D { .type =3D VSH_OT_STRING, .positional =3D true, .required =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("connection URI of the destination host as seen from the= client(normal migration) or source(p2p migration)") }, VIRSH_COMMON_OPT_LIVE(N_("live migration")), @@ -11117,25 +11117,25 @@ static const vshCmdOptDef opts_migrate[] =3D { {.name =3D "migrateuri", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("migration URI, usually can be omitted") }, {.name =3D "graphicsuri", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("graphics URI to be used for seamless graphics migration= ") }, {.name =3D "listen-address", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("listen address that destination should bind to for inco= ming migration") }, {.name =3D "dname", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("rename to new name during migration (if supported)") }, {.name =3D "timeout", @@ -11155,7 +11155,7 @@ static const vshCmdOptDef opts_migrate[] =3D { {.name =3D "xml", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompletePathLocalExisting, + .completer =3D vshCompletePathLocalExisting, .help =3D N_("filename containing updated XML for the target") }, {.name =3D "migrate-disks", @@ -11176,7 +11176,7 @@ static const vshCmdOptDef opts_migrate[] =3D { }, {.name =3D "disks-uri", .type =3D VSH_OT_STRING, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("URI to use for disks migration (overrides --disks-port)= ") }, {.name =3D "comp-methods", @@ -11210,7 +11210,7 @@ static const vshCmdOptDef opts_migrate[] =3D { }, {.name =3D "persistent-xml", .type =3D VSH_OT_STRING, - .completer =3D virshCompletePathLocalExisting, + .completer =3D vshCompletePathLocalExisting, .help =3D N_("filename containing updated persistent XML for the targ= et") }, {.name =3D "tls", @@ -11235,7 +11235,7 @@ static const vshCmdOptDef opts_migrate[] =3D { }, {.name =3D "tls-destination", .type =3D VSH_OT_STRING, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("override the destination host name used for TLS verific= ation") }, {.name =3D "comp-zlib-level", @@ -13673,7 +13673,7 @@ static const vshCmdOptDef opts_set_user_sshkeys[] = =3D { {.name =3D "file", .type =3D VSH_OT_STRING, .positional =3D true, - .completer =3D virshCompletePathLocalExisting, + .completer =3D vshCompletePathLocalExisting, .help =3D N_("optional file to read keys from"), }, {.name =3D "reset", diff --git a/tools/virsh-host.c b/tools/virsh-host.c index 7a4c2b20d5..16f9411730 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -45,7 +45,7 @@ static const vshCmdInfo info_capabilities =3D { static const vshCmdOptDef opts_capabilities[] =3D { {.name =3D "xpath", .type =3D VSH_OT_STRING, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("xpath expression to filter the XML document") }, {.name =3D "wrap", @@ -107,7 +107,7 @@ static const vshCmdOptDef opts_domcapabilities[] =3D { }, {.name =3D "xpath", .type =3D VSH_OT_STRING, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("xpath expression to filter the XML document") }, {.name =3D "wrap", @@ -1667,7 +1667,7 @@ static const vshCmdOptDef opts_hypervisor_cpu_baselin= e[] =3D { {.name =3D "file", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompletePathLocalExisting, + .completer =3D vshCompletePathLocalExisting, .help =3D N_("file containing XML CPU descriptions"), }, {.name =3D "virttype", diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c index 7e3103adf1..624d3283a2 100644 --- a/tools/virsh-interface.c +++ b/tools/virsh-interface.c @@ -453,7 +453,7 @@ static const vshCmdOptDef opts_interface_dumpxml[] =3D { }, {.name =3D "xpath", .type =3D VSH_OT_STRING, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("xpath expression to filter the XML document") }, {.name =3D "wrap", diff --git a/tools/virsh-network.c b/tools/virsh-network.c index 5382070031..3fd22db2b0 100644 --- a/tools/virsh-network.c +++ b/tools/virsh-network.c @@ -506,7 +506,7 @@ static const vshCmdOptDef opts_network_metadata[] =3D { {.name =3D "set", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("new metadata to set"), }, {.name =3D "remove", @@ -638,7 +638,7 @@ static const vshCmdOptDef opts_network_dumpxml[] =3D { }, {.name =3D "xpath", .type =3D VSH_OT_STRING, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("xpath expression to filter the XML document") }, {.name =3D "wrap", @@ -1234,7 +1234,7 @@ static const vshCmdOptDef opts_network_update[] =3D { .type =3D VSH_OT_STRING, .positional =3D true, .required =3D true, - .completer =3D virshCompletePathLocalExisting, + .completer =3D vshCompletePathLocalExisting, .help =3D N_("name of file containing xml (or, if it starts with '<',= the complete " "xml element itself) to add/modify, or to be matched for s= earch") }, @@ -1871,7 +1871,7 @@ static const vshCmdOptDef opts_network_port_dumpxml[]= =3D { VIRSH_COMMON_OPT_NETWORK_PORT(0), {.name =3D "xpath", .type =3D VSH_OT_STRING, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("xpath expression to filter the XML document") }, {.name =3D "wrap", diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c index 7ae6127513..2ce0c1411f 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -590,7 +590,7 @@ static const vshCmdOptDef opts_node_device_dumpxml[] = =3D { }, {.name =3D "xpath", .type =3D VSH_OT_STRING, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("xpath expression to filter the XML document") }, {.name =3D "wrap", diff --git a/tools/virsh-nwfilter.c b/tools/virsh-nwfilter.c index 3745abb67e..0348584f23 100644 --- a/tools/virsh-nwfilter.c +++ b/tools/virsh-nwfilter.c @@ -175,7 +175,7 @@ static const vshCmdOptDef opts_nwfilter_dumpxml[] =3D { }, {.name =3D "xpath", .type =3D VSH_OT_STRING, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("xpath expression to filter the XML document") }, {.name =3D "wrap", @@ -576,7 +576,7 @@ static const vshCmdOptDef opts_nwfilter_binding_dumpxml= [] =3D { }, {.name =3D "xpath", .type =3D VSH_OT_STRING, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("xpath expression to filter the XML document") }, {.name =3D "wrap", diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index 089fde55e2..2010ef1356 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -57,7 +57,7 @@ .type =3D VSH_OT_STRING, \ .positional =3D true, \ .required =3D true, \ - .completer =3D virshCompleteEmpty, \ + .completer =3D vshCompleteEmpty, \ .help =3D N_("name of the pool") \ }, \ {.name =3D "type", \ @@ -74,7 +74,7 @@ {.name =3D "source-host", \ .type =3D VSH_OT_STRING, \ .unwanted_positional =3D true, \ - .completer =3D virshCompleteEmpty, \ + .completer =3D vshCompleteEmpty, \ .help =3D N_("source-host for underlying storage") \ }, \ {.name =3D "source-path", \ @@ -110,7 +110,7 @@ {.name =3D "auth-username", \ .type =3D VSH_OT_STRING, \ .unwanted_positional =3D true, \ - .completer =3D virshCompleteEmpty, \ + .completer =3D vshCompleteEmpty, \ .help =3D N_("auth username to be used for underlying storage") \ }, \ {.name =3D "secret-usage", \ @@ -166,7 +166,7 @@ {.name =3D "source-initiator", \ .type =3D VSH_OT_STRING, \ .unwanted_positional =3D true, \ - .completer =3D virshCompleteEmpty, \ + .completer =3D vshCompleteEmpty, \ .help =3D N_("initiator iqn for underlying storage") \ } @@ -745,7 +745,7 @@ static const vshCmdOptDef opts_pool_dumpxml[] =3D { }, {.name =3D "xpath", .type =3D VSH_OT_STRING, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("xpath expression to filter the XML document") }, {.name =3D "wrap", @@ -1375,19 +1375,19 @@ static const vshCmdOptDef opts_find_storage_pool_so= urces_as[] =3D { {.name =3D "host", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("optional host to query") }, {.name =3D "port", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("optional port to query") }, {.name =3D "initiator", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("optional initiator IQN to use for query") }, {.name =3D NULL} @@ -1462,7 +1462,7 @@ static const vshCmdOptDef opts_find_storage_pool_sour= ces[] =3D { {.name =3D "srcSpec", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompletePathLocalExisting, + .completer =3D vshCompletePathLocalExisting, .help =3D N_("optional file of source xml to query for pools") }, {.name =3D NULL} diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c index 68b14a5276..26ecb41073 100644 --- a/tools/virsh-secret.c +++ b/tools/virsh-secret.c @@ -131,7 +131,7 @@ static const vshCmdOptDef opts_secret_dumpxml[] =3D { }, {.name =3D "xpath", .type =3D VSH_OT_STRING, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("xpath expression to filter the XML document") }, {.name =3D "wrap", @@ -186,7 +186,7 @@ static const vshCmdOptDef opts_secret_set_value[] =3D { }, {.name =3D "file", .type =3D VSH_OT_STRING, - .completer =3D virshCompletePathLocalExisting, + .completer =3D vshCompletePathLocalExisting, .help =3D N_("read secret from file"), }, {.name =3D "plain", @@ -200,7 +200,7 @@ static const vshCmdOptDef opts_secret_set_value[] =3D { {.name =3D "base64", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("base64-encoded secret value") }, {.name =3D NULL} diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c index dbd849bb3b..8e5b9d635c 100644 --- a/tools/virsh-snapshot.c +++ b/tools/virsh-snapshot.c @@ -110,7 +110,7 @@ static const vshCmdOptDef opts_snapshot_create[] =3D { {.name =3D "xmlfile", .type =3D VSH_OT_STRING, .positional =3D true, - .completer =3D virshCompletePathLocalExisting, + .completer =3D vshCompletePathLocalExisting, .help =3D N_("domain snapshot XML") }, {.name =3D "redefine", @@ -315,13 +315,13 @@ static const vshCmdOptDef opts_snapshot_create_as[] = =3D { {.name =3D "name", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("name of snapshot") }, {.name =3D "description", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("description of snapshot") }, {.name =3D "print-xml", @@ -1593,7 +1593,7 @@ static const vshCmdOptDef opts_snapshot_dumpxml[] =3D= { }, {.name =3D "xpath", .type =3D VSH_OT_STRING, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("xpath expression to filter the XML document") }, {.name =3D "wrap", diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index 7b1847d7ae..7346d628d5 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -178,20 +178,20 @@ static const vshCmdOptDef opts_vol_create_as[] =3D { .type =3D VSH_OT_STRING, .positional =3D true, .required =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("name of the volume") }, {.name =3D "capacity", .type =3D VSH_OT_STRING, .positional =3D true, .required =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("size of the vol, as scaled integer (default bytes)") }, {.name =3D "allocation", .type =3D VSH_OT_STRING, .unwanted_positional =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("initial allocation size, as scaled integer (default byt= es)") }, {.name =3D "format", @@ -531,7 +531,7 @@ static const vshCmdOptDef opts_vol_clone[] =3D { .type =3D VSH_OT_STRING, .positional =3D true, .required =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("clone name") }, VIRSH_COMMON_OPT_POOL_OPTIONAL, @@ -1041,7 +1041,7 @@ static const vshCmdOptDef opts_vol_resize[] =3D { .type =3D VSH_OT_STRING, .positional =3D true, .required =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("new capacity for the vol, as scaled integer (default by= tes)") }, VIRSH_COMMON_OPT_POOL_OPTIONAL, @@ -1129,7 +1129,7 @@ static const vshCmdOptDef opts_vol_dumpxml[] =3D { VIRSH_COMMON_OPT_POOL_OPTIONAL, {.name =3D "xpath", .type =3D VSH_OT_STRING, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("xpath expression to filter the XML document") }, {.name =3D "wrap", diff --git a/tools/virsh.c b/tools/virsh.c index c893216637..244ca655ee 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -248,7 +248,7 @@ static const vshCmdOptDef opts_connect[] =3D { .type =3D VSH_OT_STRING, .positional =3D true, .allowEmpty =3D true, - .completer =3D virshCompleteEmpty, + .completer =3D vshCompleteEmpty, .help =3D N_("hypervisor connection URI") }, {.name =3D "readonly", diff --git a/tools/virsh.h b/tools/virsh.h index 90ffc4bf18..0e4c368c9b 100644 --- a/tools/virsh.h +++ b/tools/virsh.h @@ -102,7 +102,7 @@ .type =3D VSH_OT_STRING, \ .required =3D true, \ .positional =3D true, \ - .completer =3D virshCompletePathLocalExisting, \ + .completer =3D vshCompletePathLocalExisting, \ .help =3D _helpstr \ } diff --git a/tools/virsh-completer.c b/tools/vsh-completer.c similarity index 85% rename from tools/virsh-completer.c rename to tools/vsh-completer.c index d4defba86e..8f0376879c 100644 --- a/tools/virsh-completer.c +++ b/tools/vsh-completer.c @@ -1,5 +1,5 @@ /* - * virsh-completer.c: virsh completer callbacks + * vsh-completer.c: virsh completer callbacks * * Copyright (C) 2017 Red Hat, Inc. * @@ -20,7 +20,7 @@ #include -#include "virsh-completer.h" +#include "vsh-completer.h" /** * A completer callback is a function that accepts three arguments: @@ -56,7 +56,7 @@ /** - * virshEnumComplete: + * vshEnumComplete: * @last: The number of element in enum (pass VIR_XXX_LAST) * @intToStr: integer to string conversion (pass virXXXTypeToString) * @@ -67,8 +67,8 @@ * Returns: string list of completions. */ char ** -virshEnumComplete(unsigned int last, - const char *(*intToStr)(int)) +vshEnumComplete(unsigned int last, + const char *(*intToStr)(int)) { char **ret =3D NULL; size_t i; @@ -83,7 +83,7 @@ virshEnumComplete(unsigned int last, /** - * virshCommaStringListComplete: + * vshCommaStringListComplete: * @input: user input so far * @options: ALL options available for argument * @@ -102,15 +102,15 @@ virshEnumComplete(unsigned int last, * This helper function takes care of that. In this specific case * it would be called as follows: * - * virshCommaStringListComplete("str1,str2,str3", + * vshCommaStringListComplete("str1,str2,str3", * {"strA", "strB", "strC", NULL}); * * Returns: string list of completions on success, * NULL otherwise. */ char ** -virshCommaStringListComplete(const char *input, - const char **options) +vshCommaStringListComplete(const char *input, + const char **options) { const size_t optionsLen =3D g_strv_length((char **) options); g_autofree char *inputCopy =3D NULL; @@ -156,7 +156,7 @@ virshCommaStringListComplete(const char *input, /** - * virshCompletePathLocalExisting: + * vshCompletePathLocalExisting: * * Complete a path to a existing file used as input. The file is used as i= nput * for virsh so only local files are considered. @@ -164,16 +164,16 @@ virshCommaStringListComplete(const char *input, * Note: For now this is a no-op. Readline does the correct thing. */ char ** -virshCompletePathLocalExisting(vshControl *ctl G_GNUC_UNUSED, - const vshCmd *cmd G_GNUC_UNUSED, - unsigned int completerflags G_GNUC_UNUSED) +vshCompletePathLocalExisting(vshControl *ctl G_GNUC_UNUSED, + const vshCmd *cmd G_GNUC_UNUSED, + unsigned int completerflags G_GNUC_UNUSED) { return NULL; } /** - * virshCompleteEmpty: + * vshCompleteEmpty: * * Complete nothing. For cases where an user input is required and we can't * suggest anything. @@ -182,9 +182,9 @@ virshCompletePathLocalExisting(vshControl *ctl G_GNUC_U= NUSED, * file list. */ char ** -virshCompleteEmpty(vshControl *ctl G_GNUC_UNUSED, - const vshCmd *cmd G_GNUC_UNUSED, - unsigned int completerflags G_GNUC_UNUSED) +vshCompleteEmpty(vshControl *ctl G_GNUC_UNUSED, + const vshCmd *cmd G_GNUC_UNUSED, + unsigned int completerflags G_GNUC_UNUSED) { return NULL; } diff --git a/tools/vsh-completer.h b/tools/vsh-completer.h new file mode 100644 index 0000000000..b479156062 --- /dev/null +++ b/tools/vsh-completer.h @@ -0,0 +1,41 @@ +/* + * vsh-completer.h: common virt shell completer callbacks + * + * Copyright (C) 2017 Red Hat, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#pragma once + +#include "vsh.h" + +char ** +vshEnumComplete(unsigned int last, + const char *(*intToStr)(int)); + +char ** +vshCommaStringListComplete(const char *input, + const char **options); + +char ** +vshCompletePathLocalExisting(vshControl *ctl, + const vshCmd *cmd, + unsigned int completerflags); + +char ** +vshCompleteEmpty(vshControl *ctl, + const vshCmd *cmd, + unsigned int completerflags); --=20 2.49.0