Bug 726304

Summary: Error output for blkiotune command when set invalid weight number
Product: Red Hat Enterprise Linux 6 Reporter: Min Zhan <mzhan>
Component: libvirtAssignee: Alex Jia <ajia>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.2CC: ajia, dallan, dyuan, mzhan, rwu, veillard
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-0.9.4-1.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-12-06 11:18:03 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Min Zhan 2011-07-28 07:32:40 UTC
Description of problem:
From man virsh page, weight valid value is [100,1000]. 
1. when set weight as 0, the output should report the error,but it report the current weight.
2. when set weight as 99 for running guest, there is an error display. But set weight as 99 for shutdown guest, no error display.

Version-Release number of selected component (if applicable):
kernel-2.6.32-165.el6.x86_64
qemu-kvm-0.12.1.2-2.167.el6.x86_64
libvirt-0.9.4-0rc1.el6.x86_64

How reproducible:
Always

Steps to Reproduce:
0.
# virsh list --all
 Id Name                 State
----------------------------------
  4 rhel61               running

# virsh dumpxml rhel61
...
  <blkiotune>
    <weight>1000</weight>
  </blkiotune>

1. For issue 1:
# virsh blkiotune rhel61 --weight 0
weight         : 1000

2. For issue 2:
# virsh blkiotune rhel61 --weight 99
error: Unable to change blkio parameters
error: invalid argument in out of blkio weight range.

# virsh destroy rhel61
Domain rhel61 destroyed

# virsh blkiotune rhel61 --weight 99 // no error display

# virsh blkiotune rhel61
weight         : 1000


Actual results:
As above

Expected results:
1. For issue 1: There should be the error message for invalid weight number 0. 
2. For issue 2: There should be also the same check for invalid weight for running and shutdown guest.

Additional info:

Comment 1 Alex Jia 2011-07-28 07:51:22 UTC
cmdBlkiotune function is missing 0 value judgement, I will commit a patch to fix this issue.

Alex

Comment 2 Alex Jia 2011-07-28 10:45:19 UTC
https://www.redhat.com/archives/libvir-list/2011-July/msg01973.html

The above patch is used for resolving 0 value issue, and wait for developers review.

For  0 < weight <100 and weight > 1000, cmdBlkiotune hasn't raised any error
for a inactive guest, so whether we should only allow change weight value for active guest?

Alex

Comment 3 Alex Jia 2011-07-28 14:42:46 UTC
(In reply to comment #2)
> https://www.redhat.com/archives/libvir-list/2011-July/msg01973.html
here is latest patch:
https://www.redhat.com/archives/libvir-list/2011-July/msg01980.html

For  0 < weight <100 and weight > 1000, cmdBlkiotune hasn't raised any error
for a inactive guest, so whether we should only allow change weight value for
active guest?

Alex

Comment 4 Dave Allan 2011-07-28 15:56:30 UTC
commit 3f39a0bf2750e63472b4d6d93cd6413013f90902
Author: Alex Jia <ajia>
Date:   Thu Jul 28 19:13:41 2011 +0800

    virsh: avoid missing zero value judgement in cmdBlkiotune
    
    * tools/virsh.c: fix missing zero value judgement in cmdBlkiotune and correct
      vshError information.
    
      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>

Thanks for the patch!

Comment 5 Alex Jia 2011-07-29 02:21:50 UTC
Hi Dave,
This bug has 2 issues, one is missing zero value judgement, the above patch has resolved this issue, the other is when we set weight value out of range [100, 1000] for a inactive guest, the operation is successful and without any error information, it's not we expected result, I add comments for this issue in Comment 2 and Comment3, I want to know whether libvirt only allow to change weight value for a active guest not inactive like 'schedinfo', only allow to change cpu_shares for a active guest, if so, I will commit second patch to fix this issue, but I don't know if this will have effect on '--live', '--config' and
'--current'.

BTW, so current bug status shouldn't be 'POST', we need to fix the second issue.


Alex

Comment 7 Alex Jia 2011-08-01 08:58:39 UTC
Fix issue 2:
https://www.redhat.com/archives/libvir-list/2011-August/msg00006.html

Alex

Comment 9 Alex Jia 2011-08-01 15:45:14 UTC
commit c03f7f1358a47e3bcc1575972c984233ca5da77c
Author: Alex Jia <ajia>
Date:   Mon Aug 1 23:45:27 2011 +0800

    qemu: fix return value issue
    
    whether or not previous return value is -1, the following codes will be
    executed for a inactive guest in src/qemu/qemu_driver.c:
    ret = virDomainSaveConfig(driver->configDir, persistentDef);
    and if everything is okay, 'ret' is assigned to 0, the previous 'ret'
    will be overwritten, this patch will fix this issue.
    
    * src/qemu/qemu_driver.c: avoid return value is overwritten when give a argument
      in out of blkio weight range for a inactive guest.
    
    * how to reproduce?
      % virsh blkiotune ${guestname} --weight 10
      % echo $?
    
      Note: guest must be inactive, argument 10 in out of blkio weight range,
      and can get a error information by checking libvirtd.log, however,
      virsh hasn't raised any error information, and return value is 0.
    
      https://bugzilla.redhat.com/show_bug.cgi?id=726304
    
    Signed-off-by: Alex Jia <ajia>

Comment 11 dyuan 2011-08-04 09:17:15 UTC
Reproduced this bug with libvirt-0.9.4-0rc2.el6.

Verified PASS with libvirt-0.9.4-1.el6.
pkgs:
qemu-kvm-0.12.1.2-2.176.el6
kernel-2.6.32-172.el6

# virsh start dom
Domain dom started

# virsh blkiotune dom --weight 0
error: Invalid value of 0 for I/O weight

# virsh blkiotune dom --weight 99
error: Unable to change blkio parameters
error: invalid argument in out of blkio weight range.

# virsh destroy dom
Domain dom destroyed

# virsh blkiotune dom --weight 99
error: Unable to change blkio parameters
error: invalid argument in out of blkio weight range.
# virsh blkiotune dom
weight         : 1000

Comment 12 errata-xmlrpc 2011-12-06 11:18:03 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2011-1513.html