[libvirt] [PATCHv2 12/15] virsh: use option aliases

Eric Blake eblake at redhat.com
Tue Mar 6 00:34:27 UTC 2012


Command line interfaces should use dash, not underscore, as many
keyboard layouts allow that to be typed with fewer shift key presses.

Also, the US spelling of --tunneled gets more google hits than the
UK spelling of --tunnelled.

* tools/virsh.c (opts_migrate): Allow US variant.
(opts_blkdeviotune): Prefer - over _.
* tools/virsh.pod (blkdeviotune): Fix spelling.
---

v2: no real change

 tools/virsh.c   |   49 +++++++++++++++++++++++++++++++------------------
 tools/virsh.pod |   18 +++++++++---------
 2 files changed, 40 insertions(+), 27 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index 77cf4ac..75a1a3b 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -6879,6 +6879,7 @@ static const vshCmdOptDef opts_migrate[] = {
     {"live", VSH_OT_BOOL, 0, N_("live migration")},
     {"p2p", VSH_OT_BOOL, 0, N_("peer-2-peer migration")},
     {"direct", VSH_OT_BOOL, 0, N_("direct migration")},
+    {"tunneled", VSH_OT_ALIAS, 0, "tunnelled"},
     {"tunnelled", VSH_OT_BOOL, 0, N_("tunnelled migration")},
     {"persistent", VSH_OT_BOOL, 0, N_("persist VM on destination")},
     {"undefinesource", VSH_OT_BOOL, 0, N_("undefine VM on source")},
@@ -7574,17 +7575,23 @@ static const vshCmdInfo info_blkdeviotune[] = {
 static const vshCmdOptDef opts_blkdeviotune[] = {
     {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
     {"device", VSH_OT_DATA, VSH_OFLAG_REQ, N_("block device")},
-    {"total_bytes_sec", VSH_OT_INT, VSH_OFLAG_NONE,
+    {"total_bytes_sec", VSH_OT_ALIAS, 0, "total-bytes-sec"},
+    {"total-bytes-sec", VSH_OT_INT, VSH_OFLAG_NONE,
      N_("total throughput limit in bytes per second")},
-    {"read_bytes_sec", VSH_OT_INT, VSH_OFLAG_NONE,
+    {"read_bytes_sec", VSH_OT_ALIAS, 0, "read-bytes-sec"},
+    {"read-bytes-sec", VSH_OT_INT, VSH_OFLAG_NONE,
      N_("read throughput limit in bytes per second")},
-    {"write_bytes_sec", VSH_OT_INT, VSH_OFLAG_NONE,
+    {"write_bytes_sec", VSH_OT_ALIAS, 0, "write-bytes-sec"},
+    {"write-bytes-sec", VSH_OT_INT, VSH_OFLAG_NONE,
      N_("write throughput limit in bytes per second")},
-    {"total_iops_sec", VSH_OT_INT, VSH_OFLAG_NONE,
+    {"total_iops_sec", VSH_OT_ALIAS, 0, "total-iops-sec"},
+    {"total-iops-sec", VSH_OT_INT, VSH_OFLAG_NONE,
      N_("total I/O operations limit per second")},
-    {"read_iops_sec", VSH_OT_INT, VSH_OFLAG_NONE,
+    {"read_iops_sec", VSH_OT_ALIAS, 0, "read-iops-sec"},
+    {"read-iops-sec", VSH_OT_INT, VSH_OFLAG_NONE,
      N_("read I/O operations limit per second")},
-    {"write_iops_sec", VSH_OT_INT, VSH_OFLAG_NONE,
+    {"write_iops_sec", VSH_OT_ALIAS, 0, "write-iops-sec"},
+    {"write-iops-sec", VSH_OT_INT, VSH_OFLAG_NONE,
      N_("write I/O operations limit per second")},
     {"config", VSH_OT_BOOL, 0, N_("affect next boot")},
     {"live", VSH_OT_BOOL, 0, N_("affect running domain")},
@@ -7630,7 +7637,8 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptString(cmd, "device", &disk) < 0)
         goto cleanup;

-    if ((rv = vshCommandOptULongLong(cmd, "total_bytes_sec", &total_bytes_sec)) < 0) {
+    if ((rv = vshCommandOptULongLong(cmd, "total-bytes-sec",
+                                     &total_bytes_sec)) < 0) {
         vshError(ctl, "%s",
                  _("Unable to parse integer parameter"));
         goto cleanup;
@@ -7638,7 +7646,8 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
         nparams++;
     }

-    if ((rv = vshCommandOptULongLong(cmd, "read_bytes_sec", &read_bytes_sec)) < 0) {
+    if ((rv = vshCommandOptULongLong(cmd, "read-bytes-sec",
+                                     &read_bytes_sec)) < 0) {
         vshError(ctl, "%s",
                  _("Unable to parse integer parameter"));
         goto cleanup;
@@ -7646,7 +7655,8 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
         nparams++;
     }

-    if ((rv = vshCommandOptULongLong(cmd, "write_bytes_sec", &write_bytes_sec)) < 0) {
+    if ((rv = vshCommandOptULongLong(cmd, "write-bytes-sec",
+                                     &write_bytes_sec)) < 0) {
         vshError(ctl, "%s",
                  _("Unable to parse integer parameter"));
         goto cleanup;
@@ -7654,7 +7664,8 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
         nparams++;
     }

-    if ((rv = vshCommandOptULongLong(cmd, "total_iops_sec", &total_iops_sec)) < 0) {
+    if ((rv = vshCommandOptULongLong(cmd, "total-iops-sec",
+                                     &total_iops_sec)) < 0) {
         vshError(ctl, "%s",
                  _("Unable to parse integer parameter"));
         goto cleanup;
@@ -7662,7 +7673,8 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
         nparams++;
     }

-    if ((rv = vshCommandOptULongLong(cmd, "read_iops_sec", &read_iops_sec)) < 0) {
+    if ((rv = vshCommandOptULongLong(cmd, "read-iops-sec",
+                                     &read_iops_sec)) < 0) {
         vshError(ctl, "%s",
                  _("Unable to parse integer parameter"));
         goto cleanup;
@@ -7670,7 +7682,8 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
         nparams++;
     }

-    if ((rv = vshCommandOptULongLong(cmd, "write_iops_sec", &write_iops_sec)) < 0) {
+    if ((rv = vshCommandOptULongLong(cmd, "write-iops-sec",
+                                     &write_iops_sec)) < 0) {
         vshError(ctl, "%s",
                  _("Unable to parse integer parameter"));
         goto cleanup;
@@ -7712,7 +7725,7 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
         params = vshCalloc(ctl, nparams, sizeof(*params));
         i = 0;

-        if ((i < nparams) && (vshCommandOptBool(cmd, "total_bytes_sec"))) {
+        if ((i < nparams) && (vshCommandOptBool(cmd, "total-bytes-sec"))) {
             temp = &params[i];
             temp->type = VIR_TYPED_PARAM_ULLONG;
             strncpy(temp->field, VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_BYTES_SEC,
@@ -7721,7 +7734,7 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
             i++;
         }

-        if ((i < nparams) && (vshCommandOptBool(cmd, "read_bytes_sec"))) {
+        if ((i < nparams) && (vshCommandOptBool(cmd, "read-bytes-sec"))) {
             temp = &params[i];
             temp->type = VIR_TYPED_PARAM_ULLONG;
             strncpy(temp->field, VIR_DOMAIN_BLOCK_IOTUNE_READ_BYTES_SEC,
@@ -7730,7 +7743,7 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
             i++;
         }

-        if ((i < nparams) && (vshCommandOptBool(cmd, "write_bytes_sec"))) {
+        if ((i < nparams) && (vshCommandOptBool(cmd, "write-bytes-sec"))) {
             temp = &params[i];
             temp->type = VIR_TYPED_PARAM_ULLONG;
             strncpy(temp->field, VIR_DOMAIN_BLOCK_IOTUNE_WRITE_BYTES_SEC,
@@ -7739,7 +7752,7 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
             i++;
         }

-        if ((i < nparams) && (vshCommandOptBool(cmd, "total_iops_sec"))) {
+        if ((i < nparams) && (vshCommandOptBool(cmd, "total-iops-sec"))) {
             temp = &params[i];
             temp->type = VIR_TYPED_PARAM_ULLONG;
             strncpy(temp->field, VIR_DOMAIN_BLOCK_IOTUNE_TOTAL_IOPS_SEC,
@@ -7748,7 +7761,7 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
             i++;
         }

-        if ((i < nparams) && (vshCommandOptBool(cmd, "read_iops_sec"))) {
+        if ((i < nparams) && (vshCommandOptBool(cmd, "read-iops-sec"))) {
             temp = &params[i];
             temp->type = VIR_TYPED_PARAM_ULLONG;
             strncpy(temp->field, VIR_DOMAIN_BLOCK_IOTUNE_READ_IOPS_SEC,
@@ -7757,7 +7770,7 @@ cmdBlkdeviotune(vshControl *ctl, const vshCmd *cmd)
             i++;
         }

-        if ((i < nparams) && (vshCommandOptBool(cmd, "write_iops_sec"))) {
+        if ((i < nparams) && (vshCommandOptBool(cmd, "write-iops-sec"))) {
             temp = &params[i];
             temp->type = VIR_TYPED_PARAM_ULLONG;
             strncpy(temp->field, VIR_DOMAIN_BLOCK_IOTUNE_WRITE_IOPS_SEC,
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 8f6a2d6..1bc55c4 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -614,8 +614,8 @@ I<bandwidth> specifies copying bandwidth limit in Mbps.

 =item B<blkdeviotune> I<domain> I<device>
 [[I<--config>] [I<--live>] | [I<--current>]]
-[[I<total_bytes_sec>] | [I<read_bytes_sec>] [I<write_bytes_sec>]]
-[[I<total_iops_sec>] | [I<read_iops_sec>] [I<write_iops_sec>]]
+[[I<total-bytes-sec>] | [I<read-bytes-sec>] [I<write-bytes-sec>]]
+[[I<total-iops-sec>] | [I<read-iops-sec>] [I<write-iops-sec>]]

 Set or query the block disk io parameters for a block device of I<domain>.
 I<device> specifies a unique target name (<target dev='name'/>) or source
@@ -624,15 +624,15 @@ I<domain> (see also B<domblklist> for listing these names).

 If no limit is specified, it will query current I/O limits setting.
 Otherwise, alter the limits with these flags:
-I<--total_bytes_sec> specifies total throughput limit in bytes per second.
-I<--read_bytes_sec> specifies read throughput limit in bytes per second.
-I<--write_bytes_sec> specifies write throughput limit in bytes per second.
-I<--total_iops_sec> specifies total I/O operations limit per second.
-I<--read_iops_sec> specifies read I/O operations limit per second.
-I<--write_iops_sec> specifies write I/O operations limit per second.
+I<--total-bytes-sec> specifies total throughput limit in bytes per second.
+I<--read-bytes-sec> specifies read throughput limit in bytes per second.
+I<--write-bytes-sec> specifies write throughput limit in bytes per second.
+I<--total-iops-sec> specifies total I/O operations limit per second.
+I<--read-iops-sec> specifies read I/O operations limit per second.
+I<--write-iops-sec> specifies write I/O operations limit per second.

 Bytes and iops values are independent, but setting only one value (such
-as --read_bytes_sec) resets the other two in that category to unlimited.
+as --read-bytes-sec) resets the other two in that category to unlimited.
 An explicit 0 also clears any limit.  A non-zero value for a given total
 cannot be mixed with non-zero values for read or write.

-- 
1.7.7.6




More information about the libvir-list mailing list