Bug 725269

Summary: generated qemu -smp string is ambiguous, gives unexpected results
Product: Red Hat Enterprise Linux 6 Reporter: Cole Robinson <crobinso>
Component: libvirtAssignee: Martin Kletzander <mkletzan>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.2CC: dallan, dyuan, gren, mzhan, rwu, veillard
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-0.9.10-1.el6 Doc Type: Bug Fix
Doc Text:
No Documentation needed
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-06-20 06:29:24 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Cole Robinson 2011-07-24 22:37:14 UTC
qemu -smp 1,sockets=1,cores=2,threads=1 doesn't give the expected 2 logical cpu, dual core socket result. see https://bugzilla.redhat.com/show_bug.cgi?id=725268 for more info.

libvirt tickles this qemu weirdness by _always_ specifying the oldstyle
-smp X value, even if topology is specified. What libvirt should be doing here
is specifying _only_ topology info, provided qemu is new enough, otherwise use
the oldstyle option, so it doesn't need to depend on how qemu interprets back
compat options.

Some background: https://bugzilla.redhat.com/show_bug.cgi?id=708892#c2

Comment 3 Dave Allan 2011-11-23 20:25:26 UTC
*** Bug 725271 has been marked as a duplicate of this bug. ***

Comment 4 Martin Kletzander 2012-01-13 13:23:46 UTC
According to the documentation, the number is not ambiguous. It specifies the current number of connected (enabled) vcpus, whether not specifying the number gives the maximum amount. QEmu's weirdness is, however, that specifying more than the maximum amount connectable to the specified topology doesn't generate any error nor warning.

commit 5a89aaa9385248eceefcc982d73f063ba8232d9f
Author: Martin Kletzander <mkletzan>
Date:   Thu Jan 12 10:45:35 2012 +0100

    Added check for maximum number of vcpus exceeding topology limit
    
    Earlier, when the number of vcpus was greater than the topology allowed,
    libvirt didn't raise an error and continued, resulting in running qemu
    with parameters making no sense. Even though qemu did not report any
    error itself, the number of vcpus was set to maximum allowed by the
    topology.

Comment 8 Min Zhan 2012-02-15 06:55:36 UTC
Reproduce this bug with libvirt-0.9.9-2.el6

# virsh edit guest
...
  <vcpus>9</vcpus>
  <cpu>
    <topology sockets='2' cores='2' threads='2'/>
  </cpu>
...
# ps -ef |grep kvm
qemu     16700     1 29 05:34 ?        00:00:33 /usr/libexec/qemu-kvm -S -M rhel6.2.0 -enable-kvm -m 1024 -smp 9,sockets=2,cores=2,threads=2 -name rhel62 ......




Verified this bug with libvirt-0.9.10-1.el6
Steps:
1. virsh edit guest
...
  <vcpus>3</vcpus>
  <cpu>
    <topology sockets='2' cores='2' threads='2'/>
  </cpu>
...
# ps -ef|grep kvm
qemu     18014     1 10 05:47 ?        00:00:00 /usr/libexec/qemu-kvm -S -M rhel6.2.0 -enable-kvm -m 1024 -smp 3,sockets=2,cores=2,threads=2 -name rhel62
...

In which 3 < 2*2*2, guest can run successfully.

2. vcpu exceed the max allowed by topology, such as
# virsh edit guest
...
  <vcpus>9</vcpus>
  <cpu>
    <topology sockets='2' cores='2' threads='2'/>
  </cpu>

In which 9 > 2*2*2, when want to save the changes for the guest and quit, an error display for this cmd:

# virsh edit rhel62
error: Maximum CPUs greater than topology limit

Comment 9 Martin Kletzander 2012-05-03 13:12:56 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
No Documentation needed

Comment 11 errata-xmlrpc 2012-06-20 06:29:24 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.

http://rhn.redhat.com/errata/RHSA-2012-0748.html