From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: [PATCH 1/2] kvm: libkvm: Add a wrapper for an ioctl for the KVM_SET_CPUID2 interface Date: Wed, 14 Jan 2009 16:52:12 +0200 Message-ID: <496DFC1C.4010004@redhat.com> References: <1231843674-11333-1-git-send-email-amit.shah@redhat.com> <1231843674-11333-2-git-send-email-amit.shah@redhat.com> <1231843674-11333-3-git-send-email-amit.shah@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org To: Amit Shah Return-path: Received: from mx2.redhat.com ([66.187.237.31]:38203 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750952AbZANOwP (ORCPT ); Wed, 14 Jan 2009 09:52:15 -0500 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n0EEqFAk021645 for ; Wed, 14 Jan 2009 09:52:15 -0500 In-Reply-To: <1231843674-11333-3-git-send-email-amit.shah@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: 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 > --- > 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