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 "virnodesuspend.h"
#include "virnuma.h"
#include "virhostcpu.h"
#include "qemu_monitor.h"
#include "virstring.h"
#include "qemu_hostdev.h"
@ -4336,16 +4337,22 @@ int
virQEMUCapsFillDomainCaps(virDomainCapsPtr domCaps,
virQEMUCapsPtr qemuCaps,
virFirmwarePtr *firmwares,
size_t nfirmwares)
size_t nfirmwares,
virDomainVirtType virttype)
{
virDomainCapsOSPtr os = &domCaps->os;
virDomainCapsDeviceDiskPtr disk = &domCaps->disk;
virDomainCapsDeviceHostdevPtr hostdev = &domCaps->hostdev;
virDomainCapsDeviceGraphicsPtr graphics = &domCaps->graphics;
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 ||
virQEMUCapsFillDomainDeviceDiskCaps(qemuCaps,

View File

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

View File

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

View File

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