virshCatchDisconnect: Don't probe connection URI

virsh already stores the connection URI in 'ctl->connname', use that
instead.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Peter Krempa 2023-12-14 17:13:08 +01:00
parent 06f6d76334
commit 4763f62a96

View File

@ -67,18 +67,13 @@ static int disconnected; /* we may have been disconnected */
* handler, just save the fact it was raised. * handler, just save the fact it was raised.
*/ */
static void static void
virshCatchDisconnect(virConnectPtr conn, virshCatchDisconnect(virConnectPtr conn G_GNUC_UNUSED,
int reason, int reason,
void *opaque) void *opaque)
{ {
if (reason != VIR_CONNECT_CLOSE_REASON_CLIENT) { if (reason != VIR_CONNECT_CLOSE_REASON_CLIENT) {
vshControl *ctl = opaque; vshControl *ctl = opaque;
const char *str = "unknown reason"; const char *str = "unknown reason";
virErrorPtr error;
g_autofree char *uri = NULL;
virErrorPreserveLast(&error);
uri = virConnectGetURI(conn);
switch ((virConnectCloseReason) reason) { switch ((virConnectCloseReason) reason) {
case VIR_CONNECT_CLOSE_REASON_ERROR: case VIR_CONNECT_CLOSE_REASON_ERROR:
@ -94,9 +89,8 @@ virshCatchDisconnect(virConnectPtr conn,
case VIR_CONNECT_CLOSE_REASON_LAST: case VIR_CONNECT_CLOSE_REASON_LAST:
break; break;
} }
vshError(ctl, _(str), NULLSTR(uri)); vshError(ctl, _(str), NULLSTR(ctl->connname));
virErrorRestore(&error);
disconnected++; disconnected++;
vshEventDone(ctl); vshEventDone(ctl);
} }