Re: [PATCH 4/8] Add APIs for virNetSocket for sending/receiving file descriptors

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

 



On 10/21/2011 06:55 AM, Daniel P. Berrange wrote:
From: "Daniel P. Berrange"<berrange@xxxxxxxxxx>

Add APIs to the virNetSocket object, to allow file descriptors
to be send/received over UNIX domain socket connections

s/send/sent/


* src/rpc/virnetsocket.c, src/rpc/virnetsocket.h,
   src/libvirt_private.syms: Add APIs for FD send/recv
---
  examples/systemtap/rpc-monitor.stp |   10 ++++++
  src/libvirt_private.syms           |    4 ++
  src/probes.d                       |    2 +
  src/rpc/virnetsocket.c             |   62 ++++++++++++++++++++++++++++++++++++
  src/rpc/virnetsocket.h             |    5 +++
  5 files changed, 83 insertions(+), 0 deletions(-)

diff --git a/examples/systemtap/rpc-monitor.stp b/examples/systemtap/rpc-monitor.stp
index f246571..b76564f 100755
--- a/examples/systemtap/rpc-monitor.stp
+++ b/examples/systemtap/rpc-monitor.stp
@@ -155,3 +155,13 @@ probe libvirt.rpc.server_client_free {
       delete serverSocks[pid(), client];
     }
  }
+
+
+probe libvirt.rpc.socket_send_fd {
+      print_ts(sprintf("=   %-16p send fd=%d", sock, fd));
+}
+
+
+probe libvirt.rpc.socket_recv_fd {
+      print_ts(sprintf("=   %-16p recv fd=%d", sock, fd));
+}
\ No newline at end of file

We should fix that, and supply a trailing newline.

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index dedbd16..0648e49 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -1244,6 +1244,10 @@ virNetSocketDupFD;
  virNetSocketFree;
  virNetSocketGetFD;
  virNetSocketListen;
+virNetSocketIsLocal;

Did we really forget to export this one earlier?

+virNetSocketHasPassFD;
+virNetSocketSendFD;
+virNetSocketRecvFD;

Sorting?

+int virNetSocketRecvFD(virNetSocketPtr sock)
+{
+    int ret = -1;
+    if (!virNetSocketHasPassFD(sock)) {
+        virNetError(VIR_ERR_INTERNAL_ERROR,
+                    _("Sending file descriptors is not supported on this socket"));

s/Sending/Receiving/

+        return -1;
+    }
+    virMutexLock(&sock->lock);
+
+    if ((ret = recvfd(sock->fd, 0))<  0) {

Should we s/0/O_CLOEXEC/ for flags, so the received socket has the cloexec bit already set?

ACK with nits fixed.

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