]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh-checkpoint: Make 'checkpointname' positional and required
authorPeter Krempa <pkrempa@redhat.com>
Thu, 14 Mar 2024 15:56:16 +0000 (16:56 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 2 Apr 2024 12:24:29 +0000 (14:24 +0200)
The argument was being parsed positionally due to the command parser
quirk as we didn't opt out of it.

Since the code in virshLookupCheckpoint requires that the checkpointname
is present we can mark all the options as positional and required and
remove the redundant check from virshLookupCheckpoint.

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

index 65061cbf3d56b2943d384e8a5116848872815298..9aeb8a5e7ed49503e7f9812e4a5bef211d6e06ff 100644 (file)
@@ -281,16 +281,8 @@ virshLookupCheckpoint(vshControl *ctl,
     if (vshCommandOptStringReq(ctl, cmd, arg, &chkname) < 0)
         return -1;
 
-    if (chkname) {
-        *chk = virDomainCheckpointLookupByName(dom, chkname, 0);
-    } else {
-        vshError(ctl, _("--%1$s is required"), arg);
+    if (!(*chk = virDomainCheckpointLookupByName(dom, chkname, 0)))
         return -1;
-    }
-    if (!*chk) {
-        vshReportError(ctl);
-        return -1;
-    }
 
     *name = virDomainCheckpointGetName(*chk);
     return 0;
@@ -309,6 +301,8 @@ static const vshCmdOptDef opts_checkpoint_edit[] = {
     VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_HAS_CHECKPOINT),
     {.name = "checkpointname",
      .type = VSH_OT_STRING,
+     .positional = true,
+     .required = true,
      .help = N_("checkpoint name"),
      .completer = virshCheckpointNameCompleter,
     },
@@ -420,6 +414,8 @@ static const vshCmdOptDef opts_checkpoint_info[] = {
     VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_HAS_CHECKPOINT),
     {.name = "checkpointname",
      .type = VSH_OT_STRING,
+     .positional = true,
+     .required = true,
      .help = N_("checkpoint name"),
      .completer = virshCheckpointNameCompleter,
     },
@@ -810,6 +806,8 @@ static const vshCmdOptDef opts_checkpoint_dumpxml[] = {
     VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_HAS_CHECKPOINT),
     {.name = "checkpointname",
      .type = VSH_OT_STRING,
+     .positional = true,
+     .required = true,
      .help = N_("checkpoint name"),
      .completer = virshCheckpointNameCompleter,
     },
@@ -886,6 +884,8 @@ static const vshCmdOptDef opts_checkpoint_parent[] = {
     VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_HAS_CHECKPOINT),
     {.name = "checkpointname",
      .type = VSH_OT_STRING,
+     .positional = true,
+     .required = true,
      .help = N_("find parent of checkpoint name"),
      .completer = virshCheckpointNameCompleter,
     },
@@ -935,6 +935,8 @@ static const vshCmdOptDef opts_checkpoint_delete[] = {
                                  VIR_CONNECT_LIST_DOMAINS_ACTIVE),
     {.name = "checkpointname",
      .type = VSH_OT_STRING,
+     .positional = true,
+     .required = true,
      .help = N_("checkpoint name"),
      .completer = virshCheckpointNameCompleter,
     },