Message ID | 1398779573-18825-2-git-send-email-cornelia.huck@de.ibm.com |
---|---|
State | New |
Headers | show |
On 29.04.14 15:52, Cornelia Huck wrote: > Provide helper functions for enabling capabilities (on a vcpu and on a vm). > > Reviewed-by: Thomas Huth <thuth@linux.vnet.ibm.com> > Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com> > --- > include/sysemu/kvm.h | 28 ++++++++++++++++++++++++++++ > 1 file changed, 28 insertions(+) > > diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h > index 0bee1e8..02a9f7a 100644 > --- a/include/sysemu/kvm.h > +++ b/include/sysemu/kvm.h > @@ -294,6 +294,34 @@ bool kvm_arch_stop_on_emulation_error(CPUState *cpu); > > int kvm_check_extension(KVMState *s, unsigned int extension); > > +#define kvm_enable_cap_vm(s, capability, ...) \ Please use the existing word ordering - kvm_vm_enable_cap(). And I think it makes sense to pass through "flags" as well. Otherwise I like the patch set :). Alex
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index 0bee1e8..02a9f7a 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -294,6 +294,34 @@ bool kvm_arch_stop_on_emulation_error(CPUState *cpu); int kvm_check_extension(KVMState *s, unsigned int extension); +#define kvm_enable_cap_vm(s, capability, ...) \ + ({ \ + struct kvm_enable_cap cap = { \ + .cap = capability, \ + }; \ + uint64_t args_tmp[] = { __VA_ARGS__ }; \ + int i; \ + for (i = 0; i < ARRAY_SIZE(args_tmp) && \ + i < ARRAY_SIZE(cap.args); i++) { \ + cap.args[i] = args_tmp[i]; \ + } \ + kvm_vm_ioctl(s, KVM_ENABLE_CAP, &cap); \ + }) + +#define kvm_enable_cap_vcpu(cpu, capability, ...) \ + ({ \ + struct kvm_enable_cap cap = { \ + .cap = capability, \ + }; \ + uint64_t args_tmp[] = { __VA_ARGS__ }; \ + int i; \ + for (i = 0; i < ARRAY_SIZE(args_tmp) && \ + i < ARRAY_SIZE(cap.args); i++) { \ + cap.args[i] = args_tmp[i]; \ + } \ + kvm_vcpu_ioctl(cpu, KVM_ENABLE_CAP, &cap); \ + }) + uint32_t kvm_arch_get_supported_cpuid(KVMState *env, uint32_t function, uint32_t index, int reg);