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

[libvirt] [PATCH] virNetSocketNewConnectUNIX: create socket dir if needed



Since 1b807f92dbb617db5b9d551777d3026d8ff0903f, if ~/.cache
does not exist, 'virsh -c qemu:///session' fails, because
it attempts to bind to ~/.cache/libvirt/libvirt-sock.

Create the socket's directory if needed.

Signed-off-by: Serge Hallyn <serge hallyn ubuntu com>
---
 src/rpc/virnetsocket.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
index 586a0d7..14f8cca 100644
--- a/src/rpc/virnetsocket.c
+++ b/src/rpc/virnetsocket.c
@@ -598,6 +598,10 @@ int virNetSocketNewConnectUNIX(const char *path,
 
             if (pid == 0) {
                 umask(0077);
+                if (path[0] != '@') {
+                    if (virFileMakeParentPath(path) < 0)
+                        virReportSystemError(errno, "%s", _("Failed to create directory"));
+                }
                 if (bind(passfd, &remoteAddr.data.sa, remoteAddr.len) < 0)
                     _exit(EXIT_FAILURE);
 
-- 
2.1.0


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