From nobody Fri May 3 17:24:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1503067214492512.4864027360842; Fri, 18 Aug 2017 07:40:14 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D8531C047B93; Fri, 18 Aug 2017 14:40:11 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3914B7DE21; Fri, 18 Aug 2017 14:40:11 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9C6F14ED20; Fri, 18 Aug 2017 14:40:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7IEe9aW009674 for ; Fri, 18 Aug 2017 10:40:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5CB27692BD; Fri, 18 Aug 2017 14:40:09 +0000 (UTC) Received: from caroline.localdomain (unknown [10.43.2.67]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 309736A30A for ; Fri, 18 Aug 2017 14:40:07 +0000 (UTC) Received: from caroline.brq.redhat.com (caroline.brq.redhat.com [127.0.0.1]) by caroline.localdomain (Postfix) with ESMTP id 117B612004F for ; Fri, 18 Aug 2017 16:40:06 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D8531C047B93 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Martin Kletzander To: libvir-list@redhat.com Date: Fri, 18 Aug 2017 16:40:04 +0200 Message-Id: <7de9870f9f9cfefd5cf3234ca439687f09ded290.1503067204.git.mkletzan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] virsh: Honour --readonly with cmdConnect and no name X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Fri, 18 Aug 2017 14:40:12 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Martin Kletzander --- tools/virsh.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/virsh.c b/tools/virsh.c index 94bb7ff6c93a..9883e87df2b5 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 =3D false; virshControlPtr priv =3D ctl->privData; - bool ro =3D name ? readonly : priv->readonly; + + /* If the flag was not specified, then it depends on whether we are + * reconnecting to the default 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 =3D priv->readonly; =20 if (priv->conn) { int ret; @@ -233,7 +239,7 @@ virshReconnect(vshControl *ctl, const char *name, bool = readonly, bool force) "disconnect from the hypervisor")); } =20 - priv->conn =3D virshConnect(ctl, name ? name : ctl->connname, ro); + priv->conn =3D virshConnect(ctl, name ? name : ctl->connname, readonly= ); =20 if (!priv->conn) { if (disconnected) --=20 2.14.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list