Bug 1584091

Summary: libvirt: vpx:// driver does not accept a number of vCPUs when it is not 1 or a multiple of 2
Product: Red Hat Enterprise Linux 7 Reporter: mxie <mxie>
Component: libvirtAssignee: Pino Toscano <ptoscano>
Status: CLOSED ERRATA QA Contact: mxie <mxie>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.6CC: dyuan, juzhou, lmen, mzhan, ptoscano, rjones, tzheng, xiaodwan, xuzhang
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-4.5.0-1.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-10-30 09:55: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:
Attachments:
Description Flags
singular-cpus.vmx none

Description mxie@redhat.com 2018-05-30 09:13:48 UTC
Created attachment 1445733 [details]
singular-cpus.vmx

Description of problem:
Libvirt: vpx:// driver can not get CPU topology from vmware when guest's cpu num is singular

Version-Release number of selected component (if applicable):
libvirt-4.3.0-1.el7.x86_64
qemu-kvm-rhev-2.12.0-2.el7.x86_64


How reproducible:
100%

Steps to Reproduce:
1. Set 1 sockets and 7 core for guest's cpu on vmware host

2. Use virsh to check guest's cpu topology
# virsh -c vpx://root.75.182/data/10.73.3.19/?no_verify=1
Enter root's password for 10.73.75.182: 
Welcome to virsh, the virtualization interactive terminal.

Type:  'help' for help with commands
       'quit' to quit
virsh # dumpxml esx5.5-win2016-x86_64
error: internal error: Expecting VMX entry 'numvcpus' to be an unsigned integer (1 or a multiple of 2) but found 7


Actual results:
As above description

Expected results:
Libvirt: vpx:// driver can get CPU topology from vmware when guest's cpu num is singular

Additional info:

Comment 2 Richard W.M. Jones 2018-05-30 09:17:34 UTC
https://libvirt.org/git/?p=libvirt.git;a=blob;f=src/vmx/vmx.c;h=bdc27b15b0f44fac837e5658f788be679cacceb6;hb=HEAD#l1509

I've no idea why this check is there, but it seems reasonable
to just remove it.  I'll post a patch shortly.

Comment 3 Pino Toscano 2018-05-30 09:21:31 UTC
Copying my comments from bug 1568148 comment 21:

It looks like the limitation of numvcpus to be 1 or a multiple of 2 was part of the initial commit of the VMX parser, in 2009. Not sure why it was added in the first place, and since the VMX file format is proprietary of VMware, I have no idea whether removing the limitation might break anything.

I just wrote to libvir-list, and to the author of the VMX parser asking for more details:
https://www.redhat.com/archives/libvir-list/2018-May/msg02159.html

Comment 4 Richard W.M. Jones 2018-05-30 09:34:55 UTC
Pino's question:

https://www.redhat.com/archives/libvir-list/2018-May/msg02159.html

My patch which just removes the test:

https://www.redhat.com/archives/libvir-list/2018-May/msg02160.html

Comment 5 Pino Toscano 2018-06-22 08:53:48 UTC
Fixed upstream with:

commit c92b6023e8eb670e01571e299a85e9da9bd4844c
Author:     Pino Toscano <ptoscano>
AuthorDate: Thu Jun 14 15:34:25 2018 +0200
Commit:     Jiri Denemark <jdenemar>
CommitDate: Fri Jun 22 10:37:24 2018 +0200

    vmx: allow an odd number of vCPUs
    
    Most probably this was a limitation in older ESX versions, and it seems
    it does not exist anymore in more recent versions; see the following
    thread:
    https://www.redhat.com/archives/libvir-list/2018-May/msg02159.html
    https://www.redhat.com/archives/libvir-list/2018-June/msg00043.html
    
    Hence, allow an odd number (greater than 1) of vCPUs, since most
    probably older versions of ESXi will error out anyway.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1584091
    
    Signed-off-by: Pino Toscano <ptoscano>
    Reviewed-by: Jiri Denemark <jdenemar>

Comment 7 mxie@redhat.com 2018-07-23 07:23:31 UTC
Verify the bug with builds:
libvirt-4.5.0-3.el7.x86_64
qemu-kvm-rhev-2.12.0-7.el7.x86_64


Steps:
Scenario1:
1.1 Set 7 sockets and 1 core in guest's cpu topology on ESXi6.7 host
1.2 Use virsh to check guest's cpu topology

# virsh -c vpx://root.73.141/data/10.73.75.219/?no_verify=1
Enter root's password for 10.73.73.141: 
Welcome to virsh, the virtualization interactive terminal.

Type:  'help' for help with commands
       'quit' to quit

virsh # dumpxml esx6.7-win2008r2-x86_64
....
  <vcpu placement='static'>7</vcpu>
....

Scenario2
2.1 Set 3 sockets and 3 cores in guest's cpu topology on ESXi6.7 host
2.2 Use virsh to check guest's cpu topology
virsh # dumpxml esx6.7-win2008r2-x86_64
....
  <cpu>
    <topology sockets='3' cores='3' threads='1'/>
  </cpu>
....

Scenario3:
3.1 Set 1 sockets and 5 cores in guest's cpu topology on ESXi6.7 host
3.2 Use virsh to check guest's cpu topology
virsh # dumpxml esx6.7-win2008r2-x86_64
....
  <cpu>
    <topology sockets='1' cores='5' threads='1'/>
  </cpu>
....

Result:
    Scenario1's problem has bug1590079 to be tracked, libvirt: vpx:// driver has accepted a number of vCPUs when it is not 1 or a multiple of 2 according to scenario2 and sceanrio3, so move the bug from ON_QA to VERIFIED

Comment 9 errata-xmlrpc 2018-10-30 09:55: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://access.redhat.com/errata/RHSA-2018:3113