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
libvirt as non-root is broken in Rawhide: error: Failed to connect socket to ...
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: libvirt (Show other bugs)
rawhide
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Libvirt Maintainers
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-07-22 04:46 EDT by Richard W.M. Jones
Modified: 2012-08-11 16:21 EDT (History)
11 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-08-11 16:21:39 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Output from LIBVIRT_DEBUG=1 (14.69 KB, text/x-log)
2012-07-22 04:46 EDT, Richard W.M. Jones
no flags Details

  None (edit)
Description Richard W.M. Jones 2012-07-22 04:46:16 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
directory)

Version-Release number of selected component (if applicable):

libvirt-0.9.13-1.fc18.x86_64

How reproducible:

100%

Steps to Reproduce:
1. As non-root, run any libvirt command.
Comment 1 Osier Yang 2012-07-23 05:24:57 EDT
This was fixed upstream.

commit ea9509b9e8ef9f3100a829858e8a67a90c1b1d5b
Author: Osier Yang <jyang@redhat.com>
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.
Comment 2 Richard W.M. Jones 2012-07-23 05:51:23 EDT
http://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=ea9509b9e8ef9f3100a829858e8a67a90c1b1d5b

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.
Comment 3 Daniel Berrange 2012-07-23 06:09:37 EDT
Yeah, I don't think it is that commit. It is more likely to be this one

commit efe6c8021146d046846ead5b5efc9828d97c1ceb
Author: Christophe Fergeau <cfergeau@redhat.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
    set.
    
    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.
Comment 4 Richard W.M. Jones 2012-07-23 09:22:51 EDT
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:

http://koji.fedoraproject.org/koji/taskinfo?taskID=4322980

The patch is upstream and can be removed when libvirt 0.9.14
is added to Rawhide.
Comment 5 Cole Robinson 2012-08-11 16:21:39 EDT
In rawhide now.

Note You need to log in before you can comment on or make changes to this bug.