Amit Shah wrote:
kvm_set_cpuid2() builds on top of kvm_set_cpuid() and correctly populates
cpuid functions that have sub-leaves.

Signed-off-by: Amit Shah <[email protected]>
---
 libkvm/libkvm-x86.c |   18 ++++++++++++++++++
 libkvm/libkvm.h     |   16 ++++++++++++++++
 2 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/libkvm/libkvm-x86.c b/libkvm/libkvm-x86.c
index a8cca15..93a9c4e 100644
--- a/libkvm/libkvm-x86.c
+++ b/libkvm/libkvm-x86.c
@@ -475,6 +475,24 @@ int kvm_setup_cpuid(kvm_context_t kvm, int vcpu, int nent,
        return r;
 }
+int kvm_setup_cpuid2(kvm_context_t kvm, int vcpu, int nent,
+                    struct kvm_cpuid_entry2 *entries)
+{
+       struct kvm_cpuid2 *cpuid;
+       int r;
+
+       cpuid = malloc(sizeof(*cpuid) + nent * sizeof(*entries));
+       if (!cpuid)
+               return -ENOMEM;
+
+       cpuid->nent = nent;
+       memcpy(cpuid->entries, entries, nent * sizeof(*entries));
+       r = ioctl(kvm->vcpu_fd[vcpu], KVM_SET_CPUID2, cpuid);
+
+       free(cpuid);
+       return r;
+}

Should return -errno, not -EPERM, if the ioctl fails.


--
error compiling committee.c: too many arguments to function

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to