Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx> --- src/remote/remote_daemon_dispatch.c | 45 +++++++++++++++++++++++++++++ src/remote/remote_driver.c | 44 ++++++++++++++++++++++++++++ src/remote/remote_protocol.x | 21 +++++++++++++- 3 files changed, 109 insertions(+), 1 deletion(-) diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c index 46683aa4a7..aa6a088222 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -7463,3 +7463,48 @@ remoteDispatchDomainAuthorizedSshKeysSet(virNetServerPtr server G_GNUC_UNUSED, return rv; } + +static int +remoteDispatchDomainGetDeprecations(virNetServerPtr server G_GNUC_UNUSED, + virNetServerClientPtr client, + virNetMessagePtr msg G_GNUC_UNUSED, + virNetMessageErrorPtr rerr, + remote_domain_get_deprecations_args *args, + remote_domain_get_deprecations_ret *ret) +{ + int rv = -1; + virConnectPtr conn = remoteGetHypervisorConn(client); + int nmsgs = 0; + char **msgs = NULL; + virDomainPtr dom = NULL; + + if (!conn) + goto cleanup; + + if (!(dom = get_nonnull_domain(conn, args->dom))) + goto cleanup; + + if ((nmsgs = virDomainGetDeprecations(dom, &msgs, args->flags)) < 0) + goto cleanup; + + if (nmsgs > REMOTE_DOMAIN_DEPRECATIONS_MAX) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Number of msgs %d, which exceeds max limit: %d"), + nmsgs, REMOTE_DOMAIN_DEPRECATIONS_MAX); + goto cleanup; + } + + ret->msgs.msgs_val = g_steal_pointer(&msgs); + ret->msgs.msgs_len = nmsgs; + + rv = nmsgs; + + cleanup: + if (rv < 0) + virNetMessageSaveError(rerr); + if (nmsgs > 0) + virStringListFreeCount(msgs, nmsgs); + virObjectUnref(dom); + + return rv; +} diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index 1b784e61c7..009df01a54 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -8098,6 +8098,49 @@ remoteDomainAuthorizedSSHKeysSet(virDomainPtr domain, } +static int +remoteDomainGetDeprecations(virDomainPtr domain, + char ***msgs, + unsigned int flags) +{ + int rv = -1; + size_t i; + struct private_data *priv = domain->conn->privateData; + remote_domain_get_deprecations_args args; + remote_domain_get_deprecations_ret ret; + + remoteDriverLock(priv); + + make_nonnull_domain(&args.dom, domain); + args.flags = flags; + memset(&ret, 0, sizeof(ret)); + + if (call(domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_DEPRECATIONS, + (xdrproc_t) xdr_remote_domain_get_deprecations_args, (char *)&args, + (xdrproc_t) xdr_remote_domain_get_deprecations_ret, (char *)&ret) == -1) { + goto cleanup; + } + + if (ret.msgs.msgs_len > REMOTE_DOMAIN_DEPRECATIONS_MAX) { + virReportError(VIR_ERR_RPC, "%s", + _("remoteDomainGetDeprecations: " + "returned number of msgs exceeds limit")); + goto cleanup; + } + + *msgs = g_new0(char *, ret.msgs.msgs_len + 1); + for (i = 0; i < ret.msgs.msgs_len; i++) + (*msgs)[i] = g_strdup(ret.msgs.msgs_val[i]); + + rv = ret.msgs.msgs_len; + + cleanup: + remoteDriverUnlock(priv); + xdr_free((xdrproc_t)xdr_remote_domain_get_deprecations_ret, + (char *) &ret); + return rv; +} + /* get_nonnull_domain and get_nonnull_network turn an on-wire * (name, uuid) pair into virDomainPtr or virNetworkPtr object. * These can return NULL if underlying memory allocations fail, @@ -8531,6 +8574,7 @@ static virHypervisorDriver hypervisor_driver = { .domainBackupGetXMLDesc = remoteDomainBackupGetXMLDesc, /* 6.0.0 */ .domainAuthorizedSSHKeysGet = remoteDomainAuthorizedSSHKeysGet, /* 6.10.0 */ .domainAuthorizedSSHKeysSet = remoteDomainAuthorizedSSHKeysSet, /* 6.10.0 */ + .domainGetDeprecations = remoteDomainGetDeprecations, /* 7.1.0 */ }; static virNetworkDriver network_driver = { diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x index 2df38cef77..4ddfb09631 100644 --- a/src/remote/remote_protocol.x +++ b/src/remote/remote_protocol.x @@ -283,6 +283,9 @@ const REMOTE_NETWORK_PORT_PARAMETERS_MAX = 16; /* Upper limit on number of SSH keys */ const REMOTE_DOMAIN_AUTHORIZED_SSH_KEYS_MAX = 2048; +/* Upper limit on number of deprecation messages */ +const REMOTE_DOMAIN_DEPRECATIONS_MAX = 2048; + /* UUID. VIR_UUID_BUFLEN definition comes from libvirt.h */ typedef opaque remote_uuid[VIR_UUID_BUFLEN]; @@ -3799,6 +3802,16 @@ struct remote_domain_authorized_ssh_keys_set_args { unsigned int flags; }; +struct remote_domain_get_deprecations_args { + remote_nonnull_domain dom; + unsigned int flags; +}; + +struct remote_domain_get_deprecations_ret { + remote_nonnull_string msgs<REMOTE_DOMAIN_DEPRECATIONS_MAX>; +}; + + /*----- Protocol. -----*/ /* Define the program number, protocol version and procedure numbers here. */ @@ -6714,5 +6727,11 @@ enum remote_procedure { * @generate: none * @acl: domain:write */ - REMOTE_PROC_DOMAIN_AUTHORIZED_SSH_KEYS_SET = 425 + REMOTE_PROC_DOMAIN_AUTHORIZED_SSH_KEYS_SET = 425, + + /** + * @generate: none + * @acl: domain:read + */ + REMOTE_PROC_DOMAIN_GET_DEPRECATIONS = 426 }; -- 2.29.2