Commit 984b51814712ae4337b9e908da8a03166e2b7289
1 parent
305b0eb2
Define kvm_ioctl in the same way as ioctl
The third argument to ioctl is a ... which allows any value to be passed. In practice, glibc always treats the argument as a void *. Do the same thing for the kvm ioctls to keep things consistent with a traditional ioctl. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5715 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
3 changed files
with
32 additions
and
14 deletions
kvm-all.c
... | ... | @@ -14,6 +14,7 @@ |
14 | 14 | #include <sys/types.h> |
15 | 15 | #include <sys/ioctl.h> |
16 | 16 | #include <sys/mman.h> |
17 | +#include <stdarg.h> | |
17 | 18 | |
18 | 19 | #include <linux/kvm.h> |
19 | 20 | |
... | ... | @@ -79,8 +80,7 @@ int kvm_init_vcpu(CPUState *env) |
79 | 80 | |
80 | 81 | dprintf("kvm_init_vcpu\n"); |
81 | 82 | |
82 | - ret = kvm_vm_ioctl(s, KVM_CREATE_VCPU, | |
83 | - (void *)(unsigned long)env->cpu_index); | |
83 | + ret = kvm_vm_ioctl(s, KVM_CREATE_VCPU, env->cpu_index); | |
84 | 84 | if (ret < 0) { |
85 | 85 | dprintf("kvm_create_vcpu failed\n"); |
86 | 86 | goto err; |
... | ... | @@ -156,7 +156,7 @@ int kvm_init(int smp_cpus) |
156 | 156 | * just use a user allocated buffer so we can use phys_ram_base |
157 | 157 | * unmodified. Make sure we have a sufficiently modern version of KVM. |
158 | 158 | */ |
159 | - ret = kvm_ioctl(s, KVM_CHECK_EXTENSION, (void *)KVM_CAP_USER_MEMORY); | |
159 | + ret = kvm_ioctl(s, KVM_CHECK_EXTENSION, KVM_CAP_USER_MEMORY); | |
160 | 160 | if (ret <= 0) { |
161 | 161 | if (ret == 0) |
162 | 162 | ret = -EINVAL; |
... | ... | @@ -345,33 +345,51 @@ void kvm_set_phys_mem(target_phys_addr_t start_addr, |
345 | 345 | /* FIXME deal with errors */ |
346 | 346 | } |
347 | 347 | |
348 | -int kvm_ioctl(KVMState *s, int type, void *data) | |
348 | +int kvm_ioctl(KVMState *s, int type, ...) | |
349 | 349 | { |
350 | 350 | int ret; |
351 | + void *arg; | |
352 | + va_list ap; | |
351 | 353 | |
352 | - ret = ioctl(s->fd, type, data); | |
354 | + va_start(ap, type); | |
355 | + arg = va_arg(ap, void *); | |
356 | + va_end(ap); | |
357 | + | |
358 | + ret = ioctl(s->fd, type, arg); | |
353 | 359 | if (ret == -1) |
354 | 360 | ret = -errno; |
355 | 361 | |
356 | 362 | return ret; |
357 | 363 | } |
358 | 364 | |
359 | -int kvm_vm_ioctl(KVMState *s, int type, void *data) | |
365 | +int kvm_vm_ioctl(KVMState *s, int type, ...) | |
360 | 366 | { |
361 | 367 | int ret; |
368 | + void *arg; | |
369 | + va_list ap; | |
370 | + | |
371 | + va_start(ap, type); | |
372 | + arg = va_arg(ap, void *); | |
373 | + va_end(ap); | |
362 | 374 | |
363 | - ret = ioctl(s->vmfd, type, data); | |
375 | + ret = ioctl(s->vmfd, type, arg); | |
364 | 376 | if (ret == -1) |
365 | 377 | ret = -errno; |
366 | 378 | |
367 | 379 | return ret; |
368 | 380 | } |
369 | 381 | |
370 | -int kvm_vcpu_ioctl(CPUState *env, int type, void *data) | |
382 | +int kvm_vcpu_ioctl(CPUState *env, int type, ...) | |
371 | 383 | { |
372 | 384 | int ret; |
385 | + void *arg; | |
386 | + va_list ap; | |
387 | + | |
388 | + va_start(ap, type); | |
389 | + arg = va_arg(ap, void *); | |
390 | + va_end(ap); | |
373 | 391 | |
374 | - ret = ioctl(env->kvm_fd, type, data); | |
392 | + ret = ioctl(env->kvm_fd, type, arg); | |
375 | 393 | if (ret == -1) |
376 | 394 | ret = -errno; |
377 | 395 | ... | ... |
kvm.h
... | ... | @@ -43,11 +43,11 @@ void kvm_set_phys_mem(target_phys_addr_t start_addr, |
43 | 43 | struct KVMState; |
44 | 44 | typedef struct KVMState KVMState; |
45 | 45 | |
46 | -int kvm_ioctl(KVMState *s, int type, void *data); | |
46 | +int kvm_ioctl(KVMState *s, int type, ...); | |
47 | 47 | |
48 | -int kvm_vm_ioctl(KVMState *s, int type, void *data); | |
48 | +int kvm_vm_ioctl(KVMState *s, int type, ...); | |
49 | 49 | |
50 | -int kvm_vcpu_ioctl(CPUState *env, int type, void *data); | |
50 | +int kvm_vcpu_ioctl(CPUState *env, int type, ...); | |
51 | 51 | |
52 | 52 | /* Arch specific hooks */ |
53 | 53 | ... | ... |
target-i386/kvm.c
... | ... | @@ -130,7 +130,7 @@ int kvm_arch_init(KVMState *s, int smp_cpus) |
130 | 130 | * versions of KVM just assumed that it would be at the end of physical |
131 | 131 | * memory but that doesn't work with more than 4GB of memory. We simply |
132 | 132 | * refuse to work with those older versions of KVM. */ |
133 | - ret = kvm_ioctl(s, KVM_CHECK_EXTENSION, (void *)KVM_CAP_SET_TSS_ADDR); | |
133 | + ret = kvm_ioctl(s, KVM_CHECK_EXTENSION, KVM_CAP_SET_TSS_ADDR); | |
134 | 134 | if (ret <= 0) { |
135 | 135 | fprintf(stderr, "kvm does not support KVM_CAP_SET_TSS_ADDR\n"); |
136 | 136 | return ret; |
... | ... | @@ -140,7 +140,7 @@ int kvm_arch_init(KVMState *s, int smp_cpus) |
140 | 140 | * as unavaible memory. FIXME, need to ensure the e820 map deals with |
141 | 141 | * this? |
142 | 142 | */ |
143 | - return kvm_vm_ioctl(s, KVM_SET_TSS_ADDR, (void *)0xfffbd000); | |
143 | + return kvm_vm_ioctl(s, KVM_SET_TSS_ADDR, 0xfffbd000); | |
144 | 144 | } |
145 | 145 | |
146 | 146 | static void set_v8086_seg(struct kvm_segment *lhs, const SegmentCache *rhs) | ... | ... |