[PATCHv2 3/5] Add virDomain{S, G}etInterfaceparameters support to the remote driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* daemon/remote.c: implement the server side support
* src/remote/remote_driver.c: implement the client side support
* src/remote/remote_protocol.x: definitions for the mew entry points
* src/remote_protocol-structs: structure definitions
---
 daemon/remote.c              |   64 ++++++++++++++++++++++++++++++++++++++++++
 src/remote/remote_driver.c   |   52 ++++++++++++++++++++++++++++++++++
 src/remote/remote_protocol.x |   28 +++++++++++++++++-
 src/remote_protocol-structs  |   24 +++++++++++++++
 4 files changed, 167 insertions(+), 1 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index 316d530..b7ba321 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -3436,6 +3436,70 @@ cleanup:
     return rv;
 }
 
+static int
+remoteDispatchDomainGetInterfaceParameters(virNetServerPtr server ATTRIBUTE_UNUSED,
+                                           virNetServerClientPtr client ATTRIBUTE_UNUSED,
+                                           virNetMessagePtr msg ATTRIBUTE_UNUSED,
+                                           virNetMessageErrorPtr rerr,
+                                           remote_domain_get_interface_parameters_args *args,
+                                           remote_domain_get_interface_parameters_ret *ret)
+{
+    virDomainPtr dom = NULL;
+    virTypedParameterPtr params = NULL;
+    const char *device = args->device;
+    int nparams = args->nparams;
+    unsigned int flags;
+    int rv = -1;
+    struct daemonClientPrivate *priv =
+        virNetServerClientGetPrivateData(client);
+
+    if (!priv->conn) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
+        goto cleanup;
+    }
+
+    flags = args->flags;
+
+    if (nparams > REMOTE_DOMAIN_INTERFACE_PARAMETERS_MAX) {
+        virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large"));
+        goto cleanup;
+    }
+    if (VIR_ALLOC_N(params, nparams) < 0) {
+        virReportOOMError();
+        goto cleanup;
+    }
+
+    if (!(dom = get_nonnull_domain(priv->conn, args->dom)))
+        goto cleanup;
+
+    if (virDomainGetInterfaceParameters(dom, device, params, &nparams, flags) < 0)
+        goto cleanup;
+
+    /* In this case, we need to send back the number of parameters
+     * supported
+     */
+    if (args->nparams == 0) {
+        ret->nparams = nparams;
+        goto success;
+    }
+
+    if (remoteSerializeTypedParameters(params, nparams,
+                                       &ret->params.params_val,
+                                       &ret->params.params_len,
+                                       flags) < 0)
+        goto cleanup;
+
+success:
+    rv = 0;
+
+cleanup:
+    if (rv < 0)
+        virNetMessageSaveError(rerr);
+    if (dom)
+        virDomainFree(dom);
+    VIR_FREE(params);
+    return rv;
+}
 
 /*----- Helpers. -----*/
 
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index cd3da53..7580477 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -4396,6 +4396,56 @@ call (virConnectPtr conn,
 }
 
 
+static int
+remoteDomainGetInterfaceParameters (virDomainPtr domain,
+                                    const char *device,
+                                    virTypedParameterPtr params, int *nparams,
+                                    unsigned int flags)
+{
+    int rv = -1;
+    remote_domain_get_interface_parameters_args args;
+    remote_domain_get_interface_parameters_ret ret;
+    struct private_data *priv = domain->conn->privateData;
+
+    remoteDriverLock(priv);
+
+    make_nonnull_domain (&args.dom, domain);
+    args.device = (char *)device;
+    args.nparams = *nparams;
+    args.flags = flags;
+
+    memset (&ret, 0, sizeof ret);
+    if (call (domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_INTERFACE_PARAMETERS,
+              (xdrproc_t) xdr_remote_domain_get_interface_parameters_args, (char *) &args,
+              (xdrproc_t) xdr_remote_domain_get_interface_parameters_ret, (char *) &ret) == -1)
+        goto done;
+
+    /* Handle the case when the caller does not know the number of parameters
+     * and is asking for the number of parameters supported
+     */
+    if (*nparams == 0) {
+        *nparams = ret.nparams;
+        rv = 0;
+        goto cleanup;
+    }
+
+    if (remoteDeserializeTypedParameters(ret.params.params_val,
+                                         ret.params.params_len,
+                                         REMOTE_DOMAIN_INTERFACE_PARAMETERS_MAX,
+                                         params,
+                                         nparams) < 0)
+        goto cleanup;
+
+    rv = 0;
+
+cleanup:
+    xdr_free ((xdrproc_t) xdr_remote_domain_get_interface_parameters_ret,
+              (char *) &ret);
+done:
+    remoteDriverUnlock(priv);
+    return rv;
+}
+
 static void
 remoteDomainEventQueue(struct private_data *priv, virDomainEventPtr event)
 {
@@ -4619,6 +4669,8 @@ static virDriver remote_driver = {
     .domainBlockStats = remoteDomainBlockStats, /* 0.3.2 */
     .domainBlockStatsFlags = remoteDomainBlockStatsFlags, /* 0.9.5 */
     .domainInterfaceStats = remoteDomainInterfaceStats, /* 0.3.2 */
+    .domainSetInterfaceParameters = remoteDomainSetInterfaceParameters, /* 0.9.9 */
+    .domainGetInterfaceParameters = remoteDomainGetInterfaceParameters, /* 0.9.9 */
     .domainMemoryStats = remoteDomainMemoryStats, /* 0.7.5 */
     .domainBlockPeek = remoteDomainBlockPeek, /* 0.4.2 */
     .domainMemoryPeek = remoteDomainMemoryPeek, /* 0.4.2 */
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 18dba8c..ca739ff 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -202,6 +202,11 @@ const REMOTE_CPU_BASELINE_MAX = 256;
  */
 const REMOTE_DOMAIN_SEND_KEY_MAX = 16;
 
+/*
+ * Upper limit on list of interface parameters
+ */
+const REMOTE_DOMAIN_INTERFACE_PARAMETERS_MAX = 16;
+
 /* UUID.  VIR_UUID_BUFLEN definition comes from libvirt.h */
 typedef opaque remote_uuid[VIR_UUID_BUFLEN];
 
@@ -608,6 +613,25 @@ struct remote_domain_interface_stats_ret { /* insert@2 */
     hyper tx_drop;
 };
 
+struct remote_domain_set_interface_parameters_args {
+    remote_nonnull_domain dom;
+    remote_nonnull_string device;
+    remote_typed_param params<REMOTE_DOMAIN_INTERFACE_PARAMETERS_MAX>;
+    unsigned int flags;
+};
+
+struct remote_domain_get_interface_parameters_args {
+    remote_nonnull_domain dom;
+    remote_nonnull_string device;
+    int nparams;
+    unsigned int flags;
+};
+
+struct remote_domain_get_interface_parameters_ret {
+    remote_typed_param params<REMOTE_DOMAIN_INTERFACE_PARAMETERS_MAX>;
+    int nparams;
+};
+
 struct remote_domain_memory_stats_args {
     remote_nonnull_domain dom;
     unsigned int maxStats;
@@ -2627,7 +2651,9 @@ enum remote_procedure {
     REMOTE_PROC_DOMAIN_SET_BLOCK_IO_TUNE = 252, /* autogen autogen */
     REMOTE_PROC_DOMAIN_GET_BLOCK_IO_TUNE = 253, /* skipgen skipgen */
     REMOTE_PROC_DOMAIN_SET_NUMA_PARAMETERS = 254, /* autogen autogen */
-    REMOTE_PROC_DOMAIN_GET_NUMA_PARAMETERS = 255 /* skipgen skipgen */
+    REMOTE_PROC_DOMAIN_GET_NUMA_PARAMETERS = 255, /* skipgen skipgen */
+    REMOTE_PROC_DOMAIN_SET_INTERFACE_PARAMETERS = 256, /* autogen autogen */
+    REMOTE_PROC_DOMAIN_GET_INTERFACE_PARAMETERS = 257 /* skipgen skipgen */
 
     /*
      * Notice how the entries are grouped in sets of 10 ?
diff --git a/src/remote_protocol-structs b/src/remote_protocol-structs
index f6d8ff5..2758315 100644
--- a/src/remote_protocol-structs
+++ b/src/remote_protocol-structs
@@ -328,6 +328,28 @@ struct remote_domain_interface_stats_ret {
         int64_t                    tx_errs;
         int64_t                    tx_drop;
 };
+struct remote_domain_set_interface_parameters_args {
+        remote_nonnull_domain      dom;
+        remote_nonnull_string      device;
+        struct {
+                u_int              params_len;
+                remote_typed_param * params_val;
+        } params;
+        u_int                      flags;
+};
+struct remote_domain_get_interface_parameters_args {
+        remote_nonnull_domain      dom;
+        remote_nonnull_string      device;
+        int                        nparams;
+        u_int                      flags;
+};
+struct remote_domain_get_interface_parameters_ret {
+        struct {
+                u_int              params_len;
+                remote_typed_param * params_val;
+        } params;
+        int                        nparams;
+};
 struct remote_domain_memory_stats_args {
         remote_nonnull_domain      dom;
         u_int                      maxStats;
@@ -2066,4 +2088,6 @@ enum remote_procedure {
         REMOTE_PROC_DOMAIN_GET_BLOCK_IO_TUNE = 253,
         REMOTE_PROC_DOMAIN_SET_NUMA_PARAMETERS = 254,
         REMOTE_PROC_DOMAIN_GET_NUMA_PARAMETERS = 255,
+        REMOTE_PROC_DOMAIN_SET_INTERFACE_PARAMETERS = 256,
+        REMOTE_PROC_DOMAIN_GET_INTERFACE_PARAMETERS = 257,
 };
-- 
1.7.4.4

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


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]