[PATCH 3/7] virHostCPUGetCPUID: Add comment on how KVM_GET_SUPPORTED_CPUID works

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

 



The commit adding the code fetching host CPU flags via the
KVM_GET_SUPPORTED_CPUID didn't describe at all why such an alghorithm is
needed.

Add a comment from the documentation outlining how the userspace
function is expected to allocate memory here.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/util/virhostcpu.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c
index 011ef8a153..6be00a5b76 100644
--- a/src/util/virhostcpu.c
+++ b/src/util/virhostcpu.c
@@ -1327,6 +1327,13 @@ virHostCPUGetCPUID(void)
         return NULL;
     }

+    /* Userspace invokes KVM_GET_SUPPORTED_CPUID by passing a kvm_cpuid2 structure
+     * with the 'nent' field indicating the number of entries in the variable-size
+     * array 'entries'.  If the number of entries is too low to describe the cpu
+     * capabilities, an error (E2BIG) is returned.  If the number is too high,
+     * the 'nent' field is adjusted and an error (ENOMEM) is returned.  If the
+     * number is just right, the 'nent' field is adjusted to the number of valid
+     * entries in the 'entries' array, which is then filled. */
     for (i = 1; i < INT32_MAX; i *= 2) {
         g_autofree struct kvm_cpuid2 *kvm_cpuid = NULL;
         kvm_cpuid = g_malloc0(sizeof(struct kvm_cpuid2) +
-- 
2.35.1




[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]

  Powered by Linux