Re: [PATCH 6/8] Add client side support for FD passing

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

 



On 10/25/2011 10:03 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange"<berrange@xxxxxxxxxx>

Extend the RPC client code to allow file descriptors to be sent
to the server with calls, and received back with replies.

* src/remote/remote_driver.c: Stub extra args
* src/libvirt_private.syms, src/rpc/virnetclient.c,
   src/rpc/virnetclient.h, src/rpc/virnetclientprogram.c,
   src/rpc/virnetclientprogram.h: Extend APIs to allow
   FD passing
---
  src/libvirt_private.syms      |    4 +++
  src/remote/remote_driver.c    |    1 +
  src/rpc/virnetclient.c        |   25 +++++++++++++++++
  src/rpc/virnetclient.h        |    2 +
  src/rpc/virnetclientprogram.c |   58 +++++++++++++++++++++++++++++++++++++++-
  src/rpc/virnetclientprogram.h |    4 +++
  6 files changed, 92 insertions(+), 2 deletions(-)

      msg->header.serial = serial;
      msg->header.proc = proc;
+    msg->nfds = noutfds;
+    if (VIR_ALLOC_N(msg->fds, msg->nfds)<  0) {
+        virReportOOMError();
+        goto error;
+    }
+    for (i = 0 ; i<  msg->nfds ; i++) {
+        if ((msg->fds[i] = dup(outfds[i]))<  0) {
+            virReportSystemError(errno,
+                                 _("Cannot duplicate FD %d"),
+                                 outfds[i]);
+            goto error;
+        }
+        if (virSetInherit(msg->fds[i], false)<  0) {
+            virReportSystemError(errno,
+                                 _("Cannot set close-on-exec %d"),
+                                 msg->fds[i]);

That works, but has a slight race window when compared with gnulib's dup_cloexec (in "cloexec.h"), or fcntl(fd, F_DUPFD_CLOEXEC, 0). But it goes back to my comment earlier in the series that auditing the code for atomic cloexec support is a much bigger task for later, so I'm okay with this as-is for now.

ACK.

--
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

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