mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 20:15:17 +00:00
348010ac93
While the virsh option definitions specify (either explicitly after recent refactors, or implicitly before) whether an argument is positional or not, the actual parser is way more lax and actually and allows also arguments which were considered/documented as non-positional to be filled positionally unless VSH_OFLAG_REQ_OPT is used in the flags. This creates situations such as 'snapshot-create-as' which has the following docs: SYNOPSIS snapshot-create-as <domain> [--name <string>] [--description <string>] [--print-xml] [--no-metadata] [--halt] [--disk-only] [--reuse-external] [--quiesce] [--atomic] [--live] [--validate] [--memspec <string>] [[--diskspec] <string>]... Thus showing as if '--name' and '--description' required the option, but in fact the following happens when only positionals are passed: $ virsh snapshot-create-as --print-xml 1 2 3 4 5 <domainsnapshot> <name>2</name> <description>3</description> <disks> <disk name='4'/> <disk name='5'/> </disks> </domainsnapshot> In the above example e.g. '--memspec' is not populated. This disconnect makes it impossible to refactor the parser itself and allows users to write buggy interactions with virsh. In order to address this we'll be annotating every single of these unwanted positional options as such so that this doesn't happen in the future, while still preserving the quirk in the parser. This patch introduces a tool which outputs list of options which are not marked as positional but are lacking the VSH_OFLAG_REQ_OPT flag. This tool will be removed once all the offenders found by it will be addressed. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>