On Tue, Nov 28, 2023 at 02:29:20PM +0100, Peter Krempa wrote:
On Tue, Nov 28, 2023 at 13:22:47 +0000, Daniel P. Berrangé wrote:
> On Tue, Nov 28, 2023 at 01:02:40PM +0100, Martin Kletzander wrote:
> > Before this patch users might be confused with the error when no daemon
> > nor systemd socket unit is running due to the error message being a bit
> > vague when running as root with no URI:
> >
> > # virsh list
> > error: failed to connect to the hypervisor
> > error: Operation not supported: Cannot use direct socket mode if no
> > URI is set
> >
> > Instead of merely suggesting to start any daemon, also give a hint as to
> > what socket we have tried looking up:
> >
> > # virsh list
> > error: failed to connect to the hypervisor
> > error: Operation not supported: Cannot connect to
> > '/var/run/libvirt/virtqemud-sock' and no URI is set, is any virt
> > daemon or systemd socket unit started?
>
> As Peter points out, this is a misleading message because it is
> arbitrarily reporting the first compiled in driver, which may
> be no resemblance to what the user was expecting to run. I think
Exactly. E.g. on Fedora and other distros which enable most features
you'd get:
error: Operation not supported: Cannot connect to
'/var/run/libvirt/virtxend-sock' and no URI is set, is any virt daemon or systemd
socket unit started?
And running xen is not what most users want to do when they install
libvirt.
How do you know when there is no URI set? Maybe they really want to
connect to a different host. We don't say that QEMU is the default for
some reason. If there is something most users want, then we could
rearrange the order of the drivers that were tried.
What I think is that users who install libvirt and then immediately run
virsh define or something similar as non-root user probably also do not
want the session daemon to be started. I just don't know we can
accommodate everyone. But...
> we should not include the sock path here, but we could include
> the sock *directory*, as that would help diagnose when someone
> built with the wrong install prefix, eg
>
> "No active daemon socket found in /var/run/libvirt, and no
> URI is set. Is any libvirt daemon or socket unit started ?"
This sounds much better. I also don't think we should be putting any
command examples here as suggested by Rich as there isn't a good default
value we could use because of exactly the same reason.
...this looks like a best effort. If this is fine with everyone, then
I'll change it to this, including RUNSTATEDIR / libvirt. Of course that
might still not work in other situations, e.g. when readonly connection
is being made, but no readonly socket is there, etc., but that's a very
corner case situation anyway.
So let me know if that's fine with you all.
Thanks,
Martin