Bug 1308317

Summary: libvirt check the wrong cpu placement status when change the emulator/iothreadpin configuration
Product: Red Hat Enterprise Linux 7 Reporter: Luyao Huang <lhuang>
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.2CC: rbalakri
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-1.3.3-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-11-03 18:38: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 Luyao Huang 2016-02-14 07:58:56 UTC
Description of problem:
libvirt check the wrong cpu placement status when change the emulator/iothreadpin configuration

Version-Release number of selected component (if applicable):
libvirt-1.2.17-13.el7_2.3.x86_64

How reproducible:
100%

Steps to Reproduce:
1.prepare a guest which cpu placement is auto:

# virsh dumpxml r7
...
  <vcpu placement='auto' current='1'>4</vcpu>
...

2. start it:

# virsh start r7
Domain r7 started


3. edit the inactive guest xml and change vcpu placement to static:
# virsh edit r7

  <vcpu placement='static' current='1'>4</vcpu>

Domain r7 XML configuration edited.

4. we will get failure when use iothreadpin/emulatorpin with --config:

# virsh emulatorpin r7 1 --config
error: Requested operation is not valid: Changing affinity for emulator thread dynamically is not allowed when CPU placement is 'auto'

# virsh iothreadpin r7 1 1 --config
error: Requested operation is not valid: Changing affinity for IOThread dynamically is not allowed when CPU placement is 'auto'

Actual results:
libvirt check the wrong vcpu placement status when change the emulator/iothreadpin configuration for a running guest

Expected results:

command return success on step 4

Additional info:

Comment 1 Peter Krempa 2016-03-01 09:48:57 UTC
Fixed upstream:

commit d1277de226a4f840df0c20a9931a2c009b505d25
Author: Peter Krempa <pkrempa>
Date:   Wed Feb 24 14:40:51 2016 +0100

    qemu: Allow setting pinning of emulator/iohtread with automatic placement
    
    We honour the placement bitmaps when starting up, so there's no point in
    having this check. Additionally the check was buggy since it checked
    vm->def all the time even if the user requested to modify the persistent
    definition which had different configuration.
    
    Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1308317

v1.3.2-4-gd1277de

Comment 2 Mike McCune 2016-03-28 23:19:36 UTC
This bug was accidentally moved from POST to MODIFIED via an error in automation, please see mmccune with any questions

Comment 4 Luyao Huang 2016-08-09 02:27:02 UTC
Verify this bug with libvirt-2.0.0-4.el7.x86_64:

1. prepare a guest with auto placement vcpu element

# virsh dumpxml r7
..
  <vcpu placement='auto' current='6'>10</vcpu>
  <numatune>
    <memory mode='strict' placement='auto'/>
  </numatune>
..

2. start guest

# virsh start r7
Domain r7 started

3. check iothread, vcpupin, emulatorpin:

# virsh vcpupin r7
VCPU: CPU Affinity
----------------------------------
   0: 0,2,4,6,8,10,12,14,16,18,20,22
   1: 0,2,4,6,8,10,12,14,16,18,20,22
   2: 0,2,4,6,8,10,12,14,16,18,20,22
   3: 0,2,4,6,8,10,12,14,16,18,20,22
   4: 0,2,4,6,8,10,12,14,16,18,20,22
   5: 0,2,4,6,8,10,12,14,16,18,20,22
   6: 0,2,4,6,8,10,12,14,16,18,20,22
   7: 0,2,4,6,8,10,12,14,16,18,20,22
   8: 0,2,4,6,8,10,12,14,16,18,20,22
   9: 0,2,4,6,8,10,12,14,16,18,20,22

# virsh emulatorpin r7
emulator: CPU Affinity
----------------------------------
       *: 0,2,4,6,8,10,12,14,16,18,20,22

# virsh iothreadinfo r7
 IOThread ID     CPU Affinity   
---------------------------------------------------
 1               0,2,4,6,8,10,12,14,16,18,20,22

4. live change the bind:

# virsh vcpupin r7 0 1-10

# virsh vcpupin r7
VCPU: CPU Affinity
----------------------------------
   0: 1-10
   1: 0,2,4,6,8,10,12,14,16,18,20,22
   2: 0,2,4,6,8,10,12,14,16,18,20,22
   3: 0,2,4,6,8,10,12,14,16,18,20,22
   4: 0,2,4,6,8,10,12,14,16,18,20,22
   5: 0,2,4,6,8,10,12,14,16,18,20,22
   6: 0,2,4,6,8,10,12,14,16,18,20,22
   7: 0,2,4,6,8,10,12,14,16,18,20,22
   8: 0,2,4,6,8,10,12,14,16,18,20,22
   9: 0,2,4,6,8,10,12,14,16,18,20,22

# virsh emulatorpin r7
emulator: CPU Affinity
----------------------------------
       *: 0,2,4,6,8,10,12,14,16,18,20,22

# virsh emulatorpin r7 0-23

# virsh emulatorpin r7
emulator: CPU Affinity
----------------------------------
       *: 0-23

# virsh iothreadpin r7 1 1

# virsh iothreadinfo r7
 IOThread ID     CPU Affinity   
---------------------------------------------------
 1               1


5. change config for a running guest:

# virsh emulatorpin r7 20 --config

# virsh emulatorpin r7 --config
emulator: CPU Affinity
----------------------------------
       *: 20

# virsh vcpupin r7 1 0 --config 

# virsh vcpupin r7 1 --config 
VCPU: CPU Affinity
----------------------------------
   1: 0

# virsh iothreadpin r7 1 0 --config

# virsh iothreadinfo r7 --config
 IOThread ID     CPU Affinity   
---------------------------------------------------
 1               0

Comment 6 errata-xmlrpc 2016-11-03 18:38:26 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