mirror of https://gitee.com/openkylin/libvirt.git
admin: Generate ConnectListServers dispatch helpers
Since we have the opportunity now, let's save some precious code lines. Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
6de2ef5d35
commit
d949280c72
|
@ -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"
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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__ */
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue