The qemu limit and host limit both should be considered for
the domain vcpu max limits.
Signed-off-by: Shivaprasad G Bhat <sbhat(a)linux.vnet.ibm.com>
---
src/qemu/qemu_capabilities.c | 11 ++++++++---
src/qemu/qemu_capabilities.h | 3 ++-
src/qemu/qemu_driver.c | 2 +-
tests/domaincapstest.c | 3 ++-
4 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 01466fc..ff5ad19 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -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,20 @@ 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();
+ domCaps->maxvcpus = MIN(domCaps->maxvcpus, hostmaxvcpus);
+ }
if (virQEMUCapsFillDomainOSCaps(os, firmwares, nfirmwares) < 0 ||
virQEMUCapsFillDomainDeviceDiskCaps(qemuCaps,
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index affb639..9d891c8 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -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__*/
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 4e6e4c9..59b657b 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -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);
diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c
index ae31146..01ebfcc 100644
--- a/tests/domaincapstest.c
+++ b/tests/domaincapstest.c
@@ -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