libvirt/SOURCES/libvirt-virt-admin-Add-warn...

53 lines
2.1 KiB
Diff

From 44eeb458ace773226f08d0807fda964014004301 Mon Sep 17 00:00:00 2001
Message-ID: <44eeb458ace773226f08d0807fda964014004301.1707394627.git.jdenemar@redhat.com>
From: Peter Krempa <pkrempa@redhat.com>
Date: Thu, 1 Feb 2024 10:40:41 +0100
Subject: [PATCH] virt-admin: Add warning when connection to default daemon
fails
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>
(cherry picked from commit 442061583e9dc0e4e3bf314275979051345a4a93)
https://issues.redhat.com/browse/RHEL-23170
---
tools/virt-admin.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tools/virt-admin.c b/tools/virt-admin.c
index 1e22a3c8a9..70b6e4916f 100644
--- a/tools/virt-admin.c
+++ b/tools/virt-admin.c
@@ -108,6 +108,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