From: Julio Faracco Date: Mon, 27 Nov 2017 00:18:11 +0000 (-0200) Subject: virsh: Fix virsh prompt when connection changes to readonly mode. X-Git-Tag: v3.10.0-rc1~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=13d45b0dc25ed99a9da0704d01cf21c8fe99f951;p=thirdparty%2Flibvirt.git virsh: Fix virsh prompt when connection changes to readonly mode. This commit fixes the virsh prompt when reconnection to the same URI is called: `virsh # connect --readonly` (Reconnect). The problem is happening because the code is considering URI (name) as a mandatory parameter to change the prompt. This commit remove the assignment into `priv->readonly` from `if (name)` conditional. Before: virsh # uri qemu:///system virsh # connect --readonly virsh # After: virsh # uri qemu:///system virsh # connect --readonly virsh > Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1507737 Signed-off-by: Julio Faracco Reviewed-by: Erik Skultety --- diff --git a/tools/virsh.c b/tools/virsh.c index d1789f03ad..89a2bea10c 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -251,8 +251,10 @@ virshReconnect(vshControl *ctl, const char *name, bool readonly, bool force) if (name) { VIR_FREE(ctl->connname); ctl->connname = vshStrdup(ctl, name); - priv->readonly = readonly; } + + priv->readonly = readonly; + if (virConnectRegisterCloseCallback(priv->conn, virshCatchDisconnect, ctl, NULL) < 0) vshError(ctl, "%s", _("Unable to register disconnect callback"));