Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L0hke-0004JP-1H for qemu-devel@nongnu.org; Thu, 13 Nov 2008 14:21:12 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L0hkd-0004Iy-K5 for qemu-devel@nongnu.org; Thu, 13 Nov 2008 14:21:11 -0500 Received: from [199.232.76.173] (port=59627 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L0hkd-0004It-8o for qemu-devel@nongnu.org; Thu, 13 Nov 2008 14:21:11 -0500 Received: from savannah.gnu.org ([199.232.41.3]:53306 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1L0hkd-0004tS-0I for qemu-devel@nongnu.org; Thu, 13 Nov 2008 14:21:11 -0500 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1L0hkb-00089V-9G for qemu-devel@nongnu.org; Thu, 13 Nov 2008 19:21:09 +0000 Received: from aliguori by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1L0hkV-00088u-W7 for qemu-devel@nongnu.org; Thu, 13 Nov 2008 19:21:07 +0000 MIME-Version: 1.0 Errors-To: aliguori Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Anthony Liguori Message-Id: Date: Thu, 13 Nov 2008 19:21:04 +0000 Subject: [Qemu-devel] [5715] Define kvm_ioctl in the same way as ioctl Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 5715 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5715 Author: aliguori Date: 2008-11-13 19:21:00 +0000 (Thu, 13 Nov 2008) Log Message: ----------- 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 Modified Paths: -------------- trunk/kvm-all.c trunk/kvm.h trunk/target-i386/kvm.c Modified: trunk/kvm-all.c =================================================================== --- trunk/kvm-all.c 2008-11-13 16:19:54 UTC (rev 5714) +++ trunk/kvm-all.c 2008-11-13 19:21:00 UTC (rev 5715) @@ -14,6 +14,7 @@ #include #include #include +#include #include @@ -79,8 +80,7 @@ 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 @@ * 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 @@ /* 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; - ret = ioctl(s->vmfd, type, data); + va_start(ap, type); + arg = va_arg(ap, void *); + va_end(ap); + + 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; - ret = ioctl(env->kvm_fd, type, data); + va_start(ap, type); + arg = va_arg(ap, void *); + va_end(ap); + + ret = ioctl(env->kvm_fd, type, arg); if (ret == -1) ret = -errno; Modified: trunk/kvm.h =================================================================== --- trunk/kvm.h 2008-11-13 16:19:54 UTC (rev 5714) +++ trunk/kvm.h 2008-11-13 19:21:00 UTC (rev 5715) @@ -43,11 +43,11 @@ 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 */ Modified: trunk/target-i386/kvm.c =================================================================== --- trunk/target-i386/kvm.c 2008-11-13 16:19:54 UTC (rev 5714) +++ trunk/target-i386/kvm.c 2008-11-13 19:21:00 UTC (rev 5715) @@ -130,7 +130,7 @@ * 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 @@ * 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)