[PATCH] virt-admin: Add warning when connection to default daemon fails

Peter Krempa posted 1 patch 2 months, 3 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/bc86d8da2872fe160180dac48ec619cdc1f9826e.1706801753.git.pkrempa@redhat.com
tools/virt-admin.c | 3 +++
1 file changed, 3 insertions(+)
[PATCH] virt-admin: Add warning when connection to default daemon fails
Posted by Peter Krempa 2 months, 3 weeks ago
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>
---
 tools/virt-admin.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/virt-admin.c b/tools/virt-admin.c
index fa9304c772..aaf6edb9a9 100644
--- a/tools/virt-admin.c
+++ b/tools/virt-admin.c
@@ -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
-- 
2.43.0
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org
Re: [PATCH] virt-admin: Add warning when connection to default daemon fails
Posted by Jonathon Jongsma 2 months, 3 weeks ago
On 2/1/24 9:35 AM, Peter Krempa wrote:
> 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>
> ---
>   tools/virt-admin.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/tools/virt-admin.c b/tools/virt-admin.c
> index fa9304c772..aaf6edb9a9 100644
> --- a/tools/virt-admin.c
> +++ b/tools/virt-admin.c
> @@ -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


Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org