From nobody Tue Jan 21 07:35:26 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=reject dis=none) header.from=linux.ibm.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1736937312034587.9016262870942; Wed, 15 Jan 2025 02:35:12 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 5EC051942; Wed, 15 Jan 2025 05:35:11 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 0DE8F18FE; Wed, 15 Jan 2025 05:34:20 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 4E1551639; Wed, 15 Jan 2025 05:34:16 -0500 (EST) Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 9BAA415FE for ; Wed, 15 Jan 2025 05:34:15 -0500 (EST) Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50F2QcHd014295 for ; Wed, 15 Jan 2025 10:34:15 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 445sd64gu0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 15 Jan 2025 10:34:14 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 50F6KZNi007396 for ; Wed, 15 Jan 2025 10:34:14 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4443yn7tk2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 15 Jan 2025 10:34:14 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 50FAYAsV36700564 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 15 Jan 2025 10:34:10 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 387782004E; Wed, 15 Jan 2025 10:34:10 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 18DA22005A; Wed, 15 Jan 2025 10:34:10 +0000 (GMT) Received: from fiuczyvm.. (unknown [9.152.222.247]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 15 Jan 2025 10:34:10 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=172CM7O2XgUDCjF7j SXLtR1vpA/WfMeX1nFPf/UzCCo=; b=dgLazcFivo/YxxZKa8Vh9q+qQshVyv2cO QSbUCVnzYFpBEO3fl3b7gDdho91VpcqgqFL49nxX8TwaVaNQXj0U327UHquqv4+x JeRrvQ+u+MAo/Fvi0TZ10aAyeRYZedVZTJxJXJ6UQH4ealMJk3iY9U7WxXnSwBJ+ Cktbrl8nplY2TtvgyN/yEvaTC/ZJCLIJGT8Ker4h9CEVVObcLTR2ko33Wc7z2qZ1 tMN9QEKI2LxeLyIVP2V3YwxdUb3TK/iJLMekLfX7GExkWmu+EBowJCq1NPDV13YG 70TgPsJ9OS6ZV9Pl/miC6d+ahIlnA+fyjN//2eXuM/A3i/7GSeCnQ== From: Boris Fiuczynski To: devel@lists.libvirt.org Subject: [PATCH 2/4] remote: Implement virConnectGetHypervisorCPUModelNames Date: Wed, 15 Jan 2025 11:34:07 +0100 Message-ID: <20250115103409.31064-3-fiuczy@linux.ibm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250115103409.31064-1-fiuczy@linux.ibm.com> References: <20250115103409.31064-1-fiuczy@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: I49y-6eE3fd6lW9YOrsgt-jpQq8YCxgm X-Proofpoint-ORIG-GUID: I49y-6eE3fd6lW9YOrsgt-jpQq8YCxgm X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-15_04,2025-01-15_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 adultscore=0 clxscore=1015 phishscore=0 spamscore=0 suspectscore=0 priorityscore=1501 mlxlogscore=429 bulkscore=0 lowpriorityscore=0 malwarescore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2501150079 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: QUFDF6BV5A5E5PKULPDYFCIMTB2TGGYB X-Message-ID-Hash: QUFDF6BV5A5E5PKULPDYFCIMTB2TGGYB X-MailFrom: fiuczy@linux.ibm.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: djudkovi@linux.ibm.com, walling@linux.ibm.com X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1736937313878019000 Content-Type: text/plain; charset="utf-8" From: David Judkovics Adding access to virConnectGetHypervisorCPUModelNames running on a remote machine. Signed-off-by: David Judkovics Reviewed-by: Boris Fiuczynski Signed-off-by: Boris Fiuczynski --- src/remote/remote_daemon_dispatch.c | 62 +++++++++++++++++++++++++++++ src/remote/remote_driver.c | 52 ++++++++++++++++++++++++ src/remote/remote_protocol.x | 26 +++++++++++- src/remote_protocol-structs | 16 ++++++++ 4 files changed, 155 insertions(+), 1 deletion(-) diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon= _dispatch.c index e812f5c3e9..2d3db1c74e 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -5924,6 +5924,68 @@ 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, rv =3D -1; + char *emulator; + char *arch; + char *machine; + char *virttype; + + g_auto(GStrv) models =3D NULL; + virConnectPtr conn =3D remoteGetHypervisorConn(client); + + if (!conn) + goto cleanup; + + emulator =3D args->emulator ? *args->emulator : NULL; + arch =3D args->arch ? *args->arch : NULL; + machine =3D args->machine ? *args->machine : NULL; + virttype =3D args->virttype ? *args->virttype : NULL; + + len =3D virConnectGetHypervisorCPUModelNames(conn, + emulator, + arch, + machine, + virttype, + args->need_results ? &model= s : NULL, + args->flags); + + if (len < 0) + goto cleanup; + + if (len > REMOTE_CONNECT_HYPERVISOR_CPU_MODELS_MAX) { + virReportError(VIR_ERR_RPC, + _("Too many CPU models '%1$d' for limit '%2$d'"), + len, REMOTE_CONNECT_HYPERVISOR_CPU_MODELS_MAX); + goto cleanup; + } + + if (len && models) { + ret->models.models_val =3D g_steal_pointer(&models); + ret->models.models_len =3D len; + } else { + ret->models.models_val =3D NULL; + ret->models.models_len =3D 0; + } + + 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 307f9ca945..f5e2c88723 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -5865,6 +5865,57 @@ remoteConnectGetCPUModelNames(virConnectPtr conn, } =20 =20 +static int +remoteConnectGetHypervisorCPUModelNames(virConnectPtr conn, + const char *emulator, + const char *arch, + const char *machine, + const char *virttype, + char ***models, + unsigned int flags) +{ + size_t i; + g_auto(GStrv) retmodels =3D NULL; + remote_connect_get_hypervisor_cpu_model_names_args args =3D {0}; + g_auto(remote_connect_get_hypervisor_cpu_model_names_ret) ret =3D {0}; + struct private_data *priv =3D conn->privateData; + VIR_LOCK_GUARD lock =3D remoteDriverLock(priv); + + args.emulator =3D emulator ? (char **)&emulator : NULL; + args.arch =3D arch ? (char **)&arch : NULL; + args.machine =3D machine ? (char **)&machine : NULL; + args.virttype =3D virttype ? (char **)&virttype : NULL; + args.need_results =3D !!models; + args.flags =3D flags; + + 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) + return -1; + + /* Check the length of the returned list carefully. */ + if (ret.models.models_len > REMOTE_CONNECT_HYPERVISOR_CPU_MODELS_MAX) { + virReportError(VIR_ERR_RPC, + _("Too many model names '%1$d' for limit '%2$d'"), + ret.models.models_len, + REMOTE_CONNECT_HYPERVISOR_CPU_MODELS_MAX); + return -1; + } + + if (models) { + retmodels =3D g_new0(char *, ret.models.models_len + 1); + for (i =3D 0; i < ret.models.models_len; i++) { + retmodels[i] =3D g_steal_pointer(&ret.models.models_val[i]); + } + *models =3D g_steal_pointer(&retmodels); + } + + return ret.ret; +} + + static int remoteDomainOpenGraphics(virDomainPtr dom, unsigned int idx, @@ -7815,6 +7866,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, /* 11.1.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 41c045ff78..3daf991e2d 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -239,6 +239,9 @@ const REMOTE_DOMAIN_JOB_STATS_MAX =3D 64; /* Upper limit on number of CPU models */ const REMOTE_CONNECT_CPU_MODELS_MAX =3D 8192; =20 +/* Upper limit on number Hypervisor CPU models */ +const REMOTE_CONNECT_HYPERVISOR_CPU_MODELS_MAX =3D 256; + /* Upper limit on number of mountpoints to frozen */ const REMOTE_DOMAIN_FSFREEZE_MOUNTPOINTS_MAX =3D 256; =20 @@ -3679,6 +3682,20 @@ 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; + int need_results; + unsigned int flags; +}; + +struct remote_connect_get_hypervisor_cpu_model_names_ret { + remote_nonnull_string models; + int ret; +}; + struct remote_node_get_sev_info_args { int nparams; unsigned int flags; @@ -7048,5 +7065,12 @@ enum remote_procedure { * @generate: both * @acl: domain:write */ - REMOTE_PROC_DOMAIN_GRAPHICS_RELOAD =3D 448 + REMOTE_PROC_DOMAIN_GRAPHICS_RELOAD =3D 448, + + /** + * @generate: none + * @priority: high + * @acl: connect:write + */ + REMOTE_PROC_CONNECT_GET_HYPERVISOR_CPU_MODEL_NAMES =3D 449 }; diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs index 4d3dc2d249..6d354ab6cc 100644 --- a/src/remote_protocol-structs +++ b/src/remote_protocol-structs @@ -3031,6 +3031,21 @@ 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; + int need_results; + u_int flags; +}; +struct remote_connect_get_hypervisor_cpu_model_names_ret { + struct { + u_int models_len; + remote_nonnull_string * models_val; + } models; + int ret; +}; struct remote_node_get_sev_info_args { int nparams; u_int flags; @@ -3755,4 +3770,5 @@ enum remote_procedure { REMOTE_PROC_NETWORK_EVENT_CALLBACK_METADATA_CHANGE =3D 446, REMOTE_PROC_NODE_DEVICE_UPDATE =3D 447, REMOTE_PROC_DOMAIN_GRAPHICS_RELOAD =3D 448, + REMOTE_PROC_CONNECT_GET_HYPERVISOR_CPU_MODEL_NAMES =3D 449, }; --=20 2.47.0