On Tue, Nov 28, 2023 at 01:00:53PM +0000, Richard W.M. Jones 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?This is definitely much better, but can we suggest the actual command here?
I don't think so. It would be different based on distributions, what the users want to really do (especially when there is no URI set for the command or in libvirt.conf) and I had a patch that constructed a long error message, listing all the tried sockets, but that looked like a pure overkill. I added "is any virt daemon or systemd socket unit started" in order to avoid anything more complicated. I think that's enough of a suggestion for an error message, with debugging turned on all the sockets are listed in the order they are tried.
An alternative might be to refer to a libvirt wiki page which describes how to start the libvirt daemon(s) after installing libvirt. This seems to be a common problem, but I can't find any libvirt.org page about it. There is https://libvirt.org/daemons.html but my eyes glaze over reading it. https://wiki.libvirt.org/The_daemon_cannot_be_started.html is close, but not quite the same problem.
Well, we can add some kbase page saying "you need to start a daemon if you want to use libvirt right after installation". If that seems appropriate (to be honest, it does not, at least for me), I suggest someone with a less bias against users who do not know they should start a daemon when error message asks them if any daemon is running, should od it. I would most probably not phrase it in a complimentary way.
Rich.Resolves: https://issues.redhat.com/browse/RHEL-700 Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx> --- src/remote/remote_sockets.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/remote/remote_sockets.c b/src/remote/remote_sockets.c index c21970cd31e7..0c0e31e4eb78 100644 --- a/src/remote/remote_sockets.c +++ b/src/remote/remote_sockets.c @@ -311,6 +311,7 @@ remoteGetUNIXSocket(remoteDriverTransport transport, g_autofree char *daemon_name = NULL; g_autofree char *direct_sock_name = NULL; g_autofree char *legacy_sock_name = NULL; + g_autofree char *default_socket = NULL; #ifdef REMOTE_DRIVER_AUTOSTART_DIRECT g_autofree char *guessdriver = NULL; #endif @@ -345,7 +346,7 @@ remoteGetUNIXSocket(remoteDriverTransport transport, } else { if (remoteProbeSystemDriverFromSocket(flags & REMOTE_DRIVER_OPEN_RO, &guessdriver, - NULL) < 0) + &default_socket) < 0) return NULL; } driver = guessdriver; @@ -404,8 +405,14 @@ remoteGetUNIXSocket(remoteDriverTransport transport, } if (!direct_sock_name) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - _("Cannot use direct socket mode if no URI is set")); + if (default_socket) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, + _("Cannot connect to '%1$s' and no URI is set, is any virt daemon or systemd socket unit started?"), + default_socket); + } else { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("Cannot use direct socket mode if no URI is set")); + } return NULL; } -- 2.43.0 _______________________________________________ Devel mailing list -- devel@xxxxxxxxxxxxxxxxx To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org
Attachment:
signature.asc
Description: PGP signature
_______________________________________________ Devel mailing list -- devel@xxxxxxxxxxxxxxxxx To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx