From patchwork Fri Aug 23 19:41:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 19510 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f71.google.com (mail-qe0-f71.google.com [209.85.128.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A6A04248E6 for ; Fri, 23 Aug 2013 19:41:20 +0000 (UTC) Received: by mail-qe0-f71.google.com with SMTP id 1sf836205qee.10 for ; Fri, 23 Aug 2013 12:41:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=eIieAKz44gH22LSDwhVe6/3uDXnZduouPeVLg2W482Y=; b=eKPFXX2Jh9LZ3kJ1ghXspDPDHH9moLPCKhKcRJfWq0C45anNw8f0oalnq8dJfP+8QJ xlaQFs6112kGtZ0j6pSAX+kyulFNJY6ioXsMP3iG72eA7uWhQOLxei+R1wO5pPwRjIpo n81DYrIXXy30Md2SCi5gEyMeY79BDtemfOJ2T9nttKRDI25ZZCu/8rxC6HgqSRT97sHZ /xOlLVAOm/XjMz0jTNHUG0hSyY2bAfnGISx2ZCR3UpcqIRgc/B+sdSdoPwgkd3PKOqQv E+TdEI+b3kbdybSKdjsMpj5mGOB7rUtnox7Dflfp7IoPA1P03rGChb55VSN52/YODdYN bWpw== X-Received: by 10.236.227.165 with SMTP id d35mr410985yhq.51.1377286880477; Fri, 23 Aug 2013 12:41:20 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.1.227 with SMTP id 3ls1620028qep.84.gmail; Fri, 23 Aug 2013 12:41:20 -0700 (PDT) X-Received: by 10.220.103.140 with SMTP id k12mr108209vco.39.1377286880392; Fri, 23 Aug 2013 12:41:20 -0700 (PDT) Received: from mail-ve0-f178.google.com (mail-ve0-f178.google.com [209.85.128.178]) by mx.google.com with ESMTPS id fb5si422084vcb.90.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 23 Aug 2013 12:41:20 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.178; Received: by mail-ve0-f178.google.com with SMTP id ox1so775939veb.9 for ; Fri, 23 Aug 2013 12:41:20 -0700 (PDT) X-Gm-Message-State: ALoCoQldBY7toK3osOsRolE8Pw3hK7iLzIeNWpUSuJyvDFuIIouj545RwmmAK3DmFTGF2f1Uh665 X-Received: by 10.58.211.227 with SMTP id nf3mr866288vec.20.1377286880290; Fri, 23 Aug 2013 12:41:20 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp112013vcz; Fri, 23 Aug 2013 12:41:19 -0700 (PDT) X-Received: by 10.68.164.1 with SMTP id ym1mr1497417pbb.33.1377286879227; Fri, 23 Aug 2013 12:41:19 -0700 (PDT) Received: from mail-pb0-f51.google.com (mail-pb0-f51.google.com [209.85.160.51]) by mx.google.com with ESMTPS id co1si710455pbc.168.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 23 Aug 2013 12:41:19 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.51 is neither permitted nor denied by best guess record for domain of christoffer.dall@linaro.org) client-ip=209.85.160.51; Received: by mail-pb0-f51.google.com with SMTP id jt11so1051329pbb.24 for ; Fri, 23 Aug 2013 12:41:18 -0700 (PDT) X-Received: by 10.66.139.8 with SMTP id qu8mr653441pab.94.1377286878769; Fri, 23 Aug 2013 12:41:18 -0700 (PDT) Received: from localhost.localdomain (c-67-169-183-77.hsd1.ca.comcast.net. [67.169.183.77]) by mx.google.com with ESMTPSA id ib9sm1446453pbc.43.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 23 Aug 2013 12:41:17 -0700 (PDT) From: Christoffer Dall To: qemu-devel@nongnu.org Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, kvmarm@lists.cs.columbia.edu, Christoffer Dall Subject: [PATCH 3/4] kvm: Common device control API functions Date: Fri, 23 Aug 2013 12:41:01 -0700 Message-Id: <1377286862-5879-4-git-send-email-christoffer.dall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1377286862-5879-1-git-send-email-christoffer.dall@linaro.org> References: <1377286862-5879-1-git-send-email-christoffer.dall@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: christoffer.dall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Introduces two simple functions: int kvm_device_ioctl(int fd, int type, ...); int kvm_create_device(KVMState *s, uint64_t type, bool test); These functions wrap the basic ioctl-based interactions with KVM in a way similar to other KVM ioctl wrappers. Signed-off-by: Christoffer Dall --- include/sysemu/kvm.h | 5 +++++ kvm-all.c | 39 +++++++++++++++++++++++++++++++++++++++ trace-events | 1 + 3 files changed, 45 insertions(+) diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index 1e5847e..84ca5ef 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -190,6 +190,11 @@ int kvm_vm_ioctl(KVMState *s, int type, ...); int kvm_vcpu_ioctl(CPUState *cpu, int type, ...); +int kvm_device_ioctl(int fd, int type, ...); + +int kvm_create_device(KVMState *s, uint64_t type, bool test); + + /* Arch specific hooks */ extern const KVMCapabilityInfo kvm_arch_required_capabilities[]; diff --git a/kvm-all.c b/kvm-all.c index fe64f3b..957b961 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -1770,6 +1770,24 @@ int kvm_vcpu_ioctl(CPUState *cpu, int type, ...) return ret; } +int kvm_device_ioctl(int fd, int type, ...) +{ + int ret; + void *arg; + va_list ap; + + va_start(ap, type); + arg = va_arg(ap, void *); + va_end(ap); + + trace_kvm_device_ioctl(fd, type, arg); + ret = ioctl(fd, type, arg); + if (ret == -1) { + ret = -errno; + } + return ret; +} + int kvm_has_sync_mmu(void) { return kvm_check_extension(kvm_state, KVM_CAP_SYNC_MMU); @@ -2064,3 +2082,24 @@ int kvm_on_sigbus(int code, void *addr) { return kvm_arch_on_sigbus(code, addr); } + +int kvm_create_device(KVMState *s, uint64_t type, bool test) +{ + int ret; + struct kvm_create_device create_dev; + + create_dev.type = type; + create_dev.fd = -1; + create_dev.flags = (test) ? KVM_CREATE_DEVICE_TEST : 0; + + if (!kvm_check_extension(s, KVM_CAP_DEVICE_CTRL)) { + return -1; + } + + ret = kvm_vm_ioctl(s, KVM_CREATE_DEVICE, &create_dev); + if (ret) { + return ret; + } + + return (test) ? 0 : create_dev.fd; +} diff --git a/trace-events b/trace-events index 3856b5c..5372c6e 100644 --- a/trace-events +++ b/trace-events @@ -1163,6 +1163,7 @@ migrate_set_state(int new_state) "new state %d" kvm_ioctl(int type, void *arg) "type %d, arg %p" kvm_vm_ioctl(int type, void *arg) "type %d, arg %p" kvm_vcpu_ioctl(int cpu_index, int type, void *arg) "cpu_index %d, type %d, arg %p" +kvm_device_ioctl(int fd, int type, void *arg) "dev fd %d, type %d, arg %p" kvm_run_exit(int cpu_index, uint32_t reason) "cpu_index %d, reason %d" # memory.c