[PATCH 16/21] admin: Generate ConnectListServers dispatch helpers

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

 



Since we have the opportunity now, let's save some precious code lines.

Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
---
 daemon/admin.c             | 45 ---------------------------------
 daemon/admin_server.c      |  6 ++---
 daemon/admin_server.h      |  6 ++---
 po/POTFILES.in             |  1 -
 src/admin/admin_protocol.x |  4 +--
 src/admin/admin_remote.c   | 63 ----------------------------------------------
 6 files changed, 8 insertions(+), 117 deletions(-)

diff --git a/daemon/admin.c b/daemon/admin.c
index cae2a84d84b8..3169cddb5807 100644
--- a/daemon/admin.c
+++ b/daemon/admin.c
@@ -133,49 +133,4 @@ adminConnectGetLibVersion(virNetDaemonPtr dmn ATTRIBUTE_UNUSED,
     return 0;
 }

-static int
-adminDispatchConnectListServers(virNetServerPtr server ATTRIBUTE_UNUSED,
-                                virNetServerClientPtr client,
-                                virNetMessagePtr msg ATTRIBUTE_UNUSED,
-                                virNetMessageErrorPtr rerr ATTRIBUTE_UNUSED,
-                                admin_connect_list_servers_args *args,
-                                admin_connect_list_servers_ret *ret)
-{
-    virNetServerPtr *servers = NULL;
-    int nservers = 0;
-    int rv = -1;
-    size_t i;
-    struct daemonAdmClientPrivate *priv =
-        virNetServerClientGetPrivateData(client);
-
-    if ((nservers =
-            adminDaemonListServers(priv->dmn,
-                                   args->need_results ? &servers : NULL,
-                                   args->flags)) < 0)
-        goto cleanup;
-
-    if (servers && nservers) {
-        if (VIR_ALLOC_N(ret->servers.servers_val, nservers) < 0)
-            goto cleanup;
-
-        ret->servers.servers_len = nservers;
-        for (i = 0; i < nservers; i++)
-            make_nonnull_server(ret->servers.servers_val + i, servers[i]);
-    } else {
-        ret->servers.servers_len = 0;
-        ret->servers.servers_val = NULL;
-    }
-
-    ret->ret = nservers;
-    rv = 0;
-
- cleanup:
-    if (rv < 0)
-        virNetMessageSaveError(rerr);
-    if (servers && nservers > 0)
-        for (i = 0; i < nservers; i++)
-            virObjectUnref(servers[i]);
-    VIR_FREE(servers);
-    return rv;
-}
 #include "admin_dispatch.h"
diff --git a/daemon/admin_server.c b/daemon/admin_server.c
index a35f33130607..6eabbe4ae6d5 100644
--- a/daemon/admin_server.c
+++ b/daemon/admin_server.c
@@ -37,9 +37,9 @@
 VIR_LOG_INIT("daemon.admin_server");

 int
-adminDaemonListServers(virNetDaemonPtr dmn,
-                       virNetServerPtr **servers,
-                       unsigned int flags)
+adminConnectListServers(virNetDaemonPtr dmn,
+                        virNetServerPtr **servers,
+                        unsigned int flags)
 {
     int ret = -1;
     virNetServerPtr *srvs = NULL;
diff --git a/daemon/admin_server.h b/daemon/admin_server.h
index 606442c19f5f..b77653f6c384 100644
--- a/daemon/admin_server.h
+++ b/daemon/admin_server.h
@@ -26,8 +26,8 @@

 # include "rpc/virnetdaemon.h"

-int adminDaemonListServers(virNetDaemonPtr dmn,
-                           virNetServerPtr **servers,
-                           unsigned int flags);
+int adminConnectListServers(virNetDaemonPtr dmn,
+                            virNetServerPtr **servers,
+                            unsigned int flags);

 #endif /* __LIBVIRTD_ADMIN_SERVER_H__ */
diff --git a/po/POTFILES.in b/po/POTFILES.in
index ff207cbb03e7..171d2b1e1534 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -10,7 +10,6 @@ gnulib/lib/gai_strerror.c
 gnulib/lib/regcomp.c
 src/access/viraccessdriverpolkit.c
 src/access/viraccessmanager.c
-src/admin/admin_remote.c
 src/bhyve/bhyve_command.c
 src/bhyve/bhyve_device.c
 src/bhyve/bhyve_driver.c
diff --git a/src/admin/admin_protocol.x b/src/admin/admin_protocol.x
index 742ed2a89cd1..205bfe8f7a52 100644
--- a/src/admin/admin_protocol.x
+++ b/src/admin/admin_protocol.x
@@ -60,7 +60,7 @@ struct admin_connect_list_servers_args {
     unsigned int flags;
 };

-struct admin_connect_list_servers_ret {
+struct admin_connect_list_servers_ret { /* insert@1 */
     admin_nonnull_server servers<ADMIN_SERVER_LIST_MAX>;
     unsigned int ret;
 };
@@ -103,7 +103,7 @@ enum admin_procedure {
     ADMIN_PROC_CONNECT_GET_LIB_VERSION = 3,

     /**
-      * @generate: none
+      * @generate: both
       */
     ADMIN_PROC_CONNECT_LIST_SERVERS = 4
 };
diff --git a/src/admin/admin_remote.c b/src/admin/admin_remote.c
index 3745b9e7017a..21e0dd30c4bf 100644
--- a/src/admin/admin_remote.c
+++ b/src/admin/admin_remote.c
@@ -224,66 +224,3 @@ remoteAdminPrivNew(const char *sock_path)
     virObjectUnref(priv);
     return NULL;
 }
-
-static int
-remoteAdminConnectListServers(virAdmConnectPtr conn,
-                              virAdmServerPtr **servers,
-                              unsigned int flags)
-{
-    int rv = -1;
-    size_t i;
-    virAdmServerPtr *tmp_srvs = NULL;
-    remoteAdminPrivPtr priv = conn->privateData;
-    admin_connect_list_servers_args args;
-    admin_connect_list_servers_ret ret;
-
-    args.need_results = !!servers;
-    args.flags = flags;
-
-    memset(&ret, 0, sizeof(ret));
-    virObjectLock(priv);
-
-    if (call(conn,
-             0,
-             ADMIN_PROC_CONNECT_LIST_SERVERS,
-             (xdrproc_t) xdr_admin_connect_list_servers_args,
-             (char *) &args,
-             (xdrproc_t) xdr_admin_connect_list_servers_ret,
-             (char *) &ret) == -1)
-        goto done;
-
-    if (ret.servers.servers_len > ADMIN_SERVER_LIST_MAX) {
-        virReportError(VIR_ERR_RPC,
-                       _("Too many servers '%d' for limit '%d'"),
-                       ret.servers.servers_len, ADMIN_SERVER_LIST_MAX);
-        goto cleanup;
-    }
-
-    if (servers) {
-        if (VIR_ALLOC_N(tmp_srvs, ret.servers.servers_len + 1) < 0)
-            goto cleanup;
-
-        for (i = 0; i < ret.servers.servers_len; i++) {
-            tmp_srvs[i] = get_nonnull_server(conn, ret.servers.servers_val[i]);
-            if (!tmp_srvs[i])
-                goto cleanup;
-        }
-        *servers = tmp_srvs;
-        tmp_srvs = NULL;
-    }
-
-    rv = ret.ret;
-
- cleanup:
-    if (tmp_srvs) {
-        for (i = 0; i < ret.servers.servers_len; i++)
-            virObjectUnref(tmp_srvs[i]);
-        VIR_FREE(tmp_srvs);
-    }
-
-    xdr_free((xdrproc_t) xdr_admin_connect_list_servers_ret, (char *) &ret);
-
- done:
-    virObjectUnlock(priv);
-    return rv;
-}
-- 
2.7.2

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