]> xenbits.xensource.com Git - libvirt.git/commitdiff
virt-admin: Add warning when connection to default daemon fails
authorPeter Krempa <pkrempa@redhat.com>
Thu, 1 Feb 2024 09:40:41 +0000 (10:40 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 2 Feb 2024 15:06:15 +0000 (16:06 +0100)
The admin connection defaults to the system-wide 'libvirtd' daemon to
manage (libvirtd:///system). As we've now switched to modular daemons
this will not work for most users out of the box:

 $ virt-admin version
 error: Failed to connect to the admin server
 error: no valid connection
 error: Failed to connect socket to '/run/user/1000/libvirt/libvirt-admin-sock': No such file or directory

As we don't want to assume which daemon the user wants to manage in the
modular topology there's no reasonable default to pick.

Give a hint to the users to use the '-c' if the connection to the
default URI fails:

 $ virt-admin version
 NOTE: Connecting to default daemon. Specify daemon using '-c' (e.g. virtqemud:///system)
 error: Failed to connect to the admin server
 error: no valid connection
 error: Failed to connect socket to '/run/user/1000/libvirt/libvirt-admin-sock': No such file or directory

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
tools/virt-admin.c

index fa9304c7721f975264c019292b7a096f7e5f064c..aaf6edb9a9c465acdb40f687ffbae3682efe2b95 100644 (file)
@@ -102,6 +102,9 @@ vshAdmConnect(vshControl *ctl, unsigned int flags)
     priv->conn = virAdmConnectOpen(ctl->connname, flags);
 
     if (!priv->conn) {
+        if (!ctl->connname)
+            vshPrintExtra(ctl, "%s", _("NOTE: Connecting to default daemon. Specify daemon using '-c' (e.g. virtqemud:///system)\n"));
+
         if (priv->wantReconnect)
             vshError(ctl, "%s", _("Failed to reconnect to the admin server"));
         else