Description of problem: The cpu number in error info is wrong when enable/disable a vcpu which is followed by non-hotpluggable online vcpus Version-Release number of selected component: libvirt-4.5.0-6.virtcov.el7.x86_64 How reproducible: 100% Steps to Reproduce: 1. Prepare a guest with more than two vcpus: # virsh vcpucount rhel7.5 maximum config 240 current config 8 Don't set the hotpluggable attribute for each vcpu. By default,t the first 8 vcpus are enabled and not hotpluggable. # virsh dumpxml rhel7.5 |grep hotpluggable 2.Try to disable or enable one vcpu (select one among vcpu 1-6): # virsh setvcpu rhel7.5 4 --disable --config error: invalid argument: vcpu '-1' can't be modified as it is followed by non-hotpluggable online vcpus # virsh setvcpu rhel7.5 4 --enable --config error: invalid argument: vcpu '-1' can't be modified as it is followed by non-hotpluggable online vcpus Actual results: As step2 , the vcpu number in error message is not correct Expected results: It should be: error: invalid argument: vcpu '4' can't be modified as it is followed by non-hotpluggable online vcpus
Fixed upstream: commit 5ed97c22865c86ccca3802d24c9893dd1109ab34 Author: Peter Krempa <pkrempa> Date: Tue Mar 17 18:33:31 2020 +0100 qemuDomainVcpuValidateConfig: Properly initialize 'firstcpu' variable The loop which checks whether the vcpus are in proper configuration for the requested hot(un)plug skips the first modified vcpu. This means that 'firstvcpu' which is used to print the error message in case the configuration is not suitable would never point to the first modified vcpu. In cases such as: <vcpu placement='auto' current='5'>8</vcpu> <vcpus> <vcpu id='0' enabled='yes' hotpluggable='no'/> <vcpu id='1' enabled='yes' hotpluggable='no'/> <vcpu id='2' enabled='yes' hotpluggable='no'/> <vcpu id='3' enabled='yes' hotpluggable='no'/> <vcpu id='4' enabled='yes' hotpluggable='no'/> <vcpu id='5' enabled='no' hotpluggable='yes'/> <vcpu id='6' enabled='no' hotpluggable='yes'/> <vcpu id='7' enabled='no' hotpluggable='yes'/> </vcpus> # virsh setvcpu --config --disable upstream 1 error: invalid argument: vcpu '-1' can't be modified as it is followed by non-hotpluggable online vcpus After this fix the proper vcpu is reported in the error message: # virsh setvcpu --config --disable upstream 1 error: invalid argument: vcpu '1' can't be modified as it is followed by non-hotpluggable online vcpu
Reproduced this bug libvirt-6.0.0-14.module+el8.3.0+6124+819ee737.x86_64 with and verified this bug with libvirt-6.3.0-1.module+el8.3.0+6478+69f490bb.x86_64. Version: libvirt-6.0.0-14.module+el8.3.0+6124+819ee737.x86_64 qemu-kvm-4.2.0-19.module+el8.3.0+6478+69f490bb.x86_64 kernel-4.18.0-196.el8.x86_64 Steps: 1. Prepare a shutdown VM with the following XML # virsh domstate test83 shut off # virsh dumpxml test83 --inactive | grep "<vcpu" <vcpu placement='static' current='7'>10</vcpu> 2. Start the VM and check vcpucount info # virsh start test83 Domain test83 started # virsh console test83 Connected to domain test83 Escape character is ^] Red Hat Enterprise Linux 8.2 Beta (Ootpa) Kernel 4.18.0-187.el8.x86_64 on an x86_64 localhost login: # virsh vcpucount test83 maximum config 10 maximum live 10 current config 7 current live 7 3. Disable/Enable vCPU 1 by "virsh setvcpu" cmd with --config parameter # virsh setvcpu test83 1 --enable --config error: invalid argument: vcpu '-1' can't be modified as it is followed by non-hotpluggable online vcpus # virsh setvcpu test83 1 --disable --config error: invalid argument: vcpu '-1' can't be modified as it is followed by non-hotpluggable online vcpus 4. Upgrade libvirt # yum upgrade libvirt* -y # rpm -qa libvirt libvirt-6.3.0-1.module+el8.3.0+6478+69f490bb.x86_64 # systemctl restart libvirtd 5. Repeat step-3 # virsh setvcpu test83 1 --enable --config error: invalid argument: vcpu '1' can't be modified as it is followed by non-hotpluggable online vcpus # virsh setvcpu test83 1 --disable --config error: invalid argument: vcpu '1' can't be modified as it is followed by non-hotpluggable online vcpus # virsh setvcpu test83 4 --disable --config error: invalid argument: vcpu '4' can't be modified as it is followed by non-hotpluggable online vcpus All the test results are as expected, move this bug to e 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 (virt:8.3 bug fix and enhancement update), 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/RHBA-2020:5137