From 47df89f01ebda39d5fffdb2f8f82f93d602ead8b Mon Sep 17 00:00:00 2001
From: Serge Hallyn <serge.hallyn@ubuntu.com>
Date: Mon, 8 Sep 2014 22:35:33 -0500
Subject: [PATCH 1/1] 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(+)

Index: libvirt-1.2.12/src/rpc/virnetsocket.c
===================================================================
--- libvirt-1.2.12.orig/src/rpc/virnetsocket.c	2015-02-03 13:21:49.837736090 -0500
+++ libvirt-1.2.12/src/rpc/virnetsocket.c	2015-02-03 13:22:59.269733914 -0500
@@ -631,6 +631,10 @@
 
         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);
 
