[PATCH] virsh: avoid missing zero value judgement in cmdBlkiotune

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

 



* tools/virsh.c: avoid missing zero value judgement in cmdBlkiotune, when
  weight is equal to 0, the cmdBlkiotune will not raise any error information
  when judge weight value first time, and execute else branch to judge weight 
  value again, strncpy(temp->field, VIR_DOMAIN_BLKIO_WEIGHT, sizeof(temp->field)) 
  will be not executed for ever. However, if and only if param->field is equal to 
  VIR_DOMAIN_BLKIO_WEIGHT, underlying qemuDomainSetBlkioParameters function 
  will check whether weight value is in range [100, 1000].

* how to reproduce?

  % virsh blkiotune ${guestname} --weight 0


Signed-off-by: Alex Jia <ajia@xxxxxxxxxx>
---
 tools/virsh.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index 8bd22dc..183d7c6 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -4037,12 +4037,10 @@ cmdBlkiotune(vshControl * ctl, const vshCmd * cmd)
         goto cleanup;
     }
 
-    if (weight) {
-        nparams++;
-        if (weight < 0) {
-            vshError(ctl, _("Invalid value of %d for I/O weight"), weight);
-            goto cleanup;
-        }
+    nparams++;
+    if (weight <= 0) {
+        vshError(ctl, _("Invalid value of %d for I/O weight"), weight);
+        goto cleanup;
     }
 
     if (nparams == 0) {
-- 
1.7.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[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]