aboutsummaryrefslogtreecommitdiff
path: root/kvm-all.c
diff options
context:
space:
mode:
authoraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2008-11-13 19:21:00 +0000
committeraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2008-11-13 19:21:00 +0000
commit984b51814712ae4337b9e908da8a03166e2b7289 (patch)
tree19e346b08d09bdb7a32a73515bdd2f3c00c004b8 /kvm-all.c
parent305b0eb2396a5565d008145cb671ec51ea1fac40 (diff)
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
Diffstat (limited to 'kvm-all.c')
-rw-r--r--kvm-all.c36
1 files changed, 27 insertions, 9 deletions
diff --git a/kvm-all.c b/kvm-all.c
index 8575a4dee2..d1e62ef686 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -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;