[libvirt] Supporting remote connections to QEMU session mode

Spencer Baugh catern at catern.com
Tue Jul 14 01:43:38 UTC 2015

Eric Blake <eblake at redhat.com> writes:
> On 07/03/2015 12:01 AM, sbaugh at catern.com wrote:
>> Has there been any thought given to supporting remote connections to
>> QEMU session instances in virt-manager?
>> (i.e. qemu+ssh://hostname/session?socket=path) Manually hacking in the
>> URI with dconf seems to mostly work, but (for example) I quickly
>> encountered a bug when creating a VM where virt-manager assumed the only
>> usable storage pool was my *local* homedir instead of the remote
>> homedir.
> Libvirt does not (yet) allow remote connections to qemu://host/session.
>  You'd first have to figure out how to patch libvirt to allow remote
> session connections; part of the problem is that with qemu:///system,
> there is a daemon running that is always listening for remote
> connections, but with qemu:///session, since libvirtd is only
> auto-started as needed, there is no easy way to guarantee that the
> remote machine is running a libvirtd process as the correct user.
>> virsh and other tools support these connections just fine.
> No, virsh does NOT support remote session connections, at least not
> intentionally.  If it works for you, it is a pure accident.

I'm not sure what you mean by "not support". Connecting to a
qemu+ssh://host/session?socket=path url works, and clearly some
thought has been put into it because if I leave off the socket argument,
I get this message:

@sbaugh at earth ~ $ virsh -c qemu+ssh://host/session
error: failed to connect to the hypervisor
error: Operation not supported: Connecting to session instance without
socket path is not supported by the ssh connection driver

which is created by this snippet of code:
            /* Right now we don't support default session connections */
            if (STREQ_NULLABLE(conn->uri->path, "/session")) {
                virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
                               _("Connecting to session instance without "
                                 "socket path is not supported by the libssh2 "
                                 "connection driver"));
                goto failed;

which certainly suggests to me that *non*-default session connections
are supported. No patching is necessary to allow remote session
connections, they are implicitly allowed. That if statement could easily
disable them, but chose instead to allow them when they are sufficiently
specified to actually work.

All that aside, it's obvious that not much attention has been paid to
making remote session connections work well even in core libvirt. Is
improving the support for them something that is interesting to the
libvirt developers? Would patches to improve the support be accepted?

Well, I guess virt-tools-list isn't the list to discuss that, so I've
also CC'd libvirt-list. An explanation of why I want to use remote
connections to QEMU session mode is in the description of this bug:

Spencer Baugh

More information about the libvir-list mailing list