From: David Judkovics <djudkovi@linux.ibm.com>
Adding access to virConnectGetHypervisorCPUModelNames running on a
remote machine.
Signed-off-by: David Judkovics <djudkovi@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
---
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,
}
+static int
+remoteDispatchConnectGetHypervisorCPUModelNames(virNetServer *server G_GNUC_UNUSED,
+ virNetServerClient *client,
+ virNetMessage *msg G_GNUC_UNUSED,
+ struct virNetMessageError *rerr,
+ remote_connect_get_hypervisor_cpu_model_names_args *args,
+ remote_connect_get_hypervisor_cpu_model_names_ret *ret)
+{
+ int len, rv = -1;
+ char *emulator;
+ char *arch;
+ char *machine;
+ char *virttype;
+
+ g_auto(GStrv) models = NULL;
+ virConnectPtr conn = remoteGetHypervisorConn(client);
+
+ if (!conn)
+ goto cleanup;
+
+ emulator = args->emulator ? *args->emulator : NULL;
+ arch = args->arch ? *args->arch : NULL;
+ machine = args->machine ? *args->machine : NULL;
+ virttype = args->virttype ? *args->virttype : NULL;
+
+ len = virConnectGetHypervisorCPUModelNames(conn,
+ emulator,
+ arch,
+ machine,
+ virttype,
+ args->need_results ? &models : 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 = g_steal_pointer(&models);
+ ret->models.models_len = len;
+ } else {
+ ret->models.models_val = NULL;
+ ret->models.models_len = 0;
+ }
+
+ ret->ret = len;
+
+ rv = 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,
}
+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 = NULL;
+ remote_connect_get_hypervisor_cpu_model_names_args args = {0};
+ g_auto(remote_connect_get_hypervisor_cpu_model_names_ret) ret = {0};
+ struct private_data *priv = conn->privateData;
+ VIR_LOCK_GUARD lock = remoteDriverLock(priv);
+
+ args.emulator = emulator ? (char **)&emulator : NULL;
+ args.arch = arch ? (char **)&arch : NULL;
+ args.machine = machine ? (char **)&machine : NULL;
+ args.virttype = virttype ? (char **)&virttype : NULL;
+ args.need_results = !!models;
+ args.flags = flags;
+
+ if (call(conn, priv, 0, REMOTE_PROC_CONNECT_GET_HYPERVISOR_CPU_MODEL_NAMES,
+ (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 = g_new0(char *, ret.models.models_len + 1);
+ for (i = 0; i < ret.models.models_len; i++) {
+ retmodels[i] = g_steal_pointer(&ret.models.models_val[i]);
+ }
+ *models = g_steal_pointer(&retmodels);
+ }
+
+ return ret.ret;
+}
+
+
static int
remoteDomainOpenGraphics(virDomainPtr dom,
unsigned int idx,
@@ -7815,6 +7866,7 @@ static virHypervisorDriver hypervisor_driver = {
.domainSetLifecycleAction = remoteDomainSetLifecycleAction, /* 3.9.0 */
.connectCompareHypervisorCPU = remoteConnectCompareHypervisorCPU, /* 4.4.0 */
.connectBaselineHypervisorCPU = remoteConnectBaselineHypervisorCPU, /* 4.4.0 */
+ .connectGetHypervisorCPUModelNames = remoteConnectGetHypervisorCPUModelNames, /* 11.1.0 */
.nodeGetSEVInfo = remoteNodeGetSEVInfo, /* 4.5.0 */
.domainGetLaunchSecurityInfo = remoteDomainGetLaunchSecurityInfo, /* 4.5.0 */
.domainCheckpointCreateXML = 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 = 64;
/* Upper limit on number of CPU models */
const REMOTE_CONNECT_CPU_MODELS_MAX = 8192;
+/* Upper limit on number Hypervisor CPU models */
+const REMOTE_CONNECT_HYPERVISOR_CPU_MODELS_MAX = 256;
+
/* Upper limit on number of mountpoints to frozen */
const REMOTE_DOMAIN_FSFREEZE_MOUNTPOINTS_MAX = 256;
@@ -3679,6 +3682,20 @@ 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;
+ unsigned int flags;
+};
+
+struct remote_connect_get_hypervisor_cpu_model_names_ret {
+ remote_nonnull_string models<REMOTE_CONNECT_HYPERVISOR_CPU_MODELS_MAX>;
+ 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 = 448
+ REMOTE_PROC_DOMAIN_GRAPHICS_RELOAD = 448,
+
+ /**
+ * @generate: none
+ * @priority: high
+ * @acl: connect:write
+ */
+ REMOTE_PROC_CONNECT_GET_HYPERVISOR_CPU_MODEL_NAMES = 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 = 446,
REMOTE_PROC_NODE_DEVICE_UPDATE = 447,
REMOTE_PROC_DOMAIN_GRAPHICS_RELOAD = 448,
+ REMOTE_PROC_CONNECT_GET_HYPERVISOR_CPU_MODEL_NAMES = 449,
};
--
2.47.0
© 2016 - 2025 Red Hat, Inc.