From nobody Mon Dec 15 01:47:58 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=linux.ibm.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1523920589064535.7097047070715; Mon, 16 Apr 2018 16:16:29 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 02FD34E040; Mon, 16 Apr 2018 23:16:26 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E38147A40B; Mon, 16 Apr 2018 23:16:24 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 57C93180215F; Mon, 16 Apr 2018 23:16:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w3GNGIR1008273 for ; Mon, 16 Apr 2018 19:16:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 588FB7A41D; Mon, 16 Apr 2018 23:16:18 +0000 (UTC) Received: from mx1.redhat.com (ext-mx12.extmail.prod.ext.phx2.redhat.com [10.5.110.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 511237A41B for ; Mon, 16 Apr 2018 23:16:16 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2527E315008F for ; Mon, 16 Apr 2018 23:16:15 +0000 (UTC) Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w3GN9VZq062866 for ; Mon, 16 Apr 2018 19:16:14 -0400 Received: from e11.ny.us.ibm.com (e11.ny.us.ibm.com [129.33.205.201]) by mx0a-001b2d01.pphosted.com with ESMTP id 2hd2b7xuw3-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Mon, 16 Apr 2018 19:16:14 -0400 Received: from localhost by e11.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 16 Apr 2018 19:16:13 -0400 Received: from b01cxnp23034.gho.pok.ibm.com (9.57.198.29) by e11.ny.us.ibm.com (146.89.104.198) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 16 Apr 2018 19:16:11 -0400 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w3GNGBe252232352; Mon, 16 Apr 2018 23:16:11 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A64B7B204E; Mon, 16 Apr 2018 20:18:15 -0400 (EDT) Received: from collin-ThinkPad-W541.pok.ibm.com (unknown [9.56.58.57]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP id A461CB204D; Mon, 16 Apr 2018 20:18:15 -0400 (EDT) From: Collin Walling To: libvir-list@redhat.com Date: Mon, 16 Apr 2018 19:16:06 -0400 In-Reply-To: <1523920569-9386-1-git-send-email-walling@linux.ibm.com> References: <1523920569-9386-1-git-send-email-walling@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18041623-2213-0000-0000-00000292B9DE X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008866; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000257; SDB=6.01018943; UDB=6.00519786; IPR=6.00798184; MB=3.00020604; MTD=3.00000008; XFM=3.00000015; UTC=2018-04-16 23:16:12 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18041623-2214-0000-0000-000059C7CDF1 Message-Id: <1523920569-9386-2-git-send-email-walling@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2018-04-16_12:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804160192 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Mon, 16 Apr 2018 23:16:15 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Mon, 16 Apr 2018 23:16:15 +0000 (UTC) for IP:'148.163.156.1' DOMAIN:'mx0a-001b2d01.pphosted.com' HELO:'mx0a-001b2d01.pphosted.com' FROM:'walling@linux.ibm.com' RCPT:'' X-RedHat-Spam-Score: -0.701 (RCVD_IN_DNSWL_LOW, SPF_PASS) 148.163.156.1 mx0a-001b2d01.pphosted.com 148.163.156.1 mx0a-001b2d01.pphosted.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.41 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: cventeic@redhat.com Subject: [libvirt] [PATCH v1 1/4] qemu: place qemuCaps host cpu model in virCaps X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 16 Apr 2018 23:16:26 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Some architectures retrieve their host CPU model data from QEMU via qmp-query-cpu-model-expansion and stores it in the QEMU cache files. Let's take this data and also store it in virCaps so we can easily retrieve the host CPU model for later use. We should also take care to ensure that we always query the same cache file consistently between libvirtd executions, so let's query the qemuCaps from the first qemu-system-ARCH found in $PATH (via virQEMUCapsCacheLookup). Signed-off-by: Collin Walling --- src/qemu/qemu_capabilities.c | 53 ++++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 53 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index cb716ff..d2eb813 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -896,6 +896,54 @@ virQEMUCapsProbeHostCPUForEmulator(virArch hostArch, } =20 =20 +static int +virQEMUProbeHostCPUModelFromBinary(virFileCachePtr cache, + virArch hostarch, + virCPUDefPtr *hostCPU) +{ + char *binary; + virQEMUCapsPtr qemuCaps =3D NULL; + virCPUDefPtr qemuCpu; + virCPUDefPtr tmp =3D NULL; + int ret =3D -1; + + if (!(binary =3D virQEMUCapsFindBinaryForArch(hostarch, hostarch))) + goto cleanup; + + if (!(qemuCaps =3D virQEMUCapsCacheLookup(cache, binary))) + goto cleanup; + + /* If QEMU does not report the host's cpu model, then fail gracefully = */ + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION)) { + ret =3D 0; + goto cleanup; + } + + if (!(qemuCpu =3D virQEMUCapsGetHostModel(qemuCaps, VIR_DOMAIN_VIRT_KV= M, + VIR_QEMU_CAPS_HOST_CPU_REPORTE= D))) + goto cleanup; + + if (VIR_ALLOC(tmp) < 0) + goto cleanup; + + if (!(tmp =3D virCPUDefCopyWithoutModel(*hostCPU))) + goto cleanup; + + if (virCPUDefCopyModel(tmp, qemuCpu, false) < 0) + goto cleanup; + + virCPUDefFree(*hostCPU); + VIR_STEAL_PTR(*hostCPU, tmp); + ret =3D 0; + + cleanup: + VIR_FREE(binary); + virCPUDefFree(tmp); + virObjectUnref(qemuCaps); + return ret; +} + + virCapsPtr virQEMUCapsInit(virFileCachePtr cache) { @@ -922,6 +970,11 @@ virQEMUCapsInit(virFileCachePtr cache) if (!(caps->host.cpu =3D virCPUProbeHost(caps->host.arch))) VIR_WARN("Failed to get host CPU"); =20 + /* Some archs get host cpu information via QEMU */ + if (caps->host.cpu && !caps->host.cpu->model && + virQEMUProbeHostCPUModelFromBinary(cache, hostarch, &caps->host.cp= u) < 0) + VIR_WARN("Failed to get host CPU model from QEMU"); + /* Add the power management features of the host */ if (virNodeSuspendGetTargetMask(&caps->host.powerMgmt) < 0) VIR_WARN("Failed to get host power management capabilities"); --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list