From: Martin Kletzander Date: Fri, 18 Aug 2017 14:35:23 +0000 (+0200) Subject: virsh: Honour --readonly with cmdConnect and no name X-Git-Tag: v3.7.0-rc1~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=622ea8b6cfe8d2d171064549b9f9c842b1fc38a8;p=thirdparty%2Flibvirt.git virsh: Honour --readonly with cmdConnect and no name Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1436042 Signed-off-by: Martin Kletzander --- diff --git a/tools/virsh.c b/tools/virsh.c index 94bb7ff6c9..527c1a4181 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -218,7 +218,13 @@ virshReconnect(vshControl *ctl, const char *name, bool readonly, bool force) { bool connected = false; virshControlPtr priv = ctl->privData; - bool ro = name ? readonly : priv->readonly; + + /* If the flag was not specified, then it depends on whether we are + * reconnecting to the current URI (in which case we want to keep the + * readonly flag as it was) or to a specified URI in which case it + * should stay false */ + if (!readonly && !name) + readonly = priv->readonly; if (priv->conn) { int ret; @@ -233,7 +239,7 @@ virshReconnect(vshControl *ctl, const char *name, bool readonly, bool force) "disconnect from the hypervisor")); } - priv->conn = virshConnect(ctl, name ? name : ctl->connname, ro); + priv->conn = virshConnect(ctl, name ? name : ctl->connname, readonly); if (!priv->conn) { if (disconnected)