From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40193) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yme8h-0005Rh-Ns for qemu-devel@nongnu.org; Mon, 27 Apr 2015 04:11:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yme8e-000651-Ap for qemu-devel@nongnu.org; Mon, 27 Apr 2015 04:11:39 -0400 Received: from e06smtp14.uk.ibm.com ([195.75.94.110]:48834) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yme8e-00064x-1y for qemu-devel@nongnu.org; Mon, 27 Apr 2015 04:11:36 -0400 Received: from /spool/local by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 27 Apr 2015 09:11:34 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id E48262190046 for ; Mon, 27 Apr 2015 09:11:13 +0100 (BST) Received: from d06av01.portsmouth.uk.ibm.com (d06av01.portsmouth.uk.ibm.com [9.149.37.212]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t3R8BUCa10224038 for ; Mon, 27 Apr 2015 08:11:31 GMT Received: from d06av01.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av01.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t3R8BTUd010099 for ; Mon, 27 Apr 2015 02:11:30 -0600 Message-ID: <553DEF31.5070803@de.ibm.com> Date: Mon, 27 Apr 2015 10:11:29 +0200 From: Christian Borntraeger MIME-Version: 1.0 References: <1428933396-37887-1-git-send-email-mimu@linux.vnet.ibm.com> <1428933396-37887-16-git-send-email-mimu@linux.vnet.ibm.com> In-Reply-To: <1428933396-37887-16-git-send-email-mimu@linux.vnet.ibm.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v5 15/17] target-s390x: Extend arch specific QMP command query-cpu-definitions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michael Mueller , qemu-devel@nongnu.org, kvm@vger.kernel.org, linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Eduardo Habkost , Gleb Natapov , Alexander Graf , Cornelia Huck , "Jason J. Herne" , Daniel Hansel , Paolo Bonzini , Andreas Faerber , Richard Henderson Am 13.04.2015 um 15:56 schrieb Michael Mueller: > This patch implements the QMP command 'query-cpu-definitions' in the S390 > context. The command returns a list of cpu definitions in the current host > context. A runnable and migratable cpu model has the related attributes > set to true. The order attribute is used to bring the listed cpu definitions > in a release order. Can you add some explanation why we need the fallback code (e.g. something along the line, when querying no KVM guest is available and to query the capabilities we have to open a dummy VM bla bla) [...] > -static int kvm_s390_get_machine_props(KVMState *s, S390MachineProps *prop) > +static int get_machine_props_fallback(S390MachineProps *prop) > +{ > + struct kvm_device_attr dev_attr; > + int rc, kvmfd = -1, vmfd = -1; > + > + rc = qemu_open("/dev/kvm", O_RDWR); > + if (rc < 0) { > + goto out_err; > + } > + kvmfd = rc; > + > + rc = ioctl(kvmfd, KVM_CREATE_VM, 0); > + if (rc < 0) { > + goto out_err; > + } > + vmfd = rc; > + > + rc = ioctl(vmfd, KVM_CHECK_EXTENSION, KVM_CAP_VM_ATTRIBUTES); > + if (rc < 0) { > + rc = -ENOSYS; > + goto out_err; > + } > + > + dev_attr.group = KVM_S390_VM_CPU_MODEL; > + dev_attr.attr = KVM_S390_VM_CPU_MACHINE; > + rc = ioctl(vmfd, KVM_HAS_DEVICE_ATTR, &dev_attr); > + if (rc < 0) { > + rc = -EFAULT; > + goto out_err; > + } > + > + dev_attr.addr = (uint64_t) prop; > + rc = ioctl(vmfd, KVM_GET_DEVICE_ATTR, &dev_attr); > + > +out_err: > + if (vmfd >= 0) { > + close(vmfd); > + } > + if (kvmfd >= 0) { > + close(kvmfd); > + } > + > + return rc; > +} > + > +int kvm_s390_get_machine_props(KVMState *s, S390MachineProps *prop) > { > int rc = -EFAULT; > > if (s) { > rc = cpu_model_get(s, KVM_S390_VM_CPU_MACHINE, (uint64_t) prop); > + } else { > + rc = get_machine_props_fallback(prop); > } > trace_kvm_get_machine_props(rc, prop->cpuid, prop->ibc); >