From nobody Sat Feb 7 16:00:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1679499612; cv=none; d=zohomail.com; s=zohoarc; b=n9A1Biv1+aqdMCo367Mcn00XGExJpnHHk43aQ3llBvOyosyEcC/463vgD+b92MgqSO3+EThFntMUwzmPul2zc5NE4Yo7T3SbXoUpIM/X32RQMGhd9gbsEbBMd2utxaCcVLo+fOTxCvlj1PXzZNIQrQLYYp7nOAeEmOq9jmU4EM0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679499612; 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; bh=zHE4q5DAcQNB6+2hE7DUtWLcHZXBnLNBeT9Q3ZHwRqE=; b=clj7Q8cFaLAIXFaWoifirQg+U4j0eonXlQ5nyUsZ0hkybpr+oiIGZjqww94hH1E8BbSC/83L6Q8vrMQpwwkE/yr9HUfmRNrVlKj20E/0U1qKHlgJr+5dCpTpV7CGgDqD/eaJml7ocRWxsT8Xujem8ZNvXXbp2of7BdJ8aN6dfSQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=reject dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1679499612059678.0422556246393; Wed, 22 Mar 2023 08:40:12 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-636-iZlpElqRPu6RO9cH9jo7lQ-1; Wed, 22 Mar 2023 11:40:06 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 862A43815EE5; Wed, 22 Mar 2023 15:40:03 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3AC94492C13; Wed, 22 Mar 2023 15:40:02 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E853D194658D; Wed, 22 Mar 2023 15:39:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 224E51946587 for ; Wed, 22 Mar 2023 15:39:51 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 02941492C14; Wed, 22 Mar 2023 15:39:51 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EE4CB492C13 for ; Wed, 22 Mar 2023 15:39:50 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D446B101A54F for ; Wed, 22 Mar 2023 15:39:50 +0000 (UTC) Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-588-7tqZJGODPGG9YfkTHP9XLg-1; Wed, 22 Mar 2023 11:39:49 -0400 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32MEs8nR003726 for ; Wed, 22 Mar 2023 15:39:48 GMT Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3pg3uj991b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 22 Mar 2023 15:39:48 +0000 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 32MEsntI014413 for ; Wed, 22 Mar 2023 15:39:47 GMT Received: from smtprelay05.wdc07v.mail.ibm.com ([9.208.129.117]) by ppma03dal.us.ibm.com (PPS) with ESMTPS id 3pd4x7f6q0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 22 Mar 2023 15:39:47 +0000 Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay05.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 32MFdjHc16057058 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 22 Mar 2023 15:39:46 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CCED758045; Wed, 22 Mar 2023 15:39:45 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 72D5858050; Wed, 22 Mar 2023 15:39:45 +0000 (GMT) Received: from dhcp-9-57-191-246.pok.ibm.com (unknown [9.57.191.246]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Wed, 22 Mar 2023 15:39:45 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679499611; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=zHE4q5DAcQNB6+2hE7DUtWLcHZXBnLNBeT9Q3ZHwRqE=; b=Yx8HNGfuxrMseXvwoPvYyglT8lisoi8rXceXnPSDECnt6mwoAz0bmjWESCvlXm6lIgsaui Iu5XOhxXoTAicQ7RGOuPdvm6dwtZz7ZkSmnBX8m7L2Pf5Sum5WOmoOet85c8qDNRZdUwT7 9vzXk16t4QBu+UasRaxZy5xMkn8n26I= X-MC-Unique: iZlpElqRPu6RO9cH9jo7lQ-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: 7tqZJGODPGG9YfkTHP9XLg-1 From: Collin Walling To: libvir-list@redhat.com Subject: [PATCH v1 1/4] Introduce virConnectGetHypervisorCPUNames public API Date: Wed, 22 Mar 2023 11:39:15 -0400 Message-Id: <20230322153918.96924-2-walling@linux.ibm.com> In-Reply-To: <20230322153918.96924-1-walling@linux.ibm.com> References: <20230322153918.96924-1-walling@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: B_9gRKOr-mDWnxwvrwiV348u72MbugWu X-Proofpoint-ORIG-GUID: B_9gRKOr-mDWnxwvrwiV348u72MbugWu X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-22_12,2023-03-22_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 spamscore=0 impostorscore=0 suspectscore=0 lowpriorityscore=0 mlxlogscore=863 phishscore=0 priorityscore=1501 clxscore=1015 adultscore=0 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303150002 definitions=main-2303220109 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fiuczy@linux.ibm.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1679499613346100001 Content-Type: text/plain; charset="utf-8"; x-default="true" 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: Collin Walling Reviewed-by: Boris Fiuczynski --- include/libvirt/libvirt-host.h | 6 ++++ src/driver-hypervisor.h | 9 ++++++ src/libvirt-host.c | 54 ++++++++++++++++++++++++++++++++++ src/libvirt_public.syms | 5 ++++ 4 files changed, 74 insertions(+) diff --git a/include/libvirt/libvirt-host.h b/include/libvirt/libvirt-host.h index 3112f2b676..a70a4d9971 100644 --- a/include/libvirt/libvirt-host.h +++ b/include/libvirt/libvirt-host.h @@ -961,6 +961,12 @@ int virConnectGetCPUModelNames(virConnectPtr conn, const char *arch, char ***models, unsigned int flags); +char *virConnectGetHypervisorCPUModelNames(virConnectPtr conn, + const char *emulator, + const char *arch, + const char *machine, + const char *virttype, + unsigned int flags); =20 /** * virConnectBaselineCPUFlags: diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h index 5219344b72..725c1db752 100644 --- a/src/driver-hypervisor.h +++ b/src/driver-hypervisor.h @@ -732,6 +732,14 @@ typedef int char ***models, unsigned int flags); =20 +typedef char * +(*virDrvConnectGetHypervisorCPUModelNames)(virConnectPtr conn, + const char *emulator, + const char *arch, + const char *machine, + const char *virttype, + unsigned int flags); + typedef int (*virDrvDomainGetJobInfo)(virDomainPtr domain, virDomainJobInfoPtr info); @@ -1701,6 +1709,7 @@ struct _virHypervisorDriver { virDrvDomainSetLifecycleAction domainSetLifecycleAction; virDrvConnectCompareHypervisorCPU connectCompareHypervisorCPU; virDrvConnectBaselineHypervisorCPU connectBaselineHypervisorCPU; + virDrvConnectGetHypervisorCPUModelNames connectGetHypervisorCPUModelNa= mes; virDrvNodeGetSEVInfo nodeGetSEVInfo; virDrvDomainGetLaunchSecurityInfo domainGetLaunchSecurityInfo; virDrvDomainSetLaunchSecurityState domainSetLaunchSecurityState; diff --git a/src/libvirt-host.c b/src/libvirt-host.c index a2ba347d54..407d19ffa9 100644 --- a/src/libvirt-host.c +++ b/src/libvirt-host.c @@ -1379,6 +1379,60 @@ virConnectBaselineHypervisorCPU(virConnectPtr conn, } =20 =20 +/** + * virConnectGetHypervisorCPUModelNames: + * + * @conn: pointer to the hypervisor connection + * @emulator: path to the emulator binary + * @arch: CPU architecture + * @machine: machine type + * @virttype: virtualization type + * @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 NULL on error, or a string of CPU models on success. + * + * Since: 9.2.0 + */ +char * +virConnectGetHypervisorCPUModelNames(virConnectPtr conn, + const char *emulator, + const char *arch, + const char *machine, + const char *virttype, + unsigned int flags) +{ + VIR_DEBUG("conn=3D%p, emulator=3D%s, arch=3D%s, machine=3D%s, virttype= =3D%s", + conn, NULLSTR(emulator), NULLSTR(arch), + NULLSTR(machine), NULLSTR(virttype)); + + virResetLastError(); + virCheckConnectReturn(conn, NULL); + + if (conn->driver->connectGetHypervisorCPUModelNames) { + char *result; + + result =3D conn->driver->connectGetHypervisorCPUModelNames(conn, e= mulator, arch, + machine, = virttype, flags); + if (!result) + goto error; + + return result; + } + + virReportUnsupportedError(); + + error: + virDispatchError(conn); + return NULL; +} + + /** * virConnectSetKeepAlive: * @conn: pointer to a hypervisor connection diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 80742f268e..df8d991cce 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -932,4 +932,9 @@ LIBVIRT_9.0.0 { virDomainFDAssociate; } LIBVIRT_8.5.0; =20 +LIBVIRT_9.2.0 { + global: + virConnectGetHypervisorCPUModelNames; +} LIBVIRT_9.0.0; + # .... define new API here using predicted next version number .... --=20 2.39.0 From nobody Sat Feb 7 16:00:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1679499824; cv=none; d=zohomail.com; s=zohoarc; b=K4G4hZJE53tKWcP6KjbeD5nNiDc3Eitaiqo7Dn1ReTZCR4caHtVBwd0EK+q5xx8E8oVZRu7vjTsqv7eGuz9NLnDn8x3odhhsVEmEjUgJJ4ZoKH3shJst5MLInM5IcnCefpw43Hed+Muc0CQceJbRfhJvVgLYR5edIuuCieW9YTY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679499824; 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; bh=LP//Yxfa06ZhzWEiAh0BekdoyLfs2VbUmMU/1wY+n6s=; b=inoyXsFBQikUti/EhbCbSylLLONrfBMynrvV5sfG5aLhSBaLbhBSV8ZKH+IwHm+eiEWEitjm5JXqJ+71QcjzI9PCK2ADZZxlvFy6uVnDv5VOBZL+vVO6wFFvNU4QLOG+xAz0Umu/TwykCDBmO4KTJxDLqBorfLGPOEZhaU2dEIQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=reject dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 167949982490311.260966792179829; Wed, 22 Mar 2023 08:43:44 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-464-LokAbtCZPTC6_BSKHJdJ5Q-1; Wed, 22 Mar 2023 11:43:40 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C252D87B2A8; Wed, 22 Mar 2023 15:43:37 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id AAC4740C6E68; Wed, 22 Mar 2023 15:43:37 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 768451946589; Wed, 22 Mar 2023 15:43:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 516911946587 for ; Wed, 22 Mar 2023 15:39:52 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 381F1202701F; Wed, 22 Mar 2023 15:39:52 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 30880202701E for ; Wed, 22 Mar 2023 15:39:52 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0F24485530F for ; Wed, 22 Mar 2023 15:39:52 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-537-pw_lMrSgOGmU03g1kW6zZQ-1; Wed, 22 Mar 2023 11:39:50 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32MDrR51009646 for ; Wed, 22 Mar 2023 15:39:49 GMT Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3pg2xvjyny-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 22 Mar 2023 15:39:48 +0000 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 32MFQx4a031162 for ; Wed, 22 Mar 2023 15:39:48 GMT Received: from smtprelay06.wdc07v.mail.ibm.com ([9.208.129.118]) by ppma03dal.us.ibm.com (PPS) with ESMTPS id 3pd4x7f6q4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 22 Mar 2023 15:39:48 +0000 Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay06.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 32MFdkZc8651278 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 22 Mar 2023 15:39:46 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 57F6E58045; Wed, 22 Mar 2023 15:39:46 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F208D58056; Wed, 22 Mar 2023 15:39:45 +0000 (GMT) Received: from dhcp-9-57-191-246.pok.ibm.com (unknown [9.57.191.246]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Wed, 22 Mar 2023 15:39:45 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679499823; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=LP//Yxfa06ZhzWEiAh0BekdoyLfs2VbUmMU/1wY+n6s=; b=iqOIy7hvWu90oVeX/HZIFL8sd5m9kadtR5bHvjE5s+hGUKPQ6nQsOAfDQq+MBtToqDdFvT WlCmZTD1gDu0T6blntllhYWsHqzKoG1vchc7F0uiIzJ4eao9ohlLSGt1EN11fqju8EPTyV CSgFRnRJDWtOP4dlhlupVFX7VvvsaVs= X-MC-Unique: LokAbtCZPTC6_BSKHJdJ5Q-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: pw_lMrSgOGmU03g1kW6zZQ-1 From: Collin Walling To: libvir-list@redhat.com Subject: [PATCH v1 2/4] remote: Implement virConnectGetHypervisorCPUNames Date: Wed, 22 Mar 2023 11:39:16 -0400 Message-Id: <20230322153918.96924-3-walling@linux.ibm.com> In-Reply-To: <20230322153918.96924-1-walling@linux.ibm.com> References: <20230322153918.96924-1-walling@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Avr7nMJKdjFi_JPH4ucmvjBEImv5_jOj X-Proofpoint-ORIG-GUID: Avr7nMJKdjFi_JPH4ucmvjBEImv5_jOj X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-22_12,2023-03-22_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 mlxscore=0 suspectscore=0 clxscore=1015 lowpriorityscore=0 mlxlogscore=317 phishscore=0 spamscore=0 bulkscore=0 priorityscore=1501 adultscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303150002 definitions=main-2303220111 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fiuczy@linux.ibm.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1679499827063100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: Collin Walling Reviewed-by: Boris Fiuczynski --- src/remote/remote_driver.c | 1 + src/remote/remote_protocol.x | 20 +++++++++++++++++++- src/remote_protocol-structs | 11 +++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index a4c60be3d7..10d10c5464 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -8107,6 +8107,7 @@ static virHypervisorDriver hypervisor_driver =3D { .domainSetLifecycleAction =3D remoteDomainSetLifecycleAction, /* 3.9.0= */ .connectCompareHypervisorCPU =3D remoteConnectCompareHypervisorCPU, /*= 4.4.0 */ .connectBaselineHypervisorCPU =3D remoteConnectBaselineHypervisorCPU, = /* 4.4.0 */ + .connectGetHypervisorCPUModelNames =3D remoteConnectGetHypervisorCPUMo= delNames, /* 9.2.0 */ .nodeGetSEVInfo =3D remoteNodeGetSEVInfo, /* 4.5.0 */ .domainGetLaunchSecurityInfo =3D remoteDomainGetLaunchSecurityInfo, /*= 4.5.0 */ .domainCheckpointCreateXML =3D remoteDomainCheckpointCreateXML, /* 5.6= .0 */ diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index 5d86a51116..ec179e618a 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -3646,6 +3646,18 @@ struct remote_connect_baseline_hypervisor_cpu_ret { remote_nonnull_string cpu; }; =20 +struct remote_connect_get_hypervisor_cpu_model_names_args { + remote_string emulator; + remote_string arch; + remote_string machine; + remote_string virttype; + unsigned int flags; +}; + +struct remote_connect_get_hypervisor_cpu_model_names_ret { + remote_nonnull_string models; +}; + struct remote_node_get_sev_info_args { int nparams; unsigned int flags; @@ -6974,5 +6986,11 @@ enum remote_procedure { * @generate: none * @acl: domain:write */ - REMOTE_PROC_DOMAIN_FD_ASSOCIATE =3D 443 + REMOTE_PROC_DOMAIN_FD_ASSOCIATE =3D 443, + + /** + * @generate: both + * @acl: connect:write + */ + REMOTE_PROC_CONNECT_GET_HYPERVISOR_CPU_MODEL_NAMES =3D 444 }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index 3c6c230a16..947c95c832 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -3003,6 +3003,16 @@ struct remote_connect_baseline_hypervisor_cpu_args { struct remote_connect_baseline_hypervisor_cpu_ret { remote_nonnull_string cpu; }; +struct remote_connect_get_hypervisor_cpu_model_names_args { + remote_string emulator; + remote_string arch; + remote_string machine; + remote_string virttype; + u_int flags; +}; +struct remote_connect_get_hypervisor_cpu_model_names_ret { + remote_nonnull_string models; +}; struct remote_node_get_sev_info_args { int nparams; u_int flags; @@ -3717,4 +3727,5 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_RESTORE_PARAMS =3D 441, REMOTE_PROC_DOMAIN_ABORT_JOB_FLAGS =3D 442, REMOTE_PROC_DOMAIN_FD_ASSOCIATE =3D 443, + REMOTE_PROC_CONNECT_GET_HYPERVISOR_CPU_MODEL_NAMES =3D 444, }; --=20 2.39.0 From nobody Sat Feb 7 16:00:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1679499685; cv=none; d=zohomail.com; s=zohoarc; b=Gxi5GvvQXKBcpqCvab6O79926lN112LKQbzPDSHof9+twK1LfuEG6MriHbOl4Qfci+rbguEFkDF/aYsTKo4PSzpUdi6Q1qt718bNvV/6iblRmq7CaOi4ErsFX39vflC3qgk7OIxdTsb/uoRnO3Z9oIkXsCkIg1M7dyMZTu/ocJY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679499685; 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; bh=VNJkQJcpXh5L2AlXk5vsftW6q7c7NegEFdBn7yQOFLg=; b=JkxM4Mygc5MlMxUzHWzBxbILN6k5TxZbWdrFuTkIkWdsGJS3ydk3V2AygL5wc9+K9ifijOG7V1Q/Y3Wn4W1ceIoKwNdZU1l/D17FAarfXqiu9kFiEufCo8LsLAM6K4RaMx8Yd/vG25lrR7hJr+MYwFsrtixv/6ZxjrqJkA1ijak= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=reject dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 167949968521074.02752603255419; Wed, 22 Mar 2023 08:41:25 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-391-9yBnwRXBMkW8lMJ7DZl3lA-1; Wed, 22 Mar 2023 11:41:17 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 00F0D1C08966; Wed, 22 Mar 2023 15:41:13 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id DF05E202701E; Wed, 22 Mar 2023 15:41:12 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 938971946589; Wed, 22 Mar 2023 15:41:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 731E31946587 for ; Wed, 22 Mar 2023 15:39:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 58CD81410F1E; Wed, 22 Mar 2023 15:39:53 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5108D140E95F for ; Wed, 22 Mar 2023 15:39:53 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3547D85A5B1 for ; Wed, 22 Mar 2023 15:39:53 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-647-KeLeR0lQORC2eEYmW1ZyXA-1; Wed, 22 Mar 2023 11:39:51 -0400 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32MFCfM7017924 for ; Wed, 22 Mar 2023 15:39:49 GMT Received: from ppma04wdc.us.ibm.com (1a.90.2fa9.ip4.static.sl-reverse.com [169.47.144.26]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3pg447gs2n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 22 Mar 2023 15:39:49 +0000 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 32MFMNl5011659 for ; Wed, 22 Mar 2023 15:39:48 GMT Received: from smtprelay06.wdc07v.mail.ibm.com ([9.208.129.118]) by ppma04wdc.us.ibm.com (PPS) with ESMTPS id 3pd4x791c0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 22 Mar 2023 15:39:48 +0000 Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay06.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 32MFdkPR12124682 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 22 Mar 2023 15:39:46 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D1BBD58050; Wed, 22 Mar 2023 15:39:46 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7D4C758054; Wed, 22 Mar 2023 15:39:46 +0000 (GMT) Received: from dhcp-9-57-191-246.pok.ibm.com (unknown [9.57.191.246]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Wed, 22 Mar 2023 15:39:46 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679499682; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=VNJkQJcpXh5L2AlXk5vsftW6q7c7NegEFdBn7yQOFLg=; b=bzWhrqi4V8c3UDFgKmeYbhyyPlR7tLlF96MaaEUxLx3OZvh3zXR+RpOoQ9zi47ZxRBNEPI UcBY92shgOaG4wTnV23OiawKJHemFxHldvQXm8qzoVENgR6fMgdweuKNZTOvFZwIAnLs9n GzWdoQn/Fyjd79bx3lluGNyPXG60z2U= X-MC-Unique: 9yBnwRXBMkW8lMJ7DZl3lA-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: KeLeR0lQORC2eEYmW1ZyXA-1 From: Collin Walling To: libvir-list@redhat.com Subject: [PATCH v1 3/4] virsh: Introduce new hypervisor-cpu-models command Date: Wed, 22 Mar 2023 11:39:17 -0400 Message-Id: <20230322153918.96924-4-walling@linux.ibm.com> In-Reply-To: <20230322153918.96924-1-walling@linux.ibm.com> References: <20230322153918.96924-1-walling@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: sFTdWwUfpSykMJUapLcQ6vfwD5tkcLJD X-Proofpoint-ORIG-GUID: sFTdWwUfpSykMJUapLcQ6vfwD5tkcLJD X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-22_12,2023-03-22_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 suspectscore=0 bulkscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 malwarescore=0 mlxscore=0 mlxlogscore=921 spamscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303150002 definitions=main-2303220111 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fiuczy@linux.ibm.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1679499686089100001 Content-Type: text/plain; charset="utf-8"; x-default="true" This command is a virsh wrapper for virConnectGetHypervisorCPUNames. Signed-off-by: Collin Walling Reviewed-by: Boris Fiuczynski --- docs/manpages/virsh.rst | 20 ++++++++++++ tools/virsh-host.c | 70 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 26c328d390..c156e60d6e 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -1004,6 +1004,26 @@ listed in the XML description. If *--migratable* is = specified, features that block migration will not be included in the resulting CPU. =20 =20 +hypervisor-cpu-models +--------------------- + +**Syntax:** + +:: + + hypervisor-cpu-models [virttype] [emulator] [arch] [machine] + +Print the list of CPU models known by the hypervisor for the specified arc= hitecture. +It is not guaranteed that a listed CPU will run on the host. To determine = CPU +model compatibility with the host, see ``virsh hypervisor-cpu-baseline`` a= nd +``virsh hypervisor-cpu-compare``. + +The *virttype* option specifies the virtualization type (usable in the 'ty= pe' +attribute of the top level element from the domain XML). *emulato= r* +specifies the path to the emulator, *arch* specifies the CPU architecture,= and +*machine* specifies the machine type. + + DOMAIN COMMANDS =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 diff --git a/tools/virsh-host.c b/tools/virsh-host.c index 21d479fd01..2eedc1517b 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -1779,6 +1779,70 @@ cmdHypervisorCPUBaseline(vshControl *ctl, return ret; } =20 +/* + * "hypervisor-cpu-models" command + */ +static const vshCmdInfo info_hypervisor_cpu_models[] =3D { + {.name =3D "help", + .data =3D N_("Hypervisor reported CPU models") + }, + {.name =3D "desc", + .data =3D N_("Get the CPU models reported by the hypervisor.") + }, + {.name =3D NULL} +}; + +static const vshCmdOptDef opts_hypervisor_cpu_models[] =3D { + {.name =3D "virttype", + .type =3D VSH_OT_STRING, + .completer =3D virshDomainVirtTypeCompleter, + .help =3D N_("virtualization type (/domain/@type)"), + }, + {.name =3D "emulator", + .type =3D VSH_OT_STRING, + .help =3D N_("path to emulator binary (/domain/devices/emulator)"), + }, + {.name =3D "arch", + .type =3D VSH_OT_STRING, + .completer =3D virshArchCompleter, + .help =3D N_("CPU architecture (/domain/os/type/@arch)"), + }, + {.name =3D "machine", + .type =3D VSH_OT_STRING, + .help =3D N_("machine type (/domain/os/type/@machine)"), + }, + {.name =3D NULL} +}; + +static bool +cmdHypervisorCPUModelNames(vshControl *ctl, + const vshCmd *cmd) +{ + const char *virttype =3D NULL; + const char *emulator =3D NULL; + const char *arch =3D NULL; + const char *machine =3D NULL; + g_autofree char *result =3D NULL; + virshControl *priv =3D ctl->privData; + + if (vshCommandOptStringReq(ctl, cmd, "virttype", &virttype) < 0 || + vshCommandOptStringReq(ctl, cmd, "emulator", &emulator) < 0 || + vshCommandOptStringReq(ctl, cmd, "arch", &arch) < 0 || + vshCommandOptStringReq(ctl, cmd, "machine", &machine) < 0) + return false; + + result =3D virConnectGetHypervisorCPUModelNames(priv->conn, emulator, = arch, + machine, virttype, 0); + + if (!result) { + vshError(ctl, "%s", _("failed to get CPU model names")); + return false; + } + + vshPrint(ctl, "%s\n", result); + return true; +} + =20 const vshCmdDef hostAndHypervisorCmds[] =3D { {.name =3D "allocpages", @@ -1847,6 +1911,12 @@ const vshCmdDef hostAndHypervisorCmds[] =3D { .info =3D info_hypervisor_cpu_compare, .flags =3D 0 }, + {.name =3D "hypervisor-cpu-models", + .handler =3D cmdHypervisorCPUModelNames, + .opts =3D opts_hypervisor_cpu_models, + .info =3D info_hypervisor_cpu_models, + .flags =3D 0 + }, {.name =3D "maxvcpus", .handler =3D cmdMaxvcpus, .opts =3D opts_maxvcpus, --=20 2.39.0 From nobody Sat Feb 7 16:00:51 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1679499652; cv=none; d=zohomail.com; s=zohoarc; b=PGdXpzaMXiMwqKazufUd04mHL5MPntL9PCMl6Q6skZI9liYfjvSC9YB5TafRcL8vKfsQr2G6hSKSputtAZEZC8n8Rn5z32tJuPGj6/zwq4mV7C8Jb0188xxpvOT80vb9B1xU/sNJTTCJa+TZYaaDoVkZcqtND4mGXmcNByJS3ZQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679499652; 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; bh=n2M4IXkIO8SjotoyTxhic72rnk70o4jvTozzz8IR0ws=; b=YPgYtjL+NEQjDuARq8MskvSGN530kWeK8dLb7Riyyuw9SUpELWMMbcLGl4zsKmsUl6Kt8xD+a1C1KSbojAhOu8slf8jK5TDZI3P8u+pn+3I3L+kqcqaZrOHcSpw6WnEVXu88H1/o+OikcvxSRnb54G7y+Dtxhguj6Y3zmbJ2yBA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=reject dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1679499652389248.4014090271935; Wed, 22 Mar 2023 08:40:52 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-669-5QwsjMrcMSKU05SKdbPqlw-1; Wed, 22 Mar 2023 11:40:49 -0400 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8734C80280D; Wed, 22 Mar 2023 15:40:45 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7422342C827; Wed, 22 Mar 2023 15:40:45 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 45F831946589; Wed, 22 Mar 2023 15:40:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2DF271946587 for ; Wed, 22 Mar 2023 15:39:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 014B51410F1F; Wed, 22 Mar 2023 15:39:53 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EDCA11410F1E for ; Wed, 22 Mar 2023 15:39:52 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D196F101A551 for ; Wed, 22 Mar 2023 15:39:52 +0000 (UTC) Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-168-Tzbd3wzyPd-1odImySDXWw-1; Wed, 22 Mar 2023 11:39:50 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32MEfIHK020737 for ; Wed, 22 Mar 2023 15:39:50 GMT Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3pg1xjn3e4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 22 Mar 2023 15:39:50 +0000 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 32MEVxCF010269 for ; Wed, 22 Mar 2023 15:39:49 GMT Received: from smtprelay07.wdc07v.mail.ibm.com ([9.208.129.116]) by ppma03dal.us.ibm.com (PPS) with ESMTPS id 3pd4x7f6qa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 22 Mar 2023 15:39:49 +0000 Received: from smtpav04.wdc07v.mail.ibm.com (smtpav04.wdc07v.mail.ibm.com [10.39.53.231]) by smtprelay07.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 32MFdloQ59703718 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 22 Mar 2023 15:39:47 GMT Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 57E2658050; Wed, 22 Mar 2023 15:39:47 +0000 (GMT) Received: from smtpav04.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0305A58045; Wed, 22 Mar 2023 15:39:47 +0000 (GMT) Received: from dhcp-9-57-191-246.pok.ibm.com (unknown [9.57.191.246]) by smtpav04.wdc07v.mail.ibm.com (Postfix) with ESMTP; Wed, 22 Mar 2023 15:39:46 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679499651; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=n2M4IXkIO8SjotoyTxhic72rnk70o4jvTozzz8IR0ws=; b=a+NCKVGxsJ59tGGTGsCwUGwAHWg7bm6vSJq4nUr8XW6z2Fapoj4EvlQRimXCUi0v60zRLb +irlWzfTWMGwCgclPMcezmgnDdkKJdkzLeQn+6z7Oy0HYPD9LReyl7mpAN/jW8/dzKyRyO iQtx14gK5OzeFRXDg5p4/70iq2x+O1g= X-MC-Unique: 5QwsjMrcMSKU05SKdbPqlw-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: Tzbd3wzyPd-1odImySDXWw-1 From: Collin Walling To: libvir-list@redhat.com Subject: [PATCH v1 4/4] qemu_driver: Implement qemuConnectGetHypervisorCPUNames Date: Wed, 22 Mar 2023 11:39:18 -0400 Message-Id: <20230322153918.96924-5-walling@linux.ibm.com> In-Reply-To: <20230322153918.96924-1-walling@linux.ibm.com> References: <20230322153918.96924-1-walling@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: z7hUOfq_IVAFdq3_lsSHgOvVuC9Wxn5e X-Proofpoint-GUID: z7hUOfq_IVAFdq3_lsSHgOvVuC9Wxn5e X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-22_12,2023-03-22_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 mlxscore=0 priorityscore=1501 adultscore=0 mlxlogscore=593 clxscore=1015 malwarescore=0 lowpriorityscore=0 suspectscore=0 phishscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303150002 definitions=main-2303220106 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fiuczy@linux.ibm.com Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1679499653724100001 Content-Type: text/plain; charset="utf-8"; x-default="true" This function is hooked into the virsh hypervisor-cpu-models command. The CPU models are read directly from the QEMU capabilities file, which contains a list of all models queried from the hypervisor. Signed-off-by: Collin Walling Reviewed-by: Boris Fiuczynski --- src/qemu/qemu_driver.c | 62 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 09ae893daf..e101da4d21 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -12400,6 +12400,67 @@ qemuConnectBaselineHypervisorCPU(virConnectPtr con= n, } =20 =20 +static char * +qemuConnectGetHypervisorCPUModelNames(virConnectPtr conn, + const char *emulator, + const char *archStr, + const char *machine, + const char *virttypeStr, + unsigned int flags) +{ + virQEMUDriver *driver =3D conn->privateData; + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + g_autoptr(virDomainCapsCPUModels) cpuModels =3D NULL; + g_autoptr(virQEMUCaps) qemuCaps =3D NULL; + char *modelsstr =3D g_strdup(""); + virDomainVirtType virttype; + virArch arch; + size_t i; + + virCheckFlags(0, NULL); + + if (virConnectGetHypervisorCPUModelNamesEnsureACL(conn) < 0) + return NULL; + + qemuCaps =3D virQEMUCapsCacheLookupDefault(driver->qemuCapsCache, + emulator, + archStr, + virttypeStr, + machine, + &arch, &virttype, NULL); + if (!qemuCaps) + return NULL; + + if (!(cpuModels =3D virQEMUCapsGetCPUModels(qemuCaps, virttype, NULL, = NULL)) || + cpuModels->nmodels =3D=3D 0) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("QEMU '%s' does not support any CPU models for " + "virttype '%s'"), + virQEMUCapsGetBinary(qemuCaps), + virDomainVirtTypeToString(virttype)); + return NULL; + } + + for (i =3D 0; i < cpuModels->nmodels; i++) { + const char *name =3D cpuModels->models[i].name; + char *oldstr =3D modelsstr; + /* + * These models are not architecture-specific, but rather + * generic QEMU models, so let's filter them out + */ + if (STREQ(name, "host") || + STREQ(name, "qemu") || + STREQ(name, "max")) + continue; + + modelsstr =3D g_strdup_printf("%s\n%s", name, modelsstr); + g_free(oldstr); + } + + return modelsstr; +} + + static int qemuDomainGetJobInfoMigrationStats(virDomainObj *vm, virDomainJobData *jobData) @@ -20814,6 +20875,7 @@ static virHypervisorDriver qemuHypervisorDriver =3D= { .domainSetLifecycleAction =3D qemuDomainSetLifecycleAction, /* 3.9.0 */ .connectCompareHypervisorCPU =3D qemuConnectCompareHypervisorCPU, /* 4= .4.0 */ .connectBaselineHypervisorCPU =3D qemuConnectBaselineHypervisorCPU, /*= 4.4.0 */ + .connectGetHypervisorCPUModelNames =3D qemuConnectGetHypervisorCPUMode= lNames, /* 9.2.0 */ .nodeGetSEVInfo =3D qemuNodeGetSEVInfo, /* 4.5.0 */ .domainGetLaunchSecurityInfo =3D qemuDomainGetLaunchSecurityInfo, /* 4= .5.0 */ .domainCheckpointCreateXML =3D qemuDomainCheckpointCreateXML, /* 5.6.0= */ --=20 2.39.0