From nobody Mon Feb 9 17:35:19 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=pass(p=none dis=none) header.from=redhat.com 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 1656432603436703.9228505885077; Tue, 28 Jun 2022 09:10:03 -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-642-n5B2IG7eNR65yPf_-Uyaiw-1; Tue, 28 Jun 2022 12:09:56 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C391C28061F3; Tue, 28 Jun 2022 16:09:50 +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 AFF501121314; Tue, 28 Jun 2022 16:09:50 +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 EC49C1947062; Tue, 28 Jun 2022 16:09:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 56A701947059 for ; Tue, 28 Jun 2022 16:09:49 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3B68C2166B2A; Tue, 28 Jun 2022 16:09:49 +0000 (UTC) Received: from work.fritz.box (unknown [10.39.193.108]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD7D22166B26; Tue, 28 Jun 2022 16:09:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656432602; 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=DQJkhMppfGx3QNDIHuBXrcINI/XnSha7GbIpc/PHNCw=; b=DjQFfIATcF75U5DDEe1T4Az5BmKUDtGlQ2gA4Yar/ZliDMStj1SXSZcb682JyzWgGiH6y/ 9PcvLFQfkkdfVe7yFmN3sYOYOic1hM0kPreDVyq2H+ybYr08z9t8NLVkCyVj1iDgZF3btA jKCerwLmXST5hmQTsrq79h0pOCB8464= X-MC-Unique: n5B2IG7eNR65yPf_-Uyaiw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 2/9] libvirt: introduce virConnectGetHypervisorCPUModelNames public API Date: Tue, 28 Jun 2022 18:09:39 +0200 Message-Id: <20220628160946.61028-3-twiederh@redhat.com> In-Reply-To: <20220628160946.61028-1-twiederh@redhat.com> References: <20220628160946.61028-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 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: Tim Wiederhake Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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: 1656432604981100005 Content-Type: text/plain; charset="utf-8"; x-default="true" Create a function to query the hypervisor for its list of known CPU model names. This is different from virConnectGetCPUModelNames, as this new function will determine the list of CPU models (and alias names) at runtime. Signed-off-by: Tim Wiederhake --- include/libvirt/libvirt-host.h | 6 ++++ src/driver-hypervisor.h | 8 +++++ src/libvirt-host.c | 55 ++++++++++++++++++++++++++++++++++ src/libvirt_public.syms | 1 + 4 files changed, 70 insertions(+) diff --git a/include/libvirt/libvirt-host.h b/include/libvirt/libvirt-host.h index 3112f2b676..5aaa001adb 100644 --- a/include/libvirt/libvirt-host.h +++ b/include/libvirt/libvirt-host.h @@ -962,6 +962,12 @@ int virConnectGetCPUModelNames(virConnectPtr conn, char ***models, unsigned int flags); =20 +int virConnectGetHypervisorCPUModelNames(virConnectPtr conn, + const char *arch, + char ***names, + char ***aliases, + unsigned int flags); + /** * virConnectBaselineCPUFlags: * diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h index 016d5cec7c..c81e5d4c75 100644 --- a/src/driver-hypervisor.h +++ b/src/driver-hypervisor.h @@ -732,6 +732,13 @@ typedef int char ***models, unsigned int flags); =20 +typedef int +(*virDrvConnectGetHypervisorCPUModelNames)(virConnectPtr conn, + const char *archName, + char ***names, + char ***aliases, + unsigned int flags); + typedef int (*virDrvDomainGetJobInfo)(virDomainPtr domain, virDomainJobInfoPtr info); @@ -1712,4 +1719,5 @@ struct _virHypervisorDriver { virDrvDomainAuthorizedSSHKeysSet domainAuthorizedSSHKeysSet; virDrvDomainGetMessages domainGetMessages; virDrvDomainStartDirtyRateCalc domainStartDirtyRateCalc; + virDrvConnectGetHypervisorCPUModelNames connectGetHypervisorCPUModelNa= mes; }; diff --git a/src/libvirt-host.c b/src/libvirt-host.c index 2ee6370bce..6e734628c1 100644 --- a/src/libvirt-host.c +++ b/src/libvirt-host.c @@ -1234,6 +1234,61 @@ virConnectGetCPUModelNames(virConnectPtr conn, const= char *arch, char ***models, } =20 =20 +/** + * virConnectGetHypervisorCPUModelNames: + * + * @conn: virConnect connection + * @arch: Architecture + * @names: Pointer to a variable to store the NULL-terminated array of the= CPU + * models supported by the hypervisor for the specified architectu= re. + * Each element and the array itself must be freed by the caller. + * @aliases: Pointer to a variable to store the NULL-terminated array of a= lias + * names for CPU model names. Each element and the array itself = must + * be freed by the caller. + * @flags: extra flags; not used yet, so callers should always pass 0. + * + * Get the list of CPU models supported by the hypervisor for a specific + * architecture. + * + * If @aliases[x] is not an empty string, @names[x] is an alias for that C= PU + * model. + * + * Returns -1 on error, number of elements in @models on success. + * + * Since: 8.5.0 + */ +int +virConnectGetHypervisorCPUModelNames(virConnectPtr conn, + const char *arch, + char ***names, + char ***aliases, + unsigned int flags) +{ + VIR_DEBUG("conn=3D%p, arch=3D%s, flags=3D0x%x", conn, NULLSTR(arch), f= lags); + virResetLastError(); + + virCheckConnectReturn(conn, -1); + virCheckNonNullArgGoto(arch, error); + + if (conn->driver->connectGetHypervisorCPUModelNames) { + int ret; + + ret =3D conn->driver->connectGetHypervisorCPUModelNames(conn, arch= , names, + aliases, fla= gs); + if (ret < 0) + goto error; + + return ret; + } + + virReportUnsupportedError(); + + error: + virDispatchError(conn); + return -1; +} + + /** * virConnectBaselineCPU: * diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index 297a2c436a..c6a8e898ae 100644 --- a/src/libvirt_public.syms +++ b/src/libvirt_public.syms @@ -924,6 +924,7 @@ LIBVIRT_8.4.0 { =20 LIBVIRT_8.5.0 { global: + virConnectGetHypervisorCPUModelNames; virDomainAbortJobFlags; } LIBVIRT_8.4.0; =20 --=20 2.31.1