diff options
-rw-r--r-- | kvm-all.c | 36 | ||||
-rw-r--r-- | kvm.h | 6 | ||||
-rw-r--r-- | target-i386/kvm.c | 4 |
3 files changed, 32 insertions, 14 deletions
@@ -14,6 +14,7 @@ #include <sys/types.h> #include <sys/ioctl.h> #include <sys/mman.h> +#include <stdarg.h> #include <linux/kvm.h> @@ -79,8 +80,7 @@ int kvm_init_vcpu(CPUState *env) dprintf("kvm_init_vcpu\n"); - ret = kvm_vm_ioctl(s, KVM_CREATE_VCPU, - (void *)(unsigned long)env->cpu_index); + ret = kvm_vm_ioctl(s, KVM_CREATE_VCPU, env->cpu_index); if (ret < 0) { dprintf("kvm_create_vcpu failed\n"); goto err; @@ -156,7 +156,7 @@ int kvm_init(int smp_cpus) * just use a user allocated buffer so we can use phys_ram_base * unmodified. Make sure we have a sufficiently modern version of KVM. */ - ret = kvm_ioctl(s, KVM_CHECK_EXTENSION, (void *)KVM_CAP_USER_MEMORY); + ret = kvm_ioctl(s, KVM_CHECK_EXTENSION, KVM_CAP_USER_MEMORY); if (ret <= 0) { if (ret == 0) ret = -EINVAL; @@ -345,33 +345,51 @@ void kvm_set_phys_mem(target_phys_addr_t start_addr, /* FIXME deal with errors */ } -int kvm_ioctl(KVMState *s, int type, void *data) +int kvm_ioctl(KVMState *s, int type, ...) { int ret; + void *arg; + va_list ap; - ret = ioctl(s->fd, type, data); + va_start(ap, type); + arg = va_arg(ap, void *); + va_end(ap); + + ret = ioctl(s->fd, type, arg); if (ret == -1) ret = -errno; return ret; } -int kvm_vm_ioctl(KVMState *s, int type, void *data) +int kvm_vm_ioctl(KVMState *s, int type, ...) { int ret; + void *arg; + va_list ap; + + va_start(ap, type); + arg = va_arg(ap, void *); + va_end(ap); - ret = ioctl(s->vmfd, type, data); + ret = ioctl(s->vmfd, type, arg); if (ret == -1) ret = -errno; return ret; } -int kvm_vcpu_ioctl(CPUState *env, int type, void *data) +int kvm_vcpu_ioctl(CPUState *env, int type, ...) { int ret; + void *arg; + va_list ap; + + va_start(ap, type); + arg = va_arg(ap, void *); + va_end(ap); - ret = ioctl(env->kvm_fd, type, data); + ret = ioctl(env->kvm_fd, type, arg); if (ret == -1) ret = -errno; @@ -43,11 +43,11 @@ void kvm_set_phys_mem(target_phys_addr_t start_addr, struct KVMState; typedef struct KVMState KVMState; -int kvm_ioctl(KVMState *s, int type, void *data); +int kvm_ioctl(KVMState *s, int type, ...); -int kvm_vm_ioctl(KVMState *s, int type, void *data); +int kvm_vm_ioctl(KVMState *s, int type, ...); -int kvm_vcpu_ioctl(CPUState *env, int type, void *data); +int kvm_vcpu_ioctl(CPUState *env, int type, ...); /* Arch specific hooks */ diff --git a/target-i386/kvm.c b/target-i386/kvm.c index f22f30a137..3f60654ec1 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -130,7 +130,7 @@ int kvm_arch_init(KVMState *s, int smp_cpus) * versions of KVM just assumed that it would be at the end of physical * memory but that doesn't work with more than 4GB of memory. We simply * refuse to work with those older versions of KVM. */ - ret = kvm_ioctl(s, KVM_CHECK_EXTENSION, (void *)KVM_CAP_SET_TSS_ADDR); + ret = kvm_ioctl(s, KVM_CHECK_EXTENSION, KVM_CAP_SET_TSS_ADDR); if (ret <= 0) { fprintf(stderr, "kvm does not support KVM_CAP_SET_TSS_ADDR\n"); return ret; @@ -140,7 +140,7 @@ int kvm_arch_init(KVMState *s, int smp_cpus) * as unavaible memory. FIXME, need to ensure the e820 map deals with * this? */ - return kvm_vm_ioctl(s, KVM_SET_TSS_ADDR, (void *)0xfffbd000); + return kvm_vm_ioctl(s, KVM_SET_TSS_ADDR, 0xfffbd000); } static void set_v8086_seg(struct kvm_segment *lhs, const SegmentCache *rhs) |