Implement the API function virDomainGetStateParams for the remote driver
and wire up the remote protocol.

Reviewed-by: Boris Fiuczynski <fiu...@linux.ibm.com>
Signed-off-by: Bjoern Walk <bw...@linux.ibm.com>
---
 src/remote/remote_daemon_dispatch.c | 50 +++++++++++++++++++++++++++++
 src/remote/remote_driver.c          | 48 +++++++++++++++++++++++++++
 src/remote/remote_protocol.x        | 22 ++++++++++++-
 src/remote_protocol-structs         | 13 ++++++++
 4 files changed, 132 insertions(+), 1 deletion(-)

diff --git a/src/remote/remote_daemon_dispatch.c 
b/src/remote/remote_daemon_dispatch.c
index df282590..e1e48559 100644
--- a/src/remote/remote_daemon_dispatch.c
+++ b/src/remote/remote_daemon_dispatch.c
@@ -7392,3 +7392,53 @@ remoteSerializeDomainDiskErrors(virDomainDiskErrorPtr 
errors,
     }
     return -1;
 }
+
+static int
+remoteDispatchDomainGetStateParams(virNetServerPtr server ATTRIBUTE_UNUSED,
+                                   virNetServerClientPtr client,
+                                   virNetMessagePtr msg ATTRIBUTE_UNUSED,
+                                   virNetMessageErrorPtr rerr,
+                                   remote_domain_get_state_params_args *args,
+                                   remote_domain_get_state_params_ret *ret)
+{
+    virDomainPtr dom = NULL;
+    virTypedParameterPtr params = NULL;
+    int nparams = 0;
+    int rv = -1;
+    struct daemonClientPrivate *priv =
+        virNetServerClientGetPrivateData(client);
+
+    if (!priv->conn) {
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+        goto cleanup;
+
+    if (virDomainGetStateParams(dom, &ret->state, &ret->reason, &params,
+                                &nparams, args->flags) < 0)
+        goto cleanup;
+
+    if (nparams > REMOTE_DOMAIN_STATE_PARAMS_MAX) {
+        virReportError(VIR_ERR_RPC,
+                       _("Too many state information entries '%d' for limit 
'%d'"),
+                       nparams, REMOTE_DOMAIN_STATE_PARAMS_MAX);
+        goto cleanup;
+    }
+
+    if (virTypedParamsSerialize(params, nparams,
+                                (virTypedParameterRemotePtr *) 
&ret->params.params_val,
+                                &ret->params.params_len,
+                                VIR_TYPED_PARAM_STRING_OKAY) < 0)
+        goto cleanup;
+
+    rv = 0;
+
+ cleanup:
+    if (rv < 0)
+        virNetMessageSaveError(rerr);
+    virTypedParamsFree(params, nparams);
+    virObjectUnref(dom);
+    return rv;
+}
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 5c4dd412..6907e457 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -8131,6 +8131,53 @@ remoteStorageVolGetInfoFlags(virStorageVolPtr vol,
     return rv;
 }
 
+static int
+remoteDomainGetStateParams(virDomainPtr domain,
+                           int *state,
+                           int *reason,
+                           virTypedParameterPtr *params,
+                           int *nparams,
+                           unsigned int flags)
+{
+    int rv = -1;
+    remote_domain_get_state_params_args args;
+    remote_domain_get_state_params_ret ret;
+    struct private_data *priv = domain->conn->privateData;
+
+    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_STATE_PARAMS,
+             (xdrproc_t) xdr_remote_domain_get_state_params_args, (char *) 
&args,
+             (xdrproc_t) xdr_remote_domain_get_state_params_ret, (char *) 
&ret) == -1)
+        goto done;
+
+    if (state)
+        *state = ret.state;
+    if (reason)
+        *reason = ret.reason;
+
+    if (params &&
+        virTypedParamsDeserialize((virTypedParameterRemotePtr) 
ret.params.params_val,
+                                  ret.params.params_len,
+                                  REMOTE_DOMAIN_STATE_PARAMS_MAX,
+                                  params, nparams) < 0) {
+        goto cleanup;
+    }
+
+    rv = 0;
+
+ cleanup:
+    xdr_free((xdrproc_t) xdr_remote_domain_get_state_params_ret,
+             (char *) &ret);
+ done:
+    remoteDriverUnlock(priv);
+    return rv;
+}
+
 
 /* get_nonnull_domain and get_nonnull_network turn an on-wire
  * (name, uuid) pair into virDomainPtr or virNetworkPtr object.
@@ -8326,6 +8373,7 @@ static virHypervisorDriver hypervisor_driver = {
     .domainSetPerfEvents = remoteDomainSetPerfEvents, /* 1.3.3 */
     .domainGetInfo = remoteDomainGetInfo, /* 0.3.0 */
     .domainGetState = remoteDomainGetState, /* 0.9.2 */
+    .domainGetStateParams = remoteDomainGetStateParams, /* 5.3.0 */
     .domainGetControlInfo = remoteDomainGetControlInfo, /* 0.9.3 */
     .domainSave = remoteDomainSave, /* 0.3.0 */
     .domainSaveFlags = remoteDomainSaveFlags, /* 0.9.4 */
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 74be4b37..6db1ccc1 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -263,6 +263,9 @@ const REMOTE_NODE_SEV_INFO_MAX = 64;
 /* Upper limit on number of launch security information entries */
 const REMOTE_DOMAIN_LAUNCH_SECURITY_INFO_PARAMS_MAX = 64;
 
+/* Upper limit on number of state information entries */
+const REMOTE_DOMAIN_STATE_PARAMS_MAX = 16;
+
 /* UUID.  VIR_UUID_BUFLEN definition comes from libvirt.h */
 typedef opaque remote_uuid[VIR_UUID_BUFLEN];
 
@@ -2789,6 +2792,17 @@ struct remote_domain_get_state_ret {
     int reason;
 };
 
+struct remote_domain_get_state_params_args {
+    remote_nonnull_domain dom;
+    unsigned int flags;
+};
+
+struct remote_domain_get_state_params_ret {
+    int state;
+    int reason;
+    remote_typed_param params<REMOTE_DOMAIN_STATE_PARAMS_MAX>;
+};
+
 struct remote_domain_migrate_begin3_args {
     remote_nonnull_domain dom;
     remote_string xmlin;
@@ -6342,5 +6356,11 @@ enum remote_procedure {
      * @generate: both
      * @acl: connect:read
      */
-    REMOTE_PROC_CONNECT_GET_STORAGE_POOL_CAPABILITIES = 403
+    REMOTE_PROC_CONNECT_GET_STORAGE_POOL_CAPABILITIES = 403,
+
+    /**
+     * @generate: none
+     * @acl: domain:read
+     */
+    REMOTE_PROC_DOMAIN_GET_STATE_PARAMS = 404
 };
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index 768189c5..edecc4e4 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -2162,6 +2162,18 @@ struct remote_domain_get_state_ret {
         int                        state;
         int                        reason;
 };
+struct remote_domain_get_state_params_args {
+        remote_nonnull_domain      dom;
+        u_int                      flags;
+};
+struct remote_domain_get_state_params_ret {
+        int                        state;
+        int                        reason;
+        struct {
+                u_int              params_len;
+                remote_typed_param * params_val;
+        } params;
+};
 struct remote_domain_migrate_begin3_args {
         remote_nonnull_domain      dom;
         remote_string              xmlin;
@@ -3385,4 +3397,5 @@ enum remote_procedure {
         REMOTE_PROC_CONNECT_LIST_ALL_NWFILTER_BINDINGS = 401,
         REMOTE_PROC_DOMAIN_SET_IOTHREAD_PARAMS = 402,
         REMOTE_PROC_CONNECT_GET_STORAGE_POOL_CAPABILITIES = 403,
+        REMOTE_PROC_DOMAIN_GET_STATE_PARAMS = 404,
 };
-- 
2.19.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to