Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
src/remote/remote_daemon_dispatch.c | 46 +++++++++++++++++++++++++++++
src/remote/remote_driver.c | 44 +++++++++++++++++++++++++++
src/remote/remote_protocol.x | 20 ++++++++++++-
3 files changed, 109 insertions(+), 1 deletion(-)
diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c
index aa6a088222..f2249dfa0f 100644
--- a/src/remote/remote_daemon_dispatch.c
+++ b/src/remote/remote_daemon_dispatch.c
@@ -7508,3 +7508,49 @@ remoteDispatchDomainGetDeprecations(virNetServerPtr server
G_GNUC_UNUSED,
return rv;
}
+
+
+static int
+remoteDispatchDomainGetTainting(virNetServerPtr server G_GNUC_UNUSED,
+ virNetServerClientPtr client,
+ virNetMessagePtr msg G_GNUC_UNUSED,
+ virNetMessageErrorPtr rerr,
+ remote_domain_get_tainting_args *args,
+ remote_domain_get_tainting_ret *ret)
+{
+ int rv = -1;
+ virConnectPtr conn = remoteGetHypervisorConn(client);
+ int ncodes = 0;
+ char **codes = NULL;
+ virDomainPtr dom = NULL;
+
+ if (!conn)
+ goto cleanup;
+
+ if (!(dom = get_nonnull_domain(conn, args->dom)))
+ goto cleanup;
+
+ if ((ncodes = virDomainGetTainting(dom, &codes, args->flags)) < 0)
+ goto cleanup;
+
+ if (ncodes > REMOTE_DOMAIN_TAINTING_MAX) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Number of codes %d, which exceeds max limit: %d"),
+ ncodes, REMOTE_DOMAIN_TAINTING_MAX);
+ goto cleanup;
+ }
+
+ ret->codes.codes_val = g_steal_pointer(&codes);
+ ret->codes.codes_len = ncodes;
+
+ rv = ncodes;
+
+ cleanup:
+ if (rv < 0)
+ virNetMessageSaveError(rerr);
+ if (ncodes > 0)
+ virStringListFreeCount(codes, ncodes);
+ virObjectUnref(dom);
+
+ return rv;
+}
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 009df01a54..c3cdb751f6 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -8141,6 +8141,49 @@ remoteDomainGetDeprecations(virDomainPtr domain,
return rv;
}
+static int
+remoteDomainGetTainting(virDomainPtr domain,
+ char ***codes,
+ unsigned int flags)
+{
+ int rv = -1;
+ size_t i;
+ struct private_data *priv = domain->conn->privateData;
+ remote_domain_get_tainting_args args;
+ remote_domain_get_tainting_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_TAINTING,
+ (xdrproc_t) xdr_remote_domain_get_tainting_args, (char *)&args,
+ (xdrproc_t) xdr_remote_domain_get_tainting_ret, (char *)&ret) == -1) {
+ goto cleanup;
+ }
+
+ if (ret.codes.codes_len > REMOTE_DOMAIN_TAINTING_MAX) {
+ virReportError(VIR_ERR_RPC, "%s",
+ _("remoteDomainGetTainting: "
+ "returned number of codes exceeds limit"));
+ goto cleanup;
+ }
+
+ *codes = g_new0(char *, ret.codes.codes_len + 1);
+ for (i = 0; i < ret.codes.codes_len; i++)
+ (*codes)[i] = g_strdup(ret.codes.codes_val[i]);
+
+ rv = ret.codes.codes_len;
+
+ cleanup:
+ remoteDriverUnlock(priv);
+ xdr_free((xdrproc_t)xdr_remote_domain_get_tainting_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,
@@ -8575,6 +8618,7 @@ static virHypervisorDriver hypervisor_driver = {
.domainAuthorizedSSHKeysGet = remoteDomainAuthorizedSSHKeysGet, /* 6.10.0 */
.domainAuthorizedSSHKeysSet = remoteDomainAuthorizedSSHKeysSet, /* 6.10.0 */
.domainGetDeprecations = remoteDomainGetDeprecations, /* 7.1.0 */
+ .domainGetTainting = remoteDomainGetTainting, /* 7.1.0 */
};
static virNetworkDriver network_driver = {
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 4ddfb09631..bcb15b251f 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -286,6 +286,9 @@ const REMOTE_DOMAIN_AUTHORIZED_SSH_KEYS_MAX = 2048;
/* Upper limit on number of deprecation messages */
const REMOTE_DOMAIN_DEPRECATIONS_MAX = 2048;
+/* Upper limit on number of tainting codes */
+const REMOTE_DOMAIN_TAINTING_MAX = 2048;
+
/* UUID. VIR_UUID_BUFLEN definition comes from libvirt.h */
typedef opaque remote_uuid[VIR_UUID_BUFLEN];
@@ -3811,6 +3814,15 @@ struct remote_domain_get_deprecations_ret {
remote_nonnull_string msgs<REMOTE_DOMAIN_DEPRECATIONS_MAX>;
};
+struct remote_domain_get_tainting_args {
+ remote_nonnull_domain dom;
+ unsigned int flags;
+};
+
+struct remote_domain_get_tainting_ret {
+ remote_nonnull_string codes<REMOTE_DOMAIN_TAINTING_MAX>;
+};
+
/*----- Protocol. -----*/
@@ -6733,5 +6745,11 @@ enum remote_procedure {
* @generate: none
* @acl: domain:read
*/
- REMOTE_PROC_DOMAIN_GET_DEPRECATIONS = 426
+ REMOTE_PROC_DOMAIN_GET_DEPRECATIONS = 426,
+
+ /**
+ * @generate: none
+ * @acl: domain:read
+ */
+ REMOTE_PROC_DOMAIN_GET_TAINTING = 427
};
--
2.29.2