Signed-off-by: Tim Wiederhake <twiederh(a)redhat.com>
---
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,
}
+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 = 0;
+ int rv = -1;
+ g_auto(GStrv) names = NULL;
+ g_auto(GStrv) aliases = NULL;
+ virConnectPtr conn = remoteGetHypervisorConn(client);
+
+ if (!conn)
+ goto cleanup;
+
+ len = 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 = g_steal_pointer(&names);
+ ret->names.names_len = len;
+ ret->aliases.aliases_val = g_steal_pointer(&aliases);
+ ret->aliases.aliases_len = len;
+ 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 94566069f0..8dca23a7eb 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -6393,6 +6393,64 @@ remoteConnectGetCPUModelNames(virConnectPtr conn,
}
+static int
+remoteConnectGetHypervisorCPUModelNames(virConnectPtr conn,
+ const char *archName,
+ char ***names,
+ char ***aliases,
+ unsigned int flags)
+{
+ int rv = -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 = conn->privateData;
+
+ remoteDriverLock(priv);
+
+ args.arch = (char *) archName;
+ args.flags = flags;
+
+ memset(&ret, 0, sizeof(ret));
+ 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)
+ 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 = g_new0(char *, ret.names.names_len + 1);
+ for (i = 0; i < ret.names.names_len; i++) {
+ (*names)[i] = g_steal_pointer(&ret.names.names_val[i]);
+ }
+
+ *aliases = g_new0(char *, ret.aliases.aliases_len + 1);
+ for (i = 0; i < ret.aliases.aliases_len; i++) {
+ (*aliases)[i] = g_steal_pointer(&ret.aliases.aliases_val[i]);
+ }
+
+ rv = 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 = {
.domainGetMessages = remoteDomainGetMessages, /* 7.1.0 */
.domainStartDirtyRateCalc = remoteDomainStartDirtyRateCalc, /* 7.2.0 */
.domainSetLaunchSecurityState = remoteDomainSetLaunchSecurityState, /* 8.0.0 */
+ .connectGetHypervisorCPUModelNames = remoteConnectGetHypervisorCPUModelNames, /*
8.5.0 */
};
static virNetworkDriver network_driver = {
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;
};
+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_CONNECT_CPU_MODELS_MAX>;
+ remote_nonnull_string aliases<REMOTE_CONNECT_CPU_MODELS_MAX>;
+ 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 = 442
+ REMOTE_PROC_DOMAIN_ABORT_JOB_FLAGS = 442,
+
+ /**
+ * @generate: none
+ * @acl: connect:read
+ */
+ REMOTE_PROC_CONNECT_GET_HYPERVISOR_CPU_MODEL_NAMES = 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 = 440,
REMOTE_PROC_DOMAIN_RESTORE_PARAMS = 441,
REMOTE_PROC_DOMAIN_ABORT_JOB_FLAGS = 442,
+ REMOTE_PROC_CONNECT_GET_HYPERVISOR_CPU_MODEL_NAMES = 443,
};
--
2.31.1