RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1248277 - no error output when pass a negative number to setvcpus
Summary: no error output when pass a negative number to setvcpus
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.2
Hardware: x86_64
OS: Linux
low
low
Target Milestone: rc
: ---
Assignee: Libvirt Maintainers
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-07-30 02:44 UTC by Luyao Huang
Modified: 2016-11-03 18:21 UTC (History)
5 users (show)

Fixed In Version: libvirt-1.3.1-1.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-11-03 18:21:39 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2016:2577 0 normal SHIPPED_LIVE Moderate: libvirt security, bug fix, and enhancement update 2016-11-03 12:07:06 UTC

Description Luyao Huang 2015-07-30 02:44:33 UTC
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

Comment 1 Luyao Huang 2015-07-30 02:58:24 UTC
Send a patch to upstream:

https://www.redhat.com/archives/libvir-list/2015-July/msg01109.html

Comment 2 Peter Krempa 2015-10-22 07:36:12 UTC
Fixed upstream:

commit c62c59a9840cde925f4f88fddf639e434bcef33d
Author:     Luyao Huang <lhuang>
AuthorDate: Thu Oct 22 11:27:35 2015 +0800
Commit:     Andrea Bolognani <abologna>
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.

Comment 4 yafu 2016-03-07 10:18:23 UTC
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

Comment 5 yafu 2016-08-16 03:27:42 UTC
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

Comment 6 yafu 2016-08-16 04:28:08 UTC
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!

Comment 7 Peter Krempa 2016-08-16 08:03:03 UTC
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.

Comment 9 Peter Krempa 2016-08-16 10:40:29 UTC
The error message should make more sense as of:

commit e96041ff1ac270b719e43bf0e3d5a224fe61c26a
Author: Peter Krempa <pkrempa>
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.

Comment 10 yafu 2016-08-17 04:49:49 UTC
According to comment 5, move this BZ to verified.

Comment 12 errata-xmlrpc 2016-11-03 18:21:39 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.

https://rhn.redhat.com/errata/RHSA-2016-2577.html


Note You need to log in before you can comment on or make changes to this bug.