From nobody Sun Feb 8 12:37:06 2026 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 ARC-Seal: i=1; a=rsa-sha256; t=1563372242; cv=none; d=zoho.com; s=zohoarc; b=ggOxFX+AyLslAPuGSFFX4jSMbH62DSs7tyLw55TN1D5imKZPWbkC/kPQP1bqdx4lkg83BAstzTicJqki2ubDW8PXL7a9ssz/Up5+f7cpaQOA+5ClKkHhDlC82XUfWXU9EaE5E90jIvzWtt//zY51KZAwbVY+55HrxVZFslSkR+U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563372242; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=uH+6Grnqix4IO6sI5F05Xet76qsOHXsTL9fhOjEKcbM=; b=ajD6R7sQVtB/g7JRFAJCyqXrQKck/LklmLOaKwC3SC1Cacj/itD4z5n46CLGWtK5iXhWg8lrsIbh46sykptFgU0sY8skP36nOEvdLDhNKlKNN3yH3FlLvCHeCmy1oQOz9+pj8CuW5Z0Zd7D2lDF+4CQrdOrWorFN6Vcn4+qdu5g= ARC-Authentication-Results: i=1; mx.zoho.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 header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1563372242363165.25425740294259; Wed, 17 Jul 2019 07:04:02 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 89BE83086222; Wed, 17 Jul 2019 14:04:00 +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 5E7BB5C21A; Wed, 17 Jul 2019 14:04:00 +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 1CB491800207; Wed, 17 Jul 2019 14:04:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6HE3rRZ028807 for ; Wed, 17 Jul 2019 10:03:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1918D17AEC; Wed, 17 Jul 2019 14:03:53 +0000 (UTC) Received: from mx1.redhat.com (ext-mx18.extmail.prod.ext.phx2.redhat.com [10.5.110.47]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 12B3B5DA34 for ; Wed, 17 Jul 2019 14:03:50 +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 C4FD2308218D for ; Wed, 17 Jul 2019 14:03:49 +0000 (UTC) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x6HDvKZM120069 for ; Wed, 17 Jul 2019 10:03:49 -0400 Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx0a-001b2d01.pphosted.com with ESMTP id 2tt50y8brn-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 17 Jul 2019 10:03:49 -0400 Received: from localhost by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 17 Jul 2019 15:03:48 +0100 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 17 Jul 2019 15:03:44 +0100 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x6HE3hrW33620224 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Jul 2019 14:03:43 GMT Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A60C66E04E; Wed, 17 Jul 2019 14:03:43 +0000 (GMT) Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 30DE66E050; Wed, 17 Jul 2019 14:03:43 +0000 (GMT) Received: from collin-T470p.endicott.ibm.com (unknown [9.60.89.78]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 17 Jul 2019 14:03:43 +0000 (GMT) From: Collin Walling To: libvir-list@redhat.com Date: Wed, 17 Jul 2019 10:03:25 -0400 In-Reply-To: <1563372209-23466-1-git-send-email-walling@linux.ibm.com> References: <1563372209-23466-1-git-send-email-walling@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19071714-0012-0000-0000-00001753369A X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00011445; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000286; SDB=6.01233473; UDB=6.00649944; IPR=6.01014798; MB=3.00027759; MTD=3.00000008; XFM=3.00000015; UTC=2019-07-17 14:03:46 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19071714-0013-0000-0000-0000581C07C0 Message-Id: <1563372209-23466-5-git-send-email-walling@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-07-17_06:, , 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=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1907170166 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Wed, 17 Jul 2019 14:03:49 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Wed, 17 Jul 2019 14:03:49 +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.7 (RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, 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.47 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: bwalk@linux.ibm.com, jdenemar@redhat.com, danielhb413@gmail.com, david@redhat.com Subject: [libvirt] [PATCH v4 4/8] qemu_driver: hook up query-cpu-model-baseline 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Wed, 17 Jul 2019 14:04:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This command is hooked into the virsh hypervisor-cpu-baseline command. As such, the CPU models provided in the XML sent to the command will be baselined with the CPU contained in the QEMU capabilities file for the appropriate QEMU binary (for s390x, this CPU definition can be observed via virsh domcapabilities). Signed-off-by: Collin Walling Reviewed-by: Daniel Henrique Barboza Reviewed-by: Boris Fiuczynski --- src/qemu/qemu_capabilities.c | 84 ++++++++++++++++++++++++++++++++++++++++= ++++ src/qemu/qemu_capabilities.h | 7 ++++ src/qemu/qemu_driver.c | 27 ++++++++++++++ 3 files changed, 118 insertions(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index b898113..ab337fa 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -5574,3 +5574,87 @@ virQEMUCapsStripMachineAliases(virQEMUCapsPtr qemuCa= ps) for (i =3D 0; i < qemuCaps->nmachineTypes; i++) VIR_FREE(qemuCaps->machineTypes[i].alias); } + + +static int +virQEMUCapsStealCPUModelFromInfo(virCPUDefPtr dst, + qemuMonitorCPUModelInfoPtr *src) +{ + qemuMonitorCPUModelInfoPtr info =3D *src; + size_t i; + + virCPUDefFreeModel(dst); + + VIR_STEAL_PTR(dst->model, info->name); + + for (i =3D 0; i < info->nprops; i++) { + char *name =3D info->props[i].name; + int policy =3D VIR_CPU_FEATURE_REQUIRE; + + if (info->props[i].type =3D=3D QEMU_MONITOR_CPU_PROPERTY_BOOLEAN && + !info->props[i].value.boolean) + policy =3D VIR_CPU_FEATURE_DISABLE; + + if (virCPUDefAddFeature(dst, name, policy) < 0) + goto error; + } + + qemuMonitorCPUModelInfoFree(info); + *src =3D NULL; + return 0; + + error: + virCPUDefFree(dst); + return -1; +} + + +virCPUDefPtr +virQEMUCapsCPUModelBaseline(virQEMUCapsPtr qemuCaps, + const char *libDir, + uid_t runUid, + gid_t runGid, + int ncpus, + virCPUDefPtr *cpus) +{ + qemuMonitorCPUModelInfoPtr result =3D NULL; + qemuProcessQMPPtr proc =3D NULL; + virCPUDefPtr cpu =3D NULL; + virCPUDefPtr baseline =3D NULL; + size_t i; + + if (VIR_ALLOC(cpu) < 0) + goto cleanup; + + if (virCPUDefCopyModel(cpu, cpus[0], false)) + goto cleanup; + + if (!(proc =3D qemuProcessQMPNew(qemuCaps->binary, libDir, + runUid, runGid, false))) + goto cleanup; + + if (qemuProcessQMPStart(proc) < 0) + goto cleanup; + + for (i =3D 1; i < ncpus; i++) { + if (qemuMonitorGetCPUModelBaseline(proc->mon, cpu->model, + cpu->nfeatures, cpu->features, + cpus[i]->model, cpus[i]->nfeatu= res, + cpus[i]->features, &result) < 0) + goto cleanup; + + if (virQEMUCapsStealCPUModelFromInfo(cpu, &result) < 0) + goto cleanup; + } + + VIR_STEAL_PTR(baseline, cpu); + + cleanup: + if (!baseline) + virQEMUCapsLogProbeFailure(qemuCaps->binary); + + qemuMonitorCPUModelInfoFree(result); + qemuProcessQMPFree(proc); + virCPUDefFree(cpu); + return baseline; +} diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index 8dde759..b49c0b9 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -665,3 +665,10 @@ virQEMUCapsGetSEVCapabilities(virQEMUCapsPtr qemuCaps); =20 virArch virQEMUCapsArchFromString(const char *arch); const char *virQEMUCapsArchToString(virArch arch); + +virCPUDefPtr virQEMUCapsCPUModelBaseline(virQEMUCapsPtr qemuCaps, + const char *libDir, + uid_t runUid, + gid_t runGid, + int ncpus, + virCPUDefPtr *cpus); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index d3a144a..37b9c75 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -13553,6 +13553,7 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr conn, unsigned int flags) { virQEMUDriverPtr driver =3D conn->privateData; + virQEMUDriverConfigPtr config =3D driver->config; virCPUDefPtr *cpus =3D NULL; virQEMUCapsPtr qemuCaps =3D NULL; virArch arch; @@ -13607,6 +13608,32 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr con= n, if (!(cpu =3D virCPUBaseline(arch, cpus, ncpus, cpuModels, (const char **)features, migratable))) goto cleanup; + } else if (ARCH_IS_S390(arch) && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_BASELINE= )) { + /* Add a copy of the hypervisor CPU to the list */ + virCPUDefPtr hvCPU, tmp; + size_t allocated =3D ncpus + 1; + + hvCPU =3D virQEMUCapsGetHostModel(qemuCaps, virttype, + VIR_QEMU_CAPS_HOST_CPU_REPORTED); + if (VIR_ALLOC(tmp) < 0) + goto cleanup; + + if (virCPUDefCopyModel(tmp, hvCPU, false)) + goto cleanup; + + if (VIR_INSERT_ELEMENT(cpus, ncpus, allocated, tmp) < 0) + goto cleanup; + + ncpus++; + + if (!(cpu =3D virQEMUCapsCPUModelBaseline(qemuCaps, config->libDir, + config->user, config->grou= p, + ncpus, cpus))) + goto cleanup; + + if (!(flags & VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES)) + virCPUDefFreeFeatures(cpu); } else { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, _("computing baseline hypervisor CPU is not support= ed " --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list