[libvirt] [PATCH] Fix check for socket existance / daemon spawn

From: "Daniel P. Berrange" <berrange@redhat.com> When you try to connect to a socket in the abstract namespace, the error will be ECONNREFUSED for a non-listening daemon. With the non-abstract namespace though, you instead get ENOENT. Add a check for this extra errno when auto-spawning the daemon Signed-off-by: Daniel P. Berrange <berrange@redhat.com> --- src/rpc/virnetsocket.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c index fa16d31..0b32ffe 100644 --- a/src/rpc/virnetsocket.c +++ b/src/rpc/virnetsocket.c @@ -502,7 +502,11 @@ int virNetSocketNewConnectUNIX(const char *path, retry: if (connect(fd, &remoteAddr.data.sa, remoteAddr.len) < 0) { - if (errno == ECONNREFUSED && spawnDaemon && retries < 20) { + if ((errno == ECONNREFUSED || + errno == ENOENT) && + spawnDaemon && retries < 20) { + VIR_DEBUG("Connection refused for %s, trying to spawn %s", + path, binary); if (retries == 0 && virNetSocketForkDaemon(binary) < 0) goto error; -- 1.7.10.1

On Fri, May 25, 2012 at 4:55 PM, Daniel P. Berrange <berrange@redhat.com> wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
When you try to connect to a socket in the abstract namespace, the error will be ECONNREFUSED for a non-listening daemon. With the non-abstract namespace though, you instead get ENOENT. Add a check for this extra errno when auto-spawning the daemon
Looks simple and good. ACK (if my ACK to libvirt core counts). -- Regards, Zeeshan Ali (Khattak) FSF member#5124

On 05/25/2012 08:07 AM, Zeeshan Ali (Khattak) wrote:
On Fri, May 25, 2012 at 4:55 PM, Daniel P. Berrange <berrange@redhat.com> wrote:
From: "Daniel P. Berrange" <berrange@redhat.com>
When you try to connect to a socket in the abstract namespace, the error will be ECONNREFUSED for a non-listening daemon. With the non-abstract namespace though, you instead get ENOENT. Add a check for this extra errno when auto-spawning the daemon
Looks simple and good. ACK (if my ACK to libvirt core counts).
Yes it does - we need all the good reviewers we can get :) -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (3)
-
Daniel P. Berrange
-
Eric Blake
-
Zeeshan Ali (Khattak)