[libvirt] [PATCH v2 8/8] rpc: pass listen FD to the daemon being started

Martin Kletzander mkletzan at redhat.com
Tue Jul 22 12:18:37 UTC 2014


On Wed, Jul 16, 2014 at 08:30:02PM +0200, Martin Kletzander wrote:
>This eliminates the need for active waiting.
>
>Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=927369
>
>Signed-off-by: Martin Kletzander <mkletzan at redhat.com>
>---
> src/rpc/virnetsocket.c | 58 +++++++++++++++++++++++++++++++++-----------------
> 1 file changed, 39 insertions(+), 19 deletions(-)
>
>diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
>index a94b2bc..c00209c 100644
>--- a/src/rpc/virnetsocket.c
>+++ b/src/rpc/virnetsocket.c
[...]
>@@ -569,28 +572,45 @@ int virNetSocketNewConnectUNIX(const char *path,
[...]
>+        /*
>+         * We cannot do the umask() trick here because that's not
>+         * thread-safe.  fchmod(), however, is not guaranteed to work on
>+         * some BSD favours, but *should* work on Linux before the socket
>+         * is bound.  POSIX says the behaviour of fchmod() called on
>+         * socket is unspecified, though.
>+         */
>+        if (fchmod(passfd, 0700) < 0) {
>+            virReportSystemError(errno, "%s",
>+                                 _("Failed to change permissions on socket"));
>+            goto error;
>         }
>

I've finally found a way out of this.  We can fork() and in the child
do only umask() and bind().  It shouldn't be a problem that fstat()
returns different mode for the socket than stat(), it should work
everywhere and thanks to the fact that we do this pretty rarely and
copy-on-write pages there shouldn't be significant impact.

Is this acceptable?

Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140722/cef6d5f6/attachment-0001.sig>


More information about the libvir-list mailing list