qemu: check the kvm host cpu max limits in virConnectGetDomainCapabilities

The qemu limit and host limit both should be considered for
the domain vcpu max limits.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
This commit is contained in:
Shivaprasad G Bhat 2016-06-24 20:34:13 +05:30 committed by Andrea Bolognani
parent c6910bd4c7
commit 8dbb347816
4 changed files with 15 additions and 6 deletions

View File

@ -38,6 +38,7 @@
#include "virbitmap.h" #include "virbitmap.h"
#include "virnodesuspend.h" #include "virnodesuspend.h"
#include "virnuma.h" #include "virnuma.h"
#include "virhostcpu.h"
#include "qemu_monitor.h" #include "qemu_monitor.h"
#include "virstring.h" #include "virstring.h"
#include "qemu_hostdev.h" #include "qemu_hostdev.h"
@ -4336,16 +4337,22 @@ int
virQEMUCapsFillDomainCaps(virDomainCapsPtr domCaps, virQEMUCapsFillDomainCaps(virDomainCapsPtr domCaps,
virQEMUCapsPtr qemuCaps, virQEMUCapsPtr qemuCaps,
virFirmwarePtr *firmwares, virFirmwarePtr *firmwares,
size_t nfirmwares) size_t nfirmwares,
virDomainVirtType virttype)
{ {
virDomainCapsOSPtr os = &domCaps->os; virDomainCapsOSPtr os = &domCaps->os;
virDomainCapsDeviceDiskPtr disk = &domCaps->disk; virDomainCapsDeviceDiskPtr disk = &domCaps->disk;
virDomainCapsDeviceHostdevPtr hostdev = &domCaps->hostdev; virDomainCapsDeviceHostdevPtr hostdev = &domCaps->hostdev;
virDomainCapsDeviceGraphicsPtr graphics = &domCaps->graphics; virDomainCapsDeviceGraphicsPtr graphics = &domCaps->graphics;
virDomainCapsDeviceVideoPtr video = &domCaps->video; virDomainCapsDeviceVideoPtr video = &domCaps->video;
int maxvcpus = virQEMUCapsGetMachineMaxCpus(qemuCaps, domCaps->machine);
domCaps->maxvcpus = maxvcpus; domCaps->maxvcpus = virQEMUCapsGetMachineMaxCpus(qemuCaps,
domCaps->machine);
if (virttype == VIR_DOMAIN_VIRT_KVM) {
int hostmaxvcpus = virHostCPUGetKVMMaxVCPUs();
if (hostmaxvcpus >= 0)
domCaps->maxvcpus = MIN(domCaps->maxvcpus, hostmaxvcpus);
}
if (virQEMUCapsFillDomainOSCaps(os, firmwares, nfirmwares) < 0 || if (virQEMUCapsFillDomainOSCaps(os, firmwares, nfirmwares) < 0 ||
virQEMUCapsFillDomainDeviceDiskCaps(qemuCaps, virQEMUCapsFillDomainDeviceDiskCaps(qemuCaps,

View File

@ -492,6 +492,7 @@ int virQEMUCapsInitGuestFromBinary(virCapsPtr caps,
int virQEMUCapsFillDomainCaps(virDomainCapsPtr domCaps, int virQEMUCapsFillDomainCaps(virDomainCapsPtr domCaps,
virQEMUCapsPtr qemuCaps, virQEMUCapsPtr qemuCaps,
virFirmwarePtr *firmwares, virFirmwarePtr *firmwares,
size_t nfirmwares); size_t nfirmwares,
virDomainVirtType virttype);
#endif /* __QEMU_CAPABILITIES_H__*/ #endif /* __QEMU_CAPABILITIES_H__*/

View File

@ -18475,7 +18475,7 @@ qemuConnectGetDomainCapabilities(virConnectPtr conn,
goto cleanup; goto cleanup;
if (virQEMUCapsFillDomainCaps(domCaps, qemuCaps, if (virQEMUCapsFillDomainCaps(domCaps, qemuCaps,
cfg->firmwares, cfg->nfirmwares) < 0) cfg->firmwares, cfg->nfirmwares, virttype) < 0)
goto cleanup; goto cleanup;
ret = virDomainCapsFormat(domCaps); ret = virDomainCapsFormat(domCaps);

View File

@ -129,7 +129,8 @@ fillQemuCaps(virDomainCapsPtr domCaps,
if (virQEMUCapsFillDomainCaps(domCaps, qemuCaps, if (virQEMUCapsFillDomainCaps(domCaps, qemuCaps,
cfg->firmwares, cfg->firmwares,
cfg->nfirmwares) < 0) cfg->nfirmwares,
VIR_DOMAIN_VIRT_QEMU) < 0)
goto cleanup; goto cleanup;
/* The function above tries to query host's KVM & VFIO capabilities by /* The function above tries to query host's KVM & VFIO capabilities by