提交 9c9de4e6 编写于 作者: P Peter Krempa

remote: implement remote protocol for virConnectListAllDomains()

This patch wires up the RPC protocol handlers for
virConnectListAllDomains(). The RPC generator has no support for the way
how virConnectListAllDomains() returns the results so the handler code
had to be done manually.

The new api is handled by REMOTE_PROC_CONNECT_LIST_ALL_DOMAINS, with
number 273 and marked with high priority.
上级 bd34cc8c
......@@ -995,6 +995,60 @@ no_memory:
goto cleanup;
}
static int
remoteDispatchConnectListAllDomains(virNetServerPtr server ATTRIBUTE_UNUSED,
virNetServerClientPtr client,
virNetMessagePtr msg ATTRIBUTE_UNUSED,
virNetMessageErrorPtr rerr,
remote_connect_list_all_domains_args *args,
remote_connect_list_all_domains_ret *ret)
{
virDomainPtr *doms = NULL;
int ndomains = 0;
int i;
int rv = -1;
struct daemonClientPrivate *priv = virNetServerClientGetPrivateData(client);
if (!priv->conn) {
virNetError(VIR_ERR_INTERNAL_ERROR, "%s", _("connection not open"));
goto cleanup;
}
if ((ndomains = virConnectListAllDomains(priv->conn,
args->need_results ? &doms : NULL,
args->flags)) < 0)
goto cleanup;
if (doms && ndomains) {
if (VIR_ALLOC_N(ret->domains.domains_val, ndomains) < 0) {
virReportOOMError();
goto cleanup;
}
ret->domains.domains_len = ndomains;
for (i = 0; i < ndomains; i++)
make_nonnull_domain(ret->domains.domains_val + i, doms[i]);
} else {
ret->domains.domains_len = 0;
ret->domains.domains_val = NULL;
}
ret->ret = ndomains;
rv = 0;
cleanup:
if (rv < 0)
virNetMessageSaveError(rerr);
if (doms) {
for (i = 0; i < ndomains; i++)
virDomainFree(doms[i]);
VIR_FREE(doms);
}
return rv;
}
static int
remoteDispatchDomainGetSchedulerParametersFlags(virNetServerPtr server ATTRIBUTE_UNUSED,
virNetServerClientPtr client ATTRIBUTE_UNUSED,
......
......@@ -1265,6 +1265,69 @@ done:
return rv;
}
static int
remoteConnectListAllDomains(virConnectPtr conn,
virDomainPtr **domains,
unsigned int flags)
{
int rv = -1;
int i;
virDomainPtr *doms = NULL;
remote_connect_list_all_domains_args args;
remote_connect_list_all_domains_ret ret;
struct private_data *priv = conn->privateData;
remoteDriverLock(priv);
args.need_results = !!domains;
args.flags = flags;
memset(&ret, 0, sizeof(ret));
if (call(conn,
priv,
0,
REMOTE_PROC_CONNECT_LIST_ALL_DOMAINS,
(xdrproc_t) xdr_remote_connect_list_all_domains_args,
(char *) &args,
(xdrproc_t) xdr_remote_connect_list_all_domains_ret,
(char *) &ret) == -1)
goto done;
if (domains) {
if (VIR_ALLOC_N(doms, ret.domains.domains_len + 1) < 0) {
virReportOOMError();
goto cleanup;
}
for (i = 0; i < ret.domains.domains_len; i++) {
doms[i] = get_nonnull_domain(conn, ret.domains.domains_val[i]);
if (!doms[i]) {
virReportOOMError();
goto cleanup;
}
}
*domains = doms;
doms = NULL;
}
rv = ret.ret;
cleanup:
if (doms) {
for (i = 0; i < ret.domains.domains_len; i++)
if (doms[i])
virDomainFree(doms[i]);
VIR_FREE(doms);
}
xdr_free((xdrproc_t) xdr_remote_connect_list_all_domains_ret, (char *) &ret);
done:
remoteDriverUnlock(priv);
return rv;
}
/* Helper to free typed parameters. */
static void
remoteFreeTypedParameters(remote_typed_param *args_params_val,
......@@ -4963,6 +5026,7 @@ static virDriver remote_driver = {
.getCapabilities = remoteGetCapabilities, /* 0.3.0 */
.listDomains = remoteListDomains, /* 0.3.0 */
.numOfDomains = remoteNumOfDomains, /* 0.3.0 */
.listAllDomains = remoteConnectListAllDomains, /* 0.9.13 */
.domainCreateXML = remoteDomainCreateXML, /* 0.3.0 */
.domainLookupByID = remoteDomainLookupByID, /* 0.3.0 */
.domainLookupByUUID = remoteDomainLookupByUUID, /* 0.3.0 */
......
......@@ -2481,6 +2481,16 @@ struct remote_domain_get_disk_errors_ret {
int nerrors;
};
struct remote_connect_list_all_domains_args {
int need_results;
unsigned int flags;
};
struct remote_connect_list_all_domains_ret {
remote_nonnull_domain domains<>;
unsigned int ret;
};
/*----- Protocol. -----*/
......@@ -2803,7 +2813,8 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_EVENT_PMSUSPEND = 270, /* autogen autogen */
REMOTE_PROC_DOMAIN_SNAPSHOT_IS_CURRENT = 271, /* autogen autogen */
REMOTE_PROC_DOMAIN_SNAPSHOT_HAS_METADATA = 272 /* autogen autogen */
REMOTE_PROC_DOMAIN_SNAPSHOT_HAS_METADATA = 272, /* autogen autogen */
REMOTE_PROC_CONNECT_LIST_ALL_DOMAINS = 273 /* skipgen skipgen priority:high */
/*
* Notice how the entries are grouped in sets of 10 ?
......
......@@ -1935,6 +1935,17 @@ struct remote_domain_get_disk_errors_ret {
} errors;
int nerrors;
};
struct remote_connect_list_all_domains_args {
int need_results;
u_int flags;
};
struct remote_connect_list_all_domains_ret {
struct {
u_int domains_len;
remote_nonnull_domain * domains_val;
} domains;
u_int ret;
};
enum remote_procedure {
REMOTE_PROC_OPEN = 1,
REMOTE_PROC_CLOSE = 2,
......@@ -2208,4 +2219,5 @@ enum remote_procedure {
REMOTE_PROC_DOMAIN_EVENT_PMSUSPEND = 270,
REMOTE_PROC_DOMAIN_SNAPSHOT_IS_CURRENT = 271,
REMOTE_PROC_DOMAIN_SNAPSHOT_HAS_METADATA = 272,
REMOTE_PROC_CONNECT_LIST_ALL_DOMAINS = 273,
};
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册