f4e752
From efe6c8021146d046846ead5b5efc9828d97c1ceb Mon Sep 17 00:00:00 2001
f4e752
From: Christophe Fergeau <cfergeau@redhat.com>
f4e752
Date: Thu, 12 Jul 2012 13:52:36 +0200
f4e752
Subject: [PATCH] Fix daemon auto-spawning
f4e752
f4e752
Commit 32a9aac switched libvirt to use the XDG base directories
f4e752
to locate most of its data/config. In particular, the per-user socket
f4e752
for qemu:///session is now stored in the XDG runtime directory.
f4e752
This directory is located by looking at the XDG_RUNTIME_DIR environment
f4e752
variable, with a fallback to ~/.cache/libvirt if this variable is not
f4e752
set.
f4e752
f4e752
When the daemon is autospawned because a client application wants
f4e752
to use qemu:///session, the daemon is ran in a clean environment
f4e752
which does not contain XDG_RUNTIME_DIR. It will create its socket
f4e752
in ~/.cache/libvirt. If the client application has XDG_RUNTIME_DIR
f4e752
set, it will not look for the socket in the fallback place, and will
f4e752
fail to connect to the autospawned daemon.
f4e752
f4e752
This patch adds XDG_RUNTIME_DIR to the daemon environment before
f4e752
auto-starting it. I've done this in virNetSocketForkDaemon rather
f4e752
than in virCommandAddEnvPassCommon as I wasn't sure we want to pass
f4e752
these variables to other commands libvirt spawns. XDG_CACHE_HOME
f4e752
and XDG_CONFIG_HOME are also added to the daemon env as it makes use
f4e752
of those as well.
f4e752
---
f4e752
 src/rpc/virnetsocket.c |    3 +++
f4e752
 1 file changed, 3 insertions(+)
f4e752
f4e752
diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
f4e752
index 0b32ffe..08dfbb0 100644
f4e752
--- a/src/rpc/virnetsocket.c
f4e752
+++ b/src/rpc/virnetsocket.c
f4e752
@@ -97,6 +97,9 @@ static int virNetSocketForkDaemon(const char *binary)
f4e752
                                              NULL);
f4e752
 
f4e752
     virCommandAddEnvPassCommon(cmd);
f4e752
+    virCommandAddEnvPass(cmd, "XDG_CACHE_HOME");
f4e752
+    virCommandAddEnvPass(cmd, "XDG_CONFIG_HOME");
f4e752
+    virCommandAddEnvPass(cmd, "XDG_RUNTIME_DIR");
f4e752
     virCommandClearCaps(cmd);
f4e752
     virCommandDaemonize(cmd);
f4e752
     ret = virCommandRun(cmd, NULL);
f4e752
-- 
f4e752
1.7.10.4
f4e752