From nobody Mon Feb 9 09:07:47 2026 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 1710511693301278.9567826409898; Fri, 15 Mar 2024 07:08:13 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id E78901F0F; Fri, 15 Mar 2024 10:08:11 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 9395E1E62; Fri, 15 Mar 2024 09:46:29 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id C5E511A83; Fri, 15 Mar 2024 09:45:38 -0400 (EDT) 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 8C0A11BB1 for ; Fri, 15 Mar 2024 09:44:51 -0400 (EDT) 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-503-aV2xr2rfMdKpGoJmlgSRWA-1; Fri, 15 Mar 2024 09:44:49 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (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 13C43101A56C for ; Fri, 15 Mar 2024 13:44:49 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.5]) by smtp.corp.redhat.com (Postfix) with ESMTP id 813B2C1576F for ; Fri, 15 Mar 2024 13:44:48 +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_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: aV2xr2rfMdKpGoJmlgSRWA-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 26/28] vsh: Make positional parsing of arguments opt-in Date: Fri, 15 Mar 2024 14:44:21 +0100 Message-ID: <442e12c2a6754737a2a99cf2352ac1fc235576ee.1710510137.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: 5FVWZEUZU5FKVH4EL7J5MCZGBV2C2NDG X-Message-ID-Hash: 5FVWZEUZU5FKVH4EL7J5MCZGBV2C2NDG 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: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1710511706366100001 Switch the command parser from using the VSH_OFLAG_REQ_OPT flag opting out from positional parsing of arguments to a combination of the 'positional' flags for truly positional arguments and 'unwanted_positional' preserving semantics for the existing arguments where the parser did it due to bad design. This patch retires VSH_OFLAG_REQ_OPT along with the infrastructure that was needed to refactor all uses properly. Signed-off-by: Peter Krempa --- tools/virsh-backup.c | 1 - tools/virsh-checkpoint.c | 1 - tools/virsh-domain-monitor.c | 1 - tools/virsh-domain.c | 69 ------------------------------------ tools/virsh-host.c | 2 -- tools/virsh-interface.c | 1 - tools/virsh-network.c | 2 -- tools/virsh-nodedev.c | 1 - tools/virsh-nwfilter.c | 2 -- tools/virsh-pool.c | 1 - tools/virsh-secret.c | 2 -- tools/virsh-snapshot.c | 2 -- tools/virsh-volume.c | 1 - tools/virt-admin.c | 1 - tools/vsh.c | 44 ++--------------------- tools/vsh.h | 1 - 16 files changed, 3 insertions(+), 129 deletions(-) diff --git a/tools/virsh-backup.c b/tools/virsh-backup.c index 52325b5ca0..9a1e89760f 100644 --- a/tools/virsh-backup.c +++ b/tools/virsh-backup.c @@ -109,7 +109,6 @@ 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, - .flags =3D VSH_OFLAG_REQ_OPT, .completer =3D virshCompleteEmpty, .help =3D N_("xpath expression to filter the XML document") }, diff --git a/tools/virsh-checkpoint.c b/tools/virsh-checkpoint.c index 48e3a586e4..e425041ca7 100644 --- a/tools/virsh-checkpoint.c +++ b/tools/virsh-checkpoint.c @@ -829,7 +829,6 @@ static const vshCmdOptDef opts_checkpoint_dumpxml[] =3D= { }, {.name =3D "xpath", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .completer =3D virshCompleteEmpty, .help =3D N_("xpath expression to filter the XML document") }, diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c index d88cf64235..5531d3b737 100644 --- a/tools/virsh-domain-monitor.c +++ b/tools/virsh-domain-monitor.c @@ -277,7 +277,6 @@ static const vshCmdOptDef opts_dommemstat[] =3D { VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), {.name =3D "period", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("period in seconds to set collection") }, VIRSH_COMMON_OPT_CONFIG(N_("affect next boot")), diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 600388dceb..91a9dfd96a 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -434,38 +434,31 @@ static const vshCmdOptDef opts_attach_disk[] =3D { }, {.name =3D "targetbus", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("target bus of disk device") }, {.name =3D "driver", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("driver of disk device") }, {.name =3D "subdriver", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("subdriver of disk device") }, {.name =3D "iothread", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .completer =3D virshDomainIOThreadIdCompleter, .help =3D N_("IOThread to be used by supported device") }, {.name =3D "cache", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("cache mode of disk device") }, {.name =3D "io", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("io policy of disk device") }, {.name =3D "type", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("target device type") }, {.name =3D "shareable", @@ -474,29 +467,24 @@ static const vshCmdOptDef opts_attach_disk[] =3D { }, {.name =3D "mode", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("mode of device reading and writing") }, {.name =3D "sourcetype", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("type of source (block|file|network)") }, {.name =3D "serial", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .completer =3D virshCompleteEmpty, .help =3D N_("serial of disk device") }, {.name =3D "wwn", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .completer =3D virshCompleteEmpty, .help =3D N_("wwn of disk device") }, {.name =3D "alias", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .completer =3D virshCompleteEmpty, .help =3D N_("custom alias name of disk device") }, @@ -506,7 +494,6 @@ static const vshCmdOptDef opts_attach_disk[] =3D { }, {.name =3D "address", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .completer =3D virshCompleteEmpty, .help =3D N_("address of disk device") }, @@ -520,23 +507,19 @@ static const vshCmdOptDef opts_attach_disk[] =3D { }, {.name =3D "source-protocol", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("protocol used by disk device source") }, {.name =3D "source-host-name", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .completer =3D virshCompleteEmpty, .help =3D N_("host name for source of disk device") }, {.name =3D "source-host-transport", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("host transport for source of disk device") }, {.name =3D "source-host-socket", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("host socket for source of disk device") }, VIRSH_COMMON_OPT_DOMAIN_PERSISTENT, @@ -1229,7 +1212,6 @@ static const vshCmdOptDef opts_blkdeviotune[] =3D { }, {.name =3D "total-bytes-sec", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("total throughput limit, as scaled integer (default byte= s)") }, {.name =3D "read_bytes_sec", @@ -1238,7 +1220,6 @@ static const vshCmdOptDef opts_blkdeviotune[] =3D { }, {.name =3D "read-bytes-sec", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("read throughput limit, as scaled integer (default bytes= )") }, {.name =3D "write_bytes_sec", @@ -1247,7 +1228,6 @@ static const vshCmdOptDef opts_blkdeviotune[] =3D { }, {.name =3D "write-bytes-sec", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("write throughput limit, as scaled integer (default byt= es)") }, {.name =3D "total_iops_sec", @@ -1256,7 +1236,6 @@ static const vshCmdOptDef opts_blkdeviotune[] =3D { }, {.name =3D "total-iops-sec", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("total I/O operations limit per second") }, {.name =3D "read_iops_sec", @@ -1265,7 +1244,6 @@ static const vshCmdOptDef opts_blkdeviotune[] =3D { }, {.name =3D "read-iops-sec", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("read I/O operations limit per second") }, {.name =3D "write_iops_sec", @@ -1274,7 +1252,6 @@ static const vshCmdOptDef opts_blkdeviotune[] =3D { }, {.name =3D "write-iops-sec", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("write I/O operations limit per second") }, {.name =3D "total_bytes_sec_max", @@ -1283,7 +1260,6 @@ static const vshCmdOptDef opts_blkdeviotune[] =3D { }, {.name =3D "total-bytes-sec-max", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("total max, as scaled integer (default bytes)") }, {.name =3D "read_bytes_sec_max", @@ -1292,7 +1268,6 @@ static const vshCmdOptDef opts_blkdeviotune[] =3D { }, {.name =3D "read-bytes-sec-max", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("read max, as scaled integer (default bytes)") }, {.name =3D "write_bytes_sec_max", @@ -1301,7 +1276,6 @@ static const vshCmdOptDef opts_blkdeviotune[] =3D { }, {.name =3D "write-bytes-sec-max", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("write max, as scaled integer (default bytes)") }, {.name =3D "total_iops_sec_max", @@ -1310,7 +1284,6 @@ static const vshCmdOptDef opts_blkdeviotune[] =3D { }, {.name =3D "total-iops-sec-max", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("total I/O operations max") }, {.name =3D "read_iops_sec_max", @@ -1319,7 +1292,6 @@ static const vshCmdOptDef opts_blkdeviotune[] =3D { }, {.name =3D "read-iops-sec-max", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("read I/O operations max") }, {.name =3D "write_iops_sec_max", @@ -1328,7 +1300,6 @@ static const vshCmdOptDef opts_blkdeviotune[] =3D { }, {.name =3D "write-iops-sec-max", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("write I/O operations max") }, {.name =3D "size_iops_sec", @@ -1337,7 +1308,6 @@ static const vshCmdOptDef opts_blkdeviotune[] =3D { }, {.name =3D "size-iops-sec", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("I/O size in bytes") }, {.name =3D "group_name", @@ -1346,7 +1316,6 @@ static const vshCmdOptDef opts_blkdeviotune[] =3D { }, {.name =3D "group-name", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .completer =3D virshCompleteEmpty, .help =3D N_("group name to share I/O quota between multiple drives") }, @@ -1356,7 +1325,6 @@ static const vshCmdOptDef opts_blkdeviotune[] =3D { }, {.name =3D "total-bytes-sec-max-length", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("duration in seconds to allow total max bytes") }, {.name =3D "read_bytes_sec_max_length", @@ -1365,7 +1333,6 @@ static const vshCmdOptDef opts_blkdeviotune[] =3D { }, {.name =3D "read-bytes-sec-max-length", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("duration in seconds to allow read max bytes") }, {.name =3D "write_bytes_sec_max_length", @@ -1374,7 +1341,6 @@ static const vshCmdOptDef opts_blkdeviotune[] =3D { }, {.name =3D "write-bytes-sec-max-length", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("duration in seconds to allow write max bytes") }, {.name =3D "total_iops_sec_max_length", @@ -1383,7 +1349,6 @@ static const vshCmdOptDef opts_blkdeviotune[] =3D { }, {.name =3D "total-iops-sec-max-length", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("duration in seconds to allow total I/O operations max") }, {.name =3D "read_iops_sec_max_length", @@ -1392,7 +1357,6 @@ static const vshCmdOptDef opts_blkdeviotune[] =3D { }, {.name =3D "read-iops-sec-max-length", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("duration in seconds to allow read I/O operations max") }, {.name =3D "write_iops_sec_max_length", @@ -1401,7 +1365,6 @@ static const vshCmdOptDef opts_blkdeviotune[] =3D { }, {.name =3D "write-iops-sec-max-length", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("duration in seconds to allow write I/O operations max") }, VIRSH_COMMON_OPT_DOMAIN_CONFIG, @@ -3506,7 +3469,6 @@ static const vshCmdOptDef opts_dom_pm_suspend[] =3D { }, {.name =3D "duration", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("duration in seconds") }, {.name =3D NULL} @@ -4544,7 +4506,6 @@ static const vshCmdOptDef opts_save_image_dumpxml[] = =3D { }, {.name =3D "xpath", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .completer =3D virshCompleteEmpty, .help =3D N_("xpath expression to filter the XML document") }, @@ -4950,7 +4911,6 @@ static const vshCmdOptDef opts_managed_save_dumpxml[]= =3D { }, {.name =3D "xpath", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .completer =3D virshCompleteEmpty, .help =3D N_("xpath expression to filter the XML document") }, @@ -5060,12 +5020,10 @@ static const vshCmdOptDef opts_schedinfo[] =3D { VIRSH_COMMON_OPT_DOMAIN_FULL(0), {.name =3D "weight", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("weight for XEN_CREDIT") }, {.name =3D "cap", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("cap for XEN_CREDIT") }, VIRSH_COMMON_OPT_CURRENT(N_("get/set current scheduler info")), @@ -8576,13 +8534,11 @@ static const vshCmdOptDef opts_send_key[] =3D { VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), {.name =3D "codeset", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .completer =3D virshCodesetNameCompleter, .help =3D N_("the codeset of keycodes, default:linux") }, {.name =3D "holdtime", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("the time (in milliseconds) how long the keys will be he= ld") }, {.name =3D "keycode", @@ -9524,12 +9480,10 @@ static const vshCmdOptDef opts_domsetlaunchsecstate= [] =3D { VIRSH_COMMON_OPT_DOMAIN_FULL(0), {.name =3D "secrethdr", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("path to file containing the secret header"), }, {.name =3D "secret", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("path to file containing the secret"), }, {.name =3D "set-address", @@ -9702,7 +9656,6 @@ static const vshCmdOptDef opts_qemu_monitor_command[]= =3D { }, {.name =3D "pass-fds", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .completer =3D virshCompleteEmpty, .help =3D N_("pass file descriptors N,M,... along with the command") }, @@ -10091,7 +10044,6 @@ static const vshCmdOptDef opts_qemu_agent_command[]= =3D { VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), {.name =3D "timeout", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("timeout seconds. must be positive.") }, {.name =3D "async", @@ -10329,7 +10281,6 @@ static const vshCmdOptDef opts_dumpxml[] =3D { }, {.name =3D "xpath", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .completer =3D virshCompleteEmpty, .help =3D N_("xpath expression to filter the XML document") }, @@ -10441,7 +10392,6 @@ static const vshCmdOptDef opts_domxmltonative[] =3D= { }, {.name =3D "domain", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("domain name, id or uuid"), .completer =3D virshDomainNameCompleter, }, @@ -10797,49 +10747,40 @@ static const vshCmdOptDef opts_migrate[] =3D { }, {.name =3D "disks-uri", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .completer =3D virshCompleteEmpty, .help =3D N_("URI to use for disks migration (overrides --disks-port)= ") }, {.name =3D "comp-methods", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .completer =3D virshDomainMigrateCompMethodsCompleter, .help =3D N_("comma separated list of compression methods to be used") }, {.name =3D "comp-mt-level", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("compress level for multithread compression") }, {.name =3D "comp-mt-threads", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("number of compression threads for multithread compressi= on") }, {.name =3D "comp-mt-dthreads", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("number of decompression threads for multithread compres= sion") }, {.name =3D "comp-xbzrle-cache", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("page cache size for xbzrle compression") }, {.name =3D "auto-converge-initial", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("initial CPU throttling rate for auto-convergence") }, {.name =3D "auto-converge-increment", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("CPU throttling rate increment for auto-convergence") }, {.name =3D "persistent-xml", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .completer =3D virshCompletePathLocalExisting, .help =3D N_("filename containing updated persistent XML for the targ= et") }, @@ -10849,38 +10790,31 @@ static const vshCmdOptDef opts_migrate[] =3D { }, {.name =3D "postcopy-bandwidth", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("post-copy migration bandwidth limit in MiB/s") }, {.name =3D "parallel", .type =3D VSH_OT_BOOL, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("enable parallel migration") }, {.name =3D "parallel-connections", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("number of connections for parallel migration") }, {.name =3D "bandwidth", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("migration bandwidth limit in MiB/s") }, {.name =3D "tls-destination", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .completer =3D virshCompleteEmpty, .help =3D N_("override the destination host name used for TLS verific= ation") }, {.name =3D "comp-zlib-level", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("compress level for zlib compression") }, {.name =3D "comp-zstd-level", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("compress level for zstd compression") }, {.name =3D NULL} @@ -11439,7 +11373,6 @@ static const vshCmdOptDef opts_migrate_compcache[] = =3D { VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), {.name =3D "size", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("requested size of the cache (in bytes) used for compres= sion") }, {.name =3D NULL} @@ -13100,7 +13033,6 @@ static const vshCmdOptDef opts_guest_agent_timeout[= ] =3D { VIRSH_COMMON_OPT_DOMAIN_FULL(0), {.name =3D "timeout", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("timeout seconds.") }, {.name =3D NULL} @@ -13448,7 +13380,6 @@ static const vshCmdOptDef opts_domdisplay_reload[] = =3D { VIRSH_COMMON_OPT_DOMAIN_FULL(0), {.name =3D "type", .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("graphics display type") }, {.name =3D NULL} diff --git a/tools/virsh-host.c b/tools/virsh-host.c index 52e0dc55de..c338b5cd85 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -45,7 +45,6 @@ static const vshCmdInfo info_capabilities =3D { static const vshCmdOptDef opts_capabilities[] =3D { {.name =3D "xpath", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .completer =3D virshCompleteEmpty, .help =3D N_("xpath expression to filter the XML document") }, @@ -108,7 +107,6 @@ static const vshCmdOptDef opts_domcapabilities[] =3D { }, {.name =3D "xpath", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .completer =3D virshCompleteEmpty, .help =3D N_("xpath expression to filter the XML document") }, diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c index a08bb822ed..755c0d6455 100644 --- a/tools/virsh-interface.c +++ b/tools/virsh-interface.c @@ -453,7 +453,6 @@ static const vshCmdOptDef opts_interface_dumpxml[] =3D { }, {.name =3D "xpath", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .completer =3D virshCompleteEmpty, .help =3D N_("xpath expression to filter the XML document") }, diff --git a/tools/virsh-network.c b/tools/virsh-network.c index 5bc91a361f..065e59c3a1 100644 --- a/tools/virsh-network.c +++ b/tools/virsh-network.c @@ -639,7 +639,6 @@ static const vshCmdOptDef opts_network_dumpxml[] =3D { }, {.name =3D "xpath", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .completer =3D virshCompleteEmpty, .help =3D N_("xpath expression to filter the XML document") }, @@ -1874,7 +1873,6 @@ static const vshCmdOptDef opts_network_port_dumpxml[]= =3D { VIRSH_COMMON_OPT_NETWORK_PORT(0), {.name =3D "xpath", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .completer =3D virshCompleteEmpty, .help =3D N_("xpath expression to filter the XML document") }, diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c index fafebf9972..b0563395f0 100644 --- a/tools/virsh-nodedev.c +++ b/tools/virsh-nodedev.c @@ -584,7 +584,6 @@ static const vshCmdOptDef opts_node_device_dumpxml[] = =3D { }, {.name =3D "xpath", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .completer =3D virshCompleteEmpty, .help =3D N_("xpath expression to filter the XML document") }, diff --git a/tools/virsh-nwfilter.c b/tools/virsh-nwfilter.c index f54d2a0ae5..69473b4935 100644 --- a/tools/virsh-nwfilter.c +++ b/tools/virsh-nwfilter.c @@ -175,7 +175,6 @@ static const vshCmdOptDef opts_nwfilter_dumpxml[] =3D { }, {.name =3D "xpath", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .completer =3D virshCompleteEmpty, .help =3D N_("xpath expression to filter the XML document") }, @@ -577,7 +576,6 @@ static const vshCmdOptDef opts_nwfilter_binding_dumpxml= [] =3D { }, {.name =3D "xpath", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .completer =3D virshCompleteEmpty, .help =3D N_("xpath expression to filter the XML document") }, diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index c93204dd30..aff1201ef7 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -748,7 +748,6 @@ static const vshCmdOptDef opts_pool_dumpxml[] =3D { }, {.name =3D "xpath", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .completer =3D virshCompleteEmpty, .help =3D N_("xpath expression to filter the XML document") }, diff --git a/tools/virsh-secret.c b/tools/virsh-secret.c index edf3c47362..5653451862 100644 --- a/tools/virsh-secret.c +++ b/tools/virsh-secret.c @@ -131,7 +131,6 @@ static const vshCmdOptDef opts_secret_dumpxml[] =3D { }, {.name =3D "xpath", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .completer =3D virshCompleteEmpty, .help =3D N_("xpath expression to filter the XML document") }, @@ -187,7 +186,6 @@ static const vshCmdOptDef opts_secret_set_value[] =3D { }, {.name =3D "file", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .completer =3D virshCompletePathLocalExisting, .help =3D N_("read secret from file"), }, diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c index 2fcf6e3d5e..d64649a8da 100644 --- a/tools/virsh-snapshot.c +++ b/tools/virsh-snapshot.c @@ -359,7 +359,6 @@ static const vshCmdOptDef opts_snapshot_create_as[] =3D= { }, {.name =3D "memspec", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .help =3D N_("memory attributes: [file=3D]name[,snapshot=3Dtype]") }, {.name =3D "diskspec", @@ -1587,7 +1586,6 @@ static const vshCmdOptDef opts_snapshot_dumpxml[] =3D= { }, {.name =3D "xpath", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .completer =3D virshCompleteEmpty, .help =3D N_("xpath expression to filter the XML document") }, diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index 4e5673e0ee..67a6f2eda0 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -1130,7 +1130,6 @@ static const vshCmdOptDef opts_vol_dumpxml[] =3D { VIRSH_COMMON_OPT_POOL_OPTIONAL, {.name =3D "xpath", .type =3D VSH_OT_STRING, - .flags =3D VSH_OFLAG_REQ_OPT, .completer =3D virshCompleteEmpty, .help =3D N_("xpath expression to filter the XML document") }, diff --git a/tools/virt-admin.c b/tools/virt-admin.c index 514f434c94..9a29a67999 100644 --- a/tools/virt-admin.c +++ b/tools/virt-admin.c @@ -1010,7 +1010,6 @@ static const vshCmdOptDef opts_daemon_timeout[] =3D { .type =3D VSH_OT_INT, .required =3D true, .help =3D N_("number of seconds the daemon will run without any activ= e connection"), - .flags =3D VSH_OFLAG_REQ_OPT }, {.name =3D NULL} }; diff --git a/tools/vsh.c b/tools/vsh.c index 2c90ca44f7..1dac869413 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -244,14 +244,12 @@ static int disconnected; /* we may have been disconne= cted */ static int vshCmddefCheckInternals(vshControl *ctl, const vshCmdDef *cmd, - bool missingCompleters, - int brokenPositionals) + bool missingCompleters) { size_t i; bool seenOptionalOption =3D false; const char *seenOptionalPositionalOption =3D NULL; g_auto(virBuffer) complbuf =3D VIR_BUFFER_INITIALIZER; - g_auto(virBuffer) posbuf =3D VIR_BUFFER_INITIALIZER; /* in order to perform the validation resolve the alias first */ if (cmd->alias) { @@ -328,29 +326,6 @@ vshCmddefCheckInternals(vshControl *ctl, } } - if (brokenPositionals >=3D 0) { - switch (opt->type) { - case VSH_OT_INT: - case VSH_OT_STRING: - case VSH_OT_ARGV: - if (brokenPositionals =3D=3D 0 || - brokenPositionals =3D=3D opt->type) { - if (!(opt->flags & VSH_OFLAG_REQ_OPT) && - !(opt->positional || opt->unwanted_positional)) - virBufferStrcat(&posbuf, opt->name, ", ", NULL); - } - break; - - case VSH_OT_BOOL: - /* only name is completed */ - /* no point in completing numbers */ - case VSH_OT_ALIAS: - /* alias is handled in the referenced command */ - case VSH_OT_NONE: - break; - } - } - /* allow at most one optional positional option */ if (opt->positional && !opt->required) { if (seenOptionalPositionalOption) { @@ -471,15 +446,10 @@ vshCmddefCheckInternals(vshControl *ctl, } virBufferTrim(&complbuf, ", "); - virBufferTrim(&posbuf, ", "); if (missingCompleters && virBufferUse(&complbuf) > 0) vshPrintExtra(ctl, "%s: %s\n", cmd->name, virBufferCurrentContent(= &complbuf)); - if (virBufferUse(&posbuf)) { - vshPrintExtra(ctl, "%s: %s\n", cmd->name, virBufferCurrentContent(= &posbuf)); - } - return 0; } @@ -508,7 +478,7 @@ vshCmddefOptParse(const vshCmdDef *cmd, if (opt->type =3D=3D VSH_OT_ALIAS) continue; /* skip the alias option */ - if (!(opt->flags & VSH_OFLAG_REQ_OPT)) + if (opt->positional || opt->unwanted_positional) *opts_need_arg |=3D 1ULL << i; if (opt->required) @@ -3387,11 +3357,6 @@ const vshCmdOptDef opts_selftest[] =3D { .type =3D VSH_OT_BOOL, .help =3D N_("output help for each command") }, - {.name =3D "broken-positionals", - .type =3D VSH_OT_INT, - .flags =3D VSH_OFLAG_REQ_OPT, - .help =3D N_("debug positional args") - }, {.name =3D NULL} }; const vshCmdInfo info_selftest =3D { @@ -3406,9 +3371,6 @@ cmdSelfTest(vshControl *ctl, const vshCmd *cmd) const vshCmdDef *def; bool completers =3D vshCommandOptBool(cmd, "completers-missing"); bool dumphelp =3D vshCommandOptBool(cmd, "dump-help"); - int brokenPositionals =3D -1; - - ignore_value(vshCommandOptInt(ctl, cmd, "broken-positionals", &brokenP= ositionals)); for (grp =3D cmdGroups; grp->name; grp++) { for (def =3D grp->commands; def->name; def++) { @@ -3416,7 +3378,7 @@ cmdSelfTest(vshControl *ctl, const vshCmd *cmd) if (dumphelp && !def->alias) vshCmddefHelp(def); - if (vshCmddefCheckInternals(ctl, def, completers, brokenPositi= onals) < 0) + if (vshCmddefCheckInternals(ctl, def, completers) < 0) return false; } } diff --git a/tools/vsh.h b/tools/vsh.h index fdcc89b12a..02c35488b9 100644 --- a/tools/vsh.h +++ b/tools/vsh.h @@ -99,7 +99,6 @@ typedef enum { enum { VSH_OFLAG_NONE =3D 0, /* without flags */ VSH_OFLAG_EMPTY_OK =3D (1 << 1), /* empty string option allowed */ - VSH_OFLAG_REQ_OPT =3D (1 << 2), /* --optionname required */ }; /* forward declarations */ --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org