From nobody Tue Jan 21 07:27:42 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=reject dis=none) header.from=linux.ibm.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1736937368920579.4953662337945; Wed, 15 Jan 2025 02:36:08 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 47D81161A; Wed, 15 Jan 2025 05:36:08 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 939771918; Wed, 15 Jan 2025 05:34:25 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id DBE3115B9; Wed, 15 Jan 2025 05:34:16 -0500 (EST) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 11A04162C for ; Wed, 15 Jan 2025 05:34:15 -0500 (EST) Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50F3rhe0019115 for ; Wed, 15 Jan 2025 10:34:15 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4465gbshkw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 15 Jan 2025 10:34:14 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 50F9X4dm004526 for ; Wed, 15 Jan 2025 10:34:14 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4442ysr0sm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 15 Jan 2025 10:34:13 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 50FAYAaf34800100 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Jan 2025 10:34:10 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 132272004B; Wed, 15 Jan 2025 10:34:10 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F0C852004F; Wed, 15 Jan 2025 10:34:09 +0000 (GMT) Received: from fiuczyvm.. (unknown [9.152.222.247]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 15 Jan 2025 10:34:09 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=JiILvBNXG6PJtHYPe h9Ec26M5lwgfWG1lL7c92e820E=; b=n2+dmVy0rGQ1M99pjVX71eQZs5OiKToN7 /3pEofUvbM2Fu85ujlhyvID/Tf5ptgjSagzvK+7R+Gy1cniVIFotOB2SCGKgHmHO c3sVrVZKZoNmJsMPZ6y2+9yyIQf9sGa1T6x4XiJkJfFFP1unj9dszCr00rOfLsdQ HKqL1LeujMuoAfH5qXOluRVQfYEFIYkQ1I4LMZeuNDNPYNEkY6+e2CKC7gFqNDlZ dyH7i4dePY7/6osKGRIYme+nzioNRmNjakkezxUjpITe/lz1PwVclisQUUI5KDAx 38669PtwFNsVnNH5r0DBbSNq27NYIZFaL7zS8zejlZx3WgMfcy7HQ== From: Boris Fiuczynski To: devel@lists.libvirt.org Subject: [PATCH 1/4] libvirt: Introduce virConnectGetHypervisorCPUModelNames public API Date: Wed, 15 Jan 2025 11:34:06 +0100 Message-ID: <20250115103409.31064-2-fiuczy@linux.ibm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250115103409.31064-1-fiuczy@linux.ibm.com> References: <20250115103409.31064-1-fiuczy@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Y3PU3_kpV4gLmEzwPj-olTnhMcJfUgVF X-Proofpoint-ORIG-GUID: Y3PU3_kpV4gLmEzwPj-olTnhMcJfUgVF X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-15_04,2025-01-15_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 spamscore=0 adultscore=0 mlxlogscore=852 phishscore=0 priorityscore=1501 suspectscore=0 bulkscore=0 malwarescore=0 impostorscore=0 lowpriorityscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2501150079 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 5LHVPWJMGHRC4TVRANLX6UV7FPWCBHTK X-Message-ID-Hash: 5LHVPWJMGHRC4TVRANLX6UV7FPWCBHTK X-MailFrom: fiuczy@linux.ibm.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: djudkovi@linux.ibm.com, walling@linux.ibm.com X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1736937370325019000 Content-Type: text/plain; charset="utf-8" From: David Judkovics The new API collects a list of CPU model names supported by the specified hypervisor. This is a more useful version of virConnectGetCPUNames, which does not consider any hypervisor capabilities when querying model names. Signed-off-by: David Judkovics Signed-off-by: Collin Walling Reviewed-by: Boris Fiuczynski Signed-off-by: Boris Fiuczynski --- include/libvirt/libvirt-host.h | 7 ++++ src/driver-hypervisor.h | 10 ++++++ src/libvirt-host.c | 65 ++++++++++++++++++++++++++++++++++ src/libvirt_public.syms | 5 +++ 4 files changed, 87 insertions(+) diff --git a/include/libvirt/libvirt-host.h b/include/libvirt/libvirt-host.h index 3112f2b676..67f57cdd16 100644 --- a/include/libvirt/libvirt-host.h +++ b/include/libvirt/libvirt-host.h @@ -961,6 +961,13 @@ int virConnectGetCPUModelNames(virConnectPtr conn, const char *arch, char ***models, unsigned int flags); +int virConnectGetHypervisorCPUModelNames(virConnectPtr conn, + const char *emulator, + const char *arch, + const char *machine, + const char *virttype, + char ***models, + unsigned int flags); =20 /** * virConnectBaselineCPUFlags: diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h index 4ce8da078d..ed42e3553d 100644 --- a/src/driver-hypervisor.h +++ b/src/driver-hypervisor.h @@ -1453,6 +1453,15 @@ typedef int unsigned int type, unsigned int flags); =20 +typedef int +(*virDrvConnectGetHypervisorCPUModelNames)(virConnectPtr conn, + const char *emulator, + const char *arch, + const char *machine, + const char *virttype, + char ***models, + unsigned int flags); + typedef struct _virHypervisorDriver virHypervisorDriver; =20 /** @@ -1726,4 +1735,5 @@ struct _virHypervisorDriver { virDrvDomainStartDirtyRateCalc domainStartDirtyRateCalc; virDrvDomainFDAssociate domainFDAssociate; virDrvDomainGraphicsReload domainGraphicsReload; + virDrvConnectGetHypervisorCPUModelNames connectGetHypervisorCPUModelNa= mes; }; diff --git a/src/libvirt-host.c b/src/libvirt-host.c index b3a6421a7f..ba845a7126 100644 --- a/src/libvirt-host.c +++ b/src/libvirt-host.c @@ -1222,6 +1222,71 @@ virConnectGetCPUModelNames(virConnectPtr conn, const= char *arch, char ***models, } =20 =20 +/** + * virConnectGetHypervisorCPUModelNames: + * + * @conn: pointer to the hypervisor connection + * @emulator: path to the emulator binary + * @arch: CPU architecture + * @machine: machine type + * @virttype: virtualization type + * @models: Pointer to a variable to store the NULL-terminated array of the + * CPU models supported by the hypervisor. Each element + * and the array itself must be freed by the caller with free. Pa= ss + * NULL if only the list length is needed. + * @flags: extra flags; not used yet, so callers should always pass 0. + * + * Get the list of CPU models recognized by the hypervisor for a specific + * architecture. Note that even if the hypervisor reports a particular CPU + * model, hardware limitations may impose restrictions on which CPU models + * may be supported on the host (e.g. on s390 the hypervisor may report + * model gen15a, but this model will not run on an older machine such as z= 14). + * + * Returns -1 on error, number of elements in @models on success. + * + * Since: 11.1.0 + */ +int +virConnectGetHypervisorCPUModelNames(virConnectPtr conn, + const char *emulator, + const char *arch, + const char *machine, + const char *virttype, + char ***models, + unsigned int flags) +{ + + VIR_DEBUG("conn=3D%p, emulator=3D%s, arch=3D%s, " + "machine=3D%s, virttype=3D%s,flags=3D0x%x", + conn, NULLSTR(emulator), NULLSTR(arch), + NULLSTR(machine), NULLSTR(virttype), flags); + + virResetLastError(); + virCheckConnectReturn(conn, -1); + + if (conn->driver->connectGetHypervisorCPUModelNames) { + int nmodels; + nmodels =3D conn->driver->connectGetHypervisorCPUModelNames(conn, + emulator, + arch, + machine, + virttype, + models, + flags); + if (nmodels < 0) { + goto error; + } + + return nmodels; + } + virReportUnsupportedError(); + + error: + virDispatchError(conn); + return -1; +} + + /** * virConnectBaselineCPU: * diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 7a3492d9d7..88f33427cc 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -948,4 +948,9 @@ LIBVIRT_10.2.0 { virDomainGraphicsReload; } LIBVIRT_10.1.0; =20 +LIBVIRT_11.1.0 { + global: + virConnectGetHypervisorCPUModelNames; +} LIBVIRT_10.2.0; + # .... define new API here using predicted next version number .... --=20 2.47.0