Re: [libvirt] [PATCH v2 4/8] daemon: support passing FDs from the calling process
On Thu, Jul 17, 2014 at 09:40:12AM +0100, Daniel P. Berrange wrote: On Wed, Jul 16, 2014 at 08:29:58PM +0200, Martin Kletzander wrote: First FD is the RW unix socket to listen on, second one (if applicable) is the RO unix socket. Signed-off-by: Martin Kletzander --- daemon/libvirtd.c | 45 +++-- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c index 4c926b3..d20aeae 100644 --- a/daemon/libvirtd.c +++ b/daemon/libvirtd.c @@ -56,6 +56,7 @@ #include "virstring.h" #include "locking/lock_manager.h" #include "viraccessmanager.h" +#include "virutil.h" #ifdef WITH_DRIVER_MODULES # include "driver.h" @@ -476,11 +477,19 @@ static int daemonSetupNetworking(virNetServerPtr srv, int unix_sock_ro_mask = 0; int unix_sock_rw_mask = 0; +unsigned int cur_fd = STDIN_FILENO + 1; Shouldn't that be STDERR not STDIN since the passed FDs start at 3 not 1. Oh, yes, I tried that with the value "3" and changed it right before sending, my bad. +unsigned int nfds = virGetListenFDs(); + Regards, Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| signature.asc Description: Digital signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v2 4/8] daemon: support passing FDs from the calling process
On Wed, Jul 16, 2014 at 08:29:58PM +0200, Martin Kletzander wrote: > First FD is the RW unix socket to listen on, second one (if > applicable) is the RO unix socket. > > Signed-off-by: Martin Kletzander > --- > daemon/libvirtd.c | 45 +++-- > 1 file changed, 27 insertions(+), 18 deletions(-) > > diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c > index 4c926b3..d20aeae 100644 > --- a/daemon/libvirtd.c > +++ b/daemon/libvirtd.c > @@ -56,6 +56,7 @@ > #include "virstring.h" > #include "locking/lock_manager.h" > #include "viraccessmanager.h" > +#include "virutil.h" > > #ifdef WITH_DRIVER_MODULES > # include "driver.h" > @@ -476,11 +477,19 @@ static int daemonSetupNetworking(virNetServerPtr srv, > int unix_sock_ro_mask = 0; > int unix_sock_rw_mask = 0; > > +unsigned int cur_fd = STDIN_FILENO + 1; Shouldn't that be STDERR not STDIN since the passed FDs start at 3 not 1. > +unsigned int nfds = virGetListenFDs(); > + Regards, Daniel -- |: http://berrange.com -o-http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :| -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH v2 4/8] daemon: support passing FDs from the calling process
First FD is the RW unix socket to listen on, second one (if applicable) is the RO unix socket. Signed-off-by: Martin Kletzander --- daemon/libvirtd.c | 45 +++-- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c index 4c926b3..d20aeae 100644 --- a/daemon/libvirtd.c +++ b/daemon/libvirtd.c @@ -56,6 +56,7 @@ #include "virstring.h" #include "locking/lock_manager.h" #include "viraccessmanager.h" +#include "virutil.h" #ifdef WITH_DRIVER_MODULES # include "driver.h" @@ -476,11 +477,19 @@ static int daemonSetupNetworking(virNetServerPtr srv, int unix_sock_ro_mask = 0; int unix_sock_rw_mask = 0; +unsigned int cur_fd = STDIN_FILENO + 1; +unsigned int nfds = virGetListenFDs(); + if (config->unix_sock_group) { if (virGetGroupID(config->unix_sock_group, &unix_sock_gid) < 0) return -1; } +if (nfds && nfds > ((int)!!sock_path + (int)!!sock_path_ro)) { +VIR_ERROR(_("Too many (%u) FDs passed from caller"), nfds); +return -1; +} + if (virStrToLong_i(config->unix_sock_ro_perms, NULL, 8, &unix_sock_ro_mask) != 0) { VIR_ERROR(_("Failed to parse mode '%s'"), config->unix_sock_ro_perms); goto error; @@ -491,30 +500,30 @@ static int daemonSetupNetworking(virNetServerPtr srv, goto error; } -VIR_DEBUG("Registering unix socket %s", sock_path); -if (!(svc = virNetServerServiceNewUNIX(sock_path, - unix_sock_rw_mask, - unix_sock_gid, - config->auth_unix_rw, +if (!(svc = virNetServerServiceNewFDOrUNIX(sock_path, + unix_sock_rw_mask, + unix_sock_gid, + config->auth_unix_rw, #if WITH_GNUTLS - NULL, + NULL, #endif - false, - config->max_queued_clients, - config->max_client_requests))) + false, + config->max_queued_clients, + config->max_client_requests, + nfds, &cur_fd))) goto error; if (sock_path_ro) { -VIR_DEBUG("Registering unix socket %s", sock_path_ro); -if (!(svcRO = virNetServerServiceNewUNIX(sock_path_ro, - unix_sock_ro_mask, - unix_sock_gid, - config->auth_unix_ro, +if (!(svcRO = virNetServerServiceNewFDOrUNIX(sock_path_ro, + unix_sock_ro_mask, + unix_sock_gid, + config->auth_unix_ro, #if WITH_GNUTLS - NULL, + NULL, #endif - true, - config->max_queued_clients, - config->max_client_requests))) + true, + config->max_queued_clients, + config->max_client_requests, + nfds, &cur_fd))) goto error; } -- 2.0.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list