mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-09 01:18:00 +03:00
list: Implement RPC calls for virConnectListAllNWFilters
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.
This commit is contained in:
parent
6498f76e31
commit
3f47ff8bb5
@ -4375,6 +4375,60 @@ cleanup:
|
||||
return rv;
|
||||
}
|
||||
|
||||
static int
|
||||
remoteDispatchConnectListAllNWFilters(virNetServerPtr server ATTRIBUTE_UNUSED,
|
||||
virNetServerClientPtr client,
|
||||
virNetMessagePtr msg ATTRIBUTE_UNUSED,
|
||||
virNetMessageErrorPtr rerr,
|
||||
remote_connect_list_all_nwfilters_args *args,
|
||||
remote_connect_list_all_nwfilters_ret *ret)
|
||||
{
|
||||
virNWFilterPtr *filters = NULL;
|
||||
int nfilters = 0;
|
||||
int i;
|
||||
int rv = -1;
|
||||
struct daemonClientPrivate *priv = virNetServerClientGetPrivateData(client);
|
||||
|
||||
if (!priv->conn) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if ((nfilters = virConnectListAllNWFilters(priv->conn,
|
||||
args->need_results ? &filters : NULL,
|
||||
args->flags)) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (filters && nfilters) {
|
||||
if (VIR_ALLOC_N(ret->filters.filters_val, nfilters) < 0) {
|
||||
virReportOOMError();
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
ret->filters.filters_len = nfilters;
|
||||
|
||||
for (i = 0; i < nfilters; i++)
|
||||
make_nonnull_nwfilter(ret->filters.filters_val + i, filters[i]);
|
||||
} else {
|
||||
ret->filters.filters_len = 0;
|
||||
ret->filters.filters_val = NULL;
|
||||
}
|
||||
|
||||
ret->ret = nfilters;
|
||||
|
||||
rv = 0;
|
||||
|
||||
cleanup:
|
||||
if (rv < 0)
|
||||
virNetMessageSaveError(rerr);
|
||||
if (filters) {
|
||||
for (i = 0; i < nfilters; i++)
|
||||
virNWFilterFree(filters[i]);
|
||||
VIR_FREE(filters);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
/*----- Helpers. -----*/
|
||||
|
||||
/* get_nonnull_domain and get_nonnull_network turn an on-wire
|
||||
|
@ -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]);
|
||||
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;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
@ -6021,6 +6083,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 */
|
||||
};
|
||||
|
||||
|
||||
|
@ -2609,6 +2609,16 @@ struct remote_connect_list_all_node_devices_ret {
|
||||
unsigned int ret;
|
||||
};
|
||||
|
||||
struct remote_connect_list_all_nwfilters_args {
|
||||
int need_results;
|
||||
unsigned int flags;
|
||||
};
|
||||
|
||||
struct remote_connect_list_all_nwfilters_ret {
|
||||
remote_nonnull_nwfilter filters<>;
|
||||
unsigned int ret;
|
||||
};
|
||||
|
||||
/*----- Protocol. -----*/
|
||||
|
||||
/* Define the program number, protocol version and procedure numbers here. */
|
||||
@ -2944,7 +2954,8 @@ enum remote_procedure {
|
||||
REMOTE_PROC_STORAGE_POOL_LIST_ALL_VOLUMES = 282, /* skipgen skipgen priority:high */
|
||||
REMOTE_PROC_CONNECT_LIST_ALL_NETWORKS = 283, /* skipgen skipgen priority:high */
|
||||
REMOTE_PROC_CONNECT_LIST_ALL_INTERFACES = 284, /* skipgen skipgen priority:high */
|
||||
REMOTE_PROC_CONNECT_LIST_ALL_NODE_DEVICES = 285 /* skipgen skipgen priority:high */
|
||||
REMOTE_PROC_CONNECT_LIST_ALL_NODE_DEVICES = 285, /* skipgen skipgen priority:high */
|
||||
REMOTE_PROC_CONNECT_LIST_ALL_NWFILTERS = 286 /* skipgen skipgen priority:high */
|
||||
|
||||
/*
|
||||
* Notice how the entries are grouped in sets of 10 ?
|
||||
|
@ -2067,6 +2067,17 @@ struct remote_connect_list_all_node_devices_ret {
|
||||
} devices;
|
||||
u_int ret;
|
||||
};
|
||||
struct remote_connect_list_all_nwfilters_args {
|
||||
int need_results;
|
||||
u_int flags;
|
||||
};
|
||||
struct remote_connect_list_all_nwfilters_ret {
|
||||
struct {
|
||||
u_int filters_len;
|
||||
remote_nonnull_nwfilter * filters_val;
|
||||
} filters;
|
||||
u_int ret;
|
||||
};
|
||||
enum remote_procedure {
|
||||
REMOTE_PROC_OPEN = 1,
|
||||
REMOTE_PROC_CLOSE = 2,
|
||||
@ -2353,4 +2364,5 @@ enum remote_procedure {
|
||||
REMOTE_PROC_CONNECT_LIST_ALL_NETWORKS = 283,
|
||||
REMOTE_PROC_CONNECT_LIST_ALL_INTERFACES = 284,
|
||||
REMOTE_PROC_CONNECT_LIST_ALL_NODE_DEVICES = 285,
|
||||
REMOTE_PROC_CONNECT_LIST_ALL_NWFILTERS = 286,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user