From patchwork Fri Mar 18 03:27:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 8616021 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 71942C0553 for ; Fri, 18 Mar 2016 03:29:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CEA082038E for ; Fri, 18 Mar 2016 03:29:58 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 00FC82038F for ; Fri, 18 Mar 2016 03:29:58 +0000 (UTC) Received: from localhost ([::1]:41297 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agl6r-0001XP-C4 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 17 Mar 2016 23:29:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43276) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agl4x-000641-MS for qemu-devel@nongnu.org; Thu, 17 Mar 2016 23:28:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1agl4w-0000um-R2 for qemu-devel@nongnu.org; Thu, 17 Mar 2016 23:27:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41218) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1agl4u-0000u6-53; Thu, 17 Mar 2016 23:27:56 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id C9EB17F6B2; Fri, 18 Mar 2016 03:27:55 +0000 (UTC) Received: from pxdev.xzpeter.org.com (vpn1-7-63.pek2.redhat.com [10.72.7.63]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2I3Rce4023061; Thu, 17 Mar 2016 23:27:51 -0400 From: Peter Xu To: qemu-devel@nongnu.org Date: Fri, 18 Mar 2016 11:27:32 +0800 Message-Id: <1458271654-23706-4-git-send-email-peterx@redhat.com> In-Reply-To: <1458271654-23706-1-git-send-email-peterx@redhat.com> References: <1458271654-23706-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: wei@redhat.com, peter.maydell@linaro.org, drjones@redhat.com, mdroth@linux.vnet.ibm.com, armbru@redhat.com, peterx@redhat.com, abologna@redhat.com, qemu-arm@nongnu.org Subject: [Qemu-devel] [PATCH v5 3/5] arm: enhance kvm_arm_create_scratch_host_vcpu X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some more lines to make sure we allow NULL for 1st/3rd parameter. Signed-off-by: Peter Xu --- target-arm/kvm.c | 10 +++++++++- target-arm/kvm_arm.h | 6 ++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/target-arm/kvm.c b/target-arm/kvm.c index 969ab0b..0a7f9a6 100644 --- a/target-arm/kvm.c +++ b/target-arm/kvm.c @@ -62,13 +62,17 @@ bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try, goto err; } + if (!init) { + goto finish; + } + ret = ioctl(vmfd, KVM_ARM_PREFERRED_TARGET, init); if (ret >= 0) { ret = ioctl(cpufd, KVM_ARM_VCPU_INIT, init); if (ret < 0) { goto err; } - } else { + } else if (cpus_to_try) { /* Old kernel which doesn't know about the * PREFERRED_TARGET ioctl: we know it will only support * creating one kind of guest CPU which is its preferred @@ -85,8 +89,12 @@ bool kvm_arm_create_scratch_host_vcpu(const uint32_t *cpus_to_try, if (ret < 0) { goto err; } + } else { + /* Not providing cpus_to_try, do nothing. */ + ; } +finish: fdarray[0] = kvmfd; fdarray[1] = vmfd; fdarray[2] = cpufd; diff --git a/target-arm/kvm_arm.h b/target-arm/kvm_arm.h index 07f0c72..6bcfe6c 100644 --- a/target-arm/kvm_arm.h +++ b/target-arm/kvm_arm.h @@ -124,9 +124,11 @@ void kvm_arm_reset_vcpu(ARMCPU *cpu); * kvm_arm_create_scratch_host_vcpu: * @cpus_to_try: array of QEMU_KVM_ARM_TARGET_* values (terminated with * QEMU_KVM_ARM_TARGET_NONE) to try as fallback if the kernel does not - * know the PREFERRED_TARGET ioctl + * know the PREFERRED_TARGET ioctl. If NULL is provided, will try + * nothing. * @fdarray: filled in with kvmfd, vmfd, cpufd file descriptors in that order - * @init: filled in with the necessary values for creating a host vcpu + * @init: filled in with the necessary values for creating a host + * vcpu. If NULL is provided, will not init the vCPU. * * Create a scratch vcpu in its own VM of the type preferred by the host * kernel (as would be used for '-cpu host'), for purposes of probing it