Bug 1375920

Summary: libvirt show wrong vcpuinfo for a inactive guest with hotpluggable vcpu
Product: Red Hat Enterprise Linux 7 Reporter: Luyao Huang <lhuang>
Component: libvirtAssignee: Peter Krempa <pkrempa>
Status: CLOSED ERRATA QA Contact: Jingjing Shao <jishao>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.3CC: dyuan, jdenemar, pkrempa, rbalakri, xuzhang
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-2.5.0-1.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-01 17:16:43 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-09-14 09:01:59 UTC
Description of problem:
libvirt show wrong vcpuinfo for a inactive guest with hotpluggable vcpu

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

How reproducible:
100%

Steps to Reproduce:
1. prepare guest xml like this:

# virsh dumpxml r7
...
  <vcpu placement='static' current='4'>10</vcpu>
  <vcpus>
    <vcpu id='0' enabled='yes' hotpluggable='no' order='1'/>
    <vcpu id='1' enabled='yes' hotpluggable='yes' order='4'/>
    <vcpu id='2' enabled='no' hotpluggable='yes'/>
    <vcpu id='3' enabled='no' hotpluggable='yes'/>
    <vcpu id='4' enabled='yes' hotpluggable='yes' order='3'/>
    <vcpu id='5' enabled='no' hotpluggable='yes'/>
    <vcpu id='6' enabled='yes' hotpluggable='yes' order='2'/>
    <vcpu id='7' enabled='no' hotpluggable='yes'/>
    <vcpu id='8' enabled='no' hotpluggable='yes'/>
    <vcpu id='9' enabled='no' hotpluggable='yes'/>
  </vcpus>
  <cputune>
    <vcpupin vcpu='0' cpuset='0'/>
    <vcpupin vcpu='1' cpuset='1'/>
    <vcpupin vcpu='2' cpuset='2'/>
    <vcpupin vcpu='3' cpuset='3'/>
    <vcpupin vcpu='4' cpuset='4'/>
    <vcpupin vcpu='5' cpuset='5'/>
    <vcpupin vcpu='6' cpuset='6'/>
    <vcpupin vcpu='7' cpuset='7'/>
    <vcpupin vcpu='8' cpuset='8'/>
    <vcpupin vcpu='9' cpuset='9'/>
  </cputune>
...

2. check inactive vcpuinfo:

# virsh vcpuinfo r7
VCPU:           0
CPU:            N/A
State:          N/A
CPU time        N/A
CPU Affinity:   y-----------------------

VCPU:           1
CPU:            N/A
State:          N/A
CPU time        N/A
CPU Affinity:   -y----------------------

VCPU:           2
CPU:            N/A
State:          N/A
CPU time        N/A
CPU Affinity:   --y---------------------

VCPU:           3
CPU:            N/A
State:          N/A
CPU time        N/A
CPU Affinity:   ---y--------------------


3.

Actual results:

# virsh vcpuinfo r7
VCPU:           0
CPU:            N/A
State:          N/A
CPU time        N/A
CPU Affinity:   y-----------------------

VCPU:           1
CPU:            N/A
State:          N/A
CPU time        N/A
CPU Affinity:   -y----------------------

VCPU:           2
CPU:            N/A
State:          N/A
CPU time        N/A
CPU Affinity:   --y---------------------

VCPU:           3
CPU:            N/A
State:          N/A
CPU time        N/A
CPU Affinity:   ---y--------------------


Expected results:

# virsh vcpuinfo r7
VCPU:           0
CPU:            N/A
State:          N/A
CPU time        N/A
CPU Affinity:   y-----------------------

VCPU:           1
CPU:            N/A
State:          N/A
CPU time        N/A
CPU Affinity:   -y----------------------

VCPU:           4
CPU:            N/A
State:          N/A
CPU time        N/A
CPU Affinity:   ----y-------------------

VCPU:           6
CPU:            N/A
State:          N/A
CPU time        N/A
CPU Affinity:   ------y-----------------


Additional info:

Comment 1 Peter Krempa 2016-10-12 15:31:56 UTC
Fixed upstream:

commit a62655f9c33a8f7c6257779ddbdbf1352d53a526
Author: Peter Krempa <pkrempa>
Date:   Tue Oct 11 18:03:50 2016 +0200

    virsh: vcpuinfo: Report proper vcpu numbers and data for offline VMs
    
    If the VM is offline virsh attempted to at least report the pinning
    information for the VM. This would not work properly now that the vcpus
    can be sparse. Fix it by getting the vcpu states from the XML.

Comment 3 Jingjing Shao 2016-12-26 11:56:00 UTC
Verified this issue and get the expected result. 

# rpm -q libvirt
libvirt-2.5.0-1.el7.x86_64

# virsh dumpxml rhel7.3
<domain type='kvm'>
  <name>rhel7.3</name>
  <uuid>a7b9969c-ef22-4b8b-90aa-28b5e655dff4</uuid>
  <memory unit='KiB'>1048576</memory>
  <currentMemory unit='KiB'>1048576</currentMemory>
  <vcpu placement='static' current='4'>10</vcpu>
  <vcpus>
    <vcpu id='0' enabled='yes' hotpluggable='no' order='1'/>
    <vcpu id='1' enabled='yes' hotpluggable='yes' order='4'/>
    <vcpu id='2' enabled='no' hotpluggable='yes'/>
    <vcpu id='3' enabled='no' hotpluggable='yes'/>
    <vcpu id='4' enabled='yes' hotpluggable='yes' order='3'/>
    <vcpu id='5' enabled='no' hotpluggable='yes'/>
    <vcpu id='6' enabled='yes' hotpluggable='yes' order='2'/>
    <vcpu id='7' enabled='no' hotpluggable='yes'/>
    <vcpu id='8' enabled='no' hotpluggable='yes'/>
    <vcpu id='9' enabled='no' hotpluggable='yes'/>
  </vcpus>
  <cputune>
    <vcpupin vcpu='0' cpuset='0'/>
    <vcpupin vcpu='1' cpuset='1'/>
    <vcpupin vcpu='2' cpuset='2'/>
    <vcpupin vcpu='3' cpuset='3'/>
    <vcpupin vcpu='4' cpuset='4'/>
    <vcpupin vcpu='5' cpuset='5'/>
    <vcpupin vcpu='6' cpuset='6'/>
    <vcpupin vcpu='7' cpuset='7'/>
    <vcpupin vcpu='8' cpuset='8'/>
    <vcpupin vcpu='9' cpuset='9'/>
  </cputune>
.....

# virsh vcpuinfo rhel7.3
VCPU:           0
CPU:            N/A
State:          N/A
CPU time        N/A
CPU Affinity:   y---------------------------------------------------------------

VCPU:           1
CPU:            N/A
State:          N/A
CPU time        N/A
CPU Affinity:   -y--------------------------------------------------------------

VCPU:           4
CPU:            N/A
State:          N/A
CPU time        N/A
CPU Affinity:   ----y-----------------------------------------------------------

VCPU:           6
CPU:            N/A
State:          N/A
CPU time        N/A
CPU Affinity:   ------y---------------------------------------------------------

Comment 4 errata-xmlrpc 2017-08-01 17:16: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

Comment 5 errata-xmlrpc 2017-08-01 23:57:38 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