Bug 1099836

Summary: the vcpupin info is not sync with the qemu process after hot-unplug and hot-plug vcpus
Product: Red Hat Enterprise Linux 6 Reporter: Xuesong Zhang <xuzhang>
Component: libvirtAssignee: Ján Tomko <jtomko>
Status: CLOSED WONTFIX QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.6CC: acathrow, dyuan, honzhang, jmiao, mzhan
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-06-02 16:01:26 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 Xuesong Zhang 2014-05-21 10:22:26 UTC
Description of problem:
Pin all the vcpus of guest to specific host cpu, hot-unplug some vcpus, hot-plug the vcpus back,
the vcpupin info is not sync with the info of qemu process.

Version-Release number of selected component (if applicable):
libvirt-0.10.2-36.el6.x86_64
qemu-kvm-rhev-0.12.1.2-2.426.el6.x86_64
kernel-2.6.32-466.el6.x86_64

How reproducible:
100%

Steps to Reproduce:
1. prepare one guest, let all the vcpus are pinned to some host cpus, such as the following one:
# virsh dumpxml rhel6.5|grep cpu
  <vcpu placement='static'>4</vcpu>
  <cputune>
    <vcpupin vcpu='0' cpuset='1'/>
    <vcpupin vcpu='1' cpuset='1'/>
    <vcpupin vcpu='2' cpuset='1'/>
    <vcpupin vcpu='3' cpuset='1'/>
  </cputune>

2. start the guest
# virsh start rhel6.5
Domain rhel6.5 started

3. check pid the qemu process, make sure all the vcpus are all pinned to the host cpu.
# ps -ef|grep qemu
qemu      3961     1 75 04:15 ?        00:00:21 /usr/libexec/qemu-kvm -name rhel6.5 
......
# grep Cpus_allowed_list /proc/3961/task/*/status
/proc/3961/task/3961/status:Cpus_allowed_list:        0-3
/proc/3961/task/3982/status:Cpus_allowed_list:        0-3
/proc/3961/task/3983/status:Cpus_allowed_list:        1
/proc/3961/task/3984/status:Cpus_allowed_list:        1
/proc/3961/task/3985/status:Cpus_allowed_list:        1
/proc/3961/task/3986/status:Cpus_allowed_list:        1


4. all the vcpus are all pinned to one host cpu.
# virsh vcpupin rhel6.5
VCPU: CPU Affinity
----------------------------------
   0: 1
   1: 1
   2: 1
   3: 1

5. hot-unplug vcpus
# virsh setvcpus rhel6.5 2

# virsh vcpupin rhel6.5
VCPU: CPU Affinity
----------------------------------
   0: 1
   1: 1


6. hot-plug the vcpus back
# virsh setvcpus rhel6.5 4

7. check the vcpupin info, the new hot-plugged vcpus are pinned to all the host cpus.
# virsh vcpupin rhel6.5
VCPU: CPU Affinity
----------------------------------
   0: 1
   1: 1
   2: 0-3
   3: 0-3

8, check the qemu proces, the new hot-plugged vcpus are still pinned to the host CPU1
# grep Cpus_allowed_list /proc/3961/task/*/status
/proc/3961/task/3961/status:Cpus_allowed_list:        0-3
/proc/3961/task/3982/status:Cpus_allowed_list:        0-3
/proc/3961/task/3983/status:Cpus_allowed_list:        1
/proc/3961/task/3984/status:Cpus_allowed_list:        1
/proc/3961/task/3985/status:Cpus_allowed_list:        1



Actually results:
As step7 and 8, the step7 shows that the new hot-plugged vcpu are pinned to all host cpus, but the step 8 shows that the new hot-plugged vcpu are still pinned to the host CPU1.

Expected results:
The vcpu pinned info should be kept same in step 7 and 8.

Comment 1 Ján Tomko 2014-05-23 12:39:09 UTC
Patch sent upstream:
https://www.redhat.com/archives/libvir-list/2014-May/msg00836.html

Comment 2 Ján Tomko 2014-06-02 16:01:26 UTC
This is just a cosmetic issue (pinning the re-plugged vcpus manually works) and I don't think it's worth fixing.
Upstream QEMU doesn't support hot-unplug of VCPUs, so the proposed patch is not as useful (and it made assumptions about QEMU behavior that might not be true when hot-unplug will be supported).

Also, hot-unplugging pinned vcpus would crash libvirtd until recently (bug 1088165) and vcpu hot-unplug does not seem to be supported in RHEL6: https://bugzilla.redhat.com/show_bug.cgi?id=1088216#c8