[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] ppc64: get the maxvcpus from the qemu caps instead of /dev/kvm



On PPC64, the KVM_MAX_VCPUS is defined to be 1024 where as qemu has
MAX_CPUMASK_BITS defined at 255 in include/sysemu/sysemu.h.

virsh domacapabilities and virsh maxvcpus --type kvm return different
maxvcpus values and is confusing as to know what actually works.

Signed-off-by: Shivaprasad G Bhat <sbhat linux vnet ibm com>
---
 src/qemu/qemu_driver.c |   28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 3d0c7c8..d84fc47 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -1255,10 +1255,34 @@ static int qemuConnectIsAlive(virConnectPtr conn ATTRIBUTE_UNUSED)
 
 
 static int
-kvmGetMaxVCPUs(void)
+kvmGetMaxVCPUs(virConnectPtr conn)
 {
     int fd;
     int ret;
+    virArch arch = virArchFromHost();
+    virQEMUCapsPtr qemuCaps = NULL;
+    virQEMUDriverPtr driver = conn->privateData;
+
+    const char *machine;
+
+    if (ARCH_IS_PPC64(arch)) {
+        if (!(qemuCaps = virQEMUCapsCacheLookupByArch(driver->qemuCapsCache,
+                                                      arch))) {
+            virReportError(VIR_ERR_INVALID_ARG,
+                           _("unable to find any emulator to serve '%s' "
+                             "architecture"), virArchToString(arch));
+            return -1;
+        }
+
+        if (!(machine = virQEMUCapsGetDefaultMachine(qemuCaps))) {
+            virObjectUnref(qemuCaps);
+            return -1;
+        }
+
+        ret = virQEMUCapsGetMachineMaxCpus(qemuCaps, machine);
+        virObjectUnref(qemuCaps);
+        return ret;
+    }
 
     if ((fd = open(KVM_DEVICE, O_RDONLY)) < 0) {
         virReportSystemError(errno, _("Unable to open %s"), KVM_DEVICE);
@@ -1323,7 +1347,7 @@ qemuConnectGetMaxVcpus(virConnectPtr conn ATTRIBUTE_UNUSED, const char *type)
         return 16;
 
     if (STRCASEEQ(type, "kvm"))
-        return kvmGetMaxVCPUs();
+        return kvmGetMaxVCPUs(conn);
 
     if (STRCASEEQ(type, "kqemu"))
         return 1;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]