From nobody Mon Feb 9 14:14:12 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 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