[PATCH 15/28] virsh-checkpoint: Make 'checkpointname' positional and required

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 tools/virsh-checkpoint.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/tools/virsh-checkpoint.c b/tools/virsh-checkpoint.c
index 65061cbf3d..9aeb8a5e7e 100644
--- a/tools/virsh-checkpoint.c
+++ b/tools/virsh-checkpoint.c
@@ -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,
     },
-- 
2.44.0
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux