]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: Require option flags for all optional arguments of 'attach-disk'
authorPeter Krempa <pkrempa@redhat.com>
Wed, 13 Mar 2024 21:57:04 +0000 (22:57 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 2 Apr 2024 12:24:29 +0000 (14:24 +0200)
Annotate arguments which can be unintentionally parsed positionally.
(See previous commits for explanation.)

Currently virsh accepts the arguments such as:

 $ virsh attach-disk --print-xml 1 2 3 4 5 6 7 8 9 10
 <disk type='file' device='10'>
   <driver name='5' type='6' iothread='7' cache='8' io='9'/>
   <source file='2'/>
   <target dev='3' bus='4'/>
 </disk>

While making virsh require the flags is technically a breaking change,
there were multiple instances where arguments were added to the argument
list thus changing the order the positional arguments would be
interpreted as. Examples are commits: 7e157858b4bbc5a8090afa,
ca21d75d25. As of such there are multiple breaks of compatibility for
the positional arguments.

As of such, require the option flag for all optional arguments with
value for 'virsh attach-disk'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tools/virsh-domain.c

index a558afe273926b399f9cfc88079b60c307532830..d7b86ded7db9594c811184e3a671e0f735303d00 100644 (file)
@@ -434,31 +434,38 @@ static const vshCmdOptDef opts_attach_disk[] = {
     },
     {.name = "targetbus",
      .type = VSH_OT_STRING,
+     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("target bus of disk device")
     },
     {.name = "driver",
      .type = VSH_OT_STRING,
+     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("driver of disk device")
     },
     {.name = "subdriver",
      .type = VSH_OT_STRING,
+     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("subdriver of disk device")
     },
     {.name = "iothread",
      .type = VSH_OT_STRING,
+     .flags = VSH_OFLAG_REQ_OPT,
      .completer = virshDomainIOThreadIdCompleter,
      .help = N_("IOThread to be used by supported device")
     },
     {.name = "cache",
      .type = VSH_OT_STRING,
+     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("cache mode of disk device")
     },
     {.name = "io",
      .type = VSH_OT_STRING,
+     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("io policy of disk device")
     },
     {.name = "type",
      .type = VSH_OT_STRING,
+     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("target device type")
     },
     {.name = "shareable",
@@ -467,24 +474,29 @@ static const vshCmdOptDef opts_attach_disk[] = {
     },
     {.name = "mode",
      .type = VSH_OT_STRING,
+     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("mode of device reading and writing")
     },
     {.name = "sourcetype",
      .type = VSH_OT_STRING,
+     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("type of source (block|file|network)")
     },
     {.name = "serial",
      .type = VSH_OT_STRING,
+     .flags = VSH_OFLAG_REQ_OPT,
      .completer = virshCompleteEmpty,
      .help = N_("serial of disk device")
     },
     {.name = "wwn",
      .type = VSH_OT_STRING,
+     .flags = VSH_OFLAG_REQ_OPT,
      .completer = virshCompleteEmpty,
      .help = N_("wwn of disk device")
     },
     {.name = "alias",
      .type = VSH_OT_STRING,
+     .flags = VSH_OFLAG_REQ_OPT,
      .completer = virshCompleteEmpty,
      .help = N_("custom alias name of disk device")
     },
@@ -494,6 +506,7 @@ static const vshCmdOptDef opts_attach_disk[] = {
     },
     {.name = "address",
      .type = VSH_OT_STRING,
+     .flags = VSH_OFLAG_REQ_OPT,
      .completer = virshCompleteEmpty,
      .help = N_("address of disk device")
     },
@@ -507,19 +520,23 @@ static const vshCmdOptDef opts_attach_disk[] = {
     },
     {.name = "source-protocol",
      .type = VSH_OT_STRING,
+     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("protocol used by disk device source")
     },
     {.name = "source-host-name",
      .type = VSH_OT_STRING,
+     .flags = VSH_OFLAG_REQ_OPT,
      .completer = virshCompleteEmpty,
      .help = N_("host name for source of disk device")
     },
     {.name = "source-host-transport",
      .type = VSH_OT_STRING,
+     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("host transport for source of disk device")
     },
     {.name = "source-host-socket",
      .type = VSH_OT_STRING,
+     .flags = VSH_OFLAG_REQ_OPT,
      .help = N_("host socket for source of disk device")
     },
     VIRSH_COMMON_OPT_DOMAIN_PERSISTENT,