From nobody Mon May 13 20:39:15 2024 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 1656432604388917.1450902823569; Tue, 28 Jun 2022 09:10:04 -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-610-DipPc-odNqSRlOVvq37pRA-1; Tue, 28 Jun 2022 12:09:58 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F2696801E67; Tue, 28 Jun 2022 16:09:51 +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 DEF00141510C; Tue, 28 Jun 2022 16:09:51 +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 98F161947058; Tue, 28 Jun 2022 16:09:51 +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 91F2A19466DF for ; Tue, 28 Jun 2022 16:09:48 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 85C8D2166B2A; Tue, 28 Jun 2022 16:09:48 +0000 (UTC) Received: from work.fritz.box (unknown [10.39.193.108]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1428C2166B26; Tue, 28 Jun 2022 16:09:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656432603; 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=d+R7iNkdjZOYLyLsg3MFXpxxde/zex1k52l7dqVqJiE=; b=LlE2k3yscu8+09BV6wrrLTH7yJIpWK80ZbPlpXSKrOiWpeP8nLPe9g6Sk6zagJivOsjSES h8Ycm4oqU9jEC6XxMvKVpfzHtnFG96Hf9LbYFfJd+oFbK2lYY/aCXsBEckBLVEYRc45a1p uewgpRBX+NjkZg8wMK5rswXNjnUG+bk= X-MC-Unique: DipPc-odNqSRlOVvq37pRA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 1/9] qemuMonitorCPUDefInfo: Add alias Date: Tue, 28 Jun 2022 18:09:38 +0200 Message-Id: <20220628160946.61028-2-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.85 on 10.11.54.7 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: 1656432604969100003 Content-Type: text/plain; charset="utf-8"; x-default="true" Preserve the "alias-of" information of the qemu response that indicates that the cpu model is merely an alternate name for another cpu model. Signed-off-by: Tim Wiederhake Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_monitor.c | 2 ++ src/qemu/qemu_monitor.h | 1 + src/qemu/qemu_monitor_json.c | 3 +++ 3 files changed, 6 insertions(+) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index fda5d2f368..ccea577ebc 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -3363,6 +3363,7 @@ qemuMonitorCPUDefsFree(qemuMonitorCPUDefs *defs) for (i =3D 0; i < defs->ncpus; i++) { g_strfreev(defs->cpus[i].blockers); g_free(defs->cpus[i].name); + g_free(defs->cpus[i].alias); g_free(defs->cpus[i].type); } =20 @@ -3400,6 +3401,7 @@ qemuMonitorCPUDefsCopy(qemuMonitorCPUDefs *src) =20 cpuDst->usable =3D cpuSrc->usable; cpuDst->name =3D g_strdup(cpuSrc->name); + cpuDst->alias =3D g_strdup(cpuSrc->alias); cpuDst->type =3D g_strdup(cpuSrc->type); cpuDst->blockers =3D g_strdupv(cpuSrc->blockers); cpuDst->deprecated =3D cpuSrc->deprecated; diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index 95267ec6c7..6cb4ff1e22 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -1150,6 +1150,7 @@ typedef struct _qemuMonitorCPUDefInfo qemuMonitorCPUD= efInfo; struct _qemuMonitorCPUDefInfo { virDomainCapsCPUUsable usable; char *name; + char *alias; char *type; char **blockers; /* NULL-terminated string list */ bool deprecated; diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 3aad2ab212..4ffd3bbed7 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -5274,6 +5274,9 @@ qemuMonitorJSONGetCPUDefinitions(qemuMonitor *mon, =20 cpu->name =3D g_strdup(tmp); =20 + if ((tmp =3D virJSONValueObjectGetString(child, "alias-of")) && *t= mp) + cpu->alias =3D g_strdup(tmp); + if ((tmp =3D virJSONValueObjectGetString(child, "typename")) && *t= mp) cpu->type =3D g_strdup(tmp); =20 --=20 2.31.1 From nobody Mon May 13 20:39:15 2024 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 From nobody Mon May 13 20:39:15 2024 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 1656432606216405.26089134308336; Tue, 28 Jun 2022 09:10:06 -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-22-y2xqK1DVM4-0uMZXR1zQug-1; Tue, 28 Jun 2022 12:09:59 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9FABA38173D4; Tue, 28 Jun 2022 16:09:53 +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 7F2D51400C2B; Tue, 28 Jun 2022 16:09:53 +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 3C7931947061; Tue, 28 Jun 2022 16:09:53 +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 31481194706A for ; Tue, 28 Jun 2022 16:09:50 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 1D8912166B29; Tue, 28 Jun 2022 16:09:50 +0000 (UTC) Received: from work.fritz.box (unknown [10.39.193.108]) by smtp.corp.redhat.com (Postfix) with ESMTP id 733532166B26; Tue, 28 Jun 2022 16:09:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656432605; 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=2BT9z9tcidRnHAOUQqbmGSHLQj7k0A2H0ZfL9i10c4Q=; b=eXhxNjLnfPP82IvfUebLmX7xJNmUedh+tRTSD3zCDahiBjGAFlueOFNXclW7oMe8Cmdegm hpJGcSoJGvMI4h55lkFiDqM54grH93l8kYCwyxg+QIi/JiyUkDwMcdgpu7OS1Zp2lxXavT 542f18kpTgWE92J9QgYbLuaAiFZLyUw= X-MC-Unique: y2xqK1DVM4-0uMZXR1zQug-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 3/9] remote: Add RPC support for the virConnectGetHypervisorCPUModelNames API Date: Tue, 28 Jun 2022 18:09:40 +0200 Message-Id: <20220628160946.61028-4-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.85 on 10.11.54.7 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: 1656432607108100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: Tim Wiederhake --- src/remote/remote_daemon_dispatch.c | 44 +++++++++++++++++++++ src/remote/remote_driver.c | 59 +++++++++++++++++++++++++++++ src/remote/remote_protocol.x | 19 +++++++++- src/remote_protocol-structs | 16 ++++++++ 4 files changed, 137 insertions(+), 1 deletion(-) diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon= _dispatch.c index dc5790f077..9011977e18 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -5869,6 +5869,50 @@ remoteDispatchConnectGetCPUModelNames(virNetServer *= server G_GNUC_UNUSED, } =20 =20 +static int +remoteDispatchConnectGetHypervisorCPUModelNames(virNetServer *server G_GNU= C_UNUSED, + virNetServerClient *client, + virNetMessage *msg G_GNUC_= UNUSED, + struct virNetMessageError = *rerr, + remote_connect_get_hypervi= sor_cpu_model_names_args *args, + remote_connect_get_hypervi= sor_cpu_model_names_ret *ret) +{ + int len =3D 0; + int rv =3D -1; + g_auto(GStrv) names =3D NULL; + g_auto(GStrv) aliases =3D NULL; + virConnectPtr conn =3D remoteGetHypervisorConn(client); + + if (!conn) + goto cleanup; + + len =3D virConnectGetHypervisorCPUModelNames(conn, args->arch, &names, + &aliases, args->flags); + if (len < 0) + goto cleanup; + + if (len > REMOTE_CONNECT_CPU_MODELS_MAX) { + virReportError(VIR_ERR_RPC, + _("Too many CPU models '%d' for limit '%d'"), + len, REMOTE_CONNECT_CPU_MODELS_MAX); + goto cleanup; + } + + ret->names.names_val =3D g_steal_pointer(&names); + ret->names.names_len =3D len; + ret->aliases.aliases_val =3D g_steal_pointer(&aliases); + ret->aliases.aliases_len =3D len; + ret->ret =3D len; + + rv =3D 0; + + cleanup: + if (rv < 0) + virNetMessageSaveError(rerr); + return rv; +} + + static int remoteDispatchDomainCreateXMLWithFiles(virNetServer *server G_GNUC_UNUSED, virNetServerClient *client, diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 94566069f0..8dca23a7eb 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -6393,6 +6393,64 @@ remoteConnectGetCPUModelNames(virConnectPtr conn, } =20 =20 +static int +remoteConnectGetHypervisorCPUModelNames(virConnectPtr conn, + const char *archName, + char ***names, + char ***aliases, + unsigned int flags) +{ + int rv =3D -1; + size_t i; + remote_connect_get_hypervisor_cpu_model_names_args args; + remote_connect_get_hypervisor_cpu_model_names_ret ret; + + struct private_data *priv =3D conn->privateData; + + remoteDriverLock(priv); + + args.arch =3D (char *) archName; + args.flags =3D flags; + + memset(&ret, 0, sizeof(ret)); + if (call(conn, priv, 0, REMOTE_PROC_CONNECT_GET_HYPERVISOR_CPU_MODEL_N= AMES, + (xdrproc_t) xdr_remote_connect_get_hypervisor_cpu_model_names= _args, + (char *) &args, + (xdrproc_t) xdr_remote_connect_get_hypervisor_cpu_model_names= _ret, + (char *) &ret) < 0) + goto done; + + /* Check the length of the returned list carefully. */ + if (ret.names.names_len > REMOTE_CONNECT_CPU_MODELS_MAX) { + virReportError(VIR_ERR_RPC, + _("Too many model names '%d' for limit '%d'"), + ret.names.names_len, + REMOTE_CONNECT_CPU_MODELS_MAX); + goto cleanup; + } + + *names =3D g_new0(char *, ret.names.names_len + 1); + for (i =3D 0; i < ret.names.names_len; i++) { + (*names)[i] =3D g_steal_pointer(&ret.names.names_val[i]); + } + + *aliases =3D g_new0(char *, ret.aliases.aliases_len + 1); + for (i =3D 0; i < ret.aliases.aliases_len; i++) { + (*aliases)[i] =3D g_steal_pointer(&ret.aliases.aliases_val[i]); + } + + rv =3D ret.ret; + + cleanup: + xdr_free((xdrproc_t) xdr_remote_connect_get_hypervisor_cpu_model_names= _ret, + (char *) &ret); + + done: + remoteDriverUnlock(priv); + return rv; +} + + static int remoteDomainOpenGraphics(virDomainPtr dom, unsigned int idx, @@ -8652,6 +8710,7 @@ static virHypervisorDriver hypervisor_driver =3D { .domainGetMessages =3D remoteDomainGetMessages, /* 7.1.0 */ .domainStartDirtyRateCalc =3D remoteDomainStartDirtyRateCalc, /* 7.2.0= */ .domainSetLaunchSecurityState =3D remoteDomainSetLaunchSecurityState, = /* 8.0.0 */ + .connectGetHypervisorCPUModelNames =3D remoteConnectGetHypervisorCPUMo= delNames, /* 8.5.0 */ }; =20 static virNetworkDriver network_driver =3D { diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index 79ffc63f03..a5c60399c7 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -3303,6 +3303,17 @@ struct remote_connect_get_cpu_model_names_ret { int ret; }; =20 +struct remote_connect_get_hypervisor_cpu_model_names_args { + remote_nonnull_string arch; + unsigned int flags; +}; + +struct remote_connect_get_hypervisor_cpu_model_names_ret { + remote_nonnull_string names; + remote_nonnull_string aliases; + int ret; +}; + struct remote_connect_network_event_register_any_args { int eventID; remote_network net; @@ -6959,5 +6970,11 @@ enum remote_procedure { * @generate: both * @acl: domain:write */ - REMOTE_PROC_DOMAIN_ABORT_JOB_FLAGS =3D 442 + REMOTE_PROC_DOMAIN_ABORT_JOB_FLAGS =3D 442, + + /** + * @generate: none + * @acl: connect:read + */ + REMOTE_PROC_CONNECT_GET_HYPERVISOR_CPU_MODEL_NAMES =3D 443 }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index ca5222439d..c6afb92aad 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -2671,6 +2671,21 @@ struct remote_connect_get_cpu_model_names_ret { } models; int ret; }; +struct remote_connect_get_hypervisor_cpu_model_names_args { + remote_nonnull_string arch; + u_int flags; +}; +struct remote_connect_get_hypervisor_cpu_model_names_ret { + struct { + u_int names_len; + remote_nonnull_string * names_val; + } names; + struct { + u_int aliases_len; + remote_nonnull_string * aliases_val; + } aliases; + int ret; +}; struct remote_connect_network_event_register_any_args { int eventID; remote_network net; @@ -3711,4 +3726,5 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_SAVE_PARAMS =3D 440, REMOTE_PROC_DOMAIN_RESTORE_PARAMS =3D 441, REMOTE_PROC_DOMAIN_ABORT_JOB_FLAGS =3D 442, + REMOTE_PROC_CONNECT_GET_HYPERVISOR_CPU_MODEL_NAMES =3D 443, }; --=20 2.31.1 From nobody Mon May 13 20:39:15 2024 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 1656432606121265.9328342167755; Tue, 28 Jun 2022 09:10:06 -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-102-UbRh6UyxNa-9Fj2kPGswog-1; Tue, 28 Jun 2022 12:09:59 -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 3B8012803052; Tue, 28 Jun 2022 16:09:54 +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 179F64328C9; Tue, 28 Jun 2022 16:09:54 +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 9C9DA194705C; Tue, 28 Jun 2022 16:09:53 +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 DB07F19466DF for ; Tue, 28 Jun 2022 16:09:50 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C6C482166B2B; Tue, 28 Jun 2022 16:09:50 +0000 (UTC) Received: from work.fritz.box (unknown [10.39.193.108]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5569A2166B26; Tue, 28 Jun 2022 16:09:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656432605; 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=j+Um1dR6tUMH/05RU3QuPu7/B0FusQiXZSHt++XsrKc=; b=ek38TXgaO/d8vhfoxD0Mj4vDiw+cHyb2xAim5rUlMd1tobxnYpyQUXbQ6XAZSMeaxm2JSS 3gmpbCt5WY1awscRhUoInKWXE280xVZzJmSDiArJsbOu74ms6mTXUXUwcRDXRei9guR0xL 2gaPHpMDNbcCeGUh/6KbmZTDQoascdk= X-MC-Unique: UbRh6UyxNa-9Fj2kPGswog-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 4/9] qemu: implement virConnectGetHypervisorCPUModelNames API Date: Tue, 28 Jun 2022 18:09:41 +0200 Message-Id: <20220628160946.61028-5-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.85 on 10.11.54.10 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: 1656432607145100002 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: Tim Wiederhake --- src/qemu/qemu_driver.c | 52 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 3b5c3db67c..538a35d327 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17311,6 +17311,57 @@ qemuConnectGetCPUModelNames(virConnectPtr conn, return virCPUGetModels(arch, models); } =20 +static int +qemuConnectGetHypervisorCPUModelNames(virConnectPtr conn, + const char *archName, + char ***names, + char ***aliases, + unsigned int flags) +{ + size_t i; + virQEMUDriver *driver =3D conn->privateData; + g_autoptr(qemuMonitorCPUDefs) cpuDefs =3D NULL; + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + g_autoptr(qemuProcessQMP) proc =3D NULL; + g_autoptr(virQEMUCaps) qemuCaps =3D NULL; + + virCheckFlags(0, -1); + if (virConnectGetHypervisorCPUModelNamesEnsureACL(conn) < 0) + return -1; + + qemuCaps =3D virQEMUCapsCacheLookupDefault(driver->qemuCapsCache, NULL, + archName, NULL, NULL, NULL, + NULL, NULL); + + if (!(proc =3D qemuProcessQMPNew(virQEMUCapsGetBinary(qemuCaps), cfg->= libDir, + cfg->user, cfg->group, false))) + return -1; + + if (qemuProcessQMPStart(proc) < 0) + return -1; + + if (qemuMonitorGetCPUDefinitions(proc->mon, &cpuDefs) < 0) + return -1; + + // plus one to NULL terminate the lists + *names =3D g_new(char*, cpuDefs->ncpus + 1); + *aliases =3D g_new(char*, cpuDefs->ncpus + 1); + + for (i =3D 0; i < cpuDefs->ncpus; ++i) { + if (cpuDefs->cpus[i].name) + (*names)[i] =3D g_strdup(cpuDefs->cpus[i].name); + else + (*names)[i] =3D g_strdup(""); + + if (cpuDefs->cpus[i].alias) + (*aliases)[i] =3D g_strdup(cpuDefs->cpus[i].alias); + else + (*aliases)[i] =3D g_strdup(""); + } + + return cpuDefs->ncpus; +} + =20 static int qemuDomainGetHostnameAgent(virQEMUDriver *driver, @@ -21324,6 +21375,7 @@ static virHypervisorDriver qemuHypervisorDriver =3D= { .domainGetMessages =3D qemuDomainGetMessages, /* 7.1.0 */ .domainStartDirtyRateCalc =3D qemuDomainStartDirtyRateCalc, /* 7.2.0 */ .domainSetLaunchSecurityState =3D qemuDomainSetLaunchSecurityState, /*= 8.0.0 */ + .connectGetHypervisorCPUModelNames =3D qemuConnectGetHypervisorCPUMode= lNames, /* 8.5.0 */ }; =20 =20 --=20 2.31.1 From nobody Mon May 13 20:39:15 2024 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=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.129.124]) by mx.zohomail.com with SMTPS id 1656432665697433.84024863537286; Tue, 28 Jun 2022 09:11:05 -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-375-N1pD8ofRMVeB8dx-bCegYA-1; Tue, 28 Jun 2022 12:10:03 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5E913185A7BA; Tue, 28 Jun 2022 16:09:53 +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 14B8E40CF8E4; Tue, 28 Jun 2022 16:09:53 +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 E18FA1947054; Tue, 28 Jun 2022 16:09:52 +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 9775F1947056 for ; Tue, 28 Jun 2022 16:09:51 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 7DE7D2166B29; Tue, 28 Jun 2022 16:09:51 +0000 (UTC) Received: from work.fritz.box (unknown [10.39.193.108]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C1792166B2C; Tue, 28 Jun 2022 16:09:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656432664; 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=7XDCMxo1cMgbzDIdQuxrkJomwXUsWXaoJ8WZm3glL9o=; b=Dlw+gJ5x27DtddJJc+mKPqwd24fc4A/vu5/jwhaNhhvtxPWnKgUneXKnhMKjkJfNQ4Itec 81LQbh1VYCGsVQduv4CXaJGT8z/JlS0VEihfsiSbw8aZYUifLqdhkeNltQR2kUK1wNIPBt UfImx8xx62rE6aY/C+lybMuqobSV9+Y= X-MC-Unique: N1pD8ofRMVeB8dx-bCegYA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 5/9] tools: Report hypervisor cpu model names Date: Tue, 28 Jun 2022 18:09:42 +0200 Message-Id: <20220628160946.61028-6-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.84 on 10.11.54.1 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: 1656432667482100001 Content-Type: text/plain; charset="utf-8"; x-default="true" $ virsh hypervisor-cpu-models --arch x86_64 Name Alias ---------------------------------------------------- max host base qemu64-v1 qemu64 qemu64-v1 qemu32-v1 qemu32 qemu32-v1 phenom-v1 phenom phenom-v1 (...) Note that this includes alias names and cpu models that currently do not exist in libvirt, e.g. Denverton and Knights Mill. Signed-off-by: Tim Wiederhake --- docs/manpages/virsh.rst | 14 +++++++++ tools/virsh-host.c | 67 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index 45469f2f35..a55792b0e2 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -955,6 +955,20 @@ If *--validate* is specified, validates the format of = the XML document against an internal RNG schema. =20 =20 +hypervisor-cpu-models +--------------------- + +**Syntax:** + +:: + + hypervisor-cpu-models [arch] + +List the names of cpu models known to the hypervisor. A hypervisor may def= ine +alias names for some or all cpu models. Note that the cpu models may differ +from libvirt, even if named identically. + + hypervisor-cpu-baseline ----------------------- =20 diff --git a/tools/virsh-host.c b/tools/virsh-host.c index ead966b500..cb8e1e8c6d 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -32,6 +32,7 @@ #include "virstring.h" #include "virfile.h" #include "virenum.h" +#include "vsh-table.h" =20 /* * "capabilities" command @@ -1674,6 +1675,65 @@ cmdHypervisorCPUCompare(vshControl *ctl, } =20 =20 +/* + * "hypervisor-cpu-models" command + */ +static const vshCmdInfo info_hypervisor_cpu_models[] =3D { + {.name =3D "help", + .data =3D N_("return list of CPU models supported by a specific hyper= visor") + }, + {.name =3D "desc", + .data =3D N_("Return list of CPU models supported by a specific hyper= visor") + }, + {.name =3D NULL} +}; + +static const vshCmdOptDef opts_hypervisor_cpu_models[] =3D { + {.name =3D "arch", + .type =3D VSH_OT_STRING, + .completer =3D virshArchCompleter, + .help =3D N_("CPU architecture (/domain/os/type/@arch)"), + }, + {.name =3D NULL} +}; + +static bool +cmdHypervisorCPUModels(vshControl *ctl, + const vshCmd *cmd) +{ + virshControl *priv =3D ctl->privData; + bool ret =3D false; + const char *arch =3D NULL; + char **name =3D NULL; + char **alias =3D NULL; + int nresults; + g_autoptr(vshTable) table =3D vshTableNew(_("Name"), _("Alias"), NULL); + + if (!table) + return ret; + + if (vshCommandOptStringReq(ctl, cmd, "arch", &arch) < 0) + return false; + + nresults =3D virConnectGetHypervisorCPUModelNames(priv->conn, arch, &n= ame, + &alias, 0); + if (nresults >=3D 0) { + size_t index; + for (index =3D 0; index < nresults; ++index) { + if (vshTableRowAppend(table, name[index], alias[index], NULL) = < 0) + return ret; + g_free(name[index]); + g_free(alias[index]); + } + ret =3D true; + } + vshTablePrintToStdout(table, ctl); + g_free(name); + g_free(alias); + + return ret; +} + /* * "hypervisor-cpu-baseline" command */ @@ -1819,6 +1879,13 @@ const vshCmdDef hostAndHypervisorCmds[] =3D { .info =3D info_hostname, .flags =3D 0 }, + { + .name =3D "hypervisor-cpu-models", + .handler =3D cmdHypervisorCPUModels, + .opts =3D opts_hypervisor_cpu_models, + .info =3D info_hypervisor_cpu_models, + .flags =3D 0 + }, {.name =3D "hypervisor-cpu-baseline", .handler =3D cmdHypervisorCPUBaseline, .opts =3D opts_hypervisor_cpu_baseline, --=20 2.31.1 From nobody Mon May 13 20:39:15 2024 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=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.129.124]) by mx.zohomail.com with SMTPS id 1656432602923555.1855875753619; Tue, 28 Jun 2022 09:10:02 -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-449-7Rz3Rh_GM9qkIfFVqy1vWQ-1; Tue, 28 Jun 2022 12:09:59 -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 8372C3C11A0E; Tue, 28 Jun 2022 16:09:54 +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 6F19640D2969; Tue, 28 Jun 2022 16:09:54 +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 F2B5C1947063; Tue, 28 Jun 2022 16:09:53 +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 4A38919466DF for ; Tue, 28 Jun 2022 16:09:52 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 33C3F2166B2A; Tue, 28 Jun 2022 16:09:52 +0000 (UTC) Received: from work.fritz.box (unknown [10.39.193.108]) by smtp.corp.redhat.com (Postfix) with ESMTP id B5E0F2166B26; Tue, 28 Jun 2022 16:09:51 +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=UpW2w/PSVpJeHXr2fqGcEKmCMRn8uMBQKcbbEJBatRo=; b=OxnUGHTc0sLlz/lNirNssMjTOz4fvgKGVhuVodkp2TxqLiYeX1dcBOwC+T3jectTy8ILvT Jh+QE5ZBjBCDgxcZVrHgaXsYohk5aVkt86EDgQpYyCmubH71fft+/hqZUd8Y4M6Bpemnv0 H1x8llQ2z8HG8mZPGsaU4S/qHoEBCW8= X-MC-Unique: 7Rz3Rh_GM9qkIfFVqy1vWQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 6/9] libvirt: introduce virConnectGetHypervisorCPUModelDefinition public API Date: Tue, 28 Jun 2022 18:09:43 +0200 Message-Id: <20220628160946.61028-7-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.84 on 10.11.54.2 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: 1656432604980100004 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: Tim Wiederhake --- include/libvirt/libvirt-host.h | 7 +++++ src/driver-hypervisor.h | 9 ++++++ src/libvirt-host.c | 54 ++++++++++++++++++++++++++++++++++ src/libvirt_public.syms | 1 + 4 files changed, 71 insertions(+) diff --git a/include/libvirt/libvirt-host.h b/include/libvirt/libvirt-host.h index 5aaa001adb..ad11c1172d 100644 --- a/include/libvirt/libvirt-host.h +++ b/include/libvirt/libvirt-host.h @@ -968,6 +968,13 @@ int virConnectGetHypervisorCPUModelNames(virConnectPtr= conn, char ***aliases, unsigned int flags); =20 +int virConnectGetHypervisorCPUModelDefinition(virConnectPtr conn, + const char *arch, + const char *machine, + const char *name, + char **xmlCPU, + unsigned int flags); + /** * virConnectBaselineCPUFlags: * diff --git a/src/driver-hypervisor.h b/src/driver-hypervisor.h index c81e5d4c75..b016ec7775 100644 --- a/src/driver-hypervisor.h +++ b/src/driver-hypervisor.h @@ -739,6 +739,14 @@ typedef int char ***aliases, unsigned int flags); =20 +typedef int +(*virDrvConnectGetHypervisorCPUModelDefinition)(virConnectPtr conn, + const char *arch, + const char *machine, + const char *name, + char **xmlCPU, + unsigned int flags); + typedef int (*virDrvDomainGetJobInfo)(virDomainPtr domain, virDomainJobInfoPtr info); @@ -1720,4 +1728,5 @@ struct _virHypervisorDriver { virDrvDomainGetMessages domainGetMessages; virDrvDomainStartDirtyRateCalc domainStartDirtyRateCalc; virDrvConnectGetHypervisorCPUModelNames connectGetHypervisorCPUModelNa= mes; + virDrvConnectGetHypervisorCPUModelDefinition connectGetHypervisorCPUMo= delDefinition; }; diff --git a/src/libvirt-host.c b/src/libvirt-host.c index 6e734628c1..8875f67a7b 100644 --- a/src/libvirt-host.c +++ b/src/libvirt-host.c @@ -1288,6 +1288,60 @@ virConnectGetHypervisorCPUModelNames(virConnectPtr c= onn, return -1; } =20 +/** + * virConnectGetHypervisorCPUModelDefinition: + * + * @conn: virConnect connection + * @arch: Architecture + * @machine: Machine type + * @name: CPU model name + * @xmlCPU: XML description of the CPUs + * @flags: extra flags; not used yet, so callers should always pass 0. + * + * Get the description of a specific hypervisor cpu model for a given mach= ine + * type and architecture. + * + * Returns 0 on success, -1 otherwise. + * + * Since: 8.5.0 + */ +int +virConnectGetHypervisorCPUModelDefinition(virConnectPtr conn, + const char *arch, + const char *machine, + const char *name, + char **xmlCPU, + unsigned int flags) +{ + VIR_DEBUG("conn=3D%p, arch=3D%s, machine=3D%s, model=3D%s, flags=3D0x%= x", conn, + NULLSTR(arch), NULLSTR(machine), NULLSTR(name), flags); + virResetLastError(); + + virCheckConnectReturn(conn, -1); + virCheckNonNullArgGoto(arch, error); + virCheckNonNullArgGoto(machine, error); + virCheckNonNullArgGoto(name, error); + + if (conn->driver->connectGetHypervisorCPUModelDefinition) { + int ret; + + ret =3D conn->driver->connectGetHypervisorCPUModelDefinition(conn,= arch, + machine, + name, + xmlCPU, + flags); + if (ret < 0) + goto error; + + return ret; + } + + virReportUnsupportedError(); + + error: + virDispatchError(conn); + return -1; +} =20 /** * virConnectBaselineCPU: diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms index c6a8e898ae..15ef29d07d 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: + virConnectGetHypervisorCPUModelDefinition; virConnectGetHypervisorCPUModelNames; virDomainAbortJobFlags; } LIBVIRT_8.4.0; --=20 2.31.1 From nobody Mon May 13 20:39:15 2024 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 1656432685698903.9307813354266; Tue, 28 Jun 2022 09:11:25 -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-135-WtoTaPvxPfi--UAxuOqgWQ-1; Tue, 28 Jun 2022 12:10:07 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E0F898339DF; Tue, 28 Jun 2022 16:09:54 +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 CA51540CFD0B; Tue, 28 Jun 2022 16:09:54 +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 43BA31947067; Tue, 28 Jun 2022 16:09:54 +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 EE3B31947058 for ; Tue, 28 Jun 2022 16:09:52 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id DD5B02166B2A; Tue, 28 Jun 2022 16:09:52 +0000 (UTC) Received: from work.fritz.box (unknown [10.39.193.108]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6BCF52166B26; Tue, 28 Jun 2022 16:09:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656432684; 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=2cs+CLulVJeXU8wi6nTrBYiWX4XaTVaB17oaE+cnnnE=; b=EW3AZtCBmQk33Doq4pov1lb/5r/z0bK9VqccGbkY3YXM1XQYTPifssxnWYJaXkixKhPVVM RFkljnbARucAXw8EW2TLaboucQr4Pl9Ex9sjFEJ8ozB2PSUT/Jd/R+wJ1bkOcjtXkjxB8Z c1VoW1TJOEoALjSqvBxg3UGni00iuC4= X-MC-Unique: WtoTaPvxPfi--UAxuOqgWQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 7/9] remote: Add support for the virConnectGetHypervisorCPUModelDefinition API Date: Tue, 28 Jun 2022 18:09:44 +0200 Message-Id: <20220628160946.61028-8-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.84 on 10.11.54.1 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: 1656432687545100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: Tim Wiederhake --- src/remote/remote_daemon_dispatch.c | 32 ++++++++++++++++++++++ src/remote/remote_driver.c | 41 +++++++++++++++++++++++++++++ src/remote/remote_protocol.x | 20 +++++++++++++- src/remote_protocol-structs | 11 ++++++++ 4 files changed, 103 insertions(+), 1 deletion(-) diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon= _dispatch.c index 9011977e18..bc30cb819c 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -5913,6 +5913,38 @@ remoteDispatchConnectGetHypervisorCPUModelNames(virN= etServer *server G_GNUC_UNUS } =20 =20 +static int +remoteDispatchConnectGetHypervisorCPUModelDefinition(virNetServer *server = G_GNUC_UNUSED, + virNetServerClient *c= lient, + virNetMessage *msg G_= GNUC_UNUSED, + struct virNetMessageE= rror *rerr, + remote_connect_get_hy= pervisor_cpu_model_definition_args *args, + remote_connect_get_hy= pervisor_cpu_model_definition_ret *ret) +{ + int rv =3D -1; + virConnectPtr conn =3D remoteGetHypervisorConn(client); + g_autofree char *xml =3D NULL; + + if (!conn) + goto cleanup; + + rv =3D virConnectGetHypervisorCPUModelDefinition(conn, args->arch, + args->machine, args->na= me, + &xml, args->flags); + if (rv < 0) + goto cleanup; + + ret->xml =3D g_steal_pointer(&xml); + rv =3D 0; + + cleanup: + ret->ret =3D rv; + if (rv < 0) + virNetMessageSaveError(rerr); + return rv; +} + + static int remoteDispatchDomainCreateXMLWithFiles(virNetServer *server G_GNUC_UNUSED, virNetServerClient *client, diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 8dca23a7eb..7aec988746 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -6451,6 +6451,46 @@ remoteConnectGetHypervisorCPUModelNames(virConnectPt= r conn, } =20 =20 +static int +remoteConnectGetHypervisorCPUModelDefinition(virConnectPtr conn, + const char *arch, + const char *machine, + const char *name, + char **xmlCPU, + unsigned int flags) +{ + int rv =3D -1; + remote_connect_get_hypervisor_cpu_model_definition_args args; + remote_connect_get_hypervisor_cpu_model_definition_ret ret; + + struct private_data *priv =3D conn->privateData; + + remoteDriverLock(priv); + + args.arch =3D (char *) arch; + args.machine =3D (char *) machine; + args.name =3D (char *) name; + args.flags =3D flags; + + memset(&ret, 0, sizeof(ret)); + if (call(conn, priv, 0, REMOTE_PROC_CONNECT_GET_HYPERVISOR_CPU_MODEL_D= EFINITION, + (xdrproc_t) xdr_remote_connect_get_hypervisor_cpu_model_defin= ition_args, + (char *) &args, + (xdrproc_t) xdr_remote_connect_get_hypervisor_cpu_model_defin= ition_ret, + (char *) &ret) < 0) + goto done; + + *xmlCPU =3D g_steal_pointer(&ret.xml); + rv =3D ret.ret; + + xdr_free((xdrproc_t) xdr_remote_connect_get_hypervisor_cpu_model_defin= ition_ret, + (char *) &ret); + + done: + remoteDriverUnlock(priv); + return rv; +} + static int remoteDomainOpenGraphics(virDomainPtr dom, unsigned int idx, @@ -8711,6 +8751,7 @@ static virHypervisorDriver hypervisor_driver =3D { .domainStartDirtyRateCalc =3D remoteDomainStartDirtyRateCalc, /* 7.2.0= */ .domainSetLaunchSecurityState =3D remoteDomainSetLaunchSecurityState, = /* 8.0.0 */ .connectGetHypervisorCPUModelNames =3D remoteConnectGetHypervisorCPUMo= delNames, /* 8.5.0 */ + .connectGetHypervisorCPUModelDefinition =3D remoteConnectGetHypervisor= CPUModelDefinition, /* 8.5.0 */ }; =20 static virNetworkDriver network_driver =3D { diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index a5c60399c7..2d7d6277c6 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -3314,6 +3314,18 @@ struct remote_connect_get_hypervisor_cpu_model_names= _ret { int ret; }; =20 +struct remote_connect_get_hypervisor_cpu_model_definition_args { + remote_nonnull_string arch; + remote_nonnull_string machine; + remote_nonnull_string name; + unsigned int flags; +}; + +struct remote_connect_get_hypervisor_cpu_model_definition_ret { + remote_nonnull_string xml; + int ret; +}; + struct remote_connect_network_event_register_any_args { int eventID; remote_network net; @@ -6976,5 +6988,11 @@ enum remote_procedure { * @generate: none * @acl: connect:read */ - REMOTE_PROC_CONNECT_GET_HYPERVISOR_CPU_MODEL_NAMES =3D 443 + REMOTE_PROC_CONNECT_GET_HYPERVISOR_CPU_MODEL_NAMES =3D 443, + + /** + * @generate: none + * @acl: connect:read + */ + REMOTE_PROC_CONNECT_GET_HYPERVISOR_CPU_MODEL_DEFINITION =3D 444 }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index c6afb92aad..0fdc1e8800 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -2686,6 +2686,16 @@ struct remote_connect_get_hypervisor_cpu_model_names= _ret { } aliases; int ret; }; +struct remote_connect_get_hypervisor_cpu_model_definition_args { + remote_nonnull_string arch; + remote_nonnull_string machine; + remote_nonnull_string name; + u_int flags; +}; +struct remote_connect_get_hypervisor_cpu_model_definition_ret { + remote_nonnull_string xml; + int ret; +}; struct remote_connect_network_event_register_any_args { int eventID; remote_network net; @@ -3727,4 +3737,5 @@ enum remote_procedure { REMOTE_PROC_DOMAIN_RESTORE_PARAMS =3D 441, REMOTE_PROC_DOMAIN_ABORT_JOB_FLAGS =3D 442, REMOTE_PROC_CONNECT_GET_HYPERVISOR_CPU_MODEL_NAMES =3D 443, + REMOTE_PROC_CONNECT_GET_HYPERVISOR_CPU_MODEL_DEFINITION =3D 444, }; --=20 2.31.1 From nobody Mon May 13 20:39:15 2024 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=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.129.124]) by mx.zohomail.com with SMTPS id 1656432608341290.6298137195946; Tue, 28 Jun 2022 09:10:08 -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-319-vFhBW3-cMhaLS4nY6bNQtQ-1; Tue, 28 Jun 2022 12:10:01 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 574AB3821C12; Tue, 28 Jun 2022 16:09:55 +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 39A021410DD8; Tue, 28 Jun 2022 16:09:55 +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 B9538194705F; Tue, 28 Jun 2022 16:09:54 +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 B17EA1947061 for ; Tue, 28 Jun 2022 16:09:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 94AB12166B26; Tue, 28 Jun 2022 16:09:53 +0000 (UTC) Received: from work.fritz.box (unknown [10.39.193.108]) by smtp.corp.redhat.com (Postfix) with ESMTP id 227B32166B29; Tue, 28 Jun 2022 16:09:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656432607; 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=j8CzIaS5Nyh9x5C04wLGtlIQehrK8MlhhNtAPujsbes=; b=EfIMmRTykfXsQebBol9m1EWUx13E8bCcj8I1jH41sy4AMP02Kx8O27VnKcacTH67QIsAXm /fPTi6Tl8lJS7pICDi6r+27aSjGr2Jd0u1UIPApEQvBP4sqMqg5wnKLzPN4w1N5YJfPToK 0QkMRbGYPk/nWH+561KHsJTEeY1OVp0= X-MC-Unique: vFhBW3-cMhaLS4nY6bNQtQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 8/9] qemu: Implement virConnectGetHypervisorCPUModelDefinition API Date: Tue, 28 Jun 2022 18:09:45 +0200 Message-Id: <20220628160946.61028-9-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.85 on 10.11.54.7 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: 1656432608942100005 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: Tim Wiederhake --- src/qemu/qemu_driver.c | 53 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 538a35d327..0dfc93a373 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17363,6 +17363,58 @@ qemuConnectGetHypervisorCPUModelNames(virConnectPt= r conn, } =20 =20 +static int +qemuConnectGetHypervisorCPUModelDefinition(virConnectPtr conn, + const char *arch, + const char *machine, + const char *name, + char **xmlCPU, + unsigned int flags) +{ + virQEMUDriver *driver =3D conn->privateData; + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + g_autoptr(qemuProcessQMP) proc =3D NULL; + g_autoptr(virQEMUCaps) qemuCaps =3D NULL; + g_autoptr(virCPUDef) cpu =3D g_new0(virCPUDef, 1); + g_autoptr(qemuMonitorCPUModelInfo) model_info =3D NULL; + + virCheckFlags(0, -1); + if (virConnectGetHypervisorCPUModelDefinitionEnsureACL(conn) < 0) + return -1; + + qemuCaps =3D virQEMUCapsCacheLookupDefault(driver->qemuCapsCache, NULL, + arch, NULL, machine, NULL, + NULL, NULL); + if (!qemuCaps) + return -1; + + if (!(proc =3D qemuProcessQMPNew(virQEMUCapsGetBinary(qemuCaps), cfg->= libDir, + cfg->user, cfg->group, false))) + return -1; + + if (qemuProcessQMPStart(proc) < 0) + return -1; + + cpu->model =3D g_strdup(name); + if (qemuMonitorGetCPUModelExpansion(proc->mon, + QEMU_MONITOR_CPU_MODEL_EXPANSION_F= ULL, + cpu, true, true, &model_info) < 0) + return -1; + + if (!model_info) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown model '%s'"), name); + return -1; + } + + if (qemuConnectStealCPUModelFromInfo(cpu, &model_info) < 0) + return -1; + + *xmlCPU =3D virCPUDefFormat(cpu, NULL); + return 0; +} + + static int qemuDomainGetHostnameAgent(virQEMUDriver *driver, virDomainObj *vm, @@ -21376,6 +21428,7 @@ static virHypervisorDriver qemuHypervisorDriver =3D= { .domainStartDirtyRateCalc =3D qemuDomainStartDirtyRateCalc, /* 7.2.0 */ .domainSetLaunchSecurityState =3D qemuDomainSetLaunchSecurityState, /*= 8.0.0 */ .connectGetHypervisorCPUModelNames =3D qemuConnectGetHypervisorCPUMode= lNames, /* 8.5.0 */ + .connectGetHypervisorCPUModelDefinition =3D qemuConnectGetHypervisorCP= UModelDefinition, /* 8.5.0 */ }; =20 =20 --=20 2.31.1 From nobody Mon May 13 20:39:15 2024 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=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.129.124]) by mx.zohomail.com with SMTPS id 1656432666566188.30995058781718; Tue, 28 Jun 2022 09:11:06 -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-348-KPeO48_7MBST5LlOyqSdYQ-1; Tue, 28 Jun 2022 12:10:06 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9B4423821C27; Tue, 28 Jun 2022 16:09:55 +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 85F5A1415108; Tue, 28 Jun 2022 16:09:55 +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 57142194705E; Tue, 28 Jun 2022 16:09:55 +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 5E5061947061 for ; Tue, 28 Jun 2022 16:09:54 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 4F1482166B2A; Tue, 28 Jun 2022 16:09:54 +0000 (UTC) Received: from work.fritz.box (unknown [10.39.193.108]) by smtp.corp.redhat.com (Postfix) with ESMTP id CB30A2166B29; Tue, 28 Jun 2022 16:09:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656432665; 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=+UEO7WoOCoOTEpBLIZ6XYPVVWYJtVeOyhfhJSvfSchY=; b=jRn/URkMDT9tRQmwxHh8+DqeeFtl7rDDKqcAAPPCetJyl3n/AL2r0C/rtB15BmXsLkl1pK RlmkYPMgeBRZCbCXHH2z52siuOScusU0buKXMZYKni4PV7B3xaSxXEI89Hatzuq60dDM2+ RjFzNUUTGNOs6lskW+Y+rfJK9IMvuV0= X-MC-Unique: KPeO48_7MBST5LlOyqSdYQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 9/9] tools: Report hypervisor cpu model definitions Date: Tue, 28 Jun 2022 18:09:46 +0200 Message-Id: <20220628160946.61028-10-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.85 on 10.11.54.7 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: 1656432667531100002 Content-Type: text/plain; charset="utf-8"; x-default="true" $ virsh hypervisor-cpu-definition --machine pc --arch x86_64 qemu64 qemu64 Signed-off-by: Tim Wiederhake --- docs/manpages/virsh.rst | 13 +++++++++ tools/virsh-host.c | 65 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index a55792b0e2..aa6c732fd0 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -969,6 +969,19 @@ alias names for some or all cpu models. Note that the = cpu models may differ from libvirt, even if named identically. =20 =20 +hypervisor-cpu-definition +------------------------- + +**Syntax:** + +:: + + hypervisor-cpu-definition name [arch] [machine] + +Retrieve the named CPU model as defined by the hypervisor. Note that the c= pu +model may differ from libvirt, even if named identically. + + hypervisor-cpu-baseline ----------------------- =20 diff --git a/tools/virsh-host.c b/tools/virsh-host.c index cb8e1e8c6d..75b439d04b 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -1734,6 +1734,64 @@ cmdHypervisorCPUModels(vshControl *ctl, return ret; } =20 +/* + * "hypervisor-cpu-definition" command + */ +static const vshCmdInfo info_hypervisor_cpu_definition[] =3D { + {.name =3D "help", + .data =3D N_("return CPU model as defined by hypervisor") + }, + {.name =3D "desc", + .data =3D N_("Return CPU model as defined by hypervisor") + }, + {.name =3D NULL} +}; + +static const vshCmdOptDef opts_hypervisor_cpu_definition[] =3D { + {.name =3D "name", + .type =3D VSH_OT_DATA, + .flags =3D VSH_OFLAG_REQ, + .help =3D N_("CPU name"), + }, + {.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 +cmdHypervisorCPUDefinition(vshControl *ctl, + const vshCmd *cmd) +{ + virshControl *priv =3D ctl->privData; + const char *arch =3D NULL; + const char *machine =3D NULL; + const char *name =3D NULL; + g_autofree char *xml =3D NULL; + + if (vshCommandOptStringReq(ctl, cmd, "arch", &arch) < 0) + return false; + + if (vshCommandOptStringReq(ctl, cmd, "machine", &machine) < 0) + return false; + + if (vshCommandOptStringReq(ctl, cmd, "name", &name) < 0) + return false; + + if (virConnectGetHypervisorCPUModelDefinition(priv->conn, arch, machin= e, + name, &xml, 0) < 0) + return false; + + vshPrint(ctl, "%s", xml); + return true; +} + /* * "hypervisor-cpu-baseline" command */ @@ -1886,6 +1944,13 @@ const vshCmdDef hostAndHypervisorCmds[] =3D { .info =3D info_hypervisor_cpu_models, .flags =3D 0 }, + { + .name =3D "hypervisor-cpu-definition", + .handler =3D cmdHypervisorCPUDefinition, + .opts =3D opts_hypervisor_cpu_definition, + .info =3D info_hypervisor_cpu_definition, + .flags =3D 0 + }, {.name =3D "hypervisor-cpu-baseline", .handler =3D cmdHypervisorCPUBaseline, .opts =3D opts_hypervisor_cpu_baseline, --=20 2.31.1