Bug 1370066

Summary: Use setvcpus to change maximum vcpu number 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: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.3CC: dyuan, mkolaja, pkrempa, rbalakri
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: libvirt-2.0.0-7.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-11-03 18:53:54 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-08-25 08:42:32 UTC
Description of problem:
Use setvcpus to change maximum vcpu number will make guest have broken settings

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

How reproducible:
100%

Steps to Reproduce:
1. prepare a guest which have vcpu topology
# virsh dumpxml r7
...
  <vcpu placement='static' current='1'>12</vcpu>
...
    <topology sockets='3' cores='2' threads='2'/>
...


2. change guest maximum vcpu:

# virsh setvcpus r7 13 --config --maximum


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'

libvirtd log:
journal: Maximum CPUs greater than topology limit


Actual results:
Use setvcpus to change maximum vcpu number will make guest have broken settings and guest disappear after restart libvirtd

Expected results:
report error when change maximum vcpu number

Additional info:

Comment 1 Peter Krempa 2016-08-26 15:39:17 UTC
Fixed upstream:

commit 802fac97ec8c8bd5438ec5bcd4d13edb03b00fc2
Author: Peter Krempa <pkrempa>
Date:   Thu Aug 25 15:30:21 2016 -0400

    qemu: driver: Validate configuration when setting maximum vcpu count
    
    Setting vcpu count when cpu topology is specified may result into an
    invalid configuration. Since the topology can't be modified, reject the
    setting if it doesn't match the requested topology. This will allow
    fixing the topology in case it was broken.
    
    Partially fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1370066

commit c9cb35c255222be7c972f1e049e297517aa84b42
Author: Peter Krempa <pkrempa>
Date:   Thu Aug 25 15:24:22 2016 -0400

    conf: Don't validate vcpu count in XML parser
    
    Validating the vcpu count is more intricate and doing it in the XML
    parser will make previously valid configs (with older qemus) vanish.
    
    Now that we have a very similar check in the qemu domain validation
    callback we can do it in a more appropriate place.
    
    This basically reverts commit b54de0830a.
    
    Partially resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1370066

Comment 4 Luyao Huang 2016-09-22 02:46:15 UTC
Verify this bug with libvirt-2.0.0-10.el7.x86_64:

1. 
# virsh dumpxml r7
...
<vcpu placement='static' current='4'>12</vcpu>
...
<topology sockets='2' cores='3' threads='2'/>
...

2. 

# virsh setvcpus r7 13 --config --maximum
error: invalid argument: CPU topology doesn't match the desired vcpu count

3.

# virsh setvcpus r7 11 --config --maximum
error: invalid argument: CPU topology doesn't match the desired vcpu count

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