Bug 1127675 - query-machines reports 'cpu-max' higher than is allowed
Summary: query-machines reports 'cpu-max' higher than is allowed
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: qemu-kvm
Version: 7.0
Hardware: x86_64
OS: Linux
low
low
Target Milestone: rc
: ---
Assignee: Radim Krčmář
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-08-07 10:33 UTC by Ján Tomko
Modified: 2014-08-28 14:55 UTC (History)
15 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of: 1092363
Environment:
Last Closed: 2014-08-28 14:55:58 UTC


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Bugzilla 1092363 None None None Never

Description Ján Tomko 2014-08-07 10:33:26 UTC
In the output of 'query-machines', qemu reports that 255 vcpus are supported in the cpu-max field, even though the maximum is 160.



+++ This bug was initially created as a clone of Bug #1092363 +++

Description:
 Virsh cmd maxvcpus returns 255 for kvm type, but the maximum number of vcpus supported by kvm is 160

Product Version:
libvirt-1.1.1-29.el7.x86_64

How producible:
Always

Steps:
1. Edit the domain with 255 vcpus
# virsh edit test-queues
 change the vcpu to 255 like <vcpu placement='static'>255</vcpu>
Domain test-queues XML configuration edited.

# virsh dumpxml test-queues | grep domain
<domain type='kvm'>

# virsh dumpxml test-queues | grep vcpu
  <vcpu placement='static'>255</vcpu>

2. Start domain
# virsh start test-queues
error: Failed to start domain test-queues
error: internal error: process exited while connecting to monitor: Warning: Number of SMP cpus requested (255) exceeds the recommended cpus supported by KVM (160)
Number of SMP cpus requested (255) exceeds the maximum cpus supported by KVM (160)

3. # virsh maxvcpus kvm
255

Actual Results:
As above shows

Expected Results:
In step 2, it is said that the maximum cpus supported by KVM (160). However, in step 3, the maxvcpus cpus for kvm printed by virsh is 255.
If the number of vcpu is larger than 160, domain can not be started, so the result of step 3 should be modified to 160.

--- Additional comment from Hu Jianwei on 2014-07-23 11:25:08 CEST ---

virsh capabilities also can hit this issue.

[root@localhost ~]# virsh capabilities 
<capabilities>

  <host>
    <uuid>00c1fcdb-9fd8-e111-852c-24be051881ce</uuid>
...(clipped)

  <guest>
    <os_type>hvm</os_type>
    <arch name='i686'>
      <wordsize>32</wordsize>
      <emulator>/usr/libexec/qemu-kvm</emulator>
      <machine canonical='pc-i440fx-rhel7.0.0' maxCpus='255'>pc</machine>
      <machine canonical='pc-q35-rhel7.0.0' maxCpus='255'>q35</machine>
      <machine maxCpus='255'>rhel6.0.0</machine>
      <machine maxCpus='255'>rhel6.1.0</machine>
      <machine maxCpus='255'>rhel6.2.0</machine>
      <machine maxCpus='255'>rhel6.3.0</machine>
      <machine maxCpus='255'>rhel6.4.0</machine>
      <machine maxCpus='255'>rhel6.5.0</machine>
      <machine maxCpus='1'>none</machine>
      <domain type='qemu'>
      </domain>
      <domain type='kvm'>
        <emulator>/usr/libexec/qemu-kvm</emulator>
      </domain>
    </arch>
    <features>
      <cpuselection/>
      <deviceboot/>
      <acpi default='on' toggle='yes'/>
      <apic default='on' toggle='no'/>
      <pae/>
      <nonpae/>
    </features>
  </guest>

  <guest>
    <os_type>hvm</os_type>
    <arch name='x86_64'>
      <wordsize>64</wordsize>
      <emulator>/usr/libexec/qemu-kvm</emulator>
      <machine canonical='pc-i440fx-rhel7.0.0' maxCpus='255'>pc</machine>
      <machine canonical='pc-q35-rhel7.0.0' maxCpus='255'>q35</machine>
      <machine maxCpus='255'>rhel6.0.0</machine>
      <machine maxCpus='255'>rhel6.1.0</machine>
      <machine maxCpus='255'>rhel6.2.0</machine>
      <machine maxCpus='255'>rhel6.3.0</machine>
      <machine maxCpus='255'>rhel6.4.0</machine>
      <machine maxCpus='255'>rhel6.5.0</machine>
      <machine maxCpus='1'>none</machine>
      <domain type='qemu'>
      </domain>
      <domain type='kvm'>
        <emulator>/usr/libexec/qemu-kvm</emulator>
      </domain>
    </arch>
    <features>
      <cpuselection/>
      <deviceboot/>
      <acpi default='on' toggle='yes'/>
      <apic default='on' toggle='no'/>
    </features>
  </guest>

</capabilities>

--- Additional comment from Jan Tomko on 2014-07-25 15:13:52 CEST ---

For 'virsh maxvcpus', libvirt gets the maximum from the kernel:
#ifdef KVM_CAP_MAX_VCPUS
    /* at first try KVM_CAP_MAX_VCPUS to determine the maximum count */
    if ((ret = ioctl(fd, KVM_CHECK_EXTENSION, KVM_CAP_MAX_VCPUS)) > 0)
        goto cleanup;
#endif /* KVM_CAP_MAX_VCPUS */

    /* as a fallback get KVM_CAP_NR_VCPUS (the recommended maximum number of
     * vcpus). Note that on most machines this is set to 160. */
    if ((ret = ioctl(fd, KVM_CHECK_EXTENSION, KVM_CAP_NR_VCPUS)) > 0)
        goto cleanup;

Upstream QEMU only reports a warning when the VCPU number exceeds the recommended number (CAP_NR_VCPUS), but QEMU in RHEL-7.0 treats the recommended number as a maximum.

A RHEL-only patch for libvirt reporting only the NR_VCPUS value will be needed.

The maxCpus values in 'virsh capabilites' come directly from QEMU's 'query-machines' command.

Comment 1 Radim Krčmář 2014-08-28 14:55:58 UTC
qemu-kvm-1.5.3-66.el7+ reports 160, some future one will do 240. (patches posted)

Before that, we had 255 because the machine type supports it, only KVM does not. The limit got lower because of TCG, so it is synchronized with CAP_NR_VCPUS now, but they aren't related.


Note You need to log in before you can comment on or make changes to this bug.