Red Hat Bugzilla – Bug 1248277
no error output when pass a negative number to setvcpus
Last modified: 2016-11-03 14:21:39 EDT
Description of problem: no error output when pass a negative number to setvcpus Version-Release number of selected component (if applicable): libvirt-1.2.17-2.el7.x86_64 How reproducible: 100% Steps to Reproduce: 1. # virsh setvcpus rhel7.0 0 2. # virsh setvcpus rhel7.0 -1 3. Actual results: no error in setp 1 & 2 Expected results: output error in step 1 & 2 Additional info: test with 1.2.16 and can get an error: # rpm -q libvirt libvirt-1.2.16-1.el7.x86_64 # virsh setvcpus rhel7.0 -1 error: Numeric value for <count> option is malformed or out of range
Send a patch to upstream: https://www.redhat.com/archives/libvir-list/2015-July/msg01109.html
Fixed upstream: commit c62c59a9840cde925f4f88fddf639e434bcef33d Author: Luyao Huang <lhuang@redhat.com> AuthorDate: Thu Oct 22 11:27:35 2015 +0800 Commit: Andrea Bolognani <abologna@redhat.com> CommitDate: Thu Oct 22 09:22:44 2015 +0200 virsh: Display an error when passing count <= 0 to setvcpus The number of vCPUs for a guest must be between 1 and the maximum value configured in the domain XML. This commit introduces checks to make sure that passing count <= 0 results in an error.
Passed with version libvirt-1.3.1-1.el7.x86_64. steps: 1.#virsh setvcpus rhel7.2 0 error: Can't set 0 processors for a VM 2.#virsh setvcpus rhel7.2 -1 error: Numeric value '-1' for <count> option is malformed or out of range 3.#virsh setvcpus rhel7.2 4294967296 error: Numeric value '4294967296' for <count> option is malformed or out of range 4.#virsh setvcpus rhel7.2 4294967295 error: invalid argument: requested vcpus is greater than max allowable vcpus for the domain: -1 > 1 5.#virsh setvcpus rhel7.2 4294967297 error: Numeric value '4294967297' for <count> option is malformed or out of range
Reproduced with libvirt-1.2.17-2.el7.x86_64. Verified pass with libvirt-2.0.0-5.el7.x86_64. steps: 1.virsh setvcpus rhel7.2 0 error: Can't set 0 processors for a VM 2.#virsh setvcpus rhel7.2 -1 error: Numeric value '-1' for <count> option is malformed or out of range 3.#virsh setvcpus rhle7.2 -4294967296 error: Numeric value '-4294967296' for <count> option is malformed or out of range 4.virsh setvcpus rhel7 -4.0 error: Numeric value '-4.1' for <count> option is malformed or out of range
Hi,Peter, When I pass a number between 2^31 to 2^32-1,the error output is strange: 1.#virsh setvcpus rhel7.2 2147483648 error: invalid argument: requested vcpus is greater than max allowable vcpus for the domain: -2147483648 > 4 2.# virsh setvcpus rhel7 4294967295 error: invalid argument: requested vcpus is greater than max allowable vcpus for the domain: -1 > 4 Would you help to check whether it needs to be fixed please? Thank you!
The problem is in the format character in the error message: if (!(flags & VIR_DOMAIN_VCPU_MAXIMUM) && nvcpus > maxvcpus) { virReportError(VIR_ERR_INVALID_ARG, _("requested vcpus is greater than max allowable" " vcpus for the domain: %d > %d"), nvcpus, maxvcpus); goto endjob; } Both nvcpus and maxvcpus are unsigned. I'll post a patch upstream.
The error message should make more sense as of: commit e96041ff1ac270b719e43bf0e3d5a224fe61c26a Author: Peter Krempa <pkrempa@redhat.com> Date: Wed Aug 3 12:57:23 2016 +0200 qemu: setcpus: Report better errors Mention whether it was the live or persistent definition which caused an error reported and explicitly error out in case when attempting to set maximum vcpu count for a live domain.
According to comment 5, move this BZ to verified.
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. https://rhn.redhat.com/errata/RHSA-2016-2577.html