Red Hat Bugzilla – Bug 842114
libvirt as non-root is broken in Rawhide: error: Failed to connect socket to '/run/user/1000/libvirt/libvirt-sock': No such file or directory
Last modified: 2012-08-11 16:21:39 EDT
Created attachment 599573 [details]
Output from LIBVIRT_DEBUG=1
Description of problem:
$ virsh list
error: Failed to reconnect to the hypervisor
error: no valid connection
error: Failed to connect socket to '/run/user/1000/libvirt/libvirt-sock': No such file or directory
(/run/user/1000 exists, but there is no /run/user/1000/libvirt
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. As non-root, run any libvirt command.
This was fixed upstream.
Author: Osier Yang <firstname.lastname@example.org>
Date: Tue Jul 10 19:24:04 2012 +0800
virsh: Ensure the parents of the readline history path exists
Instead of changing the existed virFileMakePath to accept mode
argument and modifying a pile of its uses, this patch introduces
virFileMakePathWithMode, and use it instead of mkdir() to create
the readline history dir.
I don't understand how this patch would make any difference
to the bug described. Note that this bug has nothing to do
with 'virsh'. It happens even with direct API access to libvirt.
In addition, I tried to create the empty directory /run/user/1000/libvirt
but that made no difference.
Yeah, I don't think it is that commit. It is more likely to be this one
Author: Christophe Fergeau <email@example.com>
Date: Thu Jul 12 13:52:36 2012 +0200
Fix daemon auto-spawning
Commit 32a9aac switched libvirt to use the XDG base directories
to locate most of its data/config. In particular, the per-user socket
for qemu:///session is now stored in the XDG runtime directory.
This directory is located by looking at the XDG_RUNTIME_DIR environment
variable, with a fallback to ~/.cache/libvirt if this variable is not
When the daemon is autospawned because a client application wants
to use qemu:///session, the daemon is ran in a clean environment
which does not contain XDG_RUNTIME_DIR. It will create its socket
in ~/.cache/libvirt. If the client application has XDG_RUNTIME_DIR
set, it will not look for the socket in the fallback place, and will
fail to connect to the autospawned daemon.
This patch adds XDG_RUNTIME_DIR to the daemon environment before
auto-starting it. I've done this in virNetSocketForkDaemon rather
than in virCommandAddEnvPassCommon as I wasn't sure we want to pass
these variables to other commands libvirt spawns. XDG_CACHE_HOME
and XDG_CONFIG_HOME are also added to the daemon env as it makes use
of those as well.
Thanks. Confirmed locally that adding the patch that
Dan mentions in comment 3 fixes this.
I have pushed a build of libvirt which includes this patch:
The patch is upstream and can be removed when libvirt 0.9.14
is added to Rawhide.
In rawhide now.