From: "Daniel P. Berrange" <berrange(a)redhat.com>
Currently the libvirt client can pass FDs to the server, but the
dispatch mechanism provides no way to return FDs back from the
server to the client. Tweak the dispatch code, such that if a
dispatcher returns '1', this indicates that it populated the
virNetMessagePtr with FDs to return
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/rpc/virnetserverprogram.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/src/rpc/virnetserverprogram.c b/src/rpc/virnetserverprogram.c
index 3ac3809..06b6325 100644
--- a/src/rpc/virnetserverprogram.c
+++ b/src/rpc/virnetserverprogram.c
@@ -431,17 +431,20 @@ virNetServerProgramDispatchCall(virNetServerProgramPtr prog,
rv = (dispatcher->func)(server, client, msg, &rerr, arg, ret);
/*
- * Clear out the FDs we got from the client, we don't
- * want to send them back !
+ * If rv == 1, this indicates the dispatch func has
+ * populated 'msg' with a list of FDs to return to
+ * the caller.
+ *
+ * Otherwise we must clear out the FDs we got from
+ * the client originally.
*
- * XXX we don't have a way to let dispatcher->func
- * return any FDs. Fortunately we don't need this
- * capability just yet
*/
- for (i = 0 ; i < msg->nfds ; i++)
- VIR_FORCE_CLOSE(msg->fds[i]);
- VIR_FREE(msg->fds);
- msg->nfds = 0;
+ if (rv != 1) {
+ for (i = 0 ; i < msg->nfds ; i++)
+ VIR_FORCE_CLOSE(msg->fds[i]);
+ VIR_FREE(msg->fds);
+ msg->nfds = 0;
+ }
xdr_free(dispatcher->arg_filter, arg);
--
1.7.11.7