[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

On Tue, Sep 09, 2014 at 03:40:48 +0000, Serge Hallyn wrote:
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.
This and several other issues with session mode are addressed by Martin's series: https://www.redhat.com/archives/libvir-list/2014-September/msg00374.html Jirka

Quoting Jiri Denemark (jdenemar@redhat.com):
On Tue, Sep 09, 2014 at 03:40:48 +0000, Serge Hallyn wrote:
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.
This and several other issues with session mode are addressed by Martin's series: https://www.redhat.com/archives/libvir-list/2014-September/msg00374.html
Oh, great, thanks.
participants (2)
-
Jiri Denemark
-
Serge Hallyn