Bug 1437010

Summary: use setvcpu command to cold unplug guest vcpu will make guest have broken settings
Product: Red Hat Enterprise Linux 7 Reporter: Luyao Huang <lhuang>
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED ERRATA QA Contact: yalzhang <yalzhang>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.4CC: dyuan, pkrempa, rbalakri, xuzhang, yalzhang
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-3.2.0-2.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-01 17:24:15 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 Luyao Huang 2017-03-29 09:16:13 UTC
Description of problem:
use setvcpu command to cold unplug guest vcpu will make guest have broken settings

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

How reproducible:
100%

Steps to Reproduce:
1. prepare a offline guest

# virsh dumpxml r7
...
  <vcpu placement='static' current='5'>10</vcpu>   <----no vcpus element
  <resource>
    <partition>/machine</partition>
  </resource>

...
  <cpu>
    <numa>
      <cell id='0' cpus='0-4' memory='524288' unit='KiB'/>
      <cell id='1' cpus='5-9' memory='524288' unit='KiB'/>
    </numa>
  </cpu>

2.
virsh setvcpu r7 2 --disable --config

3. restart libvirtd

# service libvirtd restart
Redirecting to /bin/systemctl restart  libvirtd.service

# virsh edit r7
error: failed to get domain 'r7'
error: Domain not found: no domain with matching name 'r7'


log:

libvirtd: 2017-03-29 09:14:51.019+0000: 7633: error : qemuDomainDefVcpusPostParse:2613 : unsupported configuration: online non-hotpluggable vcpus need to be ordered prior to hotplugable vcpus


Actual results:

guest disappear after restart libvirtd

Expected results:

guest still exist

Additional info:

Comment 1 Peter Krempa 2017-04-04 07:22:58 UTC
Fixed upstream by:

commit 079832103c3b7883e36db90705631cc55cac9dcc
Author: Peter Krempa <pkrempa>
Date:   Fri Mar 31 13:34:16 2017 +0200

    qemu: hotplug: Validate that vcpu-hotplug does not break config
    
    Make sure that non-hotpluggable vcpus stay clustered at the beginning
    after modifying persistent definition.

Comment 4 yalzhang@redhat.com 2017-05-10 12:43:03 UTC
Test on below packages:
libvirt-3.2.0-4.el7.x86_64
qemu-kvm-rhev-2.9.0-2.el7.x86_64

In step 2, the error message is $cpuid+1, but for cpu0, it is 0. Do you think it is expected? 

1. prepare a offline domain
# virsh dumpxml rhel7
...
  <vcpu placement='static' current='5'>10</vcpu>   <----no vcpus element
...

2. 
# virsh setvcpu rhel7 2 --disable --config
error: invalid argument: vcpu '3' can't be modified as it is followed by non-hotpluggable online vcpus

# virsh setvcpu rhel7 0 --disable
error: invalid argument: vCPU '0' must be enabled

# virsh setvcpu rhel7 11 --disable
error: invalid argument: vcpu 11 is not present in persistent config

# virsh dumpxml rhel7 | grep /vcpu 
  <vcpu placement='static' current='5'>10</vcpu>

# cat /var/log/libvirt/libvirtd.log  | grep error
2017-05-10 12:14:34.781+0000: 31726: error : qemuDomainVcpuValidateConfig:5909 : invalid argument: vcpu '3' can't be modified as it is followed by non-hotpluggable online vcpus

Comment 5 Peter Krempa 2017-05-12 15:50:41 UTC
Indeed, it prints the number of the vcpu following the modified vcpu.
I posted a patch:

https://www.redhat.com/archives/libvir-list/2017-May/msg00399.html

Comment 7 yalzhang@redhat.com 2017-05-24 00:24:17 UTC
Verify this bug, and the error message error will be tracked on bug 1451983.

Comment 8 errata-xmlrpc 2017-08-01 17:24:15 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-2017:1846

Comment 9 errata-xmlrpc 2017-08-02 00:03:43 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-2017:1846