Re: [PATCH 2/5] list: Implement RPC calls for virConnectListAllNWFilters

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

 



On 09/05/12 08:02, Osier Yang wrote:
The RPC generator doesn't support returning list of object yet, this patch
do the work manually.

   * daemon/remote.c:
     Implemente the server side handler remoteDispatchConnectListAllNWFilters.

   * src/remote/remote_driver.c:
     Add remote driver handler remoteConnectListAllNWFilters.

   * src/remote/remote_protocol.x:
     New RPC procedure REMOTE_PROC_CONNECT_LIST_ALL_NWFILTERS and
     structs to represent the args and ret for it.

   * src/remote_protocol-structs: Likewise.
---
  daemon/remote.c              |   54 ++++++++++++++++++++++++++++++++++++
  src/remote/remote_driver.c   |   63 ++++++++++++++++++++++++++++++++++++++++++
  src/remote/remote_protocol.x |   13 ++++++++-
  src/remote_protocol-structs  |   12 ++++++++
  4 files changed, 141 insertions(+), 1 deletions(-)


diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index b1671ae..2afe5b0 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -2907,6 +2907,68 @@ done:
      return rv;
  }

+static int
+remoteConnectListAllNWFilters(virConnectPtr conn,
+                              virNWFilterPtr **filters,
+                              unsigned int flags)
+{
+    int rv = -1;
+    int i;
+    virNWFilterPtr *tmp_filters = NULL;
+    remote_connect_list_all_nwfilters_args args;
+    remote_connect_list_all_nwfilters_ret ret;
+
+    struct private_data *priv = conn->privateData;
+
+    remoteDriverLock(priv);
+
+    args.need_results = !!filters;
+    args.flags = flags;
+
+    memset(&ret, 0, sizeof(ret));
+    if (call(conn,
+             priv,
+             0,
+             REMOTE_PROC_CONNECT_LIST_ALL_NWFILTERS,
+             (xdrproc_t) xdr_remote_connect_list_all_nwfilters_args,
+             (char *) &args,
+             (xdrproc_t) xdr_remote_connect_list_all_nwfilters_ret,
+             (char *) &ret) == -1)
+        goto done;
+
+    if (filters) {
+        if (VIR_ALLOC_N(tmp_filters, ret.filters.filters_len + 1) < 0) {
+            virReportOOMError();
+            goto cleanup;
+        }
+
+        for (i = 0; i < ret.filters.filters_len; i++) {
+            tmp_filters[i] = get_nonnull_nwfilter (conn, ret.filters.filters_val[i]);

Space before function arguments.

+            if (!tmp_filters[i]) {
+                virReportOOMError();
+                goto cleanup;
+            }
+        }
+        *filters = tmp_filters;
+        tmp_filters = NULL;
+    }
+
+    rv = ret.ret;
+
+cleanup:
+    if (tmp_filters) {
+        for (i = 0; i < ret.filters.filters_len; i++)
+            if (tmp_filters[i])
+                virNWFilterFree(tmp_filters[i]);
+        VIR_FREE(tmp_filters);
+    }
+
+    xdr_free((xdrproc_t) xdr_remote_connect_list_all_nwfilters_ret, (char *) &ret);
+
+done:
+    remoteDriverUnlock(priv);
+    return rv;
+}

  /*----------------------------------------------------------------------*/

@@ -6012,6 +6074,7 @@ static virNWFilterDriver nwfilter_driver = {
      .undefine             = remoteNWFilterUndefine, /* 0.8.0 */
      .numOfNWFilters       = remoteNumOfNWFilters, /* 0.8.0 */
      .listNWFilters        = remoteListNWFilters, /* 0.8.0 */
+    .listAllNWFilters     = remoteConnectListAllNWFilters, /* 0.10.2 */
  };



Otherwise looks OK.

Peter

--
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]