[PATCH REPOST 1/3] util: hostcpu: Add virHostCPUGetKVMMaxVCPUs() stub

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

 



If we don't HAVE_LINUX_KVM_H, we can't query /dev/kvm to discover
the limits on the number of vCPUs, so we report an error and
return a negative value instead.
---
 src/util/virhostcpu.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c
index 4ff4e72..a33932f 100644
--- a/src/util/virhostcpu.c
+++ b/src/util/virhostcpu.c
@@ -1299,6 +1299,7 @@ virHostCPUGetThreadsPerSubcore(virArch arch ATTRIBUTE_UNUSED)
 
 #endif /* HAVE_LINUX_KVM_H && defined(KVM_CAP_PPC_SMT) */
 
+#if HAVE_LINUX_KVM_H
 int
 virHostCPUGetKVMMaxVCPUs(void)
 {
@@ -1310,11 +1311,11 @@ virHostCPUGetKVMMaxVCPUs(void)
         return -1;
     }
 
-#ifdef KVM_CAP_MAX_VCPUS
+# 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 */
+# 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. */
@@ -1329,3 +1330,12 @@ virHostCPUGetKVMMaxVCPUs(void)
     VIR_FORCE_CLOSE(fd);
     return ret;
 }
+#else
+int
+virHostCPUGetKVMMaxVCPUs(void)
+{
+    virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                   _("KVM is not supported on this platform"));
+    return -1;
+}
+#endif /* HAVE_LINUX_KVM_H */
-- 
2.7.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]