Bug 1451983

Summary: libvirt gives wrong info when try to hot-plug vcpu 0 for inactive guest
Product: Red Hat Enterprise Linux 7 Reporter: Jingjing Shao <jishao>
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED ERRATA QA Contact: yalzhang <yalzhang>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.4CC: dyuan, lhuang, pkrempa, rbalakri, xuzhang, yalzhang
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-3.7.0-1.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-04-10 10:44:33 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Jingjing Shao 2017-05-18 05:53:17 UTC
Description of problem:
libvirt gives wrong info when try to hot-plug  vcpu 0 for inactive guest

Version-Release number of selected component (if applicable):
libvirt-3.2.0-5.el7.x86_64

How reproducible:
100%

Steps to Reproduce:

1. # virsh dumpxml r7.2 | grep vcpu  -A7
  <vcpu placement='static' current='4'>10</vcpu>
  <vcpus>
    <vcpu id='0' enabled='yes' hotpluggable='no'/>
    <vcpu id='1' enabled='yes' hotpluggable='no'/>
    <vcpu id='2' enabled='yes' hotpluggable='yes'/>
    <vcpu id='3' enabled='yes' hotpluggable='yes'/>
    <vcpu id='4' enabled='no' hotpluggable='yes'/>
    <vcpu id='5' enabled='no' hotpluggable='yes'/>
    <vcpu id='6' enabled='no' hotpluggable='yes'/>
    <vcpu id='7' enabled='no' hotpluggable='yes'/>
    <vcpu id='8' enabled='no' hotpluggable='yes'/>
    <vcpu id='9' enabled='no' hotpluggable='yes'/>
  </vcpus>

2. # virsh list --all
 Id    Name                           State
----------------------------------------------------
 -     r7.2                           shut off


3. # virsh setvcpu r7.2  0  --enable
error: invalid argument: vcpu '1' can't be modified as it is followed by non-hotpluggable online vcpus


Actual results:
As the result in step3


Expected results:
Should give some reasonable info about vcpu 0


Additional info:

Comment 2 Peter Krempa 2017-05-18 07:04:53 UTC
Additionally, the message even if it said 'vcpu 0' would be partially misleading.

Comment 3 Peter Krempa 2017-05-22 08:44:34 UTC
The number in the error message was corrected upstream:

commit ae3b82266d5d9c825f5c3639e2cea59d4060b5ff
Author: Peter Krempa <pkrempa>
Date:   Fri May 12 17:46:31 2017 +0200

    qemu: hotplug: print correct vcpu when validating hot(un)plug config
    
    The error message would contain first vcpu id after the list of vcpus
    selected for modification. To print the proper vcpu id remember the
    first vcpu selected to be modified.

The issue with the issue being misleading is still present though.

Comment 4 Peter Krempa 2017-06-28 12:28:44 UTC
As of upstream:

commit b183f17d76839587cbe411f4e12beca18d3ec702
Author: Peter Krempa <pkrempa>
Date:   Wed Jun 28 10:42:49 2017 +0200

    qemu: hotplug: Disallow modification of vcpu 0 in inactive config
    
    vcpu 0 must be always enabled and non-hotpluggable, thus you can't
    modify it using the vcpu hotplug APIs. Disallow it so that users can't
    create invalid configurations.


vcpu 0 can't be modified, so the misleading message about vcpu 0 won't appear.

Comment 6 yalzhang@redhat.com 2017-10-20 13:11:57 UTC
Test on libvirt-3.8.0-1.el7.x86_64, the result is as expected, set this bug to be verified.

1. vcpu0 can not be modified wether the vm is running or inactive, check bug 1459785#c4

2. test the order: 
start the vm, then check the vcpu0 will order from '1'
# virsh dumpxml rhel7.4 | grep /vcpus -B10 
  <vcpu placement='static' current='1'>8</vcpu>
  <vcpus>
    <vcpu id='0' enabled='yes' hotpluggable='no' order='1'/>
    <vcpu id='1' enabled='no' hotpluggable='yes'/>
    <vcpu id='2' enabled='no' hotpluggable='yes'/>
    <vcpu id='3' enabled='no' hotpluggable='yes'/>
    <vcpu id='4' enabled='no' hotpluggable='yes'/>
    <vcpu id='5' enabled='no' hotpluggable='yes'/>
    <vcpu id='6' enabled='no' hotpluggable='yes'/>
    <vcpu id='7' enabled='no' hotpluggable='yes'/>
  </vcpus>

3. vcpu3 will get if as '2' when enabled
# virsh setvcpu rhel7.4 '2-3,^2' --enable
# virsh dumpxml rhel7.4 | grep /vcpus -B10 
  <vcpu placement='static' current='2'>8</vcpu>
  <vcpus>
    <vcpu id='0' enabled='yes' hotpluggable='no' order='1'/>
    <vcpu id='1' enabled='no' hotpluggable='yes'/>
    <vcpu id='2' enabled='no' hotpluggable='yes'/>
    <vcpu id='3' enabled='yes' hotpluggable='yes' order='2'/>
    <vcpu id='4' enabled='no' hotpluggable='yes'/>
    <vcpu id='5' enabled='no' hotpluggable='yes'/>
    <vcpu id='6' enabled='no' hotpluggable='yes'/>
    <vcpu id='7' enabled='no' hotpluggable='yes'/>
  </vcpus>

4. vcpu 1 is the 3rd cpu to be enabled and get order of '3'
# virsh setvcpu rhel7.4 1 --enable
# virsh dumpxml rhel7.4 | grep /vcpus -B10 
  <vcpu placement='static' current='3'>8</vcpu>
  <vcpus>
    <vcpu id='0' enabled='yes' hotpluggable='no' order='1'/>
    <vcpu id='1' enabled='yes' hotpluggable='yes' order='3'/>
    <vcpu id='2' enabled='no' hotpluggable='yes'/>
    <vcpu id='3' enabled='yes' hotpluggable='yes' order='2'/>
    <vcpu id='4' enabled='no' hotpluggable='yes'/>
    <vcpu id='5' enabled='no' hotpluggable='yes'/>
    <vcpu id='6' enabled='no' hotpluggable='yes'/>
    <vcpu id='7' enabled='no' hotpluggable='yes'/>
  </vcpus>

5. Set the order 2 cpu as disable, the order will be re-ordered. 
# virsh setvcpu rhel7.4 3 --disable
# virsh dumpxml rhel7.4 | grep /vcpus -B10 
  <vcpu placement='static' current='2'>8</vcpu>
  <vcpus>
    <vcpu id='0' enabled='yes' hotpluggable='no' order='1'/>
    <vcpu id='1' enabled='yes' hotpluggable='yes' order='2'/>
    <vcpu id='2' enabled='no' hotpluggable='yes'/>
    <vcpu id='3' enabled='no' hotpluggable='yes'/>
    <vcpu id='4' enabled='no' hotpluggable='yes'/>
    <vcpu id='5' enabled='no' hotpluggable='yes'/>
    <vcpu id='6' enabled='no' hotpluggable='yes'/>
    <vcpu id='7' enabled='no' hotpluggable='yes'/>
  </vcpus>

6. # virsh setvcpu rhel7.4 '3-4' --enable
error: Operation not supported: only one hotpluggable entity can be selected
(for persistent config, it will return succeed. This is acceptable as the error message is clear.)

7. # virsh setvcpu rhel7.4 1 --enable
error: invalid argument: vcpu '1' is already in requested state
(for persistent config, it will return succeed. This is acceptable as the error message is clear.)

Comment 10 errata-xmlrpc 2018-04-10 10:44:33 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://access.redhat.com/errata/RHEA-2018:0704